Bug 1950665 - Upgrade to UniFFI 0.29,
Differential Revision: https://phabricator.services.mozilla.com/D239796
This commit is contained in:
25
Cargo.toml
25
Cargo.toml
@@ -61,8 +61,8 @@ rust-version = "1.82.0"
|
|||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
# Shared across multiple UniFFI consumers.
|
# Shared across multiple UniFFI consumers.
|
||||||
uniffi = "0.28.2"
|
uniffi = "0.29.0"
|
||||||
uniffi_bindgen = "0.28.2"
|
uniffi_bindgen = "0.29.0"
|
||||||
# Shared across multiple application-services consumers.
|
# Shared across multiple application-services consumers.
|
||||||
rusqlite = "0.31.0"
|
rusqlite = "0.31.0"
|
||||||
# Shared across multiple glean consumers.
|
# Shared across multiple glean consumers.
|
||||||
@@ -176,6 +176,9 @@ goblin = { path = "build/rust/goblin" }
|
|||||||
# Implement getrandom 0.2 in terms of 0.3
|
# Implement getrandom 0.2 in terms of 0.3
|
||||||
getrandom = { path = "build/rust/getrandom" }
|
getrandom = { path = "build/rust/getrandom" }
|
||||||
|
|
||||||
|
# Patch rustc-hash 1.1.0 to 2.1.1
|
||||||
|
rustc-hash = { path = "build/rust/rustc-hash" }
|
||||||
|
|
||||||
# Patch memoffset from 0.8.0 to 0.9.0 since it's compatible and it avoids duplication
|
# Patch memoffset from 0.8.0 to 0.9.0 since it's compatible and it avoids duplication
|
||||||
memoffset = { path = "build/rust/memoffset" }
|
memoffset = { path = "build/rust/memoffset" }
|
||||||
|
|
||||||
@@ -241,14 +244,14 @@ malloc_size_of_derive = { path = "xpcom/rust/malloc_size_of_derive" }
|
|||||||
objc = { git = "https://github.com/glandium/rust-objc", rev = "4de89f5aa9851ceca4d40e7ac1e2759410c04324" }
|
objc = { git = "https://github.com/glandium/rust-objc", rev = "4de89f5aa9851ceca4d40e7ac1e2759410c04324" }
|
||||||
|
|
||||||
# application-services overrides to make updating them all simpler.
|
# application-services overrides to make updating them all simpler.
|
||||||
interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "d773da92641d92930b7308300e9fc2746a05ce6a" }
|
interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "50c3f77fa264974678ec59e752fe7dc39c29900b" }
|
||||||
relevancy = { git = "https://github.com/mozilla/application-services", rev = "d773da92641d92930b7308300e9fc2746a05ce6a" }
|
relevancy = { git = "https://github.com/mozilla/application-services", rev = "50c3f77fa264974678ec59e752fe7dc39c29900b" }
|
||||||
search = { git = "https://github.com/mozilla/application-services", rev = "d773da92641d92930b7308300e9fc2746a05ce6a" }
|
search = { git = "https://github.com/mozilla/application-services", rev = "50c3f77fa264974678ec59e752fe7dc39c29900b" }
|
||||||
sql-support = { git = "https://github.com/mozilla/application-services", rev = "d773da92641d92930b7308300e9fc2746a05ce6a" }
|
sql-support = { git = "https://github.com/mozilla/application-services", rev = "50c3f77fa264974678ec59e752fe7dc39c29900b" }
|
||||||
suggest = { git = "https://github.com/mozilla/application-services", rev = "d773da92641d92930b7308300e9fc2746a05ce6a" }
|
suggest = { git = "https://github.com/mozilla/application-services", rev = "50c3f77fa264974678ec59e752fe7dc39c29900b" }
|
||||||
sync15 = { git = "https://github.com/mozilla/application-services", rev = "d773da92641d92930b7308300e9fc2746a05ce6a" }
|
sync15 = { git = "https://github.com/mozilla/application-services", rev = "50c3f77fa264974678ec59e752fe7dc39c29900b" }
|
||||||
tabs = { git = "https://github.com/mozilla/application-services", rev = "d773da92641d92930b7308300e9fc2746a05ce6a" }
|
tabs = { git = "https://github.com/mozilla/application-services", rev = "50c3f77fa264974678ec59e752fe7dc39c29900b" }
|
||||||
viaduct = { git = "https://github.com/mozilla/application-services", rev = "d773da92641d92930b7308300e9fc2746a05ce6a" }
|
viaduct = { git = "https://github.com/mozilla/application-services", rev = "50c3f77fa264974678ec59e752fe7dc39c29900b" }
|
||||||
webext-storage = { git = "https://github.com/mozilla/application-services", rev = "d773da92641d92930b7308300e9fc2746a05ce6a" }
|
webext-storage = { git = "https://github.com/mozilla/application-services", rev = "50c3f77fa264974678ec59e752fe7dc39c29900b" }
|
||||||
|
|
||||||
allocator-api2 = { path = "third_party/rust/allocator-api2" }
|
allocator-api2 = { path = "third_party/rust/allocator-api2" }
|
||||||
|
|||||||
17
build/rust/rustc-hash/Cargo.toml
Normal file
17
build/rust/rustc-hash/Cargo.toml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
[package]
|
||||||
|
name = "rustc-hash"
|
||||||
|
version = "1.999.999"
|
||||||
|
edition = "2018"
|
||||||
|
license = "Apache-2.0 OR MIT"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "lib.rs"
|
||||||
|
|
||||||
|
[dependencies.rustc-hash]
|
||||||
|
version = "2.1.1"
|
||||||
|
default-features = false
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["rustc-hash/default"]
|
||||||
|
std = ["rustc-hash/std"]
|
||||||
|
rand = ["rustc-hash/rand"]
|
||||||
11
build/rust/rustc-hash/lib.rs
Normal file
11
build/rust/rustc-hash/lib.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
pub use rustc_hash::*;
|
||||||
@@ -10,7 +10,7 @@ path = "src/main.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
askama = { version = "0.12", default-features = false, features = ["config"] }
|
rinja = { version = "0.3.4", default-features = false, features = ["config"] }
|
||||||
clap = { version = "4", default-features = false, features = ["std", "derive", "cargo"] }
|
clap = { version = "4", default-features = false, features = ["std", "derive", "cargo"] }
|
||||||
cargo_metadata = "0.15"
|
cargo_metadata = "0.15"
|
||||||
extend = "1.1"
|
extend = "1.1"
|
||||||
|
|||||||
@@ -8,33 +8,17 @@ use url::Url;
|
|||||||
pub struct Handle(pub i64);
|
pub struct Handle(pub i64);
|
||||||
|
|
||||||
// We must implement the UniffiCustomTypeConverter trait for each custom type on the scaffolding side
|
// We must implement the UniffiCustomTypeConverter trait for each custom type on the scaffolding side
|
||||||
impl UniffiCustomTypeConverter for Handle {
|
uniffi::custom_type!(Handle, i64, {
|
||||||
// The `Builtin` type will be used to marshall values across the FFI
|
try_lift: |val| Ok(Handle(val)),
|
||||||
type Builtin = i64;
|
lower: |obj| obj.0,
|
||||||
|
});
|
||||||
// Convert Builtin to our custom type
|
|
||||||
fn into_custom(val: Self::Builtin) -> uniffi::Result<Self> {
|
|
||||||
Ok(Handle(val))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert our custom type to Builtin
|
|
||||||
fn from_custom(obj: Self) -> Self::Builtin {
|
|
||||||
obj.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use `url::Url` as a custom type, with `String` as the Builtin
|
// Use `url::Url` as a custom type, with `String` as the Builtin
|
||||||
impl UniffiCustomTypeConverter for Url {
|
uniffi::custom_type!(Url, String, {
|
||||||
type Builtin = String;
|
remote,
|
||||||
|
try_lift: |val| Ok(Url::parse(&val)?),
|
||||||
fn into_custom(val: Self::Builtin) -> uniffi::Result<Self> {
|
lower: |obj| obj.to_string(),
|
||||||
Ok(Url::parse(&val)?)
|
});
|
||||||
}
|
|
||||||
|
|
||||||
fn from_custom(obj: Self) -> Self::Builtin {
|
|
||||||
obj.to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// And a little struct and function that ties them together.
|
// And a little struct and function that ties them together.
|
||||||
pub struct CustomTypesDemo {
|
pub struct CustomTypesDemo {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use askama::Template;
|
|
||||||
use camino::Utf8Path;
|
use camino::Utf8Path;
|
||||||
|
use rinja::Template;
|
||||||
use uniffi_bindgen::ComponentInterface;
|
use uniffi_bindgen::ComponentInterface;
|
||||||
|
|
||||||
use crate::{render::js::*, Component, Result};
|
use crate::{render::js::*, Component, Result};
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use askama::Template;
|
|
||||||
use camino::{Utf8Path, Utf8PathBuf};
|
use camino::{Utf8Path, Utf8PathBuf};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use rinja::Template;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ License, v. 2.0. If a copy of the MPL was not distributed with this
|
|||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use askama::Template;
|
|
||||||
use heck::{ToSnakeCase, ToUpperCamelCase};
|
use heck::{ToSnakeCase, ToUpperCamelCase};
|
||||||
|
use rinja::Template;
|
||||||
use uniffi_bindgen::interface::{
|
use uniffi_bindgen::interface::{
|
||||||
AsType, Callable, CallbackInterface, ComponentInterface, FfiDefinition, FfiFunction, FfiType,
|
AsType, Callable, CallbackInterface, ComponentInterface, FfiDefinition, FfiFunction, FfiType,
|
||||||
};
|
};
|
||||||
@@ -416,8 +416,10 @@ fn scaffolding_converter(ci: &ComponentInterface, ffi_type: &FfiType) -> String
|
|||||||
match ffi_type {
|
match ffi_type {
|
||||||
FfiType::RustArcPtr(name) => {
|
FfiType::RustArcPtr(name) => {
|
||||||
// Check if this is an external type
|
// Check if this is an external type
|
||||||
for (extern_name, crate_name, _, _) in ci.iter_external_types() {
|
for ty in ci.iter_external_types() {
|
||||||
if extern_name == name {
|
let external_ty_name = ty.name().expect("External type without name");
|
||||||
|
let crate_name = ty.module_path().expect("External type without module path");
|
||||||
|
if external_ty_name == name {
|
||||||
return format!(
|
return format!(
|
||||||
"ScaffoldingObjectConverter<&{}>",
|
"ScaffoldingObjectConverter<&{}>",
|
||||||
pointer_type(crate_name_to_namespace(&crate_name), name),
|
pointer_type(crate_name_to_namespace(&crate_name), name),
|
||||||
@@ -461,7 +463,9 @@ fn cpp_type(ffi_type: &FfiType) -> String {
|
|||||||
FfiType::RustCallStatus => "RustCallStatus".to_owned(),
|
FfiType::RustCallStatus => "RustCallStatus".to_owned(),
|
||||||
FfiType::Callback(name) | FfiType::Struct(name) => name.to_owned(),
|
FfiType::Callback(name) | FfiType::Struct(name) => name.to_owned(),
|
||||||
FfiType::VoidPointer => "void*".to_owned(),
|
FfiType::VoidPointer => "void*".to_owned(),
|
||||||
FfiType::Reference(inner) => format!("{}*", cpp_type(inner.as_ref())),
|
FfiType::MutReference(inner) | FfiType::Reference(inner) => {
|
||||||
|
format!("{}*", cpp_type(inner.as_ref()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ License, v. 2.0. If a copy of the MPL was not distributed with this
|
|||||||
|
|
||||||
use super::shared::*;
|
use super::shared::*;
|
||||||
use crate::{CallbackIds, Config, FunctionIds, ObjectIds};
|
use crate::{CallbackIds, Config, FunctionIds, ObjectIds};
|
||||||
use askama::Template;
|
|
||||||
use extend::ext;
|
use extend::ext;
|
||||||
use heck::{ToLowerCamelCase, ToShoutySnakeCase, ToUpperCamelCase};
|
use heck::{ToLowerCamelCase, ToShoutySnakeCase, ToUpperCamelCase};
|
||||||
|
use rinja::Template;
|
||||||
use uniffi_bindgen::interface::{
|
use uniffi_bindgen::interface::{
|
||||||
Argument, AsType, Callable, CallbackInterface, ComponentInterface, Constructor, Enum, Field,
|
Argument, AsType, Callable, CallbackInterface, ComponentInterface, Constructor, Enum, Field,
|
||||||
Function, Literal, Method, Object, Radix, Record, Type, Variant,
|
Function, Literal, Method, Object, Radix, Record, Type, Variant,
|
||||||
@@ -261,7 +261,6 @@ pub impl Type {
|
|||||||
| Type::Enum { name, .. }
|
| Type::Enum { name, .. }
|
||||||
| Type::Record { name, .. }
|
| Type::Record { name, .. }
|
||||||
| Type::CallbackInterface { name, .. }
|
| Type::CallbackInterface { name, .. }
|
||||||
| Type::External { name, .. }
|
|
||||||
| Type::Custom { name, .. } => name.to_upper_camel_case(),
|
| Type::Custom { name, .. } => name.to_upper_camel_case(),
|
||||||
Type::Optional { inner_type } => format!("?{}", inner_type.type_name()),
|
Type::Optional { inner_type } => format!("?{}", inner_type.type_name()),
|
||||||
Type::Sequence { inner_type } => format!("Array.<{}>", inner_type.type_name()),
|
Type::Sequence { inner_type } => format!("Array.<{}>", inner_type.type_name()),
|
||||||
@@ -302,7 +301,7 @@ pub impl Type {
|
|||||||
key_type.canonical_name().to_upper_camel_case(),
|
key_type.canonical_name().to_upper_camel_case(),
|
||||||
value_type.canonical_name().to_upper_camel_case()
|
value_type.canonical_name().to_upper_camel_case()
|
||||||
),
|
),
|
||||||
Type::External { name, .. } | Type::Custom { name, .. } => format!("Type{name}"),
|
Type::Custom { name, .. } => format!("Type{name}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export class {{ record.js_name() }} {
|
|||||||
equals(other) {
|
equals(other) {
|
||||||
return (
|
return (
|
||||||
{%- for field in record.fields() %}
|
{%- for field in record.fields() %}
|
||||||
{{ field.as_type().equals("this.{}"|format(field.js_name()), "other.{}"|format(field.js_name())) }}{% if !loop.last %} &&{% endif %}
|
{{ field.as_type().equals(&("this.{}"|format(field.js_name())), &("other.{}"|format(field.js_name()))) }}{% if !loop.last %} &&{% endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%- for type_ in ci.iter_types() %}
|
|
||||||
|
{%- for type_ in ci.iter_local_types() %}
|
||||||
{%- let ffi_converter = type_.ffi_converter() %}
|
{%- let ffi_converter = type_.ffi_converter() %}
|
||||||
{%- match type_ %}
|
{%- match type_ %}
|
||||||
|
|
||||||
@@ -75,9 +76,6 @@
|
|||||||
{%- when Type::Custom { name, builtin, module_path } %}
|
{%- when Type::Custom { name, builtin, module_path } %}
|
||||||
{%- include "CustomType.sys.mjs" %}
|
{%- include "CustomType.sys.mjs" %}
|
||||||
|
|
||||||
{%- when Type::External { name, module_path, kind, namespace, tagged } %}
|
|
||||||
{%- include "ExternalType.sys.mjs" %}
|
|
||||||
|
|
||||||
{%- when Type::CallbackInterface { name, module_path } %}
|
{%- when Type::CallbackInterface { name, module_path } %}
|
||||||
{%- include "CallbackInterface.sys.mjs" %}
|
{%- include "CallbackInterface.sys.mjs" %}
|
||||||
|
|
||||||
@@ -88,6 +86,14 @@
|
|||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{%- for type_ in ci.iter_external_types() %}
|
||||||
|
{%- let ffi_converter = type_.ffi_converter() %}
|
||||||
|
{%- let name = type_.name().expect("External type without name") %}
|
||||||
|
{%- let module_path = type_.module_path().expect("External type without module path") %}
|
||||||
|
{%- include "ExternalType.sys.mjs" %}
|
||||||
|
{%- endfor %}
|
||||||
|
|
||||||
|
|
||||||
{%- if !ci.callback_interface_definitions().is_empty() %}
|
{%- if !ci.callback_interface_definitions().is_empty() %}
|
||||||
// Define callback interface handlers, this must come after the type loop since they reference the FfiConverters defined above.
|
// Define callback interface handlers, this must come after the type loop since they reference the FfiConverters defined above.
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ test-manifest-toml:
|
|||||||
- 'testing/mozbase/manifestparser/tests/'
|
- 'testing/mozbase/manifestparser/tests/'
|
||||||
- 'testing/raptor/raptor/tests/'
|
- 'testing/raptor/raptor/tests/'
|
||||||
- 'third_party/rust/'
|
- 'third_party/rust/'
|
||||||
|
- 'toolkit/components/uniffi-bindgen-gecko-js/rinja.toml'
|
||||||
- '**/.*ruff.toml'
|
- '**/.*ruff.toml'
|
||||||
- '**/Cargo.toml'
|
- '**/Cargo.toml'
|
||||||
- '**/Cross.toml'
|
- '**/Cross.toml'
|
||||||
|
|||||||
Reference in New Issue
Block a user