FAUST compiler  0.9.9.6b8
Defines | Functions | Variables
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().


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

{
    if (isNil(pl))                  return cons ( cons(key,val), nil );
    if (isBefore(key, left(hd(pl)))) return cons(cons(key,val), pl);
    return cons ( hd(pl), addKey( tl(pl), key, val ));
}

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

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

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.

{
    fprintf(stderr, "ERROR : %s (%p)\n", s, t);
}
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().

{
    if (isNil(pl))                  return false;
    if (left(hd(pl)) == key)        { val = right(hd(pl)); return true; }
    if (isBefore(left(hd(pl)),key)) return findKey (tl(pl), key, val); 
    return false;
}

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

{
    Tree    flabel, content, item;
    if (!isUiFolder(folder, flabel, content))   { fprintf(stderr, "ERROR in getFolder : not a folder\n"); }
    if (findKey(content, ilabel, item)) {
        return item;
    } else {
        return nil;
    }
}

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

{ 
    // before comparing replace (type . label) by label
    if (isList(k1)) { k1 = tl(k1); }
    if (isList(k2)) { k2 = tl(k2); }
    
    //fprintf(stderr, "isBefore("); print(k1, stderr); fprintf(stderr,", "); print(k2, stderr); fprintf(stderr,")\n"); 
    Sym s1, s2;
    if (!isSym(k1->node(), &s1)) {
        ERROR("the node of the tree is not a symbol", k1);
    }
    if (!isSym(k2->node(), &s2)) {
        ERROR("the node of the tree is not a symbol", k2);
    }
    
    //fprintf (stderr, "strcmp(\"%s\", \"%s\") = %d\n", name(s1), name(s2), strcmp(name(s1), name(s2)));
    return strcmp(name(s1), name(s2)) < 0;
}

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

{ return isTree(t, UIFOLDER);                   }

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

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

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

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

{
    if (isNil(path)) {
        return elem;
    } else {
        return putFolder(uiFolder(hd(path)), makeSubFolderChain(tl(path),elem));
    }
} 

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

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

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

{
    if (isNil(path)) {
        //return putFolder(folder, item);
        return addToFolder(folder, item);
    } else {
        Tree subfolder = getFolder(folder, hd(path));
        if (isUiFolder(subfolder)) {
            return putFolder(folder, putSubFolder(subfolder, tl(path), item));
        } else {
            return putFolder(folder, makeSubFolderChain(path, item));
        }
    }
}

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

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

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

{
    if (isNil(pl))                  return cons ( cons(key,val), nil );
    if (left(hd(pl)) == key)        return cons ( cons(key,val), tl(pl) );
    if (isBefore(left(hd(pl)),key)) return cons ( hd(pl), updateKey( tl(pl), key, val ));
    return cons(cons(key,val), pl);
}

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.