X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=include%2Fecoli_node.h;h=0557dea7f1c6eb4759dd1fb5673cce3ad40b6c5d;hb=984760622f2c8472fd2667e24bcceb543bdb1aff;hp=45f3e74aa1d58f7984249d6ebba72cf758273e9c;hpb=18d03456d96f7a086a2ccc82ce97fcf056848d90;p=protos%2Flibecoli.git diff --git a/include/ecoli_node.h b/include/ecoli_node.h index 45f3e74..0557dea 100644 --- a/include/ecoli_node.h +++ b/include/ecoli_node.h @@ -3,10 +3,13 @@ */ /** - * Interface to manage the ecoli nodes. + * @defgroup grammar_tree Grammar Tree + * @{ * - * A node is a main structure of the ecoli library, used to define how - * to match and complete the input tokens. A node is a generic object + * @brief Libecoli grammar nodes. + * + * The grammar node is a main structure of the ecoli library, used to define + * how to match and complete the input tokens. A node is a generic object * that implements: * - a parse(node, input) method: check if an input matches * - a complete(node, input) method: return possible completions for @@ -46,15 +49,16 @@ #include #include +/** + * Node has no identifier. + */ #define EC_NO_ID "no-id" -#define EC_NODE_ENDLIST ((void *)1) - struct ec_node; -struct ec_parse; +struct ec_pnode; struct ec_comp; struct ec_strvec; -struct ec_keyval; +struct ec_dict; struct ec_config; struct ec_config_schema; @@ -73,10 +77,10 @@ TAILQ_HEAD(ec_node_type_list, ec_node_type); typedef int (*ec_node_set_config_t)(struct ec_node *node, const struct ec_config *config); -typedef int (*ec_node_parse_t)(const struct ec_node *node, - struct ec_parse *state, +typedef int (*ec_parse_t)(const struct ec_node *node, + struct ec_pnode *state, const struct ec_strvec *strvec); -typedef int (*ec_node_complete_t)(const struct ec_node *node, +typedef int (*ec_complete_t)(const struct ec_node *node, struct ec_comp *comp_state, const struct ec_strvec *strvec); typedef const char * (*ec_node_desc_t)(const struct ec_node *); @@ -96,8 +100,8 @@ struct ec_node_type { * (.type = EC_CONFIG_TYPE_NONE). */ const struct ec_config_schema *schema; ec_node_set_config_t set_config; /* validate/ack a config change */ - ec_node_parse_t parse; - ec_node_complete_t complete; + ec_parse_t parse; + ec_complete_t complete; ec_node_desc_t desc; size_t size; ec_node_init_priv_t init_priv; @@ -152,20 +156,6 @@ enum ec_node_free_state { EC_NODE_FREE_STATE_FREEING, }; -struct ec_node { - const struct ec_node_type *type; - struct ec_config *config; /**< Generic configuration. */ - char *id; - char *desc; - struct ec_keyval *attrs; - unsigned int refcnt; - struct { - enum ec_node_free_state state; /**< State of loop detection */ - unsigned int refcnt; /**< Number of reachable references - * starting from node beeing freed */ - } free; /**< Freeing state: used for loop detection */ -}; - /* create a new node when the type is known, typically called from the node * code */ struct ec_node *ec_node_from_type(const struct ec_node_type *type, const char *id); @@ -192,7 +182,7 @@ ec_node_get_child(const struct ec_node *node, size_t i, /* XXX add more accessors */ const struct ec_node_type *ec_node_type(const struct ec_node *node); -struct ec_keyval *ec_node_attrs(const struct ec_node *node); +struct ec_dict *ec_node_attrs(const struct ec_node *node); const char *ec_node_id(const struct ec_node *node); const char *ec_node_desc(const struct ec_node *node); @@ -203,4 +193,18 @@ struct ec_node *ec_node_find(struct ec_node *node, const char *id); int ec_node_check_type(const struct ec_node *node, const struct ec_node_type *type); +const char *ec_node_get_type_name(const struct ec_node *node); + +/** + * Get the pointer to the node private area. + * + * @param node + * The grammar node. + * @return + * The pointer to the node private area. + */ +void *ec_node_priv(const struct ec_node *node); + #endif + + /** @} */