@@ -10,29 +10,32 @@ namespace printer {
10
10
using mlc::core::ObjectPath;
11
11
12
12
struct PrinterConfigObj : public Object {
13
+ bool def_free_var = true ;
13
14
int32_t indent_spaces = 2 ;
14
15
int8_t print_line_numbers = 0 ;
15
16
int32_t num_context_lines = -1 ;
16
17
mlc::List<ObjectPath> path_to_underline;
17
18
18
19
PrinterConfigObj () = default ;
19
- explicit PrinterConfigObj (int32_t indent_spaces, int8_t print_line_numbers, int32_t num_context_lines ,
20
- mlc::List<ObjectPath> path_to_underline)
21
- : indent_spaces(indent_spaces ), print_line_numbers(print_line_numbers ), num_context_lines(num_context_lines ),
22
- path_to_underline(path_to_underline) {}
20
+ explicit PrinterConfigObj (bool def_free_var, int32_t indent_spaces, int8_t print_line_numbers,
21
+ int32_t num_context_lines, mlc::List<ObjectPath> path_to_underline)
22
+ : def_free_var(def_free_var ), indent_spaces(indent_spaces ), print_line_numbers(print_line_numbers ),
23
+ num_context_lines(num_context_lines), path_to_underline(path_to_underline) {}
23
24
MLC_DEF_DYN_TYPE (MLC_EXPORTS, PrinterConfigObj, Object, " mlc.printer.PrinterConfig" );
24
25
};
25
26
26
27
struct PrinterConfig : public ObjectRef {
27
28
MLC_DEF_OBJ_REF (MLC_EXPORTS, PrinterConfig, PrinterConfigObj, ObjectRef)
29
+ .Field(" def_free_var" , &PrinterConfigObj::def_free_var)
28
30
.Field(" indent_spaces" , &PrinterConfigObj::indent_spaces)
29
31
.Field(" print_line_numbers" , &PrinterConfigObj::print_line_numbers)
30
32
.Field(" num_context_lines" , &PrinterConfigObj::num_context_lines)
31
33
.Field(" path_to_underline" , &PrinterConfigObj::path_to_underline)
32
- .StaticFn(" __init__" , InitOf<PrinterConfigObj, int32_t , int8_t , int32_t , mlc::List<ObjectPath>>);
33
- explicit PrinterConfig (int32_t indent_spaces = 2 , int8_t print_line_numbers = 0 , int32_t num_context_lines = -1 ,
34
- mlc::List<ObjectPath> path_to_underline = {})
35
- : PrinterConfig(PrinterConfig::New(indent_spaces, print_line_numbers, num_context_lines, path_to_underline)) {}
34
+ .StaticFn(" __init__" , InitOf<PrinterConfigObj, bool , int32_t , int8_t , int32_t , mlc::List<ObjectPath>>);
35
+ explicit PrinterConfig (bool def_free_var = true , int32_t indent_spaces = 2 , int8_t print_line_numbers = 0 ,
36
+ int32_t num_context_lines = -1 , mlc::List<ObjectPath> path_to_underline = {})
37
+ : PrinterConfig(PrinterConfig::New(def_free_var, indent_spaces, print_line_numbers, num_context_lines,
38
+ path_to_underline)) {}
36
39
};
37
40
38
41
} // namespace printer
@@ -82,6 +85,17 @@ struct ExprObj : public ::mlc::Object {
82
85
}; // struct ExprObj
83
86
84
87
struct Expr : public ::mlc::printer::Node {
88
+ Expr Attr (mlc::Str name) const { return this ->get ()->Attr (name); }
89
+ Expr Index (mlc::List<::mlc::printer::Expr> idx) const { return this ->get ()->Index (idx); }
90
+ Expr Call (mlc::List<::mlc::printer::Expr> args) const { return this ->get ()->Call (args); }
91
+ Expr CallKw (mlc::List<::mlc::printer::Expr> args, mlc::List<::mlc::Str> kwargs_keys,
92
+ mlc::List<::mlc::printer::Expr> kwargs_values) const {
93
+ return this ->get ()->CallKw (args, kwargs_keys, kwargs_values);
94
+ }
95
+ Expr AddPath (mlc::core::ObjectPath p) {
96
+ this ->get ()->source_paths ->push_back (p);
97
+ return *this ;
98
+ }
85
99
MLC_DEF_OBJ_REF (MLC_EXPORTS, Expr, ExprObj, ::mlc::printer::Node)
86
100
.Field(" source_paths" , &ExprObj::source_paths)
87
101
.StaticFn(" __init__" , ::mlc::InitOf<ExprObj, ::mlc::List<::mlc::core::ObjectPath>>)
0 commit comments