Bug 555960 - nested structs and unions

Patch from Andreas Rottmann <a.rottmann@gmx.at>.

This change modifies the parser to hold a stack of nodes, instead of
a single concept of "current" node.  This allows the parser to recurse
into nested nodes.

svn path=/trunk/; revision=1081
This commit is contained in:
Colin Walters 2009-02-04 00:48:17 +00:00
parent 0ed02eb80b
commit 8a0cdd96e9

View File

@ -85,13 +85,14 @@ struct _ParseContext
const char *namespace; const char *namespace;
GIrModule *current_module; GIrModule *current_module;
GIrNode *current_node; GSList *node_stack;
GIrNode *current_typed; GIrNode *current_typed;
gboolean is_varargs; gboolean is_varargs;
GList *type_stack; GList *type_stack;
GList *type_parameters; GList *type_parameters;
int type_depth; int type_depth;
}; };
#define CURRENT_NODE(ctx) ((GIrNode *)((ctx)->node_stack->data))
static void start_element_handler (GMarkupParseContext *context, static void start_element_handler (GMarkupParseContext *context,
const gchar *element_name, const gchar *element_name,
@ -310,6 +311,27 @@ state_switch (ParseContext *ctx, ParseState newstate)
ctx->state = newstate; ctx->state = newstate;
} }
static GIrNode *
pop_node (ParseContext *ctx)
{
g_assert (ctx->node_stack != 0);
GSList *top = ctx->node_stack;
GIrNode *node = top->data;
g_debug ("popping node %d %s", node->type, node->name);
ctx->node_stack = top->next;
g_slist_free_1 (top);
return node;
}
static void
push_node (ParseContext *ctx, GIrNode *node)
{
g_debug ("pushing node %d %s", node->type, node->name);
ctx->node_stack = g_slist_prepend (ctx->node_stack, node);
}
static GIrNodeType * parse_type_internal (const gchar *str, gchar **next, gboolean in_glib, static GIrNodeType * parse_type_internal (const gchar *str, gchar **next, gboolean in_glib,
gboolean in_gobject); gboolean in_gobject);
@ -643,7 +665,7 @@ start_glib_boxed (GMarkupParseContext *context,
else else
boxed->deprecated = FALSE; boxed->deprecated = FALSE;
ctx->current_node = (GIrNode *)boxed; push_node (ctx, (GIrNode *)boxed);
ctx->current_module->entries = ctx->current_module->entries =
g_list_append (ctx->current_module->entries, boxed); g_list_append (ctx->current_module->entries, boxed);
@ -744,20 +766,20 @@ start_function (GMarkupParseContext *context,
else else
function->throws = FALSE; function->throws = FALSE;
if (ctx->current_node == NULL) if (ctx->node_stack == NULL)
{ {
ctx->current_module->entries = ctx->current_module->entries =
g_list_append (ctx->current_module->entries, function); g_list_append (ctx->current_module->entries, function);
} }
else else
switch (ctx->current_node->type) switch (CURRENT_NODE (ctx)->type)
{ {
case G_IR_NODE_INTERFACE: case G_IR_NODE_INTERFACE:
case G_IR_NODE_OBJECT: case G_IR_NODE_OBJECT:
{ {
GIrNodeInterface *iface; GIrNodeInterface *iface;
iface = (GIrNodeInterface *)ctx->current_node; iface = (GIrNodeInterface *)CURRENT_NODE (ctx);
iface->members = g_list_append (iface->members, function); iface->members = g_list_append (iface->members, function);
} }
break; break;
@ -765,7 +787,7 @@ start_function (GMarkupParseContext *context,
{ {
GIrNodeBoxed *boxed; GIrNodeBoxed *boxed;
boxed = (GIrNodeBoxed *)ctx->current_node; boxed = (GIrNodeBoxed *)CURRENT_NODE (ctx);
boxed->members = g_list_append (boxed->members, function); boxed->members = g_list_append (boxed->members, function);
} }
break; break;
@ -773,14 +795,14 @@ start_function (GMarkupParseContext *context,
{ {
GIrNodeStruct *struct_; GIrNodeStruct *struct_;
struct_ = (GIrNodeStruct *)ctx->current_node; struct_ = (GIrNodeStruct *)CURRENT_NODE (ctx);
struct_->members = g_list_append (struct_->members, function); } struct_->members = g_list_append (struct_->members, function); }
break; break;
case G_IR_NODE_UNION: case G_IR_NODE_UNION:
{ {
GIrNodeUnion *union_; GIrNodeUnion *union_;
union_ = (GIrNodeUnion *)ctx->current_node; union_ = (GIrNodeUnion *)CURRENT_NODE (ctx);
union_->members = g_list_append (union_->members, function); union_->members = g_list_append (union_->members, function);
} }
break; break;
@ -788,7 +810,7 @@ start_function (GMarkupParseContext *context,
g_assert_not_reached (); g_assert_not_reached ();
} }
ctx->current_node = (GIrNode *)function; push_node(ctx, (GIrNode *)function);
state_switch (ctx, STATE_FUNCTION); state_switch (ctx, STATE_FUNCTION);
return TRUE; return TRUE;
@ -921,14 +943,14 @@ start_parameter (GMarkupParseContext *context,
((GIrNode *)param)->name = g_strdup (name); ((GIrNode *)param)->name = g_strdup (name);
switch (ctx->current_node->type) switch (CURRENT_NODE (ctx)->type)
{ {
case G_IR_NODE_FUNCTION: case G_IR_NODE_FUNCTION:
case G_IR_NODE_CALLBACK: case G_IR_NODE_CALLBACK:
{ {
GIrNodeFunction *func; GIrNodeFunction *func;
func = (GIrNodeFunction *)ctx->current_node; func = (GIrNodeFunction *)CURRENT_NODE (ctx);
func->parameters = g_list_append (func->parameters, param); func->parameters = g_list_append (func->parameters, param);
} }
break; break;
@ -936,7 +958,7 @@ start_parameter (GMarkupParseContext *context,
{ {
GIrNodeSignal *signal; GIrNodeSignal *signal;
signal = (GIrNodeSignal *)ctx->current_node; signal = (GIrNodeSignal *)CURRENT_NODE (ctx);
signal->parameters = g_list_append (signal->parameters, param); signal->parameters = g_list_append (signal->parameters, param);
} }
break; break;
@ -944,7 +966,7 @@ start_parameter (GMarkupParseContext *context,
{ {
GIrNodeVFunc *vfunc; GIrNodeVFunc *vfunc;
vfunc = (GIrNodeVFunc *)ctx->current_node; vfunc = (GIrNodeVFunc *)CURRENT_NODE (ctx);
vfunc->parameters = g_list_append (vfunc->parameters, param); vfunc->parameters = g_list_append (vfunc->parameters, param);
} }
break; break;
@ -1011,13 +1033,13 @@ start_field (GMarkupParseContext *context,
else else
field->bits = 0; field->bits = 0;
switch (ctx->current_node->type) switch (CURRENT_NODE (ctx)->type)
{ {
case G_IR_NODE_OBJECT: case G_IR_NODE_OBJECT:
{ {
GIrNodeInterface *iface; GIrNodeInterface *iface;
iface = (GIrNodeInterface *)ctx->current_node; iface = (GIrNodeInterface *)CURRENT_NODE (ctx);
iface->members = g_list_append (iface->members, field); iface->members = g_list_append (iface->members, field);
state_switch (ctx, STATE_CLASS_FIELD); state_switch (ctx, STATE_CLASS_FIELD);
} }
@ -1026,7 +1048,7 @@ start_field (GMarkupParseContext *context,
{ {
GIrNodeInterface *iface; GIrNodeInterface *iface;
iface = (GIrNodeInterface *)ctx->current_node; iface = (GIrNodeInterface *)CURRENT_NODE (ctx);
iface->members = g_list_append (iface->members, field); iface->members = g_list_append (iface->members, field);
state_switch (ctx, STATE_INTERFACE_FIELD); state_switch (ctx, STATE_INTERFACE_FIELD);
} }
@ -1035,7 +1057,7 @@ start_field (GMarkupParseContext *context,
{ {
GIrNodeBoxed *boxed; GIrNodeBoxed *boxed;
boxed = (GIrNodeBoxed *)ctx->current_node; boxed = (GIrNodeBoxed *)CURRENT_NODE (ctx);
boxed->members = g_list_append (boxed->members, field); boxed->members = g_list_append (boxed->members, field);
state_switch (ctx, STATE_BOXED_FIELD); state_switch (ctx, STATE_BOXED_FIELD);
} }
@ -1044,7 +1066,7 @@ start_field (GMarkupParseContext *context,
{ {
GIrNodeStruct *struct_; GIrNodeStruct *struct_;
struct_ = (GIrNodeStruct *)ctx->current_node; struct_ = (GIrNodeStruct *)CURRENT_NODE (ctx);
struct_->members = g_list_append (struct_->members, field); struct_->members = g_list_append (struct_->members, field);
state_switch (ctx, STATE_STRUCT_FIELD); state_switch (ctx, STATE_STRUCT_FIELD);
} }
@ -1053,7 +1075,7 @@ start_field (GMarkupParseContext *context,
{ {
GIrNodeUnion *union_; GIrNodeUnion *union_;
union_ = (GIrNodeUnion *)ctx->current_node; union_ = (GIrNodeUnion *)CURRENT_NODE (ctx);
union_->members = g_list_append (union_->members, field); union_->members = g_list_append (union_->members, field);
if (branch) if (branch)
{ {
@ -1160,7 +1182,7 @@ start_enum (GMarkupParseContext *context,
else else
enum_->deprecated = FALSE; enum_->deprecated = FALSE;
ctx->current_node = (GIrNode *) enum_; push_node (ctx, (GIrNode *) enum_);
ctx->current_module->entries = ctx->current_module->entries =
g_list_append (ctx->current_module->entries, enum_); g_list_append (ctx->current_module->entries, enum_);
@ -1226,7 +1248,7 @@ start_property (GMarkupParseContext *context,
else else
property->construct_only = FALSE; property->construct_only = FALSE;
iface = (GIrNodeInterface *)ctx->current_node; iface = (GIrNodeInterface *)CURRENT_NODE (ctx);
iface->members = g_list_append (iface->members, property); iface->members = g_list_append (iface->members, property);
if (ctx->state == STATE_CLASS) if (ctx->state == STATE_CLASS)
@ -1302,7 +1324,7 @@ start_member (GMarkupParseContext *context,
else else
value_->deprecated = FALSE; value_->deprecated = FALSE;
enum_ = (GIrNodeEnum *)ctx->current_node; enum_ = (GIrNodeEnum *)CURRENT_NODE (ctx);
enum_->values = g_list_append (enum_->values, value_); enum_->values = g_list_append (enum_->values, value_);
} }
@ -1354,7 +1376,7 @@ start_constant (GMarkupParseContext *context,
if (ctx->state == STATE_NAMESPACE) if (ctx->state == STATE_NAMESPACE)
{ {
ctx->current_node = (GIrNode *) constant; push_node (ctx, (GIrNode *) constant);
ctx->current_module->entries = ctx->current_module->entries =
g_list_append (ctx->current_module->entries, constant); g_list_append (ctx->current_module->entries, constant);
} }
@ -1362,7 +1384,7 @@ start_constant (GMarkupParseContext *context,
{ {
GIrNodeInterface *iface; GIrNodeInterface *iface;
iface = (GIrNodeInterface *)ctx->current_node; iface = (GIrNodeInterface *)CURRENT_NODE (ctx);
iface->members = g_list_append (iface->members, constant); iface->members = g_list_append (iface->members, constant);
} }
@ -1430,7 +1452,7 @@ start_errordomain (GMarkupParseContext *context,
else else
domain->deprecated = FALSE; domain->deprecated = FALSE;
ctx->current_node = (GIrNode *) domain; push_node (ctx, (GIrNode *) domain);
ctx->current_module->entries = ctx->current_module->entries =
g_list_append (ctx->current_module->entries, domain); g_list_append (ctx->current_module->entries, domain);
@ -1482,7 +1504,7 @@ start_interface (GMarkupParseContext *context,
else else
iface->deprecated = FALSE; iface->deprecated = FALSE;
ctx->current_node = (GIrNode *) iface; push_node (ctx, (GIrNode *) iface);
ctx->current_module->entries = ctx->current_module->entries =
g_list_append (ctx->current_module->entries, iface); g_list_append (ctx->current_module->entries, iface);
@ -1542,7 +1564,7 @@ start_class (GMarkupParseContext *context,
iface->abstract = abstract && strcmp (abstract, "1") == 0; iface->abstract = abstract && strcmp (abstract, "1") == 0;
ctx->current_node = (GIrNode *) iface; push_node (ctx, (GIrNode *) iface);
ctx->current_module->entries = ctx->current_module->entries =
g_list_append (ctx->current_module->entries, iface); g_list_append (ctx->current_module->entries, iface);
@ -1598,18 +1620,18 @@ start_type (GMarkupParseContext *context,
ctx->type_depth = 1; ctx->type_depth = 1;
if (is_varargs) if (is_varargs)
{ {
switch (ctx->current_node->type) switch (CURRENT_NODE (ctx)->type)
{ {
case G_IR_NODE_FUNCTION: case G_IR_NODE_FUNCTION:
case G_IR_NODE_CALLBACK: case G_IR_NODE_CALLBACK:
{ {
GIrNodeFunction *func = (GIrNodeFunction *)ctx->current_node; GIrNodeFunction *func = (GIrNodeFunction *)CURRENT_NODE (ctx);
func->is_varargs = TRUE; func->is_varargs = TRUE;
} }
break; break;
case G_IR_NODE_VFUNC: case G_IR_NODE_VFUNC:
{ {
GIrNodeVFunc *vfunc = (GIrNodeVFunc *)ctx->current_node; GIrNodeVFunc *vfunc = (GIrNodeVFunc *)CURRENT_NODE (ctx);
vfunc->is_varargs = TRUE; vfunc->is_varargs = TRUE;
} }
break; break;
@ -1770,7 +1792,7 @@ end_type_top (ParseContext *ctx)
} }
break; break;
default: default:
g_printerr("current node is %d\n", ctx->current_node->type); g_printerr("current node is %d\n", CURRENT_NODE (ctx)->type);
g_assert_not_reached (); g_assert_not_reached ();
} }
g_list_free (ctx->type_parameters); g_list_free (ctx->type_parameters);
@ -1859,24 +1881,24 @@ start_return_value (GMarkupParseContext *context,
transfer = find_attribute ("transfer-ownership", attribute_names, attribute_values); transfer = find_attribute ("transfer-ownership", attribute_names, attribute_values);
parse_param_transfer (param, transfer); parse_param_transfer (param, transfer);
switch (ctx->current_node->type) switch (CURRENT_NODE (ctx)->type)
{ {
case G_IR_NODE_FUNCTION: case G_IR_NODE_FUNCTION:
case G_IR_NODE_CALLBACK: case G_IR_NODE_CALLBACK:
{ {
GIrNodeFunction *func = (GIrNodeFunction *)ctx->current_node; GIrNodeFunction *func = (GIrNodeFunction *)CURRENT_NODE (ctx);
func->result = param; func->result = param;
} }
break; break;
case G_IR_NODE_SIGNAL: case G_IR_NODE_SIGNAL:
{ {
GIrNodeSignal *signal = (GIrNodeSignal *)ctx->current_node; GIrNodeSignal *signal = (GIrNodeSignal *)CURRENT_NODE (ctx);
signal->result = param; signal->result = param;
} }
break; break;
case G_IR_NODE_VFUNC: case G_IR_NODE_VFUNC:
{ {
GIrNodeVFunc *vfunc = (GIrNodeVFunc *)ctx->current_node; GIrNodeVFunc *vfunc = (GIrNodeVFunc *)CURRENT_NODE (ctx);
vfunc->result = param; vfunc->result = param;
} }
break; break;
@ -1914,7 +1936,7 @@ start_implements (GMarkupParseContext *context,
return FALSE; return FALSE;
} }
iface = (GIrNodeInterface *)ctx->current_node; iface = (GIrNodeInterface *)CURRENT_NODE (ctx);
iface->interfaces = g_list_append (iface->interfaces, g_strdup (name)); iface->interfaces = g_list_append (iface->interfaces, g_strdup (name));
return TRUE; return TRUE;
@ -1990,10 +2012,10 @@ start_glib_signal (GMarkupParseContext *context,
else else
signal->has_class_closure = FALSE; signal->has_class_closure = FALSE;
iface = (GIrNodeInterface *)ctx->current_node; iface = (GIrNodeInterface *)CURRENT_NODE (ctx);
iface->members = g_list_append (iface->members, signal); iface->members = g_list_append (iface->members, signal);
ctx->current_node = (GIrNode *)signal; push_node (ctx, (GIrNode *)signal);
state_switch (ctx, STATE_FUNCTION); state_switch (ctx, STATE_FUNCTION);
} }
@ -2068,10 +2090,10 @@ start_vfunc (GMarkupParseContext *context,
else else
vfunc->offset = 0; vfunc->offset = 0;
iface = (GIrNodeInterface *)ctx->current_node; iface = (GIrNodeInterface *)CURRENT_NODE (ctx);
iface->members = g_list_append (iface->members, vfunc); iface->members = g_list_append (iface->members, vfunc);
ctx->current_node = (GIrNode *)vfunc; push_node (ctx, (GIrNode *)vfunc);
state_switch (ctx, STATE_FUNCTION); state_switch (ctx, STATE_FUNCTION);
} }
@ -2135,9 +2157,9 @@ start_struct (GMarkupParseContext *context,
struct_->gtype_name = g_strdup (gtype_name); struct_->gtype_name = g_strdup (gtype_name);
struct_->gtype_init = g_strdup (gtype_init); struct_->gtype_init = g_strdup (gtype_init);
ctx->current_node = (GIrNode *)struct_;
ctx->current_module->entries = ctx->current_module->entries =
g_list_append (ctx->current_module->entries, struct_); g_list_append (ctx->current_module->entries, struct_);
push_node (ctx, (GIrNode *)struct_);
state_switch (ctx, STATE_STRUCT); state_switch (ctx, STATE_STRUCT);
return TRUE; return TRUE;
@ -2183,9 +2205,9 @@ start_union (GMarkupParseContext *context,
else else
union_->deprecated = FALSE; union_->deprecated = FALSE;
ctx->current_node = (GIrNode *)union_;
ctx->current_module->entries = ctx->current_module->entries =
g_list_append (ctx->current_module->entries, union_); g_list_append (ctx->current_module->entries, union_);
push_node (ctx, (GIrNode *)union_);
state_switch (ctx, STATE_UNION); state_switch (ctx, STATE_UNION);
} }
@ -2215,9 +2237,9 @@ start_discriminator (GMarkupParseContext *context,
else if (offset == NULL) else if (offset == NULL)
MISSING_ATTRIBUTE (context, error, element_name, "offset"); MISSING_ATTRIBUTE (context, error, element_name, "offset");
{ {
((GIrNodeUnion *)ctx->current_node)->discriminator_type ((GIrNodeUnion *)CURRENT_NODE (ctx))->discriminator_type
= parse_type (ctx, type); = parse_type (ctx, type);
((GIrNodeUnion *)ctx->current_node)->discriminator_offset ((GIrNodeUnion *)CURRENT_NODE (ctx))->discriminator_offset
= atoi (offset); = atoi (offset);
} }
@ -2540,7 +2562,7 @@ start_element_handler (GMarkupParseContext *context,
{ {
GIrNodeInterface *iface; GIrNodeInterface *iface;
iface = (GIrNodeInterface *)ctx->current_node; iface = (GIrNodeInterface *)CURRENT_NODE(ctx);
iface->prerequisites = g_list_append (iface->prerequisites, g_strdup (name)); iface->prerequisites = g_list_append (iface->prerequisites, g_strdup (name));
} }
goto out; goto out;
@ -2742,28 +2764,22 @@ end_element_handler (GMarkupParseContext *context,
case STATE_FUNCTION: case STATE_FUNCTION:
{ {
gboolean current_is_toplevel; pop_node (ctx);
GList *last = g_list_last (ctx->current_module->entries); if (ctx->node_stack == NULL)
current_is_toplevel = ctx->current_node == last->data;
if (current_is_toplevel)
{ {
ctx->current_node = NULL;
state_switch (ctx, STATE_NAMESPACE); state_switch (ctx, STATE_NAMESPACE);
} }
else else
{ {
ctx->current_node = g_list_last (ctx->current_module->entries)->data; if (CURRENT_NODE (ctx)->type == G_IR_NODE_INTERFACE)
if (ctx->current_node->type == G_IR_NODE_INTERFACE)
state_switch (ctx, STATE_INTERFACE); state_switch (ctx, STATE_INTERFACE);
else if (ctx->current_node->type == G_IR_NODE_OBJECT) else if (CURRENT_NODE (ctx)->type == G_IR_NODE_OBJECT)
state_switch (ctx, STATE_CLASS); state_switch (ctx, STATE_CLASS);
else if (ctx->current_node->type == G_IR_NODE_BOXED) else if (CURRENT_NODE (ctx)->type == G_IR_NODE_BOXED)
state_switch (ctx, STATE_BOXED); state_switch (ctx, STATE_BOXED);
else if (ctx->current_node->type == G_IR_NODE_STRUCT) else if (CURRENT_NODE (ctx)->type == G_IR_NODE_STRUCT)
state_switch (ctx, STATE_STRUCT); state_switch (ctx, STATE_STRUCT);
else if (ctx->current_node->type == G_IR_NODE_UNION) else if (CURRENT_NODE (ctx)->type == G_IR_NODE_UNION)
state_switch (ctx, STATE_UNION); state_switch (ctx, STATE_UNION);
else else
{ {
@ -2801,7 +2817,7 @@ end_element_handler (GMarkupParseContext *context,
case STATE_CLASS: case STATE_CLASS:
if (require_end_element (context, ctx, "class", element_name, error)) if (require_end_element (context, ctx, "class", element_name, error))
{ {
ctx->current_node = NULL; pop_node (ctx);
state_switch (ctx, STATE_NAMESPACE); state_switch (ctx, STATE_NAMESPACE);
} }
break; break;
@ -2809,7 +2825,7 @@ end_element_handler (GMarkupParseContext *context,
case STATE_ERRORDOMAIN: case STATE_ERRORDOMAIN:
if (require_end_element (context, ctx, "errordomain", element_name, error)) if (require_end_element (context, ctx, "errordomain", element_name, error))
{ {
ctx->current_node = NULL; pop_node (ctx);
state_switch (ctx, STATE_NAMESPACE); state_switch (ctx, STATE_NAMESPACE);
} }
break; break;
@ -2835,7 +2851,7 @@ end_element_handler (GMarkupParseContext *context,
case STATE_INTERFACE: case STATE_INTERFACE:
if (require_end_element (context, ctx, "interface", element_name, error)) if (require_end_element (context, ctx, "interface", element_name, error))
{ {
ctx->current_node = NULL; pop_node (ctx);
state_switch (ctx, STATE_NAMESPACE); state_switch (ctx, STATE_NAMESPACE);
} }
break; break;
@ -2847,7 +2863,7 @@ end_element_handler (GMarkupParseContext *context,
element_name, error, "enumeration", element_name, error, "enumeration",
"bitfield", NULL)) "bitfield", NULL))
{ {
ctx->current_node = NULL; pop_node (ctx);
state_switch (ctx, STATE_NAMESPACE); state_switch (ctx, STATE_NAMESPACE);
} }
break; break;
@ -2855,7 +2871,7 @@ end_element_handler (GMarkupParseContext *context,
case STATE_BOXED: case STATE_BOXED:
if (require_end_element (context, ctx, "glib:boxed", element_name, error)) if (require_end_element (context, ctx, "glib:boxed", element_name, error))
{ {
ctx->current_node = NULL; pop_node (ctx);
state_switch (ctx, STATE_NAMESPACE); state_switch (ctx, STATE_NAMESPACE);
} }
break; break;
@ -2881,7 +2897,7 @@ end_element_handler (GMarkupParseContext *context,
case STATE_STRUCT: case STATE_STRUCT:
if (require_end_element (context, ctx, "record", element_name, error)) if (require_end_element (context, ctx, "record", element_name, error))
{ {
ctx->current_node = NULL; pop_node (ctx);
state_switch (ctx, STATE_NAMESPACE); state_switch (ctx, STATE_NAMESPACE);
} }
break; break;
@ -2898,7 +2914,7 @@ end_element_handler (GMarkupParseContext *context,
case STATE_UNION: case STATE_UNION:
if (require_end_element (context, ctx, "union", element_name, error)) if (require_end_element (context, ctx, "union", element_name, error))
{ {
ctx->current_node = NULL; pop_node (ctx);
state_switch (ctx, STATE_NAMESPACE); state_switch (ctx, STATE_NAMESPACE);
} }
break; break;
@ -2919,7 +2935,7 @@ end_element_handler (GMarkupParseContext *context,
break; break;
if (require_end_element (context, ctx, "constant", element_name, error)) if (require_end_element (context, ctx, "constant", element_name, error))
{ {
ctx->current_node = NULL; pop_node (ctx);
switch (ctx->state) switch (ctx->state)
{ {
case STATE_NAMESPACE_CONSTANT: case STATE_NAMESPACE_CONSTANT: