summaryrefslogtreecommitdiff
path: root/girepository/girparser.c
diff options
context:
space:
mode:
authorSimon Feltman <sfeltman@src.gnome.org>2014-02-27 02:05:54 -0800
committerSimon Feltman <sfeltman@src.gnome.org>2014-02-27 13:51:18 -0800
commit7027bb256d0d1ab5dd58b6d7fb02ff2f547ae4c2 (patch)
treee145d73c84392eb5f3b8c72c46a377f027d29a8c /girepository/girparser.c
parent93a63a77cfda14f7bd69aef88d6a2502903d62f0 (diff)
downloadgobject-introspection-7027bb256d0d1ab5dd58b6d7fb02ff2f547ae4c2.tar.gz
g-ir-compiler: Add support for callback fields on GObjects
Use ParseState enum instead of a boolean for the ParseContexts embedded_type flag. This allows specific tracking of the embedded type currently being parsed which can now either be STATE_STRUCT_FIELD or STATE_CLASS_FIELD (or allow for future expansion). Add ParseState::STATE_NONE as the default for this field. Fix GObject FieldBlob validation to take into account the sizeof CallbackBlobs (copied from the struct validator). Add static g_object_info_get_field_offset which parallels g_struct_info_get_field_offset which is needed since callback fields may vary in size. https://bugzilla.gnome.org/show_bug.cgi?id=725198
Diffstat (limited to 'girepository/girparser.c')
-rw-r--r--girepository/girparser.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/girepository/girparser.c b/girepository/girparser.c
index 82005fc0..c7feb6ad 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -62,37 +62,38 @@ struct _GIrParser
typedef enum
{
+ STATE_NONE = 0,
STATE_START,
STATE_END,
STATE_REPOSITORY,
STATE_INCLUDE,
- STATE_C_INCLUDE,
- STATE_PACKAGE, /* 5 */
+ STATE_C_INCLUDE, /* 5 */
+ STATE_PACKAGE,
STATE_NAMESPACE,
STATE_ENUM,
STATE_BITFIELD,
- STATE_FUNCTION,
- STATE_FUNCTION_RETURN, /* 10 */
+ STATE_FUNCTION, /* 10 */
+ STATE_FUNCTION_RETURN,
STATE_FUNCTION_PARAMETERS,
STATE_FUNCTION_PARAMETER,
STATE_CLASS,
- STATE_CLASS_FIELD,
- STATE_CLASS_PROPERTY, /* 15 */
+ STATE_CLASS_FIELD, /* 15 */
+ STATE_CLASS_PROPERTY,
STATE_INTERFACE,
STATE_INTERFACE_PROPERTY,
STATE_INTERFACE_FIELD,
- STATE_IMPLEMENTS,
- STATE_PREREQUISITE, /* 20 */
+ STATE_IMPLEMENTS, /* 20 */
+ STATE_PREREQUISITE,
STATE_BOXED,
STATE_BOXED_FIELD,
STATE_STRUCT,
- STATE_STRUCT_FIELD,
- STATE_UNION, /* 25 */
+ STATE_STRUCT_FIELD, /* 25 */
+ STATE_UNION,
STATE_UNION_FIELD,
STATE_NAMESPACE_CONSTANT,
STATE_CLASS_CONSTANT,
- STATE_INTERFACE_CONSTANT,
- STATE_ALIAS, /* 30 */
+ STATE_INTERFACE_CONSTANT, /* 30 */
+ STATE_ALIAS,
STATE_TYPE,
STATE_ATTRIBUTE,
STATE_PASSTHROUGH
@@ -123,7 +124,7 @@ struct _ParseContext
GList *type_stack;
GList *type_parameters;
int type_depth;
- gboolean in_embedded_type;
+ ParseState in_embedded_state;
};
#define CURRENT_NODE(ctx) ((GIrNode *)((ctx)->node_stack->data))
@@ -807,7 +808,7 @@ start_function (GMarkupParseContext *context,
const gchar *throws;
GIrNodeFunction *function;
gboolean found = FALSE;
- gboolean in_embedded_type;
+ ParseState in_embedded_state = STATE_NONE;
switch (ctx->state)
{
@@ -830,8 +831,10 @@ start_function (GMarkupParseContext *context,
case STATE_ENUM:
found = strcmp (element_name, "function") == 0;
break;
+ case STATE_CLASS_FIELD:
case STATE_STRUCT_FIELD:
found = (found || strcmp (element_name, "callback") == 0);
+ in_embedded_state = ctx->state;
break;
default:
break;
@@ -840,12 +843,10 @@ start_function (GMarkupParseContext *context,
if (!found)
return FALSE;
- in_embedded_type = ctx->state == STATE_STRUCT_FIELD;
-
if (!introspectable_prelude (context, attribute_names, attribute_values, ctx, STATE_FUNCTION))
return TRUE;
- ctx->in_embedded_type = in_embedded_type;
+ ctx->in_embedded_state = in_embedded_state;
name = find_attribute ("name", attribute_names, attribute_values);
shadows = find_attribute ("shadows", attribute_names, attribute_values);
@@ -3210,10 +3211,10 @@ end_element_handler (GMarkupParseContext *context,
else
{
g_debug("case STATE_FUNCTION %d", CURRENT_NODE (ctx)->type);
- if (ctx->in_embedded_type)
+ if (ctx->in_embedded_state != STATE_NONE)
{
- ctx->in_embedded_type = FALSE;
- state_switch (ctx, STATE_STRUCT_FIELD);
+ state_switch (ctx, ctx->in_embedded_state);
+ ctx->in_embedded_state = STATE_NONE;
}
else if (CURRENT_NODE (ctx)->type == G_IR_NODE_INTERFACE)
state_switch (ctx, STATE_INTERFACE);