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

Function OutputJsonProperty

engine/engine/src/engine_service.cpp:737–781  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

735 }
736
737 static void OutputJsonProperty(dmGameObject::SceneNodeProperty* property, dmWebServer::Request* request, int indent)
738 {
739 SendIndent(request, indent);
740 SendText(request, "\"");
741 SendText(request, dmHashReverseSafe64(property->m_NameHash));
742 SendText(request, "\": ");
743
744 char buffer[512];
745 buffer[0] = 0;
746
747 switch(property->m_Type)
748 {
749 case dmGameObject::SCENE_NODE_PROPERTY_TYPE_HASH:
750 {
751 const char* rev_hash = (const char*)dmHashReverse64(property->m_Value.m_Hash, 0);
752 if (rev_hash)
753 dmSnPrintf(buffer, sizeof(buffer), "\"%s\"", rev_hash);
754 else
755 dmSnPrintf(buffer, sizeof(buffer), "\"0x%016llX\"", (unsigned long long)property->m_Value.m_Hash);
756 }
757 break;
758 case dmGameObject::SCENE_NODE_PROPERTY_TYPE_NUMBER: dmSnPrintf(buffer, sizeof(buffer), "%f", JsonSafeFloat(property->m_Value.m_Number)); break;
759 case dmGameObject::SCENE_NODE_PROPERTY_TYPE_BOOLEAN: dmSnPrintf(buffer, sizeof(buffer), "%d", property->m_Value.m_Bool?1:0); break;
760 case dmGameObject::SCENE_NODE_PROPERTY_TYPE_VECTOR3: dmSnPrintf(buffer, sizeof(buffer), "[%f, %f, %f]",
761 JsonSafeFloat(property->m_Value.m_V4[0]),
762 JsonSafeFloat(property->m_Value.m_V4[1]),
763 JsonSafeFloat(property->m_Value.m_V4[2]));
764 break;
765 case dmGameObject::SCENE_NODE_PROPERTY_TYPE_VECTOR4:
766 case dmGameObject::SCENE_NODE_PROPERTY_TYPE_QUAT: dmSnPrintf(buffer, sizeof(buffer), "[%f, %f, %f, %f]",
767 JsonSafeFloat(property->m_Value.m_V4[0]),
768 JsonSafeFloat(property->m_Value.m_V4[1]),
769 JsonSafeFloat(property->m_Value.m_V4[2]),
770 JsonSafeFloat(property->m_Value.m_V4[3]));
771 break;
772 case dmGameObject::SCENE_NODE_PROPERTY_TYPE_URL: dmSnPrintf(buffer, sizeof(buffer), "\"%s\"", property->m_Value.m_URL); break;
773 case dmGameObject::SCENE_NODE_PROPERTY_TYPE_TEXT: SendJsonEscapedText(request, property->m_Value.m_Text); break;
774 default: break;
775 }
776
777 if (buffer[0] != 0)
778 {
779 SendText(request, buffer);
780 }
781 }
782
783 static void OutputJsonSceneGraph(dmGameObject::SceneNode* node, dmWebServer::Request* request, int indent)
784 {

Callers 1

OutputJsonSceneGraphFunction · 0.85

Calls 7

SendIndentFunction · 0.85
SendTextFunction · 0.85
dmHashReverseSafe64Function · 0.85
dmHashReverse64Function · 0.85
dmSnPrintfFunction · 0.85
JsonSafeFloatFunction · 0.85
SendJsonEscapedTextFunction · 0.85

Tested by

no test coverage detected