From ee8f10684d02460dc3011062f672d4dfa75c1a6d Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 8 Mar 2001 21:04:54 +0000 Subject: [PATCH] *** empty log message *** --- dtool/src/cppparser/cppBison.yxx | 2 +- dtool/src/cppparser/cppFile.cxx | 39 +++++++++++++++++++- dtool/src/cppparser/cppFile.h | 3 ++ dtool/src/interrogate/interrogateBuilder.cxx | 6 +-- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/dtool/src/cppparser/cppBison.yxx b/dtool/src/cppparser/cppBison.yxx index 9de089eb8f..1c2f51a0ae 100644 --- a/dtool/src/cppparser/cppBison.yxx +++ b/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 { } diff --git a/dtool/src/cppparser/cppFile.cxx b/dtool/src/cppparser/cppFile.cxx index 4750f4bc20..1809d7e8cf 100644 --- a/dtool/src/cppparser/cppFile.cxx +++ b/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"); } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/cppparser/cppFile.h b/dtool/src/cppparser/cppFile.h index fad4a085ef..aa3fff3607 100644 --- a/dtool/src/cppparser/cppFile.h +++ b/dtool/src/cppparser/cppFile.h @@ -32,6 +32,9 @@ public: void operator = (const CPPFile ©); ~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); diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index 2ce1cc6fdf..dab6b4ac27 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/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 + '>'); } }