static bool rewriteToObjCProperty(const ObjCMethodDecl *Getter,
const ObjCMethodDecl *Setter,
const NSAPI &NS, edit::Commit &commit,
- bool GetterHasIsPrefix) {
+ unsigned LengthOfPrefix) {
ASTContext &Context = NS.getASTContext();
std::string PropertyString = "@property(nonatomic";
std::string PropertyNameString = Getter->getNameAsString();
StringRef PropertyName(PropertyNameString);
- if (GetterHasIsPrefix) {
+ if (LengthOfPrefix > 0) {
PropertyString += ", getter=";
PropertyString += PropertyNameString;
}
PropertyString += " ";
PropertyString += RT.getAsString(Context.getPrintingPolicy());
PropertyString += " ";
- if (GetterHasIsPrefix) {
+ if (LengthOfPrefix > 0) {
// property name must strip off "is" and lower case the first character
// after that; e.g. isContinuous will become continuous.
StringRef PropertyNameStringRef(PropertyNameString);
- PropertyNameStringRef = PropertyNameStringRef.drop_front(2);
+ PropertyNameStringRef = PropertyNameStringRef.drop_front(LengthOfPrefix);
PropertyNameString = PropertyNameStringRef;
std::string NewPropertyNameString = PropertyNameString;
NewPropertyNameString[0] = toLowercase(NewPropertyNameString[0]);
PP.getSelectorTable(),
getterName);
ObjCMethodDecl *SetterMethod = D->lookupMethod(SetterSelector, true);
- bool GetterHasIsPrefix = false;
+ unsigned LengthOfPrefix = 0;
if (!SetterMethod) {
// try a different naming convention for getter: isXxxxx
StringRef getterNameString = getterName->getName();
- if (getterNameString.startswith("is") && !GRT->isObjCRetainableType()) {
- GetterHasIsPrefix = true;
- const char *CGetterName = getterNameString.data() + 2;
+ bool IsPrefix = getterNameString.startswith("is");
+ if ((IsPrefix && !GRT->isObjCRetainableType()) ||
+ getterNameString.startswith("get")) {
+ LengthOfPrefix = (IsPrefix ? 2 : 3);
+ const char *CGetterName = getterNameString.data() + LengthOfPrefix;
+ // Make sure that first character after "is" or "get" prefix can
+ // start an identifier.
+ if (!isIdentifierHead(CGetterName[0]))
+ return false;
if (CGetterName[0] && isUppercase(CGetterName[0])) {
getterName = &Ctx.Idents.get(CGetterName);
SetterSelector =
return false;
edit::Commit commit(*Editor);
rewriteToObjCProperty(Method, SetterMethod, *NSAPIObj, commit,
- GetterHasIsPrefix);
+ LengthOfPrefix);
Editor->commit(commit);
return true;
}
// as a 'readonly' property.
edit::Commit commit(*Editor);
rewriteToObjCProperty(Method, 0 /*SetterMethod*/, *NSAPIObj, commit,
- GetterHasIsPrefix);
+ LengthOfPrefix);
Editor->commit(commit);
return true;
}
+ (double) D;
@property(nonatomic, readonly) void * JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER);
@property(nonatomic, getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents;
+
+@property(nonatomic, getter=getStringValue, retain) NSString * stringValue;
+@property(nonatomic, getter=getCounterValue, readonly) BOOL counterValue;
+
+@property(nonatomic, getter=getns_dixtionary, readonly) NSDictionary * ns_dixtionary;
+
+- (BOOL)is3bar; // watch out
+- (NSString *)get3foo; // watch out
@end