diff dstep/objc/bridge/Bridge.d @ 25:b9de51448c6b

Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
author Jacob Carlborg <doob@me.com>
date Tue, 06 Apr 2010 11:37:27 +0200
parents 6255d355d752
children 57371c29ef73
line wrap: on
line diff
--- a/dstep/objc/bridge/Bridge.d	Wed Feb 10 19:24:32 2010 +0100
+++ b/dstep/objc/bridge/Bridge.d	Tue Apr 06 11:37:27 2010 +0200
@@ -111,72 +111,73 @@
 }
 
 /**
- * All Objective-C wrappers should mix in this string.
+ * All Objective-C wrappers should mix in this template.
  * 
- * Mixes in:
- * $(UL
- * 		$(LI $(D_PSYMBOL __objcClass): a class variable representing the Objective-C class)
- * 		$(LI $(D_PSYMBOL __objcSuperClass): a class variable representing the Objective-C super class)
- * 		$(LI A constructor taking an Objective-C instance)
- * 		$(LI $(D_PSYMBOL dstep.objc.bridge.ClassInitializer.ObjcSubclassInitializer))
- * )
+ * Mixes in: $(D_PSYMBOL dstep.objc.bridge.ClassInitializer.ObjcSubclassInitializer)
+ * 
  * 
  * Examples:
  * ---
  * class AppController : NSObject
  * {
- * 		mixin(ObjcWrap);
+ * 		mixin ObjcWrap;
  * }
  * ---
  */
-const ObjcWrap = "static private dstep.objc.objc.Class __objcClass;
+template ObjcWrap ()
+{
+	/// This variable represents the Objective-C class.
+	static private dstep.objc.objc.Class __objcClass;
+	
+	/// This variable represents the Objective-C super class.
 	static private dstep.objc.objc.Class __objcSuperClass;
-			
-	this (dstep.objc.objc.id object)
-	{
-		super(object);
-	}	
-				
+		
+	/**
+	 * Allocates a new instance of the receiver.
+	 * 
+	 * Returns: a new instance of the receiver
+	 */
 	static typeof(this) alloc ()
 	{
-		return invokeObjcSelfClass!(typeof(this), \"alloc\");
+		return invokeObjcSelfClass!(typeof(this), "alloc");
 	}
 		
-	mixin dstep.objc.bridge.ClassInitializer.ObjcSubclassInitializer!(this.stringof, super.stringof);";
+	mixin dstep.objc.bridge.ClassInitializer.ObjcSubclassInitializer!(this.stringof, super.stringof);
+}
 
 /**
  * All Objective-C wrappers should mix in this string.
  * 
- * Mixes in:
- * $(UL
- * 		$(LI $(D_PSYMBOL __objcClass): a class variable representing the Objective-C class)
- * 		$(LI $(D_PSYMBOL __objcSuperClass): a class variable representing the Objective-C super class)
- * 		$(LI A constructor taking an Objective-C instance)
- * 		$(LI $(D_PSYMBOL dstep.objc.bridge.ClassInitializer.ObjcSubclassInitializer))
- * ) 
+ * Mixes in: $(D_PSYMBOL dstep.objc.bridge.ClassInitializer.ObjcSubclassInitializer)
  * 
  * Examples:
  * ---
  * class NSString : NSObject
  * {
- * 		mixin(ObjcClusterWrap);
+ * 		mixin ObjcClusterWrap;
  * }
  * ---
  */
-const ObjcClusterWrap = "static private dstep.objc.objc.Class __objcClass;
+template ObjcClusterWrap ()
+{
+	/// This variable represents the Objective-C class.
+	static private dstep.objc.objc.Class __objcClass;
+	
+	/// This variable represents the Objective-C super class.
 	static private dstep.objc.objc.Class __objcSuperClass;
-			
-	this (dstep.objc.objc.id object)
-	{
-		super(object);
-	}
 	
+	/**
+	 * Allocates a new instance of the receiver.
+	 * 
+	 * Returns: a new instance of the receiver
+	 */
 	static typeof(this) alloc ()
 	{
-		return invokeObjcSuperClass!(typeof(this), \"alloc\");
+		return invokeObjcSuperClass!(typeof(this), "alloc");
 	}		
 			
-	mixin dstep.objc.bridge.ClassInitializer.ObjcSubclassInitializer!(this.stringof, super.stringof);";
+	mixin dstep.objc.bridge.ClassInitializer.ObjcSubclassInitializer!(this.stringof, super.stringof);
+}
 
 /**
  * Makes the given field available as an IBOutlet.
@@ -746,7 +747,7 @@
 	 * Params:
 	 *     objcInstance = the Objective-C instance to deregister
 	 */
-	package static void deregisterObjcInstance (id objcInstance)
+	package void deregisterObjcInstance (id objcInstance)
 	{
 		GC.removeRoot(getObjcIvar!(DObjectType, dObjectVar)(objcInstance));
 	}