diff options
author | Colin Walters <walters@src.gnome.org> | 2008-08-07 03:51:44 +0000 |
---|---|---|
committer | Colin Walters <walters@src.gnome.org> | 2008-08-07 03:51:44 +0000 |
commit | 478ef21e02a010f06525f024e1959ae87e1b8c5e (patch) | |
tree | e1da2611f7a26ed6ca3fd4d920ee2baee05aa628 /tools/girparser.c | |
parent | f8ffe54635112240198063ecb7fc5581d5239832 (diff) | |
download | gobject-introspection-478ef21e02a010f06525f024e1959ae87e1b8c5e.tar.gz |
Slowly getting farther...
svn path=/branches/gir-compiler/; revision=308
Diffstat (limited to 'tools/girparser.c')
-rw-r--r-- | tools/girparser.c | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/tools/girparser.c b/tools/girparser.c index 2aa76dc5..9bd5e4d0 100644 --- a/tools/girparser.c +++ b/tools/girparser.c @@ -44,6 +44,7 @@ typedef enum STATE_OBJECT_PROPERTY, STATE_INTERFACE, STATE_INTERFACE_PROPERTY, + STATE_INTERFACE_FIELD, STATE_IMPLEMENTS, /* 15 */ STATE_REQUIRES, STATE_BOXED, @@ -116,7 +117,7 @@ find_attribute (const gchar *name, static void state_switch (ParseContext *ctx, ParseState newstate) { - fprintf (stderr, "switching to state: %d from %d\n", newstate, ctx->state); + fprintf (stderr, "state %d -> %d\n", ctx->state, newstate); ctx->prev_state = ctx->state; ctx->state = newstate; } @@ -473,10 +474,11 @@ start_function (GMarkupParseContext *context, ctx->state == STATE_INTERFACE || ctx->state == STATE_BOXED || ctx->state == STATE_UNION) && - strcmp (element_name, "method") == 0) || + (strcmp (element_name, "method") == 0 || + strcmp (element_name, "callback") == 0)) || ((ctx->state == STATE_OBJECT || ctx->state == STATE_BOXED) && - strcmp (element_name, "constructor") == 0) || + (strcmp (element_name, "constructor") == 0)) || (ctx->state == STATE_STRUCT && strcmp (element_name, "callback") == 0)) { const gchar *name; @@ -724,7 +726,8 @@ start_field (GMarkupParseContext *context, (ctx->state == STATE_OBJECT || ctx->state == STATE_BOXED || ctx->state == STATE_STRUCT || - ctx->state == STATE_UNION)) + ctx->state == STATE_UNION || + ctx->state == STATE_INTERFACE)) { const gchar *name; const gchar *type; @@ -782,6 +785,15 @@ start_field (GMarkupParseContext *context, state_switch (ctx, STATE_OBJECT_FIELD); } break; + case G_IR_NODE_INTERFACE: + { + GIrNodeInterface *iface; + + iface = (GIrNodeInterface *)ctx->current_node; + iface->members = g_list_append (iface->members, field); + state_switch (ctx, STATE_INTERFACE_FIELD); + } + break; case G_IR_NODE_BOXED: { GIrNodeBoxed *boxed; @@ -1257,8 +1269,9 @@ start_type (GMarkupParseContext *context, const gchar *ctype; if (strcmp (element_name, "type") != 0 || - !(ctx->state == STATE_FUNCTION_PARAMETER || ctx->state == STATE_FUNCTION_RETURN - || ctx->state == STATE_STRUCT_FIELD || ctx->state == STATE_OBJECT_PROPERTY)) + !(ctx->state == STATE_FUNCTION_PARAMETER || ctx->state == STATE_FUNCTION_RETURN || + ctx->state == STATE_STRUCT_FIELD || ctx->state == STATE_OBJECT_PROPERTY || + ctx->state == STATE_OBJECT_FIELD || ctx->state == STATE_INTERFACE_FIELD)) return FALSE; if (!ctx->current_typed) @@ -1365,8 +1378,6 @@ start_signal (GMarkupParseContext *context, if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); - else if (when == NULL) - MISSING_ATTRIBUTE (context, error, element_name, "when"); else { GIrNodeInterface *iface; @@ -1379,10 +1390,10 @@ start_signal (GMarkupParseContext *context, signal->run_first = FALSE; signal->run_last = FALSE; signal->run_cleanup = FALSE; - if (strcmp (when, "FIRST") == 0) - signal->run_first = TRUE; - else if (strcmp (when, "LAST") == 0) + if (when == NULL || strcmp (when, "LAST") == 0) signal->run_last = TRUE; + else if (strcmp (when, "FIRST") == 0) + signal->run_first = TRUE; else signal->run_cleanup = TRUE; @@ -1710,6 +1721,13 @@ start_element_handler (GMarkupParseContext *context, break; + case 'g': + if (start_signal (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + break; + case 'i': if (start_interface (context, element_name, attribute_names, attribute_values, @@ -1851,13 +1869,6 @@ start_element_handler (GMarkupParseContext *context, goto out; break; - case 's': - if (start_signal (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; - break; - case 'u': if (start_union (context, element_name, attribute_names, attribute_values, @@ -2005,6 +2016,13 @@ end_element_handler (GMarkupParseContext *context, } break; + case STATE_INTERFACE_FIELD: + if (strcmp (element_name, "field") == 0) + { + state_switch (ctx, STATE_INTERFACE); + } + break; + case STATE_INTERFACE: if (strcmp (element_name, "interface") == 0) { |