mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-07-07 15:55:00 +00:00
Update wasm-bindgen, syn and wgpu (#1398)
This commit is contained in:
parent
09a509c8b5
commit
b881385e3b
26 changed files with 511 additions and 435 deletions
775
Cargo.lock
generated
775
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -36,6 +36,8 @@ specta = { git = "https://github.com/0HyperCube/specta.git", rev = "c47a22b4c086
|
|||
"glam",
|
||||
] }
|
||||
rustc-hash = "1.1.0"
|
||||
# wasm-bindgen upgrades may break various things so we pin the version
|
||||
wasm-bindgen = "=0.2.87"
|
||||
|
||||
[profile.dev.package.graphite-editor]
|
||||
opt-level = 1
|
||||
|
@ -57,9 +59,6 @@ opt-level = 3
|
|||
[profile.dev.package.image]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev.package.xxhash-rust]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 1
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ deny = [
|
|||
# Certain crates/versions that will be skipped when doing duplicate detection.
|
||||
skip = [
|
||||
#{ name = "ansi_term", version = "=0.11.0" },
|
||||
{ name = "cfg-if", version = "=0.1.10" },
|
||||
#{ name = "cfg-if", version = "=0.1.10" },
|
||||
]
|
||||
# Similarly to `skip` allows you to skip certain crates during duplicate
|
||||
# detection. Unlike skip, it also includes the entire tree of transitive
|
||||
|
|
|
@ -30,7 +30,7 @@ bezier-rs = { path = "../libraries/bezier-rs" }
|
|||
glam = { version = "0.24", features = ["serde"] }
|
||||
remain = "0.2.2"
|
||||
derivative = "2.2.0"
|
||||
once_cell = "1.13.0" # Remove when `core::cell::OnceCell` is stabilized (<https://doc.rust-lang.org/core/cell/struct.OnceCell.html>)
|
||||
once_cell = "1.13.0" # Remove when `core::cell::LazyCell` is stabilized (<https://doc.rust-lang.org/core/cell/struct.LazyCell.html>)
|
||||
specta.workspace = true
|
||||
|
||||
# Node graph
|
||||
|
@ -48,13 +48,13 @@ graphene-std = { path = "../node-graph/gstd" }
|
|||
future-executor = { path = "../node-graph/future-executor", optional = true }
|
||||
num_enum = "0.6.1"
|
||||
|
||||
wasm-bindgen = { version = "0.2.86", optional = true }
|
||||
wasm-bindgen = { workspace = true, optional = true }
|
||||
|
||||
[dependencies.document-legacy]
|
||||
path = "../document-legacy"
|
||||
package = "graphite-document-legacy"
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.8.4"
|
||||
test-case = "2.1"
|
||||
env_logger = "0.10"
|
||||
test-case = "3.1"
|
||||
futures = "0.3.28"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::messages::portfolio::utility_types::Platform;
|
||||
|
||||
use once_cell::sync::OnceCell;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
pub static GLOBAL_PLATFORM: OnceCell<Platform> = OnceCell::new();
|
||||
pub static GLOBAL_PLATFORM: OnceLock<Platform> = OnceLock::new();
|
||||
|
|
|
@ -21,10 +21,10 @@ tauri = { version = "1.2", features = ["api-all", "devtools", "linux-protocol-he
|
|||
axum = "0.6.1"
|
||||
graphite-editor = { version = "0.0.0", path = "../../editor" }
|
||||
chrono = "^0.4.23"
|
||||
tokio = {version ="1", features = ["full"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
ron = "0.8"
|
||||
log = "0.4"
|
||||
fern = {version = "0.6", features = ["colored"] }
|
||||
fern = { version = "0.6", features = ["colored"] }
|
||||
futures = "0.3.25"
|
||||
|
||||
[features]
|
||||
|
|
|
@ -29,12 +29,14 @@ graphene-core = { path = "../../node-graph/gcore", features = [
|
|||
"alloc",
|
||||
] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
wasm-bindgen = { version = "=0.2.86" }
|
||||
wasm-bindgen = { workspace = true }
|
||||
serde-wasm-bindgen = "0.5.0"
|
||||
js-sys = "0.3.63"
|
||||
wasm-bindgen-futures = "0.4.36"
|
||||
ron = { version = "0.8", optional = true }
|
||||
bezier-rs = { path = "../../libraries/bezier-rs" }
|
||||
# We don't have wgpu on multiple threads (yet) https://github.com/gfx-rs/wgpu/blob/trunk/CHANGELOG.md#wgpu-types-now-send-sync-on-wasm
|
||||
wgpu = { version = "0.17", features = ["fragile-send-sync-non-atomic-wasm"] }
|
||||
|
||||
[dependencies.web-sys]
|
||||
version = "0.3.4"
|
||||
|
|
|
@ -16,7 +16,7 @@ serde = ["dep:serde", "glam/serde", "bezier-rs/serde", "bezier-rs/serde", "base6
|
|||
gpu = ["spirv-std", "glam/bytemuck", "dyn-any", "glam/libm"]
|
||||
async = ["async-trait", "alloc"]
|
||||
nightly = []
|
||||
alloc = ["dyn-any", "bezier-rs", "once_cell"]
|
||||
alloc = ["dyn-any", "bezier-rs"]
|
||||
type_id_logging = []
|
||||
wasm = ["web-sys"]
|
||||
|
||||
|
@ -26,7 +26,7 @@ dyn-any = { path = "../../libraries/dyn-any", features = [
|
|||
"glam",
|
||||
], optional = true, default-features = false }
|
||||
|
||||
spirv-std = { version = "0.8", optional = true }
|
||||
spirv-std = { version = "0.9", optional = true }
|
||||
bytemuck = { version = "1.8", features = ["derive"] }
|
||||
async-trait = { version = "0.1", optional = true }
|
||||
serde = { version = "1.0", features = [
|
||||
|
@ -47,17 +47,16 @@ node-macro = { path = "../node-macro" }
|
|||
base64 = { version = "0.21", optional = true }
|
||||
specta.workspace = true
|
||||
specta.optional = true
|
||||
once_cell = { version = "1.17.0", default-features = false, optional = true }
|
||||
|
||||
rustybuzz = { version = "0.8.0", optional = true }
|
||||
|
||||
num-derive = { version = "0.3.3" }
|
||||
num-derive = { version = "0.4" }
|
||||
num-traits = { version = "0.2.15", default-features = false, features = [
|
||||
"i128",
|
||||
] }
|
||||
|
||||
|
||||
wasm-bindgen = { version = "0.2.84", optional = true }
|
||||
wasm-bindgen = { workspace = true, optional = true }
|
||||
js-sys = { version = "0.3.55", optional = true }
|
||||
|
||||
[dependencies.web-sys]
|
||||
|
|
|
@ -76,7 +76,7 @@ where
|
|||
type Output = T;
|
||||
fn eval(&'input self, index: I) -> Self::Output {
|
||||
let storage = self.storage.eval(());
|
||||
storage.deref().index(index).deref().clone()
|
||||
storage.deref().index(index).clone()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ base64 = "0.21"
|
|||
bytemuck = { version = "1.8" }
|
||||
nvtx = { version = "1.1.1", optional = true }
|
||||
tempfile = "3"
|
||||
spirv-builder = { version = "0.7", default-features = false, features = [
|
||||
spirv-builder = { version = "0.9", default-features = false, features = [
|
||||
"use-installed-tools",
|
||||
] }
|
||||
tera = { version = "1.17.1" }
|
||||
|
|
|
@ -23,6 +23,6 @@ base64 = "0.21"
|
|||
bezier-rs = { path = "../../libraries/bezier-rs", features = ["dyn-any"] }
|
||||
specta.workspace = true
|
||||
|
||||
bytemuck = {version = "1.8" }
|
||||
bytemuck = { version = "1.8" }
|
||||
anyhow = "1.0.66"
|
||||
rustc-hash = {workspace = true}
|
||||
rustc-hash = { workspace = true }
|
||||
|
|
|
@ -26,7 +26,7 @@ quantization = ["graphene-std/quantization"]
|
|||
|
||||
[dependencies]
|
||||
log = "0.4"
|
||||
bitflags = "1.2.1"
|
||||
bitflags = "2.4"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = { version = "1.0" }
|
||||
bezier-rs = { path = "../../libraries/bezier-rs" }
|
||||
|
@ -46,17 +46,17 @@ dyn-any = { path = "../../libraries/dyn-any" }
|
|||
graphene-core = { path = "../gcore" }
|
||||
future-executor = { path = "../future-executor", optional = true }
|
||||
|
||||
wasm-bindgen = { version = "0.2.86", optional = true }
|
||||
wasm-bindgen = { workspace = true, optional = true }
|
||||
futures = "0.3.28"
|
||||
fern = { version = "0.6.2", features = ["colored"] }
|
||||
chrono = "0.4.26"
|
||||
tokio = { version = "1.28.2", features = ["macros", "rt"] }
|
||||
wgpu = "0.16.1"
|
||||
wgpu = "0.17"
|
||||
|
||||
[dependencies.document-legacy]
|
||||
path = "../../document-legacy"
|
||||
package = "graphite-document-legacy"
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.8.4"
|
||||
test-case = "2.1"
|
||||
env_logger = "0.10"
|
||||
test-case = "3.1"
|
||||
|
|
|
@ -38,13 +38,13 @@ graphene-core = { path = "../gcore", features = [
|
|||
dyn-any = { path = "../../libraries/dyn-any", features = ["derive"] }
|
||||
graph-craft = { path = "../graph-craft" }
|
||||
vulkan-executor = { path = "../vulkan-executor", optional = true }
|
||||
wgpu-executor = { path = "../wgpu-executor", optional = true, version = "0.1.0" }
|
||||
wgpu-executor = { path = "../wgpu-executor", optional = true, version = "0.1" }
|
||||
gpu-executor = { path = "../gpu-executor", optional = true }
|
||||
gpu-compiler-bin-wrapper = { path = "../gpu-compiler/gpu-compiler-bin-wrapper", optional = true }
|
||||
compilation-client = { path = "../compilation-client", optional = true }
|
||||
bytemuck = { version = "1.8" }
|
||||
bytemuck = { version = "1.13" }
|
||||
tempfile = "3"
|
||||
image = { version = "*", default-features = false, features = ["png", "jpeg"] }
|
||||
image = { version = "0.24", default-features = false, features = ["png", "jpeg"] }
|
||||
base64 = { version = "0.21", optional = true }
|
||||
dyn-clone = "1.0"
|
||||
|
||||
|
@ -56,10 +56,10 @@ rustc-hash = { workspace = true }
|
|||
serde_json = "1.0.96"
|
||||
reqwest = { version = "0.11.18", features = ["rustls", "rustls-tls", "json"] }
|
||||
futures = "0.3.28"
|
||||
wasm-bindgen = { version = "0.2.84", optional = true }
|
||||
wasm-bindgen = { workspace = true, optional = true }
|
||||
js-sys = { version = "0.3.63", optional = true }
|
||||
wgpu-types = "0.16.0"
|
||||
wgpu = "0.16.1"
|
||||
wgpu-types = "0.17"
|
||||
wgpu = "0.17"
|
||||
wasm-bindgen-futures = { version = "0.4.36", optional = true }
|
||||
winit = "0.28.6"
|
||||
url = "2.4.0"
|
||||
|
|
|
@ -27,6 +27,6 @@ dyn-clone = "1.0"
|
|||
log = "0.4"
|
||||
serde = { version = "1", features = ["derive"], optional = true }
|
||||
glam = { version = "0.24" }
|
||||
once_cell = "1.17.0"
|
||||
once_cell = "1.18" # Remove when `core::cell::LazyCell` is stabilized (<https://doc.rust-lang.org/core/cell/struct.LazyCell.html>)
|
||||
futures = "0.3.28"
|
||||
typed-arena = "2.0.2"
|
||||
|
|
|
@ -16,6 +16,6 @@ license = "Apache-2.0"
|
|||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
syn = { version = "1.0", features = ["full"] }
|
||||
syn = { version = "2.0", features = ["full"] }
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -2,7 +2,7 @@ use proc_macro::TokenStream;
|
|||
use proc_macro2::Span;
|
||||
use quote::{format_ident, quote, ToTokens};
|
||||
use syn::{
|
||||
parse_macro_input, punctuated::Punctuated, token::Comma, AngleBracketedGenericArguments, Binding, FnArg, GenericArgument, GenericParam, Ident, ItemFn, Lifetime, Pat, PatIdent, PathArguments,
|
||||
parse_macro_input, punctuated::Punctuated, token::Comma, AngleBracketedGenericArguments, AssocType, FnArg, GenericArgument, GenericParam, Ident, ItemFn, Lifetime, Pat, PatIdent, PathArguments,
|
||||
PredicateType, ReturnType, Token, TraitBound, Type, TypeImplTrait, TypeParam, TypeParamBound, TypeTuple, WhereClause, WherePredicate,
|
||||
};
|
||||
|
||||
|
@ -294,7 +294,7 @@ fn input_node_bounds(parameter_inputs: Vec<Type>, node_generics: Vec<GenericPara
|
|||
let Some(GenericArgument::Type(in_ty)) = args_iter.next() else {
|
||||
panic!("Expected type argument in Node<> declaration")
|
||||
};
|
||||
let Some(GenericArgument::Binding(Binding { ty: out_ty, .. })) = args_iter.next() else {
|
||||
let Some(GenericArgument::AssocType(AssocType { ty: out_ty, .. })) = args_iter.next() else {
|
||||
panic!("Expected Output = in Node declaration")
|
||||
};
|
||||
(lifetime, in_ty.clone(), out_ty.clone())
|
||||
|
@ -302,7 +302,7 @@ fn input_node_bounds(parameter_inputs: Vec<Type>, node_generics: Vec<GenericPara
|
|||
ty => (
|
||||
Lifetime::new("'input", Span::call_site()),
|
||||
Type::Tuple(TypeTuple {
|
||||
paren_token: syn::token::Paren { span: Span::call_site() },
|
||||
paren_token: syn::token::Paren(Span::call_site()),
|
||||
elems: Punctuated::new(),
|
||||
}),
|
||||
ty,
|
||||
|
|
|
@ -34,10 +34,10 @@ base64 = "0.21"
|
|||
|
||||
bytemuck = { version = "1.8" }
|
||||
anyhow = "1.0.66"
|
||||
wgpu = { version = "0.16", features = ["spirv"] }
|
||||
wgpu = { version = "0.17", features = ["spirv"] }
|
||||
spirv = "0.2.0"
|
||||
futures-intrusive = "0.5.0"
|
||||
futures = "0.3.25"
|
||||
web-sys = { version = "0.3.4", features = ["HtmlCanvasElement"] }
|
||||
winit = "0.28.6"
|
||||
nvtx = { version = "1.1.1", optional = true }
|
||||
nvtx = { version = "1.2", optional = true }
|
||||
|
|
|
@ -20,7 +20,7 @@ serde-discriminant = []
|
|||
|
||||
[dependencies]
|
||||
proc-macro2 = "1"
|
||||
syn = { version = "1.0.68", features = ["full"] }
|
||||
syn = { version = "2.0", features = ["full"] }
|
||||
quote = "1.0.9"
|
||||
|
||||
[dev-dependencies.editor]
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn derive_as_message_impl(input_item: TokenStream) -> syn::Result<TokenStrea
|
|||
.map(|var| {
|
||||
let var_name = &var.ident;
|
||||
let var_name_s = var.ident.to_string();
|
||||
if var.attrs.iter().any(|a| a.path.is_ident("child")) {
|
||||
if var.attrs.iter().any(|a| a.path().is_ident("child")) {
|
||||
(
|
||||
quote::quote! {
|
||||
#input_type::#var_name(child)
|
||||
|
|
|
@ -77,8 +77,13 @@ pub fn combined_message_attrs_impl(attr: TokenStream, input_item: TokenStream) -
|
|||
}
|
||||
|
||||
for var in &mut input.variants {
|
||||
if let Some(attr) = var.attrs.iter_mut().find(|a| a.path.is_ident("child")) {
|
||||
let last_segment = attr.path.segments.last_mut().unwrap();
|
||||
if let Some(attr) = var.attrs.iter_mut().find(|a| a.path().is_ident("child")) {
|
||||
let path = match &mut attr.meta {
|
||||
syn::Meta::Path(path) => path,
|
||||
syn::Meta::List(list) => &mut list.path,
|
||||
syn::Meta::NameValue(named_value) => &mut named_value.path,
|
||||
};
|
||||
let last_segment = path.segments.last_mut().unwrap();
|
||||
last_segment.ident = call_site_ident("sub_discriminant");
|
||||
var.attrs.push(syn::parse_quote! {
|
||||
#[discriminant_attr(child)]
|
||||
|
@ -96,8 +101,13 @@ fn top_level_impl(input_item: TokenStream) -> syn::Result<TokenStream> {
|
|||
input.attrs.push(syn::parse_quote! { #[discriminant_attr(derive(Debug, Copy, Clone, PartialEq, Eq, Hash, AsMessage))] });
|
||||
|
||||
for var in &mut input.variants {
|
||||
if let Some(attr) = var.attrs.iter_mut().find(|a| a.path.is_ident("child")) {
|
||||
let last_segment = attr.path.segments.last_mut().unwrap();
|
||||
if let Some(attr) = var.attrs.iter_mut().find(|a| a.path().is_ident("child")) {
|
||||
let path = match &mut attr.meta {
|
||||
syn::Meta::Path(path) => path,
|
||||
syn::Meta::List(list) => &mut list.path,
|
||||
syn::Meta::NameValue(named_value) => &mut named_value.path,
|
||||
};
|
||||
let last_segment = path.segments.last_mut().unwrap();
|
||||
last_segment.ident = call_site_ident("sub_discriminant");
|
||||
var.attrs.push(syn::parse_quote! {
|
||||
#[discriminant_attr(child)]
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use crate::helper_structs::ParenthesizedTokens;
|
||||
use crate::helpers::call_site_ident;
|
||||
use proc_macro2::{Ident, Span, TokenStream};
|
||||
use syn::spanned::Spanned;
|
||||
use syn::{Attribute, Data, DeriveInput, Field, Fields, ItemEnum};
|
||||
use syn::{Attribute, Data, DeriveInput, Field, Fields, ItemEnum, MetaList};
|
||||
|
||||
pub fn derive_discriminant_impl(input_item: TokenStream) -> syn::Result<TokenStream> {
|
||||
let input = syn::parse2::<DeriveInput>(input_item).unwrap();
|
||||
|
@ -16,7 +15,7 @@ pub fn derive_discriminant_impl(input_item: TokenStream) -> syn::Result<TokenStr
|
|||
let mut attr_errs = vec![];
|
||||
|
||||
for var in &mut data.variants {
|
||||
if var.attrs.iter().any(|a| a.path.is_ident("sub_discriminant")) {
|
||||
if var.attrs.iter().any(|a| a.path().is_ident("sub_discriminant")) {
|
||||
match var.fields.len() {
|
||||
1 => {
|
||||
let Field { ty, .. } = var.fields.iter_mut().next().unwrap();
|
||||
|
@ -33,9 +32,9 @@ pub fn derive_discriminant_impl(input_item: TokenStream) -> syn::Result<TokenStr
|
|||
}
|
||||
let mut retain = vec![];
|
||||
for (i, a) in var.attrs.iter_mut().enumerate() {
|
||||
if a.path.is_ident("discriminant_attr") {
|
||||
match syn::parse2::<ParenthesizedTokens>(a.tokens.clone()) {
|
||||
Ok(ParenthesizedTokens { tokens, .. }) => {
|
||||
if a.path().is_ident("discriminant_attr") {
|
||||
match a.meta.require_list() {
|
||||
Ok(MetaList { tokens, .. }) => {
|
||||
let attr: Attribute = syn::parse_quote! {
|
||||
#[#tokens]
|
||||
};
|
||||
|
@ -48,7 +47,7 @@ pub fn derive_discriminant_impl(input_item: TokenStream) -> syn::Result<TokenStr
|
|||
}
|
||||
}
|
||||
}
|
||||
var.attrs = var.attrs.iter().enumerate().filter_map(|(i, x)| retain.contains(&i).then(|| x.clone())).collect();
|
||||
var.attrs = var.attrs.iter().enumerate().filter(|(i, _)| retain.contains(&i)).map(|(_, x)| x.clone()).collect();
|
||||
}
|
||||
|
||||
let attrs = input
|
||||
|
@ -57,10 +56,10 @@ pub fn derive_discriminant_impl(input_item: TokenStream) -> syn::Result<TokenStr
|
|||
.cloned()
|
||||
.filter_map(|a| {
|
||||
let a_span = a.span();
|
||||
a.path
|
||||
a.path()
|
||||
.is_ident("discriminant_attr")
|
||||
.then(|| match syn::parse2::<ParenthesizedTokens>(a.tokens) {
|
||||
Ok(ParenthesizedTokens { tokens, .. }) => {
|
||||
.then(|| match a.meta.require_list() {
|
||||
Ok(MetaList { tokens, .. }) => {
|
||||
let attr: Attribute = syn::parse_quote! {
|
||||
#[#tokens]
|
||||
};
|
||||
|
|
|
@ -55,17 +55,13 @@ impl Parse for KeyEqString {
|
|||
|
||||
/// Parses `(key="value", key="value", …)`
|
||||
pub struct AttrInnerKeyStringMap {
|
||||
_paren_token: Paren,
|
||||
parts: Punctuated<KeyEqString, Token![,]>,
|
||||
}
|
||||
|
||||
impl Parse for AttrInnerKeyStringMap {
|
||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
||||
let content;
|
||||
let _paren_token = parenthesized!(content in input);
|
||||
Ok(Self {
|
||||
_paren_token,
|
||||
parts: Punctuated::parse_terminated(&content)?,
|
||||
parts: Punctuated::parse_terminated(input)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +92,6 @@ impl AttrInnerKeyStringMap {
|
|||
|
||||
/// Parses `(left, right)`
|
||||
pub struct Pair<F, S> {
|
||||
pub paren_token: Paren,
|
||||
pub first: F,
|
||||
pub sep: Token![,],
|
||||
pub second: S,
|
||||
|
@ -108,13 +103,10 @@ where
|
|||
S: Parse,
|
||||
{
|
||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
||||
let content;
|
||||
let paren_token = parenthesized!(content in input);
|
||||
Ok(Self {
|
||||
paren_token,
|
||||
first: content.parse()?,
|
||||
sep: content.parse()?,
|
||||
second: content.parse()?,
|
||||
first: input.parse()?,
|
||||
sep: input.parse()?,
|
||||
second: input.parse()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +172,7 @@ mod tests {
|
|||
#[test]
|
||||
fn attr_inner_key_string_map() {
|
||||
let res = syn::parse2::<AttrInnerKeyStringMap>(quote::quote! {
|
||||
(key="value", key2="value2")
|
||||
key="value", key2="value2"
|
||||
});
|
||||
assert!(res.is_ok());
|
||||
let res = res.ok().unwrap();
|
||||
|
@ -190,7 +182,7 @@ mod tests {
|
|||
}
|
||||
|
||||
let res = syn::parse2::<AttrInnerKeyStringMap>(quote::quote! {
|
||||
(key="value", key2="value2",)
|
||||
key="value", key2="value2",
|
||||
});
|
||||
assert!(res.is_ok());
|
||||
let res = res.ok().unwrap();
|
||||
|
|
|
@ -7,8 +7,8 @@ fn parse_hint_helper_attrs(attrs: &[Attribute]) -> syn::Result<(Vec<LitStr>, Vec
|
|||
fold_error_iter(
|
||||
attrs
|
||||
.iter()
|
||||
.filter(|a| a.path.get_ident().map_or(false, |i| i == "hint"))
|
||||
.map(|attr| syn::parse2::<AttrInnerKeyStringMap>(attr.tokens.clone())),
|
||||
.filter(|a| a.path().get_ident().map_or(false, |i| i == "hint"))
|
||||
.map(|attr| attr.parse_args::<AttrInnerKeyStringMap>()),
|
||||
)
|
||||
.and_then(|v: Vec<AttrInnerKeyStringMap>| {
|
||||
fold_error_iter(AttrInnerKeyStringMap::multi_into_iter(v).map(|(k, mut v)| match v.len() {
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
use crate::helper_structs::Pair;
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
use syn::{Attribute, DeriveInput, Expr, Type};
|
||||
use syn::{DeriveInput, Expr, Type};
|
||||
|
||||
pub fn derive_transitive_child_impl(input_item: TokenStream) -> syn::Result<TokenStream> {
|
||||
let input = syn::parse2::<DeriveInput>(input_item).unwrap();
|
||||
|
||||
let Attribute { tokens, .. } = input
|
||||
let attribute = input
|
||||
.attrs
|
||||
.iter()
|
||||
.find(|a| a.path.is_ident("parent"))
|
||||
.find(|a| a.path().is_ident("parent"))
|
||||
.ok_or_else(|| syn::Error::new(Span::call_site(), format!("tried to derive TransitiveChild without a #[parent] attribute (on {})", input.ident)))?;
|
||||
|
||||
let parent_is_top = input.attrs.iter().any(|a| a.path.is_ident("parent_is_top"));
|
||||
let parent_is_top = input.attrs.iter().any(|a| a.path().is_ident("parent_is_top"));
|
||||
|
||||
let Pair {
|
||||
first: parent_type,
|
||||
second: to_parent,
|
||||
..
|
||||
} = syn::parse2::<Pair<Type, Expr>>(tokens.clone())?;
|
||||
} = attribute.parse_args::<Pair<Type, Expr>>()?;
|
||||
|
||||
let top_parent_type: Type = syn::parse_quote! { <#parent_type as TransitiveChild>::TopParent };
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ use syn::{Attribute, Data, DeriveInput, Field, PathArguments, Type};
|
|||
fn has_attribute(attrs: &[Attribute], target: &str) -> bool {
|
||||
attrs
|
||||
.iter()
|
||||
.filter(|attr| attr.path.to_token_stream().to_string() == "widget_builder")
|
||||
.any(|attr| attr.tokens.to_token_stream().to_string() == target)
|
||||
.filter(|attr| attr.path().to_token_stream().to_string() == "widget_builder")
|
||||
.any(|attr| attr.meta.require_list().is_ok_and(|list| list.tokens.to_string() == target))
|
||||
}
|
||||
|
||||
/// Make setting strings easier by allowing all types that `impl Into<String>`
|
||||
|
@ -67,7 +67,7 @@ fn find_type_and_assignment(field: &Field) -> syn::Result<(TokenStream2, TokenSt
|
|||
// Construct a builder function for a specific field in the struct
|
||||
fn construct_builder(field: &Field) -> syn::Result<TokenStream2> {
|
||||
// Check if this field should be skipped with `#[widget_builder(skip)]`
|
||||
if has_attribute(&field.attrs, "(skip)") {
|
||||
if has_attribute(&field.attrs, "skip") {
|
||||
return Ok(Default::default());
|
||||
}
|
||||
let field_ident = extract_ident(field)?;
|
||||
|
@ -103,7 +103,7 @@ pub fn derive_widget_builder_impl(input_item: TokenStream2) -> syn::Result<Token
|
|||
let builder_functions = fields.iter().map(construct_builder).collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
// Check if this should not have the `widget_holder()` function due to a `#[widget_builder(not_widget_holder)]` attribute
|
||||
let widget_holder_fn = if !has_attribute(&input.attrs, "(not_widget_holder)") {
|
||||
let widget_holder_fn = if !has_attribute(&input.attrs, "not_widget_holder") {
|
||||
// A doc comment for the widget_holder function
|
||||
let widget_holder_doc_comment = Literal::string(&format!("Wrap {struct_name_ident} as a WidgetHolder."));
|
||||
|
||||
|
@ -123,7 +123,7 @@ pub fn derive_widget_builder_impl(input_item: TokenStream2) -> syn::Result<Token
|
|||
// A doc comment for the new function
|
||||
let new_doc_comment = Literal::string(&format!("Create a new {struct_name_ident}, based on default values."));
|
||||
|
||||
let is_constructor = |field: &Field| has_attribute(&field.attrs, "(constructor)");
|
||||
let is_constructor = |field: &Field| has_attribute(&field.attrs, "constructor");
|
||||
|
||||
let idents = fields.iter().filter(|field| is_constructor(field)).map(extract_ident).collect::<Result<Vec<_>, _>>()?;
|
||||
let types_and_assignments = fields.iter().filter(|field| is_constructor(field)).map(find_type_and_assignment).collect::<Result<Vec<_>, _>>()?;
|
||||
|
|
|
@ -17,9 +17,9 @@ crate-type = ["cdylib", "rlib"]
|
|||
bezier-rs = { path = "../../../../libraries/bezier-rs", package = "bezier-rs" }
|
||||
log = "0.4"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
wasm-bindgen = { version = "0.2.73" }
|
||||
serde_json = "*"
|
||||
serde-wasm-bindgen = "0.4.1"
|
||||
wasm-bindgen = { workspace = true }
|
||||
serde_json = "1.0"
|
||||
serde-wasm-bindgen = "0.5"
|
||||
js-sys = "0.3.55"
|
||||
glam = { version = "0.24", features = ["serde"] }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue