Module cuicui_chirp::parse_dsl_impl
source · Expand description
Add this attribute to an impl
block to generate a ParseDsl
impl from
the methods declared in the impl
block.
All methods with a &mut self
argument
will automatically be added to the ParseDsl::method
implementation.
Example
ⓘ
use cuicui_chirp::parse_dsl_impl;
#[parse_dsl_impl(
cuicui_chirp_path = ::cuicui_chirp,
delegate = inner,
type_parsers(color = css_color_parser),
set_params<>,
)]
impl MyDsl {
// This can be called in a chirp file in method position as `Entity(parse_dsl_bare_method)`.
pub fn parse_dsl_bare_method(&mut self) {}
// This can be called in a chirp file in method position as
// > Entity(with_args(51, "I think", "path/to.png"))
pub fn with_args(&mut self, ticks: u32, though: &str, image: Handle<Image>) {}
// Only methods with a `&mut self` can be called from a chirp file.
// This can't be called in a chirp file.
pub fn method_ignored_by_parse_dsl(&self, trick: u32) -> Option<String> { None }
// If you want to not add a `&mut self` method to the chirp methods, use
// `parse_dsl(ignore)`
#[parse_dsl(ignore)]
pub fn ignored_method(&mut self, style: &Style) {}
}
Notes
Warning For hot reloading to work, avoid panicking in methods. Otherwise the game will terminate without the ability to reload the chirp file.
This module is purely illustrative, it exports stub functions that only exists for documentation.
This describes “meta-attributes”, attributes that
can be added between parenthesis to the parse_dsl_impl
attribute to modify
its behavior.
parse_dsl_impl
also accepts a parse_dsl
attribute on individual methods
within the impl
block, see parse_dsl_impl::parse_dsl
for details.
Functions
- Specify which path to use for the
cuicui_chirp
crate. - Field to delegate
ParseDsl::method
when encountering a method name not in thisimpl
block. - Do not add this method to the chirp methods list.
- Use a custom set of type bounds on the
impl
blocks generics. - Use
F
as parser for arguments of typeIdent
.