Advertisement Jump to content
Sign in to follow this  
Kurage

Register instance

This topic is 1755 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I'm in trouble about registering a C++ class instance that is guaranteed to exist while the application is running.

The application instanciates the class only once then sets some correct values and keeps the instance.

I wrote some glue functions in order to accomplish my problem but none goes well.

Is there the way to register it?

 

Best regards,

Kurage

Edited by Kurage

Share this post


Link to post
Share on other sites
Advertisement

How do you want the script to access this object instance? Should it see it as a singleton object? Or should it call methods on the object as if they were global functions?

 

If you want the singleton object, you can register the type with the flag asOBJ_NOHANDLE, then register the object pointer with RegisterGlobalProperty.

 

If you want the script to call the methods as global functions you can register the object methods with RegisterGlobalFunction and using the calling convention asCALL_THISCALL_ASGLOBAL, and informing the object pointer as the last parameter.

 

You don't need any glue code in either of these cases, unless the object's methods needs it to translate some of the arguments or return value.

Share this post


Link to post
Share on other sites

I want the script to access as a singleton object, and it can be done how you mentioned.

Thanks for a lot!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!