| 40 | |
| 41 | template<class T> |
| 42 | void FromV8(CefV8Value& v8, T& out) |
| 43 | { |
| 44 | if constexpr (HasCustomFromV8<T>) { |
| 45 | CustomV8Conversion<T>::FromV8(v8, out); |
| 46 | } |
| 47 | else if constexpr (IsContainer<std::optional, T>) { |
| 48 | if (v8.IsNull()) { |
| 49 | out.reset(); |
| 50 | } |
| 51 | else { |
| 52 | out.emplace(); |
| 53 | FromV8(v8, *out); |
| 54 | } |
| 55 | } |
| 56 | else if constexpr (std::same_as<std::string, T>) { |
| 57 | out = v8.GetStringValue(); |
| 58 | } |
| 59 | else if constexpr (std::same_as<bool, T>) { |
| 60 | out = v8.GetBoolValue(); |
| 61 | } |
| 62 | else if constexpr (IsContainer<std::vector, T>) { |
| 63 | out.clear(); |
| 64 | for (int i = 0; i < v8.GetArrayLength(); i++) { |
| 65 | out.emplace_back(); |
| 66 | FromV8(*v8.GetValue(i), out.back()); |
| 67 | } |
| 68 | } |
| 69 | else if constexpr (IsStdArray<T>) { |
| 70 | for (int i = 0; i < v8.GetArrayLength(); i++) { |
| 71 | FromV8(*v8.GetValue(i), out[i]); |
| 72 | } |
| 73 | } |
| 74 | else if constexpr (std::is_floating_point_v<T>) { |
| 75 | out = T(v8.GetDoubleValue()); |
| 76 | } |
| 77 | else if constexpr (std::is_integral_v<T>) { |
| 78 | if (v8.IsUInt()) { |
| 79 | out = T(v8.GetUIntValue()); |
| 80 | } |
| 81 | else { |
| 82 | out = T(v8.GetIntValue()); |
| 83 | } |
| 84 | } |
| 85 | else if constexpr (std::is_enum_v<T>) { |
| 86 | int keyVal = 0; |
| 87 | FromV8(v8, keyVal); |
| 88 | out = T(keyVal); |
| 89 | } |
| 90 | else if constexpr (std::is_class_v<T>) { |
| 91 | refl::for_each([&](const auto I) { |
| 92 | FromV8(*v8.GetValue(ToCefString(refl::member_name<I>(out))), refl::get<I>(out)); |
| 93 | }, out); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | template<class T> |
| 98 | T FromV8(CefV8Value& v8) |
no test coverage detected