On Monday, 15 April 2013 at 05:26:27 UTC, BLM768 wrote:

If I can automate the generation of bindings to a satisfactory degree, expanding the bindings should be a very simple process, so I could just write bindings for the core functionality and have others expand the bindings as needed. That way, the bindings only contain things that someone will actually use. I think that I'll represent the C++ classes as structs that hold the actual C++ objects as void arrays and contain stub methods that just forward to the C layer. If I can figure out a way to do it, I'd like to alias those stub methods directly to their C counterparts so I can handle cases where inlining won't kick in.

I've recently made some breakthroughs in the area of binding generation, and the system has reached the point where I can instantiate and use a simple C++ class (namely btTypedObject, which is probably the simplest class in Bullet) from D using my generated bindings. The system is rather interesting, but it's also a bit messy, so explore the code at your own risk.

Here's a condensed version of the test code:

//bullet/linearMath/btScalar.d
//Support code omitted
struct btTypedObject {
        mixin classBinding!"btTypedObject";

        mixin constructor!(int);
        mixin method!(int, "getObjectType");
}

//test.d
module main;

import std.stdio;

import bullet.linearMath.btScalar;

int main(string[] args) {
        auto obj = btTypedObject(1);

        writeln(obj.getObjectType());

        return 0;
}



Reply via email to