MiniD 2 - Tentative Release Candidate 1

Jarrett Billingsley jarrett.billingsley at gmail.com
Mon Dec 8 09:07:53 PST 2008


On Mon, Dec 8, 2008 at 3:44 AM, mpt <foo at invalid.x> wrote:
> Great stuff, but I have some trouble with the binding lib.

Good!  Because I wasn't ;)

> 1. If I don't wrap a constructor, I get an error:
> minid/bind.d(1101): static assert  "Cannot call default constructor for class Foo; please wrap a constructor explicitly"

Fixed.

> 2. If I wrap a constructor with no parameters (i.e. WrapCtors!(void function())), I get an error:
> minid/bind.d(1066): constructor minid.bind.WrappedClass!(Foo,"Foo","",WrapCtors!(void function()),WrapMethod!(Call)).WrappedClass.ClassCtorShims!(void function()).this (MDVM*,()) does not match parameter types ()
> minid/bind.d(1066): Error: expected 1 arguments, not 0

Fixed.

> 3. I can't find an obvious way to initialize global variables, so I try superPush, which gives a runtime error:

You're actually doing it right, unless you wanted to instantiate the
wrapped MiniD class, in which case it'd be more like:

   pushGlobal(t, "Foo"); // get the global class Foo
   pushNull(t); // make room for 'this'
   rawCall(t, -2, 1); // call the class to instantiate it (1 return
for the instance)
   newGlobal(t, "myfoo"); // save it in the global myfoo


> minid.types.MDException: <no location available>: newInstance - expected 'class' for base, not 'null'

Fixed.

> Test code below:
>
> import minid.bind;
> import minid.api;
>
> class Foo {
>    this() {}
>    this(int i) {}
>    void Call() {}
> }
>
> void main() {
>    MDVM vm;
>    auto t = openVM(&vm);
>    loadStdlibs(t);
>    WrapGlobals!(
>        WrapType!(
>            Foo, "Foo",
>            WrapCtors!(void function(int)),
>            WrapMethod!(Foo.Call)
>        )
>    )(t);
>    superPush(t, new Foo());
>    newGlobal(t, "myfoo");
> }

This code now works, just svn up your MiniD installation :)


More information about the Digitalmars-d-announce mailing list