Skip to content

Commit fbb6d6a

Browse files
authored
修复使用RawObject处理byte[]作为函数参数时,byte[]为null的问题,ps: 在lua侧调用FileStream.Read(byte[] buffer, int offset, int length)接口 (#917)
1 parent eda20c8 commit fbb6d6a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Assets/XLua/Src/ObjectCasters.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,12 @@ private static object getString(RealStatePtr L, int idx, object target)
314314

315315
private object getBytes(RealStatePtr L, int idx, object target)
316316
{
317-
return LuaAPI.lua_type(L, idx) == LuaTypes.LUA_TSTRING ? LuaAPI.lua_tobytes(L, idx) : translator.SafeGetCSObj(L, idx) as byte[];
317+
if(LuaAPI.lua_type(L, idx) == LuaTypes.LUA_TSTRING)
318+
{
319+
return LuaAPI.lua_tobytes(L, idx);
320+
}
321+
object obj = translator.SafeGetCSObj(L, idx);
322+
return (obj is RawObject) ? (obj as RawObject).Target : obj as byte[];
318323
}
319324

320325
private object getIntptr(RealStatePtr L, int idx, object target)

0 commit comments

Comments
 (0)