Files
fressh/packages/react-native-uniffi-russh/cpp/generated/foobar.cpp
2025-09-12 23:56:08 -04:00

2965 lines
120 KiB
C++

// This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
// Trust me, you don't want to mess with it!
#include "foobar.hpp"
#include "UniffiJsiTypes.h"
#include <stdexcept>
#include <map>
#include <utility>
#include <iostream>
#include <thread>
namespace react = facebook::react;
namespace jsi = facebook::jsi;
// Calling into Rust.
extern "C" {
typedef void
(*UniffiRustFutureContinuationCallback)(
uint64_t data,
int8_t poll_result
);
typedef void
(*UniffiForeignFutureFree)(
uint64_t handle
);
typedef void
(*UniffiCallbackInterfaceFree)(
uint64_t handle
);typedef struct UniffiForeignFuture {
uint64_t handle;
UniffiForeignFutureFree free;
} UniffiForeignFuture;typedef struct UniffiForeignFutureStructU8 {
uint8_t return_value;
RustCallStatus call_status;
} UniffiForeignFutureStructU8;
typedef void
(*UniffiForeignFutureCompleteU8)(
uint64_t callback_data,
UniffiForeignFutureStructU8 result
);typedef struct UniffiForeignFutureStructI8 {
int8_t return_value;
RustCallStatus call_status;
} UniffiForeignFutureStructI8;
typedef void
(*UniffiForeignFutureCompleteI8)(
uint64_t callback_data,
UniffiForeignFutureStructI8 result
);typedef struct UniffiForeignFutureStructU16 {
uint16_t return_value;
RustCallStatus call_status;
} UniffiForeignFutureStructU16;
typedef void
(*UniffiForeignFutureCompleteU16)(
uint64_t callback_data,
UniffiForeignFutureStructU16 result
);typedef struct UniffiForeignFutureStructI16 {
int16_t return_value;
RustCallStatus call_status;
} UniffiForeignFutureStructI16;
typedef void
(*UniffiForeignFutureCompleteI16)(
uint64_t callback_data,
UniffiForeignFutureStructI16 result
);typedef struct UniffiForeignFutureStructU32 {
uint32_t return_value;
RustCallStatus call_status;
} UniffiForeignFutureStructU32;
typedef void
(*UniffiForeignFutureCompleteU32)(
uint64_t callback_data,
UniffiForeignFutureStructU32 result
);typedef struct UniffiForeignFutureStructI32 {
int32_t return_value;
RustCallStatus call_status;
} UniffiForeignFutureStructI32;
typedef void
(*UniffiForeignFutureCompleteI32)(
uint64_t callback_data,
UniffiForeignFutureStructI32 result
);typedef struct UniffiForeignFutureStructU64 {
uint64_t return_value;
RustCallStatus call_status;
} UniffiForeignFutureStructU64;
typedef void
(*UniffiForeignFutureCompleteU64)(
uint64_t callback_data,
UniffiForeignFutureStructU64 result
);typedef struct UniffiForeignFutureStructI64 {
int64_t return_value;
RustCallStatus call_status;
} UniffiForeignFutureStructI64;
typedef void
(*UniffiForeignFutureCompleteI64)(
uint64_t callback_data,
UniffiForeignFutureStructI64 result
);typedef struct UniffiForeignFutureStructF32 {
float return_value;
RustCallStatus call_status;
} UniffiForeignFutureStructF32;
typedef void
(*UniffiForeignFutureCompleteF32)(
uint64_t callback_data,
UniffiForeignFutureStructF32 result
);typedef struct UniffiForeignFutureStructF64 {
double return_value;
RustCallStatus call_status;
} UniffiForeignFutureStructF64;
typedef void
(*UniffiForeignFutureCompleteF64)(
uint64_t callback_data,
UniffiForeignFutureStructF64 result
);typedef struct UniffiForeignFutureStructPointer {
void * return_value;
RustCallStatus call_status;
} UniffiForeignFutureStructPointer;
typedef void
(*UniffiForeignFutureCompletePointer)(
uint64_t callback_data,
UniffiForeignFutureStructPointer result
);typedef struct UniffiForeignFutureStructRustBuffer {
RustBuffer return_value;
RustCallStatus call_status;
} UniffiForeignFutureStructRustBuffer;
typedef void
(*UniffiForeignFutureCompleteRustBuffer)(
uint64_t callback_data,
UniffiForeignFutureStructRustBuffer result
);typedef struct UniffiForeignFutureStructVoid {
RustCallStatus call_status;
} UniffiForeignFutureStructVoid;
typedef void
(*UniffiForeignFutureCompleteVoid)(
uint64_t callback_data,
UniffiForeignFutureStructVoid result
);
typedef void
(*UniffiCallbackInterfaceBinaryOperatorMethod0)(
uint64_t uniffi_handle,
int64_t lhs,
int64_t rhs,
int64_t * uniffi_out_return, RustCallStatus* rust_call_status
);typedef struct UniffiVTableCallbackInterfaceBinaryOperator {
UniffiCallbackInterfaceBinaryOperatorMethod0 perform;
UniffiCallbackInterfaceFree uniffi_free;
} UniffiVTableCallbackInterfaceBinaryOperator;
void * uniffi_foobar_fn_clone_binaryoperator(
void * ptr,
RustCallStatus *uniffi_out_err
);
void uniffi_foobar_fn_free_binaryoperator(
void * ptr,
RustCallStatus *uniffi_out_err
);
void uniffi_foobar_fn_init_callback_vtable_binaryoperator(
UniffiVTableCallbackInterfaceBinaryOperator * vtable
);
int64_t uniffi_foobar_fn_method_binaryoperator_perform(
void * ptr,
int64_t lhs,
int64_t rhs,
RustCallStatus *uniffi_out_err
);
void * uniffi_foobar_fn_clone_calculator(
void * ptr,
RustCallStatus *uniffi_out_err
);
void uniffi_foobar_fn_free_calculator(
void * ptr,
RustCallStatus *uniffi_out_err
);
void * uniffi_foobar_fn_constructor_calculator_new(RustCallStatus *uniffi_out_err
);
void * uniffi_foobar_fn_method_calculator_calculate(
void * ptr,
void * op,
int64_t lhs,
int64_t rhs,
RustCallStatus *uniffi_out_err
);
void * uniffi_foobar_fn_method_calculator_calculate_more(
void * ptr,
void * op,
int64_t rhs,
RustCallStatus *uniffi_out_err
);
RustBuffer uniffi_foobar_fn_method_calculator_last_result(
void * ptr,
RustCallStatus *uniffi_out_err
);
void * uniffi_foobar_fn_clone_safeaddition(
void * ptr,
RustCallStatus *uniffi_out_err
);
void uniffi_foobar_fn_free_safeaddition(
void * ptr,
RustCallStatus *uniffi_out_err
);
void * uniffi_foobar_fn_constructor_safeaddition_new(RustCallStatus *uniffi_out_err
);
int64_t uniffi_foobar_fn_method_safeaddition_perform(
void * ptr,
int64_t lhs,
int64_t rhs,
RustCallStatus *uniffi_out_err
);
void * uniffi_foobar_fn_clone_safedivision(
void * ptr,
RustCallStatus *uniffi_out_err
);
void uniffi_foobar_fn_free_safedivision(
void * ptr,
RustCallStatus *uniffi_out_err
);
void * uniffi_foobar_fn_constructor_safedivision_new(RustCallStatus *uniffi_out_err
);
int64_t uniffi_foobar_fn_method_safedivision_perform(
void * ptr,
int64_t lhs,
int64_t rhs,
RustCallStatus *uniffi_out_err
);
void * uniffi_foobar_fn_func_safe_addition_operator(RustCallStatus *uniffi_out_err
);
void * uniffi_foobar_fn_func_safe_division_operator(RustCallStatus *uniffi_out_err
);
RustBuffer ffi_foobar_rustbuffer_alloc(
uint64_t size,
RustCallStatus *uniffi_out_err
);
RustBuffer ffi_foobar_rustbuffer_from_bytes(
ForeignBytes bytes,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rustbuffer_free(
RustBuffer buf,
RustCallStatus *uniffi_out_err
);
RustBuffer ffi_foobar_rustbuffer_reserve(
RustBuffer buf,
uint64_t additional,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rust_future_poll_u8(
/*handle*/ uint64_t handle,
UniffiRustFutureContinuationCallback callback,
/*handle*/ uint64_t callback_data
);
void ffi_foobar_rust_future_cancel_u8(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_free_u8(
/*handle*/ uint64_t handle
);
uint8_t ffi_foobar_rust_future_complete_u8(
/*handle*/ uint64_t handle,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rust_future_poll_i8(
/*handle*/ uint64_t handle,
UniffiRustFutureContinuationCallback callback,
/*handle*/ uint64_t callback_data
);
void ffi_foobar_rust_future_cancel_i8(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_free_i8(
/*handle*/ uint64_t handle
);
int8_t ffi_foobar_rust_future_complete_i8(
/*handle*/ uint64_t handle,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rust_future_poll_u16(
/*handle*/ uint64_t handle,
UniffiRustFutureContinuationCallback callback,
/*handle*/ uint64_t callback_data
);
void ffi_foobar_rust_future_cancel_u16(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_free_u16(
/*handle*/ uint64_t handle
);
uint16_t ffi_foobar_rust_future_complete_u16(
/*handle*/ uint64_t handle,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rust_future_poll_i16(
/*handle*/ uint64_t handle,
UniffiRustFutureContinuationCallback callback,
/*handle*/ uint64_t callback_data
);
void ffi_foobar_rust_future_cancel_i16(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_free_i16(
/*handle*/ uint64_t handle
);
int16_t ffi_foobar_rust_future_complete_i16(
/*handle*/ uint64_t handle,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rust_future_poll_u32(
/*handle*/ uint64_t handle,
UniffiRustFutureContinuationCallback callback,
/*handle*/ uint64_t callback_data
);
void ffi_foobar_rust_future_cancel_u32(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_free_u32(
/*handle*/ uint64_t handle
);
uint32_t ffi_foobar_rust_future_complete_u32(
/*handle*/ uint64_t handle,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rust_future_poll_i32(
/*handle*/ uint64_t handle,
UniffiRustFutureContinuationCallback callback,
/*handle*/ uint64_t callback_data
);
void ffi_foobar_rust_future_cancel_i32(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_free_i32(
/*handle*/ uint64_t handle
);
int32_t ffi_foobar_rust_future_complete_i32(
/*handle*/ uint64_t handle,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rust_future_poll_u64(
/*handle*/ uint64_t handle,
UniffiRustFutureContinuationCallback callback,
/*handle*/ uint64_t callback_data
);
void ffi_foobar_rust_future_cancel_u64(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_free_u64(
/*handle*/ uint64_t handle
);
uint64_t ffi_foobar_rust_future_complete_u64(
/*handle*/ uint64_t handle,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rust_future_poll_i64(
/*handle*/ uint64_t handle,
UniffiRustFutureContinuationCallback callback,
/*handle*/ uint64_t callback_data
);
void ffi_foobar_rust_future_cancel_i64(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_free_i64(
/*handle*/ uint64_t handle
);
int64_t ffi_foobar_rust_future_complete_i64(
/*handle*/ uint64_t handle,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rust_future_poll_f32(
/*handle*/ uint64_t handle,
UniffiRustFutureContinuationCallback callback,
/*handle*/ uint64_t callback_data
);
void ffi_foobar_rust_future_cancel_f32(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_free_f32(
/*handle*/ uint64_t handle
);
float ffi_foobar_rust_future_complete_f32(
/*handle*/ uint64_t handle,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rust_future_poll_f64(
/*handle*/ uint64_t handle,
UniffiRustFutureContinuationCallback callback,
/*handle*/ uint64_t callback_data
);
void ffi_foobar_rust_future_cancel_f64(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_free_f64(
/*handle*/ uint64_t handle
);
double ffi_foobar_rust_future_complete_f64(
/*handle*/ uint64_t handle,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rust_future_poll_pointer(
/*handle*/ uint64_t handle,
UniffiRustFutureContinuationCallback callback,
/*handle*/ uint64_t callback_data
);
void ffi_foobar_rust_future_cancel_pointer(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_free_pointer(
/*handle*/ uint64_t handle
);
void * ffi_foobar_rust_future_complete_pointer(
/*handle*/ uint64_t handle,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rust_future_poll_rust_buffer(
/*handle*/ uint64_t handle,
UniffiRustFutureContinuationCallback callback,
/*handle*/ uint64_t callback_data
);
void ffi_foobar_rust_future_cancel_rust_buffer(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_free_rust_buffer(
/*handle*/ uint64_t handle
);
RustBuffer ffi_foobar_rust_future_complete_rust_buffer(
/*handle*/ uint64_t handle,
RustCallStatus *uniffi_out_err
);
void ffi_foobar_rust_future_poll_void(
/*handle*/ uint64_t handle,
UniffiRustFutureContinuationCallback callback,
/*handle*/ uint64_t callback_data
);
void ffi_foobar_rust_future_cancel_void(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_free_void(
/*handle*/ uint64_t handle
);
void ffi_foobar_rust_future_complete_void(
/*handle*/ uint64_t handle,
RustCallStatus *uniffi_out_err
);
uint16_t uniffi_foobar_checksum_func_safe_addition_operator(
);
uint16_t uniffi_foobar_checksum_func_safe_division_operator(
);
uint16_t uniffi_foobar_checksum_method_binaryoperator_perform(
);
uint16_t uniffi_foobar_checksum_method_calculator_calculate(
);
uint16_t uniffi_foobar_checksum_method_calculator_calculate_more(
);
uint16_t uniffi_foobar_checksum_method_calculator_last_result(
);
uint16_t uniffi_foobar_checksum_method_safeaddition_perform(
);
uint16_t uniffi_foobar_checksum_method_safedivision_perform(
);
uint16_t uniffi_foobar_checksum_constructor_calculator_new(
);
uint16_t uniffi_foobar_checksum_constructor_safeaddition_new(
);
uint16_t uniffi_foobar_checksum_constructor_safedivision_new(
);
uint32_t ffi_foobar_uniffi_contract_version(
);
}
namespace uniffi::foobar {
template <typename T> struct Bridging;
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <typename T> struct Bridging<ReferenceHolder<T>> {
static jsi::Value jsNew(jsi::Runtime &rt) {
auto holder = jsi::Object(rt);
return holder;
}
static T fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &value) {
auto obj = value.asObject(rt);
if (obj.hasProperty(rt, "pointee")) {
auto pointee = obj.getProperty(rt, "pointee");
return uniffi::foobar::Bridging<T>::fromJs(rt, callInvoker, pointee);
}
throw jsi::JSError(
rt,
"Expected ReferenceHolder to have a pointee property. This is likely a bug in uniffi-bindgen-react-native"
);
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<RustBuffer> {
static RustBuffer rustbuffer_alloc(int32_t size) {
RustCallStatus status = { UNIFFI_CALL_STATUS_OK };
return ffi_foobar_rustbuffer_alloc(
size,
&status
);
}
static void rustbuffer_free(RustBuffer buf) {
RustCallStatus status = { UNIFFI_CALL_STATUS_OK };
ffi_foobar_rustbuffer_free(
buf,
&status
);
}
static RustBuffer rustbuffer_from_bytes(ForeignBytes bytes) {
RustCallStatus status = { UNIFFI_CALL_STATUS_OK };
return ffi_foobar_rustbuffer_from_bytes(
bytes,
&status
);
}
static RustBuffer fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker>,
const jsi::Value &value) {
try {
auto buffer = uniffi_jsi::Bridging<jsi::ArrayBuffer>::value_to_arraybuffer(rt, value);
auto bytes = ForeignBytes{
.len = static_cast<int32_t>(buffer.length(rt)),
.data = buffer.data(rt),
};
// This buffer is constructed from foreign bytes. Rust scaffolding copies
// the bytes, to make the RustBuffer.
auto buf = rustbuffer_from_bytes(bytes);
// Once it leaves this function, the buffer is immediately passed back
// into Rust, where it's used to deserialize into the Rust versions of the
// arguments. At that point, the copy is destroyed.
return buf;
} catch (const std::logic_error &e) {
throw jsi::JSError(rt, e.what());
}
}
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker>,
RustBuffer buf) {
// We need to make a copy of the bytes from Rust's memory space into
// Javascripts memory space. We need to do this because the two languages
// manages memory very differently: a garbage collector needs to track all
// the memory at runtime, Rust is doing it all closer to compile time.
uint8_t *bytes = new uint8_t[buf.len];
std::memcpy(bytes, buf.data, buf.len);
// Construct an ArrayBuffer with copy of the bytes from the RustBuffer.
auto payload = std::make_shared<uniffi_jsi::CMutableBuffer>(
uniffi_jsi::CMutableBuffer((uint8_t *)bytes, buf.len));
auto arrayBuffer = jsi::ArrayBuffer(rt, payload);
// Once we have a Javascript version, we no longer need the Rust version, so
// we can call into Rust to tell it it's okay to free that memory.
rustbuffer_free(buf);
// Finally, return the ArrayBuffer.
return uniffi_jsi::Bridging<jsi::ArrayBuffer>::arraybuffer_to_value(rt, arrayBuffer);;
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<RustCallStatus> {
static jsi::Value jsSuccess(jsi::Runtime &rt) {
auto statusObject = jsi::Object(rt);
statusObject.setProperty(rt, "code", jsi::Value(rt, UNIFFI_CALL_STATUS_OK));
return statusObject;
}
static RustCallStatus rustSuccess(jsi::Runtime &rt) {
return {UNIFFI_CALL_STATUS_OK};
}
static void copyIntoJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const RustCallStatus status,
const jsi::Value &jsStatus) {
auto statusObject = jsStatus.asObject(rt);
if (status.error_buf.data != nullptr) {
auto rbuf = Bridging<RustBuffer>::toJs(rt, callInvoker,
status.error_buf);
statusObject.setProperty(rt, "errorBuf", rbuf);
}
if (status.code != UNIFFI_CALL_STATUS_OK) {
auto code =
uniffi_jsi::Bridging<uint8_t>::toJs(rt, callInvoker, status.code);
statusObject.setProperty(rt, "code", code);
}
}
static RustCallStatus fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> invoker,
const jsi::Value &jsStatus) {
RustCallStatus status;
auto statusObject = jsStatus.asObject(rt);
if (statusObject.hasProperty(rt, "errorBuf")) {
auto rbuf = statusObject.getProperty(rt, "errorBuf");
status.error_buf =
Bridging<RustBuffer>::fromJs(rt, invoker, rbuf);
}
if (statusObject.hasProperty(rt, "code")) {
auto code = statusObject.getProperty(rt, "code");
status.code = uniffi_jsi::Bridging<uint8_t>::fromJs(rt, invoker, code);
}
return status;
}
static void copyFromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> invoker,
const jsi::Value &jsStatus, RustCallStatus *status) {
auto statusObject = jsStatus.asObject(rt);
if (statusObject.hasProperty(rt, "errorBuf")) {
auto rbuf = statusObject.getProperty(rt, "errorBuf");
status->error_buf =
Bridging<RustBuffer>::fromJs(rt, invoker, rbuf);
}
if (statusObject.hasProperty(rt, "code")) {
auto code = statusObject.getProperty(rt, "code");
status->code = uniffi_jsi::Bridging<uint8_t>::fromJs(rt, invoker, code);
}
}
};
} // namespace uniffi::foobar
// In other uniffi bindings, it is assumed that the foreign language holds on
// to the vtable, which the Rust just gets a pointer to.
// Here, we need to hold on to them, but also be able to clear them at just the
// right time so we can support hot-reloading.
namespace uniffi::foobar::registry {
template <typename T>
class VTableHolder {
public:
T vtable;
VTableHolder(T v) : vtable(v) {}
};
// Mutex to bind the storage and setting of vtable together.
// We declare it here, but the lock is taken by callers of the putTable
// method who are also sending a pointer to Rust.
static std::mutex vtableMutex;
// Registry to hold all vtables so they persist even when JS objects are GC'd.
// The only reason this exists is to prevent a dangling pointer in the
// Rust machinery: i.e. we don't need to access or write to this registry
// after startup.
// Registry to hold all vtables so they persist even when JS objects are GC'd.
// Maps string identifiers to vtable holders using type erasure
static std::unordered_map<std::string, std::shared_ptr<void>> vtableRegistry;
// Add a vtable to the registry with an identifier
template <typename T>
static T* putTable(std::string_view identifier, T vtable) {
auto holder = std::make_shared<VTableHolder<T>>(vtable);
// Store the raw pointer to the vtable before type erasure
T* rawPtr = &(holder->vtable);
// Store the holder using type erasure with the string identifier
vtableRegistry[std::string(identifier)] = std::shared_ptr<void>(holder);
return rawPtr;
}
// Clear the registry.
//
// Conceptually, this is called after teardown of the module (i.e. after
// teardown of the jsi::Runtime). However, because Rust is dropping callbacks
// because the Runtime is being torn down, we must keep the registry intact
// until after the runtime goes away.
//
// Therefore, in practice we should call this when the next runtime is
// being stood up.
static void clearRegistry() {
std::lock_guard<std::mutex> lock(vtableMutex);
vtableRegistry.clear();
}
} // namespace uniffi::foobar::registry
// This calls into Rust.
// Implementation of callback function calling from Rust to JS RustFutureContinuationCallback
// Callback function: uniffi::foobar::cb::rustfuturecontinuationcallback::UniffiRustFutureContinuationCallback
//
// We have the following constraints:
// - we need to pass a function pointer to Rust.
// - we need a jsi::Runtime and jsi::Function to call into JS.
// - function pointers can't store state, so we can't use a lamda.
//
// For this, we store a lambda as a global, as `rsLambda`. The `callback` function calls
// the lambda, which itself calls the `body` which then calls into JS.
//
// We then give the `callback` function pointer to Rust which will call the lambda sometime in the
// future.
namespace uniffi::foobar::cb::rustfuturecontinuationcallback {
using namespace facebook;
// We need to store a lambda in a global so we can call it from
// a function pointer. The function pointer is passed to Rust.
static std::function<void(uint64_t, int8_t)> rsLambda = nullptr;
// This is the main body of the callback. It's called from the lambda,
// which itself is called from the callback function which is passed to Rust.
static void body(jsi::Runtime &rt,
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
std::shared_ptr<jsi::Value> callbackValue
,uint64_t rs_data
,int8_t rs_pollResult) {
// Convert the arguments from Rust, into jsi::Values.
// We'll use the Bridging class to do this…
auto js_data = uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_data);
auto js_pollResult = uniffi_jsi::Bridging<int8_t>::toJs(rt, callInvoker, rs_pollResult);
// Now we are ready to call the callback.
// We are already on the JS thread, because this `body` function was
// invoked from the CallInvoker.
try {
// Getting the callback function
auto cb = callbackValue->asObject(rt).asFunction(rt);
auto uniffiResult = cb.call(rt, js_data, js_pollResult
);
} catch (const jsi::JSError &error) {
std::cout << "Error in callback UniffiRustFutureContinuationCallback: "
<< error.what() << std::endl;
throw error;
}
}
static void callback(uint64_t rs_data, int8_t rs_pollResult) {
// If the runtime has shutdown, then there is no point in trying to
// call into Javascript. BUT how do we tell if the runtime has shutdown?
//
// Answer: the module destructor calls into callback `cleanup` method,
// which nulls out the rsLamda.
//
// If rsLamda is null, then there is no runtime to call into.
if (rsLambda == nullptr) {
// This only occurs when destructors are calling into Rust free/drop,
// which causes the JS callback to be dropped.
return;
}
// The runtime, the actual callback jsi::funtion, and the callInvoker
// are all in the lambda.
rsLambda(
rs_data,
rs_pollResult);
}
static UniffiRustFutureContinuationCallback
makeCallbackFunction( // uniffi::foobar::cb::rustfuturecontinuationcallback
jsi::Runtime &rt,
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
const jsi::Value &value) {
if (rsLambda != nullptr) {
// `makeCallbackFunction` is called in two circumstances:
//
// 1. at startup, when initializing callback interface vtables.
// 2. when polling futures. This happens at least once per future that is
// exposed to Javascript. We know that this is always the same function,
// `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
//
// We can therefore return the callback function without making anything
// new if we've been initialized already.
return callback;
}
auto callbackFunction = value.asObject(rt).asFunction(rt);
auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_data, int8_t rs_pollResult) {
// We immediately make a lambda which will do the work of transforming the
// arguments into JSI values and calling the callback.
uniffi_runtime::UniffiCallFunc jsLambda = [
callInvoker,
callbackValue
, rs_data
, rs_pollResult](jsi::Runtime &rt) mutable {
body(rt, callInvoker, callbackValue
, rs_data
, rs_pollResult);
};
// We'll then call that lambda from the callInvoker which will
// look after calling it on the correct thread.
callInvoker->invokeNonBlocking(rt, jsLambda);
};
return callback;
}
// This method is called from the destructor of NativeFoobar, which only happens
// when the jsi::Runtime is being destroyed.
static void cleanup() {
// The lambda holds a reference to the the Runtime, so when this is nulled out,
// then the pointer will no longer be left dangling.
rsLambda = nullptr;
}
} // namespace uniffi::foobar::cb::rustfuturecontinuationcallback
// Implementation of callback function calling from JS to Rust ForeignFutureFree,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureFree> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureFree rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureFree"),
1,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureFree func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
// Implementation of free callback function CallbackInterfaceFree
// Callback function: uniffi::foobar::st::foreignfuture::foreignfuture::free::UniffiCallbackInterfaceFree
//
// We have the following constraints:
// - we need to pass a function pointer to Rust.
// - we need a jsi::Runtime and jsi::Function to call into JS.
// - function pointers can't store state, so we can't use a lamda.
//
// For this, we store a lambda as a global, as `rsLambda`. The `callback` function calls
// the lambda, which itself calls the `body` which then calls into JS.
//
// We then give the `callback` function pointer to Rust which will call the lambda sometime in the
// future.
namespace uniffi::foobar::st::foreignfuture::foreignfuture::free {
using namespace facebook;
// We need to store a lambda in a global so we can call it from
// a function pointer. The function pointer is passed to Rust.
static std::function<void(uint64_t)> rsLambda = nullptr;
// This is the main body of the callback. It's called from the lambda,
// which itself is called from the callback function which is passed to Rust.
static void body(jsi::Runtime &rt,
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
std::shared_ptr<jsi::Value> callbackValue
,uint64_t rs_handle) {
// Convert the arguments from Rust, into jsi::Values.
// We'll use the Bridging class to do this…
auto js_handle = uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_handle);
// Now we are ready to call the callback.
// We are already on the JS thread, because this `body` function was
// invoked from the CallInvoker.
try {
// Getting the callback function
auto cb = callbackValue->asObject(rt).asFunction(rt);
auto uniffiResult = cb.call(rt, js_handle
);
} catch (const jsi::JSError &error) {
std::cout << "Error in callback UniffiCallbackInterfaceFree: "
<< error.what() << std::endl;
throw error;
}
}
static void callback(uint64_t rs_handle) {
// If the runtime has shutdown, then there is no point in trying to
// call into Javascript. BUT how do we tell if the runtime has shutdown?
//
// Answer: the module destructor calls into callback `cleanup` method,
// which nulls out the rsLamda.
//
// If rsLamda is null, then there is no runtime to call into.
if (rsLambda == nullptr) {
// This only occurs when destructors are calling into Rust free/drop,
// which causes the JS callback to be dropped.
return;
}
// The runtime, the actual callback jsi::funtion, and the callInvoker
// are all in the lambda.
rsLambda(
rs_handle);
}
static UniffiCallbackInterfaceFree
makeCallbackFunction( // uniffi::foobar::st::foreignfuture::foreignfuture::free
jsi::Runtime &rt,
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
const jsi::Value &value) {
if (rsLambda != nullptr) {
// `makeCallbackFunction` is called in two circumstances:
//
// 1. at startup, when initializing callback interface vtables.
// 2. when polling futures. This happens at least once per future that is
// exposed to Javascript. We know that this is always the same function,
// `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
//
// We can therefore return the callback function without making anything
// new if we've been initialized already.
return callback;
}
auto callbackFunction = value.asObject(rt).asFunction(rt);
auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_handle) {
// We immediately make a lambda which will do the work of transforming the
// arguments into JSI values and calling the callback.
uniffi_runtime::UniffiCallFunc jsLambda = [
callInvoker,
callbackValue
, rs_handle](jsi::Runtime &rt) mutable {
body(rt, callInvoker, callbackValue
, rs_handle);
};
// We'll then call that lambda from the callInvoker which will
// look after calling it on the correct thread.
callInvoker->invokeNonBlocking(rt, jsLambda);
};
return callback;
}
// This method is called from the destructor of NativeFoobar, which only happens
// when the jsi::Runtime is being destroyed.
static void cleanup() {
// The lambda holds a reference to the the Runtime, so when this is nulled out,
// then the pointer will no longer be left dangling.
rsLambda = nullptr;
}
} // namespace uniffi::foobar::st::foreignfuture::foreignfuture::free
// Callback function: uniffi::foobar::st::vtablecallbackinterfacebinaryoperator::vtablecallbackinterfacebinaryoperator::free::UniffiCallbackInterfaceFree
//
// We have the following constraints:
// - we need to pass a function pointer to Rust.
// - we need a jsi::Runtime and jsi::Function to call into JS.
// - function pointers can't store state, so we can't use a lamda.
//
// For this, we store a lambda as a global, as `rsLambda`. The `callback` function calls
// the lambda, which itself calls the `body` which then calls into JS.
//
// We then give the `callback` function pointer to Rust which will call the lambda sometime in the
// future.
namespace uniffi::foobar::st::vtablecallbackinterfacebinaryoperator::vtablecallbackinterfacebinaryoperator::free {
using namespace facebook;
// We need to store a lambda in a global so we can call it from
// a function pointer. The function pointer is passed to Rust.
static std::function<void(uint64_t)> rsLambda = nullptr;
// This is the main body of the callback. It's called from the lambda,
// which itself is called from the callback function which is passed to Rust.
static void body(jsi::Runtime &rt,
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
std::shared_ptr<jsi::Value> callbackValue
,uint64_t rs_handle) {
// Convert the arguments from Rust, into jsi::Values.
// We'll use the Bridging class to do this…
auto js_handle = uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_handle);
// Now we are ready to call the callback.
// We are already on the JS thread, because this `body` function was
// invoked from the CallInvoker.
try {
// Getting the callback function
auto cb = callbackValue->asObject(rt).asFunction(rt);
auto uniffiResult = cb.call(rt, js_handle
);
} catch (const jsi::JSError &error) {
std::cout << "Error in callback UniffiCallbackInterfaceFree: "
<< error.what() << std::endl;
throw error;
}
}
static void callback(uint64_t rs_handle) {
// If the runtime has shutdown, then there is no point in trying to
// call into Javascript. BUT how do we tell if the runtime has shutdown?
//
// Answer: the module destructor calls into callback `cleanup` method,
// which nulls out the rsLamda.
//
// If rsLamda is null, then there is no runtime to call into.
if (rsLambda == nullptr) {
// This only occurs when destructors are calling into Rust free/drop,
// which causes the JS callback to be dropped.
return;
}
// The runtime, the actual callback jsi::funtion, and the callInvoker
// are all in the lambda.
rsLambda(
rs_handle);
}
static UniffiCallbackInterfaceFree
makeCallbackFunction( // uniffi::foobar::st::vtablecallbackinterfacebinaryoperator::vtablecallbackinterfacebinaryoperator::free
jsi::Runtime &rt,
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
const jsi::Value &value) {
if (rsLambda != nullptr) {
// `makeCallbackFunction` is called in two circumstances:
//
// 1. at startup, when initializing callback interface vtables.
// 2. when polling futures. This happens at least once per future that is
// exposed to Javascript. We know that this is always the same function,
// `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
//
// We can therefore return the callback function without making anything
// new if we've been initialized already.
return callback;
}
auto callbackFunction = value.asObject(rt).asFunction(rt);
auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_handle) {
// We immediately make a lambda which will do the work of transforming the
// arguments into JSI values and calling the callback.
uniffi_runtime::UniffiCallFunc jsLambda = [
callInvoker,
callbackValue
, rs_handle](jsi::Runtime &rt) mutable {
body(rt, callInvoker, callbackValue
, rs_handle);
};
// We'll then call that lambda from the callInvoker which will
// look after calling it on the correct thread.
callInvoker->invokeNonBlocking(rt, jsLambda);
};
return callback;
}
// This method is called from the destructor of NativeFoobar, which only happens
// when the jsi::Runtime is being destroyed.
static void cleanup() {
// The lambda holds a reference to the the Runtime, so when this is nulled out,
// then the pointer will no longer be left dangling.
rsLambda = nullptr;
}
} // namespace uniffi::foobar::st::vtablecallbackinterfacebinaryoperator::vtablecallbackinterfacebinaryoperator::free
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFuture> {
static UniffiForeignFuture fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFuture");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFuture rsObject;
// Create the vtable from the js callbacks.
rsObject.handle = uniffi_jsi::Bridging<uint64_t>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "handle")
);
rsObject.free = uniffi::foobar::st::foreignfuture::foreignfuture::free::makeCallbackFunction(
rt, callInvoker, jsObject.getProperty(rt, "free")
);
return rsObject;
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureStructU8> {
static UniffiForeignFutureStructU8 fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructU8");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFutureStructU8 rsObject;
// Create the vtable from the js callbacks.
rsObject.return_value = uniffi_jsi::Bridging<uint8_t>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "returnValue")
);
rsObject.call_status = uniffi::foobar::Bridging<RustCallStatus>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "callStatus")
);
return rsObject;
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from JS to Rust ForeignFutureCompleteU8,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureCompleteU8> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteU8 rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU8"),
2,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureCompleteU8 func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging<UniffiForeignFutureStructU8>::fromJs(rt, callInvoker, args[1])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureStructI8> {
static UniffiForeignFutureStructI8 fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructI8");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFutureStructI8 rsObject;
// Create the vtable from the js callbacks.
rsObject.return_value = uniffi_jsi::Bridging<int8_t>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "returnValue")
);
rsObject.call_status = uniffi::foobar::Bridging<RustCallStatus>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "callStatus")
);
return rsObject;
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from JS to Rust ForeignFutureCompleteI8,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureCompleteI8> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteI8 rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI8"),
2,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureCompleteI8 func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging<UniffiForeignFutureStructI8>::fromJs(rt, callInvoker, args[1])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureStructU16> {
static UniffiForeignFutureStructU16 fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructU16");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFutureStructU16 rsObject;
// Create the vtable from the js callbacks.
rsObject.return_value = uniffi_jsi::Bridging<uint16_t>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "returnValue")
);
rsObject.call_status = uniffi::foobar::Bridging<RustCallStatus>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "callStatus")
);
return rsObject;
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from JS to Rust ForeignFutureCompleteU16,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureCompleteU16> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteU16 rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU16"),
2,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureCompleteU16 func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging<UniffiForeignFutureStructU16>::fromJs(rt, callInvoker, args[1])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureStructI16> {
static UniffiForeignFutureStructI16 fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructI16");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFutureStructI16 rsObject;
// Create the vtable from the js callbacks.
rsObject.return_value = uniffi_jsi::Bridging<int16_t>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "returnValue")
);
rsObject.call_status = uniffi::foobar::Bridging<RustCallStatus>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "callStatus")
);
return rsObject;
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from JS to Rust ForeignFutureCompleteI16,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureCompleteI16> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteI16 rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI16"),
2,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureCompleteI16 func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging<UniffiForeignFutureStructI16>::fromJs(rt, callInvoker, args[1])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureStructU32> {
static UniffiForeignFutureStructU32 fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructU32");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFutureStructU32 rsObject;
// Create the vtable from the js callbacks.
rsObject.return_value = uniffi_jsi::Bridging<uint32_t>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "returnValue")
);
rsObject.call_status = uniffi::foobar::Bridging<RustCallStatus>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "callStatus")
);
return rsObject;
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from JS to Rust ForeignFutureCompleteU32,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureCompleteU32> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteU32 rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU32"),
2,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureCompleteU32 func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging<UniffiForeignFutureStructU32>::fromJs(rt, callInvoker, args[1])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureStructI32> {
static UniffiForeignFutureStructI32 fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructI32");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFutureStructI32 rsObject;
// Create the vtable from the js callbacks.
rsObject.return_value = uniffi_jsi::Bridging<int32_t>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "returnValue")
);
rsObject.call_status = uniffi::foobar::Bridging<RustCallStatus>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "callStatus")
);
return rsObject;
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from JS to Rust ForeignFutureCompleteI32,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureCompleteI32> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteI32 rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI32"),
2,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureCompleteI32 func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging<UniffiForeignFutureStructI32>::fromJs(rt, callInvoker, args[1])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureStructU64> {
static UniffiForeignFutureStructU64 fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructU64");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFutureStructU64 rsObject;
// Create the vtable from the js callbacks.
rsObject.return_value = uniffi_jsi::Bridging<uint64_t>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "returnValue")
);
rsObject.call_status = uniffi::foobar::Bridging<RustCallStatus>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "callStatus")
);
return rsObject;
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from JS to Rust ForeignFutureCompleteU64,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureCompleteU64> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteU64 rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU64"),
2,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureCompleteU64 func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging<UniffiForeignFutureStructU64>::fromJs(rt, callInvoker, args[1])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureStructI64> {
static UniffiForeignFutureStructI64 fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructI64");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFutureStructI64 rsObject;
// Create the vtable from the js callbacks.
rsObject.return_value = uniffi_jsi::Bridging<int64_t>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "returnValue")
);
rsObject.call_status = uniffi::foobar::Bridging<RustCallStatus>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "callStatus")
);
return rsObject;
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from JS to Rust ForeignFutureCompleteI64,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureCompleteI64> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteI64 rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI64"),
2,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureCompleteI64 func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging<UniffiForeignFutureStructI64>::fromJs(rt, callInvoker, args[1])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureStructF32> {
static UniffiForeignFutureStructF32 fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructF32");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFutureStructF32 rsObject;
// Create the vtable from the js callbacks.
rsObject.return_value = uniffi_jsi::Bridging<float>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "returnValue")
);
rsObject.call_status = uniffi::foobar::Bridging<RustCallStatus>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "callStatus")
);
return rsObject;
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from JS to Rust ForeignFutureCompleteF32,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureCompleteF32> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteF32 rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteF32"),
2,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureCompleteF32 func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging<UniffiForeignFutureStructF32>::fromJs(rt, callInvoker, args[1])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureStructF64> {
static UniffiForeignFutureStructF64 fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructF64");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFutureStructF64 rsObject;
// Create the vtable from the js callbacks.
rsObject.return_value = uniffi_jsi::Bridging<double>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "returnValue")
);
rsObject.call_status = uniffi::foobar::Bridging<RustCallStatus>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "callStatus")
);
return rsObject;
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from JS to Rust ForeignFutureCompleteF64,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureCompleteF64> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteF64 rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteF64"),
2,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureCompleteF64 func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging<UniffiForeignFutureStructF64>::fromJs(rt, callInvoker, args[1])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureStructPointer> {
static UniffiForeignFutureStructPointer fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructPointer");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFutureStructPointer rsObject;
// Create the vtable from the js callbacks.
rsObject.return_value = uniffi_jsi::Bridging<void *>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "returnValue")
);
rsObject.call_status = uniffi::foobar::Bridging<RustCallStatus>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "callStatus")
);
return rsObject;
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from JS to Rust ForeignFutureCompletePointer,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureCompletePointer> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompletePointer rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureCompletePointer"),
2,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureCompletePointer func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging<UniffiForeignFutureStructPointer>::fromJs(rt, callInvoker, args[1])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureStructRustBuffer> {
static UniffiForeignFutureStructRustBuffer fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructRustBuffer");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFutureStructRustBuffer rsObject;
// Create the vtable from the js callbacks.
rsObject.return_value = uniffi::foobar::Bridging<RustBuffer>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "returnValue")
);
rsObject.call_status = uniffi::foobar::Bridging<RustCallStatus>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "callStatus")
);
return rsObject;
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from JS to Rust ForeignFutureCompleteRustBuffer,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureCompleteRustBuffer> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteRustBuffer rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteRustBuffer"),
2,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureCompleteRustBuffer func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging<UniffiForeignFutureStructRustBuffer>::fromJs(rt, callInvoker, args[1])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureStructVoid> {
static UniffiForeignFutureStructVoid fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructVoid");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiForeignFutureStructVoid rsObject;
// Create the vtable from the js callbacks.
rsObject.call_status = uniffi::foobar::Bridging<RustCallStatus>::fromJs(
rt, callInvoker,
jsObject.getProperty(rt, "callStatus")
);
return rsObject;
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from JS to Rust ForeignFutureCompleteVoid,
// passed from Rust to JS as part of async callbacks.
namespace uniffi::foobar {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiForeignFutureCompleteVoid> {
static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteVoid rsCallback) {
return jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteVoid"),
2,
[rsCallback, callInvoker](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value
{
return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
}
);
}
static jsi::Value intoRust(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count,
UniffiForeignFutureCompleteVoid func) {
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
// then call the rs_callback with those arguments.
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging<UniffiForeignFutureStructVoid>::fromJs(rt, callInvoker, args[1])
);
return jsi::Value::undefined();
}
};
} // namespace uniffi::foobar
// Implementation of callback function calling from Rust to JS CallbackInterfaceBinaryOperatorMethod0
// Callback function: uniffi::foobar::cb::callbackinterfacebinaryoperatormethod0::UniffiCallbackInterfaceBinaryOperatorMethod0
//
// We have the following constraints:
// - we need to pass a function pointer to Rust.
// - we need a jsi::Runtime and jsi::Function to call into JS.
// - function pointers can't store state, so we can't use a lamda.
//
// For this, we store a lambda as a global, as `rsLambda`. The `callback` function calls
// the lambda, which itself calls the `body` which then calls into JS.
//
// We then give the `callback` function pointer to Rust which will call the lambda sometime in the
// future.
namespace uniffi::foobar::cb::callbackinterfacebinaryoperatormethod0 {
using namespace facebook;
// We need to store a lambda in a global so we can call it from
// a function pointer. The function pointer is passed to Rust.
static std::function<void(uint64_t, int64_t, int64_t, int64_t *, RustCallStatus*)> rsLambda = nullptr;
// This is the main body of the callback. It's called from the lambda,
// which itself is called from the callback function which is passed to Rust.
static void body(jsi::Runtime &rt,
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
std::shared_ptr<jsi::Value> callbackValue
,uint64_t rs_uniffiHandle
,int64_t rs_lhs
,int64_t rs_rhs
,int64_t * rs_uniffiOutReturn, RustCallStatus* uniffi_call_status) {
// Convert the arguments from Rust, into jsi::Values.
// We'll use the Bridging class to do this…
auto js_uniffiHandle = uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
auto js_lhs = uniffi_jsi::Bridging<int64_t>::toJs(rt, callInvoker, rs_lhs);
auto js_rhs = uniffi_jsi::Bridging<int64_t>::toJs(rt, callInvoker, rs_rhs);
// Now we are ready to call the callback.
// We are already on the JS thread, because this `body` function was
// invoked from the CallInvoker.
try {
// Getting the callback function
auto cb = callbackValue->asObject(rt).asFunction(rt);
auto uniffiResult = cb.call(rt, js_uniffiHandle, js_lhs, js_rhs
);
// Now copy the result back from JS into the RustCallStatus object.
uniffi::foobar::Bridging<RustCallStatus>::copyFromJs(rt, callInvoker, uniffiResult, uniffi_call_status);
if (uniffi_call_status->code != UNIFFI_CALL_STATUS_OK) {
// The JS callback finished abnormally, so we cannot retrieve the return value.
return;
}
// return type is MutReference(Int64)
// Finally, we need to copy the return value back into the Rust pointer.
*rs_uniffiOutReturn =
uniffi_jsi::Bridging<
ReferenceHolder<int64_t>
>::fromJs(
rt, callInvoker, uniffiResult
);
} catch (const jsi::JSError &error) {
std::cout << "Error in callback UniffiCallbackInterfaceBinaryOperatorMethod0: "
<< error.what() << std::endl;
throw error;
}
}
static void callback(uint64_t rs_uniffiHandle, int64_t rs_lhs, int64_t rs_rhs, int64_t * rs_uniffiOutReturn, RustCallStatus* uniffi_call_status) {
// If the runtime has shutdown, then there is no point in trying to
// call into Javascript. BUT how do we tell if the runtime has shutdown?
//
// Answer: the module destructor calls into callback `cleanup` method,
// which nulls out the rsLamda.
//
// If rsLamda is null, then there is no runtime to call into.
if (rsLambda == nullptr) {
// This only occurs when destructors are calling into Rust free/drop,
// which causes the JS callback to be dropped.
return;
}
// The runtime, the actual callback jsi::funtion, and the callInvoker
// are all in the lambda.
rsLambda(
rs_uniffiHandle,
rs_lhs,
rs_rhs,
rs_uniffiOutReturn, uniffi_call_status);
}
static UniffiCallbackInterfaceBinaryOperatorMethod0
makeCallbackFunction( // uniffi::foobar::cb::callbackinterfacebinaryoperatormethod0
jsi::Runtime &rt,
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
const jsi::Value &value) {
if (rsLambda != nullptr) {
// `makeCallbackFunction` is called in two circumstances:
//
// 1. at startup, when initializing callback interface vtables.
// 2. when polling futures. This happens at least once per future that is
// exposed to Javascript. We know that this is always the same function,
// `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
//
// We can therefore return the callback function without making anything
// new if we've been initialized already.
return callback;
}
auto callbackFunction = value.asObject(rt).asFunction(rt);
auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_uniffiHandle, int64_t rs_lhs, int64_t rs_rhs, int64_t * rs_uniffiOutReturn, RustCallStatus* uniffi_call_status) {
// We immediately make a lambda which will do the work of transforming the
// arguments into JSI values and calling the callback.
uniffi_runtime::UniffiCallFunc jsLambda = [
callInvoker,
callbackValue
, rs_uniffiHandle
, rs_lhs
, rs_rhs
, rs_uniffiOutReturn, uniffi_call_status](jsi::Runtime &rt) mutable {
body(rt, callInvoker, callbackValue
, rs_uniffiHandle
, rs_lhs
, rs_rhs
, rs_uniffiOutReturn, uniffi_call_status);
};
// We'll then call that lambda from the callInvoker which will
// look after calling it on the correct thread.
callInvoker->invokeBlocking(rt, jsLambda);
};
return callback;
}
// This method is called from the destructor of NativeFoobar, which only happens
// when the jsi::Runtime is being destroyed.
static void cleanup() {
// The lambda holds a reference to the the Runtime, so when this is nulled out,
// then the pointer will no longer be left dangling.
rsLambda = nullptr;
}
} // namespace uniffi::foobar::cb::callbackinterfacebinaryoperatormethod0
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiVTableCallbackInterfaceBinaryOperator> {
static UniffiVTableCallbackInterfaceBinaryOperator fromJs(jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &jsValue
) {
// Check if the input is an object
if (!jsValue.isObject()) {
throw jsi::JSError(rt, "Expected an object for UniffiVTableCallbackInterfaceBinaryOperator");
}
// Get the object from the jsi::Value
auto jsObject = jsValue.getObject(rt);
// Create the vtable struct
UniffiVTableCallbackInterfaceBinaryOperator rsObject;
// Create the vtable from the js callbacks.
rsObject.perform = uniffi::foobar::cb::callbackinterfacebinaryoperatormethod0::makeCallbackFunction(
rt, callInvoker, jsObject.getProperty(rt, "perform")
);
rsObject.uniffi_free = uniffi::foobar::st::vtablecallbackinterfacebinaryoperator::vtablecallbackinterfacebinaryoperator::free::makeCallbackFunction(
rt, callInvoker, jsObject.getProperty(rt, "uniffiFree")
);
return rsObject;
}
};
} // namespace uniffi::foobar
namespace uniffi::foobar {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
template <> struct Bridging<UniffiRustFutureContinuationCallback> {
static UniffiRustFutureContinuationCallback fromJs(
jsi::Runtime &rt,
std::shared_ptr<CallInvoker> callInvoker,
const jsi::Value &value
) {
try {
return uniffi::foobar::cb::rustfuturecontinuationcallback::makeCallbackFunction(
rt,
callInvoker,
value
);
} catch (const std::logic_error &e) {
throw jsi::JSError(rt, e.what());
}
}
};
} // namespace uniffi::foobar
NativeFoobar::NativeFoobar(
jsi::Runtime &rt,
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> invoker
) : callInvoker(invoker), props() {
// Map from Javascript names to the cpp names
props["ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_internal_fn_func_ffi__string_to_byte_length(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_internal_fn_func_ffi__string_to_arraybuffer(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_clone_binaryoperator"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_clone_binaryoperator"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_clone_binaryoperator(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_free_binaryoperator"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_free_binaryoperator"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_free_binaryoperator(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_init_callback_vtable_binaryoperator"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_init_callback_vtable_binaryoperator"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_init_callback_vtable_binaryoperator(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_method_binaryoperator_perform"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_method_binaryoperator_perform"),
3,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_method_binaryoperator_perform(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_clone_calculator"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_clone_calculator"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_clone_calculator(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_free_calculator"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_free_calculator"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_free_calculator(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_constructor_calculator_new"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_constructor_calculator_new"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_constructor_calculator_new(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_method_calculator_calculate"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_method_calculator_calculate"),
4,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_method_calculator_calculate(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_method_calculator_calculate_more"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_method_calculator_calculate_more"),
3,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_method_calculator_calculate_more(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_method_calculator_last_result"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_method_calculator_last_result"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_method_calculator_last_result(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_clone_safeaddition"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_clone_safeaddition"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_clone_safeaddition(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_free_safeaddition"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_free_safeaddition"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_free_safeaddition(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_constructor_safeaddition_new"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_constructor_safeaddition_new"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_constructor_safeaddition_new(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_method_safeaddition_perform"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_method_safeaddition_perform"),
3,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_method_safeaddition_perform(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_clone_safedivision"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_clone_safedivision"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_clone_safedivision(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_free_safedivision"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_free_safedivision"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_free_safedivision(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_constructor_safedivision_new"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_constructor_safedivision_new"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_constructor_safedivision_new(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_method_safedivision_perform"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_method_safedivision_perform"),
3,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_method_safedivision_perform(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_func_safe_addition_operator"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_func_safe_addition_operator"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_func_safe_addition_operator(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_fn_func_safe_division_operator"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_func_safe_division_operator"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_fn_func_safe_division_operator(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_checksum_func_safe_addition_operator"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_func_safe_addition_operator"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_checksum_func_safe_addition_operator(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_checksum_func_safe_division_operator"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_func_safe_division_operator"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_checksum_func_safe_division_operator(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_checksum_method_binaryoperator_perform"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_method_binaryoperator_perform"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_checksum_method_binaryoperator_perform(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_checksum_method_calculator_calculate"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_method_calculator_calculate"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_checksum_method_calculator_calculate(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_checksum_method_calculator_calculate_more"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_method_calculator_calculate_more"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_checksum_method_calculator_calculate_more(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_checksum_method_calculator_last_result"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_method_calculator_last_result"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_checksum_method_calculator_last_result(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_checksum_method_safeaddition_perform"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_method_safeaddition_perform"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_checksum_method_safeaddition_perform(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_checksum_method_safedivision_perform"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_method_safedivision_perform"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_checksum_method_safedivision_perform(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_checksum_constructor_calculator_new"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_constructor_calculator_new"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_checksum_constructor_calculator_new(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_checksum_constructor_safeaddition_new"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_constructor_safeaddition_new"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_checksum_constructor_safeaddition_new(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_foobar_checksum_constructor_safedivision_new"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_constructor_safedivision_new"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_foobar_checksum_constructor_safedivision_new(rt, thisVal, args, count);
}
);
props["ubrn_ffi_foobar_uniffi_contract_version"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_ffi_foobar_uniffi_contract_version"),
0,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_ffi_foobar_uniffi_contract_version(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_internal_fn_method_binaryoperator_ffi__bless_pointer"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_method_binaryoperator_ffi__bless_pointer"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_internal_fn_method_binaryoperator_ffi__bless_pointer(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_internal_fn_method_calculator_ffi__bless_pointer"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_method_calculator_ffi__bless_pointer"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_internal_fn_method_calculator_ffi__bless_pointer(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_internal_fn_method_safeaddition_ffi__bless_pointer"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_method_safeaddition_ffi__bless_pointer"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_internal_fn_method_safeaddition_ffi__bless_pointer(rt, thisVal, args, count);
}
);
props["ubrn_uniffi_internal_fn_method_safedivision_ffi__bless_pointer"] = jsi::Function::createFromHostFunction(
rt,
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_method_safedivision_ffi__bless_pointer"),
1,
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
return this->cpp_uniffi_internal_fn_method_safedivision_ffi__bless_pointer(rt, thisVal, args, count);
}
);
}
void NativeFoobar::registerModule(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> callInvoker) {
auto invoker = std::make_shared<uniffi_runtime::UniffiCallInvoker>(callInvoker);
auto tm = std::make_shared<NativeFoobar>(rt, invoker);
auto obj = rt.global().createFromHostObject(rt, tm);
rt.global().setProperty(rt, "NativeFoobar", obj);
}
void NativeFoobar::unregisterModule(jsi::Runtime &rt) {
uniffi::foobar::registry::clearRegistry();
}
jsi::Value NativeFoobar::get(jsi::Runtime& rt, const jsi::PropNameID& name) {
try {
return jsi::Value(rt, props.at(name.utf8(rt)));
}
catch (std::out_of_range &e) {
return jsi::Value::undefined();
}
}
std::vector<jsi::PropNameID> NativeFoobar::getPropertyNames(jsi::Runtime& rt) {
std::vector<jsi::PropNameID> rval;
for (auto& [key, value] : props) {
rval.push_back(jsi::PropNameID::forUtf8(rt, key));
}
return rval;
}
void NativeFoobar::set(jsi::Runtime& rt, const jsi::PropNameID& name, const jsi::Value& value) {
props.insert_or_assign(name.utf8(rt), &value);
}
NativeFoobar::~NativeFoobar() {
// Cleanup for callback function RustFutureContinuationCallback
uniffi::foobar::cb::rustfuturecontinuationcallback::cleanup();
// Cleanup for "free" callback function CallbackInterfaceFree
uniffi::foobar::st::foreignfuture::foreignfuture::free::cleanup();uniffi::foobar::st::vtablecallbackinterfacebinaryoperator::vtablecallbackinterfacebinaryoperator::free::cleanup();
// Cleanup for callback function CallbackInterfaceBinaryOperatorMethod0
uniffi::foobar::cb::callbackinterfacebinaryoperatormethod0::cleanup();
}
// Utility functions for serialization/deserialization of strings.
jsi::Value NativeFoobar::cpp_uniffi_internal_fn_func_ffi__string_to_byte_length(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
return uniffi_jsi::Bridging<std::string>::string_to_bytelength(rt, args[0]);
}
jsi::Value NativeFoobar::cpp_uniffi_internal_fn_func_ffi__string_to_arraybuffer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
return uniffi_jsi::Bridging<std::string>::string_to_arraybuffer(rt, args[0]);
}
jsi::Value NativeFoobar::cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
return uniffi_jsi::Bridging<std::string>::arraybuffer_to_string(rt, args[0]);
}jsi::Value NativeFoobar::cpp_uniffi_internal_fn_method_binaryoperator_ffi__bless_pointer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto pointer = uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]);
auto static destructor = [](uint64_t p) {
auto pointer = reinterpret_cast<void *>(static_cast<uintptr_t>(p));
RustCallStatus status = {0};
uniffi_foobar_fn_free_binaryoperator(pointer, &status);
};
auto ptrObj = std::make_shared<uniffi_jsi::DestructibleObject>(pointer, destructor);
auto obj = jsi::Object::createFromHostObject(rt, ptrObj);
return jsi::Value(rt, obj);
}jsi::Value NativeFoobar::cpp_uniffi_internal_fn_method_calculator_ffi__bless_pointer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto pointer = uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]);
auto static destructor = [](uint64_t p) {
auto pointer = reinterpret_cast<void *>(static_cast<uintptr_t>(p));
RustCallStatus status = {0};
uniffi_foobar_fn_free_calculator(pointer, &status);
};
auto ptrObj = std::make_shared<uniffi_jsi::DestructibleObject>(pointer, destructor);
auto obj = jsi::Object::createFromHostObject(rt, ptrObj);
return jsi::Value(rt, obj);
}jsi::Value NativeFoobar::cpp_uniffi_internal_fn_method_safeaddition_ffi__bless_pointer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto pointer = uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]);
auto static destructor = [](uint64_t p) {
auto pointer = reinterpret_cast<void *>(static_cast<uintptr_t>(p));
RustCallStatus status = {0};
uniffi_foobar_fn_free_safeaddition(pointer, &status);
};
auto ptrObj = std::make_shared<uniffi_jsi::DestructibleObject>(pointer, destructor);
auto obj = jsi::Object::createFromHostObject(rt, ptrObj);
return jsi::Value(rt, obj);
}jsi::Value NativeFoobar::cpp_uniffi_internal_fn_method_safedivision_ffi__bless_pointer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto pointer = uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]);
auto static destructor = [](uint64_t p) {
auto pointer = reinterpret_cast<void *>(static_cast<uintptr_t>(p));
RustCallStatus status = {0};
uniffi_foobar_fn_free_safedivision(pointer, &status);
};
auto ptrObj = std::make_shared<uniffi_jsi::DestructibleObject>(pointer, destructor);
auto obj = jsi::Object::createFromHostObject(rt, ptrObj);
return jsi::Value(rt, obj);
}
// Methods calling directly into the uniffi generated C API of the Rust crate.
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_clone_binaryoperator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_clone_binaryoperator(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_free_binaryoperator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
uniffi_foobar_fn_free_binaryoperator(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return jsi::Value::undefined();
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_init_callback_vtable_binaryoperator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto vtableInstance =
uniffi::foobar::Bridging<UniffiVTableCallbackInterfaceBinaryOperator>::fromJs(
rt,
callInvoker,
args[0]
);
std::lock_guard<std::mutex> lock(uniffi::foobar::registry::vtableMutex);
uniffi_foobar_fn_init_callback_vtable_binaryoperator(
uniffi::foobar::registry::putTable(
"UniffiVTableCallbackInterfaceBinaryOperator",
vtableInstance
)
);
return jsi::Value::undefined();
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_method_binaryoperator_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_method_binaryoperator_perform(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]), uniffi_jsi::Bridging<int64_t>::fromJs(rt, callInvoker, args[1]), uniffi_jsi::Bridging<int64_t>::fromJs(rt, callInvoker, args[2]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<int64_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_clone_calculator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_clone_calculator(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_free_calculator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
uniffi_foobar_fn_free_calculator(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return jsi::Value::undefined();
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_constructor_calculator_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_constructor_calculator_new(&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_method_calculator_calculate(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_method_calculator_calculate(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]), uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[1]), uniffi_jsi::Bridging<int64_t>::fromJs(rt, callInvoker, args[2]), uniffi_jsi::Bridging<int64_t>::fromJs(rt, callInvoker, args[3]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_method_calculator_calculate_more(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_method_calculator_calculate_more(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]), uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[1]), uniffi_jsi::Bridging<int64_t>::fromJs(rt, callInvoker, args[2]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_method_calculator_last_result(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_method_calculator_last_result(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi::foobar::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_clone_safeaddition(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_clone_safeaddition(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_free_safeaddition(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
uniffi_foobar_fn_free_safeaddition(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return jsi::Value::undefined();
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_constructor_safeaddition_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_constructor_safeaddition_new(&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_method_safeaddition_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_method_safeaddition_perform(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]), uniffi_jsi::Bridging<int64_t>::fromJs(rt, callInvoker, args[1]), uniffi_jsi::Bridging<int64_t>::fromJs(rt, callInvoker, args[2]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<int64_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_clone_safedivision(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_clone_safedivision(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_free_safedivision(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
uniffi_foobar_fn_free_safedivision(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return jsi::Value::undefined();
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_constructor_safedivision_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_constructor_safedivision_new(&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_method_safedivision_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_method_safedivision_perform(uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]), uniffi_jsi::Bridging<int64_t>::fromJs(rt, callInvoker, args[1]), uniffi_jsi::Bridging<int64_t>::fromJs(rt, callInvoker, args[2]),
&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<int64_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_func_safe_addition_operator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_func_safe_addition_operator(&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_func_safe_division_operator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
RustCallStatus status = uniffi::foobar::Bridging<RustCallStatus>::rustSuccess(rt);
auto value = uniffi_foobar_fn_func_safe_division_operator(&status
);
uniffi::foobar::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_func_safe_addition_operator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto value = uniffi_foobar_checksum_func_safe_addition_operator(
);
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_func_safe_division_operator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto value = uniffi_foobar_checksum_func_safe_division_operator(
);
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_method_binaryoperator_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto value = uniffi_foobar_checksum_method_binaryoperator_perform(
);
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_method_calculator_calculate(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto value = uniffi_foobar_checksum_method_calculator_calculate(
);
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_method_calculator_calculate_more(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto value = uniffi_foobar_checksum_method_calculator_calculate_more(
);
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_method_calculator_last_result(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto value = uniffi_foobar_checksum_method_calculator_last_result(
);
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_method_safeaddition_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto value = uniffi_foobar_checksum_method_safeaddition_perform(
);
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_method_safedivision_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto value = uniffi_foobar_checksum_method_safedivision_perform(
);
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_constructor_calculator_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto value = uniffi_foobar_checksum_constructor_calculator_new(
);
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_constructor_safeaddition_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto value = uniffi_foobar_checksum_constructor_safeaddition_new(
);
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_constructor_safedivision_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto value = uniffi_foobar_checksum_constructor_safedivision_new(
);
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFoobar::cpp_ffi_foobar_uniffi_contract_version(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
auto value = ffi_foobar_uniffi_contract_version(
);
return uniffi_jsi::Bridging<uint32_t>::toJs(rt, callInvoker, value);
}