mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 06:38:03 +08:00
* Remove the dead InputAccessor traits and the uncallable test helper built on them * Replace raw node input indices with macro-generated parameter symbols across the editor * Audit dynamic input index usage, converting to parameter symbols and named input position constants * Abstract the remaining input index plumbing behind ParameterRef APIs and accessors * Build SetInputValue messages as struct literals to keep message enums impl-free * Delete the typed parameter markers in favor of explicit-output test introspection * Wire the interpolation control path input per chain node type * Return no input when a parameter symbol is read against the wrong node's parameter view
41 lines
1.7 KiB
Rust
41 lines
1.7 KiB
Rust
use crate::crate_ident::CrateIdent;
|
|
use proc_macro::TokenStream;
|
|
use proc_macro_error2::proc_macro_error;
|
|
|
|
mod buffer_struct;
|
|
mod codegen;
|
|
mod crate_ident;
|
|
mod derive_choice_type;
|
|
mod parsing;
|
|
mod shader_nodes;
|
|
mod validation;
|
|
|
|
/// Used to create a node definition.
|
|
#[proc_macro_error]
|
|
#[proc_macro_attribute]
|
|
pub fn node(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
// Performs the `node_impl` macro's functionality of attaching an `impl Node for TheGivenStruct` block to the node struct
|
|
parsing::new_node_fn(attr.into(), item.into()).unwrap_or_else(|err| err.to_compile_error()).into()
|
|
}
|
|
|
|
/// Generate meta-information for an enum.
|
|
///
|
|
/// `#[widget(F)]` on a type indicates the type of widget to use to display/edit the type, currently `Radio` and `Dropdown` are supported.
|
|
///
|
|
/// `#[label("Foo")]` on a variant overrides the default UI label (which is otherwise the name converted to title case). All labels are collected into a [`core::fmt::Display`] impl.
|
|
///
|
|
/// `#[icon("tag"))]` sets the icon to use when a variant is shown in a menu or radio button.
|
|
///
|
|
/// Doc comments on a variant become tooltip description text.
|
|
#[proc_macro_derive(ChoiceType, attributes(widget, menu_separator, label, icon))]
|
|
pub fn derive_choice_type(input_item: TokenStream) -> TokenStream {
|
|
derive_choice_type::derive_choice_type_impl(input_item.into()).unwrap_or_else(|err| err.to_compile_error()).into()
|
|
}
|
|
|
|
/// Derive a struct to implement `ShaderStruct`, see that for docs.
|
|
#[proc_macro_derive(BufferStruct)]
|
|
pub fn derive_buffer_struct(input_item: TokenStream) -> TokenStream {
|
|
let crate_ident = CrateIdent::default();
|
|
TokenStream::from(buffer_struct::derive_buffer_struct(&crate_ident, input_item).unwrap_or_else(|err| err.to_compile_error()))
|
|
}
|