@@ -7,6 +7,7 @@ use godot::{
7
7
meta:: { ClassName , MethodInfo , PropertyInfo } ,
8
8
Array , Dictionary , Gd , Object , StringName , ToGodot ,
9
9
} ,
10
+ sys:: VariantType ,
10
11
} ;
11
12
12
13
use crate :: {
@@ -90,3 +91,101 @@ impl ToDictionary for MethodInfo {
90
91
} )
91
92
}
92
93
}
94
+
95
+ fn variant_type_to_str ( var_type : VariantType ) -> & ' static str {
96
+ use VariantType as V ;
97
+
98
+ match var_type {
99
+ V :: Nil => "void" ,
100
+ V :: Bool => "Bool" ,
101
+ V :: Int => "Int" ,
102
+ V :: Float => "Float" ,
103
+ V :: String => "String" ,
104
+ V :: Vector2 => "Vector2" ,
105
+ V :: Vector2i => "Vector2i" ,
106
+ V :: Rect2 => "Rect2" ,
107
+ V :: Rect2i => "Rect2i" ,
108
+ V :: Vector3 => "Vector3" ,
109
+ V :: Vector3i => "Vector3i" ,
110
+ V :: Transform2D => "Transform2D" ,
111
+ V :: Vector4 => "Vector4" ,
112
+ V :: Vector4i => "Vector4i" ,
113
+ V :: Plane => "Plane" ,
114
+ V :: Quaternion => "Quaternion" ,
115
+ V :: Aabb => "Aabb" ,
116
+ V :: Basis => "Basis" ,
117
+ V :: Transform3D => "Transform3D" ,
118
+ V :: Projection => "Projection" ,
119
+ V :: Color => "Color" ,
120
+ V :: StringName => "StringName" ,
121
+ V :: NodePath => "NodePath" ,
122
+ V :: Rid => "Rid" ,
123
+ V :: Object => "Object" ,
124
+ V :: Callable => "Callable" ,
125
+ V :: Signal => "Signal" ,
126
+ V :: Dictionary => "Dictionary" ,
127
+ V :: Array => "Array" ,
128
+ V :: PackedByteArray => "PackedByteArray" ,
129
+ V :: PackedInt32Array => "PackedInt32Array" ,
130
+ V :: PackedInt64Array => "PackedInt64Array" ,
131
+ V :: PackedColorArray => "PackedColorArray" ,
132
+ V :: PackedStringArray => "PackedStringArray" ,
133
+ V :: PackedVector3Array => "PackedVector3Array" ,
134
+ V :: PackedVector2Array => "PackedVector2Array" ,
135
+ V :: PackedFloat64Array => "PackedFloat64Array" ,
136
+ V :: PackedFloat32Array => "PackedFloat32Array" ,
137
+ }
138
+ }
139
+
140
+ pub trait ToMethodDoc {
141
+ fn to_method_doc ( & self ) -> Dictionary ;
142
+ }
143
+
144
+ impl ToMethodDoc for MethodInfo {
145
+ fn to_method_doc ( & self ) -> Dictionary {
146
+ let args: Array < Dictionary > = self
147
+ . arguments
148
+ . iter ( )
149
+ . map ( |arg| arg. to_argument_doc ( ) )
150
+ . collect ( ) ;
151
+
152
+ Dictionary :: new ( ) . apply ( |dict| {
153
+ dict. set ( "name" , self . method_name . clone ( ) ) ;
154
+ dict. set (
155
+ "return_type" ,
156
+ variant_type_to_str ( self . return_type . variant_type ) ,
157
+ ) ;
158
+ dict. set ( "is_deprecated" , false ) ;
159
+ dict. set ( "is_experimental" , false ) ;
160
+ dict. set ( "arguments" , args) ;
161
+ } )
162
+ }
163
+ }
164
+
165
+ pub trait ToArgumentDoc {
166
+ fn to_argument_doc ( & self ) -> Dictionary ;
167
+ }
168
+
169
+ impl ToArgumentDoc for PropertyInfo {
170
+ fn to_argument_doc ( & self ) -> Dictionary {
171
+ Dictionary :: new ( ) . apply ( |dict| {
172
+ dict. set ( "name" , self . property_name . clone ( ) ) ;
173
+ dict. set ( "type" , variant_type_to_str ( self . variant_type ) ) ;
174
+ } )
175
+ }
176
+ }
177
+
178
+ pub trait ToPropertyDoc {
179
+ fn to_property_doc ( & self ) -> Dictionary ;
180
+ }
181
+
182
+ impl ToPropertyDoc for PropertyInfo {
183
+ fn to_property_doc ( & self ) -> Dictionary {
184
+ Dictionary :: new ( ) . apply ( |dict| {
185
+ dict. set ( "name" , self . property_name . clone ( ) ) ;
186
+ dict. set ( "type" , variant_type_to_str ( self . variant_type ) ) ;
187
+ dict. set ( "is_deprecated" , false ) ;
188
+ dict. set ( "is_experimental" , false ) ;
189
+ } )
190
+ }
191
+ }
0 commit comments