lua-intf
lua-intf copied to clipboard
How do I work on a returning pointer in Lua?
I'm binding a method, that returns a pointer to an object. I have to call a function on this object in Lua. Is it possible to work with the pointer like the way you do it in C++? pointer->getSomething()
Or can I specify the return type of the method, so that it returns the object itself directly instead of the pointer?
I tried this in Lua:
pointer = SomeObject:getInstance()
pointer.getSomething()
But the Lua output is this:
expected userdata, got no value
If I print the pointer, it says:
userdata: 0x7f5d38003da8
The binding of the C++-Object:
LuaIntf::LuaBinding(state).beginClass<SomeObject>("SomeObject")
.addStaticFunction("getInstance", &SomeObject::getInstance)
.addFunction("getSomething", &SomeObject::getSomething)
Thanks!
pointer = SomeObject.getInstance() pointer:getSomething()
should work, '.' for static, ':' for memory