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

Function lua_save_data_push_sjson_object

src/lua/lua_api.cpp:771–860  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

769}
770
771static bool lua_save_data_push_sjson_object(lua_State *L, const char *value, bool &error, bool force_regular)
772{
773 const int top = lua_gettop(L);
774 LuaStack stack(L, INT_MAX);
775 TempAllocator4096 ta;
776 JsonObject obj(ta);
777 sjson::parse(obj, value);
778 if (error) {
779 lua_settop(L, top);
780 return false;
781 }
782
783 if (!force_regular) {
784 DynamicString type(ta);
785 if (lua_save_data_parse_typed_object(type, obj, error)) {
786 if (type == "table") {
787 if (!lua_save_data_push_sjson_object(L, obj["data"], error, true)) {
788 lua_settop(L, top);
789 return false;
790 }
791 return true;
792 }
793
794 JsonArray arr(ta);
795 sjson::parse_array(arr, obj["data"]);
796 if (error) {
797 lua_settop(L, top);
798 return false;
799 }
800
801 if (type == "vector3" || type == "vector3box") {
802 if (array::size(arr) != 3) {
803 error = true;
804 lua_settop(L, top);
805 return false;
806 }
807
808 Vector3 v = sjson::parse_vector3(obj["data"]);
809 if (error) {
810 lua_settop(L, top);
811 return false;
812 }
813
814 if (type == "vector3")
815 stack.push_vector3(v);
816 else
817 stack.push_vector3box(v);
818 return true;
819 } else if (type == "matrix4x4" || type == "matrix4x4box") {
820 if (array::size(arr) != 16) {
821 error = true;
822 lua_settop(L, top);
823 return false;
824 }
825
826 Matrix4x4 m = sjson::parse_matrix4x4(obj["data"]);
827 if (error) {
828 lua_settop(L, top);

Callers 2

lua_save_data_push_tableFunction · 0.85

Calls 15

parse_vector3Function · 0.85
parse_matrix4x4Function · 0.85
push_vector3Method · 0.80
push_matrix4x4Method · 0.80
lua_gettopFunction · 0.50
parseFunction · 0.50
lua_settopFunction · 0.50
parse_arrayFunction · 0.50
sizeFunction · 0.50
beginFunction · 0.50

Tested by

no test coverage detected