View previous topic :: View next topic |
Author |
Message |
dhasenan
Joined: 03 Feb 2005 Posts: 73 Location: New York
|
Posted: Tue Mar 24, 2009 11:10 am Post subject: Using minid objects from D? |
|
|
In a game, I want minid objects to represent various entities. The bulk of the code is in D, so I want to deal with these minid objects as D objects.
The first thing that came to mind is, just use inheritance. I'm uncertain if this just works. I know it would be somewhat tricky to implement, with final methods and so forth.
My next idea was, write a wrapper that forwards to a MDInstance. I tried writing this, but it's impossible. There's a function to insert an MDInstance* into a stack, but it's package-accessible. I'd need to create one MDThread per MDInstance.
Also, my minid objects need to receive events involving various other minid objects. I don't see any way to invoke a minid method from D that has parameters that are minid instances.
The documentation for the binding library isn't finished, and I didn't see anything relating specifically to this -- there's an example that constructs an object and uses it immediately, but that's the extent.
What do you recommend? |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Tue Mar 24, 2009 5:02 pm Post subject: |
|
|
Step 1: wrap D base class with minid.bind, wrapping the methods you want to be overridden.
Step 2: derive from that class in MiniD and override the methods you want.
Step 3: create an instance of the derived class.
Step 4: get the D instance with superGet!(BaseClass)(t, slot).
Yay!
As for methods which take MiniD classes as params? As long as those params are also classes which are or derive from wrapped D classes, it should work fine. |
|
Back to top |
|
|
dhasenan
Joined: 03 Feb 2005 Posts: 73 Location: New York
|
Posted: Tue Mar 24, 2009 5:31 pm Post subject: |
|
|
Okay, that was as easy as I could have hoped, and in fact easier than I did hope. Thanks! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|