Skip to content

Commit 3800627

Browse files
committed
change internal prefix names and add more tests to avoid conflicts
1 parent c4df8ca commit 3800627

45 files changed

Lines changed: 4495 additions & 4423 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/pigeon/example/app/android/app/src/main/java/io/flutter/plugins/Messages.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@ ArrayList<Object> toList() {
207207
return toListResult;
208208
}
209209

210-
static @NonNull MessageData fromList(@NonNull ArrayList<Object> __pigeon_list) {
210+
static @NonNull MessageData fromList(@NonNull ArrayList<Object> pigeon_list) {
211211
MessageData pigeonResult = new MessageData();
212-
Object name = __pigeon_list.get(0);
212+
Object name = pigeon_list.get(0);
213213
pigeonResult.setName((String) name);
214-
Object description = __pigeon_list.get(1);
214+
Object description = pigeon_list.get(1);
215215
pigeonResult.setDescription((String) description);
216-
Object code = __pigeon_list.get(2);
216+
Object code = pigeon_list.get(2);
217217
pigeonResult.setCode((Code) code);
218-
Object data = __pigeon_list.get(3);
218+
Object data = pigeon_list.get(3);
219219
pigeonResult.setData((Map<String, String>) data);
220220
return pigeonResult;
221221
}

packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ data class MessageData(
6666
) {
6767
companion object {
6868
@Suppress("LocalVariableName")
69-
fun fromList(__pigeon_list: List<Any?>): MessageData {
70-
val name = __pigeon_list[0] as String?
71-
val description = __pigeon_list[1] as String?
72-
val code = __pigeon_list[2] as Code
73-
val data = __pigeon_list[3] as Map<String?, String?>
69+
fun fromList(pigeon_list: List<Any?>): MessageData {
70+
val name = pigeon_list[0] as String?
71+
val description = pigeon_list[1] as String?
72+
val code = pigeon_list[2] as Code
73+
val data = pigeon_list[3] as Map<String?, String?>
7474
return MessageData(name, description, code, data)
7575
}
7676
}

packages/pigeon/example/app/ios/Runner/Messages.g.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ struct MessageData {
8686
var data: [String?: String?]
8787

8888
// swift-format-ignore: AlwaysUseLowerCamelCase
89-
static func fromList(_ __pigeon_list: [Any?]) -> MessageData? {
90-
let name: String? = nilOrValue(__pigeon_list[0])
91-
let description: String? = nilOrValue(__pigeon_list[1])
92-
let code = __pigeon_list[2] as! Code
93-
let data = __pigeon_list[3] as! [String?: String?]
89+
static func fromList(_ pigeon_list: [Any?]) -> MessageData? {
90+
let name: String? = nilOrValue(pigeon_list[0])
91+
let description: String? = nilOrValue(pigeon_list[1])
92+
let code = pigeon_list[2] as! Code
93+
let data = pigeon_list[3] as! [String?: String?]
9494

9595
return MessageData(
9696
name: name,
@@ -113,12 +113,11 @@ private class MessagesPigeonCodecReader: FlutterStandardReader {
113113
override func readValue(ofType type: UInt8) -> Any? {
114114
switch type {
115115
case 129:
116-
var enumResult: Code? = nil
117116
let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int)
118117
if let enumResultAsInt = enumResultAsInt {
119-
enumResult = Code(rawValue: enumResultAsInt)
118+
return Code(rawValue: enumResultAsInt)
120119
}
121-
return enumResult
120+
return nil
122121
case 130:
123122
return MessageData.fromList(self.readValue() as! [Any?])
124123
default:

packages/pigeon/example/app/lib/src/messages.g.dart

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -105,99 +105,99 @@ class ExampleHostApi {
105105
/// BinaryMessenger will be used which routes to the host platform.
106106
ExampleHostApi(
107107
{BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
108-
: __pigeon_binaryMessenger = binaryMessenger,
109-
__pigeon_messageChannelSuffix =
108+
: pigeon_binaryMessenger = binaryMessenger,
109+
pigeon_messageChannelSuffix =
110110
messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
111-
final BinaryMessenger? __pigeon_binaryMessenger;
111+
final BinaryMessenger? pigeon_binaryMessenger;
112112

113113
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
114114

115-
final String __pigeon_messageChannelSuffix;
115+
final String pigeon_messageChannelSuffix;
116116

117117
Future<String> getHostLanguage() async {
118-
final String __pigeon_channelName =
119-
'dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.getHostLanguage$__pigeon_messageChannelSuffix';
120-
final BasicMessageChannel<Object?> __pigeon_channel =
118+
final String pigeon_channelName =
119+
'dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.getHostLanguage$pigeon_messageChannelSuffix';
120+
final BasicMessageChannel<Object?> pigeon_channel =
121121
BasicMessageChannel<Object?>(
122-
__pigeon_channelName,
122+
pigeon_channelName,
123123
pigeonChannelCodec,
124-
binaryMessenger: __pigeon_binaryMessenger,
124+
binaryMessenger: pigeon_binaryMessenger,
125125
);
126-
final List<Object?>? __pigeon_replyList =
127-
await __pigeon_channel.send(null) as List<Object?>?;
128-
if (__pigeon_replyList == null) {
129-
throw _createConnectionError(__pigeon_channelName);
130-
} else if (__pigeon_replyList.length > 1) {
126+
final List<Object?>? pigeon_replyList =
127+
await pigeon_channel.send(null) as List<Object?>?;
128+
if (pigeon_replyList == null) {
129+
throw _createConnectionError(pigeon_channelName);
130+
} else if (pigeon_replyList.length > 1) {
131131
throw PlatformException(
132-
code: __pigeon_replyList[0]! as String,
133-
message: __pigeon_replyList[1] as String?,
134-
details: __pigeon_replyList[2],
132+
code: pigeon_replyList[0]! as String,
133+
message: pigeon_replyList[1] as String?,
134+
details: pigeon_replyList[2],
135135
);
136-
} else if (__pigeon_replyList[0] == null) {
136+
} else if (pigeon_replyList[0] == null) {
137137
throw PlatformException(
138138
code: 'null-error',
139139
message: 'Host platform returned null value for non-null return value.',
140140
);
141141
} else {
142-
return (__pigeon_replyList[0] as String?)!;
142+
return (pigeon_replyList[0] as String?)!;
143143
}
144144
}
145145

146146
Future<int> add(int a, int b) async {
147-
final String __pigeon_channelName =
148-
'dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.add$__pigeon_messageChannelSuffix';
149-
final BasicMessageChannel<Object?> __pigeon_channel =
147+
final String pigeon_channelName =
148+
'dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.add$pigeon_messageChannelSuffix';
149+
final BasicMessageChannel<Object?> pigeon_channel =
150150
BasicMessageChannel<Object?>(
151-
__pigeon_channelName,
151+
pigeon_channelName,
152152
pigeonChannelCodec,
153-
binaryMessenger: __pigeon_binaryMessenger,
153+
binaryMessenger: pigeon_binaryMessenger,
154154
);
155-
final List<Object?>? __pigeon_replyList =
156-
await __pigeon_channel.send(<Object?>[a, b]) as List<Object?>?;
157-
if (__pigeon_replyList == null) {
158-
throw _createConnectionError(__pigeon_channelName);
159-
} else if (__pigeon_replyList.length > 1) {
155+
final List<Object?>? pigeon_replyList =
156+
await pigeon_channel.send(<Object?>[a, b]) as List<Object?>?;
157+
if (pigeon_replyList == null) {
158+
throw _createConnectionError(pigeon_channelName);
159+
} else if (pigeon_replyList.length > 1) {
160160
throw PlatformException(
161-
code: __pigeon_replyList[0]! as String,
162-
message: __pigeon_replyList[1] as String?,
163-
details: __pigeon_replyList[2],
161+
code: pigeon_replyList[0]! as String,
162+
message: pigeon_replyList[1] as String?,
163+
details: pigeon_replyList[2],
164164
);
165-
} else if (__pigeon_replyList[0] == null) {
165+
} else if (pigeon_replyList[0] == null) {
166166
throw PlatformException(
167167
code: 'null-error',
168168
message: 'Host platform returned null value for non-null return value.',
169169
);
170170
} else {
171-
return (__pigeon_replyList[0] as int?)!;
171+
return (pigeon_replyList[0] as int?)!;
172172
}
173173
}
174174

175175
Future<bool> sendMessage(MessageData message) async {
176-
final String __pigeon_channelName =
177-
'dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.sendMessage$__pigeon_messageChannelSuffix';
178-
final BasicMessageChannel<Object?> __pigeon_channel =
176+
final String pigeon_channelName =
177+
'dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.sendMessage$pigeon_messageChannelSuffix';
178+
final BasicMessageChannel<Object?> pigeon_channel =
179179
BasicMessageChannel<Object?>(
180-
__pigeon_channelName,
180+
pigeon_channelName,
181181
pigeonChannelCodec,
182-
binaryMessenger: __pigeon_binaryMessenger,
182+
binaryMessenger: pigeon_binaryMessenger,
183183
);
184-
final List<Object?>? __pigeon_replyList =
185-
await __pigeon_channel.send(<Object?>[message]) as List<Object?>?;
186-
if (__pigeon_replyList == null) {
187-
throw _createConnectionError(__pigeon_channelName);
188-
} else if (__pigeon_replyList.length > 1) {
184+
final List<Object?>? pigeon_replyList =
185+
await pigeon_channel.send(<Object?>[message]) as List<Object?>?;
186+
if (pigeon_replyList == null) {
187+
throw _createConnectionError(pigeon_channelName);
188+
} else if (pigeon_replyList.length > 1) {
189189
throw PlatformException(
190-
code: __pigeon_replyList[0]! as String,
191-
message: __pigeon_replyList[1] as String?,
192-
details: __pigeon_replyList[2],
190+
code: pigeon_replyList[0]! as String,
191+
message: pigeon_replyList[1] as String?,
192+
details: pigeon_replyList[2],
193193
);
194-
} else if (__pigeon_replyList[0] == null) {
194+
} else if (pigeon_replyList[0] == null) {
195195
throw PlatformException(
196196
code: 'null-error',
197197
message: 'Host platform returned null value for non-null return value.',
198198
);
199199
} else {
200-
return (__pigeon_replyList[0] as bool?)!;
200+
return (pigeon_replyList[0] as bool?)!;
201201
}
202202
}
203203
}
@@ -215,15 +215,15 @@ abstract class MessageFlutterApi {
215215
messageChannelSuffix =
216216
messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
217217
{
218-
final BasicMessageChannel<Object?> __pigeon_channel = BasicMessageChannel<
218+
final BasicMessageChannel<Object?> pigeon_channel = BasicMessageChannel<
219219
Object?>(
220220
'dev.flutter.pigeon.pigeon_example_package.MessageFlutterApi.flutterMethod$messageChannelSuffix',
221221
pigeonChannelCodec,
222222
binaryMessenger: binaryMessenger);
223223
if (api == null) {
224-
__pigeon_channel.setMessageHandler(null);
224+
pigeon_channel.setMessageHandler(null);
225225
} else {
226-
__pigeon_channel.setMessageHandler((Object? message) async {
226+
pigeon_channel.setMessageHandler((Object? message) async {
227227
assert(message != null,
228228
'Argument for dev.flutter.pigeon.pigeon_example_package.MessageFlutterApi.flutterMethod was null.');
229229
final List<Object?> args = (message as List<Object?>?)!;

packages/pigeon/example/app/macos/Runner/messages.g.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ + (PGNMessageData *)fromList:(NSArray<id> *)list {
7171
PGNMessageData *pigeonResult = [[PGNMessageData alloc] init];
7272
pigeonResult.name = GetNullableObjectAtIndex(list, 0);
7373
pigeonResult.description = GetNullableObjectAtIndex(list, 1);
74-
PGNCodeBox *anPGNCodeBox = GetNullableObjectAtIndex(list, 2);
75-
pigeonResult.code = anPGNCodeBox.value;
74+
PGNCodeBox *boxedPGNCode = GetNullableObjectAtIndex(list, 2);
75+
pigeonResult.code = boxedPGNCode.value;
7676
pigeonResult.data = GetNullableObjectAtIndex(list, 3);
7777
return pigeonResult;
7878
}

packages/pigeon/example/app/windows/runner/messages.g.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ MessageData MessageData::FromEncodableList(const EncodableList& list) {
102102
return decoded;
103103
}
104104

105-
PigeonCodecSerializer::PigeonCodecSerializer() {}
105+
PigeonInternalCodecSerializer::PigeonInternalCodecSerializer() {}
106106

107-
EncodableValue PigeonCodecSerializer::ReadValueOfType(
107+
EncodableValue PigeonInternalCodecSerializer::ReadValueOfType(
108108
uint8_t type, flutter::ByteStreamReader* stream) const {
109109
switch (type) {
110110
case 129: {
@@ -124,7 +124,7 @@ EncodableValue PigeonCodecSerializer::ReadValueOfType(
124124
}
125125
}
126126

127-
void PigeonCodecSerializer::WriteValue(
127+
void PigeonInternalCodecSerializer::WriteValue(
128128
const EncodableValue& value, flutter::ByteStreamWriter* stream) const {
129129
if (const CustomEncodableValue* custom_value =
130130
std::get_if<CustomEncodableValue>(&value)) {
@@ -150,7 +150,7 @@ void PigeonCodecSerializer::WriteValue(
150150
/// The codec used by ExampleHostApi.
151151
const flutter::StandardMessageCodec& ExampleHostApi::GetCodec() {
152152
return flutter::StandardMessageCodec::GetInstance(
153-
&PigeonCodecSerializer::GetInstance());
153+
&PigeonInternalCodecSerializer::GetInstance());
154154
}
155155

156156
// Sets up an instance of `ExampleHostApi` to handle messages through the
@@ -299,7 +299,7 @@ MessageFlutterApi::MessageFlutterApi(flutter::BinaryMessenger* binary_messenger,
299299

300300
const flutter::StandardMessageCodec& MessageFlutterApi::GetCodec() {
301301
return flutter::StandardMessageCodec::GetInstance(
302-
&PigeonCodecSerializer::GetInstance());
302+
&PigeonInternalCodecSerializer::GetInstance());
303303
}
304304

305305
void MessageFlutterApi::FlutterMethod(

packages/pigeon/example/app/windows/runner/messages.g.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,18 @@ class MessageData {
9090
flutter::EncodableList ToEncodableList() const;
9191
friend class ExampleHostApi;
9292
friend class MessageFlutterApi;
93-
friend class PigeonCodecSerializer;
93+
friend class PigeonInternalCodecSerializer;
9494
std::optional<std::string> name_;
9595
std::optional<std::string> description_;
9696
Code code_;
9797
flutter::EncodableMap data_;
9898
};
9999

100-
class PigeonCodecSerializer : public flutter::StandardCodecSerializer {
100+
class PigeonInternalCodecSerializer : public flutter::StandardCodecSerializer {
101101
public:
102-
PigeonCodecSerializer();
103-
inline static PigeonCodecSerializer& GetInstance() {
104-
static PigeonCodecSerializer sInstance;
102+
PigeonInternalCodecSerializer();
103+
inline static PigeonInternalCodecSerializer& GetInstance() {
104+
static PigeonInternalCodecSerializer sInstance;
105105
return sInstance;
106106
}
107107

packages/pigeon/lib/cpp_generator.dart

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ const DocumentCommentSpecification _docCommentSpec =
2121
const String _standardCodecSerializer = 'flutter::StandardCodecSerializer';
2222

2323
/// The name of the codec serializer.
24-
const String _codecSerializerName = 'PigeonCodecSerializer';
24+
const String _codecSerializerName = '${classNamePrefix}CodecSerializer';
2525

26-
const String _overflowClassName = '${varNamePrefix}CodecOverflow';
26+
const String _overflowClassName = '${classNamePrefix}CodecOverflow';
2727

2828
final NamedType _overflowType = NamedType(
2929
name: 'type',
@@ -255,7 +255,7 @@ class CppHeaderGenerator extends StructuredGenerator<CppOptions> {
255255
indent,
256256
_overflowClass,
257257
dartPackageName: dartPackageName,
258-
overflow: true,
258+
isOverflowClass: true,
259259
);
260260
}
261261
}
@@ -267,7 +267,7 @@ class CppHeaderGenerator extends StructuredGenerator<CppOptions> {
267267
Indent indent,
268268
Class classDefinition, {
269269
required String dartPackageName,
270-
bool overflow = false,
270+
bool isOverflowClass = false,
271271
}) {
272272
// When generating for a Pigeon unit test, add a test fixture friend class to
273273
// allow unit testing private methods, since testing serialization via public
@@ -364,17 +364,18 @@ class CppHeaderGenerator extends StructuredGenerator<CppOptions> {
364364

365365
_writeAccessBlock(indent, _ClassAccess.private, () {
366366
_writeFunctionDeclaration(indent, 'FromEncodableList',
367-
returnType:
368-
overflow ? 'flutter::EncodableValue' : classDefinition.name,
367+
returnType: isOverflowClass
368+
? 'flutter::EncodableValue'
369+
: classDefinition.name,
369370
parameters: <String>['const flutter::EncodableList& list'],
370371
isStatic: true);
371372
_writeFunctionDeclaration(indent, 'ToEncodableList',
372373
returnType: 'flutter::EncodableList', isConst: true);
373-
if (overflow) {
374+
if (isOverflowClass) {
374375
_writeFunctionDeclaration(indent, 'Unwrap',
375376
returnType: 'flutter::EncodableValue');
376377
}
377-
if (!overflow && root.requiresOverflowClass) {
378+
if (!isOverflowClass && root.requiresOverflowClass) {
378379
indent.writeln('friend class $_overflowClassName;');
379380
}
380381
for (final Class friend in root.classes) {
@@ -952,14 +953,14 @@ class CppSourceGenerator extends StructuredGenerator<CppOptions> {
952953
);
953954

954955
indent.format('''
955-
EncodableValue __pigeon_CodecOverflow::FromEncodableList(
956+
EncodableValue $_overflowClassName::FromEncodableList(
956957
const EncodableList& list) {
957-
return __pigeon_CodecOverflow(list[0].LongValue(),
958+
return $_overflowClassName(list[0].LongValue(),
958959
list[1].IsNull() ? EncodableValue() : list[1])
959960
.Unwrap();
960961
}''');
961962

962-
indent.writeScoped('EncodableValue __pigeon_CodecOverflow::Unwrap() {', '}',
963+
indent.writeScoped('EncodableValue $_overflowClassName::Unwrap() {', '}',
963964
() {
964965
indent.writeScoped('if (wrapped_.IsNull()) {', '}', () {
965966
indent.writeln('return EncodableValue();');

0 commit comments

Comments
 (0)