yeti / signals

MIT License
3 stars 4 forks source link

Generalize field name conversion to facilitate different reserved keywords in Obj-C and Swift. This also closes #26. #68

Closed brianleungwh closed 5 years ago

brianleungwh commented 8 years ago

Since Objective-C and Swift have different reserved keywords, I have decided to factor out the functions in conversion.py into @classmethods. The conversion methods are defined under the BaseConverter class. ObjectiveCConverter and SwiftConverter inherits from BaesConverter and methods such as sanitize_field_names and get_proper_name will convert field names to appropriate names in target language based on their respective mappings defined in reserved_mappings.py, in which keywords such as long and int that causes compilation error in Objective-C are now added. Of course, methods defined in the base class can be overridden to generate different format. I have also decided to have get_proper_name in ios_template_methods.py to convert field names based on Objective-C's reserved mappings because the doc states that the iOS generator currently assumes users to be using Objective-C. However, with this more generalized approach to convert names for iOS code, it should now be easier to add the ability to output Swift templates in the future. Tests were also edited to accommodate the new changes.