FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using minid objects from D?

 
Post new topic   Reply to topic     Forum Index -> MiniD
View previous topic :: View next topic  
Author Message
dhasenan



Joined: 03 Feb 2005
Posts: 73
Location: New York

PostPosted: Tue Mar 24, 2009 11:10 am    Post subject: Using minid objects from D? Reply with quote

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
View user's profile Send private message AIM Address
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Tue Mar 24, 2009 5:02 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
dhasenan



Joined: 03 Feb 2005
Posts: 73
Location: New York

PostPosted: Tue Mar 24, 2009 5:31 pm    Post subject: Reply with quote

Okay, that was as easy as I could have hoped, and in fact easier than I did hope. Thanks!
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MiniD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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