Skip to content

Commit

Permalink
banan
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrinneal committed Aug 3, 2023
1 parent 7a1ee01 commit cab52fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions packages/pigeon/lib/cpp_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1220,8 +1220,9 @@ return EncodableValue(EncodableList{
}
final String extractedValue =
'${enumPrefix}std::move(output).TakeValue()';
final String wrapperType =
hostType.isBuiltin ? 'EncodableValue' : 'CustomEncodableValue';
final String wrapperType = hostType.isBuiltin || isEnum(root, returnType)
? 'EncodableValue'
: 'CustomEncodableValue';
if (returnType.isNullable) {
// The value is a std::optional, so needs an extra layer of
// handling.
Expand Down Expand Up @@ -1362,7 +1363,7 @@ ${prefix}reply(EncodableValue(std::move(wrapped)));''';
'const auto& $argName = std::get<${hostType.datatype}>($encodableArgName);');
} else if (hostType.isEnum) {
indent.writeln(
'const ${hostType.datatype}& $argName = (${hostType.datatype})((int32_t)$encodableArgName);');
'const ${hostType.datatype}& $argName = (${hostType.datatype})$encodableArgName.LongValue();');
} else {
indent.writeln(
'const auto& $argName = std::any_cast<const ${hostType.datatype}&>(std::get<CustomEncodableValue>($encodableArgName));');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1225,15 +1225,15 @@ void HostIntegrationCoreApi::SetUp(flutter::BinaryMessenger* binary_messenger,
return;
}
const AnEnum& an_enum_arg =
(AnEnum)((int32_t)encodable_an_enum_arg);
(AnEnum)encodable_an_enum_arg.LongValue();
ErrorOr<AnEnum> output = api->EchoEnum(an_enum_arg);
if (output.has_error()) {
reply(WrapError(output.error()));
return;
}
EncodableList wrapped;
wrapped.push_back(
CustomEncodableValue((int)std::move(output).TakeValue()));
EncodableValue((int)std::move(output).TakeValue()));
reply(EncodableValue(std::move(wrapped)));
} catch (const std::exception& exception) {
reply(WrapError(exception.what()));
Expand Down

0 comments on commit cab52fc

Please sign in to comment.