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

genNullableCaster最后一个参数为nil,其余参数都为nil #527

Closed
rebelmx4 opened this issue Jan 16, 2019 · 0 comments
Closed

genNullableCaster最后一个参数为nil,其余参数都为nil #527

rebelmx4 opened this issue Jan 16, 2019 · 0 comments

Comments

@rebelmx4
Copy link
Contributor

rebelmx4 commented Jan 16, 2019

错误:
c#:

public static void aaa(int? a, int? b, int? c, int? d)
{
    Debug.log(a);
    Debug.log(b);
    Debug.log(c);
    Debug.log(d);
}

lua:

aaa(1, 2, 3, nil)

如果最后一个参数为nil,a,b,c都为空

改法:

ObjectCast genNullableCaster(ObjectCast oc)
{
      return (RealStatePtr L, int idx, object target) =>
      {
          if (LuaAPI.lua_isnil(L, -1))
          {
               return null;
           }
           else
           {
               return oc(L, idx, target);
            }
         };
 }

将-1改为idx

onlyfeng added a commit to onlyfeng/xLua that referenced this issue Jan 21, 2019
* upstream/master:
  genNullableCaster 最后一个参数是nil,其他参数全是nil (fix Tencent#527)
  去掉多余的包装接口,加入宏用以开关 (Tencent#522)
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

No branches or pull requests

1 participant