Skip to content

Commit

Permalink
fix crash on call luafunction with (int,int) params
Browse files Browse the repository at this point in the history
  • Loading branch information
pangweiwei committed Jul 28, 2015
1 parent c6fd4fe commit 0f995db
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Assets/Slua/Editor/LuaCodeGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ static internal int checkDelegate(IntPtr l,int p,out $FN ua) {
Write(file, "pushValue(l,a{0});", n + 1);
}

Write(file, "ld.call({0}, error);", mi.GetParameters().Length - outindex.Count);
Write(file, "ld.pcall({0}, error);", mi.GetParameters().Length - outindex.Count);

if (mi.ReturnType != typeof(void))
WriteValueCheck(file, mi.ReturnType, 1, "ret", "error+");
Expand Down Expand Up @@ -703,7 +703,7 @@ static bool checkType(IntPtr l,int p,out UnityEngine.Events.UnityAction<$GN> ua)
{
int error = pushTry(l);
pushValue(l, v);
ld.call(1, error);
ld.pcall(1, error);
LuaDLL.lua_settop(l,error - 1);
};
ld.d = ua;
Expand Down
4 changes: 2 additions & 2 deletions Assets/Slua/Script/LuaState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public LuaFunction(IntPtr l, int r)
{
}

public bool call(int nArgs, int errfunc)
internal bool pcall(int nArgs, int errfunc)
{

if (!state.isMainThread())
Expand Down Expand Up @@ -176,7 +176,7 @@ public bool call(int nArgs, int errfunc)

bool innerCall(int nArgs, int errfunc)
{
bool ret = call(nArgs, errfunc);
bool ret = pcall(nArgs, errfunc);
LuaDLL.lua_remove(L, errfunc);
return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/Slua/Script/Timer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public static int Add(IntPtr l)
{
int error = pushTry(ml);
pushValue(ml, id);
ld.call(1, error);
ld.pcall(1, error);
LuaDLL.lua_settop(ml, error - 1);
};
}
Expand All @@ -292,7 +292,7 @@ public static int Add(IntPtr l)
{
int error = pushTry(ml);
pushValue(ml, id);
ld.call(1, error);
ld.pcall(1, error);
bool ret = LuaDLL.lua_toboolean(ml, -1);
LuaDLL.lua_settop(ml, error - 1);
return ret;
Expand Down

0 comments on commit 0f995db

Please sign in to comment.