BindingsGenerator: Release value setting members of dictionary

When a constructor has an optional dictionary as argument, and those
members are of type new string, make sure that we release_value()
setting the dictionary members.
This commit is contained in:
Kenneth Myhra 2023-02-23 12:22:33 +01:00 committed by Sam Atkins
parent 98ef76b144
commit 836cb73d29
Notes: sideshowbarker 2024-07-17 00:37:23 +09:00

View file

@ -729,9 +729,16 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
}
generate_to_cpp(dictionary_generator, member, member_property_value_name, "", member_value_name, interface, member.extended_attributes.contains("LegacyNullToEmptyString"), !member.required, member.default_value);
dictionary_generator.append(R"~~~(
if (optional && interface.extended_attributes.contains("UseNewAKString")) {
dictionary_generator.append(R"~~~(
if (@member_value_name@.has_value())
@cpp_name@.@member_name@ = @member_value_name@.release_value();
)~~~");
} else {
dictionary_generator.append(R"~~~(
@cpp_name@.@member_name@ = @member_value_name@;
)~~~");
}
if (!member.required && !member.default_value.has_value()) {
dictionary_generator.append(R"~~~(
}