FAUST compiler  0.9.9.6b8
Macros | Functions | Variables
uitree.cpp File Reference
#include "uitree.hh"
Include dependency graph for uitree.cpp:

Go to the source code of this file.

Macros

#define ERROR(s, t)   error(s,t); exit(1)
 

Functions

static Tree makeSubFolderChain (Tree path, Tree elem)
 
static Tree putFolder (Tree folder, Tree item)
 
static Tree getFolder (Tree folder, Tree ilabel)
 
static void error (const char *s, Tree t)
 
static bool isBefore (Tree k1, Tree k2)
 
static bool findKey (Tree pl, Tree key, Tree &val)
 
static Tree updateKey (Tree pl, Tree key, Tree val)
 
static Tree addKey (Tree pl, Tree key, Tree val)
 Like updateKey but allow multiple items with same key. More...
 
Tree uiFolder (Tree label, Tree elements)
 
bool isUiFolder (Tree t)
 
bool isUiFolder (Tree t, Tree &label, Tree &elements)
 
Tree uiWidget (Tree label, Tree varname, Tree sig)
 
bool isUiWidget (Tree t, Tree &label, Tree &varname, Tree &sig)
 
Tree addToFolder (Tree folder, Tree item)
 
Tree putSubFolder (Tree folder, Tree path, Tree item)
 

Variables

Sym UIFOLDER = symbol ("uiFolder")
 
Sym UIWIDGET = symbol ("uiWidget")
 

Macro Definition Documentation

#define ERROR (   s,
 
)    error(s,t); exit(1)

Definition at line 38 of file uitree.cpp.

Referenced by isBefore().

Function Documentation

static Tree addKey ( Tree  pl,
Tree  key,
Tree  val 
)
static

Like updateKey but allow multiple items with same key.

Definition at line 111 of file uitree.cpp.

References cons(), hd(), isBefore(), isNil(), left(), nil, and tl().

Referenced by addToFolder().

112 {
113  if (isNil(pl)) return cons ( cons(key,val), nil );
114  if (isBefore(key, left(hd(pl)))) return cons(cons(key,val), pl);
115  return cons ( hd(pl), addKey( tl(pl), key, val ));
116 }
Tree cons(Tree a, Tree b)
Definition: list.hh:124
Tree left(Tree t)
Definition: list.hh:170
Tree hd(Tree l)
Definition: list.hh:133
static bool isBefore(Tree k1, Tree k2)
Definition: uitree.cpp:72
bool isNil(Tree l)
Definition: list.hh:137
Tree nil
Definition: list.cpp:116
static Tree addKey(Tree pl, Tree key, Tree val)
Like updateKey but allow multiple items with same key.
Definition: uitree.cpp:111
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Tree addToFolder ( Tree  folder,
Tree  item 
)

Definition at line 155 of file uitree.cpp.

References addKey(), isUiFolder(), uiFolder(), and uiLabel().

Referenced by putSubFolder().

156 {
157  Tree label, content;
158 
159  if ( ! isUiFolder(folder, label, content)) { fprintf(stderr, "ERROR in addFolder : not a folder\n"); }
160  return uiFolder(label, addKey(content, uiLabel(item), item));
161 }
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
Tree uiLabel(Tree t)
Definition: uitree.hh:38
Tree uiFolder(Tree label, Tree elements)
Definition: uitree.cpp:135
bool isUiFolder(Tree t)
Definition: uitree.cpp:136
static Tree addKey(Tree pl, Tree key, Tree val)
Like updateKey but allow multiple items with same key.
Definition: uitree.cpp:111

Here is the call graph for this function:

Here is the caller graph for this function:

static void error ( const char *  s,
Tree  t 
)
static

Definition at line 33 of file uitree.cpp.

34 {
35  fprintf(stderr, "ERROR : %s (%p)\n", s, t);
36 }
static bool findKey ( Tree  pl,
Tree  key,
Tree val 
)
static

Definition at line 92 of file uitree.cpp.

References hd(), isBefore(), isNil(), left(), right(), and tl().

Referenced by getFolder().

93 {
94  if (isNil(pl)) return false;
95  if (left(hd(pl)) == key) { val = right(hd(pl)); return true; }
96  if (isBefore(left(hd(pl)),key)) return findKey (tl(pl), key, val);
97  return false;
98 }
Tree left(Tree t)
Definition: list.hh:170
Tree hd(Tree l)
Definition: list.hh:133
static bool isBefore(Tree k1, Tree k2)
Definition: uitree.cpp:72
Tree right(Tree t)
Definition: list.hh:171
bool isNil(Tree l)
Definition: list.hh:137
static bool findKey(Tree pl, Tree key, Tree &val)
Definition: uitree.cpp:92
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Tree getFolder ( Tree  folder,
Tree  ilabel 
)
static

Definition at line 164 of file uitree.cpp.

References findKey(), isUiFolder(), and nil.

Referenced by putSubFolder().

165 {
166  Tree flabel, content, item;
167  if (!isUiFolder(folder, flabel, content)) { fprintf(stderr, "ERROR in getFolder : not a folder\n"); }
168  if (findKey(content, ilabel, item)) {
169  return item;
170  } else {
171  return nil;
172  }
173 }
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
static bool findKey(Tree pl, Tree key, Tree &val)
Definition: uitree.cpp:92
Tree nil
Definition: list.cpp:116
bool isUiFolder(Tree t)
Definition: uitree.cpp:136

Here is the call graph for this function:

Here is the caller graph for this function:

static bool isBefore ( Tree  k1,
Tree  k2 
)
static

Definition at line 72 of file uitree.cpp.

References ERROR, isList(), isSym(), name(), CTree::node(), and tl().

Referenced by addKey(), findKey(), and updateKey().

73 {
74  // before comparing replace (type . label) by label
75  if (isList(k1)) { k1 = tl(k1); }
76  if (isList(k2)) { k2 = tl(k2); }
77 
78  //fprintf(stderr, "isBefore("); print(k1, stderr); fprintf(stderr,", "); print(k2, stderr); fprintf(stderr,")\n");
79  Sym s1, s2;
80  if (!isSym(k1->node(), &s1)) {
81  ERROR("the node of the tree is not a symbol", k1);
82  }
83  if (!isSym(k2->node(), &s2)) {
84  ERROR("the node of the tree is not a symbol", k2);
85  }
86 
87  //fprintf (stderr, "strcmp(\"%s\", \"%s\") = %d\n", name(s1), name(s2), strcmp(name(s1), name(s2)));
88  return strcmp(name(s1), name(s2)) < 0;
89 }
const Node & node() const
return the content of the tree
Definition: tree.hh:143
bool isList(Tree l)
Definition: list.hh:138
#define ERROR(s, t)
Definition: uitree.cpp:38
bool isSym(const Node &n)
Definition: node.hh:199
const char * name(Symbol *sym)
Returns the name of a symbol.
Definition: symbol.hh:98
Symbols are unique objects with a name stored in a hash table.
Definition: symbol.hh:53
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

bool isUiFolder ( Tree  t)

Definition at line 136 of file uitree.cpp.

References isTree().

Referenced by Description::addGroup(), addToFolder(), Compiler::generateMacroInterfaceTree(), Compiler::generateUserInterfaceTree(), getFolder(), Compiler::prepareUserInterfaceTree(), putFolder(), and putSubFolder().

136 { return isTree(t, UIFOLDER); }
Sym UIFOLDER
Definition: uitree.cpp:134
bool isTree(const Tree &t, const Node &n)
Definition: tree.cpp:305

Here is the call graph for this function:

Here is the caller graph for this function:

bool isUiFolder ( Tree  t,
Tree label,
Tree elements 
)

Definition at line 137 of file uitree.cpp.

References isTree().

137 { return isTree(t, UIFOLDER, label, elements); }
Sym UIFOLDER
Definition: uitree.cpp:134
bool isTree(const Tree &t, const Node &n)
Definition: tree.cpp:305

Here is the call graph for this function:

bool isUiWidget ( Tree  t,
Tree label,
Tree varname,
Tree sig 
)

Definition at line 141 of file uitree.cpp.

References isTree().

Referenced by Description::addGroup(), Compiler::generateMacroInterfaceTree(), and Compiler::generateUserInterfaceTree().

141 { return isTree(t, UIWIDGET, label, varname, sig); }
Sym UIWIDGET
Definition: uitree.cpp:139
bool isTree(const Tree &t, const Node &n)
Definition: tree.cpp:305

Here is the call graph for this function:

Here is the caller graph for this function:

Tree makeSubFolderChain ( Tree  path,
Tree  elem 
)
static

Definition at line 176 of file uitree.cpp.

References hd(), isNil(), putFolder(), tl(), and uiFolder().

Referenced by putSubFolder().

177 {
178  if (isNil(path)) {
179  return elem;
180  } else {
181  return putFolder(uiFolder(hd(path)), makeSubFolderChain(tl(path),elem));
182  }
183 }
static Tree putFolder(Tree folder, Tree item)
Definition: uitree.cpp:146
Tree hd(Tree l)
Definition: list.hh:133
bool isNil(Tree l)
Definition: list.hh:137
Tree uiFolder(Tree label, Tree elements)
Definition: uitree.cpp:135
static Tree makeSubFolderChain(Tree path, Tree elem)
Definition: uitree.cpp:176
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Tree putFolder ( Tree  folder,
Tree  item 
)
static

Definition at line 146 of file uitree.cpp.

References isUiFolder(), uiFolder(), uiLabel(), and updateKey().

Referenced by makeSubFolderChain(), and putSubFolder().

147 {
148  Tree label, content;
149 
150  if ( ! isUiFolder(folder, label, content)) { fprintf(stderr, "ERROR in addFolder : not a folder\n"); }
151  return uiFolder(label, updateKey(content, uiLabel(item), item));
152 }
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
Tree uiLabel(Tree t)
Definition: uitree.hh:38
Tree uiFolder(Tree label, Tree elements)
Definition: uitree.cpp:135
static Tree updateKey(Tree pl, Tree key, Tree val)
Definition: uitree.cpp:100
bool isUiFolder(Tree t)
Definition: uitree.cpp:136

Here is the call graph for this function:

Here is the caller graph for this function:

Tree putSubFolder ( Tree  folder,
Tree  path,
Tree  item 
)

Definition at line 186 of file uitree.cpp.

References addToFolder(), getFolder(), hd(), isNil(), isUiFolder(), makeSubFolderChain(), putFolder(), putSubFolder(), and tl().

Referenced by Compiler::addUIWidget(), and putSubFolder().

187 {
188  if (isNil(path)) {
189  //return putFolder(folder, item);
190  return addToFolder(folder, item);
191  } else {
192  Tree subfolder = getFolder(folder, hd(path));
193  if (isUiFolder(subfolder)) {
194  return putFolder(folder, putSubFolder(subfolder, tl(path), item));
195  } else {
196  return putFolder(folder, makeSubFolderChain(path, item));
197  }
198  }
199 }
static Tree getFolder(Tree folder, Tree ilabel)
Definition: uitree.cpp:164
static Tree putFolder(Tree folder, Tree item)
Definition: uitree.cpp:146
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
Tree hd(Tree l)
Definition: list.hh:133
bool isNil(Tree l)
Definition: list.hh:137
static Tree makeSubFolderChain(Tree path, Tree elem)
Definition: uitree.cpp:176
Tree putSubFolder(Tree folder, Tree path, Tree item)
Definition: uitree.cpp:186
bool isUiFolder(Tree t)
Definition: uitree.cpp:136
Tree tl(Tree l)
Definition: list.hh:134
Tree addToFolder(Tree folder, Tree item)
Definition: uitree.cpp:155

Here is the call graph for this function:

Here is the caller graph for this function:

Tree uiFolder ( Tree  label,
Tree  elements 
)

Definition at line 135 of file uitree.cpp.

References tree().

Referenced by addToFolder(), makeSubFolderChain(), and putFolder().

135 { return tree(UIFOLDER, label, elements); }
Sym UIFOLDER
Definition: uitree.cpp:134
Tree tree(const Node &n)
Definition: tree.hh:186

Here is the call graph for this function:

Here is the caller graph for this function:

Tree uiWidget ( Tree  label,
Tree  varname,
Tree  sig 
)

Definition at line 140 of file uitree.cpp.

References tree().

Referenced by ScalarCompiler::generateButton(), ScalarCompiler::generateCheckbox(), ScalarCompiler::generateHBargraph(), ScalarCompiler::generateHSlider(), ScalarCompiler::generateNumEntry(), ScalarCompiler::generateVBargraph(), and ScalarCompiler::generateVSlider().

140 { return tree(UIWIDGET, label, varname, sig); }
Sym UIWIDGET
Definition: uitree.cpp:139
Tree tree(const Node &n)
Definition: tree.hh:186

Here is the call graph for this function:

Here is the caller graph for this function:

static Tree updateKey ( Tree  pl,
Tree  key,
Tree  val 
)
static

Definition at line 100 of file uitree.cpp.

References cons(), hd(), isBefore(), isNil(), left(), nil, and tl().

Referenced by putFolder().

101 {
102  if (isNil(pl)) return cons ( cons(key,val), nil );
103  if (left(hd(pl)) == key) return cons ( cons(key,val), tl(pl) );
104  if (isBefore(left(hd(pl)),key)) return cons ( hd(pl), updateKey( tl(pl), key, val ));
105  return cons(cons(key,val), pl);
106 }
Tree cons(Tree a, Tree b)
Definition: list.hh:124
Tree left(Tree t)
Definition: list.hh:170
Tree hd(Tree l)
Definition: list.hh:133
static bool isBefore(Tree k1, Tree k2)
Definition: uitree.cpp:72
bool isNil(Tree l)
Definition: list.hh:137
static Tree updateKey(Tree pl, Tree key, Tree val)
Definition: uitree.cpp:100
Tree nil
Definition: list.cpp:116
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

Sym UIFOLDER = symbol ("uiFolder")

Definition at line 134 of file uitree.cpp.

Sym UIWIDGET = symbol ("uiWidget")

Definition at line 139 of file uitree.cpp.