Navigation Menu

Skip to content

Commit

Permalink
[FIX] mogenerator 1.6.1. Fix ObjC/PPC message-nil-float-method-result…
Browse files Browse the repository at this point in the history
… gotcha in generated code reported by Ruotger Skupin. Used to generate this code:

 - (float)someAttributeValue {
    return [[self someAttribute] floatValue];
 }

Now generate this code:

 - (float)someAttributeValue {
    NSNumber *result = [self someAttribute];
    return result ? [result floatValue] : 0;
 }

Ref:
 <http://unixjunkie.blogspot.com/2006/02/messaging-nil-in-objective-c.html>
 <http://ridiculousfish.com/blog/archives/2005/05/29/nil/>
  • Loading branch information
rentzsch committed Oct 11, 2007
1 parent 54ce32b commit 549d286
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion machine.m.motemplate
Expand Up @@ -23,7 +23,8 @@
<$if Attribute.hasScalarAttributeType$>

- (<$Attribute.scalarAttributeType$>)<$Attribute.name$>Value {
return [[self <$Attribute.name$>] <$Attribute.scalarAttributeType.camelCaseString$>Value];
NSNumber *result = [self <$Attribute.name$>];
return result ? [result <$Attribute.scalarAttributeType.camelCaseString$>Value] : 0;
}

- (void)set<$Attribute.name.initialCapitalString$>Value:(<$Attribute.scalarAttributeType$>)value_ {
Expand Down
2 changes: 1 addition & 1 deletion mogenerator.m
Expand Up @@ -270,7 +270,7 @@ - (int) application: (DDCliApplication *) app

if (_version)
{
printf("mogenerator 1.6. By Jonathan 'Wolf' Rentzsch + friends.\n");
printf("mogenerator 1.6.1. By Jonathan 'Wolf' Rentzsch + friends.\n");
return EXIT_SUCCESS;
}

Expand Down

0 comments on commit 549d286

Please sign in to comment.