git.droids-corp.org
/
protos
/
libecoli.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
hide ec_node structure
[protos/libecoli.git]
/
src
/
ecoli_node_once.c
diff --git
a/src/ecoli_node_once.c
b/src/ecoli_node_once.c
index
989c710
..
4662a66
100644
(file)
--- a/
src/ecoli_node_once.c
+++ b/
src/ecoli_node_once.c
@@
-25,7
+25,6
@@
EC_LOG_TYPE_REGISTER(node_once);
struct ec_node_once {
EC_LOG_TYPE_REGISTER(node_once);
struct ec_node_once {
- struct ec_node gen;
struct ec_node *child;
};
struct ec_node *child;
};
@@
-48,29
+47,29
@@
count_node(struct ec_parse *parse, const struct ec_node *node)
}
static int
}
static int
-ec_node_once_parse(const struct ec_node *
gen_
node,
+ec_node_once_parse(const struct ec_node *node,
struct ec_parse *state,
const struct ec_strvec *strvec)
{
struct ec_parse *state,
const struct ec_strvec *strvec)
{
- struct ec_node_once *
node = (struct ec_node_once *)gen_node
;
+ struct ec_node_once *
priv = ec_node_priv(node)
;
unsigned int count;
/* count the number of occurences of the node: if already parsed,
* do not match
*/
unsigned int count;
/* count the number of occurences of the node: if already parsed,
* do not match
*/
- count = count_node(ec_parse_get_root(state),
node
->child);
+ count = count_node(ec_parse_get_root(state),
priv
->child);
if (count > 0)
return EC_PARSE_NOMATCH;
if (count > 0)
return EC_PARSE_NOMATCH;
- return ec_node_parse_child(
node
->child, state, strvec);
+ return ec_node_parse_child(
priv
->child, state, strvec);
}
static int
}
static int
-ec_node_once_complete(const struct ec_node *
gen_
node,
+ec_node_once_complete(const struct ec_node *node,
struct ec_comp *comp,
const struct ec_strvec *strvec)
{
struct ec_comp *comp,
const struct ec_strvec *strvec)
{
- struct ec_node_once *
node = (struct ec_node_once *)gen_node
;
+ struct ec_node_once *
priv = ec_node_priv(node)
;
struct ec_parse *parse = ec_comp_get_state(comp);
unsigned int count;
int ret;
struct ec_parse *parse = ec_comp_get_state(comp);
unsigned int count;
int ret;
@@
-78,44
+77,44
@@
ec_node_once_complete(const struct ec_node *gen_node,
/* count the number of occurences of the node: if already parsed,
* do not match
*/
/* count the number of occurences of the node: if already parsed,
* do not match
*/
- count = count_node(ec_parse_get_root(parse),
node
->child);
+ count = count_node(ec_parse_get_root(parse),
priv
->child);
if (count > 0)
return 0;
if (count > 0)
return 0;
- ret = ec_node_complete_child(
node
->child, comp, strvec);
+ ret = ec_node_complete_child(
priv
->child, comp, strvec);
if (ret < 0)
return ret;
return 0;
}
if (ret < 0)
return ret;
return 0;
}
-static void ec_node_once_free_priv(struct ec_node *
gen_
node)
+static void ec_node_once_free_priv(struct ec_node *node)
{
{
- struct ec_node_once *
node = (struct ec_node_once *)gen_node
;
+ struct ec_node_once *
priv = ec_node_priv(node)
;
- ec_node_free(
node
->child);
+ ec_node_free(
priv
->child);
}
static size_t
}
static size_t
-ec_node_once_get_children_count(const struct ec_node *
gen_
node)
+ec_node_once_get_children_count(const struct ec_node *node)
{
{
- struct ec_node_once *
node = (struct ec_node_once *)gen_node
;
+ struct ec_node_once *
priv = ec_node_priv(node)
;
- if (
node
->child)
+ if (
priv
->child)
return 1;
return 0;
}
static int
return 1;
return 0;
}
static int
-ec_node_once_get_child(const struct ec_node *
gen_
node, size_t i,
+ec_node_once_get_child(const struct ec_node *node, size_t i,
struct ec_node **child, unsigned int *refs)
{
struct ec_node **child, unsigned int *refs)
{
- struct ec_node_once *
node = (struct ec_node_once *)gen_node
;
+ struct ec_node_once *
priv = ec_node_priv(node)
;
if (i >= 1)
return -1;
if (i >= 1)
return -1;
- *child =
node
->child;
+ *child =
priv
->child;
*refs = 2;
return 0;
}
*refs = 2;
return 0;
}
@@
-131,10
+130,10
@@
static const struct ec_config_schema ec_node_once_schema[] = {
},
};
},
};
-static int ec_node_once_set_config(struct ec_node *
gen_
node,
+static int ec_node_once_set_config(struct ec_node *node,
const struct ec_config *config)
{
const struct ec_config *config)
{
- struct ec_node_once *
node = (struct ec_node_once *)gen_node
;
+ struct ec_node_once *
priv = ec_node_priv(node)
;
const struct ec_config *child;
child = ec_config_dict_get(config, "child");
const struct ec_config *child;
child = ec_config_dict_get(config, "child");
@@
-145,9
+144,9
@@
static int ec_node_once_set_config(struct ec_node *gen_node,
goto fail;
}
goto fail;
}
- if (
node
->child != NULL)
- ec_node_free(
node
->child);
-
node
->child = ec_node_clone(child->node);
+ if (
priv
->child != NULL)
+ ec_node_free(
priv
->child);
+
priv
->child = ec_node_clone(child->node);
return 0;
return 0;
@@
-170,16
+169,16
@@
static struct ec_node_type ec_node_once_type = {
EC_NODE_TYPE_REGISTER(ec_node_once_type);
int
EC_NODE_TYPE_REGISTER(ec_node_once_type);
int
-ec_node_once_set_child(struct ec_node *
gen_
node, struct ec_node *child)
+ec_node_once_set_child(struct ec_node *node, struct ec_node *child)
{
const struct ec_config *cur_config = NULL;
struct ec_config *config = NULL;
int ret;
{
const struct ec_config *cur_config = NULL;
struct ec_config *config = NULL;
int ret;
- if (ec_node_check_type(
gen_
node, &ec_node_once_type) < 0)
+ if (ec_node_check_type(node, &ec_node_once_type) < 0)
goto fail;
goto fail;
- cur_config = ec_node_get_config(
gen_
node);
+ cur_config = ec_node_get_config(node);
if (cur_config == NULL)
config = ec_config_dict();
else
if (cur_config == NULL)
config = ec_config_dict();
else
@@
-193,7
+192,7
@@
ec_node_once_set_child(struct ec_node *gen_node, struct ec_node *child)
}
child = NULL; /* freed */
}
child = NULL; /* freed */
- ret = ec_node_set_config(
gen_
node, config);
+ ret = ec_node_set_config(node, config);
config = NULL; /* freed */
if (ret < 0)
goto fail;
config = NULL; /* freed */
if (ret < 0)
goto fail;
@@
-208,19
+207,19
@@
fail:
struct ec_node *ec_node_once(const char *id, struct ec_node *child)
{
struct ec_node *ec_node_once(const char *id, struct ec_node *child)
{
- struct ec_node *
gen_
node = NULL;
+ struct ec_node *node = NULL;
if (child == NULL)
return NULL;
if (child == NULL)
return NULL;
-
gen_
node = ec_node_from_type(&ec_node_once_type, id);
- if (
gen_
node == NULL)
+ node = ec_node_from_type(&ec_node_once_type, id);
+ if (node == NULL)
goto fail;
goto fail;
- ec_node_once_set_child(
gen_
node, child);
+ ec_node_once_set_child(node, child);
child = NULL;
child = NULL;
- return
gen_
node;
+ return node;
fail:
ec_node_free(child);
fail:
ec_node_free(child);