[scanner] Also parse C++ files
authorGustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
Tue, 17 Aug 2010 14:31:17 +0000 (11:31 -0300)
committerGustavo Noronha Silva <gns@gnome.org>
Tue, 17 Aug 2010 14:43:31 +0000 (11:43 -0300)
This is to support cases such as WebKitGTK+, that have C API
implemented in C++ files. Do note this does not mean we support proper
C++ parsing.

https://bugzilla.gnome.org/show_bug.cgi?id=627152

giscanner/scannermain.py
giscanner/sourcescanner.py

index 363f6f6d4a92e256e6c8340a731d8b711b02d81c..36942826908bc73ca64fe3733f7b5ee48560dc65 100644 (file)
@@ -266,8 +266,12 @@ def scanner_main(args):
 
     filenames = []
     for arg in args:
-        if (arg.endswith('.c') or
-            arg.endswith('.h')):
+        # We don't support real C++ parsing yet, but we should be able
+        # to understand C API implemented in C++ files.
+        if (arg.endswith('.c') or arg.endswith('.cpp') or
+            arg.endswith('.cc') or arg.endswith('.cxx') or
+            arg.endswith('.h') or arg.endswith('.hpp') or
+            arg.endswith('.hxx')):
             if not os.path.exists(arg):
                 _error('%s: no such a file or directory' % (arg, ))
             # Make absolute, because we do comparisons inside scannerparser.c
index ae3d29d21d223431984c25023613e4245a2f2d7f..cd7a4321018083a21b668b6911af40fa98300e5c 100644 (file)
@@ -220,7 +220,8 @@ class SourceScanner(object):
 
         headers = []
         for filename in filenames:
-            if filename.endswith('.c'):
+            if (filename.endswith('.c') or filename.endswith('.cpp') or
+                filename.endswith('.cc') or filename.endswith('.cxx')):
                 filename = os.path.abspath(filename)
                 self._scanner.lex_filename(filename)
             else: