Skip navigation.
 
mlRe: Strategies to prevent class name clashes
FROM : Bill Bumgarner
DATE : Sat Feb 16 19:37:13 2008

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

Related mailsAuthorDate
mlStrategies to prevent class name clashes Arne Scheffler Feb 15, 10:09
mlRe: Strategies to prevent class name clashes Lieven Dekeyser Feb 15, 10:42
mlRe: Strategies to prevent class name clashes Arne Scheffler Feb 15, 11:22
mlRe: Strategies to prevent class name clashes Uli Kusterer Feb 15, 11:43
mlRe: Strategies to prevent class name clashes Arne Scheffler Feb 15, 12:42
mlRe: Strategies to prevent class name clashes Thomas Engelmeier Feb 15, 13:04
mlRe: Strategies to prevent class name clashes Arne Scheffler Feb 15, 13:35
mlRe: Strategies to prevent class name clashes Thomas Engelmeier Feb 15, 15:57
mlRe: Strategies to prevent class name clashes glenn andreas Feb 15, 16:13
mlRe: Strategies to prevent class name clashes Jonathon Mah Feb 15, 17:11
mlRe: Strategies to prevent class name clashes Bill Bumgarner Feb 15, 17:53
mlRe: Strategies to prevent class name clashes B.J. Buchalter Feb 15, 21:16
mlRe: Strategies to prevent class name clashes Arne Scheffler Feb 16, 09:18
mlRe: Strategies to prevent class name clashes Jens Alfke Feb 16, 17:42
mlRe: Strategies to prevent class name clashes Arne Scheffler Feb 16, 19:14
mlRe: Strategies to prevent class name clashes Bill Bumgarner Feb 16, 19:37
mlRe: Strategies to prevent class name clashes Chris Hanson Feb 17, 05:45