Skip to content

Fix index of calling function argument in lua#179

Open
Riyaaaaa wants to merge 1 commit intojeremyong:masterfrom
Riyaaaaa:master
Open

Fix index of calling function argument in lua#179
Riyaaaaa wants to merge 1 commit intojeremyong:masterfrom
Riyaaaaa:master

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