Jump to content
  • Advertisement
Sign in to follow this  
rviney

Making GetFunction() aware of global functions

This topic is 2512 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

Hi,

I've run into a problem with asCContext::GetFunction(0), its return value doesn't change when execution is inside a global function, instead it just returns whatever the function was that called the global function. So if you call asGetActiveContext()->GetFunction(0) from inside the body of a global function the answer isn't very helpful!

This functionality is useful for an application that needs to associate additional data with a global function. In my case I'm proxying through to a method call on a class instance.

I ended up altering as_context.cpp at lines 2051 and 2201 to add this functionality, but my solution probably isn't perfect. Calls like this:


l_sp += CallSystemFunction(i, this, 0);


Get wrapped like this:


asCScriptFunction * previousCurrentFunction = currentFunction;
currentFunction = engine->scriptFunctions;
l_sp += CallSystemFunction(i, this, 0);
currentFunction = previousCurrentFunction;


Any chance of this change or something like it being included in the next point release?

Thanks,
Richard

Share this post


Link to post
Share on other sites
Advertisement
I'll look into it.

Though using the currentFunction for this is probably not a good idea. Instead I'll probably add a new method, e.g. GetCalledSystemFunction() or something like it.

Share this post


Link to post
Share on other sites
Thanks. Yes I wasn't sure if using currentFunction was right, but it's been working so far. Looking forward to the proper implementation at some point!

Thanks,
Richard

Share this post


Link to post
Share on other sites
I've added the function asIScriptFunction::GetSystemFunction() in revision 1143. When a system function is being called, it will return the asIScriptFunction pointer for that one, otherwise it will return 0.

Regards,
Andreas

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!