From f711fc5705e8891b41ce0364b24ff495db1a4856 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Wed, 21 Jul 2010 22:44:38 +0800 Subject: [PATCH] Fixed bugs 8, 10, and 11; added machine-generated primitive accessors credit to my colleague paugus. Project was using 10.4 SDK, now uses Base SDK. Fixed some warnings. Removed some 10.4 support. --- MiscMerge/MiscMergeEngine.m | 2 +- MiscMerge/MiscMergeTemplate.m | 2 +- MiscMerge/NSString+MiscAdditions.h | 1 - MiscMerge/NSString+MiscAdditions.m | 10 ---------- ddcli/DDCliApplication.m | 2 +- mogenerator.h | 1 + mogenerator.m | 10 ++++++---- mogenerator.xcodeproj/project.pbxproj | 4 ++-- templates/machine.h.motemplate | 22 ++++++++++++++++++++++ templates/machine.m.motemplate | 10 +++++++++- 10 files changed, 43 insertions(+), 21 deletions(-) diff --git a/MiscMerge/MiscMergeEngine.m b/MiscMerge/MiscMergeEngine.m index 6f272ead..224c5410 100755 --- a/MiscMerge/MiscMergeEngine.m +++ b/MiscMerge/MiscMergeEngine.m @@ -584,7 +584,7 @@ - (MiscMergeCommandExitType)executeCommandBlock:(MiscMergeCommandBlock *)block } [commandStack removeLastObject]; - [localPool release]; + [localPool drain]; return exitCode; } diff --git a/MiscMerge/MiscMergeTemplate.m b/MiscMerge/MiscMergeTemplate.m index d49becb4..7d35dee3 100755 --- a/MiscMerge/MiscMergeTemplate.m +++ b/MiscMerge/MiscMergeTemplate.m @@ -548,7 +548,7 @@ - (void)parseString:(NSString *)string [self _addBetweenString:[[accumString copy] autorelease]]; } - [localPool release]; + [localPool drain]; } @end diff --git a/MiscMerge/NSString+MiscAdditions.h b/MiscMerge/NSString+MiscAdditions.h index 85a0ca80..3bad4b37 100755 --- a/MiscMerge/NSString+MiscAdditions.h +++ b/MiscMerge/NSString+MiscAdditions.h @@ -26,7 +26,6 @@ enum @interface NSCharacterSet (MiscAdditions) + (NSCharacterSet *)allWhitespaceCharacterSet; -+ (NSCharacterSet *)newlineCharacterSet; @end diff --git a/MiscMerge/NSString+MiscAdditions.m b/MiscMerge/NSString+MiscAdditions.m index 52b0a66a..68e49bff 100755 --- a/MiscMerge/NSString+MiscAdditions.m +++ b/MiscMerge/NSString+MiscAdditions.m @@ -38,16 +38,6 @@ + (NSCharacterSet *)allWhitespaceCharacterSet return whiteSet; } -+ (NSCharacterSet *)newlineCharacterSet -{ - static NSCharacterSet *newlineSet = nil; - - if (newlineSet == nil) - newlineSet = [[NSCharacterSet characterSetWithCharactersInString:@"\n\r"] retain]; - - return newlineSet; -} - @end diff --git a/ddcli/DDCliApplication.m b/ddcli/DDCliApplication.m index 40a55a90..40d33023 100644 --- a/ddcli/DDCliApplication.m +++ b/ddcli/DDCliApplication.m @@ -111,6 +111,6 @@ int DDCliAppRunWithClass(Class delegateClass) // Initialize singleton/global DDCliApplication * app = [DDCliApplication sharedApplication]; int result = [app runWithClass: delegateClass]; - [pool release]; + [pool drain]; return result; } diff --git a/mogenerator.h b/mogenerator.h index da3ae255..9c07d58e 100644 --- a/mogenerator.h +++ b/mogenerator.h @@ -33,6 +33,7 @@ - (NSString*)scalarAttributeType; - (BOOL)hasDefinedAttributeType; - (NSString*)objectAttributeType; +- (BOOL)hasTransformableAttributeType; @end @interface NSString (camelCaseString) diff --git a/mogenerator.m b/mogenerator.m index 650488ed..80ae3d77 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -242,16 +242,18 @@ - (BOOL)hasDefinedAttributeType { return [self attributeType] != NSUndefinedAttributeType; } - (NSString*)objectAttributeType { -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 - #define NSTransformableAttributeType 1800 -#endif - if ([self attributeType] == NSTransformableAttributeType) { + if ([self hasTransformableAttributeType]) { NSString *result = [[self userInfo] objectForKey:@"attributeValueClassName"]; return result ? result : @"NSObject"; } else { return [self attributeValueClassName]; } } + +- (BOOL)hasTransformableAttributeType { + return ([self attributeType] == NSTransformableAttributeType); +} + @end @implementation NSString (camelCaseString) diff --git a/mogenerator.xcodeproj/project.pbxproj b/mogenerator.xcodeproj/project.pbxproj index 87811950..55ef1965 100644 --- a/mogenerator.xcodeproj/project.pbxproj +++ b/mogenerator.xcodeproj/project.pbxproj @@ -460,7 +460,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + SDKROOT = ""; }; name = Debug; }; @@ -473,7 +473,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + SDKROOT = ""; }; name = Release; }; diff --git a/templates/machine.h.motemplate b/templates/machine.h.motemplate index c3b05b78..95c55191 100644 --- a/templates/machine.h.motemplate +++ b/templates/machine.h.motemplate @@ -6,6 +6,8 @@ <$foreach Relationship noninheritedRelationships do$>@class <$Relationship.destinationEntity.managedObjectClassName$>; <$endforeach do$> +<$foreach Attribute noninheritedAttributes do$><$if Attribute.hasTransformableAttributeType$>@class <$Attribute.objectAttributeType$>;<$endif$> +<$endforeach do$> @interface <$managedObjectClassName$>ID : NSManagedObjectID {} @end @@ -54,3 +56,23 @@ - (void)remove<$Relationship.name.initialCapitalString$>Object:(<$Relationship.destinationEntity.managedObjectClassName$>*)value_; <$endif$><$endforeach do$> @end + +@interface _<$managedObjectClassName$> (CoreDataGeneratedPrimitiveAccessors) +<$foreach Attribute noninheritedAttributes do$> +- (<$Attribute.objectAttributeType$>*)primitive<$Attribute.name.initialCapitalString$>; +- (void)setPrimitive<$Attribute.name.initialCapitalString$>:(<$Attribute.objectAttributeType$>*)value; +<$if Attribute.hasScalarAttributeType$> +- (<$Attribute.scalarAttributeType$>)primitive<$Attribute.name.initialCapitalString$>Value; +- (void)setPrimitive<$Attribute.name.initialCapitalString$>Value:(<$Attribute.scalarAttributeType$>)value_; +<$endif$> +<$endforeach do$> +<$foreach Relationship noninheritedRelationships do$> +<$if Relationship.isToMany$> +- (NSMutableSet*)primitive<$Relationship.name.initialCapitalString$>; +- (void)setPrimitive<$Relationship.name.initialCapitalString$>:(NSMutableSet*)value; +<$else$> +- (<$Relationship.destinationEntity.managedObjectClassName$>*)primitive<$Relationship.name.initialCapitalString$>; +- (void)setPrimitive<$Relationship.name.initialCapitalString$>:(<$Relationship.destinationEntity.managedObjectClassName$>*)value; +<$endif$> +<$endforeach do$> +@end diff --git a/templates/machine.m.motemplate b/templates/machine.m.motemplate index f16a3767..8f8a7480 100644 --- a/templates/machine.m.motemplate +++ b/templates/machine.m.motemplate @@ -35,13 +35,21 @@ - (<$Attribute.scalarAttributeType$>)<$Attribute.name$>Value { NSNumber *result = [self <$Attribute.name$>]; - return result ? [result <$Attribute.scalarAttributeType.camelCaseString$>Value] : 0; + return [result <$Attribute.scalarAttributeType.camelCaseString$>Value]; } - (void)set<$Attribute.name.initialCapitalString$>Value:(<$Attribute.scalarAttributeType$>)value_ { [self set<$Attribute.name.initialCapitalString$>:[NSNumber numberWith<$Attribute.scalarAttributeType.camelCaseString.initialCapitalString$>:value_]]; } +- (<$Attribute.scalarAttributeType$>)primitive<$Attribute.name.initialCapitalString$>Value { + NSNumber *result = [self primitive<$Attribute.name.initialCapitalString$>]; + return [result <$Attribute.scalarAttributeType.camelCaseString$>Value]; +} + +- (void)setPrimitive<$Attribute.name.initialCapitalString$>Value:(<$Attribute.scalarAttributeType$>)value_ { + [self setPrimitive<$Attribute.name.initialCapitalString$>:[NSNumber numberWith<$Attribute.scalarAttributeType.camelCaseString.initialCapitalString$>:value_]]; +} <$endif$> <$endif$> <$endforeach do$>