Re: Strategies to prevent class name clashes
Re: Strategies to prevent class name clashes
- Subject: Re: Strategies to prevent class name clashes
- From: Bill Bumgarner <email@hidden>
- Date: Sat, 16 Feb 2008 10:37:13 -0800
On Feb 16, 2008, at 10:14 AM, Arne Scheffler wrote:
After digging deep into the runtime of objective-c I think it should
be fairly easy to support some kind of two level namespaces for it.
I hope that they will add something like that in the next major
version of os x. But for now I needed a working solution, which I
found by creating the objective-c classes at runtime.
If you haven't already, please file bugs documenting your explicit
needs. Send me the bug # directly, please, and I'll dupe it to the
oldest "i can haz namespaces, pleez" bug in the system after capturing
your specific needs in said master bug.
You are correct in that it isn't hard to dynamically generate the
needed classes. The runtime provides all the API necessary for doing
so.
If possible, one pattern that has been successfully used that
minimizes metadata issues is to:
- create an abstract superclass that contains stub implementations of
methods with the argumentation you'll need (i.e. "method that returns
int and takes two floats, method that returns int and takes three
floats, etc...")
- implement C functions in your plugin(s) that have the correct method-
like argumentation and call through to your C++ code
int foo(AbstractClass *self, SEL _cmd, float a, float b) { .. call C+
+ ..; }
int foo(AbstractClass *self, SEL _cmd, float a, float b, float c) { ..
call C++ ..; }
- on plugin load, dynamically generate a subclass of your abstract
class and plugin the C functions as IMPs. By declaring the various
methods on the AbstractClass, you can grab the method signatures from
that class instead of having to manually generate those awful type
signatures (i@:ff, for example -- and that may not even be write).
b.bum
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden