mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate jscexecutor to kotlin (#38254)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38254 In this diff I'm migrating jscexecutor to kotlin changelog: [internal] internal Reviewed By: christophpurrer Differential Revision: D47309460 fbshipit-source-id: f3d04277813ff7314eb7e5b011475bd2d4c72c7f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6dc517a7fc
commit
561f843998
-37
@@ -1,37 +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.jscexecutor;
|
||||
|
||||
import com.facebook.jni.HybridData;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.JavaScriptExecutor;
|
||||
import com.facebook.react.bridge.ReadableNativeMap;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
@DoNotStrip
|
||||
public class JSCExecutor extends JavaScriptExecutor {
|
||||
|
||||
static {
|
||||
loadLibrary();
|
||||
}
|
||||
|
||||
public static void loadLibrary() throws UnsatisfiedLinkError {
|
||||
SoLoader.loadLibrary("jscexecutor");
|
||||
}
|
||||
|
||||
/* package */ JSCExecutor(ReadableNativeMap jscConfig) {
|
||||
super(initHybrid(jscConfig));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "JSCExecutor";
|
||||
}
|
||||
|
||||
private static native HybridData initHybrid(ReadableNativeMap jscConfig);
|
||||
}
|
||||
+36
@@ -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.
|
||||
*/
|
||||
|
||||
package com.facebook.react.jscexecutor
|
||||
|
||||
import com.facebook.jni.HybridData
|
||||
import com.facebook.proguard.annotations.DoNotStrip
|
||||
import com.facebook.react.bridge.JavaScriptExecutor
|
||||
import com.facebook.react.bridge.ReadableNativeMap
|
||||
import com.facebook.soloader.SoLoader
|
||||
|
||||
@DoNotStrip
|
||||
class JSCExecutor internal constructor(jscConfig: ReadableNativeMap) :
|
||||
JavaScriptExecutor(initHybrid(jscConfig)) {
|
||||
override fun getName(): String {
|
||||
return "JSCExecutor"
|
||||
}
|
||||
|
||||
companion object {
|
||||
init {
|
||||
loadLibrary()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@Throws(UnsatisfiedLinkError::class)
|
||||
fun loadLibrary() {
|
||||
SoLoader.loadLibrary("jscexecutor")
|
||||
}
|
||||
|
||||
private external fun initHybrid(jscConfig: ReadableNativeMap): HybridData?
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +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.jscexecutor;
|
||||
|
||||
import com.facebook.react.bridge.JavaScriptExecutor;
|
||||
import com.facebook.react.bridge.JavaScriptExecutorFactory;
|
||||
import com.facebook.react.bridge.WritableNativeMap;
|
||||
|
||||
public class JSCExecutorFactory implements JavaScriptExecutorFactory {
|
||||
private final String mAppName;
|
||||
private final String mDeviceName;
|
||||
|
||||
public JSCExecutorFactory(String appName, String deviceName) {
|
||||
this.mAppName = appName;
|
||||
this.mDeviceName = deviceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaScriptExecutor create() throws Exception {
|
||||
WritableNativeMap jscConfig = new WritableNativeMap();
|
||||
jscConfig.putString("OwnerIdentity", "ReactNative");
|
||||
jscConfig.putString("AppIdentity", mAppName);
|
||||
jscConfig.putString("DeviceIdentity", mDeviceName);
|
||||
return new JSCExecutor(jscConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSamplingProfiler() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Starting sampling profiler not supported on " + toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopSamplingProfiler(String filename) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Stopping sampling profiler not supported on " + toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JSIExecutor+JSCRuntime";
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.jscexecutor
|
||||
|
||||
import com.facebook.react.bridge.JavaScriptExecutor
|
||||
import com.facebook.react.bridge.JavaScriptExecutorFactory
|
||||
import com.facebook.react.bridge.WritableNativeMap
|
||||
|
||||
class JSCExecutorFactory(private val appName: String, private val deviceName: String) :
|
||||
JavaScriptExecutorFactory {
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun create(): JavaScriptExecutor {
|
||||
val jscConfig =
|
||||
WritableNativeMap().apply {
|
||||
putString("OwnerIdentity", "ReactNative")
|
||||
putString("AppIdentity", appName)
|
||||
putString("DeviceIdentity", deviceName)
|
||||
}
|
||||
return JSCExecutor(jscConfig)
|
||||
}
|
||||
|
||||
override fun startSamplingProfiler() {
|
||||
throw UnsupportedOperationException("Starting sampling profiler not supported on ${toString()}")
|
||||
}
|
||||
|
||||
override fun stopSamplingProfiler(filename: String) {
|
||||
throw UnsupportedOperationException("Stopping sampling profiler not supported on ${toString()}")
|
||||
}
|
||||
|
||||
override fun toString(): String = "JSIExecutor+JSCRuntime"
|
||||
}
|
||||
Reference in New Issue
Block a user