Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strategies to prevent class name clashes



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Strategies to prevent class name clashes (From: Arne Scheffler <email@hidden>)
 >Re: Strategies to prevent class name clashes (From: Lieven Dekeyser <email@hidden>)
 >Re: Strategies to prevent class name clashes (From: Uli Kusterer <email@hidden>)
 >Re: Strategies to prevent class name clashes (From: Arne Scheffler <email@hidden>)
 >Re: Strategies to prevent class name clashes (From: Jens Alfke <email@hidden>)
 >Re: Strategies to prevent class name clashes (From: Arne Scheffler <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.