lua-intf icon indicating copy to clipboard operation
lua-intf copied to clipboard

How do I work on a returning pointer in Lua?

Open SimonDSA opened this issue 7 years ago • 1 comments

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!

SimonDSA avatar Jul 05 '17 14:07 SimonDSA

pointer = SomeObject.getInstance() pointer:getSomething()

should work, '.' for static, ':' for memory

SteveKChiu avatar Aug 25 '17 02:08 SteveKChiu