MCPcopy Create free account
hub / github.com/crownengine/crown / lua_save_data_push_sjson_value

Function lua_save_data_push_sjson_value

src/lua/lua_api.cpp:862–928  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

860}
861
862static bool lua_save_data_push_sjson_value(lua_State *L, const char *value, bool &error)
863{
864 const int top = lua_gettop(L);
865 LuaStack stack(L, INT_MAX);
866
867 switch (sjson::type(value)) {
868 case JsonValueType::NIL:
869 stack.push_nil();
870 break;
871
872 case JsonValueType::BOOL: {
873 const bool val = sjson::parse_bool(value);
874 if (error) {
875 lua_settop(L, top);
876 return false;
877 }
878 stack.push_bool(val);
879 return true;
880 }
881
882 case JsonValueType::NUMBER: {
883 const f32 val = sjson::parse_float(value);
884 if (error) {
885 lua_settop(L, top);
886 return false;
887 }
888 stack.push_float(val);
889 return true;
890 }
891
892 case JsonValueType::STRING: {
893 TempAllocator1024 ta;
894 DynamicString str(ta);
895 sjson::parse_string(str, value);
896 if (error) {
897 lua_settop(L, top);
898 return false;
899 }
900 stack.push_lstring(str.c_str(), str.length());
901 break;
902 }
903
904 case JsonValueType::ARRAY:
905 if (!lua_save_data_push_sjson_array(L, value, error)) {
906 lua_settop(L, top);
907 return false;
908 }
909 return true;
910
911 case JsonValueType::OBJECT:
912 if (!lua_save_data_push_sjson_object(L, value, error, false)) {
913 lua_settop(L, top);
914 return false;
915 }
916 return true;
917
918 default:
919 stack.push_nil();

Callers 2

Calls 10

lua_gettopFunction · 0.50
typeFunction · 0.50
parse_boolFunction · 0.50
lua_settopFunction · 0.50
parse_floatFunction · 0.50
parse_stringFunction · 0.50
c_strMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected