Darn! ;)
The problem I'm trying to solve involves using the asIScriptContext::Suspend() and asIScriptContext::Execute() to do external operations in our single-threaded environment.
Unfortunately, when I call asIScriptContext::Execute() I need it to return before the rest of our system can continue processing. And using asIScriptContext::Suspend(), I can make this happen. However, we have an existing code base that uses something like:
uint x;x = tcon.read(0x1234, 0x4567);
In the older system, tcon was registered as a global property of type CTcon. And tcon.read() was a registered method. Our older system could perform all the operations in the external method. So asIScriptContext::Execute() would never need to return.
However, the new system cannot do those operations within the externally registered methods. They have to happen independently of asIScriptContext::Execute(). My idea was to have asIScriptContext::Execute() return. When it returns, the caller examines some data store to determine why asIScriptContext::Execute() returned and then do whatever tasks are necessary. So when tcon.read() is called, it saves off the necessary information then calls asIScriptContext::Suspend().
The problem is that calling asIScriptContext::Suspend() will (I think) complete the current AngelScript line and suspend after that line. So now I have to split the operation into two operations, i.e.:
uint x;tcon.start_read(0x1234, 0x4567); // asIScriptContext::Suspend() called herex = tcon.end_read();
Which is fine--except for the existing code base that is used to tcon.read() in a single operation. So I thought perhaps I could add something with asIScriptEngine::AddScriptSection() that would define tcon.read() to look like:
uint tcon.read(uint req, uint addr){ tcon.start_read(req, addr); return tcon.end_read();}
Which keeps the old code compatible.
Does what I'm doing make sense? Any other suggestions? Or am I stuck changing the old code?