gobject-introspection r139 - in trunk: . tests/parser tools



Author: johan
Date: Mon Mar 10 18:43:36 2008
New Revision: 139
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=139&view=rev

Log:
2008-03-10  Johan Dahlin  <johan gnome org>

        * tests/parser/Makefile.am:
        * tests/parser/foo.c:
        * tools/scanner.c:
        * tools/scanner.h:
        * tools/scannerparser.y:
        Add an api to lex filenames.
        Lex all source .c files passed in on the command line.
        Scan sources in a test and a couple of private structures
        which should not be included in the generated gidl



Modified:
   trunk/ChangeLog
   trunk/tests/parser/Makefile.am
   trunk/tests/parser/foo.c
   trunk/tools/scanner.c
   trunk/tools/scanner.h
   trunk/tools/scannerparser.y

Modified: trunk/tests/parser/Makefile.am
==============================================================================
--- trunk/tests/parser/Makefile.am	(original)
+++ trunk/tests/parser/Makefile.am	Mon Mar 10 18:43:36 2008
@@ -11,7 +11,7 @@
 CLEANFILES = Foo.gidl
 EXTRA_DIST = Foo-expected.gidl
 
-SCANSOURCES = $(srcdir)/foo-object.h
+SCANSOURCES = $(srcdir)/foo.c $(srcdir)/foo-object.h
 
 Foo.gidl: libfoo.la foo-object.h $(top_builddir)/tools/g-idl-scanner
 	G_DEBUG=fatal_warnings $(top_builddir)/tools/g-idl-scanner -v \

Modified: trunk/tests/parser/foo.c
==============================================================================
--- trunk/tests/parser/foo.c	(original)
+++ trunk/tests/parser/foo.c	Mon Mar 10 18:43:36 2008
@@ -2,6 +2,16 @@
 
 #include "foo-object.h"
 
+typedef struct
+{
+  int i;
+} PrivateStruct;
+
+void foo_private_function (FooObject *foo)
+{
+
+}
+
 GType
 foo_interface_get_type (void)
 {

Modified: trunk/tools/scanner.c
==============================================================================
--- trunk/tools/scanner.c	(original)
+++ trunk/tools/scanner.c	Mon Mar 10 18:43:36 2008
@@ -1187,6 +1187,7 @@
   /* only add symbols of main file */
   gboolean found_filename = FALSE;
   GList *l;
+  
   for (l = igenerator->filenames; l != NULL; l = l->next)
     {
       if (strcmp (l->data, igenerator->current_filename) == 0)
@@ -1631,6 +1632,7 @@
   int gopt_argc, i;
   char **gopt_argv;
   GList *filenames = NULL;
+  GList *sources = NULL;
   GError *error = NULL;
   GList *l, *libraries = NULL;
   GList *cpp_options = NULL;
@@ -1676,7 +1678,8 @@
 	      break;
 	    }
 	}
-      else if (g_str_has_suffix (argv[i], ".h"))
+      else if (g_str_has_suffix (argv[i], ".h") ||
+	       g_str_has_suffix (argv[i], ".c"))
 	{
 	  gchar* filename;
 
@@ -1690,7 +1693,10 @@
 	  else
 	    filename = g_strdup (argv[i]);
 		
-	  filenames = g_list_append (filenames, g_realpath(filename));
+	  if (g_str_has_suffix (argv[i], ".h"))
+	    filenames = g_list_append (filenames, g_realpath (filename));
+	  else if(g_str_has_suffix (argv[i], ".c"))
+	    sources = g_list_append (sources, g_realpath (filename));
 	  g_free(filename);
 	}
       else if (g_str_has_suffix (argv[i], ".la") ||
@@ -1752,6 +1758,12 @@
 	g_igenerator_add_include_idl (igenerator, include_idls[i]);
     }
 
+  for (l = sources; l; l = l->next)
+    g_igenerator_lex_filename (igenerator, l->data);
+
+  g_list_foreach (sources, (GFunc)g_free, NULL);
+  g_list_free (sources);
+  
   tmp = g_igenerator_start_preprocessor (igenerator, cpp_options);
   if (!tmp)
     {

Modified: trunk/tools/scanner.h
==============================================================================
--- trunk/tools/scanner.h	(original)
+++ trunk/tools/scanner.h	Mon Mar 10 18:43:36 2008
@@ -155,6 +155,8 @@
 					const gchar *value);
 void         cdirective_free           (CDirective  *directive);
 
+gboolean g_igenerator_lex_filename  (GIGenerator *igenerator,
+				     const gchar *filename);
 gboolean g_igenerator_parse_file    (GIGenerator *igenerator,
 				     FILE        *file);
 void     g_igenerator_set_verbose   (GIGenerator *igenerator,

Modified: trunk/tools/scannerparser.y
==============================================================================
--- trunk/tools/scannerparser.y	(original)
+++ trunk/tools/scannerparser.y	Mon Mar 10 18:43:36 2008
@@ -1377,4 +1377,16 @@
   return TRUE;
 }
 
+gboolean
+g_igenerator_lex_filename (GIGenerator *igenerator, const gchar *filename)
+{
+  yyin = fopen (filename, "r");
+
+  while (yylex (igenerator) != YYEOF)
+    ;
+
+  fclose (yyin);
+  
+  return TRUE;
+}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]