Skip to content
Closed
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
38 changes: 24 additions & 14 deletions generator/parser/binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ CodeModel::ClassType Binder::decode_class_type(std::size_t index) const
case Token_union:
return CodeModel::Union;
default:
warnHere();
warnHere(index);
std::cerr << "** WARNING unrecognized class type" << std::endl;
}
return CodeModel::Class;
Expand Down Expand Up @@ -255,7 +255,7 @@ void Binder::declare_symbol(SimpleDeclarationAST *node, InitDeclaratorAST *init_
NameAST *id = declarator->id;
if (! declarator->id)
{
warnHere();
warnHere(declarator->start_token, declarator->end_token);
std::cerr << "** WARNING expected a declarator id" << std::endl;
return;
}
Expand All @@ -265,7 +265,7 @@ void Binder::declare_symbol(SimpleDeclarationAST *node, InitDeclaratorAST *init_
if (! symbolScope)
{
name_cc.run(id);
warnHere();
warnHere(declarator->start_token, declarator->end_token);
std::cerr << "** WARNING scope not found for symbol: "
<< qPrintable(name_cc.name()) << std::endl;
return;
Expand Down Expand Up @@ -374,8 +374,8 @@ void Binder::visitFunctionDefinition(FunctionDefinitionAST *node)
declarator = declarator->sub_declarator;
//Q_ASSERT(declarator->id);
if (!declarator->id) {
warnHere();
std::cerr << "** SHIT " << qPrintable(name_cc.name()) << std::endl
warnHere(declarator->start_token, declarator->end_token);
std::cerr << "** SHIT" << std::endl
<< "\tdefinition *ignored*"
<< std::endl;
return;
Expand All @@ -385,7 +385,7 @@ void Binder::visitFunctionDefinition(FunctionDefinitionAST *node)
ScopeModelItem functionScope = finder.resolveScope(declarator->id, scope);
if (! functionScope)
{
warnHere();
warnHere(declarator->start_token, declarator->end_token);
name_cc.run(declarator->id);
std::cerr << "** WARNING scope not found for function definition: "
<< qPrintable(name_cc.name()) << std::endl
Expand Down Expand Up @@ -571,7 +571,7 @@ void Binder::visitTypedef(TypedefAST *node)

if (alias_name.isEmpty ())
{
warnHere();
warnHere(init_declarator->start_token, init_declarator->end_token);
std::cerr << "** WARNING anonymous typedef not supported! ``";
Token const &tk = _M_token_stream->token ((int) node->start_token);
Token const &end_tk = _M_token_stream->token ((int) node->end_token);
Expand Down Expand Up @@ -682,7 +682,6 @@ void Binder::visitClassSpecifier(ClassSpecifierAST *node)
}

Q_ASSERT(node->name != 0 && node->name->unqualified_name != 0);

ScopeModelItem scope = currentScope();

ClassModelItem old = changeCurrentClass(_M_model->create<ClassModelItem>());
Expand Down Expand Up @@ -837,14 +836,25 @@ void Binder::visitQProperty(QPropertyAST *node)
_M_current_class->addPropertyDeclaration(property);
}

void Binder::warnHere() const
void Binder::warnHere(int startToken, int endToken) const
{
ScopeModelItem scope = currentScope();
QString fileName = scope ? scope->fileName() : QString("<unknown>");
if (fileName != _M_lastWarnedFile) {
_M_lastWarnedFile = fileName;
std::cerr << "In file " << fileName.toLatin1().constData() << ":" << std::endl;
int startLine, endLine;
int startColumn, endColumn;
QString firstFileName, secondFileName;
_M_location.positionAt(_M_token_stream->position(startToken), &startLine, &startColumn, &firstFileName);
_M_location.positionAt(_M_token_stream->position(endToken == -1 ? startToken : endToken),
&endLine,
&endColumn,
&secondFileName);

assert (firstFileName == secondFileName);
if (firstFileName != _M_lastWarnedFile)
{
_M_lastWarnedFile = firstFileName;
std::cerr << std::endl << "In file " << firstFileName.toLatin1().constData() << ":" << std::endl;
}

std::cerr << "lines " << std::to_string(startLine) << "-" << std::to_string(endLine) << std::endl;
}

void Binder::applyStorageSpecifiers(const ListNode<std::size_t> *it, MemberModelItem item)
Expand Down
2 changes: 1 addition & 1 deletion generator/parser/binder.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Binder: protected DefaultVisitor
virtual void visitForwardDeclarationSpecifier(ForwardDeclarationSpecifierAST *);
virtual void visitQEnums(QEnumsAST *);

void warnHere() const;
void warnHere(int startToken, int endToken = -1) const;

private:

Expand Down
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