From 64a4caaf421851ae96b87b0f270f290d9763e10e Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Mon, 15 Oct 2012 07:50:06 +0000 Subject: [PATCH] updated CppParser --- CppParser/CppParser.progen | 6 +- CppParser/CppParser_vs90.vcproj | 4 ++ CppParser/Makefile | 4 +- CppParser/include/Poco/CppParser/Attributes.h | 6 +- .../include/Poco/CppParser/AttributesParser.h | 6 +- CppParser/include/Poco/CppParser/BuiltIn.h | 69 +++++++++++++++++++ CppParser/include/Poco/CppParser/CppParser.h | 2 +- CppParser/include/Poco/CppParser/CppToken.h | 2 +- CppParser/include/Poco/CppParser/Decl.h | 2 +- CppParser/include/Poco/CppParser/Enum.h | 2 +- CppParser/include/Poco/CppParser/EnumValue.h | 2 +- CppParser/include/Poco/CppParser/Function.h | 2 +- CppParser/include/Poco/CppParser/NameSpace.h | 2 +- CppParser/include/Poco/CppParser/Parameter.h | 2 +- CppParser/include/Poco/CppParser/Parser.h | 2 +- CppParser/include/Poco/CppParser/Struct.h | 2 +- CppParser/include/Poco/CppParser/Symbol.h | 14 +++- CppParser/include/Poco/CppParser/Tokenizer.h | 2 +- CppParser/include/Poco/CppParser/TypeDef.h | 2 +- CppParser/include/Poco/CppParser/Utility.h | 2 +- CppParser/include/Poco/CppParser/Variable.h | 2 +- CppParser/src/Attributes.cpp | 10 ++- CppParser/src/AttributesParser.cpp | 2 +- CppParser/src/BuiltIn.cpp | 69 +++++++++++++++++++ CppParser/src/CppToken.cpp | 7 +- CppParser/src/Decl.cpp | 2 +- CppParser/src/Enum.cpp | 2 +- CppParser/src/EnumValue.cpp | 2 +- CppParser/src/Function.cpp | 2 +- CppParser/src/NameSpace.cpp | 2 +- CppParser/src/Parameter.cpp | 14 ++-- CppParser/src/Parser.cpp | 9 ++- CppParser/src/Struct.cpp | 2 +- CppParser/src/Symbol.cpp | 15 +++- CppParser/src/Tokenizer.cpp | 2 +- CppParser/src/TypeDef.cpp | 2 +- CppParser/src/Utility.cpp | 10 +-- CppParser/src/Variable.cpp | 2 +- 38 files changed, 234 insertions(+), 57 deletions(-) create mode 100644 CppParser/include/Poco/CppParser/BuiltIn.h create mode 100644 CppParser/src/BuiltIn.cpp diff --git a/CppParser/CppParser.progen b/CppParser/CppParser.progen index bee8c3589..0739d4568 100644 --- a/CppParser/CppParser.progen +++ b/CppParser/CppParser.progen @@ -4,14 +4,12 @@ vc.project.target = Poco${vc.project.name} vc.project.type = library vc.project.pocobase = .. vc.project.outdir = ${vc.project.pocobase} -vc.project.platforms = Win32, x64 +vc.project.platforms = Win32, x64, WinCE vc.project.configurations = debug_shared, release_shared, debug_static_mt, release_static_mt, debug_static_md, release_static_md -vc.project.prototype = CppParser_vs90.vcproj +vc.project.prototype = ${vc.project.name}_vs90.vcproj vc.project.compiler.include = ..\\Foundation\\include -vc.project.compiler.defines = vc.project.compiler.defines.shared = ${vc.project.name}_EXPORTS vc.project.compiler.defines.debug_shared = ${vc.project.compiler.defines.shared} vc.project.compiler.defines.release_shared = ${vc.project.compiler.defines.shared} -vc.project.linker.dependencies = vc.solution.create = true vc.solution.include = testsuite\\TestSuite diff --git a/CppParser/CppParser_vs90.vcproj b/CppParser/CppParser_vs90.vcproj index cfd57e2c3..667993e9a 100644 --- a/CppParser/CppParser_vs90.vcproj +++ b/CppParser/CppParser_vs90.vcproj @@ -411,6 +411,8 @@ Name="Symbol Table"> + + [,...] /// where is - /// = + /// [=] /// is a valid C++ identifier, or two identifiers separated by /// a period (struct accessor notation). - /// is a string, integer, bool literal, or a complex value + /// is a string, integer, identifier, bool literal, or a complex value /// in the form /// {=[,=...]} { diff --git a/CppParser/include/Poco/CppParser/BuiltIn.h b/CppParser/include/Poco/CppParser/BuiltIn.h new file mode 100644 index 000000000..5b17dcbe6 --- /dev/null +++ b/CppParser/include/Poco/CppParser/BuiltIn.h @@ -0,0 +1,69 @@ +// +// BuiltIn.h +// +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/BuiltIn.h#1 $ +// +// Library: CppParser +// Package: SymbolTable +// Module: BuiltIn +// +// Definition of the BuiltIn class. +// +// Copyright (c) 2011, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// Permission is hereby granted, free of charge, to any person or organization +// obtaining a copy of the software and accompanying documentation covered by +// this license (the "Software") to use, reproduce, display, distribute, +// execute, and transmit the Software, and to prepare derivative works of the +// Software, and to permit third-parties to whom the Software is furnished to +// do so, all subject to the following: +// +// The copyright notices in the Software and this entire statement, including +// the above license grant, this restriction and the following disclaimer, +// must be included in all copies of the Software, in whole or in part, and +// all derivative works of the Software, unless such copies or derivative +// works are solely in the form of machine-executable object code generated by +// a source language processor. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// + + +#ifndef CppParser_BuiltIn_INCLUDED +#define CppParser_BuiltIn_INCLUDED + + +#include "Poco/CppParser/CppParser.h" +#include "Poco/CppParser/Symbol.h" + + +namespace Poco { +namespace CppParser { + + +class CppParser_API BuiltIn: public Symbol + /// A placeholder for a built-in type. +{ +public: + BuiltIn(const std::string& name, NameSpace* pNameSpace); + /// Creates the BuiltIn. + + ~BuiltIn(); + /// Destroys the BuiltIn. + + Symbol::Kind kind() const; + std::string toString() const; +}; + + +} } // namespace Poco::CppParser + + +#endif // CppParser_BuiltIn_INCLUDED diff --git a/CppParser/include/Poco/CppParser/CppParser.h b/CppParser/include/Poco/CppParser/CppParser.h index 3486f2272..7bce0e187 100644 --- a/CppParser/include/Poco/CppParser/CppParser.h +++ b/CppParser/include/Poco/CppParser/CppParser.h @@ -1,7 +1,7 @@ // // CppParser.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/CppParser.h#2 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/CppParser.h#2 $ // // Library: CppParser // Package: CppParser diff --git a/CppParser/include/Poco/CppParser/CppToken.h b/CppParser/include/Poco/CppParser/CppToken.h index 9b02c30db..c4e7e4566 100644 --- a/CppParser/include/Poco/CppParser/CppToken.h +++ b/CppParser/include/Poco/CppParser/CppToken.h @@ -1,7 +1,7 @@ // // CppToken.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/CppToken.h#2 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/CppToken.h#1 $ // // Library: CppParser // Package: CppParser diff --git a/CppParser/include/Poco/CppParser/Decl.h b/CppParser/include/Poco/CppParser/Decl.h index d10656ab5..428977da6 100644 --- a/CppParser/include/Poco/CppParser/Decl.h +++ b/CppParser/include/Poco/CppParser/Decl.h @@ -1,7 +1,7 @@ // // Decl.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/Decl.h#1 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/Decl.h#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/include/Poco/CppParser/Enum.h b/CppParser/include/Poco/CppParser/Enum.h index c143e1ca1..26a4c8e9b 100644 --- a/CppParser/include/Poco/CppParser/Enum.h +++ b/CppParser/include/Poco/CppParser/Enum.h @@ -1,7 +1,7 @@ // // Enum.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/Enum.h#1 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/Enum.h#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/include/Poco/CppParser/EnumValue.h b/CppParser/include/Poco/CppParser/EnumValue.h index 4320c7624..647e67e28 100644 --- a/CppParser/include/Poco/CppParser/EnumValue.h +++ b/CppParser/include/Poco/CppParser/EnumValue.h @@ -1,7 +1,7 @@ // // EnumValue.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/EnumValue.h#1 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/EnumValue.h#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/include/Poco/CppParser/Function.h b/CppParser/include/Poco/CppParser/Function.h index e621667d0..2f95015ac 100644 --- a/CppParser/include/Poco/CppParser/Function.h +++ b/CppParser/include/Poco/CppParser/Function.h @@ -1,7 +1,7 @@ // // Function.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/Function.h#1 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/Function.h#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/include/Poco/CppParser/NameSpace.h b/CppParser/include/Poco/CppParser/NameSpace.h index 09f514d84..ff29da571 100644 --- a/CppParser/include/Poco/CppParser/NameSpace.h +++ b/CppParser/include/Poco/CppParser/NameSpace.h @@ -1,7 +1,7 @@ // // NameSpace.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/NameSpace.h#2 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/NameSpace.h#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/include/Poco/CppParser/Parameter.h b/CppParser/include/Poco/CppParser/Parameter.h index 076a287ff..41d4aa40f 100644 --- a/CppParser/include/Poco/CppParser/Parameter.h +++ b/CppParser/include/Poco/CppParser/Parameter.h @@ -1,7 +1,7 @@ // // Parameter.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/Parameter.h#1 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/Parameter.h#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/include/Poco/CppParser/Parser.h b/CppParser/include/Poco/CppParser/Parser.h index 54b360206..8ce381260 100644 --- a/CppParser/include/Poco/CppParser/Parser.h +++ b/CppParser/include/Poco/CppParser/Parser.h @@ -1,7 +1,7 @@ // // Parser.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/Parser.h#3 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/Parser.h#1 $ // // Library: CppParser // Package: CppParser diff --git a/CppParser/include/Poco/CppParser/Struct.h b/CppParser/include/Poco/CppParser/Struct.h index 5f8eb2191..34ea06adb 100644 --- a/CppParser/include/Poco/CppParser/Struct.h +++ b/CppParser/include/Poco/CppParser/Struct.h @@ -1,7 +1,7 @@ // // Struct.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/Struct.h#1 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/Struct.h#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/include/Poco/CppParser/Symbol.h b/CppParser/include/Poco/CppParser/Symbol.h index 312383cfe..daf89ce7f 100644 --- a/CppParser/include/Poco/CppParser/Symbol.h +++ b/CppParser/include/Poco/CppParser/Symbol.h @@ -1,7 +1,7 @@ // // Symbol.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/Symbol.h#1 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/Symbol.h#2 $ // // Library: CppParser // Package: SymbolTable @@ -68,6 +68,7 @@ public: SYM_PARAMETER, /// A function parameter SYM_STRUCT, /// A struct or class SYM_TYPEDEF, /// A typedef + SYM_BUILTIN, /// A built-in type SYM_VARIABLE /// A (member) variable }; @@ -140,7 +141,10 @@ public: const Attributes& attrs() const; /// Returns the symbol's attributes. - + + Attributes& attrs(); + /// Returns the symbol's attributes. + const Attributes& getAttributes() const; /// Returns the symbol's attributes. @@ -254,6 +258,12 @@ inline const Attributes& Symbol::attrs() const } +inline Attributes& Symbol::attrs() +{ + return _attrs; +} + + inline bool Symbol::isPublic() const { return _access == ACC_PUBLIC; diff --git a/CppParser/include/Poco/CppParser/Tokenizer.h b/CppParser/include/Poco/CppParser/Tokenizer.h index 63c02495f..ca20fd9eb 100644 --- a/CppParser/include/Poco/CppParser/Tokenizer.h +++ b/CppParser/include/Poco/CppParser/Tokenizer.h @@ -1,7 +1,7 @@ // // Tokenizer.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/Tokenizer.h#1 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/Tokenizer.h#1 $ // // Library: CppParser // Package: CppParser diff --git a/CppParser/include/Poco/CppParser/TypeDef.h b/CppParser/include/Poco/CppParser/TypeDef.h index 026484e21..443273fcd 100644 --- a/CppParser/include/Poco/CppParser/TypeDef.h +++ b/CppParser/include/Poco/CppParser/TypeDef.h @@ -1,7 +1,7 @@ // // TypeDef.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/TypeDef.h#2 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/TypeDef.h#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/include/Poco/CppParser/Utility.h b/CppParser/include/Poco/CppParser/Utility.h index 2856c0b01..57274ca3d 100644 --- a/CppParser/include/Poco/CppParser/Utility.h +++ b/CppParser/include/Poco/CppParser/Utility.h @@ -1,7 +1,7 @@ // // Utility.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/Utility.h#1 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/Utility.h#1 $ // // Library: CppParser // Package: CppParser diff --git a/CppParser/include/Poco/CppParser/Variable.h b/CppParser/include/Poco/CppParser/Variable.h index 6c61ef2ad..39e8936c4 100644 --- a/CppParser/include/Poco/CppParser/Variable.h +++ b/CppParser/include/Poco/CppParser/Variable.h @@ -1,7 +1,7 @@ // // Variable.h // -// $Id: //poco/1.3/CppParser/include/Poco/CppParser/Variable.h#2 $ +// $Id: //poco/1.4/CppParser/include/Poco/CppParser/Variable.h#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/src/Attributes.cpp b/CppParser/src/Attributes.cpp index a03b04459..37d26fac4 100644 --- a/CppParser/src/Attributes.cpp +++ b/CppParser/src/Attributes.cpp @@ -1,7 +1,7 @@ // // Attributes.cpp // -// $Id: //poco/1.3/CppParser/src/Attributes.cpp#1 $ +// $Id: //poco/1.4/CppParser/src/Attributes.cpp#2 $ // // Library: CppParser // Package: Attributes @@ -143,6 +143,14 @@ void Attributes::set(const std::string& name, const std::string& value) } +void Attributes::remove(const std::string& name) +{ + AttrMap::iterator it = _map.find(name); + if (it != _map.end()) + _map.erase(it); +} + + const std::string& Attributes::operator [] (const std::string& name) const { AttrMap::const_iterator it = _map.find(name); diff --git a/CppParser/src/AttributesParser.cpp b/CppParser/src/AttributesParser.cpp index 9ec6bb3ba..dc3504e31 100644 --- a/CppParser/src/AttributesParser.cpp +++ b/CppParser/src/AttributesParser.cpp @@ -1,7 +1,7 @@ // // AttributesParser.cpp // -// $Id: //poco/1.3/CppParser/src/AttributesParser.cpp#1 $ +// $Id: //poco/1.4/CppParser/src/AttributesParser.cpp#1 $ // // Library: CppParser // Package: Attributes diff --git a/CppParser/src/BuiltIn.cpp b/CppParser/src/BuiltIn.cpp new file mode 100644 index 000000000..15b695c8e --- /dev/null +++ b/CppParser/src/BuiltIn.cpp @@ -0,0 +1,69 @@ +// +// BuiltIn.cpp +// +// $Id: //poco/1.4/CppParser/src/BuiltIn.cpp#1 $ +// +// Library: CppParser +// Package: SymbolTable +// Module: BuiltIn +// +// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// Permission is hereby granted, free of charge, to any person or organization +// obtaining a copy of the software and accompanying documentation covered by +// this license (the "Software") to use, reproduce, display, distribute, +// execute, and transmit the Software, and to prepare derivative works of the +// Software, and to permit third-parties to whom the Software is furnished to +// do so, all subject to the following: +// +// The copyright notices in the Software and this entire statement, including +// the above license grant, this restriction and the following disclaimer, +// must be included in all copies of the Software, in whole or in part, and +// all derivative works of the Software, unless such copies or derivative +// works are solely in the form of machine-executable object code generated by +// a source language processor. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// + + +#include "Poco/CppParser/BuiltIn.h" +#include "Poco/String.h" +#include + + +namespace Poco { +namespace CppParser { + + +BuiltIn::BuiltIn(const std::string& name, NameSpace* pNameSpace): + Symbol(name, pNameSpace) +{ +} + + +BuiltIn::~BuiltIn() +{ +} + + +Symbol::Kind BuiltIn::kind() const +{ + return Symbol::SYM_BUILTIN; +} + + +std::string BuiltIn::toString() const +{ + return fullName(); +} + + +} } // namespace Poco::CppParser diff --git a/CppParser/src/CppToken.cpp b/CppParser/src/CppToken.cpp index c7ad5ab9a..4ba0b053b 100644 --- a/CppParser/src/CppToken.cpp +++ b/CppParser/src/CppToken.cpp @@ -1,7 +1,7 @@ // // CppToken.cpp // -// $Id: //poco/1.3/CppParser/src/CppToken.cpp#4 $ +// $Id: //poco/1.4/CppParser/src/CppToken.cpp#2 $ // // Library: CppParser // Package: CppParser @@ -36,6 +36,7 @@ #include "Poco/CppParser/CppToken.h" #include "Poco/Exception.h" +#include "Poco/NumberParser.h" #include #include @@ -613,14 +614,14 @@ void NumberLiteralToken::finish(std::istream& istr) int NumberLiteralToken::asInteger() const { - return static_cast(strtol(_value.c_str(), 0, 0)); + return static_cast(std::strtol(_value.c_str(), 0, 0)); } double NumberLiteralToken::asFloat() const { - return strtod(_value.c_str(), 0); + return std::strtod(_value.c_str(), 0); } diff --git a/CppParser/src/Decl.cpp b/CppParser/src/Decl.cpp index 721034442..bfd10f79b 100644 --- a/CppParser/src/Decl.cpp +++ b/CppParser/src/Decl.cpp @@ -1,7 +1,7 @@ // // Decl.cpp // -// $Id: //poco/1.3/CppParser/src/Decl.cpp#2 $ +// $Id: //poco/1.4/CppParser/src/Decl.cpp#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/src/Enum.cpp b/CppParser/src/Enum.cpp index bb4f96402..0085021d3 100644 --- a/CppParser/src/Enum.cpp +++ b/CppParser/src/Enum.cpp @@ -1,7 +1,7 @@ // // Enum.cpp // -// $Id: //poco/1.3/CppParser/src/Enum.cpp#1 $ +// $Id: //poco/1.4/CppParser/src/Enum.cpp#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/src/EnumValue.cpp b/CppParser/src/EnumValue.cpp index 177b8d10f..e08bf6464 100644 --- a/CppParser/src/EnumValue.cpp +++ b/CppParser/src/EnumValue.cpp @@ -1,7 +1,7 @@ // // EnumValue.cpp // -// $Id: //poco/1.3/CppParser/src/EnumValue.cpp#1 $ +// $Id: //poco/1.4/CppParser/src/EnumValue.cpp#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/src/Function.cpp b/CppParser/src/Function.cpp index 24ef7200f..be1976ef7 100644 --- a/CppParser/src/Function.cpp +++ b/CppParser/src/Function.cpp @@ -1,7 +1,7 @@ // // Function.cpp // -// $Id: //poco/1.3/CppParser/src/Function.cpp#3 $ +// $Id: //poco/1.4/CppParser/src/Function.cpp#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/src/NameSpace.cpp b/CppParser/src/NameSpace.cpp index 683854d7d..da31c3388 100644 --- a/CppParser/src/NameSpace.cpp +++ b/CppParser/src/NameSpace.cpp @@ -1,7 +1,7 @@ // // Namespace.cpp // -// $Id: //poco/1.3/CppParser/src/NameSpace.cpp#3 $ +// $Id: //poco/1.4/CppParser/src/NameSpace.cpp#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/src/Parameter.cpp b/CppParser/src/Parameter.cpp index 81194a955..71b5e50a0 100644 --- a/CppParser/src/Parameter.cpp +++ b/CppParser/src/Parameter.cpp @@ -1,7 +1,7 @@ // // Parameter.cpp // -// $Id: //poco/1.3/CppParser/src/Parameter.cpp#3 $ +// $Id: //poco/1.4/CppParser/src/Parameter.cpp#2 $ // // Library: CppParser // Package: SymbolTable @@ -51,16 +51,18 @@ int Parameter::_count(0); Parameter::Parameter(const std::string& decl, Function* pFunction): - Decl(handleDecl (decl), 0), // handle init values + Decl(handleDecl(decl), 0), // handle init values _type(), _isRef(false), _isPointer(false), _isConst(false) { - std::size_t pos = declaration().rfind(name()); - - std::string tmp = declaration().substr(0, pos); + std::string tmp; + if (pos == 0 && name().size() == declaration().size()) + tmp = declaration(); + else + tmp = declaration().substr(0, pos); _type = Poco::trim(tmp); std::size_t rightCut = _type.size(); while (rightCut > 0 && (_type[rightCut-1] == '&' || _type[rightCut-1] == '*' || _type[rightCut-1] == '\t' || _type[rightCut-1] == ' ')) @@ -83,7 +85,6 @@ Parameter::Parameter(const std::string& decl, Function* pFunction): _isConst = true; } - Poco::trimInPlace(_type); pos = decl.find("="); _hasDefaultValue = (pos != std::string::npos); @@ -154,7 +155,6 @@ std::string Parameter::handleDecl(const std::string& decl) mustAdd = true; if (mustAdd) { - result.append(" "); result.append("param"); result.append(Poco::NumberFormatter::format(++_count)); diff --git a/CppParser/src/Parser.cpp b/CppParser/src/Parser.cpp index 1a4182e9f..e4737b540 100644 --- a/CppParser/src/Parser.cpp +++ b/CppParser/src/Parser.cpp @@ -1,7 +1,7 @@ // // Parser.cpp // -// $Id: //poco/1.3/CppParser/src/Parser.cpp#7 $ +// $Id: //poco/1.4/CppParser/src/Parser.cpp#1 $ // // Library: CppParser // Package: CppParser @@ -682,13 +682,18 @@ const Token* Parser::parseParameters(const Token* pNext, Function* pFunc) { std::string decl; int depth = 0; - while ((depth > 0 || (!isOperator(pNext, OperatorToken::OP_CLOSPARENT) && !isOperator(pNext, OperatorToken::OP_COMMA))) && !isEOF(pNext)) + int tdepth = 0; + while ((depth > 0 || tdepth > 0 || (!isOperator(pNext, OperatorToken::OP_CLOSPARENT) && !isOperator(pNext, OperatorToken::OP_COMMA))) && !isEOF(pNext)) { append(decl, pNext); if (isOperator(pNext, OperatorToken::OP_OPENPARENT)) ++depth; else if (isOperator(pNext, OperatorToken::OP_CLOSPARENT)) --depth; + else if (isOperator(pNext, OperatorToken::OP_LT)) + ++tdepth; + else if (isOperator(pNext, OperatorToken::OP_GT)) + --tdepth; pNext = next(); } if (isOperator(pNext, OperatorToken::OP_COMMA)) diff --git a/CppParser/src/Struct.cpp b/CppParser/src/Struct.cpp index 2baf77dbd..638b21183 100644 --- a/CppParser/src/Struct.cpp +++ b/CppParser/src/Struct.cpp @@ -1,7 +1,7 @@ // // Struct.cpp // -// $Id: //poco/1.3/CppParser/src/Struct.cpp#2 $ +// $Id: //poco/1.4/CppParser/src/Struct.cpp#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/src/Symbol.cpp b/CppParser/src/Symbol.cpp index 96761aba2..778bb1071 100644 --- a/CppParser/src/Symbol.cpp +++ b/CppParser/src/Symbol.cpp @@ -1,7 +1,7 @@ // // Symbol.cpp // -// $Id: //poco/1.3/CppParser/src/Symbol.cpp#6 $ +// $Id: //poco/1.4/CppParser/src/Symbol.cpp#1 $ // // Library: CppParser // Package: SymbolTable @@ -136,8 +136,14 @@ std::string Symbol::extractName(const std::string& decl) { poco_assert (!decl.empty()); + // special cases: operator () and operator [] + if (decl.find("operator ()") != std::string::npos) + return "operator ()"; + else if (decl.find("operator[]") != std::string::npos) + return "operator []"; + std::string::size_type pos = decl.find('('); - // check for function pointer + // another special case: function pointer if (pos != std::string::npos && pos < decl.size() - 1) { std::string::size_type i = pos + 1; @@ -154,11 +160,14 @@ std::string Symbol::extractName(const std::string& decl) if (pos == std::string::npos || (pos > 0 && decl[pos - 1] == '(')) pos = decl.size(); --pos; + // check for constant std::string::size_type eqPos = decl.find('='); if (eqPos != std::string::npos) { + // special case: default template parameter std::string::size_type gtPos = decl.find('>', eqPos); - if ((gtPos == std::string::npos || gtPos > pos) && eqPos < pos && eqPos > 0 && decl[eqPos + 1] != '=') + std::string::size_type ltPos = decl.find('<', eqPos); + if ((gtPos == std::string::npos || gtPos > pos || (ltPos != std::string::npos && gtPos > ltPos)) && eqPos < pos && eqPos > 0 && decl[eqPos + 1] != '=') pos = eqPos - 1; } while (pos > 0 && std::isspace(decl[pos])) --pos; diff --git a/CppParser/src/Tokenizer.cpp b/CppParser/src/Tokenizer.cpp index fd02220f8..bd9c86baa 100644 --- a/CppParser/src/Tokenizer.cpp +++ b/CppParser/src/Tokenizer.cpp @@ -1,7 +1,7 @@ // // Tokenizer.cpp // -// $Id: //poco/1.3/CppParser/src/Tokenizer.cpp#1 $ +// $Id: //poco/1.4/CppParser/src/Tokenizer.cpp#1 $ // // Library: CppParser // Package: CppParser diff --git a/CppParser/src/TypeDef.cpp b/CppParser/src/TypeDef.cpp index 168840505..7de61b1a9 100644 --- a/CppParser/src/TypeDef.cpp +++ b/CppParser/src/TypeDef.cpp @@ -1,7 +1,7 @@ // // TypeDef.cpp // -// $Id: //poco/1.3/CppParser/src/TypeDef.cpp#3 $ +// $Id: //poco/1.4/CppParser/src/TypeDef.cpp#1 $ // // Library: CppParser // Package: SymbolTable diff --git a/CppParser/src/Utility.cpp b/CppParser/src/Utility.cpp index 6b16a3b29..68c22a839 100644 --- a/CppParser/src/Utility.cpp +++ b/CppParser/src/Utility.cpp @@ -1,7 +1,7 @@ // // Utility.cpp // -// $Id: //poco/1.3/CppParser/src/Utility.cpp#5 $ +// $Id: //poco/1.4/CppParser/src/Utility.cpp#2 $ // // Library: CppParser // Package: CppParser @@ -186,6 +186,7 @@ void Utility::detectPrefixAndIncludes(const std::string& origHFile, std::vector< istr.close(); } + std::string Utility::preprocessFile(const std::string& file, const std::string& exec, const std::string& options, const std::string& path) { Path pp(file); @@ -276,17 +277,16 @@ void Utility::buildFileList(std::set& files, const std::vector::const_iterator itExc = excludePattern.begin(); - std::vector ::const_iterator itExcEnd = excludePattern.end(); - for (std::set::const_iterator it = temp.begin(); it != temp.end(); ++it) { Path p(*it); bool include = true; + std::vector ::const_iterator itExc = excludePattern.begin(); + std::vector ::const_iterator itExcEnd = excludePattern.end(); for (; itExc != itExcEnd; ++itExc) { Glob glob(*itExc, options); - if (glob.match(p.getFileName())) + if (glob.match(p.toString())) include = false; } if (include) diff --git a/CppParser/src/Variable.cpp b/CppParser/src/Variable.cpp index 962d1df90..40b2f67ac 100644 --- a/CppParser/src/Variable.cpp +++ b/CppParser/src/Variable.cpp @@ -1,7 +1,7 @@ // // Variable.cpp // -// $Id: //poco/1.3/CppParser/src/Variable.cpp#3 $ +// $Id: //poco/1.4/CppParser/src/Variable.cpp#1 $ // // Library: CppParser // Package: SymbolTable