Mercurial > projects > openmelee
view test/example.d @ 19:08ddf9e71b88
steer to avoid
author | zzzzrrr <mason.green@gmail.com> |
---|---|
date | Wed, 25 Mar 2009 14:44:47 -0400 |
parents | 7f74e064dad5 |
children |
line wrap: on
line source
// 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)); }