Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I work on a returning pointer in Lua? #139

Open
SimonDSA opened this issue Jul 5, 2017 · 1 comment
Open

How do I work on a returning pointer in Lua? #139

SimonDSA opened this issue Jul 5, 2017 · 1 comment

Comments

@SimonDSA
Copy link

SimonDSA commented Jul 5, 2017

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!

@SteveKChiu
Copy link
Owner

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants