diff options
author | Tomeu Vizoso <tomeu@sugarlabs.org> | 2009-11-09 19:17:23 +0100 |
---|---|---|
committer | Tomeu Vizoso <tomeu@sugarlabs.org> | 2009-11-11 13:55:00 +0100 |
commit | f8693bda3775f6339f38a17c037ac7bc4a4cc3f7 (patch) | |
tree | 89456982ed5b6e8e5850a7c05f55a50f3be0c5fa /girepository/girnode.c | |
parent | 3715b02198c9efc34d70f489d4e55a39456d8f99 (diff) | |
download | gobject-introspection-f8693bda3775f6339f38a17c037ac7bc4a4cc3f7.tar.gz |
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
Diffstat (limited to 'girepository/girnode.c')
-rw-r--r-- | girepository/girnode.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/girepository/girnode.c b/girepository/girnode.c index 22e821e0..9f623453 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -279,6 +279,7 @@ g_ir_node_free (GIrNode *node) g_free (node->name); g_ir_node_free ((GIrNode *)field->type); + g_ir_node_free ((GIrNode *)field->callback); } break; @@ -508,7 +509,13 @@ g_ir_node_get_size (GIrNode *node) break; case G_IR_NODE_FIELD: - size = sizeof (FieldBlob); + { + GIrNodeField *field = (GIrNodeField *)node; + + size = sizeof (FieldBlob); + if (field->callback) + size += g_ir_node_get_size ((GIrNode *)field->callback); + } break; case G_IR_NODE_CONSTANT: @@ -797,7 +804,10 @@ g_ir_node_get_full_size_internal (GIrNode *parent, size = sizeof (FieldBlob); size += ALIGN_VALUE (strlen (node->name) + 1, 4); - size += g_ir_node_get_full_size_internal (node, (GIrNode *)field->type); + if (field->callback) + size += g_ir_node_get_full_size_internal (node, (GIrNode *)field->callback); + else + size += g_ir_node_get_full_size_internal (node, (GIrNode *)field->type); } break; @@ -1587,8 +1597,6 @@ g_ir_node_build_typelib (GIrNode *node, FieldBlob *blob; blob = (FieldBlob *)&data[*offset]; - /* We handle the size member specially below, so subtract it */ - *offset += sizeof (FieldBlob) - sizeof (SimpleTypeBlob); blob->name = write_string (node->name, strings, data, offset2); blob->readable = field->readable; @@ -1600,8 +1608,22 @@ g_ir_node_build_typelib (GIrNode *node, else blob->struct_offset = 0xFFFF; /* mark as unknown */ - g_ir_node_build_typelib ((GIrNode *)field->type, - node, build, offset, offset2); + if (field->callback) + { + blob->has_embedded_type = TRUE; + blob->type.offset = GI_INFO_TYPE_CALLBACK; + *offset += sizeof (FieldBlob); + g_ir_node_build_typelib ((GIrNode *)field->callback, + node, build, offset, offset2); + } + else + { + blob->has_embedded_type = FALSE; + /* We handle the size member specially below, so subtract it */ + *offset += sizeof (FieldBlob) - sizeof (SimpleTypeBlob); + g_ir_node_build_typelib ((GIrNode *)field->type, + node, build, offset, offset2); + } } break; |