Implement callbacks as part of struct fields. Fixes #557383

gir: embed <callback> inside <field>
typelib: if a field contains a callback, store it just after the FieldBlob
girepository API: no additions
This commit is contained in:
Tomeu Vizoso
2009-11-09 19:17:23 +01:00
parent 8ba5a13d17
commit 03dc6a590b
8 changed files with 142 additions and 34 deletions

View File

@@ -101,6 +101,7 @@ struct _ParseContext
GList *type_stack;
GList *type_parameters;
int type_depth;
gboolean in_embedded_type;
};
#define CURRENT_NODE(ctx) ((GIrNode *)((ctx)->node_stack->data))
@@ -719,6 +720,10 @@ start_function (GMarkupParseContext *context,
strcmp (element_name, "method") == 0 ||
strcmp (element_name, "callback") == 0);
break;
case STATE_STRUCT_FIELD:
ctx->in_embedded_type = TRUE;
found = (found || strcmp (element_name, "callback") == 0);
break;
default:
break;
}
@@ -782,6 +787,13 @@ start_function (GMarkupParseContext *context,
ctx->current_module->entries =
g_list_append (ctx->current_module->entries, function);
}
else if (ctx->current_typed)
{
GIrNodeField *field;
field = (GIrNodeField *)ctx->current_typed;
field->callback = function;
}
else
switch (CURRENT_NODE (ctx)->type)
{
@@ -2902,7 +2914,13 @@ end_element_handler (GMarkupParseContext *context,
}
else
{
if (CURRENT_NODE (ctx)->type == G_IR_NODE_INTERFACE)
g_debug("case STATE_FUNCTION %d", CURRENT_NODE (ctx)->type);
if (ctx->in_embedded_type)
{
ctx->in_embedded_type = FALSE;
state_switch (ctx, STATE_STRUCT_FIELD);
}
else if (CURRENT_NODE (ctx)->type == G_IR_NODE_INTERFACE)
state_switch (ctx, STATE_INTERFACE);
else if (CURRENT_NODE (ctx)->type == G_IR_NODE_OBJECT)
state_switch (ctx, STATE_CLASS);