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
This commit is contained in:
Simon Feltman
2014-02-27 02:05:54 -08:00
parent 90a99b4fcc
commit cf4fb6a0fe
3 changed files with 71 additions and 50 deletions

View File

@@ -1773,10 +1773,17 @@ validate_object_blob (ValidateContext *ctx,
push_context (ctx, get_string_nofail (typelib, blob->name));
for (i = 0; i < blob->n_fields; i++, offset2 += sizeof (FieldBlob))
for (i = 0; i < blob->n_fields; i++)
{
FieldBlob *blob = (FieldBlob*) &typelib->data[offset2];
if (!validate_field_blob (ctx, offset2, error))
return FALSE;
offset2 += sizeof (FieldBlob);
/* Special case fields which are callbacks. */
if (blob->has_embedded_type)
offset2 += sizeof (CallbackBlob);
}
for (i = 0; i < blob->n_properties; i++, offset2 += sizeof (PropertyBlob))