lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Monday 22, Alexander Gladysh wrote:
> Hi, Duncan!
>
> I'm the other guy behind Lua Alchemy.
>
> > Excellent, thank you. I just did a quick test to see if coroutines work -
> > they do - do you know if it would be possible to yield across
> > ActionScript "frames", or does the whole script need to be executed
> > within a single one currently?
>
> No plans to yield across ActionScript "frames" so far. Suggestions on
> the form and on the implementation are welcome.

I ported the LuaCoco 1.1.5 patch to Alchemy.  This allows yielding across C 
calls (metamethods/pcall/iterators/callbacks) and might allow yielding across 
ActionScript "frames" (I am not sure what you mean by ActionScript "frames").

The patch is attached to this issue on the LuaAlchemy project site:
http://code.google.com/p/lua-alchemy/issues/detail?id=53

I had first tried to hack the jmp_buf used by the _setjmp/_longjmp 
implementations that Alchemy provides, but they don't have a return address 
on the fake C-stack.  Instead Alchemy has what they call Machines(these are 
just a class for each C-function).  The Machine instances are chained 
together to create the callstack.  The fake C-stack is only used for passing 
parameters.  Each Machine has a "state" member that is used to resume that 
function after a called function has return or when _longjmp is call to jump 
back to that spot.

I ended up merging the _setjmp/_longjmp ActionScript code(pulled from the code 
generated by Alchemy, I don't know what license that code falls under) into a 
single context switching function.

-- 
Robert G. Jakabosky