@@ -128,3 +128,45 @@ impl CodegenTest2 {
128
128
#[ func( virtual) ]
129
129
fn with_virtual_many_unnamed ( & self , _: i32 , _: GString ) { }
130
130
}
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