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

Fix index of calling function argument in lua #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Riyaaaaa
Copy link

Overview

Fixed a bug that the argument becomes illegal when binding SetObj to a member function with argument to lua.

Testcode

struct Foo {
void hoge(int a){}
}

sel::State state;
Foo foo;
state["foo"].SetObj(foo, "hoge", &Foo::hoge);
state("foo:hoge(1)"); // not works

output

[string "foo:hoge(1)"]:1: calling 'hoge' on bad self (number expected, got table),

Cause

_get_args function access sequentially from the bottom of the stack. So, the first argument is assigned 1 for index, but if SetObj is used, table 1 is allocated to index 1 instead of argument. As a result, _check_get function throws GetParameterFromLuaTypeError.

Solution

Access the stack from the top.

@rasikhq
Copy link

rasikhq commented Apr 17, 2020

I had a similar issue, tried your changes but it still didn't work

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

Successfully merging this pull request may close these issues.

2 participants