forked from qt-creator/qt-creator
More work on the objc class and declaration symbols.
This commit is contained in:
@@ -69,6 +69,7 @@ Bind::Bind(TranslationUnit *unit)
|
|||||||
_name(0),
|
_name(0),
|
||||||
_declaratorId(0),
|
_declaratorId(0),
|
||||||
_visibility(Symbol::Public),
|
_visibility(Symbol::Public),
|
||||||
|
_objcVisibility(Symbol::Public),
|
||||||
_methodKey(Function::NormalMethod),
|
_methodKey(Function::NormalMethod),
|
||||||
_skipFunctionBodies(false)
|
_skipFunctionBodies(false)
|
||||||
{
|
{
|
||||||
@@ -135,6 +136,12 @@ int Bind::switchVisibility(int visibility)
|
|||||||
return visibility;
|
return visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Bind::switchObjCVisibility(int visibility)
|
||||||
|
{
|
||||||
|
std::swap(_objcVisibility, visibility);
|
||||||
|
return visibility;
|
||||||
|
}
|
||||||
|
|
||||||
int Bind::switchMethodKey(int methodKey)
|
int Bind::switchMethodKey(int methodKey)
|
||||||
{
|
{
|
||||||
std::swap(_methodKey, methodKey);
|
std::swap(_methodKey, methodKey);
|
||||||
@@ -2113,10 +2120,17 @@ bool Bind::visit(ObjCClassDeclarationAST *ast)
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->objCProtocolRefs(ast->protocol_refs, klass);
|
this->objCProtocolRefs(ast->protocol_refs, klass);
|
||||||
|
|
||||||
|
const int previousObjCVisibility = switchObjCVisibility(Function::Protected);
|
||||||
|
|
||||||
this->objCInstanceVariablesDeclaration(ast->inst_vars_decl, klass);
|
this->objCInstanceVariablesDeclaration(ast->inst_vars_decl, klass);
|
||||||
|
|
||||||
|
(void) switchObjCVisibility(Function::Public);
|
||||||
for (DeclarationListAST *it = ast->member_declaration_list; it; it = it->next) {
|
for (DeclarationListAST *it = ast->member_declaration_list; it; it = it->next) {
|
||||||
this->declaration(it->value);
|
this->declaration(it->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void) switchObjCVisibility(previousObjCVisibility);
|
||||||
(void) switchScope(previousScope);
|
(void) switchScope(previousScope);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2175,18 +2189,21 @@ bool Bind::visit(ObjCProtocolDeclarationAST *ast)
|
|||||||
_scope->addMember(protocol);
|
_scope->addMember(protocol);
|
||||||
|
|
||||||
Scope *previousScope = switchScope(protocol);
|
Scope *previousScope = switchScope(protocol);
|
||||||
|
const int previousObjCVisibility = switchObjCVisibility(Function::Public);
|
||||||
|
|
||||||
this->objCProtocolRefs(ast->protocol_refs, protocol);
|
this->objCProtocolRefs(ast->protocol_refs, protocol);
|
||||||
for (DeclarationListAST *it = ast->member_declaration_list; it; it = it->next) {
|
for (DeclarationListAST *it = ast->member_declaration_list; it; it = it->next) {
|
||||||
this->declaration(it->value);
|
this->declaration(it->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void) switchObjCVisibility(previousObjCVisibility);
|
||||||
(void) switchScope(previousScope);
|
(void) switchScope(previousScope);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bind::visit(ObjCVisibilityDeclarationAST *ast)
|
bool Bind::visit(ObjCVisibilityDeclarationAST *ast)
|
||||||
{
|
{
|
||||||
(void) ast;
|
_objcVisibility = visibilityForObjCAccessSpecifier(tokenKind(ast->visibility_token));
|
||||||
// unsigned visibility_token = ast->visibility_token;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2798,3 +2815,19 @@ int Bind::visibilityForClassKey(int tokenKind)
|
|||||||
return Symbol::Public;
|
return Symbol::Public;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Bind::visibilityForObjCAccessSpecifier(int tokenKind)
|
||||||
|
{
|
||||||
|
switch (tokenKind) {
|
||||||
|
case T_AT_PUBLIC:
|
||||||
|
return Symbol::Public;
|
||||||
|
case T_AT_PROTECTED:
|
||||||
|
return Symbol::Protected;
|
||||||
|
case T_AT_PRIVATE:
|
||||||
|
return Symbol::Private;
|
||||||
|
case T_AT_PACKAGE:
|
||||||
|
return Symbol::Package;
|
||||||
|
default:
|
||||||
|
return Symbol::Protected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -71,6 +71,7 @@ protected:
|
|||||||
|
|
||||||
static int visibilityForAccessSpecifier(int tokenKind);
|
static int visibilityForAccessSpecifier(int tokenKind);
|
||||||
static int visibilityForClassKey(int tokenKind);
|
static int visibilityForClassKey(int tokenKind);
|
||||||
|
static int visibilityForObjCAccessSpecifier(int tokenKind);
|
||||||
|
|
||||||
void setDeclSpecifiers(Symbol *symbol, const FullySpecifiedType &declSpecifiers);
|
void setDeclSpecifiers(Symbol *symbol, const FullySpecifiedType &declSpecifiers);
|
||||||
|
|
||||||
@@ -90,6 +91,7 @@ protected:
|
|||||||
Scope *switchScope(Scope *scope);
|
Scope *switchScope(Scope *scope);
|
||||||
int switchVisibility(int visibility);
|
int switchVisibility(int visibility);
|
||||||
int switchMethodKey(int methodKey);
|
int switchMethodKey(int methodKey);
|
||||||
|
int switchObjCVisibility(int visibility);
|
||||||
|
|
||||||
unsigned calculateScopeStart(ObjCClassDeclarationAST *ast) const;
|
unsigned calculateScopeStart(ObjCClassDeclarationAST *ast) const;
|
||||||
unsigned calculateScopeStart(ObjCProtocolDeclarationAST *ast) const;
|
unsigned calculateScopeStart(ObjCProtocolDeclarationAST *ast) const;
|
||||||
@@ -291,6 +293,7 @@ private:
|
|||||||
FullySpecifiedType _type;
|
FullySpecifiedType _type;
|
||||||
DeclaratorIdAST **_declaratorId;
|
DeclaratorIdAST **_declaratorId;
|
||||||
int _visibility;
|
int _visibility;
|
||||||
|
int _objcVisibility;
|
||||||
int _methodKey;
|
int _methodKey;
|
||||||
bool _skipFunctionBodies;
|
bool _skipFunctionBodies;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user