2022-11-09 10:48:49 -08:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "NativeCxxModuleExample.h"
|
2023-04-03 08:34:59 -07:00
|
|
|
#include <react/debug/react_native_assert.h>
|
2025-07-08 21:10:36 -07:00
|
|
|
#include <iomanip>
|
|
|
|
|
#include <ostream>
|
|
|
|
|
#include <sstream>
|
2025-07-22 00:48:40 -07:00
|
|
|
#include <utility>
|
2022-11-09 10:48:49 -08:00
|
|
|
|
|
|
|
|
namespace facebook::react {
|
|
|
|
|
|
2025-07-08 21:10:36 -07:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
std::string to_string_with_precision(double value, int precision = 2) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << std::setprecision(precision) << std::fixed << value;
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2022-11-09 10:48:49 -08:00
|
|
|
NativeCxxModuleExample::NativeCxxModuleExample(
|
|
|
|
|
std::shared_ptr<CallInvoker> jsInvoker)
|
|
|
|
|
: NativeCxxModuleExampleCxxSpec(std::move(jsInvoker)) {}
|
|
|
|
|
|
|
|
|
|
void NativeCxxModuleExample::getValueWithCallback(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
|
|
|
|
const AsyncCallback<std::string>& callback) {
|
2022-11-09 10:48:49 -08:00
|
|
|
callback({"value from callback!"});
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-09 11:38:54 -08:00
|
|
|
std::function<void()> NativeCxxModuleExample::setValueCallbackWithSubscription(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2023-11-09 11:38:54 -08:00
|
|
|
AsyncCallback<std::string> callback) {
|
|
|
|
|
valueCallback_ = std::make_optional(callback);
|
|
|
|
|
return [&]() {
|
|
|
|
|
if (valueCallback_.has_value()) {
|
|
|
|
|
valueCallback_.value()({"value from callback on clean up!"});
|
|
|
|
|
valueCallback_ = std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-09 10:48:49 -08:00
|
|
|
std::vector<std::optional<ObjectStruct>> NativeCxxModuleExample::getArray(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2022-11-09 10:48:49 -08:00
|
|
|
std::vector<std::optional<ObjectStruct>> arg) {
|
|
|
|
|
return arg;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-22 00:48:40 -07:00
|
|
|
bool NativeCxxModuleExample::getBool(jsi::Runtime& /*rt*/, bool arg) {
|
2022-11-09 10:48:49 -08:00
|
|
|
return arg;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-22 00:48:40 -07:00
|
|
|
ConstantsStruct NativeCxxModuleExample::getConstants(jsi::Runtime& /*rt*/) {
|
2022-11-09 10:48:49 -08:00
|
|
|
return ConstantsStruct{true, 69, "react-native"};
|
|
|
|
|
}
|
|
|
|
|
|
Generate enum types that would be allowed to be used as well as string/number in c++ turbo modules generators (#36030)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36030
Generate enum types in c++ turbo modules.
For enums in the ts schema file such as:
```
export enum NumEnum {
ONE = 1,
TWO = 2,
}
```
This would export enums and the relevant Bridging to js and from js code to the spec H files such as:
```
#pragma mark - SampleTurboModuleCxxNumEnum
enum SampleTurboModuleCxxNumEnum { ONE, TWO };
template <>
struct Bridging<SampleTurboModuleCxxNumEnum> {
static SampleTurboModuleCxxNumEnum fromJs(jsi::Runtime &rt, int32_t value) {
if (value == 1) {
return SampleTurboModuleCxxNumEnum::ONE;
} else if (value == 2) {
return SampleTurboModuleCxxNumEnum::TWO;
} else {
throw jsi::JSError(rt, "No appropriate enum member found for value");
}
}
static jsi::Value toJs(jsi::Runtime &rt, SampleTurboModuleCxxNumEnum value) {
if (value == SampleTurboModuleCxxNumEnum::ONE) {
return bridging::toJs(rt, 1);
} else if (value == SampleTurboModuleCxxNumEnum::TWO) {
return bridging::toJs(rt, 2);
} else {
throw jsi::JSError(rt, "No appropriate enum member found for enum value");
}
}
};
```
That code would allow us to use these enums in the cxx files like this:
```
NativeCxxModuleExampleCxxEnumInt getNumEnum(
jsi::Runtime &rt,
NativeCxxModuleExampleCxxEnumInt arg);
```
Changelog: [General] [Added] Generate enum types that would be allowed to be used as well as string/number in c++ turbo modules generators
Reviewed By: christophpurrer
Differential Revision: D42884147
fbshipit-source-id: d34d1fc7ba268b570821dc108444196f69a431b2
2023-02-13 15:09:44 -08:00
|
|
|
CustomEnumInt NativeCxxModuleExample::getCustomEnum(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
Generate enum types that would be allowed to be used as well as string/number in c++ turbo modules generators (#36030)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36030
Generate enum types in c++ turbo modules.
For enums in the ts schema file such as:
```
export enum NumEnum {
ONE = 1,
TWO = 2,
}
```
This would export enums and the relevant Bridging to js and from js code to the spec H files such as:
```
#pragma mark - SampleTurboModuleCxxNumEnum
enum SampleTurboModuleCxxNumEnum { ONE, TWO };
template <>
struct Bridging<SampleTurboModuleCxxNumEnum> {
static SampleTurboModuleCxxNumEnum fromJs(jsi::Runtime &rt, int32_t value) {
if (value == 1) {
return SampleTurboModuleCxxNumEnum::ONE;
} else if (value == 2) {
return SampleTurboModuleCxxNumEnum::TWO;
} else {
throw jsi::JSError(rt, "No appropriate enum member found for value");
}
}
static jsi::Value toJs(jsi::Runtime &rt, SampleTurboModuleCxxNumEnum value) {
if (value == SampleTurboModuleCxxNumEnum::ONE) {
return bridging::toJs(rt, 1);
} else if (value == SampleTurboModuleCxxNumEnum::TWO) {
return bridging::toJs(rt, 2);
} else {
throw jsi::JSError(rt, "No appropriate enum member found for enum value");
}
}
};
```
That code would allow us to use these enums in the cxx files like this:
```
NativeCxxModuleExampleCxxEnumInt getNumEnum(
jsi::Runtime &rt,
NativeCxxModuleExampleCxxEnumInt arg);
```
Changelog: [General] [Added] Generate enum types that would be allowed to be used as well as string/number in c++ turbo modules generators
Reviewed By: christophpurrer
Differential Revision: D42884147
fbshipit-source-id: d34d1fc7ba268b570821dc108444196f69a431b2
2023-02-13 15:09:44 -08:00
|
|
|
CustomEnumInt arg) {
|
2022-11-09 10:48:49 -08:00
|
|
|
return arg;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 13:58:39 -07:00
|
|
|
std::shared_ptr<CustomHostObject> NativeCxxModuleExample::getCustomHostObject(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/) {
|
2023-04-14 13:58:39 -07:00
|
|
|
return std::make_shared<CustomHostObject>(
|
|
|
|
|
std::make_shared<CustomHostObjectRef>("answer", 42));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string NativeCxxModuleExample::consumeCustomHostObject(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2023-04-14 13:58:39 -07:00
|
|
|
std::shared_ptr<CustomHostObject> arg) {
|
|
|
|
|
auto value = arg->getValue();
|
|
|
|
|
return value->a_ + std::to_string(value->b_);
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-04 05:54:50 -08:00
|
|
|
BinaryTreeNode NativeCxxModuleExample::getBinaryTreeNode(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2023-12-04 05:54:50 -08:00
|
|
|
BinaryTreeNode arg) {
|
|
|
|
|
return arg;
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-04 04:19:47 -08:00
|
|
|
GraphNode NativeCxxModuleExample::getGraphNode(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2023-12-04 04:19:47 -08:00
|
|
|
GraphNode arg) {
|
|
|
|
|
if (arg.neighbors) {
|
|
|
|
|
arg.neighbors->emplace_back(GraphNode{.label = "top"});
|
|
|
|
|
arg.neighbors->emplace_back(GraphNode{.label = "down"});
|
|
|
|
|
}
|
|
|
|
|
return arg;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-23 10:23:36 -07:00
|
|
|
NativeCxxModuleExampleEnumInt NativeCxxModuleExample::getNumEnum(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2024-05-23 10:23:36 -07:00
|
|
|
NativeCxxModuleExampleEnumInt arg) {
|
2024-04-30 21:52:09 -07:00
|
|
|
return arg;
|
Generate enum types that would be allowed to be used as well as string/number in c++ turbo modules generators (#36030)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36030
Generate enum types in c++ turbo modules.
For enums in the ts schema file such as:
```
export enum NumEnum {
ONE = 1,
TWO = 2,
}
```
This would export enums and the relevant Bridging to js and from js code to the spec H files such as:
```
#pragma mark - SampleTurboModuleCxxNumEnum
enum SampleTurboModuleCxxNumEnum { ONE, TWO };
template <>
struct Bridging<SampleTurboModuleCxxNumEnum> {
static SampleTurboModuleCxxNumEnum fromJs(jsi::Runtime &rt, int32_t value) {
if (value == 1) {
return SampleTurboModuleCxxNumEnum::ONE;
} else if (value == 2) {
return SampleTurboModuleCxxNumEnum::TWO;
} else {
throw jsi::JSError(rt, "No appropriate enum member found for value");
}
}
static jsi::Value toJs(jsi::Runtime &rt, SampleTurboModuleCxxNumEnum value) {
if (value == SampleTurboModuleCxxNumEnum::ONE) {
return bridging::toJs(rt, 1);
} else if (value == SampleTurboModuleCxxNumEnum::TWO) {
return bridging::toJs(rt, 2);
} else {
throw jsi::JSError(rt, "No appropriate enum member found for enum value");
}
}
};
```
That code would allow us to use these enums in the cxx files like this:
```
NativeCxxModuleExampleCxxEnumInt getNumEnum(
jsi::Runtime &rt,
NativeCxxModuleExampleCxxEnumInt arg);
```
Changelog: [General] [Added] Generate enum types that would be allowed to be used as well as string/number in c++ turbo modules generators
Reviewed By: christophpurrer
Differential Revision: D42884147
fbshipit-source-id: d34d1fc7ba268b570821dc108444196f69a431b2
2023-02-13 15:09:44 -08:00
|
|
|
}
|
|
|
|
|
|
2024-05-23 10:23:36 -07:00
|
|
|
NativeCxxModuleExampleEnumStr NativeCxxModuleExample::getStrEnum(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2024-05-23 10:23:36 -07:00
|
|
|
NativeCxxModuleExampleEnumNone /*arg*/) {
|
|
|
|
|
return NativeCxxModuleExampleEnumStr::SB;
|
Generate enum types that would be allowed to be used as well as string/number in c++ turbo modules generators (#36030)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36030
Generate enum types in c++ turbo modules.
For enums in the ts schema file such as:
```
export enum NumEnum {
ONE = 1,
TWO = 2,
}
```
This would export enums and the relevant Bridging to js and from js code to the spec H files such as:
```
#pragma mark - SampleTurboModuleCxxNumEnum
enum SampleTurboModuleCxxNumEnum { ONE, TWO };
template <>
struct Bridging<SampleTurboModuleCxxNumEnum> {
static SampleTurboModuleCxxNumEnum fromJs(jsi::Runtime &rt, int32_t value) {
if (value == 1) {
return SampleTurboModuleCxxNumEnum::ONE;
} else if (value == 2) {
return SampleTurboModuleCxxNumEnum::TWO;
} else {
throw jsi::JSError(rt, "No appropriate enum member found for value");
}
}
static jsi::Value toJs(jsi::Runtime &rt, SampleTurboModuleCxxNumEnum value) {
if (value == SampleTurboModuleCxxNumEnum::ONE) {
return bridging::toJs(rt, 1);
} else if (value == SampleTurboModuleCxxNumEnum::TWO) {
return bridging::toJs(rt, 2);
} else {
throw jsi::JSError(rt, "No appropriate enum member found for enum value");
}
}
};
```
That code would allow us to use these enums in the cxx files like this:
```
NativeCxxModuleExampleCxxEnumInt getNumEnum(
jsi::Runtime &rt,
NativeCxxModuleExampleCxxEnumInt arg);
```
Changelog: [General] [Added] Generate enum types that would be allowed to be used as well as string/number in c++ turbo modules generators
Reviewed By: christophpurrer
Differential Revision: D42884147
fbshipit-source-id: d34d1fc7ba268b570821dc108444196f69a431b2
2023-02-13 15:09:44 -08:00
|
|
|
}
|
|
|
|
|
|
2022-11-09 10:48:49 -08:00
|
|
|
std::map<std::string, std::optional<int32_t>> NativeCxxModuleExample::getMap(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2022-11-09 10:48:49 -08:00
|
|
|
std::map<std::string, std::optional<int32_t>> arg) {
|
|
|
|
|
return arg;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-22 00:48:40 -07:00
|
|
|
double NativeCxxModuleExample::getNumber(jsi::Runtime& /*rt*/, double arg) {
|
2022-11-09 10:48:49 -08:00
|
|
|
return arg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ObjectStruct NativeCxxModuleExample::getObject(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2022-11-09 10:48:49 -08:00
|
|
|
ObjectStruct arg) {
|
|
|
|
|
return arg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::set<float> NativeCxxModuleExample::getSet(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2022-11-09 10:48:49 -08:00
|
|
|
std::set<float> arg) {
|
|
|
|
|
return arg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string NativeCxxModuleExample::getString(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2022-11-09 10:48:49 -08:00
|
|
|
std::string arg) {
|
|
|
|
|
return arg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string NativeCxxModuleExample::getUnion(
|
2023-09-04 10:55:18 -07:00
|
|
|
jsi::Runtime& rt,
|
2022-11-09 10:48:49 -08:00
|
|
|
float x,
|
2025-07-22 00:48:40 -07:00
|
|
|
const std::string& y,
|
2022-11-09 10:48:49 -08:00
|
|
|
jsi::Object z) {
|
2025-07-08 21:10:36 -07:00
|
|
|
std::string result =
|
|
|
|
|
"x: " + to_string_with_precision(x) + ", y: " + y + ", z: { ";
|
2022-11-09 10:48:49 -08:00
|
|
|
if (z.hasProperty(rt, "value")) {
|
|
|
|
|
result += "value: ";
|
2025-07-08 21:10:36 -07:00
|
|
|
result +=
|
|
|
|
|
to_string_with_precision(z.getProperty(rt, "value").getNumber(), 0);
|
2022-11-09 10:48:49 -08:00
|
|
|
} else if (z.hasProperty(rt, "low")) {
|
|
|
|
|
result += "low: ";
|
|
|
|
|
result += z.getProperty(rt, "low").getString(rt).utf8(rt);
|
|
|
|
|
}
|
|
|
|
|
result += " }";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValueStruct NativeCxxModuleExample::getValue(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2022-11-09 10:48:49 -08:00
|
|
|
double x,
|
|
|
|
|
std::string y,
|
|
|
|
|
ObjectStruct z) {
|
2025-07-22 00:48:40 -07:00
|
|
|
ValueStruct result{x, std::move(y), std::move(z)};
|
2022-11-09 10:48:49 -08:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AsyncPromise<std::string> NativeCxxModuleExample::getValueWithPromise(
|
2023-09-04 10:55:18 -07:00
|
|
|
jsi::Runtime& rt,
|
2022-11-09 10:48:49 -08:00
|
|
|
bool error) {
|
|
|
|
|
auto promise = AsyncPromise<std::string>(rt, jsInvoker_);
|
|
|
|
|
if (error) {
|
|
|
|
|
promise.reject("intentional promise rejection");
|
|
|
|
|
} else {
|
|
|
|
|
promise.resolve("result!");
|
|
|
|
|
}
|
|
|
|
|
return promise;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-23 03:10:25 -07:00
|
|
|
std::optional<bool> NativeCxxModuleExample::getWithWithOptionalArgs(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2023-03-22 16:57:40 -07:00
|
|
|
std::optional<bool> optionalArg) {
|
2023-03-23 03:10:25 -07:00
|
|
|
return optionalArg;
|
2023-03-22 16:57:40 -07:00
|
|
|
}
|
|
|
|
|
|
2025-07-22 00:48:40 -07:00
|
|
|
void NativeCxxModuleExample::voidFunc(jsi::Runtime& /*rt*/) {
|
2024-06-11 21:12:33 -07:00
|
|
|
// Emit some events
|
|
|
|
|
emitOnPress();
|
|
|
|
|
emitOnClick<std::string>("value from callback on click!");
|
|
|
|
|
emitOnChange(ObjectStruct{1, "two", std::nullopt});
|
2025-10-26 23:40:59 -07:00
|
|
|
emitOnSubmit(
|
|
|
|
|
std::vector{
|
|
|
|
|
ObjectStruct{1, "two", std::nullopt},
|
|
|
|
|
ObjectStruct{3, "four", std::nullopt},
|
|
|
|
|
ObjectStruct{5, "six", std::nullopt}});
|
2024-08-19 08:26:20 -07:00
|
|
|
emitOnEvent(NativeCxxModuleExampleEnumNone::NA);
|
2022-11-09 10:48:49 -08:00
|
|
|
}
|
|
|
|
|
|
2025-07-06 19:53:51 -07:00
|
|
|
AsyncPromise<> NativeCxxModuleExample::voidPromise(jsi::Runtime& rt) {
|
|
|
|
|
AsyncPromise<> promise(rt, jsInvoker_);
|
|
|
|
|
promise.resolve();
|
|
|
|
|
return promise;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-22 00:48:40 -07:00
|
|
|
void NativeCxxModuleExample::setMenu(jsi::Runtime& /*rt*/, MenuItem menuItem) {
|
2023-12-05 23:27:06 -08:00
|
|
|
menuItem.onPress("value", true);
|
|
|
|
|
if (menuItem.items) {
|
2025-07-22 00:48:40 -07:00
|
|
|
for (const auto& subMenuItem : *menuItem.items) {
|
2023-12-05 23:27:06 -08:00
|
|
|
subMenuItem.onPress("another value", false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-24 06:49:14 -08:00
|
|
|
void NativeCxxModuleExample::emitCustomDeviceEvent(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
2024-04-30 11:16:57 -07:00
|
|
|
const std::string& eventName) {
|
2023-02-24 06:49:14 -08:00
|
|
|
// Test emitting device events (RCTDeviceEventEmitter.emit) from C++
|
2024-04-30 11:16:57 -07:00
|
|
|
// TurboModule with arbitrary arguments. This can be called from any thread
|
2023-02-24 06:49:14 -08:00
|
|
|
emitDeviceEvent(
|
2024-04-30 11:16:57 -07:00
|
|
|
eventName,
|
|
|
|
|
[jsInvoker = jsInvoker_](
|
|
|
|
|
jsi::Runtime& rt, std::vector<jsi::Value>& args) {
|
2025-10-26 23:40:59 -07:00
|
|
|
args.emplace_back(
|
|
|
|
|
jsi::Array::createWithElements(
|
|
|
|
|
rt,
|
|
|
|
|
jsi::Value(true),
|
|
|
|
|
jsi::Value(42),
|
|
|
|
|
jsi::String::createFromAscii(rt, "stringArg"),
|
|
|
|
|
bridging::toJs(
|
|
|
|
|
rt, CustomDeviceEvent{"one", 2, std::nullopt}, jsInvoker)));
|
2023-02-24 06:49:14 -08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-22 00:48:40 -07:00
|
|
|
void NativeCxxModuleExample::voidFuncThrows(jsi::Runtime& /*rt*/) {
|
2023-04-03 08:34:59 -07:00
|
|
|
throw std::runtime_error("Intentional exception from Cxx voidFuncThrows");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ObjectStruct NativeCxxModuleExample::getObjectThrows(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
|
|
|
|
const ObjectStruct& /*arg*/) {
|
2023-04-03 08:34:59 -07:00
|
|
|
throw std::runtime_error("Intentional exception from Cxx getObjectThrows");
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-22 00:48:40 -07:00
|
|
|
AsyncPromise<> NativeCxxModuleExample::promiseThrows(jsi::Runtime& /*rt*/) {
|
2023-04-03 08:34:59 -07:00
|
|
|
throw std::runtime_error("Intentional exception from Cxx promiseThrows");
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-22 00:48:40 -07:00
|
|
|
void NativeCxxModuleExample::voidFuncAssert(jsi::Runtime& /*rt*/) {
|
2023-04-03 08:34:59 -07:00
|
|
|
react_native_assert(false && "Intentional assert from Cxx voidFuncAssert");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ObjectStruct NativeCxxModuleExample::getObjectAssert(
|
2025-07-22 00:48:40 -07:00
|
|
|
jsi::Runtime& /*rt*/,
|
|
|
|
|
const ObjectStruct& /*arg*/) {
|
2023-04-03 08:34:59 -07:00
|
|
|
react_native_assert(false && "Intentional assert from Cxx getObjectAssert");
|
|
|
|
|
|
|
|
|
|
// Asserts disabled
|
|
|
|
|
return {};
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-06 19:53:51 -07:00
|
|
|
AsyncPromise<> NativeCxxModuleExample::promiseAssert(jsi::Runtime& rt) {
|
2023-04-03 08:34:59 -07:00
|
|
|
react_native_assert(false && "Intentional assert from Cxx promiseAssert");
|
|
|
|
|
|
|
|
|
|
// Asserts disabled
|
2025-07-06 19:53:51 -07:00
|
|
|
auto promise = AsyncPromise<>(rt, jsInvoker_);
|
2023-04-03 08:34:59 -07:00
|
|
|
promise.reject("Asserts disabled");
|
|
|
|
|
return promise;
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-09 10:48:49 -08:00
|
|
|
} // namespace facebook::react
|