Changeset 256

Show
Ignore:
Timestamp:
10/10/07 22:58:12 (11 months ago)
Author:
rentzsch
Message:

[FIX] mogenerator 1.6.1. Fix ObjC/PPC message-nil-float-method-result 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/>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cocoa/mogenerator/machine.m.motemplate

    r243 r256  
    2424 
    2525- (<$Attribute.scalarAttributeType$>)<$Attribute.name$>Value { 
    26         return [[self <$Attribute.name$>] <$Attribute.scalarAttributeType.camelCaseString$>Value]; 
     26        NSNumber *result = [self <$Attribute.name$>]; 
     27        return result ? [result <$Attribute.scalarAttributeType.camelCaseString$>Value] : 0; 
    2728} 
    2829 
  • trunk/cocoa/mogenerator/mogenerator.m

    r251 r256  
    271271    if (_version) 
    272272    { 
    273         printf("mogenerator 1.6. By Jonathan 'Wolf' Rentzsch + friends.\n"); 
     273        printf("mogenerator 1.6.1. By Jonathan 'Wolf' Rentzsch + friends.\n"); 
    274274        return EXIT_SUCCESS; 
    275275    }