Revert "[GIRPARSER] - tidy up of var args."
[gnome.gobject-introspection] / girepository / girparser.c
index 12c1d98..17b5f6e 100644 (file)
@@ -2201,6 +2201,7 @@ start_struct (GMarkupParseContext *context,
       const gchar *gtype_name;
       const gchar *gtype_init;
       const gchar *gtype_struct;
+      const gchar *foreign;
       GIrNodeStruct *struct_;
 
       name = find_attribute ("name", attribute_names, attribute_values);
@@ -2209,6 +2210,7 @@ start_struct (GMarkupParseContext *context,
       gtype_name = find_attribute ("glib:type-name", attribute_names, attribute_values);
       gtype_init = find_attribute ("glib:get-type", attribute_names, attribute_values);
       gtype_struct = find_attribute ("glib:is-gtype-struct-for", attribute_names, attribute_values);
+      foreign = find_attribute ("foreign", attribute_names, attribute_values);
 
       if (name == NULL && ctx->node_stack == NULL)
        {
@@ -2242,6 +2244,8 @@ start_struct (GMarkupParseContext *context,
       struct_->gtype_name = g_strdup (gtype_name);
       struct_->gtype_init = g_strdup (gtype_init);
 
+      struct_->foreign = (g_strcmp0 (foreign, "1") == 0);
+
       if (ctx->node_stack == NULL)
         ctx->current_module->entries =
           g_list_append (ctx->current_module->entries, struct_);
@@ -3191,6 +3195,28 @@ post_filter_toplevel_varargs_functions (GList *list,
   return list;
 }
 
+
+/* 
+  quick look up of node in the list..
+  return null, or a pointer to the list item..
+ */
+static GList *
+node_find_in_list(GList *list, const char *name)
+{
+  GList *link;
+  for (link = list;
+       link;
+       link = link->next)
+    {
+      if (!strcmp (name, ((GIrNode *)link->data)->name))
+       return link;
+    }
+  return NULL;
+}
+
+
+
 static GList *
 post_filter_varargs_functions (GList *list, GList ** varargs_callbacks_out)
 {
@@ -3225,22 +3251,59 @@ post_filter_varargs_functions (GList *list, GList ** varargs_callbacks_out)
 
              if (node->type->is_interface)
                {
-                 GList *callback;
-                 for (callback = varargs_callbacks;
-                      callback;
-                      callback = callback->next)
-                   {
-                     if (!strcmp (node->type->interface,
-                                  ((GIrNode *)varargs_callbacks->data)->name))
-                       {
-                         list = g_list_delete_link (list, link);
-                         function_done = TRUE;
-                         break;
-                       }
-                   }
+       
+                 GList *callback = node_find_in_list(
+                                       varargs_callbacks, 
+                                       ((GIrNode *)callback->data)->name);
+                 if (callback)
+                    {
+                      list = g_list_delete_link (list, link);
+                      function_done = TRUE;
+                    }
+                    
                }
            }
        }
+
+       if (node->type == G_IR_NODE_FIELD)
+          {
+           /*
+               this is a field, if the member is a blacklisted callback, 
+               then we need to flag it as to be generated as a void*
+            */
+           GIrNodeField *fnode = (GIrNodeField *)node;
+           GIrNodeType * tnode;
+           GList *match;
+
+           if (!fnode->type)
+              continue;
+           
+           tnode = (GIrNodeType *)fnode->type;
+            /* field is not an interface. */
+           if (!tnode->is_interface)
+             continue;
+             
+           match = node_find_in_list(
+                       varargs_callbacks, tnode->interface);
+
+            if (!match)
+             continue;
+
+           /*
+               we now have a field which is pointing to an blacklisted callback.
+              so need modify the type so it points to void* and
+               is not read/or writable.
+            */
+           fnode->readable = FALSE;
+           fnode->writable = FALSE;
+           
+           tnode->tag          = GI_TYPE_TAG_VOID;
+           tnode->is_interface = FALSE;
+           tnode->is_pointer   = TRUE;
+           tnode->is_basic     = TRUE;
+         }
+
+        
     }
 
   *varargs_callbacks_out = varargs_callbacks;