#include <HashVector.h>
#include <TupleSchema.h>
+#include <Binding.h>
/**
* A BindingTable is a chain of \ref HashVector "HashVectors" of
* Binding items that associate a (char*) name with a (void*) value.
*/
-typedef struct _BindingTable {
- HashVector table;
- struct _BindingTable *next;
-} BindingTable;
+typedef HashVector/*<Binding>*/ BindingTable;
/**
- * \brief Allocate a new \ref BindingTable and chain it to the one given.
+ * \brief Allocate a new \ref BindingTable.
*
* \returns the allocated \ref bandingtable.
*
* \related BindingTable
*/
-extern BindingTable *BindingTable_create(BindingTable *next);
+extern BindingTable *BindingTable_create();
/**
- * \brief Reclaim a \ref BindingTable with all its bindings and return
- * its chained.
+ * \brief Reclaim a \ref BindingTable with all its bindings.
*
* \param bt is the \ref BindingTable to reclaim.
*
- * \returns the chained \ref BindingTable.
- *
* \related BindingTable
*/
-extern BindingTable *BindingTable_release(BindingTable *bt);
+extern void BindingTable_release(BindingTable *bt);
/**
* \brief Set a Binding in a \ref BindingTable.
* \note Binding names are equal or not by means of strcmp, and each
* name has a at most single Binding.
*
+ * The name and the value are held as given with all memory management
+ * the callers responsibility. This function will however create new
+ * Binding objects and reclaim the old ones as needed.
+ *
* A value of \b 0 indicates "unbound".
*
* \related BindingTable
*
* \param name is the Binding variable name.
*
- * \param value is the Binding value.
+ * \returns the value of the found Binding, or \b 0 if none is found.
*
* \note Binding names are equal or not by means of strcmp, and each
* name has a at most single Binding.
*
- * This function scan's the \ref BindingTable chain for the first
- * assignment, if any, of the name. Note that a name can be made
- * unbound on top of being bound by setting it to \b 0.
+ * \note Not also that a name can be made unbound on top of being
+ * bound by setting it to \b 0.
*
* \related BindingTable
*/
*
* \param bt is the BindingTable concerned.
*
- * \param arity is the tuple arity.
- *
* \param t is the tuple of (char*) names to dereference.
*/
-void BindingTable_deref(BindingTable *bt,int arity,Tuple *t);
+extern void BindingTable_deref(BindingTable *bt,Tuple *t);
/**
- * \brief Unify two named bindings with option equal-value callback.
+ * \brief Set values for names, optionally unbinding names as well.
*
- * \param bt is the first BindingTable concerned.
- *
- * \param n1 is the first Binding name.
+ * \param bt is the bindingtable concerned.
*
- * \param n2 is the second Binding name.
+ * \param nm is the Tuple of names to bind.
*
- * \param eq is the optional equal-value callback that returns 0 if
- * the given values are equal.
+ * \param vs is the Tuple of values.
*
- * This function updates the top \ref BindingTable by assigning n1 or
- * n2 to any value the other has (in the chain) unless they have
- * different values (in the chain). If both are unassigned, then
- * neither get reassigned in the to both BindingTable/
+ * \param all is a flag to assign all (1) or only non-zero (0) values.
*
- * \related BindingTable
+ * \note The values tuple must be as wide as the names tuple.
*/
-extern int BindingTable_unify(
- BindingTable *bt,char *n1,char *n2,int (*eq)(void*,void*));
+extern void BindingTable_set_all(BindingTable *bt,Tuple *nm,Tuple *vs,int all);
#endif