I'm not sure I understand the Cocoa namespace problem very well. Does
this mean that even if the controls are distributed as just .h/.m
files to include in your project, the names could conflict if multiple
plugins simply have the same class name?
exactly.
(going off memory:) objc classes/symbols are registered with the objc runtime when the binary is loaded. if you attempt to register an objc class with a name that has already been registered (which happens by loading your binary), then you're well on your way to UB:
- a message will be logged when the second class attempts to register
- the first class is not replaced
- the second class is then not registered
- alloc/init calls to this class (in your implementation) would return an instance from the objc class which was first loaded (e.g., the other manufacturer's, or from another plugin you developed which also statically linked to the control library)
the problems could manifest many ways; you may end up with different data layouts of ivars and methods from multiple implementations.
if you distribute a framework (and don't alter the names), then you have to ensure all binaries refer to the framework implementation, which means you'll have to support versioning (otherwise, the chances for failure are too high).
if the classes/categories are linked into the plugin's ui executable, then all class names and category methods for each distribution will have to be uniquely named.
fwiw, you can also synthesize objc classes (with arbitrary names/selectors) at runtime.
Maybe I'm not remembering
correctly, but we *do not* have this problem in C and C++, correct?
This seems a bizarre design choice.
correct - C and C++ don't register with the objc runtime. bizarre, perhaps, but this is also a feature in some regards. for example, it allows constructs we can't (conveniently) simulate in C or C++, such as: "id stack = [NSClassFromString(@"YYYStack") new]".
I notice that AUGUI is for Carbon, which I'm not developing for. I'll
take a look at VSTGUI and WDL. Thanks
-Kevin
AUGUI also includes a cocoa sample. the library was primarily developed when Carbon AU views were the standard and Cocoa AU views were still very new.
|