Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum class support #136

Merged
merged 2 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion generator/parser/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1389,9 +1389,25 @@ bool Parser::parseEnumSpecifier(TypeSpecifierAST *&node)

CHECK(Token_enum);

if (token_stream.lookAhead() == Token_class)
{
token_stream.nextToken();
}

NameAST *name = 0;
parseName(name);

if(token_stream.lookAhead() == ':')
{
token_stream.nextToken();
TypeSpecifierAST *ast = 0;
if (!parseSimpleTypeSpecifier(ast))
{
token_stream.rewind((int) start);
return false;
}
}

if (token_stream.lookAhead() != '{')
{
token_stream.rewind((int) start);
Expand Down Expand Up @@ -1796,12 +1812,17 @@ bool Parser::parseForwardDeclarationSpecifier(TypeSpecifierAST *&node)
std::size_t start = token_stream.cursor();

int kind = token_stream.lookAhead();
if (kind != Token_class && kind != Token_struct && kind != Token_union)
if (kind != Token_class && kind != Token_struct && kind != Token_union && kind != Token_enum)
return false;

std::size_t class_key = token_stream.cursor();
token_stream.nextToken();

if (kind == Token_enum && token_stream.lookAhead() == Token_class)
{
token_stream.nextToken();
}

NameAST *name = 0;
if (!parseName(name, false)) {
token_stream.rewind((int) start);
Expand Down
6 changes: 6 additions & 0 deletions generator/typesystem_core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@
<enum-type name="QSystemSemaphore::SystemSemaphoreError"/>
<enum-type name="QTextBoundaryFinder::BoundaryReason" flags="QTextBoundaryFinder::BoundaryReasons"/>
<enum-type name="QTextBoundaryFinder::BoundaryType"/>
<enum-type name="QThread::Priority"/>
<enum-type name="QAbstractFileEngine::Extension" extensible="yes"/>
<enum-type name="QAbstractFileEngine::FileFlag" flags="QAbstractFileEngine::FileFlags"/>
<enum-type name="QAbstractFileEngine::FileName"/>
Expand Down Expand Up @@ -760,6 +761,9 @@
<enum-type name="QDirIterator::IteratorFlag" flags="QDirIterator::IteratorFlags"/>
<enum-type name="Qt::EventPriority"/>
<enum-type name="Qt::MaskMode"/>
<enum-type name="QCborKnownTags"/>
<enum-type name="QCborSimpleType"/>
<enum-type name="QCborTag"/>
<enum-type name="QCryptographicHash::Algorithm"/>

<enum-type name="QtConcurrent::ReduceOption" flags="QtConcurrent::ReduceOptions"/>
Expand Down Expand Up @@ -1954,7 +1958,9 @@
<enum-type name="QTimeZone::NameType"/>
<enum-type name="QProcess::InputChannelMode"/>
<enum-type name="QByteArray::Base64Option" flags="QByteArray::Base64Options"/>
<enum-type name="QMetaType::Type"/>
<enum-type name="QMetaType::TypeFlag" flags="QMetaType::TypeFlags"/>
<enum-type name="QAbstractItemModel::CheckIndexOption"/>
<enum-type name="QAbstractItemModel::LayoutChangeHint"/>
<enum-type name="QTextCharFormat::FontPropertiesInheritanceBehavior"/>
<enum-type name="QLocalServer::SocketOption" flags="QLocalServer::SocketOptions"/>
Expand Down
2 changes: 2 additions & 0 deletions generator/typesystem_gui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
<enum-type name="QAbstractSlider::SliderChange"/>
<enum-type name="QAbstractSpinBox::ButtonSymbols"/>
<enum-type name="QAbstractSpinBox::CorrectionMode"/>
<enum-type name="QAbstractSpinBox::StepType"/>
<enum-type name="QAbstractSpinBox::StepEnabledFlag" flags="QAbstractSpinBox::StepEnabled"/>
<enum-type name="QAccessible::Event"/>
<enum-type name="QAccessible::Method"/>
Expand Down Expand Up @@ -256,6 +257,7 @@
<enum-type name="QFrame::Shape"/>
<enum-type name="QFrame::StyleMask"/>
<enum-type name="QGradient::CoordinateMode"/>
<enum-type name="QGradient::Preset"/>
<enum-type name="QGradient::Spread" lower-bound="QGradient.PadSpread" upper-bound="QGradient.RepeatSpread"/>
<enum-type name="QGradient::Type"/>
<enum-type name="QGraphicsEllipseItem::enum_1"/>
Expand Down
2 changes: 2 additions & 0 deletions generator/typesystem_network.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<enum-type name="QLocalSocket::LocalSocketState"/>
<enum-type name="QNetworkAccessManager::Operation"/>
<enum-type name="QNetworkAccessManager::NetworkAccessibility"/>
<enum-type name="QNetworkAddressEntry::DnsEligibilityStatus"/>
<enum-type name="QNetworkCookie::RawForm"/>
<enum-type name="QNetworkReply::NetworkError"/>
<enum-type name="QNetworkRequest::Attribute" extensible="yes"/>
Expand Down Expand Up @@ -210,6 +211,7 @@
<object-type name="QDnsLookup"/>
<enum-type name="QDnsLookup::Error"/>
<enum-type name="QDnsLookup::Type"/>
<enum-type name="QDtlsError"/>
<object-type name="QDnsMailExchangeRecord"/>
<object-type name="QDnsServiceRecord"/>
<object-type name="QDnsTextRecord"/>
Expand Down
1 change: 1 addition & 0 deletions generator/typesystem_qml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<object-type name="QJSValue"></object-type>

<enum-type name="QJSEngine::Extension"/>
<enum-type name="QJSValue::ErrorType"/>
<enum-type name="QJSValue::SpecialValue"/>

<object-type name="QQmlAbstractUrlInterceptor"></object-type>
Expand Down
Loading