From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- toolkit/components/uniffi-js/OwnedRustBuffer.cpp | 100 ++ toolkit/components/uniffi-js/OwnedRustBuffer.h | 69 ++ toolkit/components/uniffi-js/README.md | 23 + toolkit/components/uniffi-js/ScaffoldingCall.h | 260 +++++ .../components/uniffi-js/ScaffoldingConverter.h | 204 ++++ toolkit/components/uniffi-js/UniFFICallbacks.cpp | 164 +++ toolkit/components/uniffi-js/UniFFICallbacks.h | 75 ++ .../uniffi-js/UniFFIFixtureScaffolding.cpp | 1078 ++++++++++++++++++++ .../uniffi-js/UniFFIGeneratedScaffolding.cpp | 488 +++++++++ toolkit/components/uniffi-js/UniFFIPointer.cpp | 118 +++ toolkit/components/uniffi-js/UniFFIPointer.h | 69 ++ toolkit/components/uniffi-js/UniFFIPointerType.h | 29 + toolkit/components/uniffi-js/UniFFIRust.h | 51 + toolkit/components/uniffi-js/UniFFIScaffolding.cpp | 162 +++ toolkit/components/uniffi-js/UniFFIScaffolding.h | 52 + toolkit/components/uniffi-js/js/UniFFI.sys.mjs | 39 + toolkit/components/uniffi-js/moz.build | 36 + 17 files changed, 3017 insertions(+) create mode 100644 toolkit/components/uniffi-js/OwnedRustBuffer.cpp create mode 100644 toolkit/components/uniffi-js/OwnedRustBuffer.h create mode 100644 toolkit/components/uniffi-js/README.md create mode 100644 toolkit/components/uniffi-js/ScaffoldingCall.h create mode 100644 toolkit/components/uniffi-js/ScaffoldingConverter.h create mode 100644 toolkit/components/uniffi-js/UniFFICallbacks.cpp create mode 100644 toolkit/components/uniffi-js/UniFFICallbacks.h create mode 100644 toolkit/components/uniffi-js/UniFFIFixtureScaffolding.cpp create mode 100644 toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp create mode 100644 toolkit/components/uniffi-js/UniFFIPointer.cpp create mode 100644 toolkit/components/uniffi-js/UniFFIPointer.h create mode 100644 toolkit/components/uniffi-js/UniFFIPointerType.h create mode 100644 toolkit/components/uniffi-js/UniFFIRust.h create mode 100644 toolkit/components/uniffi-js/UniFFIScaffolding.cpp create mode 100644 toolkit/components/uniffi-js/UniFFIScaffolding.h create mode 100644 toolkit/components/uniffi-js/js/UniFFI.sys.mjs create mode 100644 toolkit/components/uniffi-js/moz.build (limited to 'toolkit/components/uniffi-js') diff --git a/toolkit/components/uniffi-js/OwnedRustBuffer.cpp b/toolkit/components/uniffi-js/OwnedRustBuffer.cpp new file mode 100644 index 0000000000..4e334a966e --- /dev/null +++ b/toolkit/components/uniffi-js/OwnedRustBuffer.cpp @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsString.h" +#include "mozilla/dom/OwnedRustBuffer.h" + +namespace mozilla::uniffi { + +using dom::ArrayBuffer; + +OwnedRustBuffer::OwnedRustBuffer(const RustBuffer& aBuf) { + mBuf = aBuf; + MOZ_ASSERT(IsValid()); +} + +Result OwnedRustBuffer::FromArrayBuffer( + const ArrayBuffer& aArrayBuffer) { + return aArrayBuffer.ProcessData( + [](const Span& aData, + JS::AutoCheckCannotGC&&) -> Result { + if (aData.Length() > INT32_MAX) { + return Err("Input ArrayBuffer is too large"_ns); + } + + RustCallStatus status{}; + RustBuffer buf = uniffi_rustbuffer_alloc( + static_cast(aData.Length()), &status); + buf.len = aData.Length(); + if (status.code != 0) { + if (status.error_buf.data) { + auto message = nsCString("uniffi_rustbuffer_alloc: "); + message.Append(nsDependentCSubstring( + reinterpret_cast(status.error_buf.data), + status.error_buf.len)); + RustCallStatus status2{}; + uniffi_rustbuffer_free(status.error_buf, &status2); + MOZ_RELEASE_ASSERT(status2.code == 0, + "Freeing a rustbuffer should never fail"); + return Err(message); + } + + return Err("Unknown error allocating rust buffer"_ns); + } + + memcpy(buf.data, aData.Elements(), buf.len); + return OwnedRustBuffer(buf); + }); +} + +OwnedRustBuffer::OwnedRustBuffer(OwnedRustBuffer&& aOther) : mBuf(aOther.mBuf) { + aOther.mBuf = RustBuffer{0}; +} + +OwnedRustBuffer& OwnedRustBuffer::operator=(OwnedRustBuffer&& aOther) { + if (&aOther != this) { + FreeData(); + } + mBuf = aOther.mBuf; + aOther.mBuf = RustBuffer{0}; + return *this; +} + +void OwnedRustBuffer::FreeData() { + if (IsValid()) { + RustCallStatus status{}; + uniffi_rustbuffer_free(mBuf, &status); + MOZ_RELEASE_ASSERT(status.code == 0, + "Freeing a rustbuffer should never fail"); + mBuf = {0}; + } +} + +OwnedRustBuffer::~OwnedRustBuffer() { FreeData(); } + +RustBuffer OwnedRustBuffer::IntoRustBuffer() { + RustBuffer rv = mBuf; + mBuf = {}; + return rv; +} + +JSObject* OwnedRustBuffer::IntoArrayBuffer(JSContext* cx) { + JS::Rooted obj(cx); + { + int32_t len = mBuf.len; + void* data = mBuf.data; + auto userData = MakeUnique(std::move(*this)); + UniquePtr dataPtr{ + data, {&ArrayBufferFreeFunc, userData.release()}}; + obj = JS::NewExternalArrayBuffer(cx, len, std::move(dataPtr)); + } + return obj; +} + +void OwnedRustBuffer::ArrayBufferFreeFunc(void* contents, void* userData) { + UniquePtr buf{reinterpret_cast(userData)}; +} +} // namespace mozilla::uniffi diff --git a/toolkit/components/uniffi-js/OwnedRustBuffer.h b/toolkit/components/uniffi-js/OwnedRustBuffer.h new file mode 100644 index 0000000000..d43a233306 --- /dev/null +++ b/toolkit/components/uniffi-js/OwnedRustBuffer.h @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_OwnedRustBuffer_h +#define mozilla_OwnedRustBuffer_h + +#include "mozilla/ErrorResult.h" +#include "mozilla/ResultVariant.h" +#include "mozilla/dom/TypedArray.h" +#include "mozilla/dom/UniFFIRust.h" + +namespace mozilla::uniffi { + +// RustBuffer that's owned by the JS code and handles the memory management +class OwnedRustBuffer final { + private: + RustBuffer mBuf; + + void FreeData(); + + public: + // The default constructor creates an invalid OwnedRustBuffer + OwnedRustBuffer() : mBuf{0} {}; + + // Constructor for creating an OwnedRustBuffer from a raw RustBuffer struct + // that was returned by Rust (therefore we now own the RustBuffer). + explicit OwnedRustBuffer(const RustBuffer& aBuf); + + // Manual implementation of move constructor and assignment operator. + OwnedRustBuffer(OwnedRustBuffer&& aOther); + OwnedRustBuffer& operator=(OwnedRustBuffer&& aOther); + + // Delete copy & move constructor as this type is non-copyable. + OwnedRustBuffer(const OwnedRustBuffer&) = delete; + OwnedRustBuffer& operator=(const OwnedRustBuffer&) = delete; + + // Destructor that frees the RustBuffer if it is still valid + ~OwnedRustBuffer(); + + // Constructor for creating an OwnedRustBuffer from an ArrayBuffer. Will set + // aError to failed and construct an invalid OwnedRustBuffer if the + // conversion failed. + static Result FromArrayBuffer( + const mozilla::dom::ArrayBuffer& aArrayBuffer); + + // Moves the buffer out of this `OwnedArrayBuffer` into a raw `RustBuffer` + // struct. The raw struct must be passed into a Rust function, transfering + // ownership to Rust. After this call the buffer will no longer be valid. + RustBuffer IntoRustBuffer(); + + // Moves the buffer out of this `OwnedArrayBuffer` into a JS ArrayBuffer. + // This transfers ownership into the JS engine. After this call the buffer + // will no longer be valid. + JSObject* IntoArrayBuffer(JSContext* cx); + + // Is this RustBuffer pointing to valid data? + bool IsValid() const { return mBuf.data != nullptr; } + + private: + // Helper function used by IntoArrayBuffer. + static void ArrayBufferFreeFunc(void* contents, void* userData); +}; + +} // namespace mozilla::uniffi + +#endif // mozilla_OwnedRustBuffer_h diff --git a/toolkit/components/uniffi-js/README.md b/toolkit/components/uniffi-js/README.md new file mode 100644 index 0000000000..addd0b4bcc --- /dev/null +++ b/toolkit/components/uniffi-js/README.md @@ -0,0 +1,23 @@ +# uniffi-js + +This directory contains C++ helper code for the UniFFI Rust library +(https://github.com/mozilla/uniffi-rs/). + + - `UniFFIPointer.*` and `UniFFIPointerType.*` implement the `UniFFIPointer` WebIDL class + + - `UniFFI*Scaffolding.cpp` implements the `UniFFIScaffolding` WebIDL class. + - UniFFIGeneratedScaffolding.cpp contains the generated code for all + non-testing UDL files. + - UniFFIFixtureScaffolding.cpp contains generated code for test fixture UDL + files. It's only compiled if `--enable-uniffi-fixtures` is set. + - UniFFIScaffolding.cpp is a facade that wraps UniFFIFixtureScaffolding, and + UniFFIGeneratedScaffolding if enabled, to implement the interface. + +- `ScaffoldingConverter.h`, `ScaffoldingCall.h` contain generic code to make + the scaffolding calls. In general, we try to keep the logic of the calls in + these files and limit the generated code to routing call IDs to template + classes defined here. + +- `OwnedRustBuffer.*` implements a C++ class to help manager ownership of a RustBuffer. + +- `UniFFIRust.h` contains definitions for the C functions that UniFFI exports. diff --git a/toolkit/components/uniffi-js/ScaffoldingCall.h b/toolkit/components/uniffi-js/ScaffoldingCall.h new file mode 100644 index 0000000000..02b016c513 --- /dev/null +++ b/toolkit/components/uniffi-js/ScaffoldingCall.h @@ -0,0 +1,260 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_ScaffoldingCall_h +#define mozilla_ScaffoldingCall_h + +#include +#include +#include "nsIGlobalObject.h" +#include "nsPrintfCString.h" +#include "mozilla/MozPromise.h" +#include "mozilla/ResultVariant.h" +#include "mozilla/dom/OwnedRustBuffer.h" +#include "mozilla/dom/Promise.h" +#include "mozilla/dom/ScaffoldingConverter.h" +#include "mozilla/dom/UniFFIBinding.h" +#include "mozilla/dom/UniFFIRust.h" + +namespace mozilla::uniffi { + +// Low-level result of calling a scaffolding function +// +// This stores what Rust returned in order to convert it into +// UniFFIScaffoldingCallResult +template +struct RustCallResult { + ReturnType mReturnValue; + RustCallStatus mCallStatus = {}; +}; + +template <> +struct RustCallResult { + RustCallStatus mCallStatus = {}; +}; + +// Does the work required to call a scaffolding function +// +// This class is generic over the type signature of the scaffolding function. +// This seems better than being generic over the functions themselves, since it +// saves space whenever 2 functions share a signature. +template +class ScaffoldingCallHandler { + public: + // Pointer to a scaffolding function that can be called by this + // ScaffoldingConverter + using ScaffoldingFunc = typename ReturnConverter::RustType (*)( + typename ArgConverters::RustType..., RustCallStatus*); + + // Perform an async scaffolding call + static already_AddRefed CallAsync( + ScaffoldingFunc aScaffoldingFunc, const dom::GlobalObject& aGlobal, + const dom::Sequence& aArgs, + const nsLiteralCString& aFuncName, ErrorResult& aError) { + auto convertResult = ConvertJsArgs(aArgs); + if (convertResult.isErr()) { + aError.ThrowUnknownError(aFuncName + convertResult.unwrapErr()); + return nullptr; + } + auto convertedArgs = convertResult.unwrap(); + + // Create the promise that we return to JS + nsCOMPtr xpcomGlobal = + do_QueryInterface(aGlobal.GetAsSupports()); + RefPtr returnPromise = + dom::Promise::Create(xpcomGlobal, aError); + if (aError.Failed()) { + return nullptr; + } + + // Create a second promise that gets resolved by a background task that + // calls the scaffolding function + RefPtr taskPromise = new typename TaskPromiseType::Private(aFuncName.get()); + nsresult dispatchResult = NS_DispatchBackgroundTask( + NS_NewRunnableFunction(aFuncName.get(), + [args = std::move(convertedArgs), taskPromise, + aScaffoldingFunc, aFuncName]() mutable { + auto callResult = CallScaffoldingFunc( + aScaffoldingFunc, std::move(args)); + taskPromise->Resolve(std::move(callResult), + aFuncName.get()); + }), + NS_DISPATCH_EVENT_MAY_BLOCK); + if (NS_FAILED(dispatchResult)) { + taskPromise->Reject(dispatchResult, aFuncName.get()); + } + + // When the background task promise completes, resolve the JS promise + taskPromise->Then( + GetCurrentSerialEventTarget(), aFuncName.get(), + [xpcomGlobal, returnPromise, + aFuncName](typename TaskPromiseType::ResolveOrRejectValue&& aResult) { + if (!aResult.IsResolve()) { + returnPromise->MaybeRejectWithUnknownError(aFuncName); + return; + } + + dom::AutoEntryScript aes(xpcomGlobal, aFuncName.get()); + dom::RootedDictionary returnValue( + aes.cx()); + + ReturnResult(aes.cx(), aResult.ResolveValue(), returnValue, + aFuncName); + returnPromise->MaybeResolve(returnValue); + }); + + // Return the JS promise, using forget() to convert it to already_AddRefed + return returnPromise.forget(); + } + + // Perform an sync scaffolding call + // + // aFuncName should be a literal C string + static void CallSync( + ScaffoldingFunc aScaffoldingFunc, const dom::GlobalObject& aGlobal, + const dom::Sequence& aArgs, + dom::RootedDictionary& aReturnValue, + const nsLiteralCString& aFuncName, ErrorResult& aError) { + auto convertResult = ConvertJsArgs(aArgs); + if (convertResult.isErr()) { + aError.ThrowUnknownError(aFuncName + convertResult.unwrapErr()); + return; + } + + auto callResult = CallScaffoldingFunc(aScaffoldingFunc, + std::move(convertResult.unwrap())); + + ReturnResult(aGlobal.Context(), callResult, aReturnValue, aFuncName); + } + + private: + using RustArgs = std::tuple; + using IntermediateArgs = + std::tuple; + using CallResult = RustCallResult; + using TaskPromiseType = MozPromise; + + template + using NthArgConverter = + typename std::tuple_element>::type; + + // Convert arguments from JS + // + // This should be called in the main thread + static Result ConvertJsArgs( + const dom::Sequence& aArgs) { + IntermediateArgs convertedArgs; + if (aArgs.Length() != std::tuple_size_v) { + return mozilla::Err("Wrong argument count"_ns); + } + auto result = PrepareArgsHelper<0>(aArgs, convertedArgs); + return result.map([&](auto _) { return std::move(convertedArgs); }); + } + + // Helper function for PrepareArgs that uses c++ magic to help with iteration + template + static Result PrepareArgsHelper( + const dom::Sequence& aArgs, + IntermediateArgs& aConvertedArgs) { + if constexpr (I >= sizeof...(ArgConverters)) { + // Iteration complete + return mozilla::Ok(); + } else { + // Single iteration step + auto result = NthArgConverter::FromJs(aArgs[I]); + if (result.isOk()) { + // The conversion worked, store our result and move on to the next + std::get(aConvertedArgs) = result.unwrap(); + return PrepareArgsHelper(aArgs, aConvertedArgs); + } else { + // The conversion failed, return an error and don't continue + return mozilla::Err(result.unwrapErr() + + nsPrintfCString(" (arg %zu)", I)); + } + } + } + + // Call the scaffolding function + // + // For async calls this should be called in the worker thread + static CallResult CallScaffoldingFunc(ScaffoldingFunc aFunc, + IntermediateArgs&& aArgs) { + return CallScaffoldingFuncHelper( + aFunc, std::move(aArgs), std::index_sequence_for()); + } + + // Helper function for CallScaffoldingFunc that uses c++ magic to help with + // iteration + template + static CallResult CallScaffoldingFuncHelper(ScaffoldingFunc aFunc, + IntermediateArgs&& aArgs, + std::index_sequence seq) { + CallResult result; + + auto makeCall = [&]() mutable { + return aFunc( + NthArgConverter::IntoRust(std::move(std::get(aArgs)))..., + &result.mCallStatus); + }; + if constexpr (std::is_void_v) { + makeCall(); + } else { + result.mReturnValue = makeCall(); + } + return result; + } + + // Return the result of the scaffolding call back to JS + // + // This should be called on the main thread + static void ReturnResult( + JSContext* aContext, CallResult& aCallResult, + dom::RootedDictionary& aReturnValue, + const nsLiteralCString& aFuncName) { + switch (aCallResult.mCallStatus.code) { + case RUST_CALL_SUCCESS: { + aReturnValue.mCode = dom::UniFFIScaffoldingCallCode::Success; + if constexpr (!std::is_void_v) { + auto convertResult = + ReturnConverter::FromRust(aCallResult.mReturnValue); + if (convertResult.isOk()) { + ReturnConverter::IntoJs(aContext, std::move(convertResult.unwrap()), + aReturnValue.mData.Construct()); + } else { + aReturnValue.mCode = dom::UniFFIScaffoldingCallCode::Internal_error; + aReturnValue.mInternalErrorMessage.Construct( + aFuncName + " converting result: "_ns + + convertResult.unwrapErr()); + } + } + break; + } + + case RUST_CALL_ERROR: { + // Rust Err() value. Populate data with the `RustBuffer` containing the + // error + aReturnValue.mCode = dom::UniFFIScaffoldingCallCode::Error; + aReturnValue.mData.Construct().SetAsArrayBuffer().Init( + OwnedRustBuffer(aCallResult.mCallStatus.error_buf) + .IntoArrayBuffer(aContext)); + break; + } + + default: { + // This indicates a RustError, which shouldn't happen in practice since + // FF sets panic=abort + aReturnValue.mCode = dom::UniFFIScaffoldingCallCode::Internal_error; + aReturnValue.mInternalErrorMessage.Construct(aFuncName + + " Unexpected Error"_ns); + break; + } + } + } +}; + +} // namespace mozilla::uniffi + +#endif // mozilla_ScaffoldingCall_h diff --git a/toolkit/components/uniffi-js/ScaffoldingConverter.h b/toolkit/components/uniffi-js/ScaffoldingConverter.h new file mode 100644 index 0000000000..ae5629e2e4 --- /dev/null +++ b/toolkit/components/uniffi-js/ScaffoldingConverter.h @@ -0,0 +1,204 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_ScaffoldingConverter_h +#define mozilla_ScaffoldingConverter_h + +#include +#include +#include "nsString.h" +#include "mozilla/ResultVariant.h" +#include "mozilla/dom/OwnedRustBuffer.h" +#include "mozilla/dom/PrimitiveConversions.h" +#include "mozilla/dom/TypedArray.h" +#include "mozilla/dom/UniFFIBinding.h" +#include "mozilla/dom/UniFFIPointer.h" +#include "mozilla/dom/UniFFIPointerType.h" +#include "mozilla/dom/UniFFIRust.h" +#include "mozilla/dom/UniFFIScaffolding.h" + +namespace mozilla::uniffi { + +class ScaffoldingConverterTagDefault {}; + +// Handle converting types between JS and Rust +// +// Scaffolding conversions are done using a 2 step process: +// - Call FromJs/FromRust to convert to an intermediate type +// - Call IntoJs/IntoRust to convert from that type to the target type +// +// The main reason for this is handling RustBuffers when other arguments fail +// to convert. By using OwnedRustBuffer as the intermediate type, we can +// ensure those buffers get freed in that case. Note that we can't use +// OwnedRustBuffer as the Rust type. Passing the buffer into Rust transfers +// ownership so we shouldn't free the buffer in this case. +// +// For most other types, we just use the Rust type as the intermediate type. +template +class ScaffoldingConverter { + public: + using RustType = T; + using IntermediateType = T; + + // Convert a JS value to an intermedate type + // + // This inputs a const ref, because that's what the WebIDL bindings send to + // us. + // + // If this succeeds then IntoRust is also guaranteed to succeed + static mozilla::Result FromJs( + const dom::ScaffoldingType& aValue) { + if (!aValue.IsDouble()) { + return Err("Bad argument type"_ns); + } + double value = aValue.GetAsDouble(); + + if (std::isnan(value)) { + return Err("NaN not allowed"_ns); + } + + if constexpr (std::is_integral::value) { + // Use PrimitiveConversionTraits_Limits rather than std::numeric_limits, + // since it handles JS-specific bounds like the 64-bit integer limits. + // (see Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER) + if (value < dom::PrimitiveConversionTraits_Limits::min() || + value > dom::PrimitiveConversionTraits_Limits::max()) { + return Err("Out of bounds"_ns); + } + } + + // Don't check float bounds for a few reasons. + // - It's difficult because + // PrimitiveConversionTraits_Limits::min() is the smallest + // positive value, rather than the most negative. + // - A float value unlikely to overflow + // - It's also likely that we can't do an exact conversion because the + // float doesn't have enough precision, but it doesn't seem correct + // to error out in that case. + + RustType rv = static_cast(value); + if constexpr (std::is_integral::value) { + if (rv != value) { + return Err("Not an integer"_ns); + } + } + + return rv; + } + + // Convert an intermediate type to a Rust type + // + // IntoRust doesn't touch the JS data, so it's safe to call in a worker thread + static RustType IntoRust(IntermediateType aValue) { return aValue; } + + // Convert an Rust type to an intermediate type + // + // This inputs a value since RustTypes are POD types + // + // If this succeeds then IntoJs is also guaranteed to succeed + static mozilla::Result FromRust( + RustType aValue) { + if constexpr (std::is_same::value || + std::is_same::value) { + // Check that the value can fit in a double (only needed for 64 bit types) + if (aValue < dom::PrimitiveConversionTraits_Limits::min() || + aValue > dom::PrimitiveConversionTraits_Limits::max()) { + return Err("Out of bounds"_ns); + } + } + if constexpr (std::is_floating_point::value) { + if (std::isnan(aValue)) { + return Err("NaN not allowed"_ns); + } + } + return aValue; + } + + // Convert an intermedate type to a JS type + // + // This inputs an r-value reference since we may want to move data out of + // this type. + static void IntoJs(JSContext* aContext, IntermediateType&& aValue, + dom::ScaffoldingType& aDest) { + aDest.SetAsDouble() = aValue; + } +}; + +template <> +class ScaffoldingConverter { + public: + using RustType = RustBuffer; + using IntermediateType = OwnedRustBuffer; + + static mozilla::Result FromJs( + const dom::ScaffoldingType& aValue) { + if (!aValue.IsArrayBuffer()) { + return Err("Bad argument type"_ns); + } + + return OwnedRustBuffer::FromArrayBuffer(aValue.GetAsArrayBuffer()); + } + + static RustBuffer IntoRust(OwnedRustBuffer&& aValue) { + return aValue.IntoRustBuffer(); + } + + static mozilla::Result FromRust( + RustBuffer aValue) { + return OwnedRustBuffer(aValue); + } + + static void IntoJs(JSContext* aContext, OwnedRustBuffer&& aValue, + dom::ScaffoldingType& aDest) { + aDest.SetAsArrayBuffer().Init(aValue.IntoArrayBuffer(aContext)); + } +}; + +// ScaffoldingConverter for object pointers +template +class ScaffoldingObjectConverter { + public: + using RustType = void*; + using IntermediateType = void*; + + static mozilla::Result FromJs( + const dom::ScaffoldingType& aValue) { + if (!aValue.IsUniFFIPointer()) { + return Err("Bad argument type"_ns); + } + dom::UniFFIPointer& value = aValue.GetAsUniFFIPointer(); + if (!value.IsSamePtrType(PointerType)) { + return Err("Bad pointer type"_ns); + } + return value.GetPtr(); + } + + static void* IntoRust(void* aValue) { return aValue; } + + static mozilla::Result FromRust(void* aValue) { + return aValue; + } + + static void IntoJs(JSContext* aContext, void* aValue, + dom::ScaffoldingType& aDest) { + aDest.SetAsUniFFIPointer() = + dom::UniFFIPointer::Create(aValue, PointerType); + } +}; + +// ScaffoldingConverter for void returns +// +// This doesn't implement the normal interface, it's only use is a the +// ReturnConverter parameter of ScaffoldingCallHandler. +template <> +class ScaffoldingConverter { + public: + using RustType = void; +}; + +} // namespace mozilla::uniffi + +#endif // mozilla_ScaffoldingConverter_h diff --git a/toolkit/components/uniffi-js/UniFFICallbacks.cpp b/toolkit/components/uniffi-js/UniFFICallbacks.cpp new file mode 100644 index 0000000000..647914d73a --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFICallbacks.cpp @@ -0,0 +1,164 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsPrintfCString.h" +#include "nsString.h" +#include "nsThreadUtils.h" +#include "mozilla/dom/OwnedRustBuffer.h" +#include "mozilla/dom/RootedDictionary.h" +#include "mozilla/dom/UniFFIBinding.h" +#include "mozilla/dom/UniFFICallbacks.h" +#include "mozilla/Maybe.h" +#include "mozilla/Logging.h" +#include "mozilla/RefPtr.h" +#include "mozilla/UniquePtr.h" + +static mozilla::LazyLogModule UNIFFI_INVOKE_CALLBACK_LOGGER("uniffi"); + +namespace mozilla::uniffi { + +using dom::ArrayBuffer; +using dom::RootedDictionary; +using dom::UniFFICallbackHandler; +using dom::UniFFIScaffoldingCallCode; + +static Maybe GetCallbackInterfaceInfo( + uint64_t aInterfaceId) { + const Maybe cbiInfo = + UniFFIGetCallbackInterfaceInfo(aInterfaceId); +#ifdef MOZ_UNIFFI_FIXTURES + if (!cbiInfo) { + return UniFFIFixturesGetCallbackInterfaceInfo(aInterfaceId); + } +#endif + return cbiInfo; +} + +void RegisterCallbackHandler(uint64_t aInterfaceId, + UniFFICallbackHandler& aCallbackHandler, + ErrorResult& aError) { + // We should only be mutating mHandler on the main thread + MOZ_ASSERT(NS_IsMainThread()); + + Maybe cbiInfo = GetCallbackInterfaceInfo(aInterfaceId); + if (!cbiInfo.isSome()) { + aError.ThrowUnknownError( + nsPrintfCString("Unknown interface id: %" PRIu64, aInterfaceId)); + return; + } + + if (*cbiInfo->mHandler) { + MOZ_LOG(UNIFFI_INVOKE_CALLBACK_LOGGER, LogLevel::Error, + ("[UniFFI] Callback handler already registered for %s", + cbiInfo->mName)); + return; + } + *cbiInfo->mHandler = &aCallbackHandler; + RustCallStatus status = {0}; + cbiInfo->mInitForeignCallback(cbiInfo->mForeignCallback, &status); + // Just use MOZ_DIAGNOSTIC_ASSERT to check the status, since the call should + // always succeed. The RustCallStatus out param only exists because UniFFI + // adds it to all FFI calls. + MOZ_DIAGNOSTIC_ASSERT(status.code == RUST_CALL_SUCCESS); +} + +void DeregisterCallbackHandler(uint64_t aInterfaceId, ErrorResult& aError) { + // We should only be mutating mHandler on the main thread + MOZ_ASSERT(NS_IsMainThread()); + + Maybe cbiInfo = GetCallbackInterfaceInfo(aInterfaceId); + if (!cbiInfo.isSome()) { + aError.ThrowUnknownError( + nsPrintfCString("Unknown interface id: %" PRIu64, aInterfaceId)); + return; + } + *cbiInfo->mHandler = nullptr; +} + +MOZ_CAN_RUN_SCRIPT +static void QueueCallbackInner(uint64_t aInterfaceId, uint64_t aHandle, + uint32_t aMethod, + UniquePtr&& aArgsData, + int32_t aArgsLen) { + MOZ_ASSERT(NS_IsMainThread()); + + Maybe cbiInfo = GetCallbackInterfaceInfo(aInterfaceId); + if (!cbiInfo.isSome()) { + MOZ_LOG(UNIFFI_INVOKE_CALLBACK_LOGGER, LogLevel::Error, + ("[UniFFI] Unknown inferface id: %" PRIu64, aInterfaceId)); + return; + } + + // Take our own reference to the callback handler to ensure that it stays + // alive for the duration of this call + RefPtr ihandler = *cbiInfo->mHandler; + + if (!ihandler) { + MOZ_LOG(UNIFFI_INVOKE_CALLBACK_LOGGER, LogLevel::Error, + ("[UniFFI] JS handler for %s not registered", cbiInfo->mName)); + return; + } + + JSObject* global = ihandler->CallbackGlobalOrNull(); + if (!global) { + MOZ_LOG(UNIFFI_INVOKE_CALLBACK_LOGGER, LogLevel::Error, + ("[UniFFI] JS handler for %s has null global", cbiInfo->mName)); + return; + } + + dom::AutoEntryScript aes(global, cbiInfo->mName); + + JS::Rooted args( + aes.cx(), + JS::NewArrayBufferWithContents(aes.cx(), aArgsLen, std::move(aArgsData))); + if (!args) { + MOZ_LOG(UNIFFI_INVOKE_CALLBACK_LOGGER, LogLevel::Error, + ("[UniFFI] Failed to allocate buffer for arguments")); + return; + } + + IgnoredErrorResult error; + ihandler->Call(aHandle, aMethod, args, error); + + if (error.Failed()) { + MOZ_LOG(UNIFFI_INVOKE_CALLBACK_LOGGER, LogLevel::Error, + ("[UniFFI] Error invoking JS handler for %s", cbiInfo->mName)); + return; + } +} + +void QueueCallback(uint64_t aInterfaceId, uint64_t aHandle, uint32_t aMethod, + const uint8_t* aArgsData, int32_t aArgsLen) { + // Make a copy of aArgsData to be deserialized asynchronously on + // the main thread. + // + // This copy will be allocated in the ArrayBufferContentsArena, as + // ownership will be passed to an ArrayBuffer for deserialization. + UniquePtr argsDataOwned( + js_pod_arena_malloc(js::ArrayBufferContentsArena, aArgsLen)); + if (!argsDataOwned) { + MOZ_LOG(UNIFFI_INVOKE_CALLBACK_LOGGER, LogLevel::Error, + ("[UniFFI] Error allocating memory for arguments")); + return; + } + memcpy(argsDataOwned.get(), aArgsData, aArgsLen); + + nsresult dispatchResult = + GetMainThreadSerialEventTarget()->Dispatch(NS_NewRunnableFunction( + "UniFFI callback", [=, argsDataOwned = std::move(argsDataOwned)]() + MOZ_CAN_RUN_SCRIPT_BOUNDARY mutable { + QueueCallbackInner( + aInterfaceId, aHandle, aMethod, + std::move(argsDataOwned), aArgsLen); + })); + + if (NS_FAILED(dispatchResult)) { + MOZ_LOG(UNIFFI_INVOKE_CALLBACK_LOGGER, LogLevel::Error, + ("[UniFFI] Error dispatching UniFFI callback task")); + } +} + +} // namespace mozilla::uniffi diff --git a/toolkit/components/uniffi-js/UniFFICallbacks.h b/toolkit/components/uniffi-js/UniFFICallbacks.h new file mode 100644 index 0000000000..b18ba14f9e --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFICallbacks.h @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_UniFFICallbacks_h +#define mozilla_UniFFICallbacks_h + +#include "mozilla/StaticPtr.h" +#include "mozilla/dom/UniFFIRust.h" +#include "mozilla/dom/UniFFIScaffolding.h" + +namespace mozilla::uniffi { + +/** + * UniFFI-generated scaffolding function to initialize a callback interface + * + * The Rust code expests us to pass it a ForeignCallback entrypoint for each + * callback interface. + */ +typedef void (*CallbackInitFunc)(ForeignCallback, RustCallStatus*); + +/** + * All the information needed to handle a callback interface. + * + * The generated code includes a function that maps interface ids to one of + * these structs + */ +struct CallbackInterfaceInfo { + // Human-friendly name + const char* mName; + // JS handler + StaticRefPtr* mHandler; + // Handler function, defined in the generated C++ code + ForeignCallback mForeignCallback; + // Init function, defined in the generated Rust scaffolding. mForeignCallback + // should be passed to this. + CallbackInitFunc mInitForeignCallback; +}; + +Maybe UniFFIGetCallbackInterfaceInfo( + uint64_t aInterfaceId); + +#ifdef MOZ_UNIFFI_FIXTURES +Maybe UniFFIFixturesGetCallbackInterfaceInfo( + uint64_t aInterfaceId); +#endif + +/** + * Register the JS handler for a callback interface + */ +void RegisterCallbackHandler(uint64_t aInterfaceId, + dom::UniFFICallbackHandler& aCallbackHandler, + ErrorResult& aError); + +/** + * Deregister the JS handler for a callback interface + */ +void DeregisterCallbackHandler(uint64_t aInterfaceId, ErrorResult& aError); + +/** + * Queue a UniFFI callback interface function to run at some point + * + * This function is for fire-and-forget callbacks where the caller doesn't care + * about the return value and doesn't want to wait for the call to finish. A + * good use case for this is logging. + */ +MOZ_CAN_RUN_SCRIPT +void QueueCallback(size_t aInterfaceId, uint64_t aHandle, uint32_t aMethod, + const uint8_t* aArgsData, int32_t aArgsLen); + +} // namespace mozilla::uniffi + +#endif // mozilla_UniFFICallbacks_h diff --git a/toolkit/components/uniffi-js/UniFFIFixtureScaffolding.cpp b/toolkit/components/uniffi-js/UniFFIFixtureScaffolding.cpp new file mode 100644 index 0000000000..c0695f227c --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFIFixtureScaffolding.cpp @@ -0,0 +1,1078 @@ +// Generated by uniffi-bindgen-gecko-js. DO NOT EDIT. + +#include "nsString.h" +#include "nsPrintfCString.h" +#include "mozilla/Logging.h" +#include "mozilla/Maybe.h" +#include "mozilla/StaticPtr.h" +#include "mozilla/dom/UniFFICallbacks.h" +#include "mozilla/dom/UniFFIScaffolding.h" +#include "mozilla/dom/ScaffoldingCall.h" + +namespace mozilla::uniffi { + +using dom::ArrayBuffer; +using dom::AutoEntryScript; +using dom::GlobalObject; +using dom::RootedDictionary; +using dom::Promise; +using dom::ScaffoldingType; +using dom::Sequence; +using dom::UniFFICallbackHandler; +using dom::UniFFIPointer; +using dom::UniFFIScaffoldingCallResult; + +// Define scaffolding functions from UniFFI +extern "C" { + uint64_t uniffi_arithmetical_fn_func_add(uint64_t, uint64_t, RustCallStatus*); + uint64_t uniffi_arithmetical_fn_func_div(uint64_t, uint64_t, RustCallStatus*); + int8_t uniffi_arithmetical_fn_func_equal(uint64_t, uint64_t, RustCallStatus*); + uint64_t uniffi_arithmetical_fn_func_sub(uint64_t, uint64_t, RustCallStatus*); + RustBuffer uniffi_uniffi_custom_types_fn_func_get_custom_types_demo(RustBuffer, RustCallStatus*); + double uniffi_uniffi_fixture_external_types_fn_func_gradient(RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_fixture_external_types_fn_func_intersection(RustBuffer, RustBuffer, RustCallStatus*); + void uniffi_uniffi_fixture_callbacks_fn_init_callback_logger(ForeignCallback, RustCallStatus*); + void uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers(uint64_t, RustBuffer, RustCallStatus*); + void uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers_main_thread(uint64_t, RustBuffer, RustCallStatus*); + double uniffi_uniffi_geometry_fn_func_gradient(RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_geometry_fn_func_intersection(RustBuffer, RustBuffer, RustCallStatus*); + void uniffi_uniffi_rondpoint_fn_free_optionneur(void *, RustCallStatus*); + void * uniffi_uniffi_rondpoint_fn_constructor_optionneur_new(RustCallStatus*); + int8_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_boolean(void *, int8_t, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_enum(void *, RustBuffer, RustCallStatus*); + float uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f32(void *, float, RustCallStatus*); + double uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f64(void *, double, RustCallStatus*); + int16_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_dec(void *, int16_t, RustCallStatus*); + int16_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_hex(void *, int16_t, RustCallStatus*); + int32_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_dec(void *, int32_t, RustCallStatus*); + int32_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_hex(void *, int32_t, RustCallStatus*); + int64_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_dec(void *, int64_t, RustCallStatus*); + int64_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_hex(void *, int64_t, RustCallStatus*); + int8_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_dec(void *, int8_t, RustCallStatus*); + int8_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_hex(void *, int8_t, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_null(void *, RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_sequence(void *, RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_string(void *, RustBuffer, RustCallStatus*); + uint16_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_dec(void *, uint16_t, RustCallStatus*); + uint16_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_hex(void *, uint16_t, RustCallStatus*); + uint32_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_dec(void *, uint32_t, RustCallStatus*); + uint32_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_hex(void *, uint32_t, RustCallStatus*); + uint32_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_oct(void *, uint32_t, RustCallStatus*); + uint64_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_dec(void *, uint64_t, RustCallStatus*); + uint64_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_hex(void *, uint64_t, RustCallStatus*); + uint8_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_dec(void *, uint8_t, RustCallStatus*); + uint8_t uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_hex(void *, uint8_t, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_zero(void *, RustBuffer, RustCallStatus*); + void uniffi_uniffi_rondpoint_fn_free_retourneur(void *, RustCallStatus*); + void * uniffi_uniffi_rondpoint_fn_constructor_retourneur_new(RustCallStatus*); + int8_t uniffi_uniffi_rondpoint_fn_method_retourneur_identique_boolean(void *, int8_t, RustCallStatus*); + double uniffi_uniffi_rondpoint_fn_method_retourneur_identique_double(void *, double, RustCallStatus*); + float uniffi_uniffi_rondpoint_fn_method_retourneur_identique_float(void *, float, RustCallStatus*); + int16_t uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i16(void *, int16_t, RustCallStatus*); + int32_t uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i32(void *, int32_t, RustCallStatus*); + int64_t uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i64(void *, int64_t, RustCallStatus*); + int8_t uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i8(void *, int8_t, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres(void *, RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres_signes(void *, RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_retourneur_identique_optionneur_dictionnaire(void *, RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_retourneur_identique_string(void *, RustBuffer, RustCallStatus*); + uint16_t uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u16(void *, uint16_t, RustCallStatus*); + uint32_t uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u32(void *, uint32_t, RustCallStatus*); + uint64_t uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u64(void *, uint64_t, RustCallStatus*); + uint8_t uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u8(void *, uint8_t, RustCallStatus*); + void uniffi_uniffi_rondpoint_fn_free_stringifier(void *, RustCallStatus*); + void * uniffi_uniffi_rondpoint_fn_constructor_stringifier_new(RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_boolean(void *, int8_t, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_double(void *, double, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_float(void *, float, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i16(void *, int16_t, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i32(void *, int32_t, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i64(void *, int64_t, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i8(void *, int8_t, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u16(void *, uint16_t, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u32(void *, uint32_t, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u64(void *, uint64_t, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u8(void *, uint8_t, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_method_stringifier_well_known_string(void *, RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_func_copie_carte(RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_func_copie_dictionnaire(RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_func_copie_enumeration(RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_rondpoint_fn_func_copie_enumerations(RustBuffer, RustCallStatus*); + int8_t uniffi_uniffi_rondpoint_fn_func_switcheroo(int8_t, RustCallStatus*); + void uniffi_uniffi_sprites_fn_free_sprite(void *, RustCallStatus*); + void * uniffi_uniffi_sprites_fn_constructor_sprite_new(RustBuffer, RustCallStatus*); + void * uniffi_uniffi_sprites_fn_constructor_sprite_new_relative_to(RustBuffer, RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_sprites_fn_method_sprite_get_position(void *, RustCallStatus*); + void uniffi_uniffi_sprites_fn_method_sprite_move_by(void *, RustBuffer, RustCallStatus*); + void uniffi_uniffi_sprites_fn_method_sprite_move_to(void *, RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_sprites_fn_func_translate(RustBuffer, RustBuffer, RustCallStatus*); + void uniffi_uniffi_todolist_fn_free_todolist(void *, RustCallStatus*); + void * uniffi_uniffi_todolist_fn_constructor_todolist_new(RustCallStatus*); + void uniffi_uniffi_todolist_fn_method_todolist_add_entries(void *, RustBuffer, RustCallStatus*); + void uniffi_uniffi_todolist_fn_method_todolist_add_entry(void *, RustBuffer, RustCallStatus*); + void uniffi_uniffi_todolist_fn_method_todolist_add_item(void *, RustBuffer, RustCallStatus*); + void uniffi_uniffi_todolist_fn_method_todolist_add_items(void *, RustBuffer, RustCallStatus*); + void uniffi_uniffi_todolist_fn_method_todolist_clear_item(void *, RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_todolist_fn_method_todolist_get_entries(void *, RustCallStatus*); + RustBuffer uniffi_uniffi_todolist_fn_method_todolist_get_first(void *, RustCallStatus*); + RustBuffer uniffi_uniffi_todolist_fn_method_todolist_get_items(void *, RustCallStatus*); + RustBuffer uniffi_uniffi_todolist_fn_method_todolist_get_last(void *, RustCallStatus*); + RustBuffer uniffi_uniffi_todolist_fn_method_todolist_get_last_entry(void *, RustCallStatus*); + void uniffi_uniffi_todolist_fn_method_todolist_make_default(void *, RustCallStatus*); + RustBuffer uniffi_uniffi_todolist_fn_func_create_entry_with(RustBuffer, RustCallStatus*); + RustBuffer uniffi_uniffi_todolist_fn_func_get_default_list(RustCallStatus*); + void uniffi_uniffi_todolist_fn_func_set_default_list(void *, RustCallStatus*); +} + +// Define pointer types +const static mozilla::uniffi::UniFFIPointerType kRondpointOptionneurPointerType { + "rondpoint::Optionneur"_ns, + uniffi_uniffi_rondpoint_fn_free_optionneur +}; +const static mozilla::uniffi::UniFFIPointerType kRondpointRetourneurPointerType { + "rondpoint::Retourneur"_ns, + uniffi_uniffi_rondpoint_fn_free_retourneur +}; +const static mozilla::uniffi::UniFFIPointerType kRondpointStringifierPointerType { + "rondpoint::Stringifier"_ns, + uniffi_uniffi_rondpoint_fn_free_stringifier +}; +const static mozilla::uniffi::UniFFIPointerType kSpritesSpritePointerType { + "sprites::Sprite"_ns, + uniffi_uniffi_sprites_fn_free_sprite +}; +const static mozilla::uniffi::UniFFIPointerType kTodolistTodoListPointerType { + "todolist::TodoList"_ns, + uniffi_uniffi_todolist_fn_free_todolist +}; + +// Define the data we need per-callback interface +MOZ_CAN_RUN_SCRIPT +extern "C" int UniFFIFixturesCallbackHandlerLogger(uint64_t aHandle, uint32_t aMethod, const uint8_t* aArgsData, int32_t aArgsLen, RustBuffer* aOutBuffer) { + // Currently, we only support "fire-and-forget" async callbacks. These are + // callbacks that run asynchronously without returning anything. The main + // use case for callbacks is logging, which fits very well with this model. + // + // So, here we simple queue the callback and return immediately. + mozilla::uniffi::QueueCallback(0, aHandle, aMethod, aArgsData, aArgsLen); + return CALLBACK_INTERFACE_SUCCESS; +} +static StaticRefPtr JS_CALLBACK_HANDLER_LOGGER; + +// Define a lookup function for our callback interface info +Maybe UniFFIFixturesGetCallbackInterfaceInfo(uint64_t aInterfaceId) { + switch(aInterfaceId) { + case 0: { // fixture_callbacks:Logger + return Some(CallbackInterfaceInfo { + "Logger", + &JS_CALLBACK_HANDLER_LOGGER, + UniFFIFixturesCallbackHandlerLogger, + uniffi_uniffi_fixture_callbacks_fn_init_callback_logger, + }); + } + + default: + return Nothing(); + } +} + +Maybe> UniFFIFixturesCallAsync(const GlobalObject& aGlobal, uint64_t aId, const Sequence& aArgs, ErrorResult& aError) { + switch (aId) { + case 35: { // arithmetic:uniffi_arithmetical_fn_func_add + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_arithmetical_fn_func_add, aGlobal, aArgs, "uniffi_arithmetical_fn_func_add: "_ns, aError)); + } + case 36: { // arithmetic:uniffi_arithmetical_fn_func_div + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_arithmetical_fn_func_div, aGlobal, aArgs, "uniffi_arithmetical_fn_func_div: "_ns, aError)); + } + case 37: { // arithmetic:uniffi_arithmetical_fn_func_equal + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_arithmetical_fn_func_equal, aGlobal, aArgs, "uniffi_arithmetical_fn_func_equal: "_ns, aError)); + } + case 38: { // arithmetic:uniffi_arithmetical_fn_func_sub + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_arithmetical_fn_func_sub, aGlobal, aArgs, "uniffi_arithmetical_fn_func_sub: "_ns, aError)); + } + case 39: { // custom_types:uniffi_uniffi_custom_types_fn_func_get_custom_types_demo + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_custom_types_fn_func_get_custom_types_demo, aGlobal, aArgs, "uniffi_uniffi_custom_types_fn_func_get_custom_types_demo: "_ns, aError)); + } + case 40: { // external_types:uniffi_uniffi_fixture_external_types_fn_func_gradient + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_fixture_external_types_fn_func_gradient, aGlobal, aArgs, "uniffi_uniffi_fixture_external_types_fn_func_gradient: "_ns, aError)); + } + case 41: { // external_types:uniffi_uniffi_fixture_external_types_fn_func_intersection + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_fixture_external_types_fn_func_intersection, aGlobal, aArgs, "uniffi_uniffi_fixture_external_types_fn_func_intersection: "_ns, aError)); + } + case 42: { // fixture_callbacks:uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers, aGlobal, aArgs, "uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers: "_ns, aError)); + } + case 43: { // fixture_callbacks:uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers_main_thread + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers_main_thread, aGlobal, aArgs, "uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers_main_thread: "_ns, aError)); + } + case 44: { // geometry:uniffi_uniffi_geometry_fn_func_gradient + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_geometry_fn_func_gradient, aGlobal, aArgs, "uniffi_uniffi_geometry_fn_func_gradient: "_ns, aError)); + } + case 45: { // geometry:uniffi_uniffi_geometry_fn_func_intersection + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_geometry_fn_func_intersection, aGlobal, aArgs, "uniffi_uniffi_geometry_fn_func_intersection: "_ns, aError)); + } + case 46: { // rondpoint:uniffi_uniffi_rondpoint_fn_constructor_optionneur_new + using CallHandler = ScaffoldingCallHandler>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_constructor_optionneur_new, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_constructor_optionneur_new: "_ns, aError)); + } + case 47: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_boolean + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_boolean, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_boolean: "_ns, aError)); + } + case 48: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_enum + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_enum, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_enum: "_ns, aError)); + } + case 49: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f32 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f32, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f32: "_ns, aError)); + } + case 50: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f64 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f64, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f64: "_ns, aError)); + } + case 51: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_dec, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_dec: "_ns, aError)); + } + case 52: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_hex, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_hex: "_ns, aError)); + } + case 53: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_dec, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_dec: "_ns, aError)); + } + case 54: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_hex, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_hex: "_ns, aError)); + } + case 55: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_dec, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_dec: "_ns, aError)); + } + case 56: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_hex, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_hex: "_ns, aError)); + } + case 57: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_dec, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_dec: "_ns, aError)); + } + case 58: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_hex, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_hex: "_ns, aError)); + } + case 59: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_null + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_null, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_null: "_ns, aError)); + } + case 60: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_sequence + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_sequence, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_sequence: "_ns, aError)); + } + case 61: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_string + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_string, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_string: "_ns, aError)); + } + case 62: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_dec, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_dec: "_ns, aError)); + } + case 63: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_hex, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_hex: "_ns, aError)); + } + case 64: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_dec, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_dec: "_ns, aError)); + } + case 65: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_hex, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_hex: "_ns, aError)); + } + case 66: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_oct + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_oct, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_oct: "_ns, aError)); + } + case 67: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_dec, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_dec: "_ns, aError)); + } + case 68: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_hex, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_hex: "_ns, aError)); + } + case 69: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_dec, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_dec: "_ns, aError)); + } + case 70: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_hex, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_hex: "_ns, aError)); + } + case 71: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_zero + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_zero, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_zero: "_ns, aError)); + } + case 72: { // rondpoint:uniffi_uniffi_rondpoint_fn_constructor_retourneur_new + using CallHandler = ScaffoldingCallHandler>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_constructor_retourneur_new, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_constructor_retourneur_new: "_ns, aError)); + } + case 73: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_boolean + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_boolean, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_boolean: "_ns, aError)); + } + case 74: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_double + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_double, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_double: "_ns, aError)); + } + case 75: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_float + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_float, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_float: "_ns, aError)); + } + case 76: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i16 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i16, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i16: "_ns, aError)); + } + case 77: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i32 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i32, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i32: "_ns, aError)); + } + case 78: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i64 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i64, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i64: "_ns, aError)); + } + case 79: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i8 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i8, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i8: "_ns, aError)); + } + case 80: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres: "_ns, aError)); + } + case 81: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres_signes + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres_signes, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres_signes: "_ns, aError)); + } + case 82: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_optionneur_dictionnaire + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_optionneur_dictionnaire, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_optionneur_dictionnaire: "_ns, aError)); + } + case 83: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_string + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_string, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_string: "_ns, aError)); + } + case 84: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u16 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u16, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u16: "_ns, aError)); + } + case 85: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u32 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u32, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u32: "_ns, aError)); + } + case 86: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u64 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u64, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u64: "_ns, aError)); + } + case 87: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u8 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u8, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u8: "_ns, aError)); + } + case 88: { // rondpoint:uniffi_uniffi_rondpoint_fn_constructor_stringifier_new + using CallHandler = ScaffoldingCallHandler>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_constructor_stringifier_new, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_constructor_stringifier_new: "_ns, aError)); + } + case 89: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_boolean + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_boolean, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_boolean: "_ns, aError)); + } + case 90: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_double + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_double, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_double: "_ns, aError)); + } + case 91: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_float + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_float, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_float: "_ns, aError)); + } + case 92: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i16 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i16, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i16: "_ns, aError)); + } + case 93: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i32 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i32, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i32: "_ns, aError)); + } + case 94: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i64 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i64, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i64: "_ns, aError)); + } + case 95: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i8 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i8, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i8: "_ns, aError)); + } + case 96: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u16 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u16, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u16: "_ns, aError)); + } + case 97: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u32 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u32, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u32: "_ns, aError)); + } + case 98: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u64 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u64, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u64: "_ns, aError)); + } + case 99: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u8 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u8, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u8: "_ns, aError)); + } + case 100: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_well_known_string + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_method_stringifier_well_known_string, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_method_stringifier_well_known_string: "_ns, aError)); + } + case 101: { // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_carte + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_func_copie_carte, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_func_copie_carte: "_ns, aError)); + } + case 102: { // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_dictionnaire + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_func_copie_dictionnaire, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_func_copie_dictionnaire: "_ns, aError)); + } + case 103: { // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_enumeration + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_func_copie_enumeration, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_func_copie_enumeration: "_ns, aError)); + } + case 104: { // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_enumerations + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_func_copie_enumerations, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_func_copie_enumerations: "_ns, aError)); + } + case 105: { // rondpoint:uniffi_uniffi_rondpoint_fn_func_switcheroo + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_rondpoint_fn_func_switcheroo, aGlobal, aArgs, "uniffi_uniffi_rondpoint_fn_func_switcheroo: "_ns, aError)); + } + case 106: { // sprites:uniffi_uniffi_sprites_fn_constructor_sprite_new + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_sprites_fn_constructor_sprite_new, aGlobal, aArgs, "uniffi_uniffi_sprites_fn_constructor_sprite_new: "_ns, aError)); + } + case 107: { // sprites:uniffi_uniffi_sprites_fn_constructor_sprite_new_relative_to + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_sprites_fn_constructor_sprite_new_relative_to, aGlobal, aArgs, "uniffi_uniffi_sprites_fn_constructor_sprite_new_relative_to: "_ns, aError)); + } + case 108: { // sprites:uniffi_uniffi_sprites_fn_method_sprite_get_position + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSpritesSpritePointerType>>; + return Some(CallHandler::CallAsync(uniffi_uniffi_sprites_fn_method_sprite_get_position, aGlobal, aArgs, "uniffi_uniffi_sprites_fn_method_sprite_get_position: "_ns, aError)); + } + case 109: { // sprites:uniffi_uniffi_sprites_fn_method_sprite_move_by + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSpritesSpritePointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_sprites_fn_method_sprite_move_by, aGlobal, aArgs, "uniffi_uniffi_sprites_fn_method_sprite_move_by: "_ns, aError)); + } + case 110: { // sprites:uniffi_uniffi_sprites_fn_method_sprite_move_to + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSpritesSpritePointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_sprites_fn_method_sprite_move_to, aGlobal, aArgs, "uniffi_uniffi_sprites_fn_method_sprite_move_to: "_ns, aError)); + } + case 111: { // sprites:uniffi_uniffi_sprites_fn_func_translate + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_sprites_fn_func_translate, aGlobal, aArgs, "uniffi_uniffi_sprites_fn_func_translate: "_ns, aError)); + } + case 112: { // todolist:uniffi_uniffi_todolist_fn_constructor_todolist_new + using CallHandler = ScaffoldingCallHandler>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_constructor_todolist_new, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_constructor_todolist_new: "_ns, aError)); + } + case 113: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_entries + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_method_todolist_add_entries, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_method_todolist_add_entries: "_ns, aError)); + } + case 114: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_entry + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_method_todolist_add_entry, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_method_todolist_add_entry: "_ns, aError)); + } + case 115: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_item + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_method_todolist_add_item, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_method_todolist_add_item: "_ns, aError)); + } + case 116: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_items + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_method_todolist_add_items, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_method_todolist_add_items: "_ns, aError)); + } + case 117: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_clear_item + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_method_todolist_clear_item, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_method_todolist_clear_item: "_ns, aError)); + } + case 118: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_entries + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_method_todolist_get_entries, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_method_todolist_get_entries: "_ns, aError)); + } + case 119: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_first + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_method_todolist_get_first, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_method_todolist_get_first: "_ns, aError)); + } + case 120: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_items + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_method_todolist_get_items, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_method_todolist_get_items: "_ns, aError)); + } + case 121: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_last + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_method_todolist_get_last, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_method_todolist_get_last: "_ns, aError)); + } + case 122: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_last_entry + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_method_todolist_get_last_entry, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_method_todolist_get_last_entry: "_ns, aError)); + } + case 123: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_make_default + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_method_todolist_make_default, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_method_todolist_make_default: "_ns, aError)); + } + case 124: { // todolist:uniffi_uniffi_todolist_fn_func_create_entry_with + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_func_create_entry_with, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_func_create_entry_with: "_ns, aError)); + } + case 125: { // todolist:uniffi_uniffi_todolist_fn_func_get_default_list + using CallHandler = ScaffoldingCallHandler>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_func_get_default_list, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_func_get_default_list: "_ns, aError)); + } + case 126: { // todolist:uniffi_uniffi_todolist_fn_func_set_default_list + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(uniffi_uniffi_todolist_fn_func_set_default_list, aGlobal, aArgs, "uniffi_uniffi_todolist_fn_func_set_default_list: "_ns, aError)); + } + } + return Nothing(); +} + +bool UniFFIFixturesCallSync(const GlobalObject& aGlobal, uint64_t aId, const Sequence& aArgs, RootedDictionary& aReturnValue, ErrorResult& aError) { + switch (aId) { + case 35: { // arithmetic:uniffi_arithmetical_fn_func_add + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_arithmetical_fn_func_add, aGlobal, aArgs, aReturnValue, "uniffi_arithmetical_fn_func_add: "_ns, aError); + return true; + } + case 36: { // arithmetic:uniffi_arithmetical_fn_func_div + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_arithmetical_fn_func_div, aGlobal, aArgs, aReturnValue, "uniffi_arithmetical_fn_func_div: "_ns, aError); + return true; + } + case 37: { // arithmetic:uniffi_arithmetical_fn_func_equal + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_arithmetical_fn_func_equal, aGlobal, aArgs, aReturnValue, "uniffi_arithmetical_fn_func_equal: "_ns, aError); + return true; + } + case 38: { // arithmetic:uniffi_arithmetical_fn_func_sub + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_arithmetical_fn_func_sub, aGlobal, aArgs, aReturnValue, "uniffi_arithmetical_fn_func_sub: "_ns, aError); + return true; + } + case 39: { // custom_types:uniffi_uniffi_custom_types_fn_func_get_custom_types_demo + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_custom_types_fn_func_get_custom_types_demo, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_custom_types_fn_func_get_custom_types_demo: "_ns, aError); + return true; + } + case 40: { // external_types:uniffi_uniffi_fixture_external_types_fn_func_gradient + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_fixture_external_types_fn_func_gradient, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_fixture_external_types_fn_func_gradient: "_ns, aError); + return true; + } + case 41: { // external_types:uniffi_uniffi_fixture_external_types_fn_func_intersection + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_fixture_external_types_fn_func_intersection, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_fixture_external_types_fn_func_intersection: "_ns, aError); + return true; + } + case 42: { // fixture_callbacks:uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers: "_ns, aError); + return true; + } + case 43: { // fixture_callbacks:uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers_main_thread + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers_main_thread, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers_main_thread: "_ns, aError); + return true; + } + case 44: { // geometry:uniffi_uniffi_geometry_fn_func_gradient + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_geometry_fn_func_gradient, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_geometry_fn_func_gradient: "_ns, aError); + return true; + } + case 45: { // geometry:uniffi_uniffi_geometry_fn_func_intersection + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_geometry_fn_func_intersection, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_geometry_fn_func_intersection: "_ns, aError); + return true; + } + case 46: { // rondpoint:uniffi_uniffi_rondpoint_fn_constructor_optionneur_new + using CallHandler = ScaffoldingCallHandler>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_constructor_optionneur_new, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_constructor_optionneur_new: "_ns, aError); + return true; + } + case 47: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_boolean + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_boolean, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_boolean: "_ns, aError); + return true; + } + case 48: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_enum + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_enum, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_enum: "_ns, aError); + return true; + } + case 49: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f32 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f32, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f32: "_ns, aError); + return true; + } + case 50: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f64 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f64, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f64: "_ns, aError); + return true; + } + case 51: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_dec, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_dec: "_ns, aError); + return true; + } + case 52: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_hex, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_hex: "_ns, aError); + return true; + } + case 53: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_dec, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_dec: "_ns, aError); + return true; + } + case 54: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_hex, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_hex: "_ns, aError); + return true; + } + case 55: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_dec, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_dec: "_ns, aError); + return true; + } + case 56: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_hex, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_hex: "_ns, aError); + return true; + } + case 57: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_dec, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_dec: "_ns, aError); + return true; + } + case 58: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_hex, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_hex: "_ns, aError); + return true; + } + case 59: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_null + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_null, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_null: "_ns, aError); + return true; + } + case 60: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_sequence + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_sequence, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_sequence: "_ns, aError); + return true; + } + case 61: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_string + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_string, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_string: "_ns, aError); + return true; + } + case 62: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_dec, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_dec: "_ns, aError); + return true; + } + case 63: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_hex, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_hex: "_ns, aError); + return true; + } + case 64: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_dec, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_dec: "_ns, aError); + return true; + } + case 65: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_hex, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_hex: "_ns, aError); + return true; + } + case 66: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_oct + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_oct, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_oct: "_ns, aError); + return true; + } + case 67: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_dec, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_dec: "_ns, aError); + return true; + } + case 68: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_hex, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_hex: "_ns, aError); + return true; + } + case 69: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_dec + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_dec, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_dec: "_ns, aError); + return true; + } + case 70: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_hex + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_hex, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_hex: "_ns, aError); + return true; + } + case 71: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_zero + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_zero, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_zero: "_ns, aError); + return true; + } + case 72: { // rondpoint:uniffi_uniffi_rondpoint_fn_constructor_retourneur_new + using CallHandler = ScaffoldingCallHandler>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_constructor_retourneur_new, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_constructor_retourneur_new: "_ns, aError); + return true; + } + case 73: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_boolean + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_boolean, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_boolean: "_ns, aError); + return true; + } + case 74: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_double + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_double, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_double: "_ns, aError); + return true; + } + case 75: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_float + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_float, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_float: "_ns, aError); + return true; + } + case 76: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i16 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i16, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i16: "_ns, aError); + return true; + } + case 77: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i32 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i32, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i32: "_ns, aError); + return true; + } + case 78: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i64 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i64, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i64: "_ns, aError); + return true; + } + case 79: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i8 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i8, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i8: "_ns, aError); + return true; + } + case 80: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres: "_ns, aError); + return true; + } + case 81: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres_signes + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres_signes, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres_signes: "_ns, aError); + return true; + } + case 82: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_optionneur_dictionnaire + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_optionneur_dictionnaire, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_optionneur_dictionnaire: "_ns, aError); + return true; + } + case 83: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_string + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_string, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_string: "_ns, aError); + return true; + } + case 84: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u16 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u16, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u16: "_ns, aError); + return true; + } + case 85: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u32 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u32, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u32: "_ns, aError); + return true; + } + case 86: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u64 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u64, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u64: "_ns, aError); + return true; + } + case 87: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u8 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u8, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u8: "_ns, aError); + return true; + } + case 88: { // rondpoint:uniffi_uniffi_rondpoint_fn_constructor_stringifier_new + using CallHandler = ScaffoldingCallHandler>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_constructor_stringifier_new, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_constructor_stringifier_new: "_ns, aError); + return true; + } + case 89: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_boolean + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_boolean, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_boolean: "_ns, aError); + return true; + } + case 90: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_double + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_double, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_double: "_ns, aError); + return true; + } + case 91: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_float + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_float, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_float: "_ns, aError); + return true; + } + case 92: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i16 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i16, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i16: "_ns, aError); + return true; + } + case 93: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i32 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i32, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i32: "_ns, aError); + return true; + } + case 94: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i64 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i64, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i64: "_ns, aError); + return true; + } + case 95: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i8 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i8, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i8: "_ns, aError); + return true; + } + case 96: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u16 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u16, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u16: "_ns, aError); + return true; + } + case 97: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u32 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u32, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u32: "_ns, aError); + return true; + } + case 98: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u64 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u64, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u64: "_ns, aError); + return true; + } + case 99: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u8 + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u8, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u8: "_ns, aError); + return true; + } + case 100: { // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_well_known_string + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_method_stringifier_well_known_string, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_method_stringifier_well_known_string: "_ns, aError); + return true; + } + case 101: { // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_carte + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_func_copie_carte, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_func_copie_carte: "_ns, aError); + return true; + } + case 102: { // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_dictionnaire + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_func_copie_dictionnaire, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_func_copie_dictionnaire: "_ns, aError); + return true; + } + case 103: { // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_enumeration + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_func_copie_enumeration, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_func_copie_enumeration: "_ns, aError); + return true; + } + case 104: { // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_enumerations + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_func_copie_enumerations, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_func_copie_enumerations: "_ns, aError); + return true; + } + case 105: { // rondpoint:uniffi_uniffi_rondpoint_fn_func_switcheroo + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_rondpoint_fn_func_switcheroo, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_rondpoint_fn_func_switcheroo: "_ns, aError); + return true; + } + case 106: { // sprites:uniffi_uniffi_sprites_fn_constructor_sprite_new + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_sprites_fn_constructor_sprite_new, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_sprites_fn_constructor_sprite_new: "_ns, aError); + return true; + } + case 107: { // sprites:uniffi_uniffi_sprites_fn_constructor_sprite_new_relative_to + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_sprites_fn_constructor_sprite_new_relative_to, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_sprites_fn_constructor_sprite_new_relative_to: "_ns, aError); + return true; + } + case 108: { // sprites:uniffi_uniffi_sprites_fn_method_sprite_get_position + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSpritesSpritePointerType>>; + CallHandler::CallSync(uniffi_uniffi_sprites_fn_method_sprite_get_position, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_sprites_fn_method_sprite_get_position: "_ns, aError); + return true; + } + case 109: { // sprites:uniffi_uniffi_sprites_fn_method_sprite_move_by + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSpritesSpritePointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_sprites_fn_method_sprite_move_by, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_sprites_fn_method_sprite_move_by: "_ns, aError); + return true; + } + case 110: { // sprites:uniffi_uniffi_sprites_fn_method_sprite_move_to + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSpritesSpritePointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_sprites_fn_method_sprite_move_to, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_sprites_fn_method_sprite_move_to: "_ns, aError); + return true; + } + case 111: { // sprites:uniffi_uniffi_sprites_fn_func_translate + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_sprites_fn_func_translate, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_sprites_fn_func_translate: "_ns, aError); + return true; + } + case 112: { // todolist:uniffi_uniffi_todolist_fn_constructor_todolist_new + using CallHandler = ScaffoldingCallHandler>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_constructor_todolist_new, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_constructor_todolist_new: "_ns, aError); + return true; + } + case 113: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_entries + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_method_todolist_add_entries, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_method_todolist_add_entries: "_ns, aError); + return true; + } + case 114: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_entry + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_method_todolist_add_entry, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_method_todolist_add_entry: "_ns, aError); + return true; + } + case 115: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_item + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_method_todolist_add_item, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_method_todolist_add_item: "_ns, aError); + return true; + } + case 116: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_items + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_method_todolist_add_items, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_method_todolist_add_items: "_ns, aError); + return true; + } + case 117: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_clear_item + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_method_todolist_clear_item, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_method_todolist_clear_item: "_ns, aError); + return true; + } + case 118: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_entries + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_method_todolist_get_entries, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_method_todolist_get_entries: "_ns, aError); + return true; + } + case 119: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_first + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_method_todolist_get_first, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_method_todolist_get_first: "_ns, aError); + return true; + } + case 120: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_items + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_method_todolist_get_items, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_method_todolist_get_items: "_ns, aError); + return true; + } + case 121: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_last + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_method_todolist_get_last, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_method_todolist_get_last: "_ns, aError); + return true; + } + case 122: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_last_entry + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_method_todolist_get_last_entry, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_method_todolist_get_last_entry: "_ns, aError); + return true; + } + case 123: { // todolist:uniffi_uniffi_todolist_fn_method_todolist_make_default + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_method_todolist_make_default, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_method_todolist_make_default: "_ns, aError); + return true; + } + case 124: { // todolist:uniffi_uniffi_todolist_fn_func_create_entry_with + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_func_create_entry_with, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_func_create_entry_with: "_ns, aError); + return true; + } + case 125: { // todolist:uniffi_uniffi_todolist_fn_func_get_default_list + using CallHandler = ScaffoldingCallHandler>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_func_get_default_list, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_func_get_default_list: "_ns, aError); + return true; + } + case 126: { // todolist:uniffi_uniffi_todolist_fn_func_set_default_list + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(uniffi_uniffi_todolist_fn_func_set_default_list, aGlobal, aArgs, aReturnValue, "uniffi_uniffi_todolist_fn_func_set_default_list: "_ns, aError); + return true; + } + } + return false; +} + +Maybe> UniFFIFixturesReadPointer(const GlobalObject& aGlobal, uint64_t aId, const ArrayBuffer& aArrayBuff, long aPosition, ErrorResult& aError) { + const UniFFIPointerType* type; + switch (aId) { + case 5: { // rondpoint:Optionneur + type = &kRondpointOptionneurPointerType; + break; + } + case 6: { // rondpoint:Retourneur + type = &kRondpointRetourneurPointerType; + break; + } + case 7: { // rondpoint:Stringifier + type = &kRondpointStringifierPointerType; + break; + } + case 8: { // sprites:Sprite + type = &kSpritesSpritePointerType; + break; + } + case 9: { // todolist:TodoList + type = &kTodolistTodoListPointerType; + break; + } + default: + return Nothing(); + } + return Some(UniFFIPointer::Read(aArrayBuff, aPosition, type, aError)); +} + +bool UniFFIFixturesWritePointer(const GlobalObject& aGlobal, uint64_t aId, const UniFFIPointer& aPtr, const ArrayBuffer& aArrayBuff, long aPosition, ErrorResult& aError) { + const UniFFIPointerType* type; + switch (aId) { + case 5: { // rondpoint:Optionneur + type = &kRondpointOptionneurPointerType; + break; + } + case 6: { // rondpoint:Retourneur + type = &kRondpointRetourneurPointerType; + break; + } + case 7: { // rondpoint:Stringifier + type = &kRondpointStringifierPointerType; + break; + } + case 8: { // sprites:Sprite + type = &kSpritesSpritePointerType; + break; + } + case 9: { // todolist:TodoList + type = &kTodolistTodoListPointerType; + break; + } + default: + return false; + } + aPtr.Write(aArrayBuff, aPosition, type, aError); + return true; +} + +} // namespace mozilla::uniffi diff --git a/toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp b/toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp new file mode 100644 index 0000000000..c235d92986 --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp @@ -0,0 +1,488 @@ +// Generated by uniffi-bindgen-gecko-js. DO NOT EDIT. + +#include "nsString.h" +#include "nsPrintfCString.h" +#include "mozilla/Logging.h" +#include "mozilla/Maybe.h" +#include "mozilla/StaticPtr.h" +#include "mozilla/dom/UniFFICallbacks.h" +#include "mozilla/dom/UniFFIScaffolding.h" +#include "mozilla/dom/ScaffoldingCall.h" + +namespace mozilla::uniffi { + +using dom::ArrayBuffer; +using dom::AutoEntryScript; +using dom::GlobalObject; +using dom::RootedDictionary; +using dom::Promise; +using dom::ScaffoldingType; +using dom::Sequence; +using dom::UniFFICallbackHandler; +using dom::UniFFIPointer; +using dom::UniFFIScaffoldingCallResult; + +// Define scaffolding functions from UniFFI +extern "C" { + void uniffi_remote_settings_fn_free_remotesettings(void *, RustCallStatus*); + void * uniffi_remote_settings_fn_constructor_remotesettings_new(RustBuffer, RustCallStatus*); + void uniffi_remote_settings_fn_method_remotesettings_download_attachment_to_path(void *, RustBuffer, RustBuffer, RustCallStatus*); + RustBuffer uniffi_remote_settings_fn_method_remotesettings_get_records(void *, RustCallStatus*); + RustBuffer uniffi_remote_settings_fn_method_remotesettings_get_records_since(void *, uint64_t, RustCallStatus*); + void uniffi_suggest_fn_free_suggeststore(void *, RustCallStatus*); + void * uniffi_suggest_fn_constructor_suggeststore_new(RustBuffer, RustBuffer, RustCallStatus*); + void uniffi_suggest_fn_method_suggeststore_clear(void *, RustCallStatus*); + RustBuffer uniffi_suggest_fn_method_suggeststore_fetch_global_config(void *, RustCallStatus*); + RustBuffer uniffi_suggest_fn_method_suggeststore_fetch_provider_config(void *, RustBuffer, RustCallStatus*); + void uniffi_suggest_fn_method_suggeststore_ingest(void *, RustBuffer, RustCallStatus*); + void uniffi_suggest_fn_method_suggeststore_interrupt(void *, RustCallStatus*); + RustBuffer uniffi_suggest_fn_method_suggeststore_query(void *, RustBuffer, RustCallStatus*); + void uniffi_suggest_fn_free_suggeststorebuilder(void *, RustCallStatus*); + void * uniffi_suggest_fn_constructor_suggeststorebuilder_new(RustCallStatus*); + void * uniffi_suggest_fn_method_suggeststorebuilder_build(void *, RustCallStatus*); + void * uniffi_suggest_fn_method_suggeststorebuilder_cache_path(void *, RustBuffer, RustCallStatus*); + void * uniffi_suggest_fn_method_suggeststorebuilder_data_path(void *, RustBuffer, RustCallStatus*); + void * uniffi_suggest_fn_method_suggeststorebuilder_remote_settings_config(void *, RustBuffer, RustCallStatus*); + int8_t uniffi_suggest_fn_func_raw_suggestion_url_matches(RustBuffer, RustBuffer, RustCallStatus*); + void uniffi_tabs_fn_free_tabsbridgedengine(void *, RustCallStatus*); + RustBuffer uniffi_tabs_fn_method_tabsbridgedengine_apply(void *, RustCallStatus*); + RustBuffer uniffi_tabs_fn_method_tabsbridgedengine_ensure_current_sync_id(void *, RustBuffer, RustCallStatus*); + int64_t uniffi_tabs_fn_method_tabsbridgedengine_last_sync(void *, RustCallStatus*); + void uniffi_tabs_fn_method_tabsbridgedengine_prepare_for_sync(void *, RustBuffer, RustCallStatus*); + void uniffi_tabs_fn_method_tabsbridgedengine_reset(void *, RustCallStatus*); + RustBuffer uniffi_tabs_fn_method_tabsbridgedengine_reset_sync_id(void *, RustCallStatus*); + void uniffi_tabs_fn_method_tabsbridgedengine_set_last_sync(void *, int64_t, RustCallStatus*); + void uniffi_tabs_fn_method_tabsbridgedengine_set_uploaded(void *, int64_t, RustBuffer, RustCallStatus*); + void uniffi_tabs_fn_method_tabsbridgedengine_store_incoming(void *, RustBuffer, RustCallStatus*); + void uniffi_tabs_fn_method_tabsbridgedengine_sync_finished(void *, RustCallStatus*); + RustBuffer uniffi_tabs_fn_method_tabsbridgedengine_sync_id(void *, RustCallStatus*); + void uniffi_tabs_fn_method_tabsbridgedengine_sync_started(void *, RustCallStatus*); + void uniffi_tabs_fn_method_tabsbridgedengine_wipe(void *, RustCallStatus*); + void uniffi_tabs_fn_free_tabsstore(void *, RustCallStatus*); + void * uniffi_tabs_fn_constructor_tabsstore_new(RustBuffer, RustCallStatus*); + void * uniffi_tabs_fn_method_tabsstore_bridged_engine(void *, RustCallStatus*); + RustBuffer uniffi_tabs_fn_method_tabsstore_get_all(void *, RustCallStatus*); + void uniffi_tabs_fn_method_tabsstore_register_with_sync_manager(void *, RustCallStatus*); + void uniffi_tabs_fn_method_tabsstore_set_local_tabs(void *, RustBuffer, RustCallStatus*); +} + +// Define pointer types +const static mozilla::uniffi::UniFFIPointerType kRemoteSettingsRemoteSettingsPointerType { + "remote_settings::RemoteSettings"_ns, + uniffi_remote_settings_fn_free_remotesettings +}; +const static mozilla::uniffi::UniFFIPointerType kSuggestSuggestStorePointerType { + "suggest::SuggestStore"_ns, + uniffi_suggest_fn_free_suggeststore +}; +const static mozilla::uniffi::UniFFIPointerType kSuggestSuggestStoreBuilderPointerType { + "suggest::SuggestStoreBuilder"_ns, + uniffi_suggest_fn_free_suggeststorebuilder +}; +const static mozilla::uniffi::UniFFIPointerType kTabsTabsBridgedEnginePointerType { + "tabs::TabsBridgedEngine"_ns, + uniffi_tabs_fn_free_tabsbridgedengine +}; +const static mozilla::uniffi::UniFFIPointerType kTabsTabsStorePointerType { + "tabs::TabsStore"_ns, + uniffi_tabs_fn_free_tabsstore +}; + +// Define the data we need per-callback interface + +// Define a lookup function for our callback interface info +Maybe UniFFIGetCallbackInterfaceInfo(uint64_t aInterfaceId) { + switch(aInterfaceId) { + + default: + return Nothing(); + } +} + +Maybe> UniFFICallAsync(const GlobalObject& aGlobal, uint64_t aId, const Sequence& aArgs, ErrorResult& aError) { + switch (aId) { + case 0: { // remote_settings:uniffi_remote_settings_fn_constructor_remotesettings_new + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_remote_settings_fn_constructor_remotesettings_new, aGlobal, aArgs, "uniffi_remote_settings_fn_constructor_remotesettings_new: "_ns, aError)); + } + case 1: { // remote_settings:uniffi_remote_settings_fn_method_remotesettings_download_attachment_to_path + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRemoteSettingsRemoteSettingsPointerType>, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_remote_settings_fn_method_remotesettings_download_attachment_to_path, aGlobal, aArgs, "uniffi_remote_settings_fn_method_remotesettings_download_attachment_to_path: "_ns, aError)); + } + case 2: { // remote_settings:uniffi_remote_settings_fn_method_remotesettings_get_records + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRemoteSettingsRemoteSettingsPointerType>>; + return Some(CallHandler::CallAsync(uniffi_remote_settings_fn_method_remotesettings_get_records, aGlobal, aArgs, "uniffi_remote_settings_fn_method_remotesettings_get_records: "_ns, aError)); + } + case 3: { // remote_settings:uniffi_remote_settings_fn_method_remotesettings_get_records_since + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRemoteSettingsRemoteSettingsPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_remote_settings_fn_method_remotesettings_get_records_since, aGlobal, aArgs, "uniffi_remote_settings_fn_method_remotesettings_get_records_since: "_ns, aError)); + } + case 4: { // suggest:uniffi_suggest_fn_constructor_suggeststore_new + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_suggest_fn_constructor_suggeststore_new, aGlobal, aArgs, "uniffi_suggest_fn_constructor_suggeststore_new: "_ns, aError)); + } + case 5: { // suggest:uniffi_suggest_fn_method_suggeststore_clear + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>>; + return Some(CallHandler::CallAsync(uniffi_suggest_fn_method_suggeststore_clear, aGlobal, aArgs, "uniffi_suggest_fn_method_suggeststore_clear: "_ns, aError)); + } + case 6: { // suggest:uniffi_suggest_fn_method_suggeststore_fetch_global_config + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>>; + return Some(CallHandler::CallAsync(uniffi_suggest_fn_method_suggeststore_fetch_global_config, aGlobal, aArgs, "uniffi_suggest_fn_method_suggeststore_fetch_global_config: "_ns, aError)); + } + case 7: { // suggest:uniffi_suggest_fn_method_suggeststore_fetch_provider_config + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_suggest_fn_method_suggeststore_fetch_provider_config, aGlobal, aArgs, "uniffi_suggest_fn_method_suggeststore_fetch_provider_config: "_ns, aError)); + } + case 8: { // suggest:uniffi_suggest_fn_method_suggeststore_ingest + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_suggest_fn_method_suggeststore_ingest, aGlobal, aArgs, "uniffi_suggest_fn_method_suggeststore_ingest: "_ns, aError)); + } + case 9: { // suggest:uniffi_suggest_fn_method_suggeststore_interrupt + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>>; + return Some(CallHandler::CallAsync(uniffi_suggest_fn_method_suggeststore_interrupt, aGlobal, aArgs, "uniffi_suggest_fn_method_suggeststore_interrupt: "_ns, aError)); + } + case 10: { // suggest:uniffi_suggest_fn_method_suggeststore_query + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_suggest_fn_method_suggeststore_query, aGlobal, aArgs, "uniffi_suggest_fn_method_suggeststore_query: "_ns, aError)); + } + case 11: { // suggest:uniffi_suggest_fn_constructor_suggeststorebuilder_new + using CallHandler = ScaffoldingCallHandler>; + return Some(CallHandler::CallAsync(uniffi_suggest_fn_constructor_suggeststorebuilder_new, aGlobal, aArgs, "uniffi_suggest_fn_constructor_suggeststorebuilder_new: "_ns, aError)); + } + case 12: { // suggest:uniffi_suggest_fn_method_suggeststorebuilder_build + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStoreBuilderPointerType>>; + return Some(CallHandler::CallAsync(uniffi_suggest_fn_method_suggeststorebuilder_build, aGlobal, aArgs, "uniffi_suggest_fn_method_suggeststorebuilder_build: "_ns, aError)); + } + case 13: { // suggest:uniffi_suggest_fn_method_suggeststorebuilder_cache_path + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStoreBuilderPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_suggest_fn_method_suggeststorebuilder_cache_path, aGlobal, aArgs, "uniffi_suggest_fn_method_suggeststorebuilder_cache_path: "_ns, aError)); + } + case 14: { // suggest:uniffi_suggest_fn_method_suggeststorebuilder_data_path + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStoreBuilderPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_suggest_fn_method_suggeststorebuilder_data_path, aGlobal, aArgs, "uniffi_suggest_fn_method_suggeststorebuilder_data_path: "_ns, aError)); + } + case 15: { // suggest:uniffi_suggest_fn_method_suggeststorebuilder_remote_settings_config + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStoreBuilderPointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_suggest_fn_method_suggeststorebuilder_remote_settings_config, aGlobal, aArgs, "uniffi_suggest_fn_method_suggeststorebuilder_remote_settings_config: "_ns, aError)); + } + case 16: { // suggest:uniffi_suggest_fn_func_raw_suggestion_url_matches + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_suggest_fn_func_raw_suggestion_url_matches, aGlobal, aArgs, "uniffi_suggest_fn_func_raw_suggestion_url_matches: "_ns, aError)); + } + case 17: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_apply + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsbridgedengine_apply, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsbridgedengine_apply: "_ns, aError)); + } + case 18: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_ensure_current_sync_id + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsbridgedengine_ensure_current_sync_id, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsbridgedengine_ensure_current_sync_id: "_ns, aError)); + } + case 19: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_last_sync + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsbridgedengine_last_sync, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsbridgedengine_last_sync: "_ns, aError)); + } + case 20: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_prepare_for_sync + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsbridgedengine_prepare_for_sync, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsbridgedengine_prepare_for_sync: "_ns, aError)); + } + case 21: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_reset + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsbridgedengine_reset, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsbridgedengine_reset: "_ns, aError)); + } + case 22: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_reset_sync_id + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsbridgedengine_reset_sync_id, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsbridgedengine_reset_sync_id: "_ns, aError)); + } + case 23: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_set_last_sync + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsbridgedengine_set_last_sync, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsbridgedengine_set_last_sync: "_ns, aError)); + } + case 24: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_set_uploaded + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsbridgedengine_set_uploaded, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsbridgedengine_set_uploaded: "_ns, aError)); + } + case 25: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_store_incoming + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsbridgedengine_store_incoming, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsbridgedengine_store_incoming: "_ns, aError)); + } + case 26: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_sync_finished + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsbridgedengine_sync_finished, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsbridgedengine_sync_finished: "_ns, aError)); + } + case 27: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_sync_id + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsbridgedengine_sync_id, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsbridgedengine_sync_id: "_ns, aError)); + } + case 28: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_sync_started + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsbridgedengine_sync_started, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsbridgedengine_sync_started: "_ns, aError)); + } + case 29: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_wipe + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsbridgedengine_wipe, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsbridgedengine_wipe: "_ns, aError)); + } + case 30: { // tabs:uniffi_tabs_fn_constructor_tabsstore_new + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_constructor_tabsstore_new, aGlobal, aArgs, "uniffi_tabs_fn_constructor_tabsstore_new: "_ns, aError)); + } + case 31: { // tabs:uniffi_tabs_fn_method_tabsstore_bridged_engine + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsstore_bridged_engine, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsstore_bridged_engine: "_ns, aError)); + } + case 32: { // tabs:uniffi_tabs_fn_method_tabsstore_get_all + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsstore_get_all, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsstore_get_all: "_ns, aError)); + } + case 33: { // tabs:uniffi_tabs_fn_method_tabsstore_register_with_sync_manager + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsstore_register_with_sync_manager, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsstore_register_with_sync_manager: "_ns, aError)); + } + case 34: { // tabs:uniffi_tabs_fn_method_tabsstore_set_local_tabs + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>, ScaffoldingConverter>; + return Some(CallHandler::CallAsync(uniffi_tabs_fn_method_tabsstore_set_local_tabs, aGlobal, aArgs, "uniffi_tabs_fn_method_tabsstore_set_local_tabs: "_ns, aError)); + } + } + return Nothing(); +} + +bool UniFFICallSync(const GlobalObject& aGlobal, uint64_t aId, const Sequence& aArgs, RootedDictionary& aReturnValue, ErrorResult& aError) { + switch (aId) { + case 0: { // remote_settings:uniffi_remote_settings_fn_constructor_remotesettings_new + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_remote_settings_fn_constructor_remotesettings_new, aGlobal, aArgs, aReturnValue, "uniffi_remote_settings_fn_constructor_remotesettings_new: "_ns, aError); + return true; + } + case 1: { // remote_settings:uniffi_remote_settings_fn_method_remotesettings_download_attachment_to_path + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRemoteSettingsRemoteSettingsPointerType>, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_remote_settings_fn_method_remotesettings_download_attachment_to_path, aGlobal, aArgs, aReturnValue, "uniffi_remote_settings_fn_method_remotesettings_download_attachment_to_path: "_ns, aError); + return true; + } + case 2: { // remote_settings:uniffi_remote_settings_fn_method_remotesettings_get_records + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRemoteSettingsRemoteSettingsPointerType>>; + CallHandler::CallSync(uniffi_remote_settings_fn_method_remotesettings_get_records, aGlobal, aArgs, aReturnValue, "uniffi_remote_settings_fn_method_remotesettings_get_records: "_ns, aError); + return true; + } + case 3: { // remote_settings:uniffi_remote_settings_fn_method_remotesettings_get_records_since + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kRemoteSettingsRemoteSettingsPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_remote_settings_fn_method_remotesettings_get_records_since, aGlobal, aArgs, aReturnValue, "uniffi_remote_settings_fn_method_remotesettings_get_records_since: "_ns, aError); + return true; + } + case 4: { // suggest:uniffi_suggest_fn_constructor_suggeststore_new + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_suggest_fn_constructor_suggeststore_new, aGlobal, aArgs, aReturnValue, "uniffi_suggest_fn_constructor_suggeststore_new: "_ns, aError); + return true; + } + case 5: { // suggest:uniffi_suggest_fn_method_suggeststore_clear + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>>; + CallHandler::CallSync(uniffi_suggest_fn_method_suggeststore_clear, aGlobal, aArgs, aReturnValue, "uniffi_suggest_fn_method_suggeststore_clear: "_ns, aError); + return true; + } + case 6: { // suggest:uniffi_suggest_fn_method_suggeststore_fetch_global_config + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>>; + CallHandler::CallSync(uniffi_suggest_fn_method_suggeststore_fetch_global_config, aGlobal, aArgs, aReturnValue, "uniffi_suggest_fn_method_suggeststore_fetch_global_config: "_ns, aError); + return true; + } + case 7: { // suggest:uniffi_suggest_fn_method_suggeststore_fetch_provider_config + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_suggest_fn_method_suggeststore_fetch_provider_config, aGlobal, aArgs, aReturnValue, "uniffi_suggest_fn_method_suggeststore_fetch_provider_config: "_ns, aError); + return true; + } + case 8: { // suggest:uniffi_suggest_fn_method_suggeststore_ingest + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_suggest_fn_method_suggeststore_ingest, aGlobal, aArgs, aReturnValue, "uniffi_suggest_fn_method_suggeststore_ingest: "_ns, aError); + return true; + } + case 9: { // suggest:uniffi_suggest_fn_method_suggeststore_interrupt + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>>; + CallHandler::CallSync(uniffi_suggest_fn_method_suggeststore_interrupt, aGlobal, aArgs, aReturnValue, "uniffi_suggest_fn_method_suggeststore_interrupt: "_ns, aError); + return true; + } + case 10: { // suggest:uniffi_suggest_fn_method_suggeststore_query + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_suggest_fn_method_suggeststore_query, aGlobal, aArgs, aReturnValue, "uniffi_suggest_fn_method_suggeststore_query: "_ns, aError); + return true; + } + case 11: { // suggest:uniffi_suggest_fn_constructor_suggeststorebuilder_new + using CallHandler = ScaffoldingCallHandler>; + CallHandler::CallSync(uniffi_suggest_fn_constructor_suggeststorebuilder_new, aGlobal, aArgs, aReturnValue, "uniffi_suggest_fn_constructor_suggeststorebuilder_new: "_ns, aError); + return true; + } + case 12: { // suggest:uniffi_suggest_fn_method_suggeststorebuilder_build + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStoreBuilderPointerType>>; + CallHandler::CallSync(uniffi_suggest_fn_method_suggeststorebuilder_build, aGlobal, aArgs, aReturnValue, "uniffi_suggest_fn_method_suggeststorebuilder_build: "_ns, aError); + return true; + } + case 13: { // suggest:uniffi_suggest_fn_method_suggeststorebuilder_cache_path + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStoreBuilderPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_suggest_fn_method_suggeststorebuilder_cache_path, aGlobal, aArgs, aReturnValue, "uniffi_suggest_fn_method_suggeststorebuilder_cache_path: "_ns, aError); + return true; + } + case 14: { // suggest:uniffi_suggest_fn_method_suggeststorebuilder_data_path + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStoreBuilderPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_suggest_fn_method_suggeststorebuilder_data_path, aGlobal, aArgs, aReturnValue, "uniffi_suggest_fn_method_suggeststorebuilder_data_path: "_ns, aError); + return true; + } + case 15: { // suggest:uniffi_suggest_fn_method_suggeststorebuilder_remote_settings_config + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kSuggestSuggestStoreBuilderPointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_suggest_fn_method_suggeststorebuilder_remote_settings_config, aGlobal, aArgs, aReturnValue, "uniffi_suggest_fn_method_suggeststorebuilder_remote_settings_config: "_ns, aError); + return true; + } + case 16: { // suggest:uniffi_suggest_fn_func_raw_suggestion_url_matches + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_suggest_fn_func_raw_suggestion_url_matches, aGlobal, aArgs, aReturnValue, "uniffi_suggest_fn_func_raw_suggestion_url_matches: "_ns, aError); + return true; + } + case 17: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_apply + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsbridgedengine_apply, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsbridgedengine_apply: "_ns, aError); + return true; + } + case 18: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_ensure_current_sync_id + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsbridgedengine_ensure_current_sync_id, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsbridgedengine_ensure_current_sync_id: "_ns, aError); + return true; + } + case 19: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_last_sync + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsbridgedengine_last_sync, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsbridgedengine_last_sync: "_ns, aError); + return true; + } + case 20: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_prepare_for_sync + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsbridgedengine_prepare_for_sync, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsbridgedengine_prepare_for_sync: "_ns, aError); + return true; + } + case 21: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_reset + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsbridgedengine_reset, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsbridgedengine_reset: "_ns, aError); + return true; + } + case 22: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_reset_sync_id + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsbridgedengine_reset_sync_id, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsbridgedengine_reset_sync_id: "_ns, aError); + return true; + } + case 23: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_set_last_sync + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsbridgedengine_set_last_sync, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsbridgedengine_set_last_sync: "_ns, aError); + return true; + } + case 24: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_set_uploaded + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsbridgedengine_set_uploaded, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsbridgedengine_set_uploaded: "_ns, aError); + return true; + } + case 25: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_store_incoming + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsbridgedengine_store_incoming, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsbridgedengine_store_incoming: "_ns, aError); + return true; + } + case 26: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_sync_finished + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsbridgedengine_sync_finished, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsbridgedengine_sync_finished: "_ns, aError); + return true; + } + case 27: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_sync_id + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsbridgedengine_sync_id, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsbridgedengine_sync_id: "_ns, aError); + return true; + } + case 28: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_sync_started + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsbridgedengine_sync_started, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsbridgedengine_sync_started: "_ns, aError); + return true; + } + case 29: { // tabs:uniffi_tabs_fn_method_tabsbridgedengine_wipe + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsbridgedengine_wipe, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsbridgedengine_wipe: "_ns, aError); + return true; + } + case 30: { // tabs:uniffi_tabs_fn_constructor_tabsstore_new + using CallHandler = ScaffoldingCallHandler, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_tabs_fn_constructor_tabsstore_new, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_constructor_tabsstore_new: "_ns, aError); + return true; + } + case 31: { // tabs:uniffi_tabs_fn_method_tabsstore_bridged_engine + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsstore_bridged_engine, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsstore_bridged_engine: "_ns, aError); + return true; + } + case 32: { // tabs:uniffi_tabs_fn_method_tabsstore_get_all + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsstore_get_all, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsstore_get_all: "_ns, aError); + return true; + } + case 33: { // tabs:uniffi_tabs_fn_method_tabsstore_register_with_sync_manager + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsstore_register_with_sync_manager, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsstore_register_with_sync_manager: "_ns, aError); + return true; + } + case 34: { // tabs:uniffi_tabs_fn_method_tabsstore_set_local_tabs + using CallHandler = ScaffoldingCallHandler, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>, ScaffoldingConverter>; + CallHandler::CallSync(uniffi_tabs_fn_method_tabsstore_set_local_tabs, aGlobal, aArgs, aReturnValue, "uniffi_tabs_fn_method_tabsstore_set_local_tabs: "_ns, aError); + return true; + } + } + return false; +} + +Maybe> UniFFIReadPointer(const GlobalObject& aGlobal, uint64_t aId, const ArrayBuffer& aArrayBuff, long aPosition, ErrorResult& aError) { + const UniFFIPointerType* type; + switch (aId) { + case 0: { // remote_settings:RemoteSettings + type = &kRemoteSettingsRemoteSettingsPointerType; + break; + } + case 1: { // suggest:SuggestStore + type = &kSuggestSuggestStorePointerType; + break; + } + case 2: { // suggest:SuggestStoreBuilder + type = &kSuggestSuggestStoreBuilderPointerType; + break; + } + case 3: { // tabs:TabsBridgedEngine + type = &kTabsTabsBridgedEnginePointerType; + break; + } + case 4: { // tabs:TabsStore + type = &kTabsTabsStorePointerType; + break; + } + default: + return Nothing(); + } + return Some(UniFFIPointer::Read(aArrayBuff, aPosition, type, aError)); +} + +bool UniFFIWritePointer(const GlobalObject& aGlobal, uint64_t aId, const UniFFIPointer& aPtr, const ArrayBuffer& aArrayBuff, long aPosition, ErrorResult& aError) { + const UniFFIPointerType* type; + switch (aId) { + case 0: { // remote_settings:RemoteSettings + type = &kRemoteSettingsRemoteSettingsPointerType; + break; + } + case 1: { // suggest:SuggestStore + type = &kSuggestSuggestStorePointerType; + break; + } + case 2: { // suggest:SuggestStoreBuilder + type = &kSuggestSuggestStoreBuilderPointerType; + break; + } + case 3: { // tabs:TabsBridgedEngine + type = &kTabsTabsBridgedEnginePointerType; + break; + } + case 4: { // tabs:TabsStore + type = &kTabsTabsStorePointerType; + break; + } + default: + return false; + } + aPtr.Write(aArrayBuff, aPosition, type, aError); + return true; +} + +} // namespace mozilla::uniffi diff --git a/toolkit/components/uniffi-js/UniFFIPointer.cpp b/toolkit/components/uniffi-js/UniFFIPointer.cpp new file mode 100644 index 0000000000..87a1d5fe69 --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFIPointer.cpp @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsPrintfCString.h" +#include "mozilla/EndianUtils.h" +#include "mozilla/dom/UniFFIPointer.h" +#include "mozilla/dom/UniFFIBinding.h" +#include "mozilla/Logging.h" +#include "UniFFIRust.h" + +static mozilla::LazyLogModule sUniFFIPointerLogger("uniffi_logger"); + +namespace mozilla::dom { +using uniffi::RUST_CALL_SUCCESS; +using uniffi::RustCallStatus; +using uniffi::UniFFIPointerType; + +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(UniFFIPointer) + +NS_IMPL_CYCLE_COLLECTING_ADDREF(UniFFIPointer) +NS_IMPL_CYCLE_COLLECTING_RELEASE(UniFFIPointer) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(UniFFIPointer) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) +NS_INTERFACE_MAP_END + +// Static function +already_AddRefed UniFFIPointer::Create( + void* aPtr, const UniFFIPointerType* aType) { + RefPtr uniFFIPointer = new UniFFIPointer(aPtr, aType); + return uniFFIPointer.forget(); +} + +already_AddRefed UniFFIPointer::Read( + const ArrayBuffer& aArrayBuff, uint32_t aPosition, + const UniFFIPointerType* aType, ErrorResult& aError) { + MOZ_LOG(sUniFFIPointerLogger, LogLevel::Info, + ("[UniFFI] Reading Pointer from buffer")); + + uint8_t data_ptr[8]; + if (!aArrayBuff.CopyDataTo( + data_ptr, + [aPosition](size_t aLength) -> Maybe> { + CheckedUint32 end = aPosition + 8; + if (!end.isValid() || end.value() > aLength) { + return Nothing(); + } + return Some(std::make_pair(aPosition, 8)); + })) { + aError.ThrowRangeError("position is out of range"); + return nullptr; + } + + // in Rust and Write(), a pointer is converted to a void* then written as u64 + // BigEndian we do the reverse here + void* ptr = (void*)mozilla::BigEndian::readUint64(data_ptr); + return UniFFIPointer::Create(ptr, aType); +} + +void UniFFIPointer::Write(const ArrayBuffer& aArrayBuff, uint32_t aPosition, + const UniFFIPointerType* aType, + ErrorResult& aError) const { + if (!this->IsSamePtrType(aType)) { + aError.ThrowUnknownError(nsPrintfCString( + "Attempt to write pointer with wrong type: %s (expected: %s)", + aType->typeName.get(), this->mType->typeName.get())); + return; + } + MOZ_LOG(sUniFFIPointerLogger, LogLevel::Info, + ("[UniFFI] Writing Pointer to buffer")); + + aArrayBuff.ProcessData([&](const Span& aData, + JS::AutoCheckCannotGC&&) { + CheckedUint32 end = aPosition + 8; + if (!end.isValid() || end.value() > aData.Length()) { + aError.ThrowRangeError("position is out of range"); + return; + } + // in Rust and Read(), a u64 is read as BigEndian and then converted to + // a pointer we do the reverse here + const auto& data_ptr = aData.Subspan(aPosition, 8); + mozilla::BigEndian::writeUint64(data_ptr.Elements(), (uint64_t)GetPtr()); + }); +} + +UniFFIPointer::UniFFIPointer(void* aPtr, const UniFFIPointerType* aType) { + mPtr = aPtr; + mType = aType; +} + +JSObject* UniFFIPointer::WrapObject(JSContext* aCx, + JS::Handle aGivenProto) { + return dom::UniFFIPointer_Binding::Wrap(aCx, this, aGivenProto); +} + +void* UniFFIPointer::GetPtr() const { + MOZ_LOG(sUniFFIPointerLogger, LogLevel::Info, + ("[UniFFI] Getting raw pointer")); + return this->mPtr; +} + +bool UniFFIPointer::IsSamePtrType(const UniFFIPointerType* aType) const { + return this->mType == aType; +} + +UniFFIPointer::~UniFFIPointer() { + MOZ_LOG(sUniFFIPointerLogger, LogLevel::Info, + ("[UniFFI] Destroying pointer")); + RustCallStatus status{}; + this->mType->destructor(this->mPtr, &status); + MOZ_DIAGNOSTIC_ASSERT(status.code == RUST_CALL_SUCCESS, + "UniFFI destructor call returned a non-success result"); +} + +} // namespace mozilla::dom diff --git a/toolkit/components/uniffi-js/UniFFIPointer.h b/toolkit/components/uniffi-js/UniFFIPointer.h new file mode 100644 index 0000000000..59acc0ca66 --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFIPointer.h @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_UniFFIPointer_h +#define mozilla_dom_UniFFIPointer_h + +#include "nsISupports.h" +#include "nsWrapperCache.h" +#include "nsString.h" +#include "mozilla/ErrorResult.h" +#include "mozilla/dom/TypedArray.h" +#include "mozilla/dom/UniFFIPointerType.h" + +namespace mozilla::dom { + +class UniFFIPointer final : public nsISupports, public nsWrapperCache { + public: + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(UniFFIPointer) + + static already_AddRefed Create( + void* aPtr, const uniffi::UniFFIPointerType* aType); + static already_AddRefed Read( + const ArrayBuffer& aArrayBuff, uint32_t aPosition, + const uniffi::UniFFIPointerType* aType, ErrorResult& aError); + void Write(const ArrayBuffer& aArrayBuff, uint32_t aPosition, + const uniffi::UniFFIPointerType* aType, ErrorResult& aError) const; + + UniFFIPointer(void* aPtr, const uniffi::UniFFIPointerType* aType); + + JSObject* WrapObject(JSContext* aCx, + JS::Handle aGivenProto) override; + nsISupports* GetParentObject() { return nullptr; } + + /** + * returns the raw pointer `UniFFIPointer` holds + * This is safe because: + * - The pointer was allocated in Rust as a reference counted `Arc` + * - Rust cloned the pointer without destructing it when passed into C++ + * - Eventually, when the destructor of `UniFFIPointer` runs, we return + * ownership to Rust, which then decrements the count and deallocates the + * memory the pointer points to. + */ + void* GetPtr() const; + + /** + * Returns true if the pointer type `this` holds is the same as the argument + * it does so using pointer comparison, as there is **exactly** one static + * `UniFFIPointerType` per type exposed in the UniFFI interface + */ + bool IsSamePtrType(const uniffi::UniFFIPointerType* type) const; + + private: + const uniffi::UniFFIPointerType* mType; + void* mPtr; + + protected: + /** + * Destructs the `UniFFIPointer`, making sure to give back ownership of the + * raw pointer back to Rust, which deallocates the pointer + */ + ~UniFFIPointer(); +}; +} // namespace mozilla::dom + +#endif /* mozilla_dom_UniFFIPointer_h */ diff --git a/toolkit/components/uniffi-js/UniFFIPointerType.h b/toolkit/components/uniffi-js/UniFFIPointerType.h new file mode 100644 index 0000000000..7236e50cb7 --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFIPointerType.h @@ -0,0 +1,29 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_UniFFIPointerType_h +#define mozilla_UniFFIPointerType_h + +#include "nsISupports.h" +#include "nsWrapperCache.h" +#include "nsLiteralString.h" +#include "UniFFIRust.h" + +namespace mozilla::uniffi { + +/** + * UniFFIPointerType represents of UniFFI allocated pointers. + * Each UniFFIPointer will have a UniFFIPointerType, which will be a statically + * allocated type per object exposed by the UniFFI interface + **/ +struct UniFFIPointerType { + nsLiteralCString typeName; + // The Rust destructor for the pointer, this gives back ownership to Rust + void (*destructor)(void*, RustCallStatus*); +}; +} // namespace mozilla::uniffi + +#endif /* mozilla_UniFFIPointerType_h */ diff --git a/toolkit/components/uniffi-js/UniFFIRust.h b/toolkit/components/uniffi-js/UniFFIRust.h new file mode 100644 index 0000000000..2907af8f51 --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFIRust.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_UniFFIRust_h +#define mozilla_UniFFIRust_h + +#include + +namespace mozilla::uniffi { + +// Low-level Rust structs for UniFFI + +// RustCallStatus.code values +constexpr int8_t RUST_CALL_SUCCESS = 0; +constexpr int8_t RUST_CALL_ERROR = 1; +constexpr int8_t RUST_CALL_INTERNAL_ERROR = 2; + +// Return values for callback interfaces (See +// https://github.com/mozilla/uniffi-rs/blob/main/uniffi_core/src/ffi/foreigncallbacks.rs +// for details) +constexpr int8_t CALLBACK_INTERFACE_SUCCESS = 0; +constexpr int8_t CALLBACK_INTERFACE_ERROR = 1; +constexpr int8_t CALLBACK_INTERFACE_UNEXPECTED_ERROR = 2; + +// structs/functions from UniFFI +extern "C" { +struct RustBuffer { + int32_t capacity; + int32_t len; + uint8_t* data; +}; + +struct RustCallStatus { + int8_t code; + RustBuffer error_buf; +}; + +typedef int (*ForeignCallback)(uint64_t handle, uint32_t method, + const uint8_t* argsData, int32_t argsLen, + RustBuffer* buf_ptr); + +RustBuffer uniffi_rustbuffer_alloc(int32_t size, RustCallStatus* call_status); +void uniffi_rustbuffer_free(RustBuffer buf, RustCallStatus* call_status); +} + +} // namespace mozilla::uniffi + +#endif /* mozilla_UniFFIRust_h */ diff --git a/toolkit/components/uniffi-js/UniFFIScaffolding.cpp b/toolkit/components/uniffi-js/UniFFIScaffolding.cpp new file mode 100644 index 0000000000..3348b93e7d --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFIScaffolding.cpp @@ -0,0 +1,162 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include +#include "nsError.h" +#include "nsString.h" +#include "nsPrintfCString.h" +#include "mozilla/Maybe.h" +#include "mozilla/dom/UniFFIScaffolding.h" +#include "mozilla/dom/UniFFICallbacks.h" + +// This file implements the UniFFI WebIDL interface by leveraging the generate +// code in UniFFIScaffolding.cpp and UniFFIFixtureScaffolding.cpp. It's main +// purpose is to check if MOZ_UNIFFI_FIXTURES is set and only try calling the +// scaffolding code if it is. + +using mozilla::dom::ArrayBuffer; +using mozilla::dom::GlobalObject; +using mozilla::dom::Promise; +using mozilla::dom::RootedDictionary; +using mozilla::dom::ScaffoldingType; +using mozilla::dom::Sequence; +using mozilla::dom::UniFFICallbackHandler; +using mozilla::dom::UniFFIPointer; +using mozilla::dom::UniFFIScaffoldingCallResult; + +namespace mozilla::uniffi { + +// Prototypes for the generated functions +Maybe> UniFFICallAsync( + const GlobalObject& aGlobal, uint64_t aId, + const Sequence& aArgs, ErrorResult& aError); +bool UniFFICallSync(const GlobalObject& aGlobal, uint64_t aId, + const Sequence& aArgs, + RootedDictionary& aReturnValue, + ErrorResult& aError); +Maybe> UniFFIReadPointer( + const GlobalObject& aGlobal, uint64_t aId, const ArrayBuffer& aArrayBuff, + long aPosition, ErrorResult& aError); +bool UniFFIWritePointer(const GlobalObject& aGlobal, uint64_t aId, + const UniFFIPointer& aPtr, + const ArrayBuffer& aArrayBuff, long aPosition, + ErrorResult& aError); + +#ifdef MOZ_UNIFFI_FIXTURES +Maybe> UniFFIFixturesCallAsync( + const GlobalObject& aGlobal, uint64_t aId, + const Sequence& aArgs, ErrorResult& aError); +bool UniFFIFixturesCallSync( + const GlobalObject& aGlobal, uint64_t aId, + const Sequence& aArgs, + RootedDictionary& aReturnValue, + ErrorResult& aError); +Maybe> UniFFIFixturesReadPointer( + const GlobalObject& aGlobal, uint64_t aId, const ArrayBuffer& aArrayBuff, + long aPosition, ErrorResult& aError); +bool UniFFIFixturesWritePointer(const GlobalObject& aGlobal, uint64_t aId, + const UniFFIPointer& aPtr, + const ArrayBuffer& aArrayBuff, long aPosition, + ErrorResult& aError); +#endif +} // namespace mozilla::uniffi + +namespace mozilla::dom { + +// Implement the interface using the generated functions + +already_AddRefed UniFFIScaffolding::CallAsync( + const GlobalObject& aGlobal, uint64_t aId, + const Sequence& aArgs, ErrorResult& aError) { + Maybe> firstTry = + uniffi::UniFFICallAsync(aGlobal, aId, aArgs, aError); + if (firstTry.isSome()) { + return firstTry.extract(); + } +#ifdef MOZ_UNIFFI_FIXTURES + Maybe> secondTry = + uniffi::UniFFIFixturesCallAsync(aGlobal, aId, aArgs, aError); + if (secondTry.isSome()) { + return secondTry.extract(); + } +#endif + + aError.ThrowUnknownError( + nsPrintfCString("Unknown function id: %" PRIu64, aId)); + return nullptr; +} + +void UniFFIScaffolding::CallSync( + const GlobalObject& aGlobal, uint64_t aId, + const Sequence& aArgs, + RootedDictionary& aReturnValue, + ErrorResult& aError) { + if (uniffi::UniFFICallSync(aGlobal, aId, aArgs, aReturnValue, aError)) { + return; + } +#ifdef MOZ_UNIFFI_FIXTURES + if (uniffi::UniFFIFixturesCallSync(aGlobal, aId, aArgs, aReturnValue, + aError)) { + return; + } +#endif + + aError.ThrowUnknownError( + nsPrintfCString("Unknown function id: %" PRIu64, aId)); +} + +already_AddRefed UniFFIScaffolding::ReadPointer( + const GlobalObject& aGlobal, uint64_t aId, const ArrayBuffer& aArrayBuff, + long aPosition, ErrorResult& aError) { + Maybe> firstTry = + uniffi::UniFFIReadPointer(aGlobal, aId, aArrayBuff, aPosition, aError); + if (firstTry.isSome()) { + return firstTry.extract(); + } +#ifdef MOZ_UNIFFI_FIXTURES + Maybe> secondTry = + uniffi::UniFFIFixturesReadPointer(aGlobal, aId, aArrayBuff, aPosition, + aError); + if (secondTry.isSome()) { + return secondTry.extract(); + } +#endif + + aError.ThrowUnknownError(nsPrintfCString("Unknown object id: %" PRIu64, aId)); + return nullptr; +} + +void UniFFIScaffolding::WritePointer(const GlobalObject& aGlobal, uint64_t aId, + const UniFFIPointer& aPtr, + const ArrayBuffer& aArrayBuff, + long aPosition, ErrorResult& aError) { + if (uniffi::UniFFIWritePointer(aGlobal, aId, aPtr, aArrayBuff, aPosition, + aError)) { + return; + } +#ifdef MOZ_UNIFFI_FIXTURES + if (uniffi::UniFFIFixturesWritePointer(aGlobal, aId, aPtr, aArrayBuff, + aPosition, aError)) { + return; + } +#endif + + aError.ThrowUnknownError(nsPrintfCString("Unknown object id: %" PRIu64, aId)); +} + +void UniFFIScaffolding::RegisterCallbackHandler( + GlobalObject& aGlobal, uint64_t aInterfaceId, + UniFFICallbackHandler& aCallbackHandler, ErrorResult& aError) { + uniffi::RegisterCallbackHandler(aInterfaceId, aCallbackHandler, aError); +} + +void UniFFIScaffolding::DeregisterCallbackHandler(GlobalObject& aGlobal, + uint64_t aInterfaceId, + ErrorResult& aError) { + uniffi::DeregisterCallbackHandler(aInterfaceId, aError); +} + +} // namespace mozilla::dom diff --git a/toolkit/components/uniffi-js/UniFFIScaffolding.h b/toolkit/components/uniffi-js/UniFFIScaffolding.h new file mode 100644 index 0000000000..78beba8ff0 --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFIScaffolding.h @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_UniFFI_h +#define mozilla_dom_UniFFI_h + +#include "mozilla/ErrorResult.h" +#include "mozilla/dom/RootedDictionary.h" +#include "mozilla/dom/TypedArray.h" +#include "mozilla/dom/UniFFIBinding.h" + +namespace mozilla::dom { + +using ScaffoldingType = OwningDoubleOrArrayBufferOrUniFFIPointer; + +// Handle functions defined in UniFFIScaffolding.webidl +class UniFFIScaffolding { + public: + static already_AddRefed CallAsync( + const GlobalObject& aGlobal, uint64_t aId, + const Sequence& aArgs, ErrorResult& aErrorResult); + + static void CallSync( + const GlobalObject& aGlobal, uint64_t aId, + const Sequence& aArgs, + RootedDictionary& aReturnValue, + ErrorResult& aErrorResult); + + static already_AddRefed ReadPointer( + const GlobalObject& aGlobal, uint64_t aId, const ArrayBuffer& aArrayBuff, + long aPosition, ErrorResult& aError); + + static void WritePointer(const GlobalObject& aGlobal, uint64_t aId, + const UniFFIPointer& aPtr, + const ArrayBuffer& aArrayBuff, long aPosition, + ErrorResult& aError); + + static void RegisterCallbackHandler(GlobalObject& aGlobal, + uint64_t interfaceId, + UniFFICallbackHandler& aCallbackHandler, + ErrorResult& aError); + static void DeregisterCallbackHandler(GlobalObject& aGlobal, + uint64_t interfaceId, + ErrorResult& aError); +}; + +} // namespace mozilla::dom + +#endif /* mozilla_dom_UniFFI_h */ diff --git a/toolkit/components/uniffi-js/js/UniFFI.sys.mjs b/toolkit/components/uniffi-js/js/UniFFI.sys.mjs new file mode 100644 index 0000000000..c754cc9339 --- /dev/null +++ b/toolkit/components/uniffi-js/js/UniFFI.sys.mjs @@ -0,0 +1,39 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// This JS module contains shared functionality for the generated UniFFI JS +// code. + +// TypeError for UniFFI calls +// +// This extends TypeError to add support for recording a nice description of +// the item that fails the type check. This is especially useful for invalid +// values nested in objects/arrays/maps, etc. +// +// To accomplish this, the FfiConverter.checkType methods of records, arrays, +// maps, etc. catch UniFFITypeError, call `addItemDescriptionPart()` with a +// string representing the child item, then re-raise the exception. We then +// join all the parts together, in reverse order, to create item description +// strings like `foo.bar[123]["key"]` +export class UniFFITypeError extends TypeError { + constructor(reason) { + super(); + this.reason = reason; + this.itemDescriptionParts = []; + } + + addItemDescriptionPart(part) { + this.itemDescriptionParts.push(part); + } + + itemDescription() { + const itemDescriptionParts = [...this.itemDescriptionParts]; + itemDescriptionParts.reverse(); + return itemDescriptionParts.join(""); + } + + get message() { + return `${this.itemDescription()}: ${this.reason}`; + } +} diff --git a/toolkit/components/uniffi-js/moz.build b/toolkit/components/uniffi-js/moz.build new file mode 100644 index 0000000000..6eeb2d1aa7 --- /dev/null +++ b/toolkit/components/uniffi-js/moz.build @@ -0,0 +1,36 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +FINAL_LIBRARY = "xul" + +UNIFIED_SOURCES += [ + "OwnedRustBuffer.cpp", + "UniFFICallbacks.cpp", + "UniFFIGeneratedScaffolding.cpp", + "UniFFIPointer.cpp", + "UniFFIScaffolding.cpp", +] + +if CONFIG["MOZ_UNIFFI_FIXTURES"]: + DEFINES["MOZ_UNIFFI_FIXTURES"] = True + UNIFIED_SOURCES += [ + "UniFFIFixtureScaffolding.cpp", + ] + +EXPORTS.mozilla.dom += [ + "OwnedRustBuffer.h", + "ScaffoldingCall.h", + "ScaffoldingConverter.h", + "UniFFICallbacks.h", + "UniFFIPointer.h", + "UniFFIPointerType.h", + "UniFFIRust.h", + "UniFFIScaffolding.h", +] + +EXTRA_JS_MODULES += [ + "js/UniFFI.sys.mjs", +] -- cgit v1.2.3