const TypedefDecl *TypedefDcl,
const NSAPI &NS, edit::Commit &commit,
bool IsNSIntegerType) {
- std::string ClassString =
+ std::string ClassString =
IsNSIntegerType ? "typedef NS_ENUM(NSInteger, " : "typedef NS_OPTIONS(NSUInteger, ";
ClassString += TypedefDcl->getIdentifier()->getName();
ClassString += ')';
return false;
}
+static bool rewriteToNSEnumDecl(const EnumDecl *EnumDcl,
+ const TypedefDecl *TypedefDcl,
+ const NSAPI &NS, edit::Commit &commit) {
+ std::string ClassString = "NS_ENUM(NSInteger, ";
+ ClassString += TypedefDcl->getIdentifier()->getName();
+ ClassString += ')';
+ SourceRange R(EnumDcl->getLocStart(), EnumDcl->getLocStart());
+ commit.replace(R, ClassString);
+ SourceLocation TypedefLoc = TypedefDcl->getLocEnd();
+ commit.remove(SourceRange(TypedefLoc, TypedefLoc));
+ return true;
+}
+
void ObjCMigrateASTConsumer::migrateProtocolConformance(ASTContext &Ctx,
const ObjCImplementationDecl *ImpDecl) {
const ObjCInterfaceDecl *IDecl = ImpDecl->getClassInterface();
QualType qt = TypedefDcl->getTypeSourceInfo()->getType();
bool IsNSIntegerType = NSAPIObj->isObjCNSIntegerType(qt);
bool IsNSUIntegerType = !IsNSIntegerType && NSAPIObj->isObjCNSUIntegerType(qt);
- if (!IsNSIntegerType && !IsNSUIntegerType)
- return;
+ if (!IsNSIntegerType && !IsNSUIntegerType) {
+ // Also check for typedef enum {...} TD;
+ if (const EnumType *EnumTy = qt->getAs<EnumType>()) {
+ if (EnumTy->getDecl() == EnumDcl) {
+ // NS_ENUM must be available.
+ if (!Ctx.Idents.get("NS_ENUM").hasMacroDefinition())
+ return;
+ edit::Commit commit(*Editor);
+ rewriteToNSEnumDecl(EnumDcl, TypedefDcl, *NSAPIObj, commit);
+ Editor->commit(commit);
+ return;
+ }
+ else
+ return;
+ }
+ else
+ return;
+ }
// NS_ENUM must be available.
if (IsNSIntegerType && !Ctx.Idents.get("NS_ENUM").hasMacroDefinition())
typedef NSUInteger UITableViewCellStyle;
+typedef enum {
+ UIViewAnimationTransitionNone,
+ UIViewAnimationTransitionFlipFromLeft,
+ UIViewAnimationTransitionFlipFromRight,
+ UIViewAnimationTransitionCurlUp,
+ UIViewAnimationTransitionCurlDown,
+} UIViewAnimationTransition;
+
enum {
UNOne,
UNTwo
+typedef NS_ENUM(NSInteger, UIViewAnimationTransition) {
+ UIViewAnimationTransitionNone,
+ UIViewAnimationTransitionFlipFromLeft,
+ UIViewAnimationTransitionFlipFromRight,
+ UIViewAnimationTransitionCurlUp,
+ UIViewAnimationTransitionCurlDown,
+} ;
+
enum {
UNOne,
UNTwo