2424#include < Mirror/Mirror.h>
2525#include < Editor/Qt/MirrorTemplateView.h>
2626
27- // TODO
28- #pragma optimize("", off)
29-
3027namespace Editor {
3128 template <typename T> struct QtJsonSerializer {};
3229 template <typename T> concept QtJsonSerializable = requires (
@@ -320,7 +317,7 @@ namespace Editor {
320317 }
321318 if (jsonObject.contains (" value" )) {
322319 const QJsonValue jsonValue = jsonObject[" value" ];
323- QtJsonSerializer<K >::QtJsonDeserialize (jsonValue, outValue.second );
320+ QtJsonSerializer<V >::QtJsonDeserialize (jsonValue, outValue.second );
324321 }
325322 }
326323 };
@@ -378,7 +375,7 @@ namespace Editor {
378375 for (const auto & jsonElement : jsonArray) {
379376 T element;
380377 QtJsonSerializer<T>::QtJsonDeserialize (jsonElement, element);
381- outValue.emplaceback (std::move (element));
378+ outValue.emplace_back (std::move (element));
382379 }
383380 }
384381 };
@@ -404,7 +401,6 @@ namespace Editor {
404401
405402 const QJsonArray jsonArray = inJsonValue.toArray ();
406403 outValue.clear ();
407- outValue.reserve (jsonArray.size ());
408404 for (const auto & jsonElement : jsonArray) {
409405 T element;
410406 QtJsonSerializer<T>::QtJsonDeserialize (jsonElement, element);
@@ -464,7 +460,6 @@ namespace Editor {
464460
465461 const QJsonArray jsonArray = inJsonValue.toArray ();
466462 outValue.clear ();
467- outValue.reserve (jsonArray.size ());
468463 for (const auto & jsonElement : jsonArray) {
469464 T element;
470465 QtJsonSerializer<T>::QtJsonDeserialize (jsonElement, element);
@@ -497,7 +492,7 @@ namespace Editor {
497492 outValue.reserve (jsonArray.size ());
498493 for (const auto & jsonPair : jsonArray) {
499494 std::pair<K, V> pair;
500- QtJsonSerializer<std::pair<K, V>>::QtJsonSerialize (jsonPair, pair);
495+ QtJsonSerializer<std::pair<K, V>>::QtJsonDeserialize (jsonPair, pair);
501496 outValue.emplace (std::move (pair));
502497 }
503498 }
@@ -524,10 +519,9 @@ namespace Editor {
524519
525520 const QJsonArray jsonArray = inJsonValue.toArray ();
526521 outValue.clear ();
527- outValue.reserve (jsonArray.size ());
528522 for (const auto & jsonPair : jsonArray) {
529523 std::pair<K, V> pair;
530- QtJsonSerializer<std::pair<K, V>>::QtJsonSerialize (jsonPair, pair);
524+ QtJsonSerializer<std::pair<K, V>>::QtJsonDeserialize (jsonPair, pair);
531525 outValue.emplace (std::move (pair));
532526 }
533527 }
@@ -553,7 +547,7 @@ namespace Editor {
553547 {
554548 (void ) std::initializer_list<int > { ([&]() -> void {
555549 const auto key = std::to_string (I);
556- const QJsonValue jsonValue = inJsonObject[key];
550+ const QJsonValue jsonValue = inJsonObject[QString::fromStdString ( key) ];
557551 if (jsonValue.isNull ()) {
558552 return ;
559553 }
@@ -623,7 +617,7 @@ namespace Editor {
623617 const QJsonValue jsonType = jsonObject[" type" ];
624618 const QJsonValue jsonContent = jsonObject[" content" ];
625619
626- uint64_t aspectIndex;
620+ uint64_t aspectIndex = 0 ;
627621 QtJsonSerializer<uint64_t >::QtJsonDeserialize (jsonType, aspectIndex);
628622 QtJsonDeserializeInternal (jsonContent, outValue, aspectIndex, std::make_index_sequence<sizeof ...(T)> {});
629623 }
@@ -652,8 +646,7 @@ namespace Editor {
652646 return ;
653647 }
654648 for (auto i = 0 ; i < L; i++) {
655- QJsonValue jsonElement;
656- QtJsonSerializer<T>::QtJsonDeserialize (jsonElement, jsonArray[i]);
649+ QtJsonSerializer<T>::QtJsonDeserialize (jsonArray[i], outValue[i]);
657650 }
658651 }
659652 };
@@ -903,7 +896,7 @@ namespace Editor {
903896 for (const auto & jsonElement : jsonArray) {
904897 T element;
905898 QtJsonSerializer<T>::QtJsonDeserialize (jsonElement, element);
906- outValue.emplaceBack (std::move (element));
899+ outValue.insert (std::move (element));
907900 }
908901 }
909902 };
@@ -1124,7 +1117,7 @@ namespace Editor {
11241117 QJsonObject jsonObject;
11251118 jsonObject[" key" ] = jsonKey;
11261119 jsonObject[" value" ] = jsonValue;
1127- outJsonValue = std::move (jsonValue );
1120+ outJsonValue = std::move (jsonObject );
11281121 }
11291122
11301123 static void DeserializeDynWithView (const QJsonValue& inJsonValue, const Mirror::StdPairView& inView)
@@ -1404,14 +1397,14 @@ namespace Editor {
14041397 return ;
14051398 }
14061399 const QJsonObject jsonObject = inJsonValue.toObject ();
1407- if (!jsonObject.contains (" type" ) || jsonObject.contains (" content" )) {
1400+ if (!jsonObject.contains (" type" ) || ! jsonObject.contains (" content" )) {
14081401 return ;
14091402 }
14101403
14111404 const QJsonValue typeJson = jsonObject[" type" ];
14121405 const QJsonValue contentJson = jsonObject[" content" ];
14131406
1414- uint64_t type;
1407+ uint64_t type = 0 ;
14151408 QtJsonSerializer<uint64_t >::QtJsonDeserialize (typeJson, type);
14161409
14171410 Mirror::Any tempObj = inView.CreateElement (type);
0 commit comments