MCPcopy Create free account
hub / github.com/defold/defold / Sys_Serialize

Function Sys_Serialize

engine/script/src/script_sys.cpp:1409–1426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1407 */
1408
1409 static int Sys_Serialize(lua_State* L)
1410 {
1411 DM_LUA_STACK_CHECK(L, 1);
1412 luaL_checktype(L, 1, LUA_TTABLE);
1413
1414 uint32_t table_size = CheckTableSize(L, 1);
1415 char* buffer = Sys_SetupTableSerializationBuffer(table_size);
1416 if (!buffer)
1417 {
1418 return luaL_error(L, "Could not allocate %d bytes for table serialization.", table_size);
1419 }
1420
1421 uint32_t n_used = CheckTable(L, buffer, table_size, 1);
1422 lua_pushlstring(L, (const char*)buffer, n_used);
1423 Sys_FreeTableSerializationBuffer(buffer);
1424 return 1;
1425
1426 }
1427
1428 /*# deserializes buffer into a lua table
1429 * This function will raise a Lua error if an error occurs while deserializing the buffer.

Callers

nothing calls this directly

Calls 7

luaL_checktypeFunction · 0.85
CheckTableSizeFunction · 0.85
luaL_errorFunction · 0.85
CheckTableFunction · 0.85
lua_pushlstringFunction · 0.85

Tested by

no test coverage detected