Skip to content

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

Description

@SimonDSA

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions