lua-users home
lua-l archive

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

Dirk Feytons wrote:

In other words: I would like the clean and simple iterator-style Lua
code but make full use of the 'streaming' behavior of the C library.
This means that in the end I need to be able to transfer the data that
I receive in that callback to Lua somehow. However PiL2 is quite
clear: you can only yield from C when it is called from Lua and the C
function ends with 'return lua_yield(L, nres);' which ofcourse doesn't
match the interface of the library.

Check out Coco, a true C-coroutines patch for Lua. It involves patching the actual Lua source, but it's worked well for me so far when I've done similar tasks to what you're trying to do.

I think this will help with what you're trying to do. Please ignore me if I am wrong. :-)
"* Yield from C functions and resume back to them."