mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-06 00:43:38 +08:00
Merge ReactMethod and ReactSyncHook
Reviewed By: astreet Differential Revision: D4409726 fbshipit-source-id: 7a0091da754b114680772aa9c0a898b1aa721ba5
This commit is contained in:
committed by
Facebook Github Bot
parent
412acd237a
commit
59226f022c
@@ -9,6 +9,7 @@
|
||||
|
||||
package com.facebook.react.cxxbridge;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -19,6 +20,7 @@ import com.facebook.react.bridge.CatalystInstance;
|
||||
import com.facebook.react.bridge.ExecutorToken;
|
||||
import com.facebook.react.bridge.NativeArray;
|
||||
import com.facebook.react.bridge.NativeModuleLogger;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReadableNativeArray;
|
||||
import com.facebook.react.bridge.WritableNativeArray;
|
||||
import com.facebook.react.bridge.WritableNativeMap;
|
||||
@@ -38,6 +40,10 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
/* package */ class JavaModuleWrapper {
|
||||
@DoNotStrip
|
||||
public class MethodDescriptor {
|
||||
@DoNotStrip
|
||||
Method method;
|
||||
@DoNotStrip
|
||||
String signature;
|
||||
@DoNotStrip
|
||||
String name;
|
||||
@DoNotStrip
|
||||
@@ -46,7 +52,7 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
|
||||
private final CatalystInstance mCatalystInstance;
|
||||
private final ModuleHolder mModuleHolder;
|
||||
private final ArrayList<BaseJavaModule.JavaMethod> mMethods;
|
||||
private final ArrayList<NativeModule.NativeMethod> mMethods;
|
||||
|
||||
public JavaModuleWrapper(CatalystInstance catalystinstance, ModuleHolder moduleHolder) {
|
||||
mCatalystInstance = catalystinstance;
|
||||
@@ -67,19 +73,21 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
@DoNotStrip
|
||||
public List<MethodDescriptor> getMethodDescriptors() {
|
||||
ArrayList<MethodDescriptor> descs = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, BaseJavaModule.NativeMethod> entry :
|
||||
getModule().getMethods().entrySet()) {
|
||||
for (Map.Entry<String, NativeModule.NativeMethod> entry :
|
||||
getModule().getMethods().entrySet()) {
|
||||
MethodDescriptor md = new MethodDescriptor();
|
||||
md.name = entry.getKey();
|
||||
md.type = entry.getValue().getType();
|
||||
|
||||
BaseJavaModule.JavaMethod method = (BaseJavaModule.JavaMethod) entry.getValue();
|
||||
if (md.type == BaseJavaModule.METHOD_TYPE_SYNC) {
|
||||
md.signature = method.getSignature();
|
||||
md.method = method.getMethod();
|
||||
}
|
||||
mMethods.add(method);
|
||||
|
||||
descs.add(md);
|
||||
}
|
||||
|
||||
return descs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user