Objective-C Mapping for Identifiers

Objective-C identifiers are derived from Slice identifiers. The exact Objective-C identifier that is generated depends on the context. For types that are nested in modules (and hence have global visibility in Objective-C), the generated Objective-C identifiers are prefixed with their module prefix. Slice identifiers that do not have global visibility (such as operation names and structure members) do not use the module prefix and are preserved without change. For example, consider the following Slice definition:

module Example 
    struct Point 
        double x;
        double y;

This maps to the following Objective-C definition:

@interface EXPoint : NSObject <NSCopying>
        ICEDouble x;
        ICEDouble y;

@property(nonatomic, assign) ICEDouble x;
@property(nonatomic, assign) ICEDouble y;

// More definitions here...

If a Slice identifier is the same as an Objective-C keyword, the corresponding Objective-C identifier has an underscore suffix. For example, Slice while maps to Objective-C while_.

In some cases, the Objective-C mapping generates more than one identifier for a given Slice construct. For example, an interface Intf generates the identifiers EXIntf and EXIntfPrx. If a Slice identifier happens to be an Objective-C keyword, the underscore suffix applies only where necessary, so an interface while generates EXWhile and EXWhilePrx.

Note that Slice operation and member names can clash with the name of an inherited method, property, or instance variable. For example:

exception Failed 
    string reason; // Clashes with NSException

This is a legal Slice definition. However, the generated exception class derives from NSException, which defines a reason method. To avoid hiding the method in the base class, the generated exception class maps the Slice reason member to the Objective-C property reason_, just as it would for a keyword.

This escape mechanism applies to all generated classes that directly or indirectly derive from NSObject or NSException.

See Also