Adding @CountEnum to simple enums in xplat/js

Summary: Using The Count to transform enums to ints in production builds: https://our.intern.facebook.com/intern/wiki/Android-java-transforms/the-count/

Reviewed By: achen1

Differential Revision: D9614432

fbshipit-source-id: 1b1a197ad8f4962712d6006ab07b3beb3eaf2432
This commit is contained in:
Emily Janzer 2018-09-04 18:04:53 -07:00 committed by Facebook Github Bot
parent 01d5eff425
commit 06bf7b1f00
24 changed files with 52 additions and 0 deletions

View File

@ -13,6 +13,8 @@ import java.io.Writer;
import java.util.ArrayDeque;
import java.util.Deque;
import com.facebook.thecount.api.CountEnum;
/**
* Simple Json generator that does no validation.
*/
@ -207,6 +209,7 @@ public class JsonWriter implements Closeable {
mScopes.push(scope);
}
@CountEnum
private enum Scope {
EMPTY_OBJECT,
OBJECT,

View File

@ -5,6 +5,9 @@
package com.facebook.react.bridge;
import com.facebook.thecount.api.CountEnum;
@CountEnum
public enum MemoryPressure {
UI_HIDDEN,
MODERATE,

View File

@ -7,6 +7,8 @@
package com.facebook.react.bridge.queue;
import com.facebook.thecount.api.CountEnum;
/**
* Spec for creating a MessageQueueThread.
*/
@ -18,6 +20,7 @@ public class MessageQueueThreadSpec {
// The Thread constructor interprets zero the same as not specifying a stack size
public static final long DEFAULT_STACK_SIZE_BYTES = 0;
@CountEnum
protected static enum ThreadType {
MAIN_UI,
NEW_BACKGROUND,

View File

@ -19,6 +19,7 @@ rn_android_library(
],
deps = [
":build_config",
react_native_dep("java/com/facebook/thecount:thecount"),
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/jsr-305:jsr-305"),

View File

@ -7,6 +7,8 @@
package com.facebook.react.common;
import com.facebook.thecount.api.CountEnum;
/**
* Lifecycle state for an Activity. The state right after pause and right before resume are the
* basically the same so this enum is in terms of the forward lifecycle progression (onResume, etc).
@ -18,6 +20,7 @@ package com.facebook.react.common;
* STARTED,
* RESUMED
*/
@CountEnum
public enum LifecycleState {
BEFORE_CREATE,
BEFORE_RESUME,

View File

@ -7,6 +7,7 @@ rn_android_library(
"PUBLIC",
],
deps = [
react_native_dep("java/com/facebook/thecount:thecount"),
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/jsr-305:jsr-305"),

View File

@ -13,6 +13,7 @@ import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.common.ReactConstants;
import com.facebook.thecount.api.CountEnum;
/**
* A simple wrapper around Choreographer that allows us to control the order certain callbacks
@ -21,6 +22,7 @@ import com.facebook.react.common.ReactConstants;
*/
public class ReactChoreographer {
@CountEnum
public enum CallbackType {
/**

View File

@ -10,6 +10,7 @@ rn_android_library(
"PUBLIC",
],
deps = [
react_native_dep("java/com/facebook/thecount:thecount"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_target("java/com/facebook/react/bridge:bridge"),

View File

@ -7,9 +7,12 @@
package com.facebook.react.modules.datepicker;
import com.facebook.thecount.api.CountEnum;
/**
* Date picker modes
*/
@CountEnum
public enum DatePickerMode {
CALENDAR,
SPINNER,

View File

@ -10,6 +10,7 @@ rn_android_library(
"PUBLIC",
],
deps = [
react_native_dep("java/com/facebook/thecount:thecount"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_target("java/com/facebook/react/bridge:bridge"),

View File

@ -7,7 +7,9 @@
package com.facebook.react.modules.timepicker;
import com.facebook.thecount.api.CountEnum;
@CountEnum
public enum TimePickerMode {
CLOCK,
SPINNER,

View File

@ -18,6 +18,7 @@ rn_java_library(
source = "7",
target = "7",
deps = [
react_native_dep("java/com/facebook/thecount:thecount"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/javapoet:javapoet"),
react_native_dep("third-party/java/jsr-305:jsr-305"),

View File

@ -53,6 +53,8 @@ import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import com.facebook.thecount.api.CountEnum;
/**
* This annotation processor crawls subclasses of ReactShadowNode and ViewManager and finds their
* exported properties with the @ReactProp or @ReactGroupProp annotation. It generates a class
@ -549,6 +551,7 @@ public class ReactPropertyProcessor extends AbstractProcessor {
}
}
@CountEnum
private enum SettableType {
VIEW_MANAGER,
SHADOW_NODE

View File

@ -23,6 +23,7 @@ rn_android_library(
YOGA_TARGET,
":DisplayMetrics",
react_native_dep("java/com/facebook/systrace:systrace"),
react_native_dep("java/com/facebook/thecount:thecount"),
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_target("java/com/facebook/debug/tags:tags"),

View File

@ -7,10 +7,13 @@
package com.facebook.react.uimanager;
import com.facebook.thecount.api.CountEnum;
/**
* Possible values for pointer events that a view and its descendants should receive. See
* https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events for more info.
*/
@CountEnum
public enum PointerEvents {
/**

View File

@ -7,9 +7,12 @@
package com.facebook.react.uimanager.events;
import com.facebook.thecount.api.CountEnum;
/**
* Touch event types that JS module RCTEventEmitter can understand
*/
@CountEnum
public enum TouchEventType {
START("topTouchStart"),
END("topTouchEnd"),

View File

@ -5,10 +5,13 @@
package com.facebook.react.uimanager.layoutanimation;
import com.facebook.thecount.api.CountEnum;
/**
* Enum representing the different view properties that can be used when animating layout for
* view creation.
*/
@CountEnum
/* package */ enum AnimatedPropertyType {
OPACITY("opacity"),
SCALE_X("scaleX"),

View File

@ -5,9 +5,12 @@
package com.facebook.react.uimanager.layoutanimation;
import com.facebook.thecount.api.CountEnum;
/**
* Enum representing the different animation type that can be specified in layout animation config.
*/
@CountEnum
/* package */ enum LayoutAnimationType {
CREATE("create"),
UPDATE("update"),

View File

@ -35,6 +35,7 @@ rn_android_library(
],
deps = [
YOGA_TARGET,
react_native_dep("java/com/facebook/thecount:thecount"),
react_native_dep("libraries/fresco/fresco-react-native:fbcore"),
react_native_dep("libraries/fresco/fresco-react-native:fresco-drawee"),
react_native_dep("libraries/fresco/fresco-react-native:fresco-react-native"),

View File

@ -7,6 +7,9 @@
package com.facebook.react.views.image;
import com.facebook.thecount.api.CountEnum;
@CountEnum
public enum ImageResizeMethod {
AUTO,
RESIZE,

View File

@ -11,6 +11,7 @@ rn_android_library(
],
deps = [
YOGA_TARGET,
react_native_dep("java/com/facebook/thecount:thecount"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_target("java/com/facebook/react/bridge:bridge"),

View File

@ -7,9 +7,12 @@
package com.facebook.react.views.scroll;
import com.facebook.thecount.api.CountEnum;
/**
* Scroll event types that JS module RCTEventEmitter can understand
*/
@CountEnum
public enum ScrollEventType {
BEGIN_DRAG("topScrollBeginDrag"),
END_DRAG("topScrollEndDrag"),

View File

@ -8,6 +8,7 @@ rn_android_library(
],
deps = [
YOGA_TARGET,
react_native_dep("java/com/facebook/thecount:thecount"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_target("java/com/facebook/react/bridge:bridge"),

View File

@ -27,11 +27,13 @@ import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.modules.i18nmanager.I18nUtil;
import com.facebook.react.uimanager.FloatUtil;
import com.facebook.react.uimanager.Spacing;
import com.facebook.thecount.api.CountEnum;
import com.facebook.yoga.YogaConstants;
import java.util.Arrays;
import java.util.Locale;
import javax.annotation.Nullable;
/**
* A subclass of {@link Drawable} used for background of {@link ReactViewGroup}. It supports drawing
* background color and borders (including rounded borders) by providing a react friendly API
@ -111,6 +113,7 @@ public class ReactViewBackgroundDrawable extends Drawable {
private final Context mContext;
private int mLayoutDirection;
@CountEnum
public enum BorderRadiusLocation {
TOP_LEFT,
TOP_RIGHT,