Bug 1766045 - Fixes to make the hybrid builds work r=markh,teshaq

This is a repsonse to the build errors I noticed with
build-macosx64-hybrid/plain, build-win64-hybrid/plain, and
build-linux64-hybrid/plain.

I'm not exactly sure why those build had errors but others didn't, but
my guess is that it was a combination of:
  - A clang++ producing different warnings/errors.
  - The uniffied builds being arranged slightly differently, which
    surfaced errors based on missing include statements.

Differential Revision: https://phabricator.services.mozilla.com/D153414
This commit is contained in:
Ben Dean-Kawamura 2022-08-03 18:59:38 +00:00
Родитель f4102dd546
Коммит d7f0b286fe
7 изменённых файлов: 30 добавлений и 22 удалений

Просмотреть файл

@ -25,6 +25,12 @@ pub struct CPPScaffoldingTemplate<'a> {
pub object_ids: &'a ObjectIds<'a>,
}
impl<'a> CPPScaffoldingTemplate<'a> {
fn has_any_objects(&self) -> bool {
self.ci_list.iter().any(|ci| ci.object_definitions().len() > 0)
}
}
// Define extension traits with methods used in our template code
#[ext(name=ComponentInterfaceCppExt)]

Просмотреть файл

@ -68,6 +68,7 @@ bool {{ prefix }}CallSync(const GlobalObject& aGlobal, uint64_t aId, const Seque
}
Maybe<already_AddRefed<UniFFIPointer>> {{ prefix }}ReadPointer(const GlobalObject& aGlobal, uint64_t aId, const ArrayBuffer& aArrayBuff, long aPosition, ErrorResult& aError) {
{%- if self.has_any_objects() %}
const UniFFIPointerType* type;
switch (aId) {
{%- for ci in ci_list %}
@ -82,9 +83,13 @@ Maybe<already_AddRefed<UniFFIPointer>> {{ prefix }}ReadPointer(const GlobalObjec
return Nothing();
}
return Some(UniFFIPointer::Read(aArrayBuff, aPosition, type, aError));
{%- else %}
return Nothing();
{%- endif %}
}
bool {{ prefix }}WritePointer(const GlobalObject& aGlobal, uint64_t aId, const UniFFIPointer& aPtr, const ArrayBuffer& aArrayBuff, long aPosition, ErrorResult& aError) {
{%- if self.has_any_objects() %}
const UniFFIPointerType* type;
switch (aId) {
{%- for ci in ci_list %}
@ -100,6 +105,9 @@ bool {{ prefix }}WritePointer(const GlobalObject& aGlobal, uint64_t aId, const U
}
aPtr.Write(aArrayBuff, aPosition, type, aError);
return true;
{%- else %}
return false;
{%- endif %}
}
} // namespace mozilla::uniffi

Просмотреть файл

@ -134,8 +134,8 @@ class ScaffoldingCallHandler {
using RustArgs = std::tuple<typename ArgConverters::RustType...>;
using IntermediateArgs =
std::tuple<typename ArgConverters::IntermediateType...>;
using RustCallResult = RustCallResult<typename ReturnConverter::RustType>;
using TaskPromiseType = MozPromise<RustCallResult, nsresult, true>;
using CallResult = RustCallResult<typename ReturnConverter::RustType>;
using TaskPromiseType = MozPromise<CallResult, nsresult, true>;
template <size_t I>
using NthArgConverter =
@ -180,8 +180,8 @@ class ScaffoldingCallHandler {
// Call the scaffolding function
//
// For async calls this should be called in the worker thread
static RustCallResult CallScaffoldingFunc(ScaffoldingFunc aFunc,
IntermediateArgs&& aArgs) {
static CallResult CallScaffoldingFunc(ScaffoldingFunc aFunc,
IntermediateArgs&& aArgs) {
return CallScaffoldingFuncHelper(
aFunc, std::move(aArgs), std::index_sequence_for<ArgConverters...>());
}
@ -189,10 +189,10 @@ class ScaffoldingCallHandler {
// Helper function for CallScaffoldingFunc that uses c++ magic to help with
// iteration
template <size_t... Is>
static RustCallResult CallScaffoldingFuncHelper(
ScaffoldingFunc aFunc, IntermediateArgs&& aArgs,
std::index_sequence<Is...> seq) {
RustCallResult result;
static CallResult CallScaffoldingFuncHelper(ScaffoldingFunc aFunc,
IntermediateArgs&& aArgs,
std::index_sequence<Is...> seq) {
CallResult result;
auto makeCall = [&]() mutable {
return aFunc(
@ -211,7 +211,7 @@ class ScaffoldingCallHandler {
//
// This should be called on the main thread
static void ReturnResult(
JSContext* aContext, RustCallResult& aCallResult,
JSContext* aContext, CallResult& aCallResult,
dom::RootedDictionary<dom::UniFFIScaffoldingCallResult>& aReturnValue,
const nsLiteralCString& aFuncName) {
switch (aCallResult.mCallStatus.code) {

Просмотреть файл

@ -36,22 +36,11 @@ bool UniFFICallSync(const GlobalObject& aGlobal, uint64_t aId, const Sequence<Sc
}
Maybe<already_AddRefed<UniFFIPointer>> UniFFIReadPointer(const GlobalObject& aGlobal, uint64_t aId, const ArrayBuffer& aArrayBuff, long aPosition, ErrorResult& aError) {
const UniFFIPointerType* type;
switch (aId) {
default:
return Nothing();
}
return Some(UniFFIPointer::Read(aArrayBuff, aPosition, type, aError));
return Nothing();
}
bool UniFFIWritePointer(const GlobalObject& aGlobal, uint64_t aId, const UniFFIPointer& aPtr, const ArrayBuffer& aArrayBuff, long aPosition, ErrorResult& aError) {
const UniFFIPointerType* type;
switch (aId) {
default:
return false;
}
aPtr.Write(aArrayBuff, aPosition, type, aError);
return true;
return false;
}
} // namespace mozilla::uniffi

Просмотреть файл

@ -10,6 +10,8 @@
#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 {

Просмотреть файл

@ -16,6 +16,7 @@
// 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;

Просмотреть файл

@ -7,7 +7,9 @@
#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 {