mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
TurboModule Android: move SampleTurboModule impl and spec to OSS
Summary: This is the Java/JNI impl of the NativeSampleTurboModule.js, just like on iOS. The files here are supposed to be generated by the react-native-codegen, but they are checked in to the repo for easier build integration with RNTester. Changelog: [Internal] Reviewed By: hramos Differential Revision: D23985746 fbshipit-source-id: 46340d778f3d964efe5b538d15ebe0f2cab04862
This commit is contained in:
1 parent
b931bd33fe
commit
b9a1ea9e9e
11 files changed
+536
-6
No files matched your search
+200
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// NOTE: This entire file should be codegen'ed.
|
||||
|
||||
#include <ReactCommon/SampleTurboModuleSpec.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
static facebook::jsi::Value
|
||||
__hostFunction_NativeSampleTurboModuleSpecJSI_voidFunc(
|
||||
facebook::jsi::Runtime &rt,
|
||||
TurboModule &turboModule,
|
||||
const facebook::jsi::Value *args,
|
||||
size_t count) {
|
||||
return static_cast<JavaTurboModule &>(turboModule)
|
||||
.invokeJavaMethod(rt, VoidKind, "voidFunc", "()V", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value
|
||||
__hostFunction_NativeSampleTurboModuleSpecJSI_getBool(
|
||||
facebook::jsi::Runtime &rt,
|
||||
TurboModule &turboModule,
|
||||
const facebook::jsi::Value *args,
|
||||
size_t count) {
|
||||
return static_cast<JavaTurboModule &>(turboModule)
|
||||
.invokeJavaMethod(rt, BooleanKind, "getBool", "(Z)Z", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value
|
||||
__hostFunction_NativeSampleTurboModuleSpecJSI_getNumber(
|
||||
facebook::jsi::Runtime &rt,
|
||||
TurboModule &turboModule,
|
||||
const facebook::jsi::Value *args,
|
||||
size_t count) {
|
||||
return static_cast<JavaTurboModule &>(turboModule)
|
||||
.invokeJavaMethod(rt, NumberKind, "getNumber", "(D)D", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value
|
||||
__hostFunction_NativeSampleTurboModuleSpecJSI_getString(
|
||||
facebook::jsi::Runtime &rt,
|
||||
TurboModule &turboModule,
|
||||
const facebook::jsi::Value *args,
|
||||
size_t count) {
|
||||
return static_cast<JavaTurboModule &>(turboModule)
|
||||
.invokeJavaMethod(
|
||||
rt,
|
||||
StringKind,
|
||||
"getString",
|
||||
"(Ljava/lang/String;)Ljava/lang/String;",
|
||||
args,
|
||||
count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value
|
||||
__hostFunction_NativeSampleTurboModuleSpecJSI_getArray(
|
||||
facebook::jsi::Runtime &rt,
|
||||
TurboModule &turboModule,
|
||||
const facebook::jsi::Value *args,
|
||||
size_t count) {
|
||||
return static_cast<JavaTurboModule &>(turboModule)
|
||||
.invokeJavaMethod(
|
||||
rt,
|
||||
ArrayKind,
|
||||
"getArray",
|
||||
"(Lcom/facebook/react/bridge/ReadableArray;)Lcom/facebook/react/bridge/WritableArray;",
|
||||
args,
|
||||
count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value
|
||||
__hostFunction_NativeSampleTurboModuleSpecJSI_getObject(
|
||||
facebook::jsi::Runtime &rt,
|
||||
TurboModule &turboModule,
|
||||
const facebook::jsi::Value *args,
|
||||
size_t count) {
|
||||
return static_cast<JavaTurboModule &>(turboModule)
|
||||
.invokeJavaMethod(
|
||||
rt,
|
||||
ObjectKind,
|
||||
"getObject",
|
||||
"(Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/bridge/WritableMap;",
|
||||
args,
|
||||
count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value
|
||||
__hostFunction_NativeSampleTurboModuleSpecJSI_getRootTag(
|
||||
facebook::jsi::Runtime &rt,
|
||||
TurboModule &turboModule,
|
||||
const facebook::jsi::Value *args,
|
||||
size_t count) {
|
||||
return static_cast<JavaTurboModule &>(turboModule)
|
||||
.invokeJavaMethod(rt, NumberKind, "getRootTag", "(D)D", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value
|
||||
__hostFunction_NativeSampleTurboModuleSpecJSI_getValue(
|
||||
facebook::jsi::Runtime &rt,
|
||||
TurboModule &turboModule,
|
||||
const facebook::jsi::Value *args,
|
||||
size_t count) {
|
||||
return static_cast<JavaTurboModule &>(turboModule)
|
||||
.invokeJavaMethod(
|
||||
rt,
|
||||
ObjectKind,
|
||||
"getValue",
|
||||
"(DLjava/lang/String;Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/bridge/WritableMap;",
|
||||
args,
|
||||
count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value
|
||||
__hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithCallback(
|
||||
facebook::jsi::Runtime &rt,
|
||||
TurboModule &turboModule,
|
||||
const facebook::jsi::Value *args,
|
||||
size_t count) {
|
||||
return static_cast<JavaTurboModule &>(turboModule)
|
||||
.invokeJavaMethod(
|
||||
rt,
|
||||
VoidKind,
|
||||
"getValueWithCallback",
|
||||
"(Lcom/facebook/react/bridge/Callback;)V",
|
||||
args,
|
||||
count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value
|
||||
__hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithPromise(
|
||||
facebook::jsi::Runtime &rt,
|
||||
TurboModule &turboModule,
|
||||
const facebook::jsi::Value *args,
|
||||
size_t count) {
|
||||
return static_cast<JavaTurboModule &>(turboModule)
|
||||
.invokeJavaMethod(
|
||||
rt,
|
||||
PromiseKind,
|
||||
"getValueWithPromise",
|
||||
"(ZLcom/facebook/react/bridge/Promise;)V",
|
||||
args,
|
||||
count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value
|
||||
__hostFunction_NativeSampleTurboModuleSpecJSI_getConstants(
|
||||
facebook::jsi::Runtime &rt,
|
||||
TurboModule &turboModule,
|
||||
const facebook::jsi::Value *args,
|
||||
size_t count) {
|
||||
return static_cast<JavaTurboModule &>(turboModule)
|
||||
.invokeJavaMethod(
|
||||
rt, ObjectKind, "getConstants", "()Ljava/util/Map;", args, count);
|
||||
}
|
||||
|
||||
NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(
|
||||
const JavaTurboModule::InitParams ¶ms)
|
||||
: JavaTurboModule(params) {
|
||||
methodMap_["voidFunc"] =
|
||||
MethodMetadata{0, __hostFunction_NativeSampleTurboModuleSpecJSI_voidFunc};
|
||||
|
||||
methodMap_["getBool"] =
|
||||
MethodMetadata{1, __hostFunction_NativeSampleTurboModuleSpecJSI_getBool};
|
||||
|
||||
methodMap_["getNumber"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getNumber};
|
||||
|
||||
methodMap_["getString"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getString};
|
||||
|
||||
methodMap_["getArray"] =
|
||||
MethodMetadata{1, __hostFunction_NativeSampleTurboModuleSpecJSI_getArray};
|
||||
|
||||
methodMap_["getObject"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getObject};
|
||||
|
||||
methodMap_["getRootTag"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getRootTag};
|
||||
|
||||
methodMap_["getValue"] =
|
||||
MethodMetadata{3, __hostFunction_NativeSampleTurboModuleSpecJSI_getValue};
|
||||
|
||||
methodMap_["getValueWithCallback"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithCallback};
|
||||
|
||||
methodMap_["getValueWithPromise"] = MethodMetadata{
|
||||
1, __hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithPromise};
|
||||
|
||||
methodMap_["getConstants"] = MethodMetadata{
|
||||
0, __hostFunction_NativeSampleTurboModuleSpecJSI_getConstants};
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
Reference in new issue
Block a user