diff options
Diffstat (limited to '')
-rw-r--r-- | toolkit/components/uniffi-js/OwnedRustBuffer.cpp | 92 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/OwnedRustBuffer.h | 69 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/README.md | 23 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/ScaffoldingCall.h | 260 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/ScaffoldingConverter.h | 206 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/UniFFICallbacks.cpp | 137 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/UniFFICallbacks.h | 75 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/UniFFIFixtureScaffolding.cpp | 1068 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp | 299 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/UniFFIPointer.cpp | 112 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/UniFFIPointer.h | 69 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/UniFFIPointerType.h | 29 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/UniFFIRust.h | 50 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/UniFFIScaffolding.cpp | 162 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/UniFFIScaffolding.h | 52 | ||||
-rw-r--r-- | toolkit/components/uniffi-js/moz.build | 32 |
16 files changed, 2735 insertions, 0 deletions
diff --git a/toolkit/components/uniffi-js/OwnedRustBuffer.cpp b/toolkit/components/uniffi-js/OwnedRustBuffer.cpp new file mode 100644 index 0000000000..96d9dc1fd7 --- /dev/null +++ b/toolkit/components/uniffi-js/OwnedRustBuffer.cpp @@ -0,0 +1,92 @@ +/* -*- 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, nsCString> OwnedRustBuffer::FromArrayBuffer( + const ArrayBuffer& aArrayBuffer) { + if (aArrayBuffer.Length() > INT32_MAX) { + return Err("Input ArrayBuffer is too large"_ns); + } + + RustCallStatus status{}; + RustBuffer buf = uniffi_rustbuffer_alloc( + static_cast<int32_t>(aArrayBuffer.Length()), &status); + buf.len = aArrayBuffer.Length(); + if (status.code != 0) { + if (status.error_buf.data) { + auto message = nsCString("uniffi_rustbuffer_alloc: "); + message.Append( + nsDependentCSubstring(reinterpret_cast<char*>(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); + + } else { + return Err("Unknown error allocating rust buffer"_ns); + } + } + + memcpy(buf.data, aArrayBuffer.Data(), 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) { + int32_t len = mBuf.len; + void* data = mBuf.data; + auto userData = MakeUnique<OwnedRustBuffer>(std::move(*this)); + return JS::NewExternalArrayBuffer(cx, len, data, &ArrayBufferFreeFunc, + userData.release()); +} + +void OwnedRustBuffer::ArrayBufferFreeFunc(void* contents, void* userData) { + UniquePtr<OwnedRustBuffer> buf{reinterpret_cast<OwnedRustBuffer*>(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<OwnedRustBuffer, nsCString> 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 <tuple> +#include <type_traits> +#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 <typename ReturnType> +struct RustCallResult { + ReturnType mReturnValue; + RustCallStatus mCallStatus = {}; +}; + +template <> +struct RustCallResult<void> { + 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 <typename ReturnConverter, typename... ArgConverters> +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<dom::Promise> CallAsync( + ScaffoldingFunc aScaffoldingFunc, const dom::GlobalObject& aGlobal, + const dom::Sequence<dom::ScaffoldingType>& 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<nsIGlobalObject> xpcomGlobal = + do_QueryInterface(aGlobal.GetAsSupports()); + RefPtr<dom::Promise> 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<dom::UniFFIScaffoldingCallResult> 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<dom::ScaffoldingType>& aArgs, + dom::RootedDictionary<dom::UniFFIScaffoldingCallResult>& 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<typename ArgConverters::RustType...>; + using IntermediateArgs = + std::tuple<typename ArgConverters::IntermediateType...>; + using CallResult = RustCallResult<typename ReturnConverter::RustType>; + using TaskPromiseType = MozPromise<CallResult, nsresult, true>; + + template <size_t I> + using NthArgConverter = + typename std::tuple_element<I, std::tuple<ArgConverters...>>::type; + + // Convert arguments from JS + // + // This should be called in the main thread + static Result<IntermediateArgs, nsCString> ConvertJsArgs( + const dom::Sequence<dom::ScaffoldingType>& aArgs) { + IntermediateArgs convertedArgs; + if (aArgs.Length() != std::tuple_size_v<IntermediateArgs>) { + 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 <size_t I = 0> + static Result<mozilla::Ok, nsCString> PrepareArgsHelper( + const dom::Sequence<dom::ScaffoldingType>& aArgs, + IntermediateArgs& aConvertedArgs) { + if constexpr (I >= sizeof...(ArgConverters)) { + // Iteration complete + return mozilla::Ok(); + } else { + // Single iteration step + auto result = NthArgConverter<I>::FromJs(aArgs[I]); + if (result.isOk()) { + // The conversion worked, store our result and move on to the next + std::get<I>(aConvertedArgs) = result.unwrap(); + return PrepareArgsHelper<I + 1>(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<ArgConverters...>()); + } + + // Helper function for CallScaffoldingFunc that uses c++ magic to help with + // iteration + template <size_t... Is> + static CallResult CallScaffoldingFuncHelper(ScaffoldingFunc aFunc, + IntermediateArgs&& aArgs, + std::index_sequence<Is...> seq) { + CallResult result; + + auto makeCall = [&]() mutable { + return aFunc( + NthArgConverter<Is>::IntoRust(std::move(std::get<Is>(aArgs)))..., + &result.mCallStatus); + }; + if constexpr (std::is_void_v<typename ReturnConverter::RustType>) { + 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<dom::UniFFIScaffoldingCallResult>& aReturnValue, + const nsLiteralCString& aFuncName) { + switch (aCallResult.mCallStatus.code) { + case RUST_CALL_SUCCESS: { + aReturnValue.mCode = dom::UniFFIScaffoldingCallCode::Success; + if constexpr (!std::is_void_v<typename ReturnConverter::RustType>) { + 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..59829938c2 --- /dev/null +++ b/toolkit/components/uniffi-js/ScaffoldingConverter.h @@ -0,0 +1,206 @@ +/* -*- 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 <limits> +#include <type_traits> +#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 <typename T, typename Tag = ScaffoldingConverterTagDefault> +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<IntermediateType, nsCString> 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<RustType>::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<RustType>::min() || + value > dom::PrimitiveConversionTraits_Limits<RustType>::max()) { + return Err("Out of bounds"_ns); + } + } + + // Don't check float bounds for a few reasons. + // - It's difficult because + // PrimitiveConversionTraits_Limits<float>::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<RustType>(value); + if constexpr (std::is_integral<RustType>::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<IntermediateType, nsCString> FromRust( + RustType aValue) { + if constexpr (std::is_same<RustType, int64_t>::value || + std::is_same<RustType, uint64_t>::value) { + // Check that the value can fit in a double (only needed for 64 bit types) + if (aValue < dom::PrimitiveConversionTraits_Limits<RustType>::min() || + aValue > dom::PrimitiveConversionTraits_Limits<RustType>::max()) { + return Err("Out of bounds"_ns); + } + } + if constexpr (std::is_floating_point<RustType>::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<RustBuffer> { + public: + using RustType = RustBuffer; + using IntermediateType = OwnedRustBuffer; + + static mozilla::Result<OwnedRustBuffer, nsCString> FromJs( + const dom::ScaffoldingType& aValue) { + if (!aValue.IsArrayBuffer()) { + return Err("Bad argument type"_ns); + } + + const dom::ArrayBuffer& arrayBuf = aValue.GetAsArrayBuffer(); + arrayBuf.ComputeState(); + return OwnedRustBuffer::FromArrayBuffer(arrayBuf); + } + + static RustBuffer IntoRust(OwnedRustBuffer&& aValue) { + return aValue.IntoRustBuffer(); + } + + static mozilla::Result<OwnedRustBuffer, nsCString> 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 <const UniFFIPointerType* PointerType> +class ScaffoldingObjectConverter { + public: + using RustType = void*; + using IntermediateType = void*; + + static mozilla::Result<void*, nsCString> 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<void*, nsCString> 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<void> { + 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..c8014558a7 --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFICallbacks.cpp @@ -0,0 +1,137 @@ +/* -*- 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" + +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<CallbackInterfaceInfo> GetCallbackInterfaceInfo( + uint64_t aInterfaceId) { + const Maybe<CallbackInterfaceInfo> 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<CallbackInterfaceInfo> 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<CallbackInterfaceInfo> 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, OwnedRustBuffer aArgs) { + MOZ_ASSERT(NS_IsMainThread()); + + Maybe<CallbackInterfaceInfo> 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<UniFFICallbackHandler> 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); + IgnoredErrorResult error; + JS::Rooted<JSObject*> args(aes.cx(), aArgs.IntoArrayBuffer(aes.cx())); + + 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, + RustBuffer aArgs) { + nsresult dispatchResult = + GetMainThreadSerialEventTarget()->Dispatch(NS_NewRunnableFunction( + "UniFFI callback", [=]() MOZ_CAN_RUN_SCRIPT_BOUNDARY { + QueueCallbackInner(aInterfaceId, aHandle, aMethod, + OwnedRustBuffer(aArgs)); + })); + + 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..34faeda6a2 --- /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<dom::UniFFICallbackHandler>* 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<CallbackInterfaceInfo> UniFFIGetCallbackInterfaceInfo( + uint64_t aInterfaceId); + +#ifdef MOZ_UNIFFI_FIXTURES +Maybe<CallbackInterfaceInfo> 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, + RustBuffer aArgs); + +} // 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..67d6506b2e --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFIFixtureScaffolding.cpp @@ -0,0 +1,1068 @@ +// 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" { + double geometry_1cce_gradient(RustBuffer, RustCallStatus*); + RustBuffer geometry_1cce_intersection(RustBuffer, RustBuffer, RustCallStatus*); + uint64_t arithmetic_906c_add(uint64_t, uint64_t, RustCallStatus*); + uint64_t arithmetic_906c_sub(uint64_t, uint64_t, RustCallStatus*); + uint64_t arithmetic_906c_div(uint64_t, uint64_t, RustCallStatus*); + int8_t arithmetic_906c_equal(uint64_t, uint64_t, RustCallStatus*); + void ffi_rondpoint_c6ef_Retourneur_object_free(void *, RustCallStatus*); + void * rondpoint_c6ef_Retourneur_new(RustCallStatus*); + int8_t rondpoint_c6ef_Retourneur_identique_i8(void *, int8_t, RustCallStatus*); + uint8_t rondpoint_c6ef_Retourneur_identique_u8(void *, uint8_t, RustCallStatus*); + int16_t rondpoint_c6ef_Retourneur_identique_i16(void *, int16_t, RustCallStatus*); + uint16_t rondpoint_c6ef_Retourneur_identique_u16(void *, uint16_t, RustCallStatus*); + int32_t rondpoint_c6ef_Retourneur_identique_i32(void *, int32_t, RustCallStatus*); + uint32_t rondpoint_c6ef_Retourneur_identique_u32(void *, uint32_t, RustCallStatus*); + int64_t rondpoint_c6ef_Retourneur_identique_i64(void *, int64_t, RustCallStatus*); + uint64_t rondpoint_c6ef_Retourneur_identique_u64(void *, uint64_t, RustCallStatus*); + float rondpoint_c6ef_Retourneur_identique_float(void *, float, RustCallStatus*); + double rondpoint_c6ef_Retourneur_identique_double(void *, double, RustCallStatus*); + int8_t rondpoint_c6ef_Retourneur_identique_boolean(void *, int8_t, RustCallStatus*); + RustBuffer rondpoint_c6ef_Retourneur_identique_string(void *, RustBuffer, RustCallStatus*); + RustBuffer rondpoint_c6ef_Retourneur_identique_nombres_signes(void *, RustBuffer, RustCallStatus*); + RustBuffer rondpoint_c6ef_Retourneur_identique_nombres(void *, RustBuffer, RustCallStatus*); + RustBuffer rondpoint_c6ef_Retourneur_identique_optionneur_dictionnaire(void *, RustBuffer, RustCallStatus*); + void ffi_rondpoint_c6ef_Stringifier_object_free(void *, RustCallStatus*); + void * rondpoint_c6ef_Stringifier_new(RustCallStatus*); + RustBuffer rondpoint_c6ef_Stringifier_well_known_string(void *, RustBuffer, RustCallStatus*); + RustBuffer rondpoint_c6ef_Stringifier_to_string_i8(void *, int8_t, RustCallStatus*); + RustBuffer rondpoint_c6ef_Stringifier_to_string_u8(void *, uint8_t, RustCallStatus*); + RustBuffer rondpoint_c6ef_Stringifier_to_string_i16(void *, int16_t, RustCallStatus*); + RustBuffer rondpoint_c6ef_Stringifier_to_string_u16(void *, uint16_t, RustCallStatus*); + RustBuffer rondpoint_c6ef_Stringifier_to_string_i32(void *, int32_t, RustCallStatus*); + RustBuffer rondpoint_c6ef_Stringifier_to_string_u32(void *, uint32_t, RustCallStatus*); + RustBuffer rondpoint_c6ef_Stringifier_to_string_i64(void *, int64_t, RustCallStatus*); + RustBuffer rondpoint_c6ef_Stringifier_to_string_u64(void *, uint64_t, RustCallStatus*); + RustBuffer rondpoint_c6ef_Stringifier_to_string_float(void *, float, RustCallStatus*); + RustBuffer rondpoint_c6ef_Stringifier_to_string_double(void *, double, RustCallStatus*); + RustBuffer rondpoint_c6ef_Stringifier_to_string_boolean(void *, int8_t, RustCallStatus*); + void ffi_rondpoint_c6ef_Optionneur_object_free(void *, RustCallStatus*); + void * rondpoint_c6ef_Optionneur_new(RustCallStatus*); + int8_t rondpoint_c6ef_Optionneur_sinon_boolean(void *, int8_t, RustCallStatus*); + RustBuffer rondpoint_c6ef_Optionneur_sinon_string(void *, RustBuffer, RustCallStatus*); + RustBuffer rondpoint_c6ef_Optionneur_sinon_sequence(void *, RustBuffer, RustCallStatus*); + RustBuffer rondpoint_c6ef_Optionneur_sinon_null(void *, RustBuffer, RustCallStatus*); + RustBuffer rondpoint_c6ef_Optionneur_sinon_zero(void *, RustBuffer, RustCallStatus*); + uint8_t rondpoint_c6ef_Optionneur_sinon_u8_dec(void *, uint8_t, RustCallStatus*); + int8_t rondpoint_c6ef_Optionneur_sinon_i8_dec(void *, int8_t, RustCallStatus*); + uint16_t rondpoint_c6ef_Optionneur_sinon_u16_dec(void *, uint16_t, RustCallStatus*); + int16_t rondpoint_c6ef_Optionneur_sinon_i16_dec(void *, int16_t, RustCallStatus*); + uint32_t rondpoint_c6ef_Optionneur_sinon_u32_dec(void *, uint32_t, RustCallStatus*); + int32_t rondpoint_c6ef_Optionneur_sinon_i32_dec(void *, int32_t, RustCallStatus*); + uint64_t rondpoint_c6ef_Optionneur_sinon_u64_dec(void *, uint64_t, RustCallStatus*); + int64_t rondpoint_c6ef_Optionneur_sinon_i64_dec(void *, int64_t, RustCallStatus*); + uint8_t rondpoint_c6ef_Optionneur_sinon_u8_hex(void *, uint8_t, RustCallStatus*); + int8_t rondpoint_c6ef_Optionneur_sinon_i8_hex(void *, int8_t, RustCallStatus*); + uint16_t rondpoint_c6ef_Optionneur_sinon_u16_hex(void *, uint16_t, RustCallStatus*); + int16_t rondpoint_c6ef_Optionneur_sinon_i16_hex(void *, int16_t, RustCallStatus*); + uint32_t rondpoint_c6ef_Optionneur_sinon_u32_hex(void *, uint32_t, RustCallStatus*); + int32_t rondpoint_c6ef_Optionneur_sinon_i32_hex(void *, int32_t, RustCallStatus*); + uint64_t rondpoint_c6ef_Optionneur_sinon_u64_hex(void *, uint64_t, RustCallStatus*); + int64_t rondpoint_c6ef_Optionneur_sinon_i64_hex(void *, int64_t, RustCallStatus*); + uint32_t rondpoint_c6ef_Optionneur_sinon_u32_oct(void *, uint32_t, RustCallStatus*); + float rondpoint_c6ef_Optionneur_sinon_f32(void *, float, RustCallStatus*); + double rondpoint_c6ef_Optionneur_sinon_f64(void *, double, RustCallStatus*); + RustBuffer rondpoint_c6ef_Optionneur_sinon_enum(void *, RustBuffer, RustCallStatus*); + RustBuffer rondpoint_c6ef_copie_dictionnaire(RustBuffer, RustCallStatus*); + RustBuffer rondpoint_c6ef_copie_enumeration(RustBuffer, RustCallStatus*); + RustBuffer rondpoint_c6ef_copie_enumerations(RustBuffer, RustCallStatus*); + RustBuffer rondpoint_c6ef_copie_carte(RustBuffer, RustCallStatus*); + int8_t rondpoint_c6ef_switcheroo(int8_t, RustCallStatus*); + void ffi_sprites_accb_Sprite_object_free(void *, RustCallStatus*); + void * sprites_accb_Sprite_new(RustBuffer, RustCallStatus*); + void * sprites_accb_Sprite_new_relative_to(RustBuffer, RustBuffer, RustCallStatus*); + RustBuffer sprites_accb_Sprite_get_position(void *, RustCallStatus*); + void sprites_accb_Sprite_move_to(void *, RustBuffer, RustCallStatus*); + void sprites_accb_Sprite_move_by(void *, RustBuffer, RustCallStatus*); + RustBuffer sprites_accb_translate(RustBuffer, RustBuffer, RustCallStatus*); + void ffi_todolist_aa33_TodoList_object_free(void *, RustCallStatus*); + void * todolist_aa33_TodoList_new(RustCallStatus*); + void todolist_aa33_TodoList_add_item(void *, RustBuffer, RustCallStatus*); + void todolist_aa33_TodoList_add_entry(void *, RustBuffer, RustCallStatus*); + RustBuffer todolist_aa33_TodoList_get_entries(void *, RustCallStatus*); + RustBuffer todolist_aa33_TodoList_get_items(void *, RustCallStatus*); + void todolist_aa33_TodoList_add_entries(void *, RustBuffer, RustCallStatus*); + void todolist_aa33_TodoList_add_items(void *, RustBuffer, RustCallStatus*); + RustBuffer todolist_aa33_TodoList_get_last_entry(void *, RustCallStatus*); + RustBuffer todolist_aa33_TodoList_get_last(void *, RustCallStatus*); + RustBuffer todolist_aa33_TodoList_get_first(void *, RustCallStatus*); + void todolist_aa33_TodoList_clear_item(void *, RustBuffer, RustCallStatus*); + void todolist_aa33_TodoList_make_default(void *, RustCallStatus*); + RustBuffer todolist_aa33_get_default_list(RustCallStatus*); + void todolist_aa33_set_default_list(void *, RustCallStatus*); + RustBuffer todolist_aa33_create_entry_with(RustBuffer, RustCallStatus*); + void ffi_fixture_callbacks_1107_Logger_init_callback(ForeignCallback, RustCallStatus*); + void fixture_callbacks_1107_log_even_numbers(uint64_t, RustBuffer, RustCallStatus*); + void fixture_callbacks_1107_log_even_numbers_main_thread(uint64_t, RustBuffer, RustCallStatus*); + RustBuffer custom_types_8ecd_get_custom_types_demo(RustBuffer, RustCallStatus*); + double external_types_54cc_gradient(RustBuffer, RustCallStatus*); +} + +// Define pointer types +const static mozilla::uniffi::UniFFIPointerType kRondpointRetourneurPointerType { + "rondpoint::Retourneur"_ns, + ffi_rondpoint_c6ef_Retourneur_object_free +}; +const static mozilla::uniffi::UniFFIPointerType kRondpointStringifierPointerType { + "rondpoint::Stringifier"_ns, + ffi_rondpoint_c6ef_Stringifier_object_free +}; +const static mozilla::uniffi::UniFFIPointerType kRondpointOptionneurPointerType { + "rondpoint::Optionneur"_ns, + ffi_rondpoint_c6ef_Optionneur_object_free +}; +const static mozilla::uniffi::UniFFIPointerType kSpritesSpritePointerType { + "sprites::Sprite"_ns, + ffi_sprites_accb_Sprite_object_free +}; +const static mozilla::uniffi::UniFFIPointerType kTodolistTodoListPointerType { + "todolist::TodoList"_ns, + ffi_todolist_aa33_TodoList_object_free +}; + +// Define the data we need per-callback interface +MOZ_CAN_RUN_SCRIPT +extern "C" int UniFFIFixturesCallbackHandlerLogger(uint64_t aHandle, uint32_t aMethod, RustBuffer aArgs, 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, aArgs); + return CALLBACK_INTERFACE_SUCCESS; +} +static StaticRefPtr<dom::UniFFICallbackHandler> JS_CALLBACK_HANDLER_LOGGER; + +// Define a lookup function for our callback interface info +Maybe<CallbackInterfaceInfo> UniFFIFixturesGetCallbackInterfaceInfo(uint64_t aInterfaceId) { + switch(aInterfaceId) { + case 0: { // fixture_callbacks:Logger + return Some(CallbackInterfaceInfo { + "Logger", + &JS_CALLBACK_HANDLER_LOGGER, + UniFFIFixturesCallbackHandlerLogger, + ffi_fixture_callbacks_1107_Logger_init_callback, + }); + } + + default: + return Nothing(); + } +} + +Maybe<already_AddRefed<Promise>> UniFFIFixturesCallAsync(const GlobalObject& aGlobal, uint64_t aId, const Sequence<ScaffoldingType>& aArgs, ErrorResult& aError) { + switch (aId) { + case 20: { // geometry:geometry_1cce_gradient + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<double>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(geometry_1cce_gradient, aGlobal, aArgs, "geometry_1cce_gradient: "_ns, aError)); + } + case 21: { // geometry:geometry_1cce_intersection + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(geometry_1cce_intersection, aGlobal, aArgs, "geometry_1cce_intersection: "_ns, aError)); + } + case 22: { // arithmetic:arithmetic_906c_add + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>>; + return Some(CallHandler::CallAsync(arithmetic_906c_add, aGlobal, aArgs, "arithmetic_906c_add: "_ns, aError)); + } + case 23: { // arithmetic:arithmetic_906c_sub + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>>; + return Some(CallHandler::CallAsync(arithmetic_906c_sub, aGlobal, aArgs, "arithmetic_906c_sub: "_ns, aError)); + } + case 24: { // arithmetic:arithmetic_906c_div + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>>; + return Some(CallHandler::CallAsync(arithmetic_906c_div, aGlobal, aArgs, "arithmetic_906c_div: "_ns, aError)); + } + case 25: { // arithmetic:arithmetic_906c_equal + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>>; + return Some(CallHandler::CallAsync(arithmetic_906c_equal, aGlobal, aArgs, "arithmetic_906c_equal: "_ns, aError)); + } + case 26: { // rondpoint:rondpoint_c6ef_Retourneur_new + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_new, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_new: "_ns, aError)); + } + case 27: { // rondpoint:rondpoint_c6ef_Retourneur_identique_i8 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<int8_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_i8, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_i8: "_ns, aError)); + } + case 28: { // rondpoint:rondpoint_c6ef_Retourneur_identique_u8 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint8_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<uint8_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_u8, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_u8: "_ns, aError)); + } + case 29: { // rondpoint:rondpoint_c6ef_Retourneur_identique_i16 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int16_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<int16_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_i16, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_i16: "_ns, aError)); + } + case 30: { // rondpoint:rondpoint_c6ef_Retourneur_identique_u16 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint16_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<uint16_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_u16, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_u16: "_ns, aError)); + } + case 31: { // rondpoint:rondpoint_c6ef_Retourneur_identique_i32 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int32_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<int32_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_i32, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_i32: "_ns, aError)); + } + case 32: { // rondpoint:rondpoint_c6ef_Retourneur_identique_u32 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint32_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<uint32_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_u32, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_u32: "_ns, aError)); + } + case 33: { // rondpoint:rondpoint_c6ef_Retourneur_identique_i64 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int64_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<int64_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_i64, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_i64: "_ns, aError)); + } + case 34: { // rondpoint:rondpoint_c6ef_Retourneur_identique_u64 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint64_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<uint64_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_u64, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_u64: "_ns, aError)); + } + case 35: { // rondpoint:rondpoint_c6ef_Retourneur_identique_float + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<float>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<float>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_float, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_float: "_ns, aError)); + } + case 36: { // rondpoint:rondpoint_c6ef_Retourneur_identique_double + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<double>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<double>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_double, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_double: "_ns, aError)); + } + case 37: { // rondpoint:rondpoint_c6ef_Retourneur_identique_boolean + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<int8_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_boolean, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_boolean: "_ns, aError)); + } + case 38: { // rondpoint:rondpoint_c6ef_Retourneur_identique_string + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_string, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_string: "_ns, aError)); + } + case 39: { // rondpoint:rondpoint_c6ef_Retourneur_identique_nombres_signes + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_nombres_signes, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_nombres_signes: "_ns, aError)); + } + case 40: { // rondpoint:rondpoint_c6ef_Retourneur_identique_nombres + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_nombres, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_nombres: "_ns, aError)); + } + case 41: { // rondpoint:rondpoint_c6ef_Retourneur_identique_optionneur_dictionnaire + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Retourneur_identique_optionneur_dictionnaire, aGlobal, aArgs, "rondpoint_c6ef_Retourneur_identique_optionneur_dictionnaire: "_ns, aError)); + } + case 42: { // rondpoint:rondpoint_c6ef_Stringifier_new + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kRondpointStringifierPointerType>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Stringifier_new, aGlobal, aArgs, "rondpoint_c6ef_Stringifier_new: "_ns, aError)); + } + case 43: { // rondpoint:rondpoint_c6ef_Stringifier_well_known_string + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Stringifier_well_known_string, aGlobal, aArgs, "rondpoint_c6ef_Stringifier_well_known_string: "_ns, aError)); + } + case 44: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_i8 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<int8_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Stringifier_to_string_i8, aGlobal, aArgs, "rondpoint_c6ef_Stringifier_to_string_i8: "_ns, aError)); + } + case 45: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_u8 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<uint8_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Stringifier_to_string_u8, aGlobal, aArgs, "rondpoint_c6ef_Stringifier_to_string_u8: "_ns, aError)); + } + case 46: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_i16 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<int16_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Stringifier_to_string_i16, aGlobal, aArgs, "rondpoint_c6ef_Stringifier_to_string_i16: "_ns, aError)); + } + case 47: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_u16 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<uint16_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Stringifier_to_string_u16, aGlobal, aArgs, "rondpoint_c6ef_Stringifier_to_string_u16: "_ns, aError)); + } + case 48: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_i32 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<int32_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Stringifier_to_string_i32, aGlobal, aArgs, "rondpoint_c6ef_Stringifier_to_string_i32: "_ns, aError)); + } + case 49: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_u32 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<uint32_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Stringifier_to_string_u32, aGlobal, aArgs, "rondpoint_c6ef_Stringifier_to_string_u32: "_ns, aError)); + } + case 50: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_i64 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<int64_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Stringifier_to_string_i64, aGlobal, aArgs, "rondpoint_c6ef_Stringifier_to_string_i64: "_ns, aError)); + } + case 51: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_u64 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<uint64_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Stringifier_to_string_u64, aGlobal, aArgs, "rondpoint_c6ef_Stringifier_to_string_u64: "_ns, aError)); + } + case 52: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_float + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<float>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Stringifier_to_string_float, aGlobal, aArgs, "rondpoint_c6ef_Stringifier_to_string_float: "_ns, aError)); + } + case 53: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_double + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<double>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Stringifier_to_string_double, aGlobal, aArgs, "rondpoint_c6ef_Stringifier_to_string_double: "_ns, aError)); + } + case 54: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_boolean + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<int8_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Stringifier_to_string_boolean, aGlobal, aArgs, "rondpoint_c6ef_Stringifier_to_string_boolean: "_ns, aError)); + } + case 55: { // rondpoint:rondpoint_c6ef_Optionneur_new + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_new, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_new: "_ns, aError)); + } + case 56: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_boolean + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int8_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_boolean, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_boolean: "_ns, aError)); + } + case 57: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_string + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_string, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_string: "_ns, aError)); + } + case 58: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_sequence + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_sequence, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_sequence: "_ns, aError)); + } + case 59: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_null + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_null, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_null: "_ns, aError)); + } + case 60: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_zero + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_zero, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_zero: "_ns, aError)); + } + case 61: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u8_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint8_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint8_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_u8_dec, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_u8_dec: "_ns, aError)); + } + case 62: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i8_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int8_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_i8_dec, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_i8_dec: "_ns, aError)); + } + case 63: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u16_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint16_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint16_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_u16_dec, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_u16_dec: "_ns, aError)); + } + case 64: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i16_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int16_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int16_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_i16_dec, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_i16_dec: "_ns, aError)); + } + case 65: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u32_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint32_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint32_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_u32_dec, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_u32_dec: "_ns, aError)); + } + case 66: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i32_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int32_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int32_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_i32_dec, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_i32_dec: "_ns, aError)); + } + case 67: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u64_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint64_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint64_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_u64_dec, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_u64_dec: "_ns, aError)); + } + case 68: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i64_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int64_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int64_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_i64_dec, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_i64_dec: "_ns, aError)); + } + case 69: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u8_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint8_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint8_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_u8_hex, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_u8_hex: "_ns, aError)); + } + case 70: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i8_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int8_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_i8_hex, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_i8_hex: "_ns, aError)); + } + case 71: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u16_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint16_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint16_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_u16_hex, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_u16_hex: "_ns, aError)); + } + case 72: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i16_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int16_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int16_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_i16_hex, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_i16_hex: "_ns, aError)); + } + case 73: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u32_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint32_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint32_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_u32_hex, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_u32_hex: "_ns, aError)); + } + case 74: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i32_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int32_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int32_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_i32_hex, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_i32_hex: "_ns, aError)); + } + case 75: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u64_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint64_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint64_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_u64_hex, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_u64_hex: "_ns, aError)); + } + case 76: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i64_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int64_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int64_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_i64_hex, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_i64_hex: "_ns, aError)); + } + case 77: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u32_oct + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint32_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint32_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_u32_oct, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_u32_oct: "_ns, aError)); + } + case 78: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_f32 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<float>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<float>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_f32, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_f32: "_ns, aError)); + } + case 79: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_f64 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<double>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<double>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_f64, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_f64: "_ns, aError)); + } + case 80: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_enum + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_Optionneur_sinon_enum, aGlobal, aArgs, "rondpoint_c6ef_Optionneur_sinon_enum: "_ns, aError)); + } + case 81: { // rondpoint:rondpoint_c6ef_copie_dictionnaire + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_copie_dictionnaire, aGlobal, aArgs, "rondpoint_c6ef_copie_dictionnaire: "_ns, aError)); + } + case 82: { // rondpoint:rondpoint_c6ef_copie_enumeration + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_copie_enumeration, aGlobal, aArgs, "rondpoint_c6ef_copie_enumeration: "_ns, aError)); + } + case 83: { // rondpoint:rondpoint_c6ef_copie_enumerations + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_copie_enumerations, aGlobal, aArgs, "rondpoint_c6ef_copie_enumerations: "_ns, aError)); + } + case 84: { // rondpoint:rondpoint_c6ef_copie_carte + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_copie_carte, aGlobal, aArgs, "rondpoint_c6ef_copie_carte: "_ns, aError)); + } + case 85: { // rondpoint:rondpoint_c6ef_switcheroo + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingConverter<int8_t>>; + return Some(CallHandler::CallAsync(rondpoint_c6ef_switcheroo, aGlobal, aArgs, "rondpoint_c6ef_switcheroo: "_ns, aError)); + } + case 86: { // sprites:sprites_accb_Sprite_new + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kSpritesSpritePointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(sprites_accb_Sprite_new, aGlobal, aArgs, "sprites_accb_Sprite_new: "_ns, aError)); + } + case 87: { // sprites:sprites_accb_Sprite_new_relative_to + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kSpritesSpritePointerType>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(sprites_accb_Sprite_new_relative_to, aGlobal, aArgs, "sprites_accb_Sprite_new_relative_to: "_ns, aError)); + } + case 88: { // sprites:sprites_accb_Sprite_get_position + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kSpritesSpritePointerType>>; + return Some(CallHandler::CallAsync(sprites_accb_Sprite_get_position, aGlobal, aArgs, "sprites_accb_Sprite_get_position: "_ns, aError)); + } + case 89: { // sprites:sprites_accb_Sprite_move_to + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kSpritesSpritePointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(sprites_accb_Sprite_move_to, aGlobal, aArgs, "sprites_accb_Sprite_move_to: "_ns, aError)); + } + case 90: { // sprites:sprites_accb_Sprite_move_by + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kSpritesSpritePointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(sprites_accb_Sprite_move_by, aGlobal, aArgs, "sprites_accb_Sprite_move_by: "_ns, aError)); + } + case 91: { // sprites:sprites_accb_translate + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(sprites_accb_translate, aGlobal, aArgs, "sprites_accb_translate: "_ns, aError)); + } + case 92: { // todolist:todolist_aa33_TodoList_new + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(todolist_aa33_TodoList_new, aGlobal, aArgs, "todolist_aa33_TodoList_new: "_ns, aError)); + } + case 93: { // todolist:todolist_aa33_TodoList_add_item + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(todolist_aa33_TodoList_add_item, aGlobal, aArgs, "todolist_aa33_TodoList_add_item: "_ns, aError)); + } + case 94: { // todolist:todolist_aa33_TodoList_add_entry + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(todolist_aa33_TodoList_add_entry, aGlobal, aArgs, "todolist_aa33_TodoList_add_entry: "_ns, aError)); + } + case 95: { // todolist:todolist_aa33_TodoList_get_entries + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(todolist_aa33_TodoList_get_entries, aGlobal, aArgs, "todolist_aa33_TodoList_get_entries: "_ns, aError)); + } + case 96: { // todolist:todolist_aa33_TodoList_get_items + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(todolist_aa33_TodoList_get_items, aGlobal, aArgs, "todolist_aa33_TodoList_get_items: "_ns, aError)); + } + case 97: { // todolist:todolist_aa33_TodoList_add_entries + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(todolist_aa33_TodoList_add_entries, aGlobal, aArgs, "todolist_aa33_TodoList_add_entries: "_ns, aError)); + } + case 98: { // todolist:todolist_aa33_TodoList_add_items + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(todolist_aa33_TodoList_add_items, aGlobal, aArgs, "todolist_aa33_TodoList_add_items: "_ns, aError)); + } + case 99: { // todolist:todolist_aa33_TodoList_get_last_entry + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(todolist_aa33_TodoList_get_last_entry, aGlobal, aArgs, "todolist_aa33_TodoList_get_last_entry: "_ns, aError)); + } + case 100: { // todolist:todolist_aa33_TodoList_get_last + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(todolist_aa33_TodoList_get_last, aGlobal, aArgs, "todolist_aa33_TodoList_get_last: "_ns, aError)); + } + case 101: { // todolist:todolist_aa33_TodoList_get_first + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(todolist_aa33_TodoList_get_first, aGlobal, aArgs, "todolist_aa33_TodoList_get_first: "_ns, aError)); + } + case 102: { // todolist:todolist_aa33_TodoList_clear_item + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(todolist_aa33_TodoList_clear_item, aGlobal, aArgs, "todolist_aa33_TodoList_clear_item: "_ns, aError)); + } + case 103: { // todolist:todolist_aa33_TodoList_make_default + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(todolist_aa33_TodoList_make_default, aGlobal, aArgs, "todolist_aa33_TodoList_make_default: "_ns, aError)); + } + case 104: { // todolist:todolist_aa33_get_default_list + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(todolist_aa33_get_default_list, aGlobal, aArgs, "todolist_aa33_get_default_list: "_ns, aError)); + } + case 105: { // todolist:todolist_aa33_set_default_list + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + return Some(CallHandler::CallAsync(todolist_aa33_set_default_list, aGlobal, aArgs, "todolist_aa33_set_default_list: "_ns, aError)); + } + case 106: { // todolist:todolist_aa33_create_entry_with + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(todolist_aa33_create_entry_with, aGlobal, aArgs, "todolist_aa33_create_entry_with: "_ns, aError)); + } + case 107: { // fixture_callbacks:fixture_callbacks_1107_log_even_numbers + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingConverter<uint64_t>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(fixture_callbacks_1107_log_even_numbers, aGlobal, aArgs, "fixture_callbacks_1107_log_even_numbers: "_ns, aError)); + } + case 108: { // fixture_callbacks:fixture_callbacks_1107_log_even_numbers_main_thread + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingConverter<uint64_t>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(fixture_callbacks_1107_log_even_numbers_main_thread, aGlobal, aArgs, "fixture_callbacks_1107_log_even_numbers_main_thread: "_ns, aError)); + } + case 109: { // custom_types:custom_types_8ecd_get_custom_types_demo + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(custom_types_8ecd_get_custom_types_demo, aGlobal, aArgs, "custom_types_8ecd_get_custom_types_demo: "_ns, aError)); + } + case 110: { // external_types:external_types_54cc_gradient + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<double>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(external_types_54cc_gradient, aGlobal, aArgs, "external_types_54cc_gradient: "_ns, aError)); + } + } + return Nothing(); +} + +bool UniFFIFixturesCallSync(const GlobalObject& aGlobal, uint64_t aId, const Sequence<ScaffoldingType>& aArgs, RootedDictionary<UniFFIScaffoldingCallResult>& aReturnValue, ErrorResult& aError) { + switch (aId) { + case 20: { // geometry:geometry_1cce_gradient + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<double>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(geometry_1cce_gradient, aGlobal, aArgs, aReturnValue, "geometry_1cce_gradient: "_ns, aError); + return true; + } + case 21: { // geometry:geometry_1cce_intersection + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(geometry_1cce_intersection, aGlobal, aArgs, aReturnValue, "geometry_1cce_intersection: "_ns, aError); + return true; + } + case 22: { // arithmetic:arithmetic_906c_add + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>>; + CallHandler::CallSync(arithmetic_906c_add, aGlobal, aArgs, aReturnValue, "arithmetic_906c_add: "_ns, aError); + return true; + } + case 23: { // arithmetic:arithmetic_906c_sub + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>>; + CallHandler::CallSync(arithmetic_906c_sub, aGlobal, aArgs, aReturnValue, "arithmetic_906c_sub: "_ns, aError); + return true; + } + case 24: { // arithmetic:arithmetic_906c_div + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>>; + CallHandler::CallSync(arithmetic_906c_div, aGlobal, aArgs, aReturnValue, "arithmetic_906c_div: "_ns, aError); + return true; + } + case 25: { // arithmetic:arithmetic_906c_equal + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingConverter<uint64_t>, ScaffoldingConverter<uint64_t>>; + CallHandler::CallSync(arithmetic_906c_equal, aGlobal, aArgs, aReturnValue, "arithmetic_906c_equal: "_ns, aError); + return true; + } + case 26: { // rondpoint:rondpoint_c6ef_Retourneur_new + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_new, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_new: "_ns, aError); + return true; + } + case 27: { // rondpoint:rondpoint_c6ef_Retourneur_identique_i8 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<int8_t>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_i8, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_i8: "_ns, aError); + return true; + } + case 28: { // rondpoint:rondpoint_c6ef_Retourneur_identique_u8 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint8_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<uint8_t>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_u8, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_u8: "_ns, aError); + return true; + } + case 29: { // rondpoint:rondpoint_c6ef_Retourneur_identique_i16 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int16_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<int16_t>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_i16, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_i16: "_ns, aError); + return true; + } + case 30: { // rondpoint:rondpoint_c6ef_Retourneur_identique_u16 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint16_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<uint16_t>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_u16, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_u16: "_ns, aError); + return true; + } + case 31: { // rondpoint:rondpoint_c6ef_Retourneur_identique_i32 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int32_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<int32_t>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_i32, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_i32: "_ns, aError); + return true; + } + case 32: { // rondpoint:rondpoint_c6ef_Retourneur_identique_u32 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint32_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<uint32_t>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_u32, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_u32: "_ns, aError); + return true; + } + case 33: { // rondpoint:rondpoint_c6ef_Retourneur_identique_i64 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int64_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<int64_t>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_i64, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_i64: "_ns, aError); + return true; + } + case 34: { // rondpoint:rondpoint_c6ef_Retourneur_identique_u64 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint64_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<uint64_t>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_u64, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_u64: "_ns, aError); + return true; + } + case 35: { // rondpoint:rondpoint_c6ef_Retourneur_identique_float + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<float>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<float>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_float, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_float: "_ns, aError); + return true; + } + case 36: { // rondpoint:rondpoint_c6ef_Retourneur_identique_double + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<double>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<double>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_double, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_double: "_ns, aError); + return true; + } + case 37: { // rondpoint:rondpoint_c6ef_Retourneur_identique_boolean + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<int8_t>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_boolean, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_boolean: "_ns, aError); + return true; + } + case 38: { // rondpoint:rondpoint_c6ef_Retourneur_identique_string + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_string, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_string: "_ns, aError); + return true; + } + case 39: { // rondpoint:rondpoint_c6ef_Retourneur_identique_nombres_signes + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_nombres_signes, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_nombres_signes: "_ns, aError); + return true; + } + case 40: { // rondpoint:rondpoint_c6ef_Retourneur_identique_nombres + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_nombres, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_nombres: "_ns, aError); + return true; + } + case 41: { // rondpoint:rondpoint_c6ef_Retourneur_identique_optionneur_dictionnaire + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointRetourneurPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_Retourneur_identique_optionneur_dictionnaire, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Retourneur_identique_optionneur_dictionnaire: "_ns, aError); + return true; + } + case 42: { // rondpoint:rondpoint_c6ef_Stringifier_new + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kRondpointStringifierPointerType>>; + CallHandler::CallSync(rondpoint_c6ef_Stringifier_new, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Stringifier_new: "_ns, aError); + return true; + } + case 43: { // rondpoint:rondpoint_c6ef_Stringifier_well_known_string + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_Stringifier_well_known_string, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Stringifier_well_known_string: "_ns, aError); + return true; + } + case 44: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_i8 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<int8_t>>; + CallHandler::CallSync(rondpoint_c6ef_Stringifier_to_string_i8, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Stringifier_to_string_i8: "_ns, aError); + return true; + } + case 45: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_u8 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<uint8_t>>; + CallHandler::CallSync(rondpoint_c6ef_Stringifier_to_string_u8, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Stringifier_to_string_u8: "_ns, aError); + return true; + } + case 46: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_i16 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<int16_t>>; + CallHandler::CallSync(rondpoint_c6ef_Stringifier_to_string_i16, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Stringifier_to_string_i16: "_ns, aError); + return true; + } + case 47: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_u16 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<uint16_t>>; + CallHandler::CallSync(rondpoint_c6ef_Stringifier_to_string_u16, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Stringifier_to_string_u16: "_ns, aError); + return true; + } + case 48: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_i32 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<int32_t>>; + CallHandler::CallSync(rondpoint_c6ef_Stringifier_to_string_i32, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Stringifier_to_string_i32: "_ns, aError); + return true; + } + case 49: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_u32 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<uint32_t>>; + CallHandler::CallSync(rondpoint_c6ef_Stringifier_to_string_u32, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Stringifier_to_string_u32: "_ns, aError); + return true; + } + case 50: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_i64 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<int64_t>>; + CallHandler::CallSync(rondpoint_c6ef_Stringifier_to_string_i64, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Stringifier_to_string_i64: "_ns, aError); + return true; + } + case 51: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_u64 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<uint64_t>>; + CallHandler::CallSync(rondpoint_c6ef_Stringifier_to_string_u64, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Stringifier_to_string_u64: "_ns, aError); + return true; + } + case 52: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_float + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<float>>; + CallHandler::CallSync(rondpoint_c6ef_Stringifier_to_string_float, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Stringifier_to_string_float: "_ns, aError); + return true; + } + case 53: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_double + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<double>>; + CallHandler::CallSync(rondpoint_c6ef_Stringifier_to_string_double, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Stringifier_to_string_double: "_ns, aError); + return true; + } + case 54: { // rondpoint:rondpoint_c6ef_Stringifier_to_string_boolean + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointStringifierPointerType>, ScaffoldingConverter<int8_t>>; + CallHandler::CallSync(rondpoint_c6ef_Stringifier_to_string_boolean, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Stringifier_to_string_boolean: "_ns, aError); + return true; + } + case 55: { // rondpoint:rondpoint_c6ef_Optionneur_new + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_new, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_new: "_ns, aError); + return true; + } + case 56: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_boolean + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int8_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_boolean, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_boolean: "_ns, aError); + return true; + } + case 57: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_string + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_string, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_string: "_ns, aError); + return true; + } + case 58: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_sequence + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_sequence, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_sequence: "_ns, aError); + return true; + } + case 59: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_null + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_null, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_null: "_ns, aError); + return true; + } + case 60: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_zero + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_zero, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_zero: "_ns, aError); + return true; + } + case 61: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u8_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint8_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint8_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_u8_dec, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_u8_dec: "_ns, aError); + return true; + } + case 62: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i8_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int8_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_i8_dec, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_i8_dec: "_ns, aError); + return true; + } + case 63: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u16_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint16_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint16_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_u16_dec, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_u16_dec: "_ns, aError); + return true; + } + case 64: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i16_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int16_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int16_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_i16_dec, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_i16_dec: "_ns, aError); + return true; + } + case 65: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u32_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint32_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint32_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_u32_dec, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_u32_dec: "_ns, aError); + return true; + } + case 66: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i32_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int32_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int32_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_i32_dec, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_i32_dec: "_ns, aError); + return true; + } + case 67: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u64_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint64_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint64_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_u64_dec, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_u64_dec: "_ns, aError); + return true; + } + case 68: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i64_dec + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int64_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int64_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_i64_dec, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_i64_dec: "_ns, aError); + return true; + } + case 69: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u8_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint8_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint8_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_u8_hex, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_u8_hex: "_ns, aError); + return true; + } + case 70: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i8_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int8_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_i8_hex, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_i8_hex: "_ns, aError); + return true; + } + case 71: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u16_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint16_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint16_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_u16_hex, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_u16_hex: "_ns, aError); + return true; + } + case 72: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i16_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int16_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int16_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_i16_hex, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_i16_hex: "_ns, aError); + return true; + } + case 73: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u32_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint32_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint32_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_u32_hex, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_u32_hex: "_ns, aError); + return true; + } + case 74: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i32_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int32_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int32_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_i32_hex, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_i32_hex: "_ns, aError); + return true; + } + case 75: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u64_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint64_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint64_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_u64_hex, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_u64_hex: "_ns, aError); + return true; + } + case 76: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_i64_hex + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int64_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<int64_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_i64_hex, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_i64_hex: "_ns, aError); + return true; + } + case 77: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_u32_oct + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<uint32_t>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<uint32_t>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_u32_oct, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_u32_oct: "_ns, aError); + return true; + } + case 78: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_f32 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<float>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<float>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_f32, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_f32: "_ns, aError); + return true; + } + case 79: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_f64 + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<double>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<double>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_f64, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_f64: "_ns, aError); + return true; + } + case 80: { // rondpoint:rondpoint_c6ef_Optionneur_sinon_enum + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kRondpointOptionneurPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_Optionneur_sinon_enum, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_Optionneur_sinon_enum: "_ns, aError); + return true; + } + case 81: { // rondpoint:rondpoint_c6ef_copie_dictionnaire + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_copie_dictionnaire, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_copie_dictionnaire: "_ns, aError); + return true; + } + case 82: { // rondpoint:rondpoint_c6ef_copie_enumeration + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_copie_enumeration, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_copie_enumeration: "_ns, aError); + return true; + } + case 83: { // rondpoint:rondpoint_c6ef_copie_enumerations + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_copie_enumerations, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_copie_enumerations: "_ns, aError); + return true; + } + case 84: { // rondpoint:rondpoint_c6ef_copie_carte + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(rondpoint_c6ef_copie_carte, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_copie_carte: "_ns, aError); + return true; + } + case 85: { // rondpoint:rondpoint_c6ef_switcheroo + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int8_t>, ScaffoldingConverter<int8_t>>; + CallHandler::CallSync(rondpoint_c6ef_switcheroo, aGlobal, aArgs, aReturnValue, "rondpoint_c6ef_switcheroo: "_ns, aError); + return true; + } + case 86: { // sprites:sprites_accb_Sprite_new + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kSpritesSpritePointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(sprites_accb_Sprite_new, aGlobal, aArgs, aReturnValue, "sprites_accb_Sprite_new: "_ns, aError); + return true; + } + case 87: { // sprites:sprites_accb_Sprite_new_relative_to + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kSpritesSpritePointerType>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(sprites_accb_Sprite_new_relative_to, aGlobal, aArgs, aReturnValue, "sprites_accb_Sprite_new_relative_to: "_ns, aError); + return true; + } + case 88: { // sprites:sprites_accb_Sprite_get_position + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kSpritesSpritePointerType>>; + CallHandler::CallSync(sprites_accb_Sprite_get_position, aGlobal, aArgs, aReturnValue, "sprites_accb_Sprite_get_position: "_ns, aError); + return true; + } + case 89: { // sprites:sprites_accb_Sprite_move_to + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kSpritesSpritePointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(sprites_accb_Sprite_move_to, aGlobal, aArgs, aReturnValue, "sprites_accb_Sprite_move_to: "_ns, aError); + return true; + } + case 90: { // sprites:sprites_accb_Sprite_move_by + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kSpritesSpritePointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(sprites_accb_Sprite_move_by, aGlobal, aArgs, aReturnValue, "sprites_accb_Sprite_move_by: "_ns, aError); + return true; + } + case 91: { // sprites:sprites_accb_translate + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(sprites_accb_translate, aGlobal, aArgs, aReturnValue, "sprites_accb_translate: "_ns, aError); + return true; + } + case 92: { // todolist:todolist_aa33_TodoList_new + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(todolist_aa33_TodoList_new, aGlobal, aArgs, aReturnValue, "todolist_aa33_TodoList_new: "_ns, aError); + return true; + } + case 93: { // todolist:todolist_aa33_TodoList_add_item + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(todolist_aa33_TodoList_add_item, aGlobal, aArgs, aReturnValue, "todolist_aa33_TodoList_add_item: "_ns, aError); + return true; + } + case 94: { // todolist:todolist_aa33_TodoList_add_entry + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(todolist_aa33_TodoList_add_entry, aGlobal, aArgs, aReturnValue, "todolist_aa33_TodoList_add_entry: "_ns, aError); + return true; + } + case 95: { // todolist:todolist_aa33_TodoList_get_entries + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(todolist_aa33_TodoList_get_entries, aGlobal, aArgs, aReturnValue, "todolist_aa33_TodoList_get_entries: "_ns, aError); + return true; + } + case 96: { // todolist:todolist_aa33_TodoList_get_items + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(todolist_aa33_TodoList_get_items, aGlobal, aArgs, aReturnValue, "todolist_aa33_TodoList_get_items: "_ns, aError); + return true; + } + case 97: { // todolist:todolist_aa33_TodoList_add_entries + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(todolist_aa33_TodoList_add_entries, aGlobal, aArgs, aReturnValue, "todolist_aa33_TodoList_add_entries: "_ns, aError); + return true; + } + case 98: { // todolist:todolist_aa33_TodoList_add_items + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(todolist_aa33_TodoList_add_items, aGlobal, aArgs, aReturnValue, "todolist_aa33_TodoList_add_items: "_ns, aError); + return true; + } + case 99: { // todolist:todolist_aa33_TodoList_get_last_entry + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(todolist_aa33_TodoList_get_last_entry, aGlobal, aArgs, aReturnValue, "todolist_aa33_TodoList_get_last_entry: "_ns, aError); + return true; + } + case 100: { // todolist:todolist_aa33_TodoList_get_last + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(todolist_aa33_TodoList_get_last, aGlobal, aArgs, aReturnValue, "todolist_aa33_TodoList_get_last: "_ns, aError); + return true; + } + case 101: { // todolist:todolist_aa33_TodoList_get_first + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(todolist_aa33_TodoList_get_first, aGlobal, aArgs, aReturnValue, "todolist_aa33_TodoList_get_first: "_ns, aError); + return true; + } + case 102: { // todolist:todolist_aa33_TodoList_clear_item + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(todolist_aa33_TodoList_clear_item, aGlobal, aArgs, aReturnValue, "todolist_aa33_TodoList_clear_item: "_ns, aError); + return true; + } + case 103: { // todolist:todolist_aa33_TodoList_make_default + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(todolist_aa33_TodoList_make_default, aGlobal, aArgs, aReturnValue, "todolist_aa33_TodoList_make_default: "_ns, aError); + return true; + } + case 104: { // todolist:todolist_aa33_get_default_list + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(todolist_aa33_get_default_list, aGlobal, aArgs, aReturnValue, "todolist_aa33_get_default_list: "_ns, aError); + return true; + } + case 105: { // todolist:todolist_aa33_set_default_list + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTodolistTodoListPointerType>>; + CallHandler::CallSync(todolist_aa33_set_default_list, aGlobal, aArgs, aReturnValue, "todolist_aa33_set_default_list: "_ns, aError); + return true; + } + case 106: { // todolist:todolist_aa33_create_entry_with + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(todolist_aa33_create_entry_with, aGlobal, aArgs, aReturnValue, "todolist_aa33_create_entry_with: "_ns, aError); + return true; + } + case 107: { // fixture_callbacks:fixture_callbacks_1107_log_even_numbers + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingConverter<uint64_t>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(fixture_callbacks_1107_log_even_numbers, aGlobal, aArgs, aReturnValue, "fixture_callbacks_1107_log_even_numbers: "_ns, aError); + return true; + } + case 108: { // fixture_callbacks:fixture_callbacks_1107_log_even_numbers_main_thread + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingConverter<uint64_t>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(fixture_callbacks_1107_log_even_numbers_main_thread, aGlobal, aArgs, aReturnValue, "fixture_callbacks_1107_log_even_numbers_main_thread: "_ns, aError); + return true; + } + case 109: { // custom_types:custom_types_8ecd_get_custom_types_demo + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(custom_types_8ecd_get_custom_types_demo, aGlobal, aArgs, aReturnValue, "custom_types_8ecd_get_custom_types_demo: "_ns, aError); + return true; + } + case 110: { // external_types:external_types_54cc_gradient + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<double>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(external_types_54cc_gradient, aGlobal, aArgs, aReturnValue, "external_types_54cc_gradient: "_ns, aError); + return true; + } + } + return false; +} + +Maybe<already_AddRefed<UniFFIPointer>> UniFFIFixturesReadPointer(const GlobalObject& aGlobal, uint64_t aId, const ArrayBuffer& aArrayBuff, long aPosition, ErrorResult& aError) { + const UniFFIPointerType* type; + switch (aId) { + case 2: { // rondpoint:Retourneur + type = &kRondpointRetourneurPointerType; + break; + } + case 3: { // rondpoint:Stringifier + type = &kRondpointStringifierPointerType; + break; + } + case 4: { // rondpoint:Optionneur + type = &kRondpointOptionneurPointerType; + break; + } + case 5: { // sprites:Sprite + type = &kSpritesSpritePointerType; + break; + } + case 6: { // 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 2: { // rondpoint:Retourneur + type = &kRondpointRetourneurPointerType; + break; + } + case 3: { // rondpoint:Stringifier + type = &kRondpointStringifierPointerType; + break; + } + case 4: { // rondpoint:Optionneur + type = &kRondpointOptionneurPointerType; + break; + } + case 5: { // sprites:Sprite + type = &kSpritesSpritePointerType; + break; + } + case 6: { // 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..d83136d792 --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp @@ -0,0 +1,299 @@ +// 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 ffi_tabs_edc9_TabsStore_object_free(void *, RustCallStatus*); + void * tabs_edc9_TabsStore_new(RustBuffer, RustCallStatus*); + RustBuffer tabs_edc9_TabsStore_get_all(void *, RustCallStatus*); + void tabs_edc9_TabsStore_set_local_tabs(void *, RustBuffer, RustCallStatus*); + void tabs_edc9_TabsStore_register_with_sync_manager(void *, RustCallStatus*); + void tabs_edc9_TabsStore_reset(void *, RustCallStatus*); + RustBuffer tabs_edc9_TabsStore_sync(void *, RustBuffer, RustBuffer, RustBuffer, RustBuffer, RustBuffer, RustCallStatus*); + void * tabs_edc9_TabsStore_bridged_engine(void *, RustCallStatus*); + void ffi_tabs_edc9_TabsBridgedEngine_object_free(void *, RustCallStatus*); + int64_t tabs_edc9_TabsBridgedEngine_last_sync(void *, RustCallStatus*); + void tabs_edc9_TabsBridgedEngine_set_last_sync(void *, int64_t, RustCallStatus*); + RustBuffer tabs_edc9_TabsBridgedEngine_sync_id(void *, RustCallStatus*); + RustBuffer tabs_edc9_TabsBridgedEngine_reset_sync_id(void *, RustCallStatus*); + RustBuffer tabs_edc9_TabsBridgedEngine_ensure_current_sync_id(void *, RustBuffer, RustCallStatus*); + void tabs_edc9_TabsBridgedEngine_prepare_for_sync(void *, RustBuffer, RustCallStatus*); + void tabs_edc9_TabsBridgedEngine_sync_started(void *, RustCallStatus*); + void tabs_edc9_TabsBridgedEngine_store_incoming(void *, RustBuffer, RustCallStatus*); + RustBuffer tabs_edc9_TabsBridgedEngine_apply(void *, RustCallStatus*); + void tabs_edc9_TabsBridgedEngine_set_uploaded(void *, int64_t, RustBuffer, RustCallStatus*); + void tabs_edc9_TabsBridgedEngine_sync_finished(void *, RustCallStatus*); + void tabs_edc9_TabsBridgedEngine_reset(void *, RustCallStatus*); + void tabs_edc9_TabsBridgedEngine_wipe(void *, RustCallStatus*); +} + +// Define pointer types +const static mozilla::uniffi::UniFFIPointerType kTabsTabsStorePointerType { + "tabs::TabsStore"_ns, + ffi_tabs_edc9_TabsStore_object_free +}; +const static mozilla::uniffi::UniFFIPointerType kTabsTabsBridgedEnginePointerType { + "tabs::TabsBridgedEngine"_ns, + ffi_tabs_edc9_TabsBridgedEngine_object_free +}; + +// Define the data we need per-callback interface + +// Define a lookup function for our callback interface info +Maybe<CallbackInterfaceInfo> UniFFIGetCallbackInterfaceInfo(uint64_t aInterfaceId) { + switch(aInterfaceId) { + + default: + return Nothing(); + } +} + +Maybe<already_AddRefed<Promise>> UniFFICallAsync(const GlobalObject& aGlobal, uint64_t aId, const Sequence<ScaffoldingType>& aArgs, ErrorResult& aError) { + switch (aId) { + case 0: { // tabs:tabs_edc9_TabsStore_new + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kTabsTabsStorePointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsStore_new, aGlobal, aArgs, "tabs_edc9_TabsStore_new: "_ns, aError)); + } + case 1: { // tabs:tabs_edc9_TabsStore_get_all + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsStore_get_all, aGlobal, aArgs, "tabs_edc9_TabsStore_get_all: "_ns, aError)); + } + case 2: { // tabs:tabs_edc9_TabsStore_set_local_tabs + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsStore_set_local_tabs, aGlobal, aArgs, "tabs_edc9_TabsStore_set_local_tabs: "_ns, aError)); + } + case 3: { // tabs:tabs_edc9_TabsStore_register_with_sync_manager + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsStore_register_with_sync_manager, aGlobal, aArgs, "tabs_edc9_TabsStore_register_with_sync_manager: "_ns, aError)); + } + case 4: { // tabs:tabs_edc9_TabsStore_reset + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsStore_reset, aGlobal, aArgs, "tabs_edc9_TabsStore_reset: "_ns, aError)); + } + case 5: { // tabs:tabs_edc9_TabsStore_sync + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsStore_sync, aGlobal, aArgs, "tabs_edc9_TabsStore_sync: "_ns, aError)); + } + case 6: { // tabs:tabs_edc9_TabsStore_bridged_engine + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsStore_bridged_engine, aGlobal, aArgs, "tabs_edc9_TabsStore_bridged_engine: "_ns, aError)); + } + case 7: { // tabs:tabs_edc9_TabsBridgedEngine_last_sync + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int64_t>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsBridgedEngine_last_sync, aGlobal, aArgs, "tabs_edc9_TabsBridgedEngine_last_sync: "_ns, aError)); + } + case 8: { // tabs:tabs_edc9_TabsBridgedEngine_set_last_sync + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter<int64_t>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsBridgedEngine_set_last_sync, aGlobal, aArgs, "tabs_edc9_TabsBridgedEngine_set_last_sync: "_ns, aError)); + } + case 9: { // tabs:tabs_edc9_TabsBridgedEngine_sync_id + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsBridgedEngine_sync_id, aGlobal, aArgs, "tabs_edc9_TabsBridgedEngine_sync_id: "_ns, aError)); + } + case 10: { // tabs:tabs_edc9_TabsBridgedEngine_reset_sync_id + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsBridgedEngine_reset_sync_id, aGlobal, aArgs, "tabs_edc9_TabsBridgedEngine_reset_sync_id: "_ns, aError)); + } + case 11: { // tabs:tabs_edc9_TabsBridgedEngine_ensure_current_sync_id + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsBridgedEngine_ensure_current_sync_id, aGlobal, aArgs, "tabs_edc9_TabsBridgedEngine_ensure_current_sync_id: "_ns, aError)); + } + case 12: { // tabs:tabs_edc9_TabsBridgedEngine_prepare_for_sync + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsBridgedEngine_prepare_for_sync, aGlobal, aArgs, "tabs_edc9_TabsBridgedEngine_prepare_for_sync: "_ns, aError)); + } + case 13: { // tabs:tabs_edc9_TabsBridgedEngine_sync_started + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsBridgedEngine_sync_started, aGlobal, aArgs, "tabs_edc9_TabsBridgedEngine_sync_started: "_ns, aError)); + } + case 14: { // tabs:tabs_edc9_TabsBridgedEngine_store_incoming + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsBridgedEngine_store_incoming, aGlobal, aArgs, "tabs_edc9_TabsBridgedEngine_store_incoming: "_ns, aError)); + } + case 15: { // tabs:tabs_edc9_TabsBridgedEngine_apply + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsBridgedEngine_apply, aGlobal, aArgs, "tabs_edc9_TabsBridgedEngine_apply: "_ns, aError)); + } + case 16: { // tabs:tabs_edc9_TabsBridgedEngine_set_uploaded + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter<int64_t>, ScaffoldingConverter<RustBuffer>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsBridgedEngine_set_uploaded, aGlobal, aArgs, "tabs_edc9_TabsBridgedEngine_set_uploaded: "_ns, aError)); + } + case 17: { // tabs:tabs_edc9_TabsBridgedEngine_sync_finished + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsBridgedEngine_sync_finished, aGlobal, aArgs, "tabs_edc9_TabsBridgedEngine_sync_finished: "_ns, aError)); + } + case 18: { // tabs:tabs_edc9_TabsBridgedEngine_reset + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsBridgedEngine_reset, aGlobal, aArgs, "tabs_edc9_TabsBridgedEngine_reset: "_ns, aError)); + } + case 19: { // tabs:tabs_edc9_TabsBridgedEngine_wipe + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + return Some(CallHandler::CallAsync(tabs_edc9_TabsBridgedEngine_wipe, aGlobal, aArgs, "tabs_edc9_TabsBridgedEngine_wipe: "_ns, aError)); + } + } + return Nothing(); +} + +bool UniFFICallSync(const GlobalObject& aGlobal, uint64_t aId, const Sequence<ScaffoldingType>& aArgs, RootedDictionary<UniFFIScaffoldingCallResult>& aReturnValue, ErrorResult& aError) { + switch (aId) { + case 0: { // tabs:tabs_edc9_TabsStore_new + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kTabsTabsStorePointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(tabs_edc9_TabsStore_new, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsStore_new: "_ns, aError); + return true; + } + case 1: { // tabs:tabs_edc9_TabsStore_get_all + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + CallHandler::CallSync(tabs_edc9_TabsStore_get_all, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsStore_get_all: "_ns, aError); + return true; + } + case 2: { // tabs:tabs_edc9_TabsStore_set_local_tabs + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(tabs_edc9_TabsStore_set_local_tabs, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsStore_set_local_tabs: "_ns, aError); + return true; + } + case 3: { // tabs:tabs_edc9_TabsStore_register_with_sync_manager + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + CallHandler::CallSync(tabs_edc9_TabsStore_register_with_sync_manager, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsStore_register_with_sync_manager: "_ns, aError); + return true; + } + case 4: { // tabs:tabs_edc9_TabsStore_reset + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + CallHandler::CallSync(tabs_edc9_TabsStore_reset, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsStore_reset: "_ns, aError); + return true; + } + case 5: { // tabs:tabs_edc9_TabsStore_sync + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(tabs_edc9_TabsStore_sync, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsStore_sync: "_ns, aError); + return true; + } + case 6: { // tabs:tabs_edc9_TabsStore_bridged_engine + using CallHandler = ScaffoldingCallHandler<ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingObjectConverter<&kTabsTabsStorePointerType>>; + CallHandler::CallSync(tabs_edc9_TabsStore_bridged_engine, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsStore_bridged_engine: "_ns, aError); + return true; + } + case 7: { // tabs:tabs_edc9_TabsBridgedEngine_last_sync + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<int64_t>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(tabs_edc9_TabsBridgedEngine_last_sync, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsBridgedEngine_last_sync: "_ns, aError); + return true; + } + case 8: { // tabs:tabs_edc9_TabsBridgedEngine_set_last_sync + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter<int64_t>>; + CallHandler::CallSync(tabs_edc9_TabsBridgedEngine_set_last_sync, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsBridgedEngine_set_last_sync: "_ns, aError); + return true; + } + case 9: { // tabs:tabs_edc9_TabsBridgedEngine_sync_id + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(tabs_edc9_TabsBridgedEngine_sync_id, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsBridgedEngine_sync_id: "_ns, aError); + return true; + } + case 10: { // tabs:tabs_edc9_TabsBridgedEngine_reset_sync_id + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(tabs_edc9_TabsBridgedEngine_reset_sync_id, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsBridgedEngine_reset_sync_id: "_ns, aError); + return true; + } + case 11: { // tabs:tabs_edc9_TabsBridgedEngine_ensure_current_sync_id + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(tabs_edc9_TabsBridgedEngine_ensure_current_sync_id, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsBridgedEngine_ensure_current_sync_id: "_ns, aError); + return true; + } + case 12: { // tabs:tabs_edc9_TabsBridgedEngine_prepare_for_sync + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(tabs_edc9_TabsBridgedEngine_prepare_for_sync, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsBridgedEngine_prepare_for_sync: "_ns, aError); + return true; + } + case 13: { // tabs:tabs_edc9_TabsBridgedEngine_sync_started + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(tabs_edc9_TabsBridgedEngine_sync_started, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsBridgedEngine_sync_started: "_ns, aError); + return true; + } + case 14: { // tabs:tabs_edc9_TabsBridgedEngine_store_incoming + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(tabs_edc9_TabsBridgedEngine_store_incoming, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsBridgedEngine_store_incoming: "_ns, aError); + return true; + } + case 15: { // tabs:tabs_edc9_TabsBridgedEngine_apply + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<RustBuffer>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(tabs_edc9_TabsBridgedEngine_apply, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsBridgedEngine_apply: "_ns, aError); + return true; + } + case 16: { // tabs:tabs_edc9_TabsBridgedEngine_set_uploaded + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>, ScaffoldingConverter<int64_t>, ScaffoldingConverter<RustBuffer>>; + CallHandler::CallSync(tabs_edc9_TabsBridgedEngine_set_uploaded, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsBridgedEngine_set_uploaded: "_ns, aError); + return true; + } + case 17: { // tabs:tabs_edc9_TabsBridgedEngine_sync_finished + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(tabs_edc9_TabsBridgedEngine_sync_finished, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsBridgedEngine_sync_finished: "_ns, aError); + return true; + } + case 18: { // tabs:tabs_edc9_TabsBridgedEngine_reset + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(tabs_edc9_TabsBridgedEngine_reset, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsBridgedEngine_reset: "_ns, aError); + return true; + } + case 19: { // tabs:tabs_edc9_TabsBridgedEngine_wipe + using CallHandler = ScaffoldingCallHandler<ScaffoldingConverter<void>, ScaffoldingObjectConverter<&kTabsTabsBridgedEnginePointerType>>; + CallHandler::CallSync(tabs_edc9_TabsBridgedEngine_wipe, aGlobal, aArgs, aReturnValue, "tabs_edc9_TabsBridgedEngine_wipe: "_ns, aError); + return true; + } + } + return false; +} + +Maybe<already_AddRefed<UniFFIPointer>> UniFFIReadPointer(const GlobalObject& aGlobal, uint64_t aId, const ArrayBuffer& aArrayBuff, long aPosition, ErrorResult& aError) { + const UniFFIPointerType* type; + switch (aId) { + case 0: { // tabs:TabsStore + type = &kTabsTabsStorePointerType; + break; + } + case 1: { // tabs:TabsBridgedEngine + type = &kTabsTabsBridgedEnginePointerType; + 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: { // tabs:TabsStore + type = &kTabsTabsStorePointerType; + break; + } + case 1: { // tabs:TabsBridgedEngine + type = &kTabsTabsBridgedEnginePointerType; + 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..9a204aac5d --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFIPointer.cpp @@ -0,0 +1,112 @@ +/* -*- 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> UniFFIPointer::Create( + void* aPtr, const UniFFIPointerType* aType) { + RefPtr<UniFFIPointer> uniFFIPointer = new UniFFIPointer(aPtr, aType); + return uniFFIPointer.forget(); +} + +already_AddRefed<UniFFIPointer> UniFFIPointer::Read( + const ArrayBuffer& aArrayBuff, uint32_t aPosition, + const UniFFIPointerType* aType, ErrorResult& aError) { + MOZ_LOG(sUniFFIPointerLogger, LogLevel::Info, + ("[UniFFI] Reading Pointer from buffer")); + aArrayBuff.ComputeState(); + + CheckedUint32 position = aPosition; + CheckedUint32 end = position + 8; + if (!end.isValid() || end.value() > aArrayBuff.Length()) { + 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 + uint8_t* data_ptr = aArrayBuff.Data() + + aPosition; // Pointer arithmetic, move by position bytes + 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.ComputeState(); + CheckedUint32 position = aPosition; + CheckedUint32 end = position + 8; + if (!end.isValid() || end.value() > aArrayBuff.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 + uint8_t* data_ptr = aArrayBuff.Data() + + aPosition; // Pointer arithmetic, move by position bytes + mozilla::BigEndian::writeUint64(data_ptr, (uint64_t)GetPtr()); +} + +UniFFIPointer::UniFFIPointer(void* aPtr, const UniFFIPointerType* aType) { + mPtr = aPtr; + mType = aType; +} + +JSObject* UniFFIPointer::WrapObject(JSContext* aCx, + JS::Handle<JSObject*> 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<UniFFIPointer> Create( + void* aPtr, const uniffi::UniFFIPointerType* aType); + static already_AddRefed<UniFFIPointer> 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<JSObject*> 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<T>` + * - 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..bdda442551 --- /dev/null +++ b/toolkit/components/uniffi-js/UniFFIRust.h @@ -0,0 +1,50 @@ +/* -*- 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 <stdint.h> + +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/src/ffi/foreigncallbacks.rs +// for details) +constexpr int8_t CALLBACK_INTERFACE_SUCCESS = 1; +constexpr int8_t CALLBACK_INTERFACE_INTERNAL_ERROR = -1; +constexpr int8_t CALLBACK_INTERFACE_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, + RustBuffer args, 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 <inttypes.h> +#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<already_AddRefed<Promise>> UniFFICallAsync( + const GlobalObject& aGlobal, uint64_t aId, + const Sequence<ScaffoldingType>& aArgs, ErrorResult& aError); +bool UniFFICallSync(const GlobalObject& aGlobal, uint64_t aId, + const Sequence<ScaffoldingType>& aArgs, + RootedDictionary<UniFFIScaffoldingCallResult>& aReturnValue, + ErrorResult& aError); +Maybe<already_AddRefed<UniFFIPointer>> 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<already_AddRefed<Promise>> UniFFIFixturesCallAsync( + const GlobalObject& aGlobal, uint64_t aId, + const Sequence<ScaffoldingType>& aArgs, ErrorResult& aError); +bool UniFFIFixturesCallSync( + const GlobalObject& aGlobal, uint64_t aId, + const Sequence<ScaffoldingType>& aArgs, + RootedDictionary<UniFFIScaffoldingCallResult>& aReturnValue, + ErrorResult& aError); +Maybe<already_AddRefed<UniFFIPointer>> 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<Promise> UniFFIScaffolding::CallAsync( + const GlobalObject& aGlobal, uint64_t aId, + const Sequence<ScaffoldingType>& aArgs, ErrorResult& aError) { + Maybe<already_AddRefed<Promise>> firstTry = + uniffi::UniFFICallAsync(aGlobal, aId, aArgs, aError); + if (firstTry.isSome()) { + return firstTry.extract(); + } +#ifdef MOZ_UNIFFI_FIXTURES + Maybe<already_AddRefed<Promise>> 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<ScaffoldingType>& aArgs, + RootedDictionary<UniFFIScaffoldingCallResult>& 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<UniFFIPointer> UniFFIScaffolding::ReadPointer( + const GlobalObject& aGlobal, uint64_t aId, const ArrayBuffer& aArrayBuff, + long aPosition, ErrorResult& aError) { + Maybe<already_AddRefed<UniFFIPointer>> firstTry = + uniffi::UniFFIReadPointer(aGlobal, aId, aArrayBuff, aPosition, aError); + if (firstTry.isSome()) { + return firstTry.extract(); + } +#ifdef MOZ_UNIFFI_FIXTURES + Maybe<already_AddRefed<UniFFIPointer>> 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<Promise> CallAsync( + const GlobalObject& aGlobal, uint64_t aId, + const Sequence<ScaffoldingType>& aArgs, ErrorResult& aErrorResult); + + static void CallSync( + const GlobalObject& aGlobal, uint64_t aId, + const Sequence<ScaffoldingType>& aArgs, + RootedDictionary<UniFFIScaffoldingCallResult>& aReturnValue, + ErrorResult& aErrorResult); + + static already_AddRefed<UniFFIPointer> 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/moz.build b/toolkit/components/uniffi-js/moz.build new file mode 100644 index 0000000000..7a4b7e620b --- /dev/null +++ b/toolkit/components/uniffi-js/moz.build @@ -0,0 +1,32 @@ +# -*- 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", +] |