uitree.cpp File Reference

#include "uitree.hh"
Include dependency graph for uitree.cpp:

Go to the source code of this file.

Defines

#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.
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")

Define Documentation

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

Definition at line 38 of file uitree.cpp.

Referenced by isBefore(), tree2double(), tree2float(), tree2int(), tree2ptr(), and tree2str().


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().

00112 {
00113     if (isNil(pl))                  return cons ( cons(key,val), nil );
00114     if (isBefore(key, left(hd(pl)))) return cons(cons(key,val), pl);
00115     return cons ( hd(pl), addKey( tl(pl), key, val ));
00116 }

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().

00156 {
00157     Tree    label, content;
00158     
00159     if ( ! isUiFolder(folder, label, content)) { fprintf(stderr, "ERROR in addFolder : not a folder\n"); }
00160     return uiFolder(label, addKey(content, uiLabel(item), item));
00161 }

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.

00034 {
00035     fprintf(stderr, "ERROR : %s (%p)\n", s, t);
00036 }

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().

00093 {
00094     if (isNil(pl))                  return false;
00095     if (left(hd(pl)) == key)        { val = right(hd(pl)); return true; }
00096     if (isBefore(left(hd(pl)),key)) return findKey (tl(pl), key, val); 
00097     return false;
00098 }

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().

00165 {
00166     Tree    flabel, content, item;
00167     if (!isUiFolder(folder, flabel, content))   { fprintf(stderr, "ERROR in getFolder : not a folder\n"); }
00168     if (findKey(content, ilabel, item)) {
00169         return item;
00170     } else {
00171         return nil;
00172     }
00173 }

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().

00073 { 
00074     // before comparing replace (type . label) by label
00075     if (isList(k1)) { k1 = tl(k1); }
00076     if (isList(k2)) { k2 = tl(k2); }
00077     
00078     //fprintf(stderr, "isBefore("); print(k1, stderr); fprintf(stderr,", "); print(k2, stderr); fprintf(stderr,")\n"); 
00079     Sym s1, s2;
00080     if (!isSym(k1->node(), &s1)) {
00081         ERROR("the node of the tree is not a symbol", k1);
00082     }
00083     if (!isSym(k2->node(), &s2)) {
00084         ERROR("the node of the tree is not a symbol", k2);
00085     }
00086     
00087     //fprintf (stderr, "strcmp(\"%s\", \"%s\") = %d\n", name(s1), name(s2), strcmp(name(s1), name(s2)));
00088     return strcmp(name(s1), name(s2)) < 0;
00089 }

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().

00137 { return isTree(t, UIFOLDER, label, elements);  }

Here is the call 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().

00136 { return isTree(t, UIFOLDER);                   }

Here is the call graph for this function:

Here is the caller 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().

00141 { return isTree(t, UIWIDGET, label, varname, sig); }

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().

00177 {
00178     if (isNil(path)) {
00179         return elem;
00180     } else {
00181         return putFolder(uiFolder(hd(path)), makeSubFolderChain(tl(path),elem));
00182     }
00183 } 

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().

00147 {
00148     Tree    label, content;
00149     
00150     if ( ! isUiFolder(folder, label, content)) { fprintf(stderr, "ERROR in addFolder : not a folder\n"); }
00151     return uiFolder(label, updateKey(content, uiLabel(item), item));
00152 }

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().

00187 {
00188     if (isNil(path)) {
00189         //return putFolder(folder, item);
00190         return addToFolder(folder, item);
00191     } else {
00192         Tree subfolder = getFolder(folder, hd(path));
00193         if (isUiFolder(subfolder)) {
00194             return putFolder(folder, putSubFolder(subfolder, tl(path), item));
00195         } else {
00196             return putFolder(folder, makeSubFolderChain(path, item));
00197         }
00198     }
00199 }

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().

00135 { return tree(UIFOLDER, label, elements);       }

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().

00140 { return tree(UIWIDGET, label, varname, sig); }

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().

00101 {
00102     if (isNil(pl))                  return cons ( cons(key,val), nil );
00103     if (left(hd(pl)) == key)        return cons ( cons(key,val), tl(pl) );
00104     if (isBefore(left(hd(pl)),key)) return cons ( hd(pl), updateKey( tl(pl), key, val ));
00105     return cons(cons(key,val), pl);
00106 }

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.

Generated on Thu Jul 15 15:47:28 2010 for FAUST compiler by  doxygen 1.6.3