Mailing Lists: Apple Mailing Lists

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

Namespaces and ObjC




Hi

we intend to introduce namespaces to ObjM2 and ideally do so in a way that ObjC classes will also benefit from this. It would be great if somebody with insights into the Mach-O format and the ObjC runtime could give some feedback or even join our discussion on this topic.

So far the idea is to allow classes to be bundled into a library module and add a facility for the library module to rename the classes as it exports them, which would cause them to be added to the ObjC runtime under their "rebranded" name instead of their original name.

Example ...

DEFINITION MODULE Vendor; (* this is the library module *)

EXPORT Foobar AS ProductA, Barbar AS ProductB;

(* a class written in ObjM2 which is external to Vendor but repackaged here *)
INTERFACE MODULE Foobar : NSObject; <*EXTERNAL=ObjM2*>


(* a class written in ObjC which is external to Vendor but repackaged here *)
INTERFACE MODULE Barbar : NSObject; <*EXTERNAL=ObjC*>


END Vendor.

Now, "consumers" can use both classes under their "rebranded" names ...

MODULE MyApp;

FROM Vendor IMPORT Foobar, Barbar;

VAR
  foobar : Foobar = [[Foobar alloc] init];
  barbar : Barbar = [[Barbar alloc] init];

and the compiler will generate code that adds those classes as Foobar and Barbar to the ObjC runtime, using objc_addClass(), thereby avoiding any name conflict there may have been with a third party library or framework.

The general concept is that of a trade relationship. An exporter of products has control over the global branding of those products, whether they are manufactured inhouse, or whether they are OEM products sourced elsewhere.

Now, the issue here is that if we don't have the source code for classes that refer to Foobar as ProductA and Barbar as ProductB, then we would need to replace any references to ProductA and ProductB in those compiled classes with Foobar and Barbar.

It would seem that this should be possible to do, but we are not sure about that. We'd appreciate some comments on this, mainly as to feasibility in general, not necessarily in respect of how to do it, because at this point the goal is to design a language extension. Implementation is further down the road.

thanks for any feedback
ObjM2 project



___________________________________________________________ To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/objc-language/email@hidden


This email sent to 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.