Pyd
Kirk McDonald
kirklin.mcdonald at gmail.com
Sat Jul 1 15:07:37 PDT 2006
Kirk McDonald wrote:
> Important things left to do:
> * Exposure of properties (and maybe member variables, though that is
> harder).
Done!
[testdll.d]
class Foo {
int m_i;
this() { }
this(int i) { m_i = i; }
this(int i, int j) { m_i = i + j; }
void foo() {
writefln("Foo.foo(): i = %s", m_i);
}
int i() { return m_i; }
void i(int j) { m_i = j; }
}
extern (C)
export void inittestdll() {
module_init("testdll");
wrapped_class!("Foo", Foo) f;
f.init!(ctor!(int), ctor!(int, int));
f.def!("foo", Foo.foo);
f.prop!("i", Foo.i);
finalize_class(f);
}
// EOF
(Also note the reworked class wrapping syntax.)
In Python:
>>> import testdll
>>> a = testdll.Foo(10)
>>> a.i
10
>>> a.i = 20
>>> a.i
20
--
Kirk McDonald
Pyd: Wrapping Python with D
http://dsource.org/projects/pyd/wiki
More information about the Digitalmars-d
mailing list