Przeglądaj źródła

*** empty log message ***

David Rose 25 lat temu
rodzic
commit
ee8f10684d

+ 1 - 1
dtool/src/cppparser/cppBison.yxx

@@ -2029,7 +2029,7 @@ element:
 	| KW_SHORT | KW_SIGNED | KW_SIZEOF | KW_STATIC | KW_STATIC_CAST
 	| KW_STRUCT | KW_THROW | KW_TRUE | KW_TRY | KW_TYPEDEF | KW_TYPENAME
 	| KW_UNION | KW_UNSIGNED | KW_VIRTUAL | KW_VOID | KW_VOLATILE
-	| KW_WHILE
+	| KW_WHILE | TOKENPASTE
 	| KW_OPERATOR
 {
 }

+ 37 - 2
dtool/src/cppparser/cppFile.cxx

@@ -58,6 +58,42 @@ CPPFile::
 ~CPPFile() {
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: CPPFile::is_c_or_i_file
+//       Access: Public
+//  Description: Returns true if the file appears to be a C or C++
+//               source code file based on its extension.  That is,
+//               returns true if the filename ends in .c, .C, .cc,
+//               .cpp, or any of a series of likely extensions.
+////////////////////////////////////////////////////////////////////
+bool CPPFile::
+is_c_or_i_file() const {
+  return is_c_or_i_file(_filename);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: CPPFile::is_c_or_i_file
+//       Access: Public, Static
+//  Description: Returns true if the file appears to be a C or C++
+//               source code file based on its extension.  That is,
+//               returns true if the filename ends in .c, .C, .cc,
+//               .cpp, or any of a series of likely extensions.
+////////////////////////////////////////////////////////////////////
+bool CPPFile::
+is_c_or_i_file(const Filename &filename) {
+  string extension = filename.get_extension();
+  // downcase the extension.
+  for (string::iterator ei = extension.begin(); 
+       ei != extension.end();
+       ++ei) {
+    (*ei) = tolower(*ei);
+  }
+    
+  return (extension == "c" || extension == "cc" || 
+	  extension == "cpp" || extension == "c++" || extension == "cxx" ||
+	  extension == "i");
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: CPPFile::is_c_file
 //       Access: Public
@@ -90,8 +126,7 @@ is_c_file(const Filename &filename) {
   }
     
   return (extension == "c" || extension == "cc" || 
-	  extension == "cpp" || extension == "c++" || extension == "cxx" ||
-	  extension == "i");
+	  extension == "cpp" || extension == "c++" || extension == "cxx");
 }
 
 ////////////////////////////////////////////////////////////////////

+ 3 - 0
dtool/src/cppparser/cppFile.h

@@ -32,6 +32,9 @@ public:
   void operator = (const CPPFile &copy);
   ~CPPFile();
 
+  bool is_c_or_i_file() const;
+  static bool is_c_or_i_file(const Filename &filename);
+
   bool is_c_file() const;
   static bool is_c_file(const Filename &filename);
 

+ 3 - 3
dtool/src/interrogate/interrogateBuilder.cxx

@@ -66,7 +66,7 @@ add_source_file(const string &filename) {
     return;
   }
 
-  if (!CPPFile::is_c_file(filename)) {
+  if (!CPPFile::is_c_or_i_file(filename)) {
     _include_files.insert('"' + filename + '"');
   }
 }
@@ -198,7 +198,7 @@ build() {
        ++ii) {
     const string &filename = (*ii);
     // Don't add any C files to the include list.
-    if (!CPPFile::is_c_file(filename)) {
+    if (!CPPFile::is_c_or_i_file(filename)) {
       _include_files.insert('"' + filename + '"');
     }
   }
@@ -207,7 +207,7 @@ build() {
        ++ii) {
     const string &filename = (*ii);
     // Don't add any C files to the include list.
-    if (!CPPFile::is_c_file(filename)) {
+    if (!CPPFile::is_c_or_i_file(filename)) {
       _include_files.insert('<' + filename + '>');
     }
   }