mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove unused hybrid class from DefaultComponentsRegistry (#45205)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45205 We only need a static register method, which includes the core components and the provider function. CoreComponentsRegistry isn't referenced at all in Kotlin/Java, and can be replaced with DefaultComponentsRegistry with no change in behaviour in all scenarios. Changelog: [Android][Removed] CoreComponentsRegistry is now fully replaced by DefaultComponentRegistry. Reviewed By: cortinico Differential Revision: D59107106 fbshipit-source-id: e679be490f43dab52eb5e11a08aa9d0ae2a89a92
This commit is contained in:
committed by
Facebook GitHub Bot
parent
20521cc908
commit
de7976c69d
@@ -1979,13 +1979,8 @@ public class com/facebook/react/config/ReactFeatureFlags {
|
||||
}
|
||||
|
||||
public final class com/facebook/react/defaults/DefaultComponentsRegistry {
|
||||
public static final field Companion Lcom/facebook/react/defaults/DefaultComponentsRegistry$Companion;
|
||||
public synthetic fun <init> (Lcom/facebook/react/fabric/ComponentFactory;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public static final fun register (Lcom/facebook/react/fabric/ComponentFactory;)Lcom/facebook/react/defaults/DefaultComponentsRegistry;
|
||||
}
|
||||
|
||||
public final class com/facebook/react/defaults/DefaultComponentsRegistry$Companion {
|
||||
public final fun register (Lcom/facebook/react/fabric/ComponentFactory;)Lcom/facebook/react/defaults/DefaultComponentsRegistry;
|
||||
public static final field INSTANCE Lcom/facebook/react/defaults/DefaultComponentsRegistry;
|
||||
public static final fun register (Lcom/facebook/react/fabric/ComponentFactory;)V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/defaults/DefaultNewArchitectureEntryPoint {
|
||||
@@ -2532,16 +2527,6 @@ public final class com/facebook/react/fabric/ComponentFactory {
|
||||
public fun <init> ()V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/fabric/CoreComponentsRegistry {
|
||||
public static final field Companion Lcom/facebook/react/fabric/CoreComponentsRegistry$Companion;
|
||||
public synthetic fun <init> (Lcom/facebook/react/fabric/ComponentFactory;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public static final fun register (Lcom/facebook/react/fabric/ComponentFactory;)Lcom/facebook/react/fabric/CoreComponentsRegistry;
|
||||
}
|
||||
|
||||
public final class com/facebook/react/fabric/CoreComponentsRegistry$Companion {
|
||||
public final fun register (Lcom/facebook/react/fabric/ComponentFactory;)Lcom/facebook/react/fabric/CoreComponentsRegistry;
|
||||
}
|
||||
|
||||
public class com/facebook/react/fabric/DevToolsReactPerfLogger : com/facebook/react/bridge/ReactMarker$FabricMarkerListener {
|
||||
public static final field mStreamingBatchExecutionStats Lcom/facebook/react/fabric/LongStreamingStats;
|
||||
public static final field mStreamingCommitStats Lcom/facebook/react/fabric/LongStreamingStats;
|
||||
|
||||
+5
-20
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.facebook.react.defaults
|
||||
|
||||
import com.facebook.jni.HybridData
|
||||
import com.facebook.proguard.annotations.DoNotStrip
|
||||
import com.facebook.react.fabric.ComponentFactory
|
||||
|
||||
@@ -21,24 +20,10 @@ import com.facebook.react.fabric.ComponentFactory
|
||||
* TODO(T186951312): Should this be @UnstableReactNativeAPI?
|
||||
*/
|
||||
@DoNotStrip
|
||||
public class DefaultComponentsRegistry
|
||||
@DoNotStrip
|
||||
private constructor(componentFactory: ComponentFactory) {
|
||||
|
||||
@DoNotStrip
|
||||
@Suppress("NoHungarianNotation")
|
||||
private val mHybridData: HybridData = initHybrid(componentFactory)
|
||||
|
||||
@DoNotStrip private external fun initHybrid(componentFactory: ComponentFactory): HybridData
|
||||
|
||||
public companion object {
|
||||
init {
|
||||
DefaultSoLoader.maybeLoadSoLibrary()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@DoNotStrip
|
||||
public fun register(componentFactory: ComponentFactory): DefaultComponentsRegistry =
|
||||
DefaultComponentsRegistry(componentFactory)
|
||||
public object DefaultComponentsRegistry {
|
||||
init {
|
||||
DefaultSoLoader.maybeLoadSoLibrary()
|
||||
}
|
||||
|
||||
@JvmStatic @DoNotStrip public external fun register(componentFactory: ComponentFactory): Unit
|
||||
}
|
||||
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* 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.fabric
|
||||
|
||||
import com.facebook.jni.HybridData
|
||||
import com.facebook.proguard.annotations.DoNotStripAny
|
||||
|
||||
@DoNotStripAny
|
||||
public class CoreComponentsRegistry private constructor(componentFactory: ComponentFactory) {
|
||||
|
||||
@Suppress("NoHungarianNotation")
|
||||
private val mHybridData: HybridData = initHybrid(componentFactory)
|
||||
|
||||
private external fun initHybrid(componentFactory: ComponentFactory): HybridData
|
||||
|
||||
public companion object {
|
||||
init {
|
||||
FabricSoLoader.staticInit()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun register(componentFactory: ComponentFactory): CoreComponentsRegistry =
|
||||
CoreComponentsRegistry(componentFactory)
|
||||
}
|
||||
}
|
||||
+3
-43
@@ -9,8 +9,6 @@
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
|
||||
#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
|
||||
#include <react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h>
|
||||
#include <react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h>
|
||||
@@ -24,13 +22,10 @@
|
||||
#include <react/renderer/components/text/TextComponentDescriptor.h>
|
||||
#include <react/renderer/components/view/ViewComponentDescriptor.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
CoreComponentsRegistry::CoreComponentsRegistry(ComponentFactory* delegate)
|
||||
: delegate_(delegate) {}
|
||||
namespace facebook::react::CoreComponentsRegistry {
|
||||
|
||||
std::shared_ptr<const ComponentDescriptorProviderRegistry>
|
||||
CoreComponentsRegistry::sharedProviderRegistry() {
|
||||
sharedProviderRegistry() {
|
||||
static auto providerRegistry =
|
||||
[]() -> std::shared_ptr<ComponentDescriptorProviderRegistry> {
|
||||
auto providerRegistry =
|
||||
@@ -74,39 +69,4 @@ CoreComponentsRegistry::sharedProviderRegistry() {
|
||||
return providerRegistry;
|
||||
}
|
||||
|
||||
jni::local_ref<CoreComponentsRegistry::jhybriddata>
|
||||
CoreComponentsRegistry::initHybrid(
|
||||
jni::alias_ref<jclass>,
|
||||
ComponentFactory* delegate) {
|
||||
auto instance = makeCxxInstance(delegate);
|
||||
|
||||
// TODO T69453179: Codegen this file
|
||||
auto buildRegistryFunction =
|
||||
[](const EventDispatcher::Weak& eventDispatcher,
|
||||
const ContextContainer::Shared& contextContainer)
|
||||
-> ComponentDescriptorRegistry::Shared {
|
||||
ComponentDescriptorParameters params{
|
||||
.eventDispatcher = eventDispatcher,
|
||||
.contextContainer = contextContainer,
|
||||
.flavor = nullptr};
|
||||
|
||||
auto registry = CoreComponentsRegistry::sharedProviderRegistry()
|
||||
->createComponentDescriptorRegistry(params);
|
||||
auto& mutableRegistry = const_cast<ComponentDescriptorRegistry&>(*registry);
|
||||
mutableRegistry.setFallbackComponentDescriptor(
|
||||
std::make_shared<UnimplementedNativeViewComponentDescriptor>(params));
|
||||
|
||||
return registry;
|
||||
};
|
||||
|
||||
delegate->buildRegistryFunction = buildRegistryFunction;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void CoreComponentsRegistry::registerNatives() {
|
||||
registerHybrid({
|
||||
makeNativeMethod("initHybrid", CoreComponentsRegistry::initHybrid),
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
} // namespace facebook::react::CoreComponentsRegistry
|
||||
|
||||
+4
-27
@@ -7,34 +7,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
||||
#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
|
||||
#include "ComponentFactory.h"
|
||||
|
||||
namespace facebook::react {
|
||||
namespace facebook::react::CoreComponentsRegistry {
|
||||
|
||||
class CoreComponentsRegistry
|
||||
: public facebook::jni::HybridClass<CoreComponentsRegistry> {
|
||||
public:
|
||||
constexpr static auto kJavaDescriptor =
|
||||
"Lcom/facebook/react/fabric/CoreComponentsRegistry;";
|
||||
std::shared_ptr<const ComponentDescriptorProviderRegistry>
|
||||
sharedProviderRegistry();
|
||||
|
||||
static void registerNatives();
|
||||
|
||||
explicit CoreComponentsRegistry(ComponentFactory* delegate);
|
||||
|
||||
static std::shared_ptr<const ComponentDescriptorProviderRegistry>
|
||||
sharedProviderRegistry();
|
||||
|
||||
private:
|
||||
friend HybridBase;
|
||||
|
||||
const ComponentFactory* delegate_;
|
||||
|
||||
static jni::local_ref<jhybriddata> initHybrid(
|
||||
jni::alias_ref<jclass>,
|
||||
ComponentFactory* delegate);
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
} // namespace facebook::react::CoreComponentsRegistry
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "Binding.h"
|
||||
#include "ComponentFactory.h"
|
||||
#include "CoreComponentsRegistry.h"
|
||||
#include "EventBeatManager.h"
|
||||
#include "EventEmitterWrapper.h"
|
||||
#include "JEmptyReactNativeConfig.h"
|
||||
@@ -23,7 +22,6 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
||||
facebook::react::EventEmitterWrapper::registerNatives();
|
||||
facebook::react::StateWrapperImpl::registerNatives();
|
||||
facebook::react::ComponentFactory::registerNatives();
|
||||
facebook::react::CoreComponentsRegistry::registerNatives();
|
||||
facebook::react::SurfaceHandlerBinding::registerNatives();
|
||||
facebook::react::JEmptyReactNativeConfig::registerNatives();
|
||||
});
|
||||
|
||||
+16
-33
@@ -18,56 +18,39 @@ namespace facebook::react {
|
||||
std::function<void(std::shared_ptr<const ComponentDescriptorProviderRegistry>)>
|
||||
DefaultComponentsRegistry::registerComponentDescriptorsFromEntryPoint{};
|
||||
|
||||
DefaultComponentsRegistry::DefaultComponentsRegistry(ComponentFactory* delegate)
|
||||
: delegate_(delegate) {}
|
||||
|
||||
std::shared_ptr<const ComponentDescriptorProviderRegistry>
|
||||
DefaultComponentsRegistry::sharedProviderRegistry() {
|
||||
auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry();
|
||||
|
||||
if (DefaultComponentsRegistry::registerComponentDescriptorsFromEntryPoint) {
|
||||
(DefaultComponentsRegistry::registerComponentDescriptorsFromEntryPoint)(
|
||||
providerRegistry);
|
||||
} else {
|
||||
LOG(WARNING)
|
||||
<< "Custom component descriptors were not configured from JNI_OnLoad";
|
||||
}
|
||||
|
||||
return providerRegistry;
|
||||
}
|
||||
|
||||
jni::local_ref<DefaultComponentsRegistry::jhybriddata>
|
||||
DefaultComponentsRegistry::initHybrid(
|
||||
void DefaultComponentsRegistry::setRegistryRunction(
|
||||
jni::alias_ref<jclass>,
|
||||
ComponentFactory* delegate) {
|
||||
auto instance = makeCxxInstance(delegate);
|
||||
|
||||
auto buildRegistryFunction =
|
||||
[](const EventDispatcher::Weak& eventDispatcher,
|
||||
const ContextContainer::Shared& contextContainer)
|
||||
-> ComponentDescriptorRegistry::Shared {
|
||||
delegate
|
||||
->buildRegistryFunction = [](const EventDispatcher::Weak& eventDispatcher,
|
||||
const ContextContainer::Shared&
|
||||
contextContainer) {
|
||||
ComponentDescriptorParameters params{
|
||||
.eventDispatcher = eventDispatcher,
|
||||
.contextContainer = contextContainer,
|
||||
.flavor = nullptr};
|
||||
|
||||
auto registry = DefaultComponentsRegistry::sharedProviderRegistry()
|
||||
->createComponentDescriptorRegistry(params);
|
||||
auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry();
|
||||
if (registerComponentDescriptorsFromEntryPoint) {
|
||||
registerComponentDescriptorsFromEntryPoint(providerRegistry);
|
||||
} else {
|
||||
LOG(WARNING)
|
||||
<< "Custom component descriptors were not configured from JNI_OnLoad";
|
||||
}
|
||||
|
||||
auto registry = providerRegistry->createComponentDescriptorRegistry(params);
|
||||
auto& mutableRegistry = const_cast<ComponentDescriptorRegistry&>(*registry);
|
||||
mutableRegistry.setFallbackComponentDescriptor(
|
||||
std::make_shared<UnimplementedNativeViewComponentDescriptor>(params));
|
||||
|
||||
return registry;
|
||||
};
|
||||
|
||||
delegate->buildRegistryFunction = buildRegistryFunction;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void DefaultComponentsRegistry::registerNatives() {
|
||||
registerHybrid({
|
||||
makeNativeMethod("initHybrid", DefaultComponentsRegistry::initHybrid),
|
||||
javaClassLocal()->registerNatives({
|
||||
makeNativeMethod(
|
||||
"register", DefaultComponentsRegistry::setRegistryRunction),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+2
-11
@@ -16,7 +16,7 @@
|
||||
namespace facebook::react {
|
||||
|
||||
class DefaultComponentsRegistry
|
||||
: public facebook::jni::HybridClass<DefaultComponentsRegistry> {
|
||||
: public facebook::jni::JavaClass<DefaultComponentsRegistry> {
|
||||
public:
|
||||
constexpr static auto kJavaDescriptor =
|
||||
"Lcom/facebook/react/defaults/DefaultComponentsRegistry;";
|
||||
@@ -27,17 +27,8 @@ class DefaultComponentsRegistry
|
||||
std::shared_ptr<const ComponentDescriptorProviderRegistry>)>
|
||||
registerComponentDescriptorsFromEntryPoint;
|
||||
|
||||
DefaultComponentsRegistry(ComponentFactory* delegate);
|
||||
|
||||
private:
|
||||
friend HybridBase;
|
||||
|
||||
static std::shared_ptr<const ComponentDescriptorProviderRegistry>
|
||||
sharedProviderRegistry();
|
||||
|
||||
const ComponentFactory* delegate_;
|
||||
|
||||
static jni::local_ref<jhybriddata> initHybrid(
|
||||
static void setRegistryRunction(
|
||||
jni::alias_ref<jclass>,
|
||||
ComponentFactory* delegate);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user