-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Differential Revision: D52806730 fbshipit-source-id: 3000a1e47d835b69df528e9c015f1e0a850c21da
- Loading branch information
1 parent
1b36add
commit 2c177e4
Showing
65 changed files
with
2,738 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...Android/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @generated SignedSource<<941c7eb38bebe95c3b038de7bf3ae912>> | ||
*/ | ||
|
||
/** | ||
* IMPORTANT: Do NOT modify this file directly. | ||
* | ||
* To change the definition of the flags, edit | ||
* `packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json`. | ||
* | ||
* To regenerate this code, run | ||
* `packages/react-native/scripts/featureflags/update.js`. | ||
*/ | ||
|
||
package com.facebook.react.internal.featureflags | ||
|
||
object ReactNativeFeatureFlags { | ||
var accessor = ReactNativeFeatureFlagsAccessor() | ||
|
||
/** | ||
* Common flag for testing. Do NOT modify. | ||
*/ | ||
fun commonTestFlag() = accessor.commonTestFlag() | ||
|
||
/** | ||
* Overrides the feature flags with the ones provided by the given provider. | ||
*/ | ||
fun override(provider: ReactNativeFeatureFlagsProvider) = | ||
ReactNativeFeatureFlagsCxxInterop.override(provider as Any) | ||
|
||
/** | ||
* Removes the overridden feature flags and returns default values again. | ||
*/ | ||
fun reset() { | ||
ReactNativeFeatureFlagsCxxInterop.reset() | ||
accessor = ReactNativeFeatureFlagsAccessor() | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsAccessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @generated SignedSource<<e90fe3ecb417f22607ac92b7fb19e85c>> | ||
*/ | ||
|
||
/** | ||
* IMPORTANT: Do NOT modify this file directly. | ||
* | ||
* To change the definition of the flags, edit | ||
* `packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json`. | ||
* | ||
* To regenerate this code, run | ||
* `packages/react-native/scripts/featureflags/update.js`. | ||
*/ | ||
|
||
package com.facebook.react.internal.featureflags | ||
|
||
class ReactNativeFeatureFlagsAccessor { | ||
var commonTestFlagCache: Boolean? = null | ||
|
||
fun commonTestFlag(): Boolean { | ||
var cached = commonTestFlagCache | ||
if (cached == null) { | ||
cached = ReactNativeFeatureFlagsCxxInterop.commonTestFlag() | ||
commonTestFlagCache = cached | ||
} | ||
return cached | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...c/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @generated SignedSource<<08ea12cf0c10faa724fd7e16c713337b>> | ||
*/ | ||
|
||
/** | ||
* IMPORTANT: Do NOT modify this file directly. | ||
* | ||
* To change the definition of the flags, edit | ||
* `packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json`. | ||
* | ||
* To regenerate this code, run | ||
* `packages/react-native/scripts/featureflags/update.js`. | ||
*/ | ||
|
||
package com.facebook.react.internal.featureflags | ||
|
||
import com.facebook.proguard.annotations.DoNotStrip | ||
import com.facebook.soloader.SoLoader | ||
|
||
@DoNotStrip | ||
object ReactNativeFeatureFlagsCxxInterop { | ||
init { | ||
SoLoader.loadLibrary("reactfeatureflagsjni") | ||
} | ||
|
||
@DoNotStrip @JvmStatic external fun commonTestFlag(): Boolean | ||
|
||
@DoNotStrip @JvmStatic external fun override(provider: Object) | ||
|
||
@DoNotStrip @JvmStatic external fun reset() | ||
} |
27 changes: 27 additions & 0 deletions
27
...src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @generated SignedSource<<35de3b0df307b57616b1da2c31d0e918>> | ||
*/ | ||
|
||
/** | ||
* IMPORTANT: Do NOT modify this file directly. | ||
* | ||
* To change the definition of the flags, edit | ||
* `packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json`. | ||
* | ||
* To regenerate this code, run | ||
* `packages/react-native/scripts/featureflags/update.js`. | ||
*/ | ||
|
||
package com.facebook.react.internal.featureflags | ||
|
||
open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvider { | ||
// We could use JNI to get the defaults from C++, | ||
// but that is more expensive than just duplicating the defaults here. | ||
|
||
override fun commonTestFlag(): Boolean = false | ||
} |
24 changes: 24 additions & 0 deletions
24
...src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @generated SignedSource<<9f38db38c05560c89d27ce8c70000332>> | ||
*/ | ||
|
||
/** | ||
* IMPORTANT: Do NOT modify this file directly. | ||
* | ||
* To change the definition of the flags, edit | ||
* `packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json`. | ||
* | ||
* To regenerate this code, run | ||
* `packages/react-native/scripts/featureflags/update.js`. | ||
*/ | ||
|
||
package com.facebook.react.internal.featureflags | ||
|
||
interface ReactNativeFeatureFlagsProvider { | ||
fun commonTestFlag(): Boolean | ||
} |
34 changes: 34 additions & 0 deletions
34
packages/react-native/ReactAndroid/src/main/jni/react/featureflags/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
cmake_minimum_required(VERSION 3.13) | ||
|
||
file(GLOB featureflagsjni_SRCS CONFIGURE_DEPENDS *.cpp) | ||
|
||
add_library( | ||
featureflagsjni | ||
SHARED | ||
${featureflagsjni_SRCS} | ||
) | ||
|
||
target_include_directories(featureflagsjni PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
target_link_libraries( | ||
featureflagsjni | ||
fb | ||
fbjni | ||
react_featureflags | ||
reactnativejni | ||
) | ||
|
||
target_compile_options( | ||
featureflagsjni | ||
PRIVATE | ||
-DLOG_TAG=\"ReactNative\" | ||
-fexceptions | ||
-frtti | ||
-std=c++20 | ||
-Wall | ||
) |
54 changes: 54 additions & 0 deletions
54
...ative/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @generated SignedSource<<0c0fd104af5903288313b9e33fcc3da4>> | ||
*/ | ||
|
||
/** | ||
* IMPORTANT: Do NOT modify this file directly. | ||
* | ||
* To change the definition of the flags, edit | ||
* `packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json`. | ||
* | ||
* To regenerate this code, run | ||
* `packages/react-native/scripts/featureflags/update.js`. | ||
*/ | ||
|
||
#include "JReactNativeFeatureFlagsCxxInterop.h" | ||
#include <react/featureflags/ReactNativeFeatureFlags.h> | ||
#include <react/featureflags/ReactNativeFeatureFlagsProviderHolder.h> | ||
|
||
namespace facebook::react { | ||
|
||
bool JReactNativeFeatureFlagsCxxInterop::commonTestFlag( | ||
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) { | ||
return ReactNativeFeatureFlags::commonTestFlag(); | ||
} | ||
|
||
void JReactNativeFeatureFlagsCxxInterop::override( | ||
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/, | ||
jni::alias_ref<jobject> provider) { | ||
ReactNativeFeatureFlags::override( | ||
std::make_unique<ReactNativeFeatureFlagsProviderHolder>(provider)); | ||
} | ||
|
||
void JReactNativeFeatureFlagsCxxInterop::reset( | ||
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) { | ||
ReactNativeFeatureFlags::reset(); | ||
} | ||
|
||
void JReactNativeFeatureFlagsCxxInterop::registerNatives() { | ||
javaClassLocal()->registerNatives({ | ||
makeNativeMethod( | ||
"override", JReactNativeFeatureFlagsCxxInterop::override), | ||
makeNativeMethod("reset", JReactNativeFeatureFlagsCxxInterop::reset), | ||
makeNativeMethod( | ||
"commonTestFlag", | ||
JReactNativeFeatureFlagsCxxInterop::commonTestFlag), | ||
}); | ||
} | ||
|
||
} // namespace facebook::react |
46 changes: 46 additions & 0 deletions
46
...-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @generated SignedSource<<92dbf3bd6e30ad982edb39de8a0ca392>> | ||
*/ | ||
|
||
/** | ||
* IMPORTANT: Do NOT modify this file directly. | ||
* | ||
* To change the definition of the flags, edit | ||
* `packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json`. | ||
* | ||
* To regenerate this code, run | ||
* `packages/react-native/scripts/featureflags/update.js`. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <fbjni/fbjni.h> | ||
#include <jni.h> | ||
|
||
namespace facebook::react { | ||
|
||
class JReactNativeFeatureFlagsCxxInterop | ||
: public jni::JavaClass<JReactNativeFeatureFlagsCxxInterop> { | ||
public: | ||
constexpr static auto kJavaDescriptor = | ||
"Lcom/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop;"; | ||
|
||
static bool commonTestFlag( | ||
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>); | ||
|
||
static void override( | ||
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>, | ||
jni::alias_ref<jobject> provider); | ||
|
||
static void reset( | ||
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>); | ||
|
||
static void registerNatives(); | ||
}; | ||
|
||
} // namespace facebook::react |
16 changes: 16 additions & 0 deletions
16
packages/react-native/ReactAndroid/src/main/jni/react/featureflags/OnLoad.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include <fbjni/fbjni.h> | ||
|
||
#include "JReactNativeFeatureFlagsCxxInterop.h" | ||
|
||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) { | ||
return facebook::jni::initialize(vm, [] { | ||
facebook::react::JReactNativeFeatureFlagsCxxInterop::registerNatives(); | ||
}); | ||
} |
Oops, something went wrong.