Making GetFunction() aware of global functions

Started by
3 comments, last by rviney 12 years, 2 months ago
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
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.

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

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
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

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

Awesome, thanks very much.

Richard

This topic is closed to new replies.

Advertisement