summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2014-08-05 19:33:48 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2014-08-15 16:58:20 +0800
commit29838038a5661eaa5513ee9d7d922a12b65620bf (patch)
tree239df0fc90b5a2b533cf5f4a6e8161d77c8281b7
parentab3f38c8fdf21930c97026cd25a20efc1d52baa1 (diff)
downloadgobject-introspection-29838038a5661eaa5513ee9d7d922a12b65620bf.tar.gz
scannerlexer.l: Update to Support MSVC Preprocessor
This updates giscanner/scannerlexer.l by ignoring the Visual C++-specific directives, so that the scanner will not bail out while trying to produce the introspection dumper program source code, and silence many of the warnings that are produced in the process. As the Visual C++ processor produces slightly different line markers, we need to handle this here as well, otherwise the sources/headers would not be processed to acquire the _get_type and _get_gtype symbols to put in the introspection dumper sources, producing bad results. https://bugzilla.gnome.org/show_bug.cgi?id=728313
-rw-r--r--giscanner/scannerlexer.l23
1 files changed, 18 insertions, 5 deletions
diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l
index 941154d8..e35e9d5d 100644
--- a/giscanner/scannerlexer.l
+++ b/giscanner/scannerlexer.l
@@ -55,7 +55,7 @@ extern int yylex (GISourceScanner *scanner);
static int yywrap (void);
static void parse_comment (GISourceScanner *scanner);
static void parse_trigraph (GISourceScanner *scanner);
-static void process_linemarks (GISourceScanner *scanner);
+static void process_linemarks (GISourceScanner *scanner, gboolean has_line);
static int check_identifier (GISourceScanner *scanner, const char *);
static int parse_ignored_macro (void);
static void print_error (GISourceScanner *scanner);
@@ -98,7 +98,8 @@ stringtext ([^\\\"])|(\\.)
"#endif".*"\n" { return ENDIF_COND; }
"#pragma ".*"\n" { /* Ignore pragma. */ }
-"# "[0-9]+" ".*"\n" { process_linemarks(scanner); }
+"# "[0-9]+" ".*"\n" { process_linemarks(scanner, FALSE); }
+"#line "[0-9]+" ".*"\n" { process_linemarks(scanner, TRUE); }
"#" { }
"{" { return '{'; }
"<%" { return '{'; }
@@ -171,6 +172,14 @@ stringtext ([^\\\"])|(\\.)
"__volatile" { return VOLATILE; }
"__volatile__" { return VOLATILE; }
"_Bool" { return BOOL; }
+"typedef char __static_assert_t".*"\n" { /* Ignore */ }
+"__cdecl" { /* Ignore */ }
+"__declspec(deprecated(".*"))" { /* Ignore */ }
+"__declspec"[\t ]*"("[a-z\t ]+")" { /* Ignore */ }
+"__stdcall" { /* ignore */ }
+"__w64" { /* ignore */ }
+"__int64" { return INT; }
+
"G_GINT64_CONSTANT" { return INTL_CONST; }
"G_GUINT64_CONSTANT" { return INTUL_CONST; }
@@ -389,13 +398,17 @@ _realpath (const char *path)
**/
static void
-process_linemarks (GISourceScanner *scanner)
+process_linemarks (GISourceScanner *scanner, gboolean has_line)
{
char escaped_filename[1025];
char *filename;
- char *real;
+ char *real;
+
+ if (has_line)
+ sscanf(yytext, "#line %d \"%1024[^\"]\"", &lineno, escaped_filename);
+ else
+ sscanf(yytext, "# %d \"%1024[^\"]\"", &lineno, escaped_filename);
- sscanf(yytext, "# %d \"%1024[^\"]\"", &lineno, escaped_filename);
filename = g_strcompress (escaped_filename);
real = _realpath (filename);