====== Xdef_ctor ====== Xdef_ctor0() Xdef_ctor1(A0) Xdef_ctor2(A0, A2) ... Xdef_ctor13(A0, A2, ..., A12) XTAL_PREBINDマクロのスコープ内で呼び出すことでそのクラスのコンストラクタをバインドすることができます。Xtal及びバインダはオーバーロードをサポートしていないので、ネイティブコンストラクタが複数あっても1つしか指定できません。 ===== Example ===== ==== C++ ==== class Rect{ public: int x, y, w, h; public: Rect(int x, int y, int w, int h) : x(x), y(y), w(w), h(h) { } StringPtr to_s() const{ return Xf("Rect(%d, %d, %d, %d)")->call(x, y, w, h)->to_s(); } }; XTAL_PREBIND(Rect){ Xdef_ctor4(int, int, int, int); Xparam(x, 0); Xparam(y, 0); Xparam(w, -1); Xparam(h, -1); } XTAL_BIND(Rect){ Xdef_var(x); Xdef_var(y); Xdef_var(w); Xdef_var(h); Xdef_method(to_s); } void exec_xtal(){ xtal::global()->def(Xid(Rect), xtal::cpp_class()); Xsrc(( rect : Rect(w:32, h:32); rect.p; rect.x = 24; rect.y = 16; rect.p; ))->call(); } ==== Output ==== Rect(0, 0, 32, 32) Rect(24, 16, 32, 32)