Skip to content

Commit 0a80270

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Extend Property Processor to support long properties
Summary: This change is a preliminary change to add support to `Long` and `long` React props that are required for supporting WideGamut color space. ## Changelog [Android][Added] - Extend Property Processor to support long props Reviewed By: cortinico Differential Revision: D56461183 fbshipit-source-id: 0f70388abe2b414a09df640f04e767f1164d63ce
1 parent 0a9891a commit 0a80270

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5414,6 +5414,7 @@ public abstract interface annotation class com/facebook/react/uimanager/annotati
54145414
public abstract fun defaultDouble ()D
54155415
public abstract fun defaultFloat ()F
54165416
public abstract fun defaultInt ()I
5417+
public abstract fun defaultLong ()J
54175418
public abstract fun name ()Ljava/lang/String;
54185419
}
54195420

@@ -5423,6 +5424,7 @@ public abstract interface annotation class com/facebook/react/uimanager/annotati
54235424
public abstract fun defaultDouble ()D
54245425
public abstract fun defaultFloat ()F
54255426
public abstract fun defaultInt ()I
5427+
public abstract fun defaultLong ()J
54265428
public abstract fun names ()[Ljava/lang/String;
54275429
}
54285430

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/processing/ReactPropertyProcessor.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ public class ReactPropertyProcessor extends ProcessorBase {
108108
DEFAULT_TYPES.put(TypeName.DOUBLE, "number");
109109
DEFAULT_TYPES.put(TypeName.FLOAT, "number");
110110
DEFAULT_TYPES.put(TypeName.INT, "number");
111+
DEFAULT_TYPES.put(TypeName.LONG, "number");
111112

112113
// Boxed primitives
113114
DEFAULT_TYPES.put(TypeName.BOOLEAN.box(), "boolean");
114115
DEFAULT_TYPES.put(TypeName.INT.box(), "number");
116+
DEFAULT_TYPES.put(TypeName.LONG.box(), "number");
115117

116118
// Class types
117119
DEFAULT_TYPES.put(STRING_TYPE, "String");
@@ -124,6 +126,7 @@ public class ReactPropertyProcessor extends ProcessorBase {
124126
BOXED_PRIMITIVES.add(TypeName.BOOLEAN.box());
125127
BOXED_PRIMITIVES.add(TypeName.FLOAT.box());
126128
BOXED_PRIMITIVES.add(TypeName.INT.box());
129+
BOXED_PRIMITIVES.add(TypeName.LONG.box());
127130
}
128131

129132
public ReactPropertyProcessor() {
@@ -409,6 +412,11 @@ private static void getPropertyExtractor(
409412
return;
410413
}
411414
}
415+
if (propertyType.equals(TypeName.LONG)) {
416+
long defaultLong = info.mProperty.defaultLong();
417+
builder.add("!(value instanceof Long) ? $L : (long)value", defaultLong);
418+
return;
419+
}
412420
if ("Color".equals(info.mProperty.customType())) {
413421
switch (classInfo.getType()) {
414422
case VIEW_MANAGER:
@@ -502,6 +510,8 @@ private interface Property {
502510

503511
int defaultInt();
504512

513+
long defaultLong();
514+
505515
boolean defaultBoolean();
506516
}
507517

@@ -537,6 +547,11 @@ public int defaultInt() {
537547
return mProp.defaultInt();
538548
}
539549

550+
@Override
551+
public long defaultLong() {
552+
return mProp.defaultLong();
553+
}
554+
540555
@Override
541556
public boolean defaultBoolean() {
542557
return mProp.defaultBoolean();
@@ -577,6 +592,11 @@ public int defaultInt() {
577592
return mProp.defaultInt();
578593
}
579594

595+
@Override
596+
public long defaultLong() {
597+
return mProp.defaultLong();
598+
}
599+
580600
@Override
581601
public boolean defaultBoolean() {
582602
throw new UnsupportedOperationException();

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/annotations/ReactProp.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@
9595
*/
9696
int defaultInt() default 0;
9797

98+
/**
99+
* Default value for property of type {@code long}. This value will be provided to property setter
100+
* method annotated with {@link ReactProp} if property with a given name gets removed from the
101+
* component description in JS
102+
*/
103+
long defaultLong() default 0L;
104+
98105
/**
99106
* Default value for property of type {@code boolean}. This value will be provided to property
100107
* setter method annotated with {@link ReactProp} if property with a given name gets removed from

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/annotations/ReactPropGroup.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,11 @@
8989
* the component description in JS
9090
*/
9191
int defaultInt() default 0;
92+
93+
/**
94+
* Default value for property of type {@code long}. This value will be provided to property setter
95+
* method annotated with {@link ReactProp} if property with a given name gets removed from the
96+
* component description in JS
97+
*/
98+
long defaultLong() default 0L;
9299
}

0 commit comments

Comments
 (0)