Skip to content

Commit 97e28f4

Browse files
committed
Merge remote-tracking branch 'origin/main' into shirakaba/reuse-uiwindow-in-rctdevloadingview
# Conflicts: # packages/react-native/React/CoreModules/RCTDevLoadingView.mm
2 parents 7b7b4d9 + 33f783a commit 97e28f4

File tree

83 files changed

+1381
-158
lines changed

Some content is hidden

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

83 files changed

+1381
-158
lines changed

packages/react-native-codegen/src/CodegenSchema.d.ts

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export interface FloatTypeAnnotation {
2626
readonly type: 'FloatTypeAnnotation';
2727
}
2828

29+
export interface NumberTypeAnnotation {
30+
readonly type: 'NumberTypeAnnotation';
31+
}
32+
2933
export interface BooleanTypeAnnotation {
3034
readonly type: 'BooleanTypeAnnotation';
3135
}
@@ -42,13 +46,23 @@ export interface VoidTypeAnnotation {
4246
readonly type: 'VoidTypeAnnotation';
4347
}
4448

49+
export interface BooleanLiteralTypeAnnotation {
50+
readonly type: 'BooleanLiteralTypeAnnotation';
51+
readonly value: boolean;
52+
}
53+
4554
export interface ObjectTypeAnnotation<T> {
4655
readonly type: 'ObjectTypeAnnotation';
4756
readonly properties: readonly NamedShape<T>[];
4857
// metadata for objects that generated from interfaces
4958
readonly baseTypes?: readonly string[] | undefined;
5059
}
5160

61+
export interface UnionTypeAnnotation<T> {
62+
readonly type: 'UnionTypeAnnotation';
63+
readonly types: readonly T[];
64+
}
65+
5266
export interface MixedTypeAnnotation {
5367
readonly type: 'MixedTypeAnnotation';
5468
}
@@ -290,7 +304,7 @@ export interface UnsafeAnyTypeAnnotation {
290304
readonly type: 'AnyTypeAnnotation',
291305
}
292306

293-
export interface NativeModuleNumberLiteralTypeAnnotation {
307+
export interface NumberLiteralTypeAnnotation {
294308
readonly type: 'NumberLiteralTypeAnnotation';
295309
readonly value: number;
296310
}
@@ -299,14 +313,14 @@ export interface NativeModuleStringTypeAnnotation {
299313
readonly type: 'StringTypeAnnotation';
300314
}
301315

302-
export interface NativeModuleStringLiteralTypeAnnotation {
316+
export interface StringLiteralTypeAnnotation {
303317
readonly type: 'StringLiteralTypeAnnotation';
304318
readonly value: string;
305319
}
306320

307321
export interface StringLiteralUnionTypeAnnotation {
308322
readonly type: 'StringLiteralUnionTypeAnnotation';
309-
readonly types: NativeModuleStringLiteralTypeAnnotation[];
323+
readonly types: StringLiteralTypeAnnotation[];
310324
}
311325

312326
export interface NativeModuleNumberTypeAnnotation {
@@ -331,7 +345,7 @@ export interface NativeModuleBooleanTypeAnnotation {
331345

332346
export type NativeModuleEnumMember = {
333347
readonly name: string;
334-
readonly value: NativeModuleStringLiteralTypeAnnotation | NativeModuleNumberLiteralTypeAnnotation,
348+
readonly value: StringLiteralTypeAnnotation | NumberLiteralTypeAnnotation,
335349
};
336350

337351
export type NativeModuleEnumMemberType =
@@ -374,6 +388,15 @@ export type UnionTypeAnnotationMemberType =
374388
| 'ObjectTypeAnnotation'
375389
| 'StringTypeAnnotation';
376390

391+
export type NativeModuleUnionTypeAnnotationMemberType =
392+
| NativeModuleObjectTypeAnnotation
393+
| StringLiteralTypeAnnotation
394+
| NumberLiteralTypeAnnotation
395+
| BooleanLiteralTypeAnnotation
396+
| BooleanTypeAnnotation
397+
| StringTypeAnnotation
398+
| NumberTypeAnnotation;
399+
377400
export interface NativeModuleUnionTypeAnnotation {
378401
readonly type: 'UnionTypeAnnotation';
379402
readonly memberType: UnionTypeAnnotationMemberType;
@@ -389,9 +412,10 @@ export type NativeModuleEventEmitterBaseTypeAnnotation =
389412
| NativeModuleFloatTypeAnnotation
390413
| NativeModuleInt32TypeAnnotation
391414
| NativeModuleNumberTypeAnnotation
392-
| NativeModuleNumberLiteralTypeAnnotation
415+
| NumberLiteralTypeAnnotation
416+
| BooleanLiteralTypeAnnotation
393417
| NativeModuleStringTypeAnnotation
394-
| NativeModuleStringLiteralTypeAnnotation
418+
| StringLiteralTypeAnnotation
395419
| StringLiteralUnionTypeAnnotation
396420
| NativeModuleTypeAliasTypeAnnotation
397421
| NativeModuleGenericObjectTypeAnnotation
@@ -403,10 +427,11 @@ export type NativeModuleEventEmitterTypeAnnotation =
403427

404428
export type NativeModuleBaseTypeAnnotation =
405429
NativeModuleStringTypeAnnotation
406-
| NativeModuleStringLiteralTypeAnnotation
430+
| StringLiteralTypeAnnotation
407431
| StringLiteralUnionTypeAnnotation
408432
| NativeModuleNumberTypeAnnotation
409-
| NativeModuleNumberLiteralTypeAnnotation
433+
| NumberLiteralTypeAnnotation
434+
| BooleanLiteralTypeAnnotation
410435
| NativeModuleInt32TypeAnnotation
411436
| NativeModuleDoubleTypeAnnotation
412437
| NativeModuleFloatTypeAnnotation

packages/react-native-codegen/src/CodegenSchema.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ export type FloatTypeAnnotation = $ReadOnly<{
3030
type: 'FloatTypeAnnotation',
3131
}>;
3232

33+
export type NumberTypeAnnotation = $ReadOnly<{
34+
type: 'NumberTypeAnnotation',
35+
}>;
36+
3337
export type BooleanTypeAnnotation = $ReadOnly<{
3438
type: 'BooleanTypeAnnotation',
3539
}>;
@@ -52,6 +56,11 @@ export type StringLiteralTypeAnnotation = $ReadOnly<{
5256
value: string,
5357
}>;
5458

59+
export type BooleanLiteralTypeAnnotation = $ReadOnly<{
60+
type: 'BooleanLiteralTypeAnnotation',
61+
value: boolean,
62+
}>;
63+
5564
export type StringLiteralUnionTypeAnnotation = $ReadOnly<{
5665
type: 'StringLiteralUnionTypeAnnotation',
5766
types: $ReadOnlyArray<StringLiteralTypeAnnotation>,
@@ -68,6 +77,11 @@ export type ObjectTypeAnnotation<+T> = $ReadOnly<{
6877
baseTypes?: $ReadOnlyArray<string>,
6978
}>;
7079

80+
export type UnionTypeAnnotation<+T> = $ReadOnly<{
81+
type: 'UnionTypeAnnotation',
82+
types: $ReadOnlyArray<T>,
83+
}>;
84+
7185
export type MixedTypeAnnotation = $ReadOnly<{
7286
type: 'MixedTypeAnnotation',
7387
}>;
@@ -363,6 +377,15 @@ export type UnionTypeAnnotationMemberType =
363377
| 'ObjectTypeAnnotation'
364378
| 'StringTypeAnnotation';
365379

380+
export type NativeModuleUnionTypeAnnotationMemberType =
381+
| NativeModuleObjectTypeAnnotation
382+
| StringLiteralTypeAnnotation
383+
| NumberLiteralTypeAnnotation
384+
| BooleanLiteralTypeAnnotation
385+
| BooleanTypeAnnotation
386+
| StringTypeAnnotation
387+
| NumberTypeAnnotation;
388+
366389
export type NativeModuleUnionTypeAnnotation = $ReadOnly<{
367390
type: 'UnionTypeAnnotation',
368391
memberType: UnionTypeAnnotationMemberType,
@@ -379,6 +402,7 @@ type NativeModuleEventEmitterBaseTypeAnnotation =
379402
| Int32TypeAnnotation
380403
| NativeModuleNumberTypeAnnotation
381404
| NumberLiteralTypeAnnotation
405+
| BooleanLiteralTypeAnnotation
382406
| StringTypeAnnotation
383407
| StringLiteralTypeAnnotation
384408
| StringLiteralUnionTypeAnnotation
@@ -396,6 +420,7 @@ export type NativeModuleBaseTypeAnnotation =
396420
| StringLiteralUnionTypeAnnotation
397421
| NativeModuleNumberTypeAnnotation
398422
| NumberLiteralTypeAnnotation
423+
| BooleanLiteralTypeAnnotation
399424
| Int32TypeAnnotation
400425
| DoubleTypeAnnotation
401426
| FloatTypeAnnotation

packages/react-native-codegen/src/generators/modules/GenerateModuleH.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ function serializeArg(
9696
return wrap(val => `${val}.asString(rt)`);
9797
case 'BooleanTypeAnnotation':
9898
return wrap(val => `${val}.asBool()`);
99+
case 'BooleanLiteralTypeAnnotation':
100+
return wrap(val => `${val}.asBool()`);
99101
case 'EnumDeclaration':
100102
switch (realTypeAnnotation.memberType) {
101103
case 'NumberTypeAnnotation':
@@ -265,6 +267,8 @@ function translatePrimitiveJSTypeToCpp(
265267
return wrapOptional('int', isRequired);
266268
case 'BooleanTypeAnnotation':
267269
return wrapOptional('bool', isRequired);
270+
case 'BooleanLiteralTypeAnnotation':
271+
return wrapOptional('bool', isRequired);
268272
case 'EnumDeclaration':
269273
switch (realTypeAnnotation.memberType) {
270274
case 'NumberTypeAnnotation':

packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ function translateEventEmitterTypeToJavaType(
142142
case 'Int32TypeAnnotation':
143143
return 'double';
144144
case 'BooleanTypeAnnotation':
145+
case 'BooleanLiteralTypeAnnotation':
145146
return 'boolean';
146147
case 'GenericObjectTypeAnnotation':
147148
case 'ObjectTypeAnnotation':
@@ -214,6 +215,8 @@ function translateFunctionParamToJavaType(
214215
return wrapOptional('double', isRequired);
215216
case 'BooleanTypeAnnotation':
216217
return wrapOptional('boolean', isRequired);
218+
case 'BooleanLiteralTypeAnnotation':
219+
return wrapOptional('boolean', isRequired);
217220
case 'EnumDeclaration':
218221
switch (realTypeAnnotation.memberType) {
219222
case 'NumberTypeAnnotation':
@@ -310,6 +313,8 @@ function translateFunctionReturnTypeToJavaType(
310313
return wrapOptional('double', isRequired);
311314
case 'BooleanTypeAnnotation':
312315
return wrapOptional('boolean', isRequired);
316+
case 'BooleanLiteralTypeAnnotation':
317+
return wrapOptional('boolean', isRequired);
313318
case 'EnumDeclaration':
314319
switch (realTypeAnnotation.memberType) {
315320
case 'NumberTypeAnnotation':
@@ -388,6 +393,8 @@ function getFalsyReturnStatementFromReturnType(
388393
return nullable ? 'return null;' : 'return 0;';
389394
case 'BooleanTypeAnnotation':
390395
return nullable ? 'return null;' : 'return false;';
396+
case 'BooleanLiteralTypeAnnotation':
397+
return nullable ? 'return null;' : 'return false;';
391398
case 'EnumDeclaration':
392399
switch (realTypeAnnotation.memberType) {
393400
case 'NumberTypeAnnotation':

packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ function translateReturnTypeToKind(
171171
return 'StringKind';
172172
case 'BooleanTypeAnnotation':
173173
return 'BooleanKind';
174+
case 'BooleanLiteralTypeAnnotation':
175+
return 'BooleanKind';
174176
case 'EnumDeclaration':
175177
switch (typeAnnotation.memberType) {
176178
case 'NumberTypeAnnotation':
@@ -256,6 +258,8 @@ function translateParamTypeToJniType(
256258
return 'Ljava/lang/String;';
257259
case 'BooleanTypeAnnotation':
258260
return !isRequired ? 'Ljava/lang/Boolean;' : 'Z';
261+
case 'BooleanLiteralTypeAnnotation':
262+
return !isRequired ? 'Ljava/lang/Boolean;' : 'Z';
259263
case 'EnumDeclaration':
260264
switch (typeAnnotation.memberType) {
261265
case 'NumberTypeAnnotation':
@@ -338,6 +342,8 @@ function translateReturnTypeToJniType(
338342
return 'Ljava/lang/String;';
339343
case 'BooleanTypeAnnotation':
340344
return nullable ? 'Ljava/lang/Boolean;' : 'Z';
345+
case 'BooleanLiteralTypeAnnotation':
346+
return nullable ? 'Ljava/lang/Boolean;' : 'Z';
341347
case 'EnumDeclaration':
342348
switch (typeAnnotation.memberType) {
343349
case 'NumberTypeAnnotation':

packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'use strict';
1212

1313
import type {
14+
BooleanLiteralTypeAnnotation,
1415
BooleanTypeAnnotation,
1516
DoubleTypeAnnotation,
1617
FloatTypeAnnotation,
@@ -65,6 +66,7 @@ export type StructTypeAnnotation =
6566
| StringLiteralUnionTypeAnnotation
6667
| NativeModuleNumberTypeAnnotation
6768
| NumberLiteralTypeAnnotation
69+
| BooleanLiteralTypeAnnotation
6870
| Int32TypeAnnotation
6971
| DoubleTypeAnnotation
7072
| FloatTypeAnnotation

packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ function toObjCType(
110110
return wrapCxxOptional('double', isRequired);
111111
case 'BooleanTypeAnnotation':
112112
return wrapCxxOptional('bool', isRequired);
113+
case 'BooleanLiteralTypeAnnotation':
114+
return wrapCxxOptional('bool', isRequired);
113115
case 'EnumDeclaration':
114116
switch (typeAnnotation.memberType) {
115117
case 'NumberTypeAnnotation':
@@ -195,6 +197,8 @@ function toObjCValue(
195197
return wrapPrimitive('double');
196198
case 'BooleanTypeAnnotation':
197199
return wrapPrimitive('BOOL');
200+
case 'BooleanLiteralTypeAnnotation':
201+
return wrapPrimitive('BOOL');
198202
case 'EnumDeclaration':
199203
switch (typeAnnotation.memberType) {
200204
case 'NumberTypeAnnotation':

packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ function toObjCType(
101101
return wrapCxxOptional('double', isRequired);
102102
case 'BooleanTypeAnnotation':
103103
return wrapCxxOptional('bool', isRequired);
104+
case 'BooleanLiteralTypeAnnotation':
105+
return wrapCxxOptional('bool', isRequired);
104106
case 'EnumDeclaration':
105107
switch (typeAnnotation.memberType) {
106108
case 'NumberTypeAnnotation':
@@ -185,6 +187,8 @@ function toObjCValue(
185187
return RCTBridgingTo('Double');
186188
case 'BooleanTypeAnnotation':
187189
return RCTBridgingTo('Bool');
190+
case 'BooleanLiteralTypeAnnotation':
191+
return RCTBridgingTo('Bool');
188192
case 'EnumDeclaration':
189193
switch (typeAnnotation.memberType) {
190194
case 'NumberTypeAnnotation':

packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeEventEmitter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function getEventEmitterTypeObjCType(
2828
case 'NumberLiteralTypeAnnotation':
2929
return 'NSNumber *_Nonnull';
3030
case 'BooleanTypeAnnotation':
31+
case 'BooleanLiteralTypeAnnotation':
3132
return 'BOOL';
3233
case 'GenericObjectTypeAnnotation':
3334
case 'ObjectTypeAnnotation':

packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ function getParamObjCType(
273273
return notStruct(isRequired ? 'NSInteger' : 'NSNumber *');
274274
case 'BooleanTypeAnnotation':
275275
return notStruct(isRequired ? 'BOOL' : 'NSNumber *');
276+
case 'BooleanLiteralTypeAnnotation':
277+
return notStruct(isRequired ? 'BOOL' : 'NSNumber *');
276278
case 'EnumDeclaration':
277279
switch (typeAnnotation.memberType) {
278280
case 'NumberTypeAnnotation':
@@ -356,6 +358,8 @@ function getReturnObjCType(
356358
return wrapOptional('NSNumber *', isRequired);
357359
case 'BooleanTypeAnnotation':
358360
return wrapOptional('NSNumber *', isRequired);
361+
case 'BooleanLiteralTypeAnnotation':
362+
return wrapOptional('NSNumber *', isRequired);
359363
case 'EnumDeclaration':
360364
switch (typeAnnotation.memberType) {
361365
case 'NumberTypeAnnotation':
@@ -428,6 +432,8 @@ function getReturnJSType(
428432
return 'NumberKind';
429433
case 'BooleanTypeAnnotation':
430434
return 'BooleanKind';
435+
case 'BooleanLiteralTypeAnnotation':
436+
return 'BooleanKind';
431437
case 'GenericObjectTypeAnnotation':
432438
return 'ObjectKind';
433439
case 'EnumDeclaration':

0 commit comments

Comments
 (0)