gobject-introspection r553 - in trunk: . giscanner



Author: johan
Date: Sun Aug 31 16:10:18 2008
New Revision: 553
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=553&view=rev

Log:
2008-08-31  Johan Dahlin  <johan gnome org>

    * giscanner/scannerlexer.l:
    * giscanner/scannerparser.y:
    * giscanner/sourcescanner.h:
    * giscanner/sourcescanner.py:
    Parse GCC extensions in the parser instead of just undeffing them
    in the pre-processor.



Modified:
   trunk/ChangeLog
   trunk/giscanner/scannerlexer.l
   trunk/giscanner/scannerparser.y
   trunk/giscanner/sourcescanner.h
   trunk/giscanner/sourcescanner.py

Modified: trunk/giscanner/scannerlexer.l
==============================================================================
--- trunk/giscanner/scannerlexer.l	(original)
+++ trunk/giscanner/scannerlexer.l	Sun Aug 31 16:10:18 2008
@@ -44,7 +44,7 @@
 static void parse_comment (GISourceScanner *scanner);
 static void process_directive (GISourceScanner *scanner);
 static int check_identifier (GISourceScanner *scanner, const char *);
-static int parse_attribute (void);
+static int parse_ignored_macro (void);
 %}
 
 intsuffix				([uU][lL]?[lL]?)|([lL][lL]?[uU]?)
@@ -118,7 +118,12 @@
 ","					{ return ','; }
 "->"					{ return ARROW; }
 
-"__attribute__" 			{ if (!parse_attribute()) REJECT; }
+"__attribute__" 		        { if (!parse_ignored_macro()) REJECT; }
+"__const"                               { return CONST; }
+"__extension__"                         { return EXTENSION; }
+"__inline"				{ return INLINE; }
+"__nonnull" 			        { if (!parse_ignored_macro()) REJECT; }
+"__restrict"				{ return RESTRICT; }
 
 [a-zA-Z_][a-zA-Z_0-9]*			{ if (scanner->macro_scan) return IDENTIFIER; else REJECT; }
 
@@ -409,8 +414,12 @@
 	g_string_free (filename_builder, TRUE);
 }
 
+/*
+ * This parses a macro which is ignored, such as
+ * __attribute__(x)
+ */
 static int
-parse_attribute (void)
+parse_ignored_macro (void)
 {
 	int c;
 	int nest;

Modified: trunk/giscanner/scannerparser.y
==============================================================================
--- trunk/giscanner/scannerparser.y	(original)
+++ trunk/giscanner/scannerparser.y	Sun Aug 31 16:10:18 2008
@@ -70,9 +70,9 @@
 %token SLEQ SREQ EQ NOTEQ LTEQ GTEQ ANDAND OROR PLUSPLUS MINUSMINUS ARROW
 
 %token AUTO BOOL BREAK CASE CHAR CONST CONTINUE DEFAULT DO DOUBLE ELSE ENUM
-%token EXTERN FLOAT FOR GOTO IF INLINE INT LONG REGISTER RESTRICT RETURN SHORT
-%token SIGNED SIZEOF STATIC STRUCT SWITCH TYPEDEF UNION UNSIGNED VOID VOLATILE
-%token WHILE
+%token EXTENSION EXTERN FLOAT FOR GOTO IF INLINE INT LONG REGISTER RESTRICT
+%token RETURN SHORT SIGNED SIZEOF STATIC STRUCT SWITCH TYPEDEF UNION UNSIGNED
+%token VOID VOLATILE WHILE
 
 %token FUNCTION_MACRO OBJECT_MACRO
 
@@ -858,6 +858,10 @@
 	  {
 		$$ = TYPE_QUALIFIER_RESTRICT;
 	  }
+	| EXTENSION
+	  {
+		$$ = TYPE_QUALIFIER_EXTENSION;
+	  }
 	| VOLATILE
 	  {
 		$$ = TYPE_QUALIFIER_VOLATILE;

Modified: trunk/giscanner/sourcescanner.h
==============================================================================
--- trunk/giscanner/sourcescanner.h	(original)
+++ trunk/giscanner/sourcescanner.h	Sun Aug 31 16:10:18 2008
@@ -75,7 +75,8 @@
   TYPE_QUALIFIER_NONE = 0,
   TYPE_QUALIFIER_CONST = 1 << 1,
   TYPE_QUALIFIER_RESTRICT = 1 << 2,
-  TYPE_QUALIFIER_VOLATILE = 1 << 3
+  TYPE_QUALIFIER_VOLATILE = 1 << 3,
+  TYPE_QUALIFIER_EXTENSION = 1 << 4
 } TypeQualifier;
 
 typedef enum

Modified: trunk/giscanner/sourcescanner.py
==============================================================================
--- trunk/giscanner/sourcescanner.py	(original)
+++ trunk/giscanner/sourcescanner.py	Sun Aug 31 16:10:18 2008
@@ -56,6 +56,7 @@
 TYPE_QUALIFIER_CONST = 1 << 1
 TYPE_QUALIFIER_RESTRICT = 1 << 2
 TYPE_QUALIFIER_VOLATILE = 1 << 3
+TYPE_QUALIFIER_EXTENSION = 1 << 4
 
 FUNCTION_NONE = 0
 FUNCTION_INLINE = 1 << 1
@@ -231,11 +232,6 @@
                                 stdin=subprocess.PIPE,
                                 stdout=subprocess.PIPE)
 
-        proc.stdin.write('#define __const\n')
-        proc.stdin.write('#define __extension__\n')
-        proc.stdin.write('#define __inline\n')
-        proc.stdin.write('#define __restrict\n')
-
         for define in defines:
             proc.stdin.write('#ifndef %s\n' % (define, ))
             proc.stdin.write('# define %s\n' % (define, ))



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