[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: "attempt to yield across metamethod/C-call boundary" with LuaJIT but not with Lua
- From: Patrick Rapin <toupie300@...>
- Date: Sun, 16 Oct 2011 10:40:43 +0200
Side note. I tried to compile your example. It was not easy because I
had to install both luabind and the huge Boost++ library.
For the matter of comparison, I tried to port that code to my
LuaClassBasedCall binding (a single header file).
I realized that unlike luabind, my library has no special support for
coroutines, so it was easier to create / resume the coroutine in Lua
language.
Still the resulting code is shorter, and IMHO easier to understand...
#include <iostream>
#include <lgencall.hpp>
using namespace std;
using namespace lua;
int func(lua_State* L)
{
cout << "c func" << endl;
return lua_yield(L, 0);
}
int main()
{
Lua<> L;
const char* error = L.PCall(
"local func = ...\n"
"function funcWrap() func(); print('resumed') end\n"
"coro = coroutine.create(funcWrap)\n"
"coroutine.resume(coro)", Input(func));
if(error)
cout << error << endl;
cin.get();
}