Skip to content

Commit 5413304

Browse files
javachefacebook-github-bot
authored andcommitted
Convert com.facebook.react.runtime.ReactHostImpl to Kotlin (facebook#51017)
Summary: Pull Request resolved: facebook#51017 Changelog: [Internal] Reviewed By: rshest Differential Revision: D73846053 fbshipit-source-id: 98017000e8f10df4156b232bc8b5d6e132502ea5
1 parent 7e5a266 commit 5413304

File tree

12 files changed

+1499
-1836
lines changed

12 files changed

+1499
-1836
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3222,9 +3222,9 @@ public abstract class com/facebook/react/runtime/JSRuntimeFactory {
32223222
public fun <init> (Lcom/facebook/jni/HybridData;)V
32233223
}
32243224

3225-
public class com/facebook/react/runtime/ReactHostImpl : com/facebook/react/ReactHost {
3226-
public fun <init> (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;ZZ)V
3225+
public final class com/facebook/react/runtime/ReactHostImpl : com/facebook/react/ReactHost {
32273226
public fun <init> (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;ZZLcom/facebook/react/devsupport/DevSupportManagerFactory;)V
3227+
public synthetic fun <init> (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;ZZLcom/facebook/react/devsupport/DevSupportManagerFactory;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
32283228
public fun <init> (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;ZZ)V
32293229
public fun addBeforeDestroyListener (Lkotlin/jvm/functions/Function0;)V
32303230
public fun addReactInstanceEventListener (Lcom/facebook/react/ReactInstanceEventListener;)V

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/MemoryPressureListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
package com.facebook.react.bridge
99

1010
/** Listener interface for memory pressure events. */
11-
public interface MemoryPressureListener {
11+
public fun interface MemoryPressureListener {
1212
/** Called when the system generates a memory warning. */
1313
public fun handleMemoryPressure(level: Int)
1414
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessAtomicRef.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class BridgelessAtomicRef<T>(
1414
@field:Volatile @get:Synchronized @get:JvmName("getNullable") var value: T? = null
1515
) {
1616

17-
internal interface Provider<T> {
17+
internal fun interface Provider<T> {
1818
fun get(): T
1919
}
2020

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessCatalystInstance.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import com.facebook.react.bridge.RuntimeExecutor
2424
import com.facebook.react.bridge.RuntimeScheduler
2525
import com.facebook.react.bridge.UIManager
2626
import com.facebook.react.bridge.queue.ReactQueueConfiguration
27+
import com.facebook.react.common.annotations.FrameworkAPI
2728
import com.facebook.react.common.annotations.VisibleForTesting
2829
import com.facebook.react.common.annotations.internal.LegacyArchitecture
2930
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
@@ -35,6 +36,7 @@ import com.facebook.react.turbomodule.core.interfaces.NativeMethodCallInvokerHol
3536
message =
3637
"This class is deprecated, please to migrate to new architecture using [com.facebook.react.defaults.DefaultReactHost] instead.")
3738
@LegacyArchitecture
39+
@FrameworkAPI
3840
internal class BridgelessCatalystInstance(private val reactHost: ReactHostImpl) : CatalystInstance {
3941

4042
override fun handleMemoryPressure(level: Int) {
@@ -94,13 +96,13 @@ internal class BridgelessCatalystInstance(private val reactHost: ReactHostImpl)
9496

9597
@get:Deprecated("Deprecated in Java")
9698
public override val javaScriptContextHolder: JavaScriptContextHolder
97-
get() = reactHost.getJavaScriptContextHolder()!!
99+
get() = reactHost.javaScriptContextHolder!!
98100

99101
@Suppress("INAPPLICABLE_JVM_NAME")
100102
@get:Deprecated("Deprecated in Java")
101103
@get:JvmName("getJSCallInvokerHolder") // This is needed to keep backward compatibility
102104
public override val jsCallInvokerHolder: CallInvokerHolder
103-
get() = reactHost.getJSCallInvokerHolder()!!
105+
get() = reactHost.jsCallInvokerHolder!!
104106

105107
public override val nativeMethodCallInvokerHolder: NativeMethodCallInvokerHolder
106108
get() =
@@ -117,13 +119,13 @@ internal class BridgelessCatalystInstance(private val reactHost: ReactHostImpl)
117119
reactHost.getNativeModule(moduleName)
118120

119121
public override val nativeModules: Collection<NativeModule>
120-
get() = reactHost.getNativeModules()
122+
get() = reactHost.nativeModules
121123

122124
public override val reactQueueConfiguration: ReactQueueConfiguration
123125
get() = reactHost.reactQueueConfiguration!!
124126

125127
public override val runtimeExecutor: RuntimeExecutor?
126-
get() = reactHost.getRuntimeExecutor()
128+
get() = reactHost.runtimeExecutor
127129

128130
public override val runtimeScheduler: RuntimeScheduler
129131
get() = throw UnsupportedOperationException("Unimplemented method 'getRuntimeScheduler'")

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessReactContext.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ internal class BridgelessReactContext(context: Context, private val reactHost: R
6363
@Deprecated("This method is deprecated, please use UIManagerHelper.getUIManager() instead.")
6464
override fun getFabricUIManager(): UIManager? = reactHost.uiManager
6565

66+
@OptIn(FrameworkAPI::class)
6667
override fun getCatalystInstance(): CatalystInstance {
6768
if (ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE) {
6869
throw UnsupportedOperationException(
@@ -136,7 +137,7 @@ internal class BridgelessReactContext(context: Context, private val reactHost: R
136137
override fun <T : NativeModule> hasNativeModule(nativeModuleInterface: Class<T>): Boolean =
137138
reactHost.hasNativeModule(nativeModuleInterface)
138139

139-
override fun getNativeModules(): MutableCollection<NativeModule> = reactHost.nativeModules
140+
override fun getNativeModules(): Collection<NativeModule> = reactHost.nativeModules
140141

141142
override fun <T : NativeModule> getNativeModule(nativeModuleInterface: Class<T>): T? =
142143
reactHost.getNativeModule(nativeModuleInterface)

0 commit comments

Comments
 (0)