Closed ChristopherBruno78 closed 8 years ago
Just curios, but would you mind sharing a pseudo-example how that would possibly look/work in OJ and what could be done with it?
Categories are a core feature of objective-c, would be nice to use them with the oj compiler. Right now you get an compile error. What should happen is the methods get added to an existing class (if the class doesnt existing, you get a runtime exception)
This should be doable, syntax would be similar to Obj-C:
@implementation Foo (CategoryName)
@end
Which would have an AST node similar to:
{ type: Syntax.OJClassImplementation, id: "Foo", category: "CategoryName", body: ... }
Likely handleClassImplementation
in the generator would be modified to call some kind of _registerCategory
function in this case rather than _registerClass
at runtime.
6072f88 adds the ability to define categories which add methods, similar to objc 1.
The following are unsupported:
@property
and @dynamic
in a category implementationLike Obj-C, defining a method that already exists is undefined behavior.
I wonder if there is any plan to implement Objective-C Categories?