Skip to content

Commit 9fa8556

Browse files
committed
Test generation of proc-macro code via declarative macro
1 parent 6a5d19d commit 9fa8556

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

itest/rust/src/engine_tests/codegen_test.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,45 @@ impl CodegenTest2 {
128128
#[func(virtual)]
129129
fn with_virtual_many_unnamed(&self, _: i32, _: GString) {}
130130
}
131+
132+
// ----------------------------------------------------------------------------------------------------------------------------------------------
133+
// Generation of APIs via declarative macro.
134+
135+
macro_rules! make_class {
136+
($ClassName:ident, $BaseName:ident) => {
137+
#[derive(GodotClass)]
138+
#[class(no_init, base=$BaseName)]
139+
pub struct $ClassName {
140+
base: Base<godot::classes::$BaseName>,
141+
}
142+
};
143+
}
144+
145+
macro_rules! make_interface_impl {
146+
($Class:ty, $Trait:path) => {
147+
#[godot_api]
148+
#[allow(unused)]
149+
impl $Trait for $Class {
150+
fn init(base: Base<Self::Base>) -> Self {
151+
Self { base }
152+
}
153+
154+
fn process(&mut self, _: f64) {}
155+
}
156+
};
157+
}
158+
159+
macro_rules! make_user_api {
160+
($Class:ty, $method:ident, $Param:ty) => {
161+
#[godot_api]
162+
#[allow(unused)]
163+
impl $Class {
164+
#[func]
165+
fn $method(&self, _m: $Param) {}
166+
}
167+
};
168+
}
169+
170+
make_class!(CodegenTest3, Node3D);
171+
make_interface_impl!(CodegenTest3, INode3D);
172+
make_user_api!(CodegenTest3, take_param, i32);

0 commit comments

Comments
 (0)