Skip to content
Snippets Groups Projects
Commit 56f755ef authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Changed ObjC context keyword comparison to use identifiers.

parent c5cf70c6
No related branches found
No related tags found
No related merge requests found
...@@ -700,26 +700,26 @@ bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast) ...@@ -700,26 +700,26 @@ bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast)
if (!attrAst) if (!attrAst)
continue; continue;
const char *attrName = spell(attrAst->attribute_identifier_token); Identifier *attrId = identifier(attrAst->attribute_identifier_token);
if (!strcmp("getter", attrName)) { if (attrId == control()->objcGetterId()) {
if (checkPropertyAttribute(attrAst, propAttrs, Getter)) { if (checkPropertyAttribute(attrAst, propAttrs, Getter)) {
// TODO: find method declaration for getter // TODO: find method declaration for getter
} }
} else if (!strcmp("setter", attrName)) { } else if (attrId == control()->objcSetterId()) {
if (checkPropertyAttribute(attrAst, propAttrs, Setter)) { if (checkPropertyAttribute(attrAst, propAttrs, Setter)) {
// TODO: find method declaration for setter // TODO: find method declaration for setter
} }
} else if (!strcmp("readwrite", attrName)) { } else if (attrId == control()->objcReadwriteId()) {
checkPropertyAttribute(attrAst, propAttrs, ReadWrite); checkPropertyAttribute(attrAst, propAttrs, ReadWrite);
} else if (!strcmp("readonly", attrName)) { } else if (attrId == control()->objcReadonlyId()) {
checkPropertyAttribute(attrAst, propAttrs, ReadOnly); checkPropertyAttribute(attrAst, propAttrs, ReadOnly);
} else if (!strcmp("assign", attrName)) { } else if (attrId == control()->objcAssignId()) {
checkPropertyAttribute(attrAst, propAttrs, Assign); checkPropertyAttribute(attrAst, propAttrs, Assign);
} else if (!strcmp("retain", attrName)) { } else if (attrId == control()->objcRetainId()) {
checkPropertyAttribute(attrAst, propAttrs, Retain); checkPropertyAttribute(attrAst, propAttrs, Retain);
} else if (!strcmp("copy", attrName)) { } else if (attrId == control()->objcCopyId()) {
checkPropertyAttribute(attrAst, propAttrs, Copy); checkPropertyAttribute(attrAst, propAttrs, Copy);
} else if (!strcmp("nonatomic", attrName)) { } else if (attrId == control()->objcNonatomicId()) {
checkPropertyAttribute(attrAst, propAttrs, NonAtomic); checkPropertyAttribute(attrAst, propAttrs, NonAtomic);
} }
} }
......
...@@ -89,7 +89,16 @@ public: ...@@ -89,7 +89,16 @@ public:
: control(control), : control(control),
translationUnit(0), translationUnit(0),
diagnosticClient(0) diagnosticClient(0)
{ } {
objcGetterId = control->findOrInsertIdentifier("getter");
objcSetterId = control->findOrInsertIdentifier("setter");
objcReadwriteId = control->findOrInsertIdentifier("readwrite");
objcReadonlyId = control->findOrInsertIdentifier("readonly");
objcAssignId = control->findOrInsertIdentifier("assign");
objcRetainId = control->findOrInsertIdentifier("retain");
objcCopyId = control->findOrInsertIdentifier("copy");
objcNonatomicId = control->findOrInsertIdentifier("nonatomic");
}
~Data() ~Data()
{ {
...@@ -577,6 +586,16 @@ public: ...@@ -577,6 +586,16 @@ public:
std::vector<ObjCForwardClassDeclaration *> objcForwardClassDeclarations; std::vector<ObjCForwardClassDeclaration *> objcForwardClassDeclarations;
std::vector<ObjCForwardProtocolDeclaration *> objcForwardProtocolDeclarations; std::vector<ObjCForwardProtocolDeclaration *> objcForwardProtocolDeclarations;
std::vector<ObjCMethod *> objcMethods; std::vector<ObjCMethod *> objcMethods;
// ObjC context keywords:
Identifier *objcGetterId;
Identifier *objcSetterId;
Identifier *objcReadwriteId;
Identifier *objcReadonlyId;
Identifier *objcAssignId;
Identifier *objcRetainId;
Identifier *objcCopyId;
Identifier *objcNonatomicId;
}; };
Control::Control() Control::Control()
...@@ -766,4 +785,26 @@ ObjCForwardProtocolDeclaration *Control::newObjCForwardProtocolDeclaration(unsig ...@@ -766,4 +785,26 @@ ObjCForwardProtocolDeclaration *Control::newObjCForwardProtocolDeclaration(unsig
ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, Name *name) ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, Name *name)
{ return d->newObjCMethod(sourceLocation, name); } { return d->newObjCMethod(sourceLocation, name); }
Identifier *Control::objcGetterId() const
{ return d->objcGetterId; }
Identifier *Control::objcSetterId() const
{ return d->objcSetterId; }
Identifier *Control::objcReadwriteId() const
{ return d->objcReadwriteId; }
Identifier *Control::objcReadonlyId() const
{ return d->objcReadonlyId; }
Identifier *Control::objcAssignId() const
{ return d->objcAssignId; }
Identifier *Control::objcRetainId() const
{ return d->objcRetainId; }
Identifier *Control::objcCopyId() const
{ return d->objcCopyId; }
Identifier *Control::objcNonatomicId() const
{ return d->objcNonatomicId; }
...@@ -169,6 +169,16 @@ public: ...@@ -169,6 +169,16 @@ public:
/// Creates a new Objective-C method symbol. /// Creates a new Objective-C method symbol.
ObjCMethod *newObjCMethod(unsigned sourceLocation, Name *name = 0); ObjCMethod *newObjCMethod(unsigned sourceLocation, Name *name = 0);
// Objective-C specific context keywords.
Identifier *objcGetterId() const;
Identifier *objcSetterId() const;
Identifier *objcReadwriteId() const;
Identifier *objcReadonlyId() const;
Identifier *objcAssignId() const;
Identifier *objcRetainId() const;
Identifier *objcCopyId() const;
Identifier *objcNonatomicId() const;
Identifier *findIdentifier(const char *chars, unsigned size) const; Identifier *findIdentifier(const char *chars, unsigned size) const;
Identifier *findOrInsertIdentifier(const char *chars, unsigned size); Identifier *findOrInsertIdentifier(const char *chars, unsigned size);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment