-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make UIConstantsProviderManager a static method
Differential Revision: D55241233
- Loading branch information
1 parent
b58d81b
commit 0721900
Showing
11 changed files
with
179 additions
and
267 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
47 changes: 47 additions & 0 deletions
47
...ive/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIConstantsProviderBinding.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,47 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package com.facebook.react.uimanager | ||
|
||
import com.facebook.proguard.annotations.DoNotStripAny | ||
import com.facebook.react.bridge.NativeMap | ||
import com.facebook.react.bridge.RuntimeExecutor | ||
import com.facebook.soloader.SoLoader | ||
import kotlin.jvm.JvmStatic | ||
|
||
@DoNotStripAny | ||
object UIConstantsProviderBinding { | ||
init { | ||
SoLoader.loadLibrary("uimanagerjni") | ||
} | ||
|
||
@JvmStatic | ||
external fun install( | ||
runtimeExecutor: RuntimeExecutor, | ||
defaultEventTypesProvider: DefaultEventTypesProvider, | ||
viewManagerConstantsProvider: ConstantsForViewManagerProvider, | ||
constantsProvider: ConstantsProvider | ||
) | ||
|
||
@DoNotStripAny | ||
interface DefaultEventTypesProvider { | ||
/* Returns UIManager's constants. */ | ||
fun getDefaultEventTypes(): NativeMap | ||
} | ||
|
||
@DoNotStripAny | ||
interface ConstantsForViewManagerProvider { | ||
/* Returns UIManager's constants. */ | ||
fun getConstantsForViewManager(viewManagerName: String): NativeMap? | ||
} | ||
|
||
@DoNotStripAny | ||
interface ConstantsProvider { | ||
/* Returns UIManager's constants. */ | ||
fun getConstants(): NativeMap | ||
} | ||
} |
75 changes: 0 additions & 75 deletions
75
...e/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIConstantsProviderManager.java
This file was deleted.
Oops, something went wrong.
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
64 changes: 64 additions & 0 deletions
64
...ges/react-native/ReactAndroid/src/main/jni/react/uimanager/UIConstantsProviderBinding.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,64 @@ | ||
/* | ||
* 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 "UIConstantsProviderBinding.h" | ||
|
||
#include <react/runtime/nativeviewconfig/LegacyUIManagerConstantsProviderBinding.h> | ||
|
||
namespace facebook::react { | ||
|
||
using namespace facebook::jni; | ||
|
||
void UIConstantsProviderBinding::registerNatives() { | ||
javaClassStatic()->registerNatives({ | ||
makeNativeMethod("install", UIConstantsProviderBinding::install), | ||
}); | ||
} | ||
|
||
void UIConstantsProviderBinding::install( | ||
jni::alias_ref<jclass> /* unused */, | ||
jni::alias_ref<JRuntimeExecutor::javaobject> runtimeExecutor, | ||
jni::alias_ref<DefaultEventTypesProvider::javaobject> | ||
defaultExportableEventTypesProvider, | ||
jni::alias_ref<ConstantsForViewManagerProvider::javaobject> | ||
constantsForViewManagerProvider, | ||
jni::alias_ref<ConstantsProvider::javaobject> constantsProvider) { | ||
auto executor = runtimeExecutor->cthis()->get(); | ||
executor([defaultExportableEventTypesProvider = | ||
make_global(defaultExportableEventTypesProvider), | ||
constantsForViewManagerProvider = | ||
make_global(constantsForViewManagerProvider), | ||
constantsProvider = | ||
make_global(constantsProvider)](jsi::Runtime& runtime) mutable { | ||
LegacyUIManagerConstantsProviderBinding::install( | ||
runtime, | ||
"getDefaultEventTypes", | ||
[provider = std::move(defaultExportableEventTypesProvider)]( | ||
jsi::Runtime& runtime) { | ||
return jsi::valueFromDynamic( | ||
runtime, provider->getDefaultEventTypes()); | ||
}); | ||
|
||
LegacyUIManagerConstantsProviderBinding::install( | ||
runtime, | ||
"getConstantsForViewManager", | ||
[provider = std::move(constantsForViewManagerProvider)]( | ||
jsi::Runtime& runtime, const std::string& viewManagerName) { | ||
return jsi::valueFromDynamic( | ||
runtime, provider->getConstantsForViewManager(viewManagerName)); | ||
}); | ||
|
||
LegacyUIManagerConstantsProviderBinding::install( | ||
runtime, | ||
"getConstants", | ||
[provider = std::move(constantsProvider)](jsi::Runtime& runtime) { | ||
return jsi::valueFromDynamic(runtime, provider->getConstants()); | ||
}); | ||
}); | ||
} | ||
|
||
} // namespace facebook::react |
Oops, something went wrong.