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

Method pushPrimitive

Assets/XLua/Src/ObjectTranslator.cs:1085–1127  ·  view source on GitHub ↗
(RealStatePtr L, object o)

Source from the content-addressed store, hash-verified

1083 }
1084
1085 void pushPrimitive(RealStatePtr L, object o)
1086 {
1087 if (o is sbyte || o is byte || o is short || o is ushort ||
1088 o is int)
1089 {
1090 int i = Convert.ToInt32(o);
1091 LuaAPI.xlua_pushinteger(L, i);
1092 }
1093 else if (o is uint)
1094 {
1095 LuaAPI.xlua_pushuint(L, (uint)o);
1096 }
1097 else if (o is float || o is double)
1098 {
1099 double d = Convert.ToDouble(o);
1100 LuaAPI.lua_pushnumber(L, d);
1101 }
1102 else if (o is IntPtr)
1103 {
1104 LuaAPI.lua_pushlightuserdata(L, (IntPtr)o);
1105 }
1106 else if (o is char)
1107 {
1108 LuaAPI.xlua_pushinteger(L, (char)o);
1109 }
1110 else if (o is long)
1111 {
1112 LuaAPI.lua_pushint64(L, Convert.ToInt64(o));
1113 }
1114 else if (o is ulong)
1115 {
1116 LuaAPI.lua_pushuint64(L, Convert.ToUInt64(o));
1117 }
1118 else if (o is bool)
1119 {
1120 bool b = (bool)o;
1121 LuaAPI.lua_pushboolean(L, b);
1122 }
1123 else
1124 {
1125 throw new Exception("No support type " + o.GetType());
1126 }
1127 }
1128
1129 public void PushAny(RealStatePtr L, object o)
1130 {

Callers

nothing calls this directly

Calls 7

xlua_pushintegerMethod · 0.80
xlua_pushuintMethod · 0.80
lua_pushnumberMethod · 0.80
lua_pushlightuserdataMethod · 0.80
lua_pushint64Method · 0.80
lua_pushuint64Method · 0.80
lua_pushbooleanMethod · 0.80

Tested by

no test coverage detected