better test coverage
[protos/libecoli.git] / lib / ecoli_node.h
index ac88033..f0b0281 100644 (file)
@@ -99,7 +99,6 @@ typedef int (*ec_node_parse_t)(const struct ec_node *node,
 typedef int (*ec_node_complete_t)(const struct ec_node *node,
                                struct ec_completed *completed_state,
                                const struct ec_strvec *strvec);
-typedef size_t (*ec_node_get_max_parse_len_t)(const struct ec_node *node);
 typedef const char * (*ec_node_desc_t)(const struct ec_node *);
 typedef int (*ec_node_init_priv_t)(struct ec_node *);
 typedef void (*ec_node_free_priv_t)(struct ec_node *);
@@ -113,7 +112,6 @@ struct ec_node_type {
        ec_node_build_t build;           /**< (Re)build the node */
        ec_node_parse_t parse;
        ec_node_complete_t complete;
-       ec_node_get_max_parse_len_t get_max_parse_len;
        ec_node_desc_t desc;
        size_t size;
        ec_node_init_priv_t init_priv;
@@ -146,17 +144,14 @@ struct ec_node_type *ec_node_type_lookup(const char *name);
  */
 void ec_node_type_dump(FILE *out);
 
-TAILQ_HEAD(ec_node_list, ec_node);
-
 struct ec_node {
        const struct ec_node_type *type;
        char *id;
        char *desc;
        struct ec_keyval *attrs;
        unsigned int refcnt;
-
-       TAILQ_ENTRY(ec_node) next;
-       struct ec_node_list children;
+       struct ec_node **children;   /* array of children */
+       size_t n_children;           /* number of children in the array */
 };
 
 /* create a new node when the type is known, typically called from the node
@@ -169,12 +164,11 @@ struct ec_node *ec_node(const char *typename, const char *id);
 struct ec_node *ec_node_clone(struct ec_node *node);
 void ec_node_free(struct ec_node *node);
 
-/**
- * Get the max len of strvec that can be parsed by this node
- *
- * If there is no maximum, return SIZE_MAX.
- */
-size_t ec_node_get_max_parse_len(const struct ec_node *node);
+size_t ec_node_get_children_count(const struct ec_node *node);
+struct ec_node *
+ec_node_get_child(const struct ec_node *node, size_t i);
+int ec_node_add_child(struct ec_node *node, struct ec_node *child);
+int ec_node_del_child(struct ec_node *node, struct ec_node *child);
 
 /* XXX add more accessors */
 struct ec_keyval *ec_node_attrs(const struct ec_node *node);