File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -150,12 +150,35 @@ pub(crate) fn generate_fields_inspection(
150
150
. map ( |it| it. to_token_stream ( ) )
151
151
. unwrap_or_else ( || cls. to_token_stream ( ) ) ;
152
152
153
+ let mut args: Vec < TokenStream > = vec ! [ ] ;
154
+ for arg in & field. spec . args {
155
+ let name = Literal :: string ( & * arg. name . to_string ( ) ) ;
156
+ let typ = generate_type ( arg. ty )
157
+ . map ( |it| it. to_token_stream ( ) )
158
+ . unwrap_or_else ( || cls. to_token_stream ( ) ) ;
159
+
160
+ let is_mutable = arg. mutability . is_some ( ) ;
161
+
162
+ args. push ( quote ! {
163
+ _pyo3:: inspect:: fields:: ArgumentInfo {
164
+ name: #name,
165
+ kind: _pyo3:: inspect:: fields:: ArgumentKind :: PositionOrKeyword , //TODO
166
+ py_type: :: std:: option:: Option :: Some ( || <#typ as _pyo3:: conversion:: FromPyObject >:: type_input( ) ) ,
167
+ default_value: false ,
168
+ is_modified: #is_mutable,
169
+ }
170
+ } ) ;
171
+ }
172
+ let args_size = Literal :: usize_suffixed ( args. len ( ) ) ;
173
+
153
174
let output = quote ! {
154
175
fn #field_type_fn_name( ) -> _pyo3:: inspect:: types:: TypeInfo {
155
176
<#field_type as _pyo3:: conversion:: IntoPy <_>>:: type_output( )
156
177
}
157
178
158
- const #field_args_name: [ _pyo3:: inspect:: fields:: ArgumentInfo <' static >; 0 ] = [ ] ; //TODO
179
+ const #field_args_name: [ _pyo3:: inspect:: fields:: ArgumentInfo <' static >; #args_size] = [
180
+ #( #args) , *
181
+ ] ;
159
182
160
183
const #field_info_name: _pyo3:: inspect:: fields:: FieldInfo <' static > = _pyo3:: inspect:: fields:: FieldInfo {
161
184
name: #field_name,
Original file line number Diff line number Diff line change @@ -229,6 +229,7 @@ struct Complicated {
229
229
#[ allow( unused_variables) ]
230
230
#[ pymethods]
231
231
impl Complicated {
232
+ #[ new]
232
233
fn new ( foo : PyObject , parent : PyObject ) -> Self {
233
234
unreachable ! ( "This is just a stub" )
234
235
}
You can’t perform that action at this time.
0 commit comments