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

LuaClass fails to handle some constructor cases #75

Closed
SirLynix opened this issue Oct 3, 2016 · 0 comments
Closed

LuaClass fails to handle some constructor cases #75

SirLynix opened this issue Oct 3, 2016 · 0 comments
Assignees
Labels
Milestone

Comments

@SirLynix
Copy link
Contributor

SirLynix commented Oct 3, 2016

When constructing an object, that (empty) object is pushed on the Lua stack before the constructor function is called.

    template<class T>
    int LuaClass<T>::ConstructorProxy(lua_State* state)
    {
        LuaInstance& lua = *LuaInstance::GetInstance(state);

        std::shared_ptr<ClassInfo>& info = *static_cast<std::shared_ptr<ClassInfo>*>(lua.ToUserdata(lua.GetIndexOfUpValue(1)));
        const ConstructorFunc& constructor = info->constructor;

        lua.Remove(1); // On enlève l'argument "table" du stack

        T* instance = static_cast<T*>(lua.PushUserdata(sizeof(T))); //<<<<<< HERE

        if (!constructor(lua, instance))

which induce an extra parameter of type "userdata" on every constructor.

@SirLynix SirLynix added the Bug label Oct 3, 2016
@SirLynix SirLynix added this to the 0.1.1 milestone Oct 3, 2016
@SirLynix SirLynix self-assigned this Oct 3, 2016
SirLynix added a commit that referenced this issue Oct 11, 2016
Former-commit-id: 3a0e60a6e7ec7c85ff5f179cc84a468d8c0682f4 [formerly f0712658e69c7ced1fa46f8878f96776d6b36567] [formerly 3035b072473d17863c3c0f6950451ccf582c107e [formerly 578791c]]
Former-commit-id: df8812d712d28efc2bc83258df53dcb21bbb4b2d [formerly 6d2d8773c96d406690bd5cfc19cef7d1706ff6fc]
Former-commit-id: 461fec0cc2dd99690a3de10436730514712beb73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant