Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
8078053c
Commit
8078053c
authored
Jan 12, 2009
by
Roberto Raggi
Browse files
Improved ObjC++ support.
parent
54d9d0d4
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
shared/cplusplus/AST.cpp
View file @
8078053c
...
...
@@ -3898,6 +3898,8 @@ void IdentifierListAST::accept0(ASTVisitor *visitor)
unsigned
ObjCClassDeclarationAST
::
firstToken
()
const
{
if
(
attributes
)
return
attributes
->
firstToken
();
return
class_token
;
}
...
...
@@ -3911,12 +3913,19 @@ unsigned ObjCClassDeclarationAST::lastToken() const
return
it
->
identifier_token
+
1
;
}
for
(
SpecifierAST
*
it
=
attributes
;
it
;
it
=
it
->
next
)
{
if
(
!
it
->
next
)
return
it
->
lastToken
();
}
return
class_token
+
1
;
}
ObjCClassDeclarationAST
*
ObjCClassDeclarationAST
::
clone
(
MemoryPool
*
pool
)
const
{
ObjCClassDeclarationAST
*
ast
=
new
(
pool
)
ObjCClassDeclarationAST
;
if
(
attributes
)
ast
->
attributes
=
attributes
->
clone
(
pool
);
ast
->
class_token
=
class_token
;
if
(
identifier_list
)
ast
->
identifier_list
=
identifier_list
->
clone
(
pool
);
...
...
@@ -3927,6 +3936,9 @@ ObjCClassDeclarationAST *ObjCClassDeclarationAST::clone(MemoryPool *pool) const
void
ObjCClassDeclarationAST
::
accept0
(
ASTVisitor
*
visitor
)
{
if
(
visitor
->
visit
(
this
))
{
for
(
SpecifierAST
*
it
=
attributes
;
it
;
it
=
it
->
next
)
{
accept
(
it
,
visitor
);
}
}
}
...
...
shared/cplusplus/AST.h
View file @
8078053c
...
...
@@ -1949,6 +1949,7 @@ protected:
class
CPLUSPLUS_EXPORT
ObjCClassDeclarationAST
:
public
DeclarationAST
{
public:
SpecifierAST
*
attributes
;
unsigned
class_token
;
IdentifierListAST
*
identifier_list
;
unsigned
semicolon_token
;
...
...
shared/cplusplus/Parser.cpp
View file @
8078053c
This diff is collapsed.
Click to expand it.
shared/cplusplus/Parser.h
View file @
8078053c
...
...
@@ -206,46 +206,32 @@ public:
bool
parseUsingDirective
(
DeclarationAST
*&
node
);
bool
parseWhileStatement
(
StatementAST
*&
node
);
// Qt MOC run
bool
parseQtMethod
(
ExpressionAST
*&
node
);
// ObjC++
bool
parseObjCClassImplementation
(
DeclarationAST
*&
node
);
bool
parseObjCClassDeclaration
(
DeclarationAST
*&
node
);
bool
parseObjCInterfaceDeclaration
(
DeclarationAST
*&
node
);
bool
parseObjCProtocolDeclaration
(
DeclarationAST
*&
node
);
bool
parseObjCEndDeclaration
(
DeclarationAST
*&
node
);
bool
parseObjCAliasDeclaration
(
DeclarationAST
*&
node
);
bool
parseObjCPropertySynthesize
(
DeclarationAST
*&
node
);
bool
parseObjCPropertyDynamic
(
DeclarationAST
*&
node
);
bool
parseObjCInterface
(
DeclarationAST
*&
node
,
SpecifierAST
*
attributes
=
0
);
bool
parseObjCProtocol
(
DeclarationAST
*&
node
,
SpecifierAST
*
attributes
=
0
);
bool
parseObjCIdentifierList
(
IdentifierListAST
*&
node
);
bool
parseObjCPropertyDeclaration
(
DeclarationAST
*&
node
);
bool
parseObjCProtocolRefs
();
bool
parseObjC
C
lassInstanceVariables
();
bool
parseObjClassInstanceVariables
();
bool
parseObjCInterfaceMemberDeclaration
();
bool
parseObjCInterfaceDeclList
();
bool
parseObjCInstanceVariableDeclaration
(
DeclarationAST
*&
node
);
bool
parseObjCPropertyDeclaration
(
DeclarationAST
*&
node
,
SpecifierAST
*
attributes
=
0
);
bool
parseObjCMethodPrototype
();
bool
parseObjCExpression
(
ExpressionAST
*&
node
);
bool
parseObjCMessageExpression
(
ExpressionAST
*&
node
);
bool
parseObjCStringLiteral
(
ExpressionAST
*&
node
);
bool
parseObjCEncodeExpression
(
ExpressionAST
*&
node
);
bool
parseObjCProtocolExpression
(
ExpressionAST
*&
node
);
bool
parseObjCSelectorExpression
(
ExpressionAST
*&
node
);
bool
parseObjCMessageReceiver
(
ExpressionAST
*&
node
);
bool
parseObjCMessageArguments
();
bool
parseObjCMethodSignature
();
bool
parseObjCMethodDefinitionList
();
bool
parseObjCAtProperty
();
bool
parseObjCPropertyAttribute
();
bool
parseObjCTypeName
();
bool
parseObjCProtocolQualifiers
();
bool
parseObjCSelector
();
bool
parseObjCKeywordDeclaration
();
bool
parseObjCTypeQualifiers
();
bool
parseObjCEnd
(
DeclarationAST
*&
node
);
bool
lookAtObjCSelector
()
const
;
// Qt MOC run
bool
parseQtMethod
(
ExpressionAST
*&
node
);
bool
skipUntil
(
int
token
);
bool
skipUntilDeclaration
();
bool
skipUntilStatement
();
...
...
shared/cplusplus/Token.h
View file @
8078053c
...
...
@@ -201,9 +201,9 @@ enum Kind {
T___TYPEOF__
,
// obj c++ @ keywords
T_FIRST_OBJC_KEYWORD
,
T_FIRST_OBJC_
AT_
KEYWORD
,
T_AT_CATCH
=
T_FIRST_OBJC_KEYWORD
,
T_AT_CATCH
=
T_FIRST_OBJC_
AT_
KEYWORD
,
T_AT_CLASS
,
T_AT_COMPATIBILITY_ALIAS
,
T_AT_DEFS
,
...
...
@@ -228,7 +228,9 @@ enum Kind {
T_AT_THROW
,
T_AT_TRY
,
T_FIRST_QT_KEYWORD
,
T_LAST_OBJC_AT_KEYWORD
,
T_FIRST_QT_KEYWORD
=
T_LAST_OBJC_AT_KEYWORD
,
// Qt keywords
T_SIGNAL
=
T_FIRST_QT_KEYWORD
,
...
...
@@ -295,6 +297,9 @@ public:
inline
bool
isKeyword
()
const
{
return
kind
>=
T_FIRST_KEYWORD
&&
kind
<
T_FIRST_QT_KEYWORD
;
}
inline
bool
isObjCAtKeyword
()
const
{
return
kind
>=
T_FIRST_OBJC_AT_KEYWORD
&&
kind
<
T_LAST_OBJC_AT_KEYWORD
;
}
static
const
char
*
name
(
int
kind
);
public:
...
...
tests/auto/cplusplus/ast/tst_ast.cpp
View file @
8078053c
...
...
@@ -20,11 +20,15 @@ public:
{
StringLiteral
*
fileId
=
control
.
findOrInsertFileName
(
"<stdin>"
);
TranslationUnit
*
unit
=
new
TranslationUnit
(
&
control
,
fileId
);
unit
->
setObjCEnabled
(
true
);
unit
->
setSource
(
source
.
constData
(),
source
.
length
());
unit
->
parse
(
mode
);
return
unit
;
}
TranslationUnit
*
parseDeclaration
(
const
QByteArray
&
source
)
{
return
parse
(
source
,
TranslationUnit
::
ParseDeclaration
);
}
TranslationUnit
*
parseExpression
(
const
QByteArray
&
source
)
{
return
parse
(
source
,
TranslationUnit
::
ParseExpression
);
}
...
...
@@ -43,6 +47,11 @@ private slots:
void
while_condition_statement
();
void
for_statement
();
void
cpp_initializer_or_function_declaration
();
// objc++
void
objc_attributes_followed_by_at_keyword
();
void
objc_protocol_forward_declaration_1
();
void
objc_protocol_definition_1
();
};
void
tst_AST
::
simple_name
()
...
...
@@ -293,6 +302,31 @@ void tst_AST::cpp_initializer_or_function_declaration()
QCOMPARE
(
param
->
type_specifier
->
asNamedTypeSpecifier
()
->
name
->
asSimpleName
()
->
identifier_token
,
4U
);
}
void
tst_AST
::
objc_attributes_followed_by_at_keyword
()
{
QSharedPointer
<
TranslationUnit
>
unit
(
parseDeclaration
(
"
\n
"
"__attribute__((deprecated)) @interface foo <bar>
\n
"
"{
\n
"
" int a, b;
\n
"
"}
\n
"
"+ (id) init;
\n
"
"- (id) init:(int)a foo:(int)b, c;
\n
"
"@end
\n
"
));
AST
*
ast
=
unit
->
ast
();
}
void
tst_AST
::
objc_protocol_forward_declaration_1
()
{
QSharedPointer
<
TranslationUnit
>
unit
(
parseDeclaration
(
"
\n
@protocol foo;"
));
AST
*
ast
=
unit
->
ast
();
}
void
tst_AST
::
objc_protocol_definition_1
()
{
QSharedPointer
<
TranslationUnit
>
unit
(
parseDeclaration
(
"
\n
@protocol foo <ciao, bar> @end"
));
AST
*
ast
=
unit
->
ast
();
}
QTEST_APPLESS_MAIN
(
tst_AST
)
#include
"tst_ast.moc"
tests/manual/cplusplus/main.cpp
View file @
8078053c
...
...
@@ -248,6 +248,7 @@ int main(int argc, char *argv[])
Control
control
;
StringLiteral
*
fileId
=
control
.
findOrInsertFileName
(
"<stdin>"
);
TranslationUnit
unit
(
&
control
,
fileId
);
unit
.
setObjCEnabled
(
true
);
unit
.
setSource
(
source
.
constData
(),
source
.
size
());
unit
.
parse
();
if
(
!
unit
.
ast
())
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment