diff test/example.d @ 18:7f74e064dad5

refactored code
author zzzzrrr <mason.green@gmail.com>
date Wed, 25 Mar 2009 11:28:25 -0400
parents example.d@82efafc87d54
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/example.d	Wed Mar 25 11:28:25 2009 -0400
@@ -0,0 +1,80 @@
+// jake -I../minid -I.. -version=old example.d
+module example;
+
+import xf.xpose2.Expose;
+import xf.xpose2.MiniD;
+import tango.text.convert.Format;
+
+struct vec3 {
+	float x, y, z;
+	
+	char[] toString() {
+		return Format("x={} y={} z={}", x, y, z);
+	}
+	
+	mixin(xpose2(`
+		.*
+		toString
+		_ctor overload vec3 function(float, float, float)
+	`));
+	mixin xposeMiniD;
+}
+
+class Poop {
+	int x = 0;
+	
+	this() {
+		this.x = 123456;
+	}
+	
+	this(int x) {
+		this.x = x;
+	}
+	
+	this (char[] zomg) {
+		this.x = zomg.length;
+	}
+	
+	int max(int a, int b) {
+		return a > b ? a : b;
+	}
+	
+	int dmax(int a, int b) {
+		return max(max(a, b), x);
+	}
+	
+	int dmax(int a, int b, int c) {
+		return dmax(a, dmax(b, c));
+	}
+	
+	vec3 getVec3(int x, int y, int z) {
+		return vec3(x, y, z);
+	}
+    
+}
+
+mixin(xpose2(`Poop`,`
+	dmax
+	dmax overload int function(int, int, int) ; md { rename "dmax2" }
+	getVec3
+	.*
+	_ctor
+	_ctor overload Poop function(int)
+	_ctor overload Poop function(char[])
+`));
+
+mixin xposeMiniD!(`Poop`);
+
+void main(char[][] args)
+{
+	MDVM vm;
+	auto t = openVM(&vm);
+	loadStdlibs(t);
+    xposeMiniD_initAll(t);
+    superPush(t, new Poop(10));
+    newGlobal(t, "poop");
+    importModule(t, args[1]);
+    lookup(t, "poop");
+	auto poop = superGet!(Poop)(t, -1);
+	Stdout.formatln("poop.dmax(1, 2) == {}", poop.dmax(1, 2));
+}