+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:
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]?)
"," { 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; }
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;
%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
{
$$ = TYPE_QUALIFIER_RESTRICT;
}
+ | EXTENSION
+ {
+ $$ = TYPE_QUALIFIER_EXTENSION;
+ }
| VOLATILE
{
$$ = TYPE_QUALIFIER_VOLATILE;
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
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
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, ))