diff --git a/api/sixtyfps-cpp/include/sixtyfps_interpreter.h b/api/sixtyfps-cpp/include/sixtyfps_interpreter.h index 4cedc2602..c31b8a2bd 100644 --- a/api/sixtyfps-cpp/include/sixtyfps_interpreter.h +++ b/api/sixtyfps-cpp/include/sixtyfps_interpreter.h @@ -185,13 +185,10 @@ public: Type type() const { return cbindgen_private::sixtyfps_interpreter_value_type(&inner); } - // internal - Value(const sixtyfps::cbindgen_private::ValueOpaque &inner) : inner(inner) { } - private: using ValueOpaque = sixtyfps::cbindgen_private::ValueOpaque; ValueOpaque inner; - friend class Struct; + friend struct Struct; }; inline Value::Value(const sixtyfps::SharedVector &array) @@ -273,7 +270,7 @@ inline std::optional Struct::get_field(std::string_view name) const name.size() }; if (auto *value = cbindgen_private::sixtyfps_interpreter_struct_get_field(&inner, name_view)) { - return *value; + return *reinterpret_cast(value); } else { return {}; } @@ -287,4 +284,4 @@ inline void Struct::set_field(std::string_view name, const Value &value) cbindgen_private::sixtyfps_interpreter_struct_set_field(&inner, name_view, &value.inner); } -} \ No newline at end of file +} diff --git a/api/sixtyfps-cpp/tests/tests.cpp b/api/sixtyfps-cpp/tests/tests.cpp index a09fd4bfc..a87a936d2 100644 --- a/api/sixtyfps-cpp/tests/tests.cpp +++ b/api/sixtyfps-cpp/tests/tests.cpp @@ -164,11 +164,12 @@ SCENARIO("Struct API") REQUIRE(!struc.get_field("not_there")); - struc.set_field("field_a", Value(true)); + struc.set_field("field_a", Value(sixtyfps::SharedString("Hallo"))); auto value_opt = struc.get_field("field_a"); REQUIRE(value_opt.has_value()); auto value = value_opt.value(); - REQUIRE(value.to_bool().has_value()); - REQUIRE(value.to_bool().value() == true); -} \ No newline at end of file + REQUIRE(value.to_string().has_value()); + REQUIRE(value.to_string().value() == "Hallo"); + +}