Compute field offsets and overall size for object structures
authorOwen Taylor <otaylor@redhat.com>
Tue, 11 Nov 2008 21:10:12 +0000 (21:10 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Tue, 11 Nov 2008 21:10:12 +0000 (21:10 +0000)
2008-11-11  Owen Taylor  <otaylor@redhat.com>

        Compute field offsets and overall size for object structures

        Bug 560326 – Fails to build Gtk-2.0.typelib with "Unexpected non-pointer
        field of type object in structure"

        Do basic computation of field offsets for objects and interfaces;
        this doesn't attempt to address all of the "mess" for virtual
        functions described in Bug 560281.

svn path=/trunk/; revision=888

ChangeLog
girepository/girnode.h
girepository/giroffsets.c

index 25fbd1a..afaa4e7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-11-11  Owen Taylor  <otaylor@redhat.com>
+
+       Compute field offsets and overall size for object structures
+
+       Bug 560326 – Fails to build Gtk-2.0.typelib with "Unexpected non-pointer
+       field of type object in structure"
+
+       Do basic computation of field offsets for objects and interfaces;
+       this doesn't attempt to address all of the "mess" for virtual
+       functions described in Bug 560281.
+
 2008-11-11  Tommi Komulainen  <tommi.komulainen@iki.fi>
 
        Bug 560308 – g-ir-compiler goes in infinite loop on Gdk-2.0.gir
index 971df6b..9829a93 100644 (file)
@@ -228,6 +228,9 @@ struct _GIrNodeInterface
   GList *interfaces;
   GList *prerequisites;
 
+  gint alignment;
+  gint size;
+  
   GList *members;
 };
 
index 66d1855..1844dd1 100644 (file)
@@ -150,6 +150,14 @@ get_interface_size_alignment (GIrNodeField *field,
        *alignment = struct_->alignment;
        break;
       }
+    case G_IR_NODE_OBJECT:
+    case G_IR_NODE_INTERFACE:
+      {
+       GIrNodeInterface *interface = (GIrNodeInterface *)iface;
+       *size = interface->size;
+       *alignment = interface->alignment;
+       break;
+      }
     case G_IR_NODE_UNION:
       {
        GIrNodeUnion *union_ = (GIrNodeUnion *)iface;
@@ -426,6 +434,19 @@ g_ir_node_compute_offsets (GIrNode   *node,
                                      &struct_->size, &struct_->alignment);
        break;
       }
+    case G_IR_NODE_OBJECT:
+    case G_IR_NODE_INTERFACE:
+      {
+       GIrNodeInterface *iface = (GIrNodeInterface *)node;
+
+       if (!check_needs_computation (node, module, iface->alignment))
+         return;
+
+       compute_struct_field_offsets (node, iface->members,
+                                     module, modules,
+                                     &iface->size, &iface->alignment);
+       break;
+      }
     case G_IR_NODE_UNION:
       {
        GIrNodeUnion *union_ = (GIrNodeUnion *)node;