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
api documentation for ec_parse
[protos/libecoli.git]
/
src
/
ecoli_node_once.c
diff --git
a/src/ecoli_node_once.c
b/src/ecoli_node_once.c
index
989c710
..
f2c8ec1
100644
(file)
--- a/
src/ecoli_node_once.c
+++ b/
src/ecoli_node_once.c
@@
-25,97
+25,96
@@
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;
};
static unsigned int
struct ec_node *child;
};
static unsigned int
-count_node(struct ec_p
ars
e *parse, const struct ec_node *node)
+count_node(struct ec_p
nod
e *parse, const struct ec_node *node)
{
{
- struct ec_p
ars
e *child;
+ struct ec_p
nod
e *child;
unsigned int count = 0;
if (parse == NULL)
return 0;
unsigned int count = 0;
if (parse == NULL)
return 0;
- if (ec_p
ars
e_get_node(parse) == node)
+ if (ec_p
nod
e_get_node(parse) == node)
count++;
count++;
- EC_P
ARS
E_FOREACH_CHILD(child, parse)
+ EC_P
NOD
E_FOREACH_CHILD(child, parse)
count += count_node(child, node);
return count;
}
static int
count += count_node(child, node);
return count;
}
static int
-ec_node_once_parse(const struct ec_node *
gen_
node,
- struct ec_p
ars
e *state,
+ec_node_once_parse(const struct ec_node *node,
+ struct ec_p
nod
e *state,
const struct ec_strvec *strvec)
{
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_p
arse_get_root(state), node
->child);
+ count = count_node(ec_p
node_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_
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_p
arse *parse = ec_comp_get_
state(comp);
+ struct ec_node_once *
priv = ec_node_priv(node)
;
+ struct ec_p
node *parse = ec_comp_get_cur_p
state(comp);
unsigned int count;
int ret;
/* count the number of occurences of the node: if already parsed,
* do not match
*/
unsigned int count;
int ret;
/* count the number of occurences of the node: if already parsed,
* do not match
*/
- count = count_node(ec_p
arse_get_root(parse), node
->child);
+ count = count_node(ec_p
node_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_
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);
@@
-254,20
+253,20
@@
static int ec_node_once_testcase(void)
testres |= EC_TEST_CHECK_PARSE(node, 0, "foox");
testres |= EC_TEST_CHECK_COMPLETE(node,
testres |= EC_TEST_CHECK_PARSE(node, 0, "foox");
testres |= EC_TEST_CHECK_COMPLETE(node,
- "", EC_
NODE_ENDLIST
,
- "foo", "bar", EC_
NODE_ENDLIST
);
+ "", EC_
VA_END
,
+ "foo", "bar", EC_
VA_END
);
testres |= EC_TEST_CHECK_COMPLETE(node,
testres |= EC_TEST_CHECK_COMPLETE(node,
- "f", EC_
NODE_ENDLIST
,
- "foo", EC_
NODE_ENDLIST
);
+ "f", EC_
VA_END
,
+ "foo", EC_
VA_END
);
testres |= EC_TEST_CHECK_COMPLETE(node,
testres |= EC_TEST_CHECK_COMPLETE(node,
- "b", EC_
NODE_ENDLIST
,
- "bar", EC_
NODE_ENDLIST
);
+ "b", EC_
VA_END
,
+ "bar", EC_
VA_END
);
testres |= EC_TEST_CHECK_COMPLETE(node,
testres |= EC_TEST_CHECK_COMPLETE(node,
- "foo", "", EC_
NODE_ENDLIST
,
- "bar", EC_
NODE_ENDLIST
);
+ "foo", "", EC_
VA_END
,
+ "bar", EC_
VA_END
);
testres |= EC_TEST_CHECK_COMPLETE(node,
testres |= EC_TEST_CHECK_COMPLETE(node,
- "bar", "", EC_
NODE_ENDLIST
,
- "foo", "bar", EC_
NODE_ENDLIST
);
+ "bar", "", EC_
VA_END
,
+ "foo", "bar", EC_
VA_END
);
ec_node_free(node);
return testres;
ec_node_free(node);
return testres;