[gobject-introspection] scannerlexer.l: Update to Support MSVC Preprocessor



commit 29838038a5661eaa5513ee9d7d922a12b65620bf
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Aug 5 19:33:48 2014 +0800

    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

 giscanner/scannerlexer.l |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l
index 941154d..e35e9d5 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);


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