summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--giscanner/scannerlexer.l15
-rw-r--r--giscanner/scannerparser.y10
-rw-r--r--giscanner/sourcescanner.h3
-rw-r--r--giscanner/sourcescanner.py6
5 files changed, 31 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index a239e802..424ddd38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
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.
+
+2008-08-31 Johan Dahlin <johan@gnome.org>
+
* giscanner/glibtransformer.py:
Clean up a huge if. Do not add methods or constructors
to enums/flags.
diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l
index c4eb1d41..45a47ab1 100644
--- a/giscanner/scannerlexer.l
+++ b/giscanner/scannerlexer.l
@@ -44,7 +44,7 @@ static int yywrap (void);
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 @@ stringtext ([^\"])|(\\.)
"," { 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 @@ process_directive (GISourceScanner *scanner)
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;
diff --git a/giscanner/scannerparser.y b/giscanner/scannerparser.y
index f21950db..dbde3223 100644
--- a/giscanner/scannerparser.y
+++ b/giscanner/scannerparser.y
@@ -70,9 +70,9 @@ static GHashTable *const_table = NULL;
%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
{
$$ = TYPE_QUALIFIER_RESTRICT;
}
+ | EXTENSION
+ {
+ $$ = TYPE_QUALIFIER_EXTENSION;
+ }
| VOLATILE
{
$$ = TYPE_QUALIFIER_VOLATILE;
diff --git a/giscanner/sourcescanner.h b/giscanner/sourcescanner.h
index 93fa450e..171a995a 100644
--- a/giscanner/sourcescanner.h
+++ b/giscanner/sourcescanner.h
@@ -75,7 +75,8 @@ typedef enum
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
diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py
index a58c44a2..46ab7f5a 100644
--- a/giscanner/sourcescanner.py
+++ b/giscanner/sourcescanner.py
@@ -56,6 +56,7 @@ TYPE_QUALIFIER_NONE = 0
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 @@ class SourceScanner(object):
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, ))