mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
e088a4fe9c
Summary: This new type will be valid in Flow strict mode and can be used by native modules and components to replace `Object`, with the same semantics. This unblocks the migration of the most modules in the React Native package to Flow strict. Changelog: [Internal] Add UnsafeObject type compatible with Flow strict mode to use in native modules and components Reviewed By: RSNara Differential Revision: D25540631 fbshipit-source-id: 60b80bbc84a53aecc747e3a1799cdf551e1859cd
155 lines
5.9 KiB
Plaintext
155 lines
5.9 KiB
Plaintext
/*
|
|
* 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.
|
|
*/
|
|
|
|
#import "RCTNativeSampleTurboModuleSpec.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<ObjCTurboModule &>(turboModule)
|
|
.invokeObjCMethod(rt, VoidKind, "voidFunc", @selector(voidFunc), 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<ObjCTurboModule &>(turboModule)
|
|
.invokeObjCMethod(rt, BooleanKind, "getBool", @selector(getBool:), 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<ObjCTurboModule &>(turboModule)
|
|
.invokeObjCMethod(rt, NumberKind, "getNumber", @selector(getNumber:), 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<ObjCTurboModule &>(turboModule)
|
|
.invokeObjCMethod(rt, StringKind, "getString", @selector(getString:), 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<ObjCTurboModule &>(turboModule)
|
|
.invokeObjCMethod(rt, ArrayKind, "getArray", @selector(getArray:), 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<ObjCTurboModule &>(turboModule)
|
|
.invokeObjCMethod(rt, ObjectKind, "getObject", @selector(getObject:), args, count);
|
|
}
|
|
|
|
static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getUnsafeObject(
|
|
facebook::jsi::Runtime &rt,
|
|
TurboModule &turboModule,
|
|
const facebook::jsi::Value *args,
|
|
size_t count)
|
|
{
|
|
return static_cast<ObjCTurboModule &>(turboModule)
|
|
.invokeObjCMethod(rt, ObjectKind, "getUnsafeObject", @selector(getUnsafeObject:), 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<ObjCTurboModule &>(turboModule)
|
|
.invokeObjCMethod(rt, NumberKind, "getRootTag", @selector(getRootTag:), 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<ObjCTurboModule &>(turboModule)
|
|
.invokeObjCMethod(rt, ObjectKind, "getValue", @selector(getValue:y:z:), 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<ObjCTurboModule &>(turboModule)
|
|
.invokeObjCMethod(rt, VoidKind, "getValueWithCallback", @selector(getValueWithCallback:), 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<ObjCTurboModule &>(turboModule)
|
|
.invokeObjCMethod(
|
|
rt, PromiseKind, "getValueWithPromise", @selector(getValueWithPromise:resolve:reject:), 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<ObjCTurboModule &>(turboModule)
|
|
.invokeObjCMethod(rt, ObjectKind, "getConstants", @selector(getConstants), args, count);
|
|
}
|
|
|
|
NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const ObjCTurboModule::InitParams ¶ms)
|
|
: ObjCTurboModule(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_["getUnsafeObject"] = MethodMetadata{1, __hostFunction_NativeSampleTurboModuleSpecJSI_getUnsafeObject};
|
|
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
|