Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
nits
  • Loading branch information
tarrinneal committed Jul 10, 2023
commit fb5c6cb547ec180ee37d8c3d22e30c035983b130
4 changes: 2 additions & 2 deletions packages/pigeon/lib/cpp_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,8 @@ class CppSourceGenerator extends StructuredGenerator<CppOptions> {
return '(${field.type.baseName})(std::get<int32_t>($encodable))';
} else if (field.type.baseName == 'int') {
return '$encodable.LongValue()';
} else if (field.type.baseName == 'Object') {
return encodable;
} else {
final HostDatatype hostDatatype = getFieldHostDatatype(field,
root.classes, root.enums, _shortBaseCppTypeForBuiltinDartType);
Expand All @@ -669,8 +671,6 @@ class CppSourceGenerator extends StructuredGenerator<CppOptions> {
.map((Class x) => x.name)
.contains(field.type.baseName)) {
return '${hostDatatype.datatype}::FromEncodableList(std::get<EncodableList>($encodable))';
} else if (field.type.baseName == 'Object') {
return encodable;
} else {
return 'std::get<${hostDatatype.datatype}>($encodable)';
}
Expand Down
6 changes: 3 additions & 3 deletions packages/pigeon/lib/dart_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class DartGenerator extends StructuredGenerator<DartOptions> {
) {
void writeValueDecode(NamedType field, int index) {
final String resultAt = 'result[$index]';
String castCallPrefix = field.type.isNullable ? '?' : '!';
final String castCallPrefix = field.type.isNullable ? '?' : '!';
final String genericType = _makeGenericTypeArguments(field.type);
final String castCall = _makeGenericCastCall(field.type);
final String nullableTag = field.type.isNullable ? '?' : '';
Expand Down Expand Up @@ -235,13 +235,13 @@ $resultAt != null
'($resultAt as $genericType?)$castCallPrefix$castCall',
);
} else {
castCallPrefix = field.type.isNullable ? '' : '!';
final String castCallForcePrefix = field.type.isNullable ? '' : '!';
final String castString = field.type.baseName == 'Object'
? ''
: ' as $genericType$nullableTag';

indent.add(
'$resultAt$castCallPrefix$castString',
'$resultAt$castCallForcePrefix$castString',
);
}
}
Expand Down