Closed DominikMS closed 10 years ago
I have to admit, the std::function support hasn't been widely tested. I'll try and look at this today.
Oh, and can you give me your actual C++/lua code that triggers that?
class ClassA {
public:
ClassA()
{
m_str = "default";
}
ClassA(std::string str)
{
m_str = str;
}
~ClassA()
{
}
bool test()
{
std::cout << "ClassA->test() : " << m_str << std::endl;
return true;
}
void testFunc(std::function<void(int)> f)
{
std::cout << "[testFunc]" << std::endl;
f(5);
}
private:
std::string m_str;
};
int main(int argc, char *argv[])
{
LuaGlue state;
state.
Class<ClassA>("ClassA").
ctor<std::string>("new").
method("test", &ClassA::test).
method("testFunc", &ClassA::testFunc).
end();
state.open().glue();
if(!state.doFile("script.lua"))
std::cout << "failed to dofile [script.lua]: " << state.lastError() << std::endl;
Sleep(1000 * 100);
return 0;
}
local A = ClassA:new("in lua")
A:test()
A:testFunc(function(x) print("hello std::function: ".. x) return "called" end)
I believe this one is fixed. If it isn't, please reopen.
Works only void. Engine is crashed.