Merge commit 'origin'
authorJohan Dahlin <jdahlin@litl.com>
Wed, 25 Feb 2009 17:38:39 +0000 (14:38 -0300)
committerJohan Dahlin <johan@gnome.org>
Wed, 25 Feb 2009 17:38:39 +0000 (14:38 -0300)
14 files changed:
configure.ac
girepository/ginvoke.c
giscanner/dumper.py
giscanner/giscannermodule.c
giscanner/sourcescanner.c
giscanner/sourcescanner.h
giscanner/sourcescanner.py
giscanner/transformer.py
tests/invoke/genericmarshaller.c
tests/scanner/foo-1.0-expected.gir
tests/scanner/foo-1.0-expected.tgir
tests/scanner/foo.c
tests/scanner/foo.h
tools/g-ir-scanner

index c81b00e..5487e75 100644 (file)
@@ -163,7 +163,7 @@ GIREPO_CFLAGS="$GIREPO_CFLAGS $FFI_CFLAGS"
 GIREPO_CFLAGS="$GIREPO_CFLAGS $GCOV_CFLAGS"
 
 # gtk-doc
-GTK_DOC_CHECK([1.11])
+GTK_DOC_CHECK([1.12])
 
 # Checks for header files.
 AC_HEADER_STDC
index e83a820..70d81f8 100644 (file)
@@ -407,18 +407,26 @@ gi_cclosure_marshal_generic (GClosure *closure,
   atypes = g_alloca (sizeof (ffi_type *) * n_args);
   args =  g_alloca (sizeof (gpointer) * n_args);
 
-  if (G_CCLOSURE_SWAP_DATA (closure))
+  if (n_param_values > 0)
     {
-      atypes[n_args-1] = value_to_ffi_type (param_values + 0,  
-                                            &args[n_args-1]);
-      atypes[0] = &ffi_type_pointer;
-      args[0] = &closure->data;
+      if (G_CCLOSURE_SWAP_DATA (closure))
+        {
+          atypes[n_args-1] = value_to_ffi_type (param_values + 0,  
+                                                &args[n_args-1]);
+          atypes[0] = &ffi_type_pointer;
+          args[0] = &closure->data;
+        }
+      else
+        {
+          atypes[0] = value_to_ffi_type (param_values + 0, &args[0]);
+          atypes[n_args-1] = &ffi_type_pointer;
+          args[n_args-1] = &closure->data;
+        }
     }
   else
     {
-      atypes[0] = value_to_ffi_type (param_values + 0, &args[0]);
-      atypes[n_args-1] = &ffi_type_pointer;
-      args[n_args-1] = &closure->data;
+      atypes[0] = &ffi_type_pointer;
+      args[0] = &closure->data;
     }
 
   for (i = 1; i < n_args - 1; i++)
index 95a66ab..c8f9927 100644 (file)
@@ -165,7 +165,8 @@ class DumpCompiler(object):
         return ['libtool']
 
     def _compile(self, output, *sources):
-        args = [self._compiler_cmd]
+        # Not strictly speaking correct, but easier than parsing shell
+        args = self._compiler_cmd.split()
         if self._compiler_cmd == 'gcc':
             args.append('-Wall')
         pkgconfig_flags = self._run_pkgconfig('--cflags')
index b7ac316..7d63784 100644 (file)
@@ -151,6 +151,19 @@ symbol_get_const_string (PyGISourceSymbol *self,
   return PyString_FromString (self->symbol->const_string);
 }
 
+static PyObject *
+symbol_get_source_filename (PyGISourceSymbol *self,
+                            void             *context)
+{
+  if (!self->symbol->source_filename)
+    {
+      Py_INCREF(Py_None);
+      return Py_None;
+    }
+
+  return PyString_FromString (self->symbol->source_filename);
+}
+
 static const PyGetSetDef _PyGISourceSymbol_getsets[] = {
   /* int ref_count; */
   { "type", (getter)symbol_get_type, NULL, NULL},
@@ -159,7 +172,8 @@ static const PyGetSetDef _PyGISourceSymbol_getsets[] = {
   { "base_type", (getter)symbol_get_base_type, NULL, NULL},
   /* gboolean const_int_set; */
   { "const_int", (getter)symbol_get_const_int, NULL, NULL},  
-  { "const_string", (getter)symbol_get_const_string, NULL, NULL},  
+  { "const_string", (getter)symbol_get_const_string, NULL, NULL},
+  { "source_filename", (getter)symbol_get_source_filename, NULL, NULL},
   { 0 }
 };
 
index 1a2508d..79d89cd 100644 (file)
@@ -60,6 +60,7 @@ gi_source_symbol_unref (GISourceSymbol * symbol)
       if (symbol->base_type)
         ctype_free (symbol->base_type);
       g_free (symbol->const_string);
+      g_free (symbol->source_filename);
       g_slice_free (GISourceSymbol, symbol);
     }
 }
@@ -245,6 +246,11 @@ gi_source_scanner_add_symbol (GISourceScanner  *scanner,
   if (found_filename || scanner->macro_scan)
     scanner->symbols = g_slist_prepend (scanner->symbols,
                                        gi_source_symbol_ref (symbol));
+  /* TODO: Refcounted string here or some other optimization */
+  if (found_filename && symbol->source_filename == NULL)
+    {
+      symbol->source_filename = g_strdup (scanner->current_filename);
+    }
 
   switch (symbol->type)
     {
index 276b0cb..bbc4977 100644 (file)
@@ -116,6 +116,7 @@ struct _GISourceSymbol
   gboolean const_int_set;
   int const_int;
   char *const_string;
+  char *source_filename;
 };
 
 struct _GISourceType
index 56aac93..30e624b 100644 (file)
@@ -179,6 +179,10 @@ class SourceSymbol(object):
         if self._symbol.base_type is not None:
             return SourceType(self._scanner, self._symbol.base_type)
 
+    @property
+    def source_filename(self):
+        return self._symbol.source_filename
+
 
 class SourceScanner(object):
 
index 6f9207a..58c2fbc 100644 (file)
@@ -419,7 +419,7 @@ class Transformer(object):
 
     def _create_type(self, source_type, is_param, is_retval):
         ctype = self._create_source_type(source_type)
-        if ctype == 'va_list':
+        if ctype.startswith('va_list'):
             raise SkipError()
         # FIXME: FILE* should not be skipped, it should be handled
         #        properly instead
@@ -460,6 +460,10 @@ class Transformer(object):
         return return_
 
     def _create_const(self, symbol):
+        # Don't create constants for non-public things
+        # http://bugzilla.gnome.org/show_bug.cgi?id=572790
+        if not symbol.source_filename.endswith('.h'):
+            return None
         name = self.remove_prefix(symbol.ident)
         if symbol.const_string is None:
             type_name = 'int'
index dd2509c..d023399 100644 (file)
@@ -150,12 +150,20 @@ test4_callback (TestObject *object,
   g_return_if_fail (ulong == 30L);
 }
 
+/* this callback has no "this" */
+static void
+test5_callback (gpointer user_data)
+{
+  g_return_if_fail (!strcmp (user_data, "user-data"));
+}
+
 static void
 test_cclosure_marshal (void)
 {
   TestObject *object;
   gchar *data = "user-data";
   int i;
+  GClosure *closure;
   
   g_type_init ();
   
@@ -189,7 +197,17 @@ test_cclosure_marshal (void)
   g_assert (i == 20);
 
   g_object_unref (object);
+
+  closure = g_cclosure_new (G_CALLBACK (test5_callback),
+                            data,
+                            NULL);
+  g_closure_ref (closure);
+  g_closure_sink (closure);
+  g_closure_set_marshal (closure, gi_cclosure_marshal_generic);
+  g_closure_invoke (closure, NULL, 0, NULL, NULL);
+  g_closure_unref (closure);
 }
+
   
 int main(void)
 {
index 6a1d8a4..2f82175 100644 (file)
@@ -132,6 +132,9 @@ and/or use gtk-doc annotations.  -->
         </return-value>
       </method>
     </record>
+    <constant name="DEFINE_SHOULD_BE_EXPOSED" value="should be exposed">
+      <type name="utf8"/>
+    </constant>
     <enumeration name="EnumFullname" c:type="FooEnumFullname">
       <member name="one" value="1" c:identifier="FOO_ENUM_FULLNAME_ONE"/>
       <member name="two" value="2" c:identifier="FOO_ENUM_FULLNAME_TWO"/>
index 3401fe2..edf58ef 100644 (file)
         </return-value>
       </method>
     </record>
+    <constant name="DEFINE_SHOULD_BE_EXPOSED" value="should be exposed">
+      <type name="utf8"/>
+    </constant>
     <enumeration name="EnumFullname">
       <member name="one" value="1"/>
       <member name="two" value="2"/>
index 0e5beb6..0488260 100644 (file)
@@ -1,5 +1,3 @@
-#define FOO_SUCCESS_INT 0x1138
-
 #include "foo.h"
 
 /* A hidden type not exposed publicly, similar to GUPNP's XML wrapper
@@ -524,3 +522,5 @@ void
 foo_buffer_some_method (FooBuffer *buffer)
 {
 }
+
+#define FOO_DEFINE_SHOULD_NOT_BE_EXPOSED "should not be exposed"
index 060b5d5..d3dd29f 100644 (file)
@@ -4,6 +4,10 @@
 #include <glib-object.h>
 #include "utility.h"
 
+#define FOO_SUCCESS_INT 0x1138
+
+#define FOO_DEFINE_SHOULD_BE_EXPOSED "should be exposed"
+
 #define FOO_TYPE_INTERFACE           (foo_interface_get_type ())
 #define FOO_INTERFACE(object)        (G_TYPE_CHECK_INSTANCE_CAST ((object), FOO_TYPE_INTERFACE, FooInterface))
 #define FOO_IS_INTERFACE(object)     (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_INTERFACE))
@@ -320,5 +324,6 @@ GQuark foo_error_quark (void);
 
 /* Should be skipped */
 void foo_some_variant (guint x, va_list args);
+void foo_some_variant_ptr (guint x, va_list *args);
 
 #endif /* __FOO_OBJECT_H__ */
index de20a7e..4b5b924 100755 (executable)
@@ -282,7 +282,9 @@ def main(args):
             arg.endswith('.h')):
             if not os.path.exists(arg):
                 _error('%s: no such a file or directory' % (arg, ))
-            filenames.append(arg)
+            # Make absolute, because we do comparisons inside scannerparser.c
+            # against the absolute path that cpp will give us
+            filenames.append(os.path.abspath(arg))
             
     cachestore = CacheStore()            
     transformer = Transformer(cachestore,