Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Pointers to member functions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Jake Albano   Members   -  Reputation: 605

Like
0Likes
Like

Posted 15 July 2012 - 07:16 PM

I can't seem to find any mention of whether this is possible or not. I'll explain what I'd like to do, and if it's impossible feel free to shoot me down. Posted Image

I have a keyboard class registered as a singleton in my game engine, so my scripts can access key state. The interface looks like this:

if (keyboard.space)
{
	doStuff();
}

The keys (in this case 'space') are implemented as property accessors that return a bool.

I'd like to be able to do something like this:

bind(@keyboard.space, @doStuff);

In this case, a pointer to the accessor would be stored along with a pointer to another function. The first function would be called continually, and if it returns true the second function would be called. I understand I could get the function object by declaration and set the calling object in the application, but I'd like to be able to do this with function and funcdefs.

So I'm wondering two things, actually:
  • Are pointers to member functions possible currently, or might they be in a future version?
  • If they are possible, would pointers to accessors need to be declared in long-form (@obj.get_prop), or would the short-form work as well (@obj.prop)?

Edited by Jake Albano, 15 July 2012 - 07:20 PM.


Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3261

Like
1Likes
Like

Posted 16 July 2012 - 08:18 PM

It's currently not possible to take pointers to class methods.

I have plans to implement something similar to c# / java delegates, though I don't know when I'll get to it.

Getting the pointer to a virtual property accessor will have to be done through the full name, e.g get_property, otherwise it would not be known which method it is.

Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 Jake Albano   Members   -  Reputation: 605

Like
0Likes
Like

Posted 17 July 2012 - 12:35 PM

Alright, thanks for the info. I look forward to the feature if/when you implement it, but it's not a blocking issue until then. :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS