File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -602,23 +602,10 @@ fn ast_parse(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
602602}
603603
604604pub fn mk_module ( ctx : & PyContext ) -> PyObjectRef {
605- // TODO: maybe we can use some clever macro to generate this?
606- let ast_mod = ctx. new_module ( "ast" , ctx. new_scope ( None ) ) ;
607-
608- ctx. set_attr ( & ast_mod, "parse" , ctx. new_rustfunc ( ast_parse) ) ;
609-
610- ctx. set_attr (
611- & ast_mod,
612- "Module" ,
613- ctx. new_class ( "_ast.Module" , ctx. object ( ) ) ,
614- ) ;
615-
616- ctx. set_attr (
617- & ast_mod,
618- "FunctionDef" ,
619- ctx. new_class ( "_ast.FunctionDef" , ctx. object ( ) ) ,
620- ) ;
621- ctx. set_attr ( & ast_mod, "Call" , ctx. new_class ( "_ast.Call" , ctx. object ( ) ) ) ;
622-
623- ast_mod
605+ py_module ! ( ctx, "ast" , {
606+ "parse" => ctx. new_rustfunc( ast_parse) ,
607+ "Module" => ctx. new_class( "_ast.Module" , ctx. object( ) ) ,
608+ "FunctionDef" =>ctx. new_class( "_ast.FunctionDef" , ctx. object( ) ) ,
609+ "Call" => ctx. new_class( "_ast.Call" , ctx. object( ) )
610+ } )
624611}
You can’t perform that action at this time.
0 commit comments