Move class-builder.m intelligence to Python
The code in class-builder.m should be split into two parts:
- In Python: API that has as its input the parent class, class name and input class dictionary, and returns the actual class dictionary
The Python code contains the logic for converting Python functions to objc.selector classes, adding convenience methods, .... This is is the interesting part of building a class.
- In ObjC: Calls (1) and then builds the ObjC class using only the objc.selector instances in the class dictionary.
Splitting class-builder like this should make it easier to update the interesting part, which is needed for a number of new features I'm thinking about:
- add "objc_method" class, similar to "python_method", to mark a method as a ObjC method (side-stepping auto detection)
- be smarter about the conversion to objc.selector, taking away the need to mark methods as a python_method (or objc_method).
- an async function is never a objc method
- ... except for some special cases that the framework wrappers know about (such as the application:shouldTerminate: delegate method)
- add async methods for most ObjC methods that have a completion block argument [*]
- add PEP8 compliant aliases [*]
- add
__new__to most classes [*]
This is one step toward making PyObjC more convenient and natural to use.
NOTE: the new (internal) Python API should also be used when updating the methods of a class (such as when assigning to a class).
NOTE: When this is done the "python_method" class no longer needs to be defined in C code.
[*] These can already be done with the current internal API