1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016, Olivier MATZ <zer0@droids-corp.org>
12 #include <ecoli_malloc.h>
13 #include <ecoli_log.h>
14 #include <ecoli_test.h>
15 #include <ecoli_strvec.h>
16 #include <ecoli_node.h>
17 #include <ecoli_parsed.h>
18 #include <ecoli_completed.h>
19 #include <ecoli_node_str.h>
20 #include <ecoli_node_option.h>
21 #include <ecoli_node_weakref.h>
23 EC_LOG_TYPE_REGISTER(node_weakref);
25 struct ec_node_weakref {
27 struct ec_node *child;
31 ec_node_weakref_parse(const struct ec_node *gen_node,
32 struct ec_parsed *state,
33 const struct ec_strvec *strvec)
35 struct ec_node_weakref *node = (struct ec_node_weakref *)gen_node;
37 return ec_node_parse_child(node->child, state, strvec);
41 ec_node_weakref_complete(const struct ec_node *gen_node,
42 struct ec_completed *completed,
43 const struct ec_strvec *strvec)
45 struct ec_node_weakref *node = (struct ec_node_weakref *)gen_node;
47 return ec_node_complete_child(node->child, completed, strvec);
50 static struct ec_node_type ec_node_weakref_type = {
52 .parse = ec_node_weakref_parse,
53 .complete = ec_node_weakref_complete,
54 .size = sizeof(struct ec_node_weakref),
57 EC_NODE_TYPE_REGISTER(ec_node_weakref_type);
59 int ec_node_weakref_set(struct ec_node *gen_node, struct ec_node *child)
61 struct ec_node_weakref *node = (struct ec_node_weakref *)gen_node;
70 if (ec_node_check_type(gen_node, &ec_node_weakref_type) < 0)
82 struct ec_node *ec_node_weakref(const char *id, struct ec_node *child)
84 struct ec_node *gen_node = NULL;
89 gen_node = __ec_node(&ec_node_weakref_type, id);
93 ec_node_weakref_set(gen_node, child);
99 static int ec_node_weakref_testcase(void)
101 //XXX weakref testcase
106 static struct ec_test ec_node_weakref_test = {
107 .name = "node_weakref",
108 .test = ec_node_weakref_testcase,
111 EC_TEST_REGISTER(ec_node_weakref_test);