summaryrefslogtreecommitdiff
path: root/engine/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2025-06-05 18:27:00 +0200
committerHampusM <hampus@hampusmat.com>2025-06-05 18:27:00 +0200
commit11367ae5b43771b722e2f98b3f3edaef1fb4505f (patch)
tree2cf9fc09b3d887853d9c8d54f37c5c7073f32ba4 /engine/src
parent9362dbdb04de92382833ff2d31de7fccef165934 (diff)
feat(engine): add builder macro attr to skip generating field fnHEADmaster
Diffstat (limited to 'engine/src')
-rw-r--r--engine/src/util.rs34
1 files changed, 26 insertions, 8 deletions
diff --git a/engine/src/util.rs b/engine/src/util.rs
index 7e22bbb..cc4677d 100644
--- a/engine/src/util.rs
+++ b/engine/src/util.rs
@@ -26,6 +26,17 @@ macro_rules! or {
pub(crate) use or;
#[macro_export]
+macro_rules! expand_map_opt {
+ ($in: tt, no_occurance=($($no_occurance: tt)*), occurance=($($occurance: tt)*)) => {
+ $($occurance)*
+ };
+
+ (, no_occurance=($($no_occurance: tt)*), occurance=($($occurance: tt)*)) => {
+ $($no_occurance)*
+ };
+}
+
+#[macro_export]
macro_rules! builder {
(
$(#[doc = $doc: literal])*
@@ -37,7 +48,8 @@ macro_rules! builder {
$visibility: vis struct $name: ident
{
$(
- $(#[$field_attr: meta])*
+ $(#[doc = $field_doc: literal])*
+ $(#[builder(skip_generate_fn$($field_skip_generate_fn: tt)?)])?
$field_visibility: vis $field: ident: $field_type: ty,
)*
}
@@ -47,7 +59,7 @@ macro_rules! builder {
$visibility struct $name
{
$(
- $(#[$field_attr])*
+ $(#[doc = $field_doc])*
$field_visibility $field: $field_type,
)*
}
@@ -63,12 +75,18 @@ macro_rules! builder {
impl $builder_name
{
$(
- #[must_use]
- $visibility fn $field(mut self, $field: $field_type) -> Self
- {
- self.$field = $field;
- self
- }
+ $crate::expand_map_opt!(
+ $(true $($field_skip_generate_fn)?)?,
+ no_occurance=(
+ #[must_use]
+ $visibility fn $field(mut self, $field: $field_type) -> Self
+ {
+ self.$field = $field;
+ self
+ }
+ ),
+ occurance=()
+ );
)*
#[must_use]