Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

script context and nested calls (PushState/PopState)


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
4 replies to this topic

#1 iraxef   Members   -  Reputation: 352

Like
0Likes
Like

Posted 18 December 2013 - 09:04 PM

What are the expected uses of PushState/PopState on a script context?

 

One gotcha I'm thinking of is what if the script function you called via a nested-context-call suspends itself.. would that not also suspend the execution of the 'outer' function (which might be unexpected/undesirable)?

 

If you call the same script function (as the one that reached out to C++ and got it to make a nested call back into script).. it will have a different local stack/state than the 'outer' script function, due to the nested call, right?

 

Thank you very much.



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3361

Like
0Likes
Like

Posted 19 December 2013 - 08:29 AM

The use for Push/PopState is exactly how you imagine it. When a script calls an application function that needs to call another script function you can reuse the active context rather than create a new one. After calling PushState() the context can be used exactly like a newly created context, i.e. you'd call Prepare(), SetArg...() and Execute() to make a call to the new function.

 

When the context is suspended only the inner-most execution is suspended. The outer execution will only be suspended if the application first calls PopState() and then Suspend() again.


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 iraxef   Members   -  Reputation: 352

Like
0Likes
Like

Posted 19 December 2013 - 10:28 AM

Thanks. Once you've PushState(), the outer execution isn't continuing to run though, is it?



#4 Andreas Jonsson   Moderators   -  Reputation: 3361

Like
0Likes
Like

Posted 19 December 2013 - 11:43 AM

The outer execution will only continue once the PopState() is called.

 

Remember that normally Push/PopState() is called from a function called by the context, so the application call stack will look something like this:

 

application::DoProcessing
  asCScriptContext::Execute                    <-- outer execution
    application::RegisteredFunction          <-- application registered function that called PushState
      asCScriptContext::Execute                <-- inner execution

 

The outer execution can only continue after the application registered function returns.

 

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

#5 iraxef   Members   -  Reputation: 352

Like
0Likes
Like

Posted 19 December 2013 - 12:47 PM

Thank you.






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