MCPcopy Create free account
hub / github.com/Tencent/xLua / TryPrimitiveArraySet

Function TryPrimitiveArraySet

Assets/XLua/Src/StaticLuaCallbacks.cs:390–491  ·  view source on GitHub ↗
(Type type, RealStatePtr L, object obj, int array_idx, int obj_idx)

Source from the content-addressed store, hash-verified

388
389
390 public static bool TryPrimitiveArraySet(Type type, RealStatePtr L, object obj, int array_idx, int obj_idx)
391 {
392 bool ok = true;
393
394 LuaTypes lua_type = LuaAPI.lua_type(L, obj_idx);
395
396 if (type == typeof(int[]) && lua_type == LuaTypes.LUA_TNUMBER)
397 {
398 int[] array = obj as int[];
399 array[array_idx] = LuaAPI.xlua_tointeger(L, obj_idx);
400 }
401 else if (type == typeof(float[]) && lua_type == LuaTypes.LUA_TNUMBER)
402 {
403 float[] array = obj as float[];
404 array[array_idx] = (float)LuaAPI.lua_tonumber(L, obj_idx);
405 }
406 else if (type == typeof(double[]) && lua_type == LuaTypes.LUA_TNUMBER)
407 {
408 double[] array = obj as double[];
409 array[array_idx] = LuaAPI.lua_tonumber(L, obj_idx); ;
410 }
411 else if (type == typeof(bool[]) && lua_type == LuaTypes.LUA_TBOOLEAN)
412 {
413 bool[] array = obj as bool[];
414 array[array_idx] = LuaAPI.lua_toboolean(L, obj_idx);
415 }
416 else if (type == typeof(long[]) && LuaAPI.lua_isint64(L, obj_idx))
417 {
418 long[] array = obj as long[];
419 array[array_idx] = LuaAPI.lua_toint64(L, obj_idx);
420 }
421 else if (type == typeof(ulong[]) && LuaAPI.lua_isuint64(L, obj_idx))
422 {
423 ulong[] array = obj as ulong[];
424 array[array_idx] = LuaAPI.lua_touint64(L, obj_idx);
425 }
426 else if (type == typeof(sbyte[]) && lua_type == LuaTypes.LUA_TNUMBER)
427 {
428 sbyte[] array = obj as sbyte[];
429 array[array_idx] = (sbyte)LuaAPI.xlua_tointeger(L, obj_idx);
430 }
431 else if (type == typeof(short[]) && lua_type == LuaTypes.LUA_TNUMBER)
432 {
433 short[] array = obj as short[];
434 array[array_idx] = (short)LuaAPI.xlua_tointeger(L, obj_idx);
435 }
436 else if (type == typeof(ushort[]) && lua_type == LuaTypes.LUA_TNUMBER)
437 {
438 ushort[] array = obj as ushort[];
439 array[array_idx] = (ushort)LuaAPI.xlua_tointeger(L, obj_idx);
440 }
441 else if (type == typeof(char[]) && lua_type == LuaTypes.LUA_TNUMBER)
442 {
443 char[] array = obj as char[];
444 array[array_idx] = (char)LuaAPI.xlua_tointeger(L, obj_idx);
445 }
446 else if (type == typeof(uint[]) && lua_type == LuaTypes.LUA_TNUMBER)
447 {

Callers 1

ArrayNewIndexerFunction · 0.85

Calls 14

lua_typeMethod · 0.80
xlua_tointegerMethod · 0.80
lua_tonumberMethod · 0.80
lua_tobooleanMethod · 0.80
lua_isint64Method · 0.80
lua_toint64Method · 0.80
lua_isuint64Method · 0.80
lua_touint64Method · 0.80
xlua_touintMethod · 0.80
lua_touserdataMethod · 0.80
FindMethod · 0.80
IsDecimalMethod · 0.80

Tested by

no test coverage detected