mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-26 07:54:07 +00:00
shader-rt: fix impl Context
in the wrong places
This commit is contained in:
parent
f82f3e6484
commit
d68c33479a
2 changed files with 11 additions and 16 deletions
|
@ -144,7 +144,7 @@ pub struct NodeParsedField {
|
||||||
pub implementations: Punctuated<Implementation, Comma>,
|
pub implementations: Punctuated<Implementation, Comma>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) struct Input {
|
pub(crate) struct Input {
|
||||||
pub(crate) pat_ident: PatIdent,
|
pub(crate) pat_ident: PatIdent,
|
||||||
pub(crate) ty: Type,
|
pub(crate) ty: Type,
|
||||||
|
@ -663,7 +663,7 @@ pub fn new_node_fn(attr: TokenStream2, item: TokenStream2) -> TokenStream2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ParsedNodeFn {
|
impl ParsedNodeFn {
|
||||||
fn replace_impl_trait_in_input(&mut self) {
|
pub fn replace_impl_trait_in_input(&mut self) {
|
||||||
if let Type::ImplTrait(impl_trait) = self.input.ty.clone() {
|
if let Type::ImplTrait(impl_trait) = self.input.ty.clone() {
|
||||||
let ident = Ident::new("_Input", impl_trait.span());
|
let ident = Ident::new("_Input", impl_trait.span());
|
||||||
let mut bounds = impl_trait.bounds;
|
let mut bounds = impl_trait.bounds;
|
||||||
|
|
|
@ -2,12 +2,12 @@ use crate::parsing::{Input, NodeFnAttributes, ParsedField, ParsedFieldType, Pars
|
||||||
use crate::shader_nodes::{ShaderCodegen, ShaderNodeType, ShaderTokens};
|
use crate::shader_nodes::{ShaderCodegen, ShaderNodeType, ShaderTokens};
|
||||||
use convert_case::{Case, Casing};
|
use convert_case::{Case, Casing};
|
||||||
use proc_macro_crate::FoundCrate;
|
use proc_macro_crate::FoundCrate;
|
||||||
use proc_macro2::{Ident, Span, TokenStream};
|
use proc_macro2::{Ident, TokenStream};
|
||||||
use quote::{ToTokens, format_ident, quote};
|
use quote::{ToTokens, format_ident, quote};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use syn::parse::{Parse, ParseStream};
|
use syn::parse::{Parse, ParseStream};
|
||||||
use syn::punctuated::Punctuated;
|
use syn::punctuated::Punctuated;
|
||||||
use syn::{Token, TraitBound, TraitBoundModifier, Type, TypeImplTrait, TypeParamBound};
|
use syn::{Type, parse_quote};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct PerPixelAdjust {}
|
pub struct PerPixelAdjust {}
|
||||||
|
@ -119,7 +119,7 @@ impl PerPixelAdjust {
|
||||||
FoundCrate::Itself => format_ident!("crate"),
|
FoundCrate::Itself => format_ident!("crate"),
|
||||||
FoundCrate::Name(name) => format_ident!("{name}"),
|
FoundCrate::Name(name) => format_ident!("{name}"),
|
||||||
};
|
};
|
||||||
let raster_gpu = syn::parse2::<Type>(quote!(#gcore::table::Table<#gcore::raster_types::Raster<#gcore::raster_types::GPU>>))?;
|
let raster_gpu: Type = parse_quote!(#gcore::table::Table<#gcore::raster_types::Raster<#gcore::raster_types::GPU>>);
|
||||||
|
|
||||||
let fields = parsed
|
let fields = parsed
|
||||||
.fields
|
.fields
|
||||||
|
@ -128,6 +128,7 @@ impl PerPixelAdjust {
|
||||||
ParsedFieldType::Regular(reg @ RegularParsedField { gpu_image: true, .. }) => Ok(ParsedField {
|
ParsedFieldType::Regular(reg @ RegularParsedField { gpu_image: true, .. }) => Ok(ParsedField {
|
||||||
ty: ParsedFieldType::Regular(RegularParsedField {
|
ty: ParsedFieldType::Regular(RegularParsedField {
|
||||||
ty: raster_gpu.clone(),
|
ty: raster_gpu.clone(),
|
||||||
|
implementations: Punctuated::default(),
|
||||||
..reg.clone()
|
..reg.clone()
|
||||||
}),
|
}),
|
||||||
..f.clone()
|
..f.clone()
|
||||||
|
@ -143,7 +144,7 @@ impl PerPixelAdjust {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let gpu_node = crate::codegen::generate_node_code(&ParsedNodeFn {
|
let mut parsed_node_fn = ParsedNodeFn {
|
||||||
vis: parsed.vis.clone(),
|
vis: parsed.vis.clone(),
|
||||||
attributes: NodeFnAttributes {
|
attributes: NodeFnAttributes {
|
||||||
shader_node: Some(ShaderNodeType::GpuNode),
|
shader_node: Some(ShaderNodeType::GpuNode),
|
||||||
|
@ -156,15 +157,7 @@ impl PerPixelAdjust {
|
||||||
where_clause: None,
|
where_clause: None,
|
||||||
input: Input {
|
input: Input {
|
||||||
pat_ident: parsed.input.pat_ident.clone(),
|
pat_ident: parsed.input.pat_ident.clone(),
|
||||||
ty: Type::ImplTrait(TypeImplTrait {
|
ty: parse_quote!(impl #gcore::context::Ctx),
|
||||||
impl_token: Token),
|
|
||||||
bounds: Punctuated::from_iter([TypeParamBound::Trait(TraitBound {
|
|
||||||
paren_token: None,
|
|
||||||
modifier: TraitBoundModifier::None,
|
|
||||||
lifetimes: None,
|
|
||||||
path: syn::parse2(quote!(#gcore::context::Ctx))?,
|
|
||||||
})]),
|
|
||||||
}),
|
|
||||||
implementations: Default::default(),
|
implementations: Default::default(),
|
||||||
},
|
},
|
||||||
output_type: raster_gpu,
|
output_type: raster_gpu,
|
||||||
|
@ -173,7 +166,9 @@ impl PerPixelAdjust {
|
||||||
body,
|
body,
|
||||||
crate_name: parsed.crate_name.clone(),
|
crate_name: parsed.crate_name.clone(),
|
||||||
description: "".to_string(),
|
description: "".to_string(),
|
||||||
})?;
|
};
|
||||||
|
parsed_node_fn.replace_impl_trait_in_input();
|
||||||
|
let gpu_node = crate::codegen::generate_node_code(&parsed_node_fn)?;
|
||||||
|
|
||||||
Ok(quote! {
|
Ok(quote! {
|
||||||
#node_cfg
|
#node_cfg
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue