MCPcopy Create free account
hub / github.com/MonaSolutions/MonaServer / Serialize

Method Serialize

MonaServer/sources/LUAPersistentTable.cpp:126–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126const UInt8* LUAPersistentTable::Serialize(lua_State* pState, int index, UInt32& size) {
127 // value to stringize is in the top
128 switch (lua_type(pState, index)) {
129 case LUA_TLIGHTUSERDATA:
130 case LUA_TFUNCTION:
131 case LUA_TUSERDATA:
132 case LUA_TTHREAD:
133 case LUA_TTABLE: {
134 string pointer;
135 String::Format(pointer, lua_topointer(pState, index));
136 size = pointer.size();
137 return (const UInt8*)pointer.c_str();
138 }
139 case LUA_TBOOLEAN: {
140 bool value = lua_toboolean(pState, index) ? true : false;
141 if (value) {
142 size = 4;
143 return (const UInt8*)"true";
144 }
145 size = 5;
146 return (const UInt8*)"false";
147 }
148 case LUA_TNIL:
149 size = 3;
150 return (const UInt8*)"null";
151 default:
152 size = lua_objlen(pState, index);
153 return (const UInt8*)lua_tostring(pState, index);
154 }
155}

Callers

nothing calls this directly

Calls 2

FormatClass · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected