Skip to content
Merged
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
Next Next commit
FlutterError cpp fix
  • Loading branch information
tarrinneal committed Nov 17, 2023
commit e6ad15b865726219b0a61bdd1f8a8de624d0ee82
17 changes: 11 additions & 6 deletions packages/pigeon/lib/cpp_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class CppHeaderGenerator extends StructuredGenerator<CppOptions> {
final bool hasFlutterApi = root.apis.any((Api api) =>
api.methods.isNotEmpty && api.location == ApiLocation.flutter);

_writeFlutterError(indent);
if (hasHostApi) {
_writeErrorOr(indent, friends: root.apis.map((Api api) => api.name));
}
Expand Down Expand Up @@ -510,11 +511,7 @@ class CppHeaderGenerator extends StructuredGenerator<CppOptions> {
indent.newln();
}

void _writeErrorOr(Indent indent,
{Iterable<String> friends = const <String>[]}) {
final String friendLines = friends
.map((String className) => '\tfriend class $className;')
.join('\n');
void _writeFlutterError(Indent indent) {
indent.format('''

class FlutterError {
Expand All @@ -534,7 +531,15 @@ class FlutterError {
\tstd::string code_;
\tstd::string message_;
\tflutter::EncodableValue details_;
};
};''');
}

void _writeErrorOr(Indent indent,
{Iterable<String> friends = const <String>[]}) {
final String friendLines = friends
.map((String className) => '\tfriend class $className;')
.join('\n');
indent.format('''

template<class T> class ErrorOr {
public:
Expand Down