mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-26 00:20:34 +01:00
add support for typed enums and deleted functions
This commit is contained in:
parent
64101df736
commit
328d6a1a46
@ -52,6 +52,13 @@ public:
|
||||
/// in the form #AnonEnum<n> (where <n> is a unique integer)
|
||||
/// will be assigned.
|
||||
|
||||
Enum(const std::string& name, NameSpace* pNameSpace, const std::string& baseType, int flags = 0);
|
||||
/// Creates the Enum.
|
||||
///
|
||||
/// If name is the empty string, an internal name
|
||||
/// in the form #AnonEnum<n> (where <n> is a unique integer)
|
||||
/// will be assigned.
|
||||
|
||||
~Enum();
|
||||
/// Destroys the Enum.
|
||||
|
||||
@ -64,7 +71,11 @@ public:
|
||||
Iterator end() const;
|
||||
/// Returns an iterator for iterating over the Enum's EnumValue's.
|
||||
|
||||
const std::string& baseType() const;
|
||||
/// Returns the base type or an empty string if no base type has been specified.
|
||||
|
||||
int flags() const;
|
||||
/// Returns the flags.
|
||||
|
||||
Symbol::Kind kind() const;
|
||||
std::string toString() const;
|
||||
@ -74,6 +85,7 @@ protected:
|
||||
|
||||
private:
|
||||
Values _values;
|
||||
std::string _baseType;
|
||||
int _flags;
|
||||
static int _count;
|
||||
};
|
||||
@ -82,6 +94,12 @@ private:
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline const std::string& Enum::baseType() const
|
||||
{
|
||||
return _baseType;
|
||||
}
|
||||
|
||||
|
||||
inline int Enum::flags() const
|
||||
{
|
||||
return _flags;
|
||||
|
@ -113,6 +113,12 @@ public:
|
||||
bool isConst() const;
|
||||
/// Returns true iff the method is const.
|
||||
|
||||
bool isDefault() const;
|
||||
/// Returns true iff the method has a default implementation.
|
||||
|
||||
bool isDeleted() const;
|
||||
/// Returns true iff the method has been deleted.
|
||||
|
||||
int countParameters() const;
|
||||
/// Returns the number of parameters.
|
||||
|
||||
@ -160,6 +166,18 @@ inline bool Function::isConst() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Function::isDefault() const
|
||||
{
|
||||
return (flags() & FN_DEFAULT) != 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool Function::isDeleted() const
|
||||
{
|
||||
return (flags() & FN_DELETE) != 0;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::CppParser
|
||||
|
||||
|
||||
|
@ -35,6 +35,14 @@ Enum::Enum(const std::string& name, NameSpace* pNameSpace, int flags):
|
||||
}
|
||||
|
||||
|
||||
Enum::Enum(const std::string& name, NameSpace* pNameSpace, const std::string& baseType, int flags):
|
||||
Symbol(processName(name), pNameSpace),
|
||||
_baseType(baseType),
|
||||
_flags(flags)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Enum::~Enum()
|
||||
{
|
||||
}
|
||||
@ -81,7 +89,11 @@ Symbol::Kind Enum::kind() const
|
||||
std::string Enum::toString() const
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << "enum " << name() << "\n{\n";
|
||||
ostr << "enum ";
|
||||
if (_flags & ENUM_IS_CLASS) ostr << "class ";
|
||||
ostr << name();
|
||||
if (!_baseType.empty()) ostr << ": " << _baseType;
|
||||
ostr << "\n{\n";
|
||||
for (Iterator it = begin(); it != end(); ++it)
|
||||
{
|
||||
ostr << "\t" << (*it)->toString() << "\n";
|
||||
|
@ -804,6 +804,7 @@ const Token* Parser::parseEnum(const Token* pNext)
|
||||
{
|
||||
poco_assert (isKeyword(pNext, IdentifierToken::KW_ENUM));
|
||||
|
||||
std::string baseType;
|
||||
int flags = 0;
|
||||
_pCurrentSymbol = 0;
|
||||
int line = _istr.getCurrentLineNumber();
|
||||
@ -821,8 +822,15 @@ const Token* Parser::parseEnum(const Token* pNext)
|
||||
name = pNext->tokenString();
|
||||
pNext = next();
|
||||
}
|
||||
|
||||
if (isOperator(pNext, OperatorToken::OP_COLON))
|
||||
{
|
||||
pNext = next();
|
||||
pNext = parseIdentifier(pNext, baseType);
|
||||
}
|
||||
|
||||
expectOperator(pNext, OperatorToken::OP_OPENBRACE, "{");
|
||||
Enum* pEnum = new Enum(name, currentNameSpace(), flags);
|
||||
Enum* pEnum = new Enum(name, currentNameSpace(), baseType, flags);
|
||||
addSymbol(pEnum, line);
|
||||
pNext = next();
|
||||
while (pNext->is(Token::IDENTIFIER_TOKEN))
|
||||
|
Loading…
x
Reference in New Issue
Block a user