diff --git a/Cargo.toml b/Cargo.toml index b37c6cfd..8f0741cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ include = ["LICENSE", "Cargo.toml", "src/**/*.rs"] [workspace] resolver = "2" members = [ - "ast", "core", "format", "literal", "parser", + "ast", "core", "format", "literal", "parser", "parser-pyo3", "ruff_text_size", "ruff_source_location", ] @@ -19,6 +19,8 @@ members = [ rustpython-ast = { path = "ast", default-features = false } rustpython-parser-core = { path = "core", features = [] } rustpython-literal = { path = "literal" } +rustpython-format = { path = "format" } +rustpython-parser = { path = "parser" } ahash = "0.7.6" anyhow = "1.0.45" diff --git a/ast/Cargo.toml b/ast/Cargo.toml index d8d58e0a..bee7c188 100644 --- a/ast/Cargo.toml +++ b/ast/Cargo.toml @@ -17,6 +17,10 @@ visitor = [] all-nodes-with-ranges = [] pyo3 = ["dep:pyo3", "num-complex", "once_cell"] +# This feature is experimental +# It reimplements AST types, but currently both slower than python AST types and limited to use in other API +pyo3-wrapper = ["pyo3"] + [dependencies] rustpython-parser-core = { workspace = true } rustpython-literal = { workspace = true, optional = true } diff --git a/ast/asdl_rs.py b/ast/asdl_rs.py index 0dc4c8c4..a16c46ec 100755 --- a/ast/asdl_rs.py +++ b/ast/asdl_rs.py @@ -42,6 +42,7 @@ "yield", "in", "mod", + "type", } @@ -212,7 +213,7 @@ def emit_identifier(self, name): def emit(self, line, depth): if line: - line = (" " * TABSIZE * depth) + line + line = (" " * TABSIZE * depth) + textwrap.dedent(line) self.file.write(line + "\n") @@ -277,10 +278,9 @@ def add_children(self, name, fields): def rust_field(field_name): - if field_name == "type": - return "type_" - else: - return field_name + if field_name in RUST_KEYWORDS: + field_name += "_" + return field_name class StructVisitor(EmitVisitor): @@ -954,19 +954,24 @@ def generics(self): else: assert False, self.namespace + @property + def location(self): + # lineno, col_offset + pass + def visitModule(self, mod): for dfn in mod.dfns: self.visit(dfn) - def visitType(self, type, depth=0): - self.visit(type.value, type.name, depth) + def visitType(self, type): + self.visit(type.value, type) - def visitProduct(self, product, name, depth=0): - rust_name = rust_type_name(name) - self.emit_to_pyo3_with_fields(product, rust_name) + def visitProduct(self, product, type): + rust_name = rust_type_name(type.name) + self.emit_to_pyo3_with_fields(product, type, rust_name) - def visitSum(self, sum, name, depth=0): - rust_name = rust_type_name(name) + def visitSum(self, sum, type): + rust_name = rust_type_name(type.name) simple = is_simple(sum) if is_simple(sum): return @@ -983,7 +988,7 @@ def visitSum(self, sum, name, depth=0): for cons in sum.types: self.emit( f"""crate::{rust_name}::{cons.name}(cons) => cons.to_pyo3_ast(py)?,""", - depth, + 1, ) self.emit( """ @@ -996,52 +1001,372 @@ def visitSum(self, sum, name, depth=0): ) for cons in sum.types: - self.visit(cons, rust_name, depth) + self.visit(cons, type) - def visitConstructor(self, cons, parent, depth): - self.emit_to_pyo3_with_fields(cons, f"{parent}{cons.name}") + def visitConstructor(self, cons, type): + parent = rust_type_name(type.name) + self.emit_to_pyo3_with_fields(cons, type, f"{parent}{cons.name}") - def emit_to_pyo3_with_fields(self, cons, name): - if cons.fields: - self.emit( - f""" - impl ToPyo3Ast for crate::{name}{self.generics} {{ - #[inline] + def emit_to_pyo3_with_fields(self, cons, type, name): + type_info = self.type_info[type.name] + self.emit( + f""" + impl ToPyo3Ast for crate::{name}{self.generics} {{ + #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> {{ let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, ( - """, - 0, + """, + 0, + ) + if cons.fields: + field_names = ", ".join(rust_field(f.name) for f in cons.fields) + if not type_info.is_simple: + field_names += ", range: _range" + self.emit( + f"let Self {{ {field_names} }} = self;", + 1, + ) + self.emit( + "let instance = cache.0.call1(py, (", + 1, ) for field in cons.fields: self.emit( - f"self.{rust_field(field.name)}.to_pyo3_ast(py)?,", + f"{rust_field(field.name)}.to_pyo3_ast(py)?,", 3, ) self.emit( """ ))?; - Ok(instance) - } + """, + 0, + ) + else: + self.emit( + "let instance = cache.0.call0(py)?;", + 1, + ) + self.emit( + "let Self { range: _range } = self;", + 1, + ) + if type.value.attributes and self.namespace == "located": + self.emit( + """ + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; } """, + 1, + ) + self.emit( + """ + Ok(instance) + } + } + """, + 0, + ) + + +class Pyo3StructVisitor(EmitVisitor): + """Visitor to generate type-defs for AST.""" + + def __init__(self, namespace, *args, **kw): + self.namespace = namespace + self.borrow = True + super().__init__(*args, **kw) + + @property + def generics(self): + if self.namespace == "ranged": + return "" + elif self.namespace == "located": + return "" + else: + assert False, self.namespace + + @property + def module_name(self): + name = f"rustpython_ast.{self.namespace}" + return name + + @property + def ref_def(self): + return "&'static " if self.borrow else "" + + @property + def ref(self): + return "&" if self.borrow else "" + + def emit_class(self, name, rust_name, simple, base="super::AST"): + info = self.type_info[name] + if simple: + generics = "" + else: + generics = self.generics + if info.is_sum: + subclass = ", subclass" + body = "" + into = f"{rust_name}" + else: + subclass = "" + body = f"(pub {self.ref_def} crate::{rust_name}{generics})" + into = f"{rust_name}(node)" + + self.emit( + textwrap.dedent( + f""" + #[pyclass(module="{self.module_name}", name="_{name}", extends={base}, frozen{subclass})] + #[derive(Clone, Debug)] + pub struct {rust_name} {body}; + + impl From<{self.ref_def} crate::{rust_name}{generics}> for {rust_name} {{ + fn from({"" if body else "_"}node: {self.ref_def} crate::{rust_name}{generics}) -> Self {{ + {into} + }} + }} + """ + ), + 0, + ) + if subclass: + self.emit( + textwrap.dedent( + f""" + #[pymethods] + impl {rust_name} {{ + #[new] + fn new() -> PyClassInitializer {{ + PyClassInitializer::from(AST) + .add_subclass(Self) + }} + + }} + impl ToPyObject for {rust_name} {{ + fn to_object(&self, py: Python) -> PyObject {{ + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + }} + }} + """ + ), 0, ) else: + if base != "super::AST": + add_subclass = f".add_subclass({base})" + else: + add_subclass = "" self.emit( + textwrap.dedent( + f""" + impl ToPyObject for {rust_name} {{ + fn to_object(&self, py: Python) -> PyObject {{ + let initializer = PyClassInitializer::from(AST) + {add_subclass} + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + }} + }} + """ + ), + 0, + ) + + if not subclass: + self.emit_wrapper(rust_name) + + def emit_getter(self, owner, type_name): + self.emit( + textwrap.dedent( f""" - impl ToPyo3Ast for crate::{name}{self.generics} {{ + #[pymethods] + impl {type_name} {{ + """ + ), + 0, + ) + + for field in owner.fields: + self.emit( + textwrap.dedent( + f""" + #[getter] #[inline] - fn to_pyo3_ast(&self, py: Python) -> PyResult> {{ - let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call0(py)?; - Ok(instance) + fn get_{field.name}(&self, py: Python) -> PyResult {{ + self.0.{rust_field(field.name)}.to_pyo3_wrapper(py) }} + """ + ), + 3, + ) + + self.emit( + textwrap.dedent( + """ + } + """ + ), + 0, + ) + + def emit_getattr(self, owner, type_name): + self.emit( + textwrap.dedent( + f""" + #[pymethods] + impl {type_name} {{ + fn __getattr__(&self, py: Python, key: &str) -> PyResult {{ + let object: Py = match key {{ + """ + ), + 0, + ) + + for field in owner.fields: + self.emit( + f'"{field.name}" => self.0.{rust_field(field.name)}.to_pyo3_wrapper(py)?,', + 3, + ) + + self.emit( + textwrap.dedent( + """ + _ => todo!(), + }; + Ok(object) + } + } + """ + ), + 0, + ) + + def emit_wrapper(self, rust_name): + self.emit( + f""" + impl ToPyo3Wrapper for crate::{rust_name}{self.generics} {{ + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> {{ + Ok({rust_name}(self).to_object(py)) }} + }} + """, + 0, + ) + + def visitModule(self, mod): + for dfn in mod.dfns: + self.visit(dfn) + + def visitType(self, type, depth=0): + self.visit(type.value, type, depth) + + def visitSum(self, sum, type, depth=0): + rust_name = rust_type_name(type.name) + + simple = is_simple(sum) + self.emit_class(type.name, rust_name, simple) + + if not simple: + self.emit( + f""" + impl ToPyo3Wrapper for crate::{rust_name}{self.generics} {{ + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> {{ + match &self {{ + """, + 0, + ) + + for cons in sum.types: + self.emit(f"Self::{cons.name}(cons) => cons.to_pyo3_wrapper(py),", 3) + + self.emit( + """ + } + } + } """, 0, ) + for cons in sum.types: + self.visit(cons, rust_name, simple, depth + 1) + + def visitProduct(self, product, type, depth=0): + rust_name = rust_type_name(type.name) + self.emit_class(type.name, rust_name, False) + if self.borrow: + self.emit_getter(product, rust_name) + + def visitConstructor(self, cons, parent, simple, depth): + if simple: + self.emit( + f""" +#[pyclass(module="{self.module_name}", name="_{cons.name}", extends={parent})] +pub struct {parent}{cons.name}; + +impl ToPyObject for {parent}{cons.name} {{ + fn to_object(&self, py: Python) -> PyObject {{ + let initializer = PyClassInitializer::from(AST) + .add_subclass({parent}) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + }} +}} + """, + depth, + ) + else: + self.emit_class( + cons.name, + f"{parent}{cons.name}", + simple=False, + base=parent, + ) + if self.borrow: + self.emit_getter(cons, f"{parent}{cons.name}") + + +class Pyo3PymoduleVisitor(EmitVisitor): + def __init__(self, namespace, *args, **kw): + self.namespace = namespace + super().__init__(*args, **kw) + + def visitModule(self, mod): + for dfn in mod.dfns: + self.visit(dfn) + + def visitType(self, type, depth=0): + self.visit(type.value, type.name, depth) + + def visitProduct(self, product, name, depth=0): + rust_name = rust_type_name(name) + self.emit_fields(name, rust_name, False) + + def visitSum(self, sum, name, depth): + rust_name = rust_type_name(name) + simple = is_simple(sum) + self.emit_fields(name, rust_name, True) + + for cons in sum.types: + self.visit(cons, name, simple, depth) + + def visitConstructor(self, cons, parent, simple, depth): + rust_name = rust_type_name(parent) + rust_type_name(cons.name) + self.emit_fields(cons.name, rust_name, simple) + + def emit_fields(self, name, rust_name, simple): + self.emit( + f"super::init_type::<{rust_name}, crate::generic::{rust_name}>(py, m)?;", 1 + ) + class StdlibClassDefVisitor(EmitVisitor): def visitModule(self, mod): @@ -1412,7 +1737,7 @@ def write_to_pyo3(mod, type_info, f): f.write( """ - pub fn init(py: Python) -> PyResult<()> { + fn init_types(py: Python) -> PyResult<()> { let ast_module = PyModule::import(py, "_ast")?; """ ) @@ -1453,6 +1778,58 @@ def write_to_pyo3_simple(type_info, f): ) +def write_pyo3_wrapper(mod, type_info, namespace, f): + Pyo3StructVisitor(namespace, f, type_info).visit(mod) + + if namespace == "located": + for type_info in type_info.values(): + if not type_info.is_simple or not type_info.is_sum: + continue + + rust_name = type_info.rust_sum_name + f.write( + f""" + impl ToPyo3Wrapper for crate::generic::{rust_name} {{ + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> {{ + match &self {{ + """, + ) + for cons in type_info.type.value.types: + f.write( + f"Self::{cons.name} => Ok({rust_name}{cons.name}.to_object(py)),", + ) + f.write( + """ + } + } + } + """, + ) + + for cons in type_info.type.value.types: + f.write( + f""" + impl ToPyo3Wrapper for crate::generic::{rust_name}{cons.name} {{ + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> {{ + Ok({rust_name}{cons.name}.to_object(py)) + }} + }} + """ + ) + + f.write( + """ + pub fn add_to_module(py: Python, m: &PyModule) -> PyResult<()> { + super::init_module(py, m)?; + """ + ) + + Pyo3PymoduleVisitor(namespace, f, type_info).visit(mod) + f.write("Ok(())\n}") + + def write_ast_mod(mod, type_info, f): f.write( textwrap.dedent( @@ -1499,6 +1876,8 @@ def main( ("located", p(write_located_def, mod, type_info)), ("visitor", p(write_visitor_def, mod, type_info)), ("to_pyo3", p(write_to_pyo3, mod, type_info)), + ("pyo3_wrapper_located", p(write_pyo3_wrapper, mod, type_info, "located")), + ("pyo3_wrapper_ranged", p(write_pyo3_wrapper, mod, type_info, "ranged")), ]: with (ast_dir / f"{filename}.rs").open("w") as f: f.write(auto_gen_msg) diff --git a/ast/src/gen/pyo3_wrapper_located.rs b/ast/src/gen/pyo3_wrapper_located.rs new file mode 100644 index 00000000..ba55ee24 --- /dev/null +++ b/ast/src/gen/pyo3_wrapper_located.rs @@ -0,0 +1,4415 @@ +// File automatically generated by ast/asdl_rs.py. + +#[pyclass(module="rustpython_ast.located", name="_mod", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Mod; + +impl From<&'static crate::Mod> for Mod { + fn from(_node: &'static crate::Mod) -> Self { + Mod + } +} + +#[pymethods] +impl Mod { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Mod { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Mod { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::Module(cons) => cons.to_pyo3_wrapper(py), + Self::Interactive(cons) => cons.to_pyo3_wrapper(py), + Self::Expression(cons) => cons.to_pyo3_wrapper(py), + Self::FunctionType(cons) => cons.to_pyo3_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.located", name="_Module", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModModule(pub &'static crate::ModModule); + +impl From<&'static crate::ModModule> for ModModule { + fn from(node: &'static crate::ModModule) -> Self { + ModModule(node) + } +} + +impl ToPyObject for ModModule { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ModModule { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModModule(self).to_object(py)) + } +} + +#[pymethods] +impl ModModule { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_ignores(&self, py: Python) -> PyResult { + self.0.type_ignores.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Interactive", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModInteractive(pub &'static crate::ModInteractive); + +impl From<&'static crate::ModInteractive> for ModInteractive { + fn from(node: &'static crate::ModInteractive) -> Self { + ModInteractive(node) + } +} + +impl ToPyObject for ModInteractive { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ModInteractive { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModInteractive(self).to_object(py)) + } +} + +#[pymethods] +impl ModInteractive { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Expression", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModExpression(pub &'static crate::ModExpression); + +impl From<&'static crate::ModExpression> for ModExpression { + fn from(node: &'static crate::ModExpression) -> Self { + ModExpression(node) + } +} + +impl ToPyObject for ModExpression { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ModExpression { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModExpression(self).to_object(py)) + } +} + +#[pymethods] +impl ModExpression { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_FunctionType", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModFunctionType(pub &'static crate::ModFunctionType); + +impl From<&'static crate::ModFunctionType> for ModFunctionType { + fn from(node: &'static crate::ModFunctionType) -> Self { + ModFunctionType(node) + } +} + +impl ToPyObject for ModFunctionType { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ModFunctionType { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModFunctionType(self).to_object(py)) + } +} + +#[pymethods] +impl ModFunctionType { + #[getter] + #[inline] + fn get_argtypes(&self, py: Python) -> PyResult { + self.0.argtypes.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_returns(&self, py: Python) -> PyResult { + self.0.returns.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_stmt", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Stmt; + +impl From<&'static crate::Stmt> for Stmt { + fn from(_node: &'static crate::Stmt) -> Self { + Stmt + } +} + +#[pymethods] +impl Stmt { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Stmt { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Stmt { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::FunctionDef(cons) => cons.to_pyo3_wrapper(py), + Self::AsyncFunctionDef(cons) => cons.to_pyo3_wrapper(py), + Self::ClassDef(cons) => cons.to_pyo3_wrapper(py), + Self::Return(cons) => cons.to_pyo3_wrapper(py), + Self::Delete(cons) => cons.to_pyo3_wrapper(py), + Self::Assign(cons) => cons.to_pyo3_wrapper(py), + Self::AugAssign(cons) => cons.to_pyo3_wrapper(py), + Self::AnnAssign(cons) => cons.to_pyo3_wrapper(py), + Self::For(cons) => cons.to_pyo3_wrapper(py), + Self::AsyncFor(cons) => cons.to_pyo3_wrapper(py), + Self::While(cons) => cons.to_pyo3_wrapper(py), + Self::If(cons) => cons.to_pyo3_wrapper(py), + Self::With(cons) => cons.to_pyo3_wrapper(py), + Self::AsyncWith(cons) => cons.to_pyo3_wrapper(py), + Self::Match(cons) => cons.to_pyo3_wrapper(py), + Self::Raise(cons) => cons.to_pyo3_wrapper(py), + Self::Try(cons) => cons.to_pyo3_wrapper(py), + Self::TryStar(cons) => cons.to_pyo3_wrapper(py), + Self::Assert(cons) => cons.to_pyo3_wrapper(py), + Self::Import(cons) => cons.to_pyo3_wrapper(py), + Self::ImportFrom(cons) => cons.to_pyo3_wrapper(py), + Self::Global(cons) => cons.to_pyo3_wrapper(py), + Self::Nonlocal(cons) => cons.to_pyo3_wrapper(py), + Self::Expr(cons) => cons.to_pyo3_wrapper(py), + Self::Pass(cons) => cons.to_pyo3_wrapper(py), + Self::Break(cons) => cons.to_pyo3_wrapper(py), + Self::Continue(cons) => cons.to_pyo3_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.located", name="_FunctionDef", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtFunctionDef(pub &'static crate::StmtFunctionDef); + +impl From<&'static crate::StmtFunctionDef> for StmtFunctionDef { + fn from(node: &'static crate::StmtFunctionDef) -> Self { + StmtFunctionDef(node) + } +} + +impl ToPyObject for StmtFunctionDef { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtFunctionDef { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtFunctionDef(self).to_object(py)) + } +} + +#[pymethods] +impl StmtFunctionDef { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_decorator_list(&self, py: Python) -> PyResult { + self.0.decorator_list.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_returns(&self, py: Python) -> PyResult { + self.0.returns.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_AsyncFunctionDef", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAsyncFunctionDef(pub &'static crate::StmtAsyncFunctionDef); + +impl From<&'static crate::StmtAsyncFunctionDef> for StmtAsyncFunctionDef { + fn from(node: &'static crate::StmtAsyncFunctionDef) -> Self { + StmtAsyncFunctionDef(node) + } +} + +impl ToPyObject for StmtAsyncFunctionDef { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAsyncFunctionDef { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAsyncFunctionDef(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAsyncFunctionDef { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_decorator_list(&self, py: Python) -> PyResult { + self.0.decorator_list.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_returns(&self, py: Python) -> PyResult { + self.0.returns.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_ClassDef", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtClassDef(pub &'static crate::StmtClassDef); + +impl From<&'static crate::StmtClassDef> for StmtClassDef { + fn from(node: &'static crate::StmtClassDef) -> Self { + StmtClassDef(node) + } +} + +impl ToPyObject for StmtClassDef { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtClassDef { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtClassDef(self).to_object(py)) + } +} + +#[pymethods] +impl StmtClassDef { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_bases(&self, py: Python) -> PyResult { + self.0.bases.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_keywords(&self, py: Python) -> PyResult { + self.0.keywords.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_decorator_list(&self, py: Python) -> PyResult { + self.0.decorator_list.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Return", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtReturn(pub &'static crate::StmtReturn); + +impl From<&'static crate::StmtReturn> for StmtReturn { + fn from(node: &'static crate::StmtReturn) -> Self { + StmtReturn(node) + } +} + +impl ToPyObject for StmtReturn { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtReturn { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtReturn(self).to_object(py)) + } +} + +#[pymethods] +impl StmtReturn { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Delete", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtDelete(pub &'static crate::StmtDelete); + +impl From<&'static crate::StmtDelete> for StmtDelete { + fn from(node: &'static crate::StmtDelete) -> Self { + StmtDelete(node) + } +} + +impl ToPyObject for StmtDelete { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtDelete { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtDelete(self).to_object(py)) + } +} + +#[pymethods] +impl StmtDelete { + #[getter] + #[inline] + fn get_targets(&self, py: Python) -> PyResult { + self.0.targets.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Assign", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAssign(pub &'static crate::StmtAssign); + +impl From<&'static crate::StmtAssign> for StmtAssign { + fn from(node: &'static crate::StmtAssign) -> Self { + StmtAssign(node) + } +} + +impl ToPyObject for StmtAssign { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAssign { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAssign(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAssign { + #[getter] + #[inline] + fn get_targets(&self, py: Python) -> PyResult { + self.0.targets.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_AugAssign", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAugAssign(pub &'static crate::StmtAugAssign); + +impl From<&'static crate::StmtAugAssign> for StmtAugAssign { + fn from(node: &'static crate::StmtAugAssign) -> Self { + StmtAugAssign(node) + } +} + +impl ToPyObject for StmtAugAssign { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAugAssign { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAugAssign(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAugAssign { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_AnnAssign", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAnnAssign(pub &'static crate::StmtAnnAssign); + +impl From<&'static crate::StmtAnnAssign> for StmtAnnAssign { + fn from(node: &'static crate::StmtAnnAssign) -> Self { + StmtAnnAssign(node) + } +} + +impl ToPyObject for StmtAnnAssign { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAnnAssign { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAnnAssign(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAnnAssign { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_annotation(&self, py: Python) -> PyResult { + self.0.annotation.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_simple(&self, py: Python) -> PyResult { + self.0.simple.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_For", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtFor(pub &'static crate::StmtFor); + +impl From<&'static crate::StmtFor> for StmtFor { + fn from(node: &'static crate::StmtFor) -> Self { + StmtFor(node) + } +} + +impl ToPyObject for StmtFor { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtFor { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtFor(self).to_object(py)) + } +} + +#[pymethods] +impl StmtFor { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_iter(&self, py: Python) -> PyResult { + self.0.iter.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_AsyncFor", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAsyncFor(pub &'static crate::StmtAsyncFor); + +impl From<&'static crate::StmtAsyncFor> for StmtAsyncFor { + fn from(node: &'static crate::StmtAsyncFor) -> Self { + StmtAsyncFor(node) + } +} + +impl ToPyObject for StmtAsyncFor { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAsyncFor { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAsyncFor(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAsyncFor { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_iter(&self, py: Python) -> PyResult { + self.0.iter.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_While", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtWhile(pub &'static crate::StmtWhile); + +impl From<&'static crate::StmtWhile> for StmtWhile { + fn from(node: &'static crate::StmtWhile) -> Self { + StmtWhile(node) + } +} + +impl ToPyObject for StmtWhile { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtWhile { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtWhile(self).to_object(py)) + } +} + +#[pymethods] +impl StmtWhile { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_If", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtIf(pub &'static crate::StmtIf); + +impl From<&'static crate::StmtIf> for StmtIf { + fn from(node: &'static crate::StmtIf) -> Self { + StmtIf(node) + } +} + +impl ToPyObject for StmtIf { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtIf { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtIf(self).to_object(py)) + } +} + +#[pymethods] +impl StmtIf { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_With", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtWith(pub &'static crate::StmtWith); + +impl From<&'static crate::StmtWith> for StmtWith { + fn from(node: &'static crate::StmtWith) -> Self { + StmtWith(node) + } +} + +impl ToPyObject for StmtWith { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtWith { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtWith(self).to_object(py)) + } +} + +#[pymethods] +impl StmtWith { + #[getter] + #[inline] + fn get_items(&self, py: Python) -> PyResult { + self.0.items.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_AsyncWith", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAsyncWith(pub &'static crate::StmtAsyncWith); + +impl From<&'static crate::StmtAsyncWith> for StmtAsyncWith { + fn from(node: &'static crate::StmtAsyncWith) -> Self { + StmtAsyncWith(node) + } +} + +impl ToPyObject for StmtAsyncWith { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAsyncWith { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAsyncWith(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAsyncWith { + #[getter] + #[inline] + fn get_items(&self, py: Python) -> PyResult { + self.0.items.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Match", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtMatch(pub &'static crate::StmtMatch); + +impl From<&'static crate::StmtMatch> for StmtMatch { + fn from(node: &'static crate::StmtMatch) -> Self { + StmtMatch(node) + } +} + +impl ToPyObject for StmtMatch { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtMatch { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtMatch(self).to_object(py)) + } +} + +#[pymethods] +impl StmtMatch { + #[getter] + #[inline] + fn get_subject(&self, py: Python) -> PyResult { + self.0.subject.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_cases(&self, py: Python) -> PyResult { + self.0.cases.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Raise", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtRaise(pub &'static crate::StmtRaise); + +impl From<&'static crate::StmtRaise> for StmtRaise { + fn from(node: &'static crate::StmtRaise) -> Self { + StmtRaise(node) + } +} + +impl ToPyObject for StmtRaise { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtRaise { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtRaise(self).to_object(py)) + } +} + +#[pymethods] +impl StmtRaise { + #[getter] + #[inline] + fn get_exc(&self, py: Python) -> PyResult { + self.0.exc.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_cause(&self, py: Python) -> PyResult { + self.0.cause.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Try", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtTry(pub &'static crate::StmtTry); + +impl From<&'static crate::StmtTry> for StmtTry { + fn from(node: &'static crate::StmtTry) -> Self { + StmtTry(node) + } +} + +impl ToPyObject for StmtTry { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtTry { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtTry(self).to_object(py)) + } +} + +#[pymethods] +impl StmtTry { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_handlers(&self, py: Python) -> PyResult { + self.0.handlers.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_finalbody(&self, py: Python) -> PyResult { + self.0.finalbody.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_TryStar", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtTryStar(pub &'static crate::StmtTryStar); + +impl From<&'static crate::StmtTryStar> for StmtTryStar { + fn from(node: &'static crate::StmtTryStar) -> Self { + StmtTryStar(node) + } +} + +impl ToPyObject for StmtTryStar { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtTryStar { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtTryStar(self).to_object(py)) + } +} + +#[pymethods] +impl StmtTryStar { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_handlers(&self, py: Python) -> PyResult { + self.0.handlers.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_finalbody(&self, py: Python) -> PyResult { + self.0.finalbody.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Assert", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAssert(pub &'static crate::StmtAssert); + +impl From<&'static crate::StmtAssert> for StmtAssert { + fn from(node: &'static crate::StmtAssert) -> Self { + StmtAssert(node) + } +} + +impl ToPyObject for StmtAssert { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAssert { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAssert(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAssert { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_msg(&self, py: Python) -> PyResult { + self.0.msg.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Import", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtImport(pub &'static crate::StmtImport); + +impl From<&'static crate::StmtImport> for StmtImport { + fn from(node: &'static crate::StmtImport) -> Self { + StmtImport(node) + } +} + +impl ToPyObject for StmtImport { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtImport { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtImport(self).to_object(py)) + } +} + +#[pymethods] +impl StmtImport { + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_ImportFrom", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtImportFrom(pub &'static crate::StmtImportFrom); + +impl From<&'static crate::StmtImportFrom> for StmtImportFrom { + fn from(node: &'static crate::StmtImportFrom) -> Self { + StmtImportFrom(node) + } +} + +impl ToPyObject for StmtImportFrom { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtImportFrom { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtImportFrom(self).to_object(py)) + } +} + +#[pymethods] +impl StmtImportFrom { + #[getter] + #[inline] + fn get_module(&self, py: Python) -> PyResult { + self.0.module.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_level(&self, py: Python) -> PyResult { + self.0.level.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Global", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtGlobal(pub &'static crate::StmtGlobal); + +impl From<&'static crate::StmtGlobal> for StmtGlobal { + fn from(node: &'static crate::StmtGlobal) -> Self { + StmtGlobal(node) + } +} + +impl ToPyObject for StmtGlobal { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtGlobal { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtGlobal(self).to_object(py)) + } +} + +#[pymethods] +impl StmtGlobal { + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Nonlocal", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtNonlocal(pub &'static crate::StmtNonlocal); + +impl From<&'static crate::StmtNonlocal> for StmtNonlocal { + fn from(node: &'static crate::StmtNonlocal) -> Self { + StmtNonlocal(node) + } +} + +impl ToPyObject for StmtNonlocal { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtNonlocal { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtNonlocal(self).to_object(py)) + } +} + +#[pymethods] +impl StmtNonlocal { + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Expr", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtExpr(pub &'static crate::StmtExpr); + +impl From<&'static crate::StmtExpr> for StmtExpr { + fn from(node: &'static crate::StmtExpr) -> Self { + StmtExpr(node) + } +} + +impl ToPyObject for StmtExpr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtExpr { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtExpr(self).to_object(py)) + } +} + +#[pymethods] +impl StmtExpr { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Pass", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtPass(pub &'static crate::StmtPass); + +impl From<&'static crate::StmtPass> for StmtPass { + fn from(node: &'static crate::StmtPass) -> Self { + StmtPass(node) + } +} + +impl ToPyObject for StmtPass { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtPass { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtPass(self).to_object(py)) + } +} + +#[pymethods] +impl StmtPass {} + +#[pyclass(module="rustpython_ast.located", name="_Break", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtBreak(pub &'static crate::StmtBreak); + +impl From<&'static crate::StmtBreak> for StmtBreak { + fn from(node: &'static crate::StmtBreak) -> Self { + StmtBreak(node) + } +} + +impl ToPyObject for StmtBreak { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtBreak { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtBreak(self).to_object(py)) + } +} + +#[pymethods] +impl StmtBreak {} + +#[pyclass(module="rustpython_ast.located", name="_Continue", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtContinue(pub &'static crate::StmtContinue); + +impl From<&'static crate::StmtContinue> for StmtContinue { + fn from(node: &'static crate::StmtContinue) -> Self { + StmtContinue(node) + } +} + +impl ToPyObject for StmtContinue { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtContinue { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtContinue(self).to_object(py)) + } +} + +#[pymethods] +impl StmtContinue {} + +#[pyclass(module="rustpython_ast.located", name="_expr", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Expr; + +impl From<&'static crate::Expr> for Expr { + fn from(_node: &'static crate::Expr) -> Self { + Expr + } +} + +#[pymethods] +impl Expr { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Expr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Expr { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::BoolOp(cons) => cons.to_pyo3_wrapper(py), + Self::NamedExpr(cons) => cons.to_pyo3_wrapper(py), + Self::BinOp(cons) => cons.to_pyo3_wrapper(py), + Self::UnaryOp(cons) => cons.to_pyo3_wrapper(py), + Self::Lambda(cons) => cons.to_pyo3_wrapper(py), + Self::IfExp(cons) => cons.to_pyo3_wrapper(py), + Self::Dict(cons) => cons.to_pyo3_wrapper(py), + Self::Set(cons) => cons.to_pyo3_wrapper(py), + Self::ListComp(cons) => cons.to_pyo3_wrapper(py), + Self::SetComp(cons) => cons.to_pyo3_wrapper(py), + Self::DictComp(cons) => cons.to_pyo3_wrapper(py), + Self::GeneratorExp(cons) => cons.to_pyo3_wrapper(py), + Self::Await(cons) => cons.to_pyo3_wrapper(py), + Self::Yield(cons) => cons.to_pyo3_wrapper(py), + Self::YieldFrom(cons) => cons.to_pyo3_wrapper(py), + Self::Compare(cons) => cons.to_pyo3_wrapper(py), + Self::Call(cons) => cons.to_pyo3_wrapper(py), + Self::FormattedValue(cons) => cons.to_pyo3_wrapper(py), + Self::JoinedStr(cons) => cons.to_pyo3_wrapper(py), + Self::Constant(cons) => cons.to_pyo3_wrapper(py), + Self::Attribute(cons) => cons.to_pyo3_wrapper(py), + Self::Subscript(cons) => cons.to_pyo3_wrapper(py), + Self::Starred(cons) => cons.to_pyo3_wrapper(py), + Self::Name(cons) => cons.to_pyo3_wrapper(py), + Self::List(cons) => cons.to_pyo3_wrapper(py), + Self::Tuple(cons) => cons.to_pyo3_wrapper(py), + Self::Slice(cons) => cons.to_pyo3_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.located", name="_BoolOp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprBoolOp(pub &'static crate::ExprBoolOp); + +impl From<&'static crate::ExprBoolOp> for ExprBoolOp { + fn from(node: &'static crate::ExprBoolOp) -> Self { + ExprBoolOp(node) + } +} + +impl ToPyObject for ExprBoolOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprBoolOp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprBoolOp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprBoolOp { + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_values(&self, py: Python) -> PyResult { + self.0.values.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_NamedExpr", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprNamedExpr(pub &'static crate::ExprNamedExpr); + +impl From<&'static crate::ExprNamedExpr> for ExprNamedExpr { + fn from(node: &'static crate::ExprNamedExpr) -> Self { + ExprNamedExpr(node) + } +} + +impl ToPyObject for ExprNamedExpr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprNamedExpr { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprNamedExpr(self).to_object(py)) + } +} + +#[pymethods] +impl ExprNamedExpr { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_BinOp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprBinOp(pub &'static crate::ExprBinOp); + +impl From<&'static crate::ExprBinOp> for ExprBinOp { + fn from(node: &'static crate::ExprBinOp) -> Self { + ExprBinOp(node) + } +} + +impl ToPyObject for ExprBinOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprBinOp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprBinOp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprBinOp { + #[getter] + #[inline] + fn get_left(&self, py: Python) -> PyResult { + self.0.left.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_right(&self, py: Python) -> PyResult { + self.0.right.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_UnaryOp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprUnaryOp(pub &'static crate::ExprUnaryOp); + +impl From<&'static crate::ExprUnaryOp> for ExprUnaryOp { + fn from(node: &'static crate::ExprUnaryOp) -> Self { + ExprUnaryOp(node) + } +} + +impl ToPyObject for ExprUnaryOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprUnaryOp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprUnaryOp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprUnaryOp { + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_operand(&self, py: Python) -> PyResult { + self.0.operand.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Lambda", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprLambda(pub &'static crate::ExprLambda); + +impl From<&'static crate::ExprLambda> for ExprLambda { + fn from(node: &'static crate::ExprLambda) -> Self { + ExprLambda(node) + } +} + +impl ToPyObject for ExprLambda { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprLambda { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprLambda(self).to_object(py)) + } +} + +#[pymethods] +impl ExprLambda { + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_IfExp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprIfExp(pub &'static crate::ExprIfExp); + +impl From<&'static crate::ExprIfExp> for ExprIfExp { + fn from(node: &'static crate::ExprIfExp) -> Self { + ExprIfExp(node) + } +} + +impl ToPyObject for ExprIfExp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprIfExp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprIfExp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprIfExp { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Dict", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprDict(pub &'static crate::ExprDict); + +impl From<&'static crate::ExprDict> for ExprDict { + fn from(node: &'static crate::ExprDict) -> Self { + ExprDict(node) + } +} + +impl ToPyObject for ExprDict { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprDict { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprDict(self).to_object(py)) + } +} + +#[pymethods] +impl ExprDict { + #[getter] + #[inline] + fn get_keys(&self, py: Python) -> PyResult { + self.0.keys.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_values(&self, py: Python) -> PyResult { + self.0.values.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Set", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSet(pub &'static crate::ExprSet); + +impl From<&'static crate::ExprSet> for ExprSet { + fn from(node: &'static crate::ExprSet) -> Self { + ExprSet(node) + } +} + +impl ToPyObject for ExprSet { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprSet { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSet(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSet { + #[getter] + #[inline] + fn get_elts(&self, py: Python) -> PyResult { + self.0.elts.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_ListComp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprListComp(pub &'static crate::ExprListComp); + +impl From<&'static crate::ExprListComp> for ExprListComp { + fn from(node: &'static crate::ExprListComp) -> Self { + ExprListComp(node) + } +} + +impl ToPyObject for ExprListComp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprListComp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprListComp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprListComp { + #[getter] + #[inline] + fn get_elt(&self, py: Python) -> PyResult { + self.0.elt.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_SetComp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSetComp(pub &'static crate::ExprSetComp); + +impl From<&'static crate::ExprSetComp> for ExprSetComp { + fn from(node: &'static crate::ExprSetComp) -> Self { + ExprSetComp(node) + } +} + +impl ToPyObject for ExprSetComp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprSetComp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSetComp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSetComp { + #[getter] + #[inline] + fn get_elt(&self, py: Python) -> PyResult { + self.0.elt.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_DictComp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprDictComp(pub &'static crate::ExprDictComp); + +impl From<&'static crate::ExprDictComp> for ExprDictComp { + fn from(node: &'static crate::ExprDictComp) -> Self { + ExprDictComp(node) + } +} + +impl ToPyObject for ExprDictComp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprDictComp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprDictComp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprDictComp { + #[getter] + #[inline] + fn get_key(&self, py: Python) -> PyResult { + self.0.key.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_GeneratorExp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprGeneratorExp(pub &'static crate::ExprGeneratorExp); + +impl From<&'static crate::ExprGeneratorExp> for ExprGeneratorExp { + fn from(node: &'static crate::ExprGeneratorExp) -> Self { + ExprGeneratorExp(node) + } +} + +impl ToPyObject for ExprGeneratorExp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprGeneratorExp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprGeneratorExp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprGeneratorExp { + #[getter] + #[inline] + fn get_elt(&self, py: Python) -> PyResult { + self.0.elt.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Await", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprAwait(pub &'static crate::ExprAwait); + +impl From<&'static crate::ExprAwait> for ExprAwait { + fn from(node: &'static crate::ExprAwait) -> Self { + ExprAwait(node) + } +} + +impl ToPyObject for ExprAwait { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprAwait { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprAwait(self).to_object(py)) + } +} + +#[pymethods] +impl ExprAwait { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Yield", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprYield(pub &'static crate::ExprYield); + +impl From<&'static crate::ExprYield> for ExprYield { + fn from(node: &'static crate::ExprYield) -> Self { + ExprYield(node) + } +} + +impl ToPyObject for ExprYield { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprYield { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprYield(self).to_object(py)) + } +} + +#[pymethods] +impl ExprYield { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_YieldFrom", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprYieldFrom(pub &'static crate::ExprYieldFrom); + +impl From<&'static crate::ExprYieldFrom> for ExprYieldFrom { + fn from(node: &'static crate::ExprYieldFrom) -> Self { + ExprYieldFrom(node) + } +} + +impl ToPyObject for ExprYieldFrom { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprYieldFrom { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprYieldFrom(self).to_object(py)) + } +} + +#[pymethods] +impl ExprYieldFrom { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Compare", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprCompare(pub &'static crate::ExprCompare); + +impl From<&'static crate::ExprCompare> for ExprCompare { + fn from(node: &'static crate::ExprCompare) -> Self { + ExprCompare(node) + } +} + +impl ToPyObject for ExprCompare { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprCompare { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprCompare(self).to_object(py)) + } +} + +#[pymethods] +impl ExprCompare { + #[getter] + #[inline] + fn get_left(&self, py: Python) -> PyResult { + self.0.left.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ops(&self, py: Python) -> PyResult { + self.0.ops.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_comparators(&self, py: Python) -> PyResult { + self.0.comparators.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Call", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprCall(pub &'static crate::ExprCall); + +impl From<&'static crate::ExprCall> for ExprCall { + fn from(node: &'static crate::ExprCall) -> Self { + ExprCall(node) + } +} + +impl ToPyObject for ExprCall { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprCall { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprCall(self).to_object(py)) + } +} + +#[pymethods] +impl ExprCall { + #[getter] + #[inline] + fn get_func(&self, py: Python) -> PyResult { + self.0.func.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_keywords(&self, py: Python) -> PyResult { + self.0.keywords.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_FormattedValue", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprFormattedValue(pub &'static crate::ExprFormattedValue); + +impl From<&'static crate::ExprFormattedValue> for ExprFormattedValue { + fn from(node: &'static crate::ExprFormattedValue) -> Self { + ExprFormattedValue(node) + } +} + +impl ToPyObject for ExprFormattedValue { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprFormattedValue { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprFormattedValue(self).to_object(py)) + } +} + +#[pymethods] +impl ExprFormattedValue { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_conversion(&self, py: Python) -> PyResult { + self.0.conversion.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_format_spec(&self, py: Python) -> PyResult { + self.0.format_spec.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_JoinedStr", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprJoinedStr(pub &'static crate::ExprJoinedStr); + +impl From<&'static crate::ExprJoinedStr> for ExprJoinedStr { + fn from(node: &'static crate::ExprJoinedStr) -> Self { + ExprJoinedStr(node) + } +} + +impl ToPyObject for ExprJoinedStr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprJoinedStr { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprJoinedStr(self).to_object(py)) + } +} + +#[pymethods] +impl ExprJoinedStr { + #[getter] + #[inline] + fn get_values(&self, py: Python) -> PyResult { + self.0.values.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Constant", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprConstant(pub &'static crate::ExprConstant); + +impl From<&'static crate::ExprConstant> for ExprConstant { + fn from(node: &'static crate::ExprConstant) -> Self { + ExprConstant(node) + } +} + +impl ToPyObject for ExprConstant { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprConstant { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprConstant(self).to_object(py)) + } +} + +#[pymethods] +impl ExprConstant { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_kind(&self, py: Python) -> PyResult { + self.0.kind.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Attribute", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprAttribute(pub &'static crate::ExprAttribute); + +impl From<&'static crate::ExprAttribute> for ExprAttribute { + fn from(node: &'static crate::ExprAttribute) -> Self { + ExprAttribute(node) + } +} + +impl ToPyObject for ExprAttribute { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprAttribute { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprAttribute(self).to_object(py)) + } +} + +#[pymethods] +impl ExprAttribute { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_attr(&self, py: Python) -> PyResult { + self.0.attr.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Subscript", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSubscript(pub &'static crate::ExprSubscript); + +impl From<&'static crate::ExprSubscript> for ExprSubscript { + fn from(node: &'static crate::ExprSubscript) -> Self { + ExprSubscript(node) + } +} + +impl ToPyObject for ExprSubscript { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprSubscript { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSubscript(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSubscript { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_slice(&self, py: Python) -> PyResult { + self.0.slice.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Starred", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprStarred(pub &'static crate::ExprStarred); + +impl From<&'static crate::ExprStarred> for ExprStarred { + fn from(node: &'static crate::ExprStarred) -> Self { + ExprStarred(node) + } +} + +impl ToPyObject for ExprStarred { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprStarred { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprStarred(self).to_object(py)) + } +} + +#[pymethods] +impl ExprStarred { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Name", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprName(pub &'static crate::ExprName); + +impl From<&'static crate::ExprName> for ExprName { + fn from(node: &'static crate::ExprName) -> Self { + ExprName(node) + } +} + +impl ToPyObject for ExprName { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprName { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprName(self).to_object(py)) + } +} + +#[pymethods] +impl ExprName { + #[getter] + #[inline] + fn get_id(&self, py: Python) -> PyResult { + self.0.id.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_List", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprList(pub &'static crate::ExprList); + +impl From<&'static crate::ExprList> for ExprList { + fn from(node: &'static crate::ExprList) -> Self { + ExprList(node) + } +} + +impl ToPyObject for ExprList { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprList { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprList(self).to_object(py)) + } +} + +#[pymethods] +impl ExprList { + #[getter] + #[inline] + fn get_elts(&self, py: Python) -> PyResult { + self.0.elts.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Tuple", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprTuple(pub &'static crate::ExprTuple); + +impl From<&'static crate::ExprTuple> for ExprTuple { + fn from(node: &'static crate::ExprTuple) -> Self { + ExprTuple(node) + } +} + +impl ToPyObject for ExprTuple { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprTuple { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprTuple(self).to_object(py)) + } +} + +#[pymethods] +impl ExprTuple { + #[getter] + #[inline] + fn get_elts(&self, py: Python) -> PyResult { + self.0.elts.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Slice", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSlice(pub &'static crate::ExprSlice); + +impl From<&'static crate::ExprSlice> for ExprSlice { + fn from(node: &'static crate::ExprSlice) -> Self { + ExprSlice(node) + } +} + +impl ToPyObject for ExprSlice { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprSlice { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSlice(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSlice { + #[getter] + #[inline] + fn get_lower(&self, py: Python) -> PyResult { + self.0.lower.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_upper(&self, py: Python) -> PyResult { + self.0.upper.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_step(&self, py: Python) -> PyResult { + self.0.step.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_expr_context", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct ExprContext; + +impl From<&'static crate::ExprContext> for ExprContext { + fn from(_node: &'static crate::ExprContext) -> Self { + ExprContext + } +} + +#[pymethods] +impl ExprContext { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for ExprContext { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Load", extends=ExprContext)] +pub struct ExprContextLoad; + +impl ToPyObject for ExprContextLoad { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(ExprContext) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Store", extends=ExprContext)] +pub struct ExprContextStore; + +impl ToPyObject for ExprContextStore { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(ExprContext) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Del", extends=ExprContext)] +pub struct ExprContextDel; + +impl ToPyObject for ExprContextDel { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(ExprContext) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_boolop", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Boolop; + +impl From<&'static crate::Boolop> for Boolop { + fn from(_node: &'static crate::Boolop) -> Self { + Boolop + } +} + +#[pymethods] +impl Boolop { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Boolop { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_And", extends=Boolop)] +pub struct BoolopAnd; + +impl ToPyObject for BoolopAnd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Boolop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Or", extends=Boolop)] +pub struct BoolopOr; + +impl ToPyObject for BoolopOr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Boolop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_operator", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Operator; + +impl From<&'static crate::Operator> for Operator { + fn from(_node: &'static crate::Operator) -> Self { + Operator + } +} + +#[pymethods] +impl Operator { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Operator { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Add", extends=Operator)] +pub struct OperatorAdd; + +impl ToPyObject for OperatorAdd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Sub", extends=Operator)] +pub struct OperatorSub; + +impl ToPyObject for OperatorSub { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Mult", extends=Operator)] +pub struct OperatorMult; + +impl ToPyObject for OperatorMult { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatMult", extends=Operator)] +pub struct OperatorMatMult; + +impl ToPyObject for OperatorMatMult { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Div", extends=Operator)] +pub struct OperatorDiv; + +impl ToPyObject for OperatorDiv { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Mod", extends=Operator)] +pub struct OperatorMod; + +impl ToPyObject for OperatorMod { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Pow", extends=Operator)] +pub struct OperatorPow; + +impl ToPyObject for OperatorPow { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_LShift", extends=Operator)] +pub struct OperatorLShift; + +impl ToPyObject for OperatorLShift { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_RShift", extends=Operator)] +pub struct OperatorRShift; + +impl ToPyObject for OperatorRShift { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_BitOr", extends=Operator)] +pub struct OperatorBitOr; + +impl ToPyObject for OperatorBitOr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_BitXor", extends=Operator)] +pub struct OperatorBitXor; + +impl ToPyObject for OperatorBitXor { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_BitAnd", extends=Operator)] +pub struct OperatorBitAnd; + +impl ToPyObject for OperatorBitAnd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_FloorDiv", extends=Operator)] +pub struct OperatorFloorDiv; + +impl ToPyObject for OperatorFloorDiv { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_unaryop", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Unaryop; + +impl From<&'static crate::Unaryop> for Unaryop { + fn from(_node: &'static crate::Unaryop) -> Self { + Unaryop + } +} + +#[pymethods] +impl Unaryop { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Unaryop { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Invert", extends=Unaryop)] +pub struct UnaryopInvert; + +impl ToPyObject for UnaryopInvert { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Unaryop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Not", extends=Unaryop)] +pub struct UnaryopNot; + +impl ToPyObject for UnaryopNot { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Unaryop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_UAdd", extends=Unaryop)] +pub struct UnaryopUAdd; + +impl ToPyObject for UnaryopUAdd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Unaryop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_USub", extends=Unaryop)] +pub struct UnaryopUSub; + +impl ToPyObject for UnaryopUSub { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Unaryop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_cmpop", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Cmpop; + +impl From<&'static crate::Cmpop> for Cmpop { + fn from(_node: &'static crate::Cmpop) -> Self { + Cmpop + } +} + +#[pymethods] +impl Cmpop { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Cmpop { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Eq", extends=Cmpop)] +pub struct CmpopEq; + +impl ToPyObject for CmpopEq { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_NotEq", extends=Cmpop)] +pub struct CmpopNotEq; + +impl ToPyObject for CmpopNotEq { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Lt", extends=Cmpop)] +pub struct CmpopLt; + +impl ToPyObject for CmpopLt { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_LtE", extends=Cmpop)] +pub struct CmpopLtE; + +impl ToPyObject for CmpopLtE { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Gt", extends=Cmpop)] +pub struct CmpopGt; + +impl ToPyObject for CmpopGt { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_GtE", extends=Cmpop)] +pub struct CmpopGtE; + +impl ToPyObject for CmpopGtE { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Is", extends=Cmpop)] +pub struct CmpopIs; + +impl ToPyObject for CmpopIs { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_IsNot", extends=Cmpop)] +pub struct CmpopIsNot; + +impl ToPyObject for CmpopIsNot { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_In", extends=Cmpop)] +pub struct CmpopIn; + +impl ToPyObject for CmpopIn { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_NotIn", extends=Cmpop)] +pub struct CmpopNotIn; + +impl ToPyObject for CmpopNotIn { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_comprehension", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct Comprehension(pub &'static crate::Comprehension); + +impl From<&'static crate::Comprehension> for Comprehension { + fn from(node: &'static crate::Comprehension) -> Self { + Comprehension(node) + } +} + +impl ToPyObject for Comprehension { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Comprehension { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Comprehension(self).to_object(py)) + } +} + +#[pymethods] +impl Comprehension { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_iter(&self, py: Python) -> PyResult { + self.0.iter.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ifs(&self, py: Python) -> PyResult { + self.0.ifs.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_is_async(&self, py: Python) -> PyResult { + self.0.is_async.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_excepthandler", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Excepthandler; + +impl From<&'static crate::Excepthandler> for Excepthandler { + fn from(_node: &'static crate::Excepthandler) -> Self { + Excepthandler + } +} + +#[pymethods] +impl Excepthandler { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Excepthandler { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Excepthandler { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::ExceptHandler(cons) => cons.to_pyo3_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.located", name="_ExceptHandler", extends=Excepthandler, frozen)] +#[derive(Clone, Debug)] +pub struct ExcepthandlerExceptHandler(pub &'static crate::ExcepthandlerExceptHandler); + +impl From<&'static crate::ExcepthandlerExceptHandler> for ExcepthandlerExceptHandler { + fn from(node: &'static crate::ExcepthandlerExceptHandler) -> Self { + ExcepthandlerExceptHandler(node) + } +} + +impl ToPyObject for ExcepthandlerExceptHandler { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Excepthandler) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExcepthandlerExceptHandler { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExcepthandlerExceptHandler(self).to_object(py)) + } +} + +#[pymethods] +impl ExcepthandlerExceptHandler { + #[getter] + #[inline] + fn get_type(&self, py: Python) -> PyResult { + self.0.type_.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_arguments", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct Arguments(pub &'static crate::Arguments); + +impl From<&'static crate::Arguments> for Arguments { + fn from(node: &'static crate::Arguments) -> Self { + Arguments(node) + } +} + +impl ToPyObject for Arguments { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Arguments { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Arguments(self).to_object(py)) + } +} + +#[pymethods] +impl Arguments { + #[getter] + #[inline] + fn get_posonlyargs(&self, py: Python) -> PyResult { + self.0.posonlyargs.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_vararg(&self, py: Python) -> PyResult { + self.0.vararg.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwonlyargs(&self, py: Python) -> PyResult { + self.0.kwonlyargs.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_kw_defaults(&self, py: Python) -> PyResult { + self.0.kw_defaults.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwarg(&self, py: Python) -> PyResult { + self.0.kwarg.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_defaults(&self, py: Python) -> PyResult { + self.0.defaults.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_arg", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct Arg(pub &'static crate::Arg); + +impl From<&'static crate::Arg> for Arg { + fn from(node: &'static crate::Arg) -> Self { + Arg(node) + } +} + +impl ToPyObject for Arg { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Arg { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Arg(self).to_object(py)) + } +} + +#[pymethods] +impl Arg { + #[getter] + #[inline] + fn get_arg(&self, py: Python) -> PyResult { + self.0.arg.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_annotation(&self, py: Python) -> PyResult { + self.0.annotation.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_keyword", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct Keyword(pub &'static crate::Keyword); + +impl From<&'static crate::Keyword> for Keyword { + fn from(node: &'static crate::Keyword) -> Self { + Keyword(node) + } +} + +impl ToPyObject for Keyword { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Keyword { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Keyword(self).to_object(py)) + } +} + +#[pymethods] +impl Keyword { + #[getter] + #[inline] + fn get_arg(&self, py: Python) -> PyResult { + self.0.arg.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_alias", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct Alias(pub &'static crate::Alias); + +impl From<&'static crate::Alias> for Alias { + fn from(node: &'static crate::Alias) -> Self { + Alias(node) + } +} + +impl ToPyObject for Alias { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Alias { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Alias(self).to_object(py)) + } +} + +#[pymethods] +impl Alias { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_asname(&self, py: Python) -> PyResult { + self.0.asname.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_withitem", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct Withitem(pub &'static crate::Withitem); + +impl From<&'static crate::Withitem> for Withitem { + fn from(node: &'static crate::Withitem) -> Self { + Withitem(node) + } +} + +impl ToPyObject for Withitem { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Withitem { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Withitem(self).to_object(py)) + } +} + +#[pymethods] +impl Withitem { + #[getter] + #[inline] + fn get_context_expr(&self, py: Python) -> PyResult { + self.0.context_expr.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_optional_vars(&self, py: Python) -> PyResult { + self.0.optional_vars.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_match_case", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct MatchCase(pub &'static crate::MatchCase); + +impl From<&'static crate::MatchCase> for MatchCase { + fn from(node: &'static crate::MatchCase) -> Self { + MatchCase(node) + } +} + +impl ToPyObject for MatchCase { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::MatchCase { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(MatchCase(self).to_object(py)) + } +} + +#[pymethods] +impl MatchCase { + #[getter] + #[inline] + fn get_pattern(&self, py: Python) -> PyResult { + self.0.pattern.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_guard(&self, py: Python) -> PyResult { + self.0.guard.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_pattern", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Pattern; + +impl From<&'static crate::Pattern> for Pattern { + fn from(_node: &'static crate::Pattern) -> Self { + Pattern + } +} + +#[pymethods] +impl Pattern { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Pattern { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Pattern { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::MatchValue(cons) => cons.to_pyo3_wrapper(py), + Self::MatchSingleton(cons) => cons.to_pyo3_wrapper(py), + Self::MatchSequence(cons) => cons.to_pyo3_wrapper(py), + Self::MatchMapping(cons) => cons.to_pyo3_wrapper(py), + Self::MatchClass(cons) => cons.to_pyo3_wrapper(py), + Self::MatchStar(cons) => cons.to_pyo3_wrapper(py), + Self::MatchAs(cons) => cons.to_pyo3_wrapper(py), + Self::MatchOr(cons) => cons.to_pyo3_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchValue", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchValue(pub &'static crate::PatternMatchValue); + +impl From<&'static crate::PatternMatchValue> for PatternMatchValue { + fn from(node: &'static crate::PatternMatchValue) -> Self { + PatternMatchValue(node) + } +} + +impl ToPyObject for PatternMatchValue { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchValue { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchValue(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchValue { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchSingleton", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchSingleton(pub &'static crate::PatternMatchSingleton); + +impl From<&'static crate::PatternMatchSingleton> for PatternMatchSingleton { + fn from(node: &'static crate::PatternMatchSingleton) -> Self { + PatternMatchSingleton(node) + } +} + +impl ToPyObject for PatternMatchSingleton { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchSingleton { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchSingleton(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchSingleton { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchSequence", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchSequence(pub &'static crate::PatternMatchSequence); + +impl From<&'static crate::PatternMatchSequence> for PatternMatchSequence { + fn from(node: &'static crate::PatternMatchSequence) -> Self { + PatternMatchSequence(node) + } +} + +impl ToPyObject for PatternMatchSequence { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchSequence { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchSequence(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchSequence { + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchMapping", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchMapping(pub &'static crate::PatternMatchMapping); + +impl From<&'static crate::PatternMatchMapping> for PatternMatchMapping { + fn from(node: &'static crate::PatternMatchMapping) -> Self { + PatternMatchMapping(node) + } +} + +impl ToPyObject for PatternMatchMapping { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchMapping { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchMapping(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchMapping { + #[getter] + #[inline] + fn get_keys(&self, py: Python) -> PyResult { + self.0.keys.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_rest(&self, py: Python) -> PyResult { + self.0.rest.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchClass", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchClass(pub &'static crate::PatternMatchClass); + +impl From<&'static crate::PatternMatchClass> for PatternMatchClass { + fn from(node: &'static crate::PatternMatchClass) -> Self { + PatternMatchClass(node) + } +} + +impl ToPyObject for PatternMatchClass { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchClass { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchClass(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchClass { + #[getter] + #[inline] + fn get_cls(&self, py: Python) -> PyResult { + self.0.cls.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwd_attrs(&self, py: Python) -> PyResult { + self.0.kwd_attrs.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwd_patterns(&self, py: Python) -> PyResult { + self.0.kwd_patterns.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchStar", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchStar(pub &'static crate::PatternMatchStar); + +impl From<&'static crate::PatternMatchStar> for PatternMatchStar { + fn from(node: &'static crate::PatternMatchStar) -> Self { + PatternMatchStar(node) + } +} + +impl ToPyObject for PatternMatchStar { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchStar { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchStar(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchStar { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchAs", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchAs(pub &'static crate::PatternMatchAs); + +impl From<&'static crate::PatternMatchAs> for PatternMatchAs { + fn from(node: &'static crate::PatternMatchAs) -> Self { + PatternMatchAs(node) + } +} + +impl ToPyObject for PatternMatchAs { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchAs { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchAs(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchAs { + #[getter] + #[inline] + fn get_pattern(&self, py: Python) -> PyResult { + self.0.pattern.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchOr", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchOr(pub &'static crate::PatternMatchOr); + +impl From<&'static crate::PatternMatchOr> for PatternMatchOr { + fn from(node: &'static crate::PatternMatchOr) -> Self { + PatternMatchOr(node) + } +} + +impl ToPyObject for PatternMatchOr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchOr { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchOr(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchOr { + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_type_ignore", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct TypeIgnore; + +impl From<&'static crate::TypeIgnore> for TypeIgnore { + fn from(_node: &'static crate::TypeIgnore) -> Self { + TypeIgnore + } +} + +#[pymethods] +impl TypeIgnore { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for TypeIgnore { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::TypeIgnore { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::TypeIgnore(cons) => cons.to_pyo3_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.located", name="_TypeIgnore", extends=TypeIgnore, frozen)] +#[derive(Clone, Debug)] +pub struct TypeIgnoreTypeIgnore(pub &'static crate::TypeIgnoreTypeIgnore); + +impl From<&'static crate::TypeIgnoreTypeIgnore> for TypeIgnoreTypeIgnore { + fn from(node: &'static crate::TypeIgnoreTypeIgnore) -> Self { + TypeIgnoreTypeIgnore(node) + } +} + +impl ToPyObject for TypeIgnoreTypeIgnore { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(TypeIgnore) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::TypeIgnoreTypeIgnore { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(TypeIgnoreTypeIgnore(self).to_object(py)) + } +} + +#[pymethods] +impl TypeIgnoreTypeIgnore { + #[getter] + #[inline] + fn get_lineno(&self, py: Python) -> PyResult { + self.0.lineno.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_tag(&self, py: Python) -> PyResult { + self.0.tag.to_pyo3_wrapper(py) + } +} + +impl ToPyo3Wrapper for crate::generic::ExprContext { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + match &self { + Self::Load => Ok(ExprContextLoad.to_object(py)), + Self::Store => Ok(ExprContextStore.to_object(py)), + Self::Del => Ok(ExprContextDel.to_object(py)), + } + } +} + +impl ToPyo3Wrapper for crate::generic::ExprContextLoad { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(ExprContextLoad.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::ExprContextStore { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(ExprContextStore.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::ExprContextDel { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(ExprContextDel.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::Boolop { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + match &self { + Self::And => Ok(BoolopAnd.to_object(py)), + Self::Or => Ok(BoolopOr.to_object(py)), + } + } +} + +impl ToPyo3Wrapper for crate::generic::BoolopAnd { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(BoolopAnd.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::BoolopOr { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(BoolopOr.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::Operator { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + match &self { + Self::Add => Ok(OperatorAdd.to_object(py)), + Self::Sub => Ok(OperatorSub.to_object(py)), + Self::Mult => Ok(OperatorMult.to_object(py)), + Self::MatMult => Ok(OperatorMatMult.to_object(py)), + Self::Div => Ok(OperatorDiv.to_object(py)), + Self::Mod => Ok(OperatorMod.to_object(py)), + Self::Pow => Ok(OperatorPow.to_object(py)), + Self::LShift => Ok(OperatorLShift.to_object(py)), + Self::RShift => Ok(OperatorRShift.to_object(py)), + Self::BitOr => Ok(OperatorBitOr.to_object(py)), + Self::BitXor => Ok(OperatorBitXor.to_object(py)), + Self::BitAnd => Ok(OperatorBitAnd.to_object(py)), + Self::FloorDiv => Ok(OperatorFloorDiv.to_object(py)), + } + } +} + +impl ToPyo3Wrapper for crate::generic::OperatorAdd { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorAdd.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::OperatorSub { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorSub.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::OperatorMult { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorMult.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::OperatorMatMult { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorMatMult.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::OperatorDiv { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorDiv.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::OperatorMod { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorMod.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::OperatorPow { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorPow.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::OperatorLShift { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorLShift.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::OperatorRShift { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorRShift.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::OperatorBitOr { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorBitOr.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::OperatorBitXor { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorBitXor.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::OperatorBitAnd { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorBitAnd.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::OperatorFloorDiv { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorFloorDiv.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::Unaryop { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + match &self { + Self::Invert => Ok(UnaryopInvert.to_object(py)), + Self::Not => Ok(UnaryopNot.to_object(py)), + Self::UAdd => Ok(UnaryopUAdd.to_object(py)), + Self::USub => Ok(UnaryopUSub.to_object(py)), + } + } +} + +impl ToPyo3Wrapper for crate::generic::UnaryopInvert { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(UnaryopInvert.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::UnaryopNot { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(UnaryopNot.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::UnaryopUAdd { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(UnaryopUAdd.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::UnaryopUSub { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(UnaryopUSub.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::Cmpop { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + match &self { + Self::Eq => Ok(CmpopEq.to_object(py)), + Self::NotEq => Ok(CmpopNotEq.to_object(py)), + Self::Lt => Ok(CmpopLt.to_object(py)), + Self::LtE => Ok(CmpopLtE.to_object(py)), + Self::Gt => Ok(CmpopGt.to_object(py)), + Self::GtE => Ok(CmpopGtE.to_object(py)), + Self::Is => Ok(CmpopIs.to_object(py)), + Self::IsNot => Ok(CmpopIsNot.to_object(py)), + Self::In => Ok(CmpopIn.to_object(py)), + Self::NotIn => Ok(CmpopNotIn.to_object(py)), + } + } +} + +impl ToPyo3Wrapper for crate::generic::CmpopEq { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpopEq.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::CmpopNotEq { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpopNotEq.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::CmpopLt { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpopLt.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::CmpopLtE { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpopLtE.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::CmpopGt { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpopGt.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::CmpopGtE { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpopGtE.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::CmpopIs { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpopIs.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::CmpopIsNot { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpopIsNot.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::CmpopIn { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpopIn.to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::generic::CmpopNotIn { + #[inline] + fn to_pyo3_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpopNotIn.to_object(py)) + } +} + +pub fn add_to_module(py: Python, m: &PyModule) -> PyResult<()> { + super::init_module(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::( + py, m, + )?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + Ok(()) +} diff --git a/ast/src/gen/pyo3_wrapper_ranged.rs b/ast/src/gen/pyo3_wrapper_ranged.rs new file mode 100644 index 00000000..dfa0a30a --- /dev/null +++ b/ast/src/gen/pyo3_wrapper_ranged.rs @@ -0,0 +1,4119 @@ +// File automatically generated by ast/asdl_rs.py. + +#[pyclass(module="rustpython_ast.ranged", name="_mod", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Mod; + +impl From<&'static crate::Mod> for Mod { + fn from(_node: &'static crate::Mod) -> Self { + Mod + } +} + +#[pymethods] +impl Mod { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Mod { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Mod { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::Module(cons) => cons.to_pyo3_wrapper(py), + Self::Interactive(cons) => cons.to_pyo3_wrapper(py), + Self::Expression(cons) => cons.to_pyo3_wrapper(py), + Self::FunctionType(cons) => cons.to_pyo3_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Module", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModModule(pub &'static crate::ModModule); + +impl From<&'static crate::ModModule> for ModModule { + fn from(node: &'static crate::ModModule) -> Self { + ModModule(node) + } +} + +impl ToPyObject for ModModule { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ModModule { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModModule(self).to_object(py)) + } +} + +#[pymethods] +impl ModModule { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_ignores(&self, py: Python) -> PyResult { + self.0.type_ignores.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Interactive", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModInteractive(pub &'static crate::ModInteractive); + +impl From<&'static crate::ModInteractive> for ModInteractive { + fn from(node: &'static crate::ModInteractive) -> Self { + ModInteractive(node) + } +} + +impl ToPyObject for ModInteractive { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ModInteractive { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModInteractive(self).to_object(py)) + } +} + +#[pymethods] +impl ModInteractive { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Expression", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModExpression(pub &'static crate::ModExpression); + +impl From<&'static crate::ModExpression> for ModExpression { + fn from(node: &'static crate::ModExpression) -> Self { + ModExpression(node) + } +} + +impl ToPyObject for ModExpression { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ModExpression { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModExpression(self).to_object(py)) + } +} + +#[pymethods] +impl ModExpression { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_FunctionType", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModFunctionType(pub &'static crate::ModFunctionType); + +impl From<&'static crate::ModFunctionType> for ModFunctionType { + fn from(node: &'static crate::ModFunctionType) -> Self { + ModFunctionType(node) + } +} + +impl ToPyObject for ModFunctionType { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ModFunctionType { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModFunctionType(self).to_object(py)) + } +} + +#[pymethods] +impl ModFunctionType { + #[getter] + #[inline] + fn get_argtypes(&self, py: Python) -> PyResult { + self.0.argtypes.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_returns(&self, py: Python) -> PyResult { + self.0.returns.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_stmt", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Stmt; + +impl From<&'static crate::Stmt> for Stmt { + fn from(_node: &'static crate::Stmt) -> Self { + Stmt + } +} + +#[pymethods] +impl Stmt { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Stmt { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Stmt { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::FunctionDef(cons) => cons.to_pyo3_wrapper(py), + Self::AsyncFunctionDef(cons) => cons.to_pyo3_wrapper(py), + Self::ClassDef(cons) => cons.to_pyo3_wrapper(py), + Self::Return(cons) => cons.to_pyo3_wrapper(py), + Self::Delete(cons) => cons.to_pyo3_wrapper(py), + Self::Assign(cons) => cons.to_pyo3_wrapper(py), + Self::AugAssign(cons) => cons.to_pyo3_wrapper(py), + Self::AnnAssign(cons) => cons.to_pyo3_wrapper(py), + Self::For(cons) => cons.to_pyo3_wrapper(py), + Self::AsyncFor(cons) => cons.to_pyo3_wrapper(py), + Self::While(cons) => cons.to_pyo3_wrapper(py), + Self::If(cons) => cons.to_pyo3_wrapper(py), + Self::With(cons) => cons.to_pyo3_wrapper(py), + Self::AsyncWith(cons) => cons.to_pyo3_wrapper(py), + Self::Match(cons) => cons.to_pyo3_wrapper(py), + Self::Raise(cons) => cons.to_pyo3_wrapper(py), + Self::Try(cons) => cons.to_pyo3_wrapper(py), + Self::TryStar(cons) => cons.to_pyo3_wrapper(py), + Self::Assert(cons) => cons.to_pyo3_wrapper(py), + Self::Import(cons) => cons.to_pyo3_wrapper(py), + Self::ImportFrom(cons) => cons.to_pyo3_wrapper(py), + Self::Global(cons) => cons.to_pyo3_wrapper(py), + Self::Nonlocal(cons) => cons.to_pyo3_wrapper(py), + Self::Expr(cons) => cons.to_pyo3_wrapper(py), + Self::Pass(cons) => cons.to_pyo3_wrapper(py), + Self::Break(cons) => cons.to_pyo3_wrapper(py), + Self::Continue(cons) => cons.to_pyo3_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_FunctionDef", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtFunctionDef(pub &'static crate::StmtFunctionDef); + +impl From<&'static crate::StmtFunctionDef> for StmtFunctionDef { + fn from(node: &'static crate::StmtFunctionDef) -> Self { + StmtFunctionDef(node) + } +} + +impl ToPyObject for StmtFunctionDef { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtFunctionDef { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtFunctionDef(self).to_object(py)) + } +} + +#[pymethods] +impl StmtFunctionDef { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_decorator_list(&self, py: Python) -> PyResult { + self.0.decorator_list.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_returns(&self, py: Python) -> PyResult { + self.0.returns.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_AsyncFunctionDef", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAsyncFunctionDef(pub &'static crate::StmtAsyncFunctionDef); + +impl From<&'static crate::StmtAsyncFunctionDef> for StmtAsyncFunctionDef { + fn from(node: &'static crate::StmtAsyncFunctionDef) -> Self { + StmtAsyncFunctionDef(node) + } +} + +impl ToPyObject for StmtAsyncFunctionDef { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAsyncFunctionDef { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAsyncFunctionDef(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAsyncFunctionDef { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_decorator_list(&self, py: Python) -> PyResult { + self.0.decorator_list.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_returns(&self, py: Python) -> PyResult { + self.0.returns.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_ClassDef", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtClassDef(pub &'static crate::StmtClassDef); + +impl From<&'static crate::StmtClassDef> for StmtClassDef { + fn from(node: &'static crate::StmtClassDef) -> Self { + StmtClassDef(node) + } +} + +impl ToPyObject for StmtClassDef { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtClassDef { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtClassDef(self).to_object(py)) + } +} + +#[pymethods] +impl StmtClassDef { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_bases(&self, py: Python) -> PyResult { + self.0.bases.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_keywords(&self, py: Python) -> PyResult { + self.0.keywords.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_decorator_list(&self, py: Python) -> PyResult { + self.0.decorator_list.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Return", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtReturn(pub &'static crate::StmtReturn); + +impl From<&'static crate::StmtReturn> for StmtReturn { + fn from(node: &'static crate::StmtReturn) -> Self { + StmtReturn(node) + } +} + +impl ToPyObject for StmtReturn { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtReturn { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtReturn(self).to_object(py)) + } +} + +#[pymethods] +impl StmtReturn { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Delete", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtDelete(pub &'static crate::StmtDelete); + +impl From<&'static crate::StmtDelete> for StmtDelete { + fn from(node: &'static crate::StmtDelete) -> Self { + StmtDelete(node) + } +} + +impl ToPyObject for StmtDelete { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtDelete { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtDelete(self).to_object(py)) + } +} + +#[pymethods] +impl StmtDelete { + #[getter] + #[inline] + fn get_targets(&self, py: Python) -> PyResult { + self.0.targets.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Assign", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAssign(pub &'static crate::StmtAssign); + +impl From<&'static crate::StmtAssign> for StmtAssign { + fn from(node: &'static crate::StmtAssign) -> Self { + StmtAssign(node) + } +} + +impl ToPyObject for StmtAssign { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAssign { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAssign(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAssign { + #[getter] + #[inline] + fn get_targets(&self, py: Python) -> PyResult { + self.0.targets.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_AugAssign", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAugAssign(pub &'static crate::StmtAugAssign); + +impl From<&'static crate::StmtAugAssign> for StmtAugAssign { + fn from(node: &'static crate::StmtAugAssign) -> Self { + StmtAugAssign(node) + } +} + +impl ToPyObject for StmtAugAssign { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAugAssign { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAugAssign(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAugAssign { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_AnnAssign", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAnnAssign(pub &'static crate::StmtAnnAssign); + +impl From<&'static crate::StmtAnnAssign> for StmtAnnAssign { + fn from(node: &'static crate::StmtAnnAssign) -> Self { + StmtAnnAssign(node) + } +} + +impl ToPyObject for StmtAnnAssign { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAnnAssign { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAnnAssign(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAnnAssign { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_annotation(&self, py: Python) -> PyResult { + self.0.annotation.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_simple(&self, py: Python) -> PyResult { + self.0.simple.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_For", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtFor(pub &'static crate::StmtFor); + +impl From<&'static crate::StmtFor> for StmtFor { + fn from(node: &'static crate::StmtFor) -> Self { + StmtFor(node) + } +} + +impl ToPyObject for StmtFor { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtFor { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtFor(self).to_object(py)) + } +} + +#[pymethods] +impl StmtFor { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_iter(&self, py: Python) -> PyResult { + self.0.iter.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_AsyncFor", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAsyncFor(pub &'static crate::StmtAsyncFor); + +impl From<&'static crate::StmtAsyncFor> for StmtAsyncFor { + fn from(node: &'static crate::StmtAsyncFor) -> Self { + StmtAsyncFor(node) + } +} + +impl ToPyObject for StmtAsyncFor { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAsyncFor { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAsyncFor(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAsyncFor { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_iter(&self, py: Python) -> PyResult { + self.0.iter.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_While", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtWhile(pub &'static crate::StmtWhile); + +impl From<&'static crate::StmtWhile> for StmtWhile { + fn from(node: &'static crate::StmtWhile) -> Self { + StmtWhile(node) + } +} + +impl ToPyObject for StmtWhile { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtWhile { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtWhile(self).to_object(py)) + } +} + +#[pymethods] +impl StmtWhile { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_If", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtIf(pub &'static crate::StmtIf); + +impl From<&'static crate::StmtIf> for StmtIf { + fn from(node: &'static crate::StmtIf) -> Self { + StmtIf(node) + } +} + +impl ToPyObject for StmtIf { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtIf { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtIf(self).to_object(py)) + } +} + +#[pymethods] +impl StmtIf { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_With", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtWith(pub &'static crate::StmtWith); + +impl From<&'static crate::StmtWith> for StmtWith { + fn from(node: &'static crate::StmtWith) -> Self { + StmtWith(node) + } +} + +impl ToPyObject for StmtWith { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtWith { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtWith(self).to_object(py)) + } +} + +#[pymethods] +impl StmtWith { + #[getter] + #[inline] + fn get_items(&self, py: Python) -> PyResult { + self.0.items.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_AsyncWith", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAsyncWith(pub &'static crate::StmtAsyncWith); + +impl From<&'static crate::StmtAsyncWith> for StmtAsyncWith { + fn from(node: &'static crate::StmtAsyncWith) -> Self { + StmtAsyncWith(node) + } +} + +impl ToPyObject for StmtAsyncWith { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAsyncWith { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAsyncWith(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAsyncWith { + #[getter] + #[inline] + fn get_items(&self, py: Python) -> PyResult { + self.0.items.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Match", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtMatch(pub &'static crate::StmtMatch); + +impl From<&'static crate::StmtMatch> for StmtMatch { + fn from(node: &'static crate::StmtMatch) -> Self { + StmtMatch(node) + } +} + +impl ToPyObject for StmtMatch { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtMatch { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtMatch(self).to_object(py)) + } +} + +#[pymethods] +impl StmtMatch { + #[getter] + #[inline] + fn get_subject(&self, py: Python) -> PyResult { + self.0.subject.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_cases(&self, py: Python) -> PyResult { + self.0.cases.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Raise", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtRaise(pub &'static crate::StmtRaise); + +impl From<&'static crate::StmtRaise> for StmtRaise { + fn from(node: &'static crate::StmtRaise) -> Self { + StmtRaise(node) + } +} + +impl ToPyObject for StmtRaise { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtRaise { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtRaise(self).to_object(py)) + } +} + +#[pymethods] +impl StmtRaise { + #[getter] + #[inline] + fn get_exc(&self, py: Python) -> PyResult { + self.0.exc.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_cause(&self, py: Python) -> PyResult { + self.0.cause.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Try", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtTry(pub &'static crate::StmtTry); + +impl From<&'static crate::StmtTry> for StmtTry { + fn from(node: &'static crate::StmtTry) -> Self { + StmtTry(node) + } +} + +impl ToPyObject for StmtTry { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtTry { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtTry(self).to_object(py)) + } +} + +#[pymethods] +impl StmtTry { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_handlers(&self, py: Python) -> PyResult { + self.0.handlers.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_finalbody(&self, py: Python) -> PyResult { + self.0.finalbody.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_TryStar", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtTryStar(pub &'static crate::StmtTryStar); + +impl From<&'static crate::StmtTryStar> for StmtTryStar { + fn from(node: &'static crate::StmtTryStar) -> Self { + StmtTryStar(node) + } +} + +impl ToPyObject for StmtTryStar { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtTryStar { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtTryStar(self).to_object(py)) + } +} + +#[pymethods] +impl StmtTryStar { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_handlers(&self, py: Python) -> PyResult { + self.0.handlers.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_finalbody(&self, py: Python) -> PyResult { + self.0.finalbody.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Assert", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAssert(pub &'static crate::StmtAssert); + +impl From<&'static crate::StmtAssert> for StmtAssert { + fn from(node: &'static crate::StmtAssert) -> Self { + StmtAssert(node) + } +} + +impl ToPyObject for StmtAssert { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtAssert { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAssert(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAssert { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_msg(&self, py: Python) -> PyResult { + self.0.msg.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Import", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtImport(pub &'static crate::StmtImport); + +impl From<&'static crate::StmtImport> for StmtImport { + fn from(node: &'static crate::StmtImport) -> Self { + StmtImport(node) + } +} + +impl ToPyObject for StmtImport { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtImport { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtImport(self).to_object(py)) + } +} + +#[pymethods] +impl StmtImport { + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_ImportFrom", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtImportFrom(pub &'static crate::StmtImportFrom); + +impl From<&'static crate::StmtImportFrom> for StmtImportFrom { + fn from(node: &'static crate::StmtImportFrom) -> Self { + StmtImportFrom(node) + } +} + +impl ToPyObject for StmtImportFrom { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtImportFrom { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtImportFrom(self).to_object(py)) + } +} + +#[pymethods] +impl StmtImportFrom { + #[getter] + #[inline] + fn get_module(&self, py: Python) -> PyResult { + self.0.module.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_level(&self, py: Python) -> PyResult { + self.0.level.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Global", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtGlobal(pub &'static crate::StmtGlobal); + +impl From<&'static crate::StmtGlobal> for StmtGlobal { + fn from(node: &'static crate::StmtGlobal) -> Self { + StmtGlobal(node) + } +} + +impl ToPyObject for StmtGlobal { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtGlobal { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtGlobal(self).to_object(py)) + } +} + +#[pymethods] +impl StmtGlobal { + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Nonlocal", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtNonlocal(pub &'static crate::StmtNonlocal); + +impl From<&'static crate::StmtNonlocal> for StmtNonlocal { + fn from(node: &'static crate::StmtNonlocal) -> Self { + StmtNonlocal(node) + } +} + +impl ToPyObject for StmtNonlocal { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtNonlocal { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtNonlocal(self).to_object(py)) + } +} + +#[pymethods] +impl StmtNonlocal { + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Expr", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtExpr(pub &'static crate::StmtExpr); + +impl From<&'static crate::StmtExpr> for StmtExpr { + fn from(node: &'static crate::StmtExpr) -> Self { + StmtExpr(node) + } +} + +impl ToPyObject for StmtExpr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtExpr { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtExpr(self).to_object(py)) + } +} + +#[pymethods] +impl StmtExpr { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Pass", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtPass(pub &'static crate::StmtPass); + +impl From<&'static crate::StmtPass> for StmtPass { + fn from(node: &'static crate::StmtPass) -> Self { + StmtPass(node) + } +} + +impl ToPyObject for StmtPass { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtPass { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtPass(self).to_object(py)) + } +} + +#[pymethods] +impl StmtPass {} + +#[pyclass(module="rustpython_ast.ranged", name="_Break", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtBreak(pub &'static crate::StmtBreak); + +impl From<&'static crate::StmtBreak> for StmtBreak { + fn from(node: &'static crate::StmtBreak) -> Self { + StmtBreak(node) + } +} + +impl ToPyObject for StmtBreak { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtBreak { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtBreak(self).to_object(py)) + } +} + +#[pymethods] +impl StmtBreak {} + +#[pyclass(module="rustpython_ast.ranged", name="_Continue", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtContinue(pub &'static crate::StmtContinue); + +impl From<&'static crate::StmtContinue> for StmtContinue { + fn from(node: &'static crate::StmtContinue) -> Self { + StmtContinue(node) + } +} + +impl ToPyObject for StmtContinue { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::StmtContinue { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtContinue(self).to_object(py)) + } +} + +#[pymethods] +impl StmtContinue {} + +#[pyclass(module="rustpython_ast.ranged", name="_expr", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Expr; + +impl From<&'static crate::Expr> for Expr { + fn from(_node: &'static crate::Expr) -> Self { + Expr + } +} + +#[pymethods] +impl Expr { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Expr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Expr { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::BoolOp(cons) => cons.to_pyo3_wrapper(py), + Self::NamedExpr(cons) => cons.to_pyo3_wrapper(py), + Self::BinOp(cons) => cons.to_pyo3_wrapper(py), + Self::UnaryOp(cons) => cons.to_pyo3_wrapper(py), + Self::Lambda(cons) => cons.to_pyo3_wrapper(py), + Self::IfExp(cons) => cons.to_pyo3_wrapper(py), + Self::Dict(cons) => cons.to_pyo3_wrapper(py), + Self::Set(cons) => cons.to_pyo3_wrapper(py), + Self::ListComp(cons) => cons.to_pyo3_wrapper(py), + Self::SetComp(cons) => cons.to_pyo3_wrapper(py), + Self::DictComp(cons) => cons.to_pyo3_wrapper(py), + Self::GeneratorExp(cons) => cons.to_pyo3_wrapper(py), + Self::Await(cons) => cons.to_pyo3_wrapper(py), + Self::Yield(cons) => cons.to_pyo3_wrapper(py), + Self::YieldFrom(cons) => cons.to_pyo3_wrapper(py), + Self::Compare(cons) => cons.to_pyo3_wrapper(py), + Self::Call(cons) => cons.to_pyo3_wrapper(py), + Self::FormattedValue(cons) => cons.to_pyo3_wrapper(py), + Self::JoinedStr(cons) => cons.to_pyo3_wrapper(py), + Self::Constant(cons) => cons.to_pyo3_wrapper(py), + Self::Attribute(cons) => cons.to_pyo3_wrapper(py), + Self::Subscript(cons) => cons.to_pyo3_wrapper(py), + Self::Starred(cons) => cons.to_pyo3_wrapper(py), + Self::Name(cons) => cons.to_pyo3_wrapper(py), + Self::List(cons) => cons.to_pyo3_wrapper(py), + Self::Tuple(cons) => cons.to_pyo3_wrapper(py), + Self::Slice(cons) => cons.to_pyo3_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_BoolOp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprBoolOp(pub &'static crate::ExprBoolOp); + +impl From<&'static crate::ExprBoolOp> for ExprBoolOp { + fn from(node: &'static crate::ExprBoolOp) -> Self { + ExprBoolOp(node) + } +} + +impl ToPyObject for ExprBoolOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprBoolOp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprBoolOp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprBoolOp { + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_values(&self, py: Python) -> PyResult { + self.0.values.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_NamedExpr", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprNamedExpr(pub &'static crate::ExprNamedExpr); + +impl From<&'static crate::ExprNamedExpr> for ExprNamedExpr { + fn from(node: &'static crate::ExprNamedExpr) -> Self { + ExprNamedExpr(node) + } +} + +impl ToPyObject for ExprNamedExpr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprNamedExpr { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprNamedExpr(self).to_object(py)) + } +} + +#[pymethods] +impl ExprNamedExpr { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_BinOp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprBinOp(pub &'static crate::ExprBinOp); + +impl From<&'static crate::ExprBinOp> for ExprBinOp { + fn from(node: &'static crate::ExprBinOp) -> Self { + ExprBinOp(node) + } +} + +impl ToPyObject for ExprBinOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprBinOp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprBinOp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprBinOp { + #[getter] + #[inline] + fn get_left(&self, py: Python) -> PyResult { + self.0.left.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_right(&self, py: Python) -> PyResult { + self.0.right.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_UnaryOp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprUnaryOp(pub &'static crate::ExprUnaryOp); + +impl From<&'static crate::ExprUnaryOp> for ExprUnaryOp { + fn from(node: &'static crate::ExprUnaryOp) -> Self { + ExprUnaryOp(node) + } +} + +impl ToPyObject for ExprUnaryOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprUnaryOp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprUnaryOp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprUnaryOp { + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_operand(&self, py: Python) -> PyResult { + self.0.operand.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Lambda", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprLambda(pub &'static crate::ExprLambda); + +impl From<&'static crate::ExprLambda> for ExprLambda { + fn from(node: &'static crate::ExprLambda) -> Self { + ExprLambda(node) + } +} + +impl ToPyObject for ExprLambda { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprLambda { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprLambda(self).to_object(py)) + } +} + +#[pymethods] +impl ExprLambda { + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_IfExp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprIfExp(pub &'static crate::ExprIfExp); + +impl From<&'static crate::ExprIfExp> for ExprIfExp { + fn from(node: &'static crate::ExprIfExp) -> Self { + ExprIfExp(node) + } +} + +impl ToPyObject for ExprIfExp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprIfExp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprIfExp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprIfExp { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Dict", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprDict(pub &'static crate::ExprDict); + +impl From<&'static crate::ExprDict> for ExprDict { + fn from(node: &'static crate::ExprDict) -> Self { + ExprDict(node) + } +} + +impl ToPyObject for ExprDict { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprDict { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprDict(self).to_object(py)) + } +} + +#[pymethods] +impl ExprDict { + #[getter] + #[inline] + fn get_keys(&self, py: Python) -> PyResult { + self.0.keys.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_values(&self, py: Python) -> PyResult { + self.0.values.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Set", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSet(pub &'static crate::ExprSet); + +impl From<&'static crate::ExprSet> for ExprSet { + fn from(node: &'static crate::ExprSet) -> Self { + ExprSet(node) + } +} + +impl ToPyObject for ExprSet { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprSet { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSet(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSet { + #[getter] + #[inline] + fn get_elts(&self, py: Python) -> PyResult { + self.0.elts.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_ListComp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprListComp(pub &'static crate::ExprListComp); + +impl From<&'static crate::ExprListComp> for ExprListComp { + fn from(node: &'static crate::ExprListComp) -> Self { + ExprListComp(node) + } +} + +impl ToPyObject for ExprListComp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprListComp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprListComp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprListComp { + #[getter] + #[inline] + fn get_elt(&self, py: Python) -> PyResult { + self.0.elt.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_SetComp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSetComp(pub &'static crate::ExprSetComp); + +impl From<&'static crate::ExprSetComp> for ExprSetComp { + fn from(node: &'static crate::ExprSetComp) -> Self { + ExprSetComp(node) + } +} + +impl ToPyObject for ExprSetComp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprSetComp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSetComp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSetComp { + #[getter] + #[inline] + fn get_elt(&self, py: Python) -> PyResult { + self.0.elt.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_DictComp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprDictComp(pub &'static crate::ExprDictComp); + +impl From<&'static crate::ExprDictComp> for ExprDictComp { + fn from(node: &'static crate::ExprDictComp) -> Self { + ExprDictComp(node) + } +} + +impl ToPyObject for ExprDictComp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprDictComp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprDictComp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprDictComp { + #[getter] + #[inline] + fn get_key(&self, py: Python) -> PyResult { + self.0.key.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_GeneratorExp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprGeneratorExp(pub &'static crate::ExprGeneratorExp); + +impl From<&'static crate::ExprGeneratorExp> for ExprGeneratorExp { + fn from(node: &'static crate::ExprGeneratorExp) -> Self { + ExprGeneratorExp(node) + } +} + +impl ToPyObject for ExprGeneratorExp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprGeneratorExp { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprGeneratorExp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprGeneratorExp { + #[getter] + #[inline] + fn get_elt(&self, py: Python) -> PyResult { + self.0.elt.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Await", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprAwait(pub &'static crate::ExprAwait); + +impl From<&'static crate::ExprAwait> for ExprAwait { + fn from(node: &'static crate::ExprAwait) -> Self { + ExprAwait(node) + } +} + +impl ToPyObject for ExprAwait { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprAwait { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprAwait(self).to_object(py)) + } +} + +#[pymethods] +impl ExprAwait { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Yield", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprYield(pub &'static crate::ExprYield); + +impl From<&'static crate::ExprYield> for ExprYield { + fn from(node: &'static crate::ExprYield) -> Self { + ExprYield(node) + } +} + +impl ToPyObject for ExprYield { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprYield { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprYield(self).to_object(py)) + } +} + +#[pymethods] +impl ExprYield { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_YieldFrom", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprYieldFrom(pub &'static crate::ExprYieldFrom); + +impl From<&'static crate::ExprYieldFrom> for ExprYieldFrom { + fn from(node: &'static crate::ExprYieldFrom) -> Self { + ExprYieldFrom(node) + } +} + +impl ToPyObject for ExprYieldFrom { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprYieldFrom { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprYieldFrom(self).to_object(py)) + } +} + +#[pymethods] +impl ExprYieldFrom { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Compare", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprCompare(pub &'static crate::ExprCompare); + +impl From<&'static crate::ExprCompare> for ExprCompare { + fn from(node: &'static crate::ExprCompare) -> Self { + ExprCompare(node) + } +} + +impl ToPyObject for ExprCompare { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprCompare { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprCompare(self).to_object(py)) + } +} + +#[pymethods] +impl ExprCompare { + #[getter] + #[inline] + fn get_left(&self, py: Python) -> PyResult { + self.0.left.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ops(&self, py: Python) -> PyResult { + self.0.ops.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_comparators(&self, py: Python) -> PyResult { + self.0.comparators.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Call", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprCall(pub &'static crate::ExprCall); + +impl From<&'static crate::ExprCall> for ExprCall { + fn from(node: &'static crate::ExprCall) -> Self { + ExprCall(node) + } +} + +impl ToPyObject for ExprCall { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprCall { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprCall(self).to_object(py)) + } +} + +#[pymethods] +impl ExprCall { + #[getter] + #[inline] + fn get_func(&self, py: Python) -> PyResult { + self.0.func.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_keywords(&self, py: Python) -> PyResult { + self.0.keywords.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_FormattedValue", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprFormattedValue(pub &'static crate::ExprFormattedValue); + +impl From<&'static crate::ExprFormattedValue> for ExprFormattedValue { + fn from(node: &'static crate::ExprFormattedValue) -> Self { + ExprFormattedValue(node) + } +} + +impl ToPyObject for ExprFormattedValue { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprFormattedValue { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprFormattedValue(self).to_object(py)) + } +} + +#[pymethods] +impl ExprFormattedValue { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_conversion(&self, py: Python) -> PyResult { + self.0.conversion.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_format_spec(&self, py: Python) -> PyResult { + self.0.format_spec.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_JoinedStr", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprJoinedStr(pub &'static crate::ExprJoinedStr); + +impl From<&'static crate::ExprJoinedStr> for ExprJoinedStr { + fn from(node: &'static crate::ExprJoinedStr) -> Self { + ExprJoinedStr(node) + } +} + +impl ToPyObject for ExprJoinedStr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprJoinedStr { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprJoinedStr(self).to_object(py)) + } +} + +#[pymethods] +impl ExprJoinedStr { + #[getter] + #[inline] + fn get_values(&self, py: Python) -> PyResult { + self.0.values.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Constant", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprConstant(pub &'static crate::ExprConstant); + +impl From<&'static crate::ExprConstant> for ExprConstant { + fn from(node: &'static crate::ExprConstant) -> Self { + ExprConstant(node) + } +} + +impl ToPyObject for ExprConstant { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprConstant { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprConstant(self).to_object(py)) + } +} + +#[pymethods] +impl ExprConstant { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_kind(&self, py: Python) -> PyResult { + self.0.kind.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Attribute", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprAttribute(pub &'static crate::ExprAttribute); + +impl From<&'static crate::ExprAttribute> for ExprAttribute { + fn from(node: &'static crate::ExprAttribute) -> Self { + ExprAttribute(node) + } +} + +impl ToPyObject for ExprAttribute { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprAttribute { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprAttribute(self).to_object(py)) + } +} + +#[pymethods] +impl ExprAttribute { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_attr(&self, py: Python) -> PyResult { + self.0.attr.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Subscript", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSubscript(pub &'static crate::ExprSubscript); + +impl From<&'static crate::ExprSubscript> for ExprSubscript { + fn from(node: &'static crate::ExprSubscript) -> Self { + ExprSubscript(node) + } +} + +impl ToPyObject for ExprSubscript { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprSubscript { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSubscript(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSubscript { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_slice(&self, py: Python) -> PyResult { + self.0.slice.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Starred", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprStarred(pub &'static crate::ExprStarred); + +impl From<&'static crate::ExprStarred> for ExprStarred { + fn from(node: &'static crate::ExprStarred) -> Self { + ExprStarred(node) + } +} + +impl ToPyObject for ExprStarred { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprStarred { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprStarred(self).to_object(py)) + } +} + +#[pymethods] +impl ExprStarred { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Name", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprName(pub &'static crate::ExprName); + +impl From<&'static crate::ExprName> for ExprName { + fn from(node: &'static crate::ExprName) -> Self { + ExprName(node) + } +} + +impl ToPyObject for ExprName { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprName { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprName(self).to_object(py)) + } +} + +#[pymethods] +impl ExprName { + #[getter] + #[inline] + fn get_id(&self, py: Python) -> PyResult { + self.0.id.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_List", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprList(pub &'static crate::ExprList); + +impl From<&'static crate::ExprList> for ExprList { + fn from(node: &'static crate::ExprList) -> Self { + ExprList(node) + } +} + +impl ToPyObject for ExprList { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprList { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprList(self).to_object(py)) + } +} + +#[pymethods] +impl ExprList { + #[getter] + #[inline] + fn get_elts(&self, py: Python) -> PyResult { + self.0.elts.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Tuple", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprTuple(pub &'static crate::ExprTuple); + +impl From<&'static crate::ExprTuple> for ExprTuple { + fn from(node: &'static crate::ExprTuple) -> Self { + ExprTuple(node) + } +} + +impl ToPyObject for ExprTuple { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprTuple { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprTuple(self).to_object(py)) + } +} + +#[pymethods] +impl ExprTuple { + #[getter] + #[inline] + fn get_elts(&self, py: Python) -> PyResult { + self.0.elts.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Slice", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSlice(pub &'static crate::ExprSlice); + +impl From<&'static crate::ExprSlice> for ExprSlice { + fn from(node: &'static crate::ExprSlice) -> Self { + ExprSlice(node) + } +} + +impl ToPyObject for ExprSlice { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExprSlice { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSlice(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSlice { + #[getter] + #[inline] + fn get_lower(&self, py: Python) -> PyResult { + self.0.lower.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_upper(&self, py: Python) -> PyResult { + self.0.upper.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_step(&self, py: Python) -> PyResult { + self.0.step.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_expr_context", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct ExprContext; + +impl From<&'static crate::ExprContext> for ExprContext { + fn from(_node: &'static crate::ExprContext) -> Self { + ExprContext + } +} + +#[pymethods] +impl ExprContext { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for ExprContext { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Load", extends=ExprContext)] +pub struct ExprContextLoad; + +impl ToPyObject for ExprContextLoad { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(ExprContext) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Store", extends=ExprContext)] +pub struct ExprContextStore; + +impl ToPyObject for ExprContextStore { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(ExprContext) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Del", extends=ExprContext)] +pub struct ExprContextDel; + +impl ToPyObject for ExprContextDel { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(ExprContext) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_boolop", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Boolop; + +impl From<&'static crate::Boolop> for Boolop { + fn from(_node: &'static crate::Boolop) -> Self { + Boolop + } +} + +#[pymethods] +impl Boolop { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Boolop { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_And", extends=Boolop)] +pub struct BoolopAnd; + +impl ToPyObject for BoolopAnd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Boolop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Or", extends=Boolop)] +pub struct BoolopOr; + +impl ToPyObject for BoolopOr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Boolop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_operator", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Operator; + +impl From<&'static crate::Operator> for Operator { + fn from(_node: &'static crate::Operator) -> Self { + Operator + } +} + +#[pymethods] +impl Operator { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Operator { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Add", extends=Operator)] +pub struct OperatorAdd; + +impl ToPyObject for OperatorAdd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Sub", extends=Operator)] +pub struct OperatorSub; + +impl ToPyObject for OperatorSub { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Mult", extends=Operator)] +pub struct OperatorMult; + +impl ToPyObject for OperatorMult { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatMult", extends=Operator)] +pub struct OperatorMatMult; + +impl ToPyObject for OperatorMatMult { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Div", extends=Operator)] +pub struct OperatorDiv; + +impl ToPyObject for OperatorDiv { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Mod", extends=Operator)] +pub struct OperatorMod; + +impl ToPyObject for OperatorMod { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Pow", extends=Operator)] +pub struct OperatorPow; + +impl ToPyObject for OperatorPow { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_LShift", extends=Operator)] +pub struct OperatorLShift; + +impl ToPyObject for OperatorLShift { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_RShift", extends=Operator)] +pub struct OperatorRShift; + +impl ToPyObject for OperatorRShift { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_BitOr", extends=Operator)] +pub struct OperatorBitOr; + +impl ToPyObject for OperatorBitOr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_BitXor", extends=Operator)] +pub struct OperatorBitXor; + +impl ToPyObject for OperatorBitXor { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_BitAnd", extends=Operator)] +pub struct OperatorBitAnd; + +impl ToPyObject for OperatorBitAnd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_FloorDiv", extends=Operator)] +pub struct OperatorFloorDiv; + +impl ToPyObject for OperatorFloorDiv { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_unaryop", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Unaryop; + +impl From<&'static crate::Unaryop> for Unaryop { + fn from(_node: &'static crate::Unaryop) -> Self { + Unaryop + } +} + +#[pymethods] +impl Unaryop { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Unaryop { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Invert", extends=Unaryop)] +pub struct UnaryopInvert; + +impl ToPyObject for UnaryopInvert { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Unaryop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Not", extends=Unaryop)] +pub struct UnaryopNot; + +impl ToPyObject for UnaryopNot { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Unaryop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_UAdd", extends=Unaryop)] +pub struct UnaryopUAdd; + +impl ToPyObject for UnaryopUAdd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Unaryop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_USub", extends=Unaryop)] +pub struct UnaryopUSub; + +impl ToPyObject for UnaryopUSub { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Unaryop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_cmpop", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Cmpop; + +impl From<&'static crate::Cmpop> for Cmpop { + fn from(_node: &'static crate::Cmpop) -> Self { + Cmpop + } +} + +#[pymethods] +impl Cmpop { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Cmpop { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Eq", extends=Cmpop)] +pub struct CmpopEq; + +impl ToPyObject for CmpopEq { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_NotEq", extends=Cmpop)] +pub struct CmpopNotEq; + +impl ToPyObject for CmpopNotEq { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Lt", extends=Cmpop)] +pub struct CmpopLt; + +impl ToPyObject for CmpopLt { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_LtE", extends=Cmpop)] +pub struct CmpopLtE; + +impl ToPyObject for CmpopLtE { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Gt", extends=Cmpop)] +pub struct CmpopGt; + +impl ToPyObject for CmpopGt { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_GtE", extends=Cmpop)] +pub struct CmpopGtE; + +impl ToPyObject for CmpopGtE { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Is", extends=Cmpop)] +pub struct CmpopIs; + +impl ToPyObject for CmpopIs { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_IsNot", extends=Cmpop)] +pub struct CmpopIsNot; + +impl ToPyObject for CmpopIsNot { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_In", extends=Cmpop)] +pub struct CmpopIn; + +impl ToPyObject for CmpopIn { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_NotIn", extends=Cmpop)] +pub struct CmpopNotIn; + +impl ToPyObject for CmpopNotIn { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Cmpop) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_comprehension", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct Comprehension(pub &'static crate::Comprehension); + +impl From<&'static crate::Comprehension> for Comprehension { + fn from(node: &'static crate::Comprehension) -> Self { + Comprehension(node) + } +} + +impl ToPyObject for Comprehension { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Comprehension { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Comprehension(self).to_object(py)) + } +} + +#[pymethods] +impl Comprehension { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_iter(&self, py: Python) -> PyResult { + self.0.iter.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_ifs(&self, py: Python) -> PyResult { + self.0.ifs.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_is_async(&self, py: Python) -> PyResult { + self.0.is_async.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_excepthandler", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Excepthandler; + +impl From<&'static crate::Excepthandler> for Excepthandler { + fn from(_node: &'static crate::Excepthandler) -> Self { + Excepthandler + } +} + +#[pymethods] +impl Excepthandler { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Excepthandler { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Excepthandler { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::ExceptHandler(cons) => cons.to_pyo3_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_ExceptHandler", extends=Excepthandler, frozen)] +#[derive(Clone, Debug)] +pub struct ExcepthandlerExceptHandler(pub &'static crate::ExcepthandlerExceptHandler); + +impl From<&'static crate::ExcepthandlerExceptHandler> for ExcepthandlerExceptHandler { + fn from(node: &'static crate::ExcepthandlerExceptHandler) -> Self { + ExcepthandlerExceptHandler(node) + } +} + +impl ToPyObject for ExcepthandlerExceptHandler { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Excepthandler) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ExcepthandlerExceptHandler { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExcepthandlerExceptHandler(self).to_object(py)) + } +} + +#[pymethods] +impl ExcepthandlerExceptHandler { + #[getter] + #[inline] + fn get_type(&self, py: Python) -> PyResult { + self.0.type_.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_arguments", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct Arguments(pub &'static crate::Arguments); + +impl From<&'static crate::Arguments> for Arguments { + fn from(node: &'static crate::Arguments) -> Self { + Arguments(node) + } +} + +impl ToPyObject for Arguments { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Arguments { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Arguments(self).to_object(py)) + } +} + +#[pymethods] +impl Arguments { + #[getter] + #[inline] + fn get_posonlyargs(&self, py: Python) -> PyResult { + self.0.posonlyargs.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_vararg(&self, py: Python) -> PyResult { + self.0.vararg.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwonlyargs(&self, py: Python) -> PyResult { + self.0.kwonlyargs.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_kw_defaults(&self, py: Python) -> PyResult { + self.0.kw_defaults.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwarg(&self, py: Python) -> PyResult { + self.0.kwarg.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_defaults(&self, py: Python) -> PyResult { + self.0.defaults.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_arg", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct Arg(pub &'static crate::Arg); + +impl From<&'static crate::Arg> for Arg { + fn from(node: &'static crate::Arg) -> Self { + Arg(node) + } +} + +impl ToPyObject for Arg { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Arg { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Arg(self).to_object(py)) + } +} + +#[pymethods] +impl Arg { + #[getter] + #[inline] + fn get_arg(&self, py: Python) -> PyResult { + self.0.arg.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_annotation(&self, py: Python) -> PyResult { + self.0.annotation.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_keyword", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct Keyword(pub &'static crate::Keyword); + +impl From<&'static crate::Keyword> for Keyword { + fn from(node: &'static crate::Keyword) -> Self { + Keyword(node) + } +} + +impl ToPyObject for Keyword { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Keyword { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Keyword(self).to_object(py)) + } +} + +#[pymethods] +impl Keyword { + #[getter] + #[inline] + fn get_arg(&self, py: Python) -> PyResult { + self.0.arg.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_alias", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct Alias(pub &'static crate::Alias); + +impl From<&'static crate::Alias> for Alias { + fn from(node: &'static crate::Alias) -> Self { + Alias(node) + } +} + +impl ToPyObject for Alias { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Alias { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Alias(self).to_object(py)) + } +} + +#[pymethods] +impl Alias { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_asname(&self, py: Python) -> PyResult { + self.0.asname.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_withitem", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct Withitem(pub &'static crate::Withitem); + +impl From<&'static crate::Withitem> for Withitem { + fn from(node: &'static crate::Withitem) -> Self { + Withitem(node) + } +} + +impl ToPyObject for Withitem { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Withitem { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Withitem(self).to_object(py)) + } +} + +#[pymethods] +impl Withitem { + #[getter] + #[inline] + fn get_context_expr(&self, py: Python) -> PyResult { + self.0.context_expr.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_optional_vars(&self, py: Python) -> PyResult { + self.0.optional_vars.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_match_case", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct MatchCase(pub &'static crate::MatchCase); + +impl From<&'static crate::MatchCase> for MatchCase { + fn from(node: &'static crate::MatchCase) -> Self { + MatchCase(node) + } +} + +impl ToPyObject for MatchCase { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::MatchCase { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(MatchCase(self).to_object(py)) + } +} + +#[pymethods] +impl MatchCase { + #[getter] + #[inline] + fn get_pattern(&self, py: Python) -> PyResult { + self.0.pattern.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_guard(&self, py: Python) -> PyResult { + self.0.guard.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_pattern", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Pattern; + +impl From<&'static crate::Pattern> for Pattern { + fn from(_node: &'static crate::Pattern) -> Self { + Pattern + } +} + +#[pymethods] +impl Pattern { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for Pattern { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::Pattern { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::MatchValue(cons) => cons.to_pyo3_wrapper(py), + Self::MatchSingleton(cons) => cons.to_pyo3_wrapper(py), + Self::MatchSequence(cons) => cons.to_pyo3_wrapper(py), + Self::MatchMapping(cons) => cons.to_pyo3_wrapper(py), + Self::MatchClass(cons) => cons.to_pyo3_wrapper(py), + Self::MatchStar(cons) => cons.to_pyo3_wrapper(py), + Self::MatchAs(cons) => cons.to_pyo3_wrapper(py), + Self::MatchOr(cons) => cons.to_pyo3_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchValue", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchValue(pub &'static crate::PatternMatchValue); + +impl From<&'static crate::PatternMatchValue> for PatternMatchValue { + fn from(node: &'static crate::PatternMatchValue) -> Self { + PatternMatchValue(node) + } +} + +impl ToPyObject for PatternMatchValue { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchValue { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchValue(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchValue { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchSingleton", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchSingleton(pub &'static crate::PatternMatchSingleton); + +impl From<&'static crate::PatternMatchSingleton> for PatternMatchSingleton { + fn from(node: &'static crate::PatternMatchSingleton) -> Self { + PatternMatchSingleton(node) + } +} + +impl ToPyObject for PatternMatchSingleton { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchSingleton { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchSingleton(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchSingleton { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchSequence", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchSequence(pub &'static crate::PatternMatchSequence); + +impl From<&'static crate::PatternMatchSequence> for PatternMatchSequence { + fn from(node: &'static crate::PatternMatchSequence) -> Self { + PatternMatchSequence(node) + } +} + +impl ToPyObject for PatternMatchSequence { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchSequence { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchSequence(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchSequence { + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchMapping", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchMapping(pub &'static crate::PatternMatchMapping); + +impl From<&'static crate::PatternMatchMapping> for PatternMatchMapping { + fn from(node: &'static crate::PatternMatchMapping) -> Self { + PatternMatchMapping(node) + } +} + +impl ToPyObject for PatternMatchMapping { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchMapping { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchMapping(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchMapping { + #[getter] + #[inline] + fn get_keys(&self, py: Python) -> PyResult { + self.0.keys.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_rest(&self, py: Python) -> PyResult { + self.0.rest.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchClass", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchClass(pub &'static crate::PatternMatchClass); + +impl From<&'static crate::PatternMatchClass> for PatternMatchClass { + fn from(node: &'static crate::PatternMatchClass) -> Self { + PatternMatchClass(node) + } +} + +impl ToPyObject for PatternMatchClass { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchClass { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchClass(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchClass { + #[getter] + #[inline] + fn get_cls(&self, py: Python) -> PyResult { + self.0.cls.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwd_attrs(&self, py: Python) -> PyResult { + self.0.kwd_attrs.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwd_patterns(&self, py: Python) -> PyResult { + self.0.kwd_patterns.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchStar", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchStar(pub &'static crate::PatternMatchStar); + +impl From<&'static crate::PatternMatchStar> for PatternMatchStar { + fn from(node: &'static crate::PatternMatchStar) -> Self { + PatternMatchStar(node) + } +} + +impl ToPyObject for PatternMatchStar { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchStar { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchStar(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchStar { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchAs", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchAs(pub &'static crate::PatternMatchAs); + +impl From<&'static crate::PatternMatchAs> for PatternMatchAs { + fn from(node: &'static crate::PatternMatchAs) -> Self { + PatternMatchAs(node) + } +} + +impl ToPyObject for PatternMatchAs { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchAs { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchAs(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchAs { + #[getter] + #[inline] + fn get_pattern(&self, py: Python) -> PyResult { + self.0.pattern.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchOr", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchOr(pub &'static crate::PatternMatchOr); + +impl From<&'static crate::PatternMatchOr> for PatternMatchOr { + fn from(node: &'static crate::PatternMatchOr) -> Self { + PatternMatchOr(node) + } +} + +impl ToPyObject for PatternMatchOr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::PatternMatchOr { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchOr(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchOr { + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_pyo3_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_type_ignore", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct TypeIgnore; + +impl From<&'static crate::TypeIgnore> for TypeIgnore { + fn from(_node: &'static crate::TypeIgnore) -> Self { + TypeIgnore + } +} + +#[pymethods] +impl TypeIgnore { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(AST).add_subclass(Self) + } +} +impl ToPyObject for TypeIgnore { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::TypeIgnore { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::TypeIgnore(cons) => cons.to_pyo3_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_TypeIgnore", extends=TypeIgnore, frozen)] +#[derive(Clone, Debug)] +pub struct TypeIgnoreTypeIgnore(pub &'static crate::TypeIgnoreTypeIgnore); + +impl From<&'static crate::TypeIgnoreTypeIgnore> for TypeIgnoreTypeIgnore { + fn from(node: &'static crate::TypeIgnoreTypeIgnore) -> Self { + TypeIgnoreTypeIgnore(node) + } +} + +impl ToPyObject for TypeIgnoreTypeIgnore { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(AST) + .add_subclass(TypeIgnore) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::TypeIgnoreTypeIgnore { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(TypeIgnoreTypeIgnore(self).to_object(py)) + } +} + +#[pymethods] +impl TypeIgnoreTypeIgnore { + #[getter] + #[inline] + fn get_lineno(&self, py: Python) -> PyResult { + self.0.lineno.to_pyo3_wrapper(py) + } + + #[getter] + #[inline] + fn get_tag(&self, py: Python) -> PyResult { + self.0.tag.to_pyo3_wrapper(py) + } +} + +pub fn add_to_module(py: Python, m: &PyModule) -> PyResult<()> { + super::init_module(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::( + py, m, + )?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + Ok(()) +} diff --git a/ast/src/gen/to_pyo3.rs b/ast/src/gen/to_pyo3.rs index 47786ebd..c8a7478f 100644 --- a/ast/src/gen/to_pyo3.rs +++ b/ast/src/gen/to_pyo3.rs @@ -1038,13 +1038,16 @@ impl ToPyo3Ast for crate::ModModule { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - ( - self.body.to_pyo3_ast(py)?, - self.type_ignores.to_pyo3_ast(py)?, - ), - )?; + + let Self { + body, + type_ignores, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (body.to_pyo3_ast(py)?, type_ignores.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1053,7 +1056,13 @@ impl ToPyo3Ast for crate::ModInteractive { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.body.to_pyo3_ast(py)?,))?; + + let Self { + body, + range: _range, + } = self; + let instance = cache.0.call1(py, (body.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -1062,7 +1071,13 @@ impl ToPyo3Ast for crate::ModExpression { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.body.to_pyo3_ast(py)?,))?; + + let Self { + body, + range: _range, + } = self; + let instance = cache.0.call1(py, (body.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -1071,13 +1086,16 @@ impl ToPyo3Ast for crate::ModFunctionType { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - ( - self.argtypes.to_pyo3_ast(py)?, - self.returns.to_pyo3_ast(py)?, - ), - )?; + + let Self { + argtypes, + returns, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (argtypes.to_pyo3_ast(py)?, returns.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1122,17 +1140,28 @@ impl ToPyo3Ast for crate::StmtFunctionDef { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + args, + body, + decorator_list, + returns, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.name.to_pyo3_ast(py)?, - self.args.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.decorator_list.to_pyo3_ast(py)?, - self.returns.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + name.to_pyo3_ast(py)?, + args.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + decorator_list.to_pyo3_ast(py)?, + returns.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1141,17 +1170,28 @@ impl ToPyo3Ast for crate::StmtAsyncFunctionDef { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + args, + body, + decorator_list, + returns, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.name.to_pyo3_ast(py)?, - self.args.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.decorator_list.to_pyo3_ast(py)?, - self.returns.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + name.to_pyo3_ast(py)?, + args.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + decorator_list.to_pyo3_ast(py)?, + returns.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1160,16 +1200,26 @@ impl ToPyo3Ast for crate::StmtClassDef { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + bases, + keywords, + body, + decorator_list, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.name.to_pyo3_ast(py)?, - self.bases.to_pyo3_ast(py)?, - self.keywords.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.decorator_list.to_pyo3_ast(py)?, + name.to_pyo3_ast(py)?, + bases.to_pyo3_ast(py)?, + keywords.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + decorator_list.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1178,7 +1228,13 @@ impl ToPyo3Ast for crate::StmtReturn { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -1187,7 +1243,13 @@ impl ToPyo3Ast for crate::StmtDelete { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.targets.to_pyo3_ast(py)?,))?; + + let Self { + targets, + range: _range, + } = self; + let instance = cache.0.call1(py, (targets.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -1196,14 +1258,22 @@ impl ToPyo3Ast for crate::StmtAssign { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + targets, + value, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.targets.to_pyo3_ast(py)?, - self.value.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + targets.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1212,14 +1282,22 @@ impl ToPyo3Ast for crate::StmtAugAssign { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + op, + value, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.target.to_pyo3_ast(py)?, - self.op.to_pyo3_ast(py)?, - self.value.to_pyo3_ast(py)?, + target.to_pyo3_ast(py)?, + op.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1228,15 +1306,24 @@ impl ToPyo3Ast for crate::StmtAnnAssign { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + annotation, + value, + simple, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.target.to_pyo3_ast(py)?, - self.annotation.to_pyo3_ast(py)?, - self.value.to_pyo3_ast(py)?, - self.simple.to_pyo3_ast(py)?, + target.to_pyo3_ast(py)?, + annotation.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, + simple.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1245,16 +1332,26 @@ impl ToPyo3Ast for crate::StmtFor { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + iter, + body, + orelse, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.target.to_pyo3_ast(py)?, - self.iter.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + target.to_pyo3_ast(py)?, + iter.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1263,16 +1360,26 @@ impl ToPyo3Ast for crate::StmtAsyncFor { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + iter, + body, + orelse, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.target.to_pyo3_ast(py)?, - self.iter.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + target.to_pyo3_ast(py)?, + iter.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1281,14 +1388,22 @@ impl ToPyo3Ast for crate::StmtWhile { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + body, + orelse, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.test.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, + test.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1297,14 +1412,22 @@ impl ToPyo3Ast for crate::StmtIf { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + body, + orelse, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.test.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, + test.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1313,14 +1436,22 @@ impl ToPyo3Ast for crate::StmtWith { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + items, + body, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.items.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + items.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1329,14 +1460,22 @@ impl ToPyo3Ast for crate::StmtAsyncWith { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + items, + body, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.items.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + items.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1345,10 +1484,16 @@ impl ToPyo3Ast for crate::StmtMatch { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.subject.to_pyo3_ast(py)?, self.cases.to_pyo3_ast(py)?), - )?; + + let Self { + subject, + cases, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (subject.to_pyo3_ast(py)?, cases.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1357,9 +1502,16 @@ impl ToPyo3Ast for crate::StmtRaise { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + exc, + cause, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.exc.to_pyo3_ast(py)?, self.cause.to_pyo3_ast(py)?))?; + .call1(py, (exc.to_pyo3_ast(py)?, cause.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1368,15 +1520,24 @@ impl ToPyo3Ast for crate::StmtTry { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + handlers, + orelse, + finalbody, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.body.to_pyo3_ast(py)?, - self.handlers.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, - self.finalbody.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + handlers.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, + finalbody.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1385,15 +1546,24 @@ impl ToPyo3Ast for crate::StmtTryStar { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + handlers, + orelse, + finalbody, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.body.to_pyo3_ast(py)?, - self.handlers.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, - self.finalbody.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + handlers.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, + finalbody.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1402,9 +1572,16 @@ impl ToPyo3Ast for crate::StmtAssert { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + msg, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.test.to_pyo3_ast(py)?, self.msg.to_pyo3_ast(py)?))?; + .call1(py, (test.to_pyo3_ast(py)?, msg.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1413,7 +1590,13 @@ impl ToPyo3Ast for crate::StmtImport { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.names.to_pyo3_ast(py)?,))?; + + let Self { + names, + range: _range, + } = self; + let instance = cache.0.call1(py, (names.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -1422,14 +1605,22 @@ impl ToPyo3Ast for crate::StmtImportFrom { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + module, + names, + level, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.module.to_pyo3_ast(py)?, - self.names.to_pyo3_ast(py)?, - self.level.to_pyo3_ast(py)?, + module.to_pyo3_ast(py)?, + names.to_pyo3_ast(py)?, + level.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1438,7 +1629,13 @@ impl ToPyo3Ast for crate::StmtGlobal { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.names.to_pyo3_ast(py)?,))?; + + let Self { + names, + range: _range, + } = self; + let instance = cache.0.call1(py, (names.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -1447,7 +1644,13 @@ impl ToPyo3Ast for crate::StmtNonlocal { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.names.to_pyo3_ast(py)?,))?; + + let Self { + names, + range: _range, + } = self; + let instance = cache.0.call1(py, (names.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -1456,7 +1659,13 @@ impl ToPyo3Ast for crate::StmtExpr { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -1465,7 +1674,10 @@ impl ToPyo3Ast for crate::StmtPass { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + let instance = cache.0.call0(py)?; + let Self { range: _range } = self; + Ok(instance) } } @@ -1474,7 +1686,10 @@ impl ToPyo3Ast for crate::StmtBreak { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + let instance = cache.0.call0(py)?; + let Self { range: _range } = self; + Ok(instance) } } @@ -1483,7 +1698,10 @@ impl ToPyo3Ast for crate::StmtContinue { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + let instance = cache.0.call0(py)?; + let Self { range: _range } = self; + Ok(instance) } } @@ -1528,9 +1746,16 @@ impl ToPyo3Ast for crate::ExprBoolOp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + op, + values, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.op.to_pyo3_ast(py)?, self.values.to_pyo3_ast(py)?))?; + .call1(py, (op.to_pyo3_ast(py)?, values.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1539,10 +1764,16 @@ impl ToPyo3Ast for crate::ExprNamedExpr { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.target.to_pyo3_ast(py)?, self.value.to_pyo3_ast(py)?), - )?; + + let Self { + target, + value, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (target.to_pyo3_ast(py)?, value.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1551,14 +1782,22 @@ impl ToPyo3Ast for crate::ExprBinOp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + left, + op, + right, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.left.to_pyo3_ast(py)?, - self.op.to_pyo3_ast(py)?, - self.right.to_pyo3_ast(py)?, + left.to_pyo3_ast(py)?, + op.to_pyo3_ast(py)?, + right.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1567,10 +1806,16 @@ impl ToPyo3Ast for crate::ExprUnaryOp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.op.to_pyo3_ast(py)?, self.operand.to_pyo3_ast(py)?), - )?; + + let Self { + op, + operand, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (op.to_pyo3_ast(py)?, operand.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1579,9 +1824,16 @@ impl ToPyo3Ast for crate::ExprLambda { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + args, + body, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.args.to_pyo3_ast(py)?, self.body.to_pyo3_ast(py)?))?; + .call1(py, (args.to_pyo3_ast(py)?, body.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1590,14 +1842,22 @@ impl ToPyo3Ast for crate::ExprIfExp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + body, + orelse, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.test.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, + test.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1606,10 +1866,16 @@ impl ToPyo3Ast for crate::ExprDict { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.keys.to_pyo3_ast(py)?, self.values.to_pyo3_ast(py)?), - )?; + + let Self { + keys, + values, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (keys.to_pyo3_ast(py)?, values.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1618,7 +1884,13 @@ impl ToPyo3Ast for crate::ExprSet { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.elts.to_pyo3_ast(py)?,))?; + + let Self { + elts, + range: _range, + } = self; + let instance = cache.0.call1(py, (elts.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -1627,10 +1899,16 @@ impl ToPyo3Ast for crate::ExprListComp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.elt.to_pyo3_ast(py)?, self.generators.to_pyo3_ast(py)?), - )?; + + let Self { + elt, + generators, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (elt.to_pyo3_ast(py)?, generators.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1639,10 +1917,16 @@ impl ToPyo3Ast for crate::ExprSetComp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.elt.to_pyo3_ast(py)?, self.generators.to_pyo3_ast(py)?), - )?; + + let Self { + elt, + generators, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (elt.to_pyo3_ast(py)?, generators.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1651,14 +1935,22 @@ impl ToPyo3Ast for crate::ExprDictComp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + key, + value, + generators, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.key.to_pyo3_ast(py)?, - self.value.to_pyo3_ast(py)?, - self.generators.to_pyo3_ast(py)?, + key.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, + generators.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1667,10 +1959,16 @@ impl ToPyo3Ast for crate::ExprGeneratorExp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.elt.to_pyo3_ast(py)?, self.generators.to_pyo3_ast(py)?), - )?; + + let Self { + elt, + generators, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (elt.to_pyo3_ast(py)?, generators.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1679,7 +1977,13 @@ impl ToPyo3Ast for crate::ExprAwait { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -1688,7 +1992,13 @@ impl ToPyo3Ast for crate::ExprYield { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -1697,7 +2007,13 @@ impl ToPyo3Ast for crate::ExprYieldFrom { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -1706,14 +2022,22 @@ impl ToPyo3Ast for crate::ExprCompare { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + left, + ops, + comparators, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.left.to_pyo3_ast(py)?, - self.ops.to_pyo3_ast(py)?, - self.comparators.to_pyo3_ast(py)?, + left.to_pyo3_ast(py)?, + ops.to_pyo3_ast(py)?, + comparators.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1722,14 +2046,22 @@ impl ToPyo3Ast for crate::ExprCall { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + func, + args, + keywords, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.func.to_pyo3_ast(py)?, - self.args.to_pyo3_ast(py)?, - self.keywords.to_pyo3_ast(py)?, + func.to_pyo3_ast(py)?, + args.to_pyo3_ast(py)?, + keywords.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1738,14 +2070,22 @@ impl ToPyo3Ast for crate::ExprFormattedValue { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + conversion, + format_spec, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.value.to_pyo3_ast(py)?, - self.conversion.to_pyo3_ast(py)?, - self.format_spec.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, + conversion.to_pyo3_ast(py)?, + format_spec.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1754,7 +2094,13 @@ impl ToPyo3Ast for crate::ExprJoinedStr { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.values.to_pyo3_ast(py)?,))?; + + let Self { + values, + range: _range, + } = self; + let instance = cache.0.call1(py, (values.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -1763,10 +2109,16 @@ impl ToPyo3Ast for crate::ExprConstant { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.value.to_pyo3_ast(py)?, self.kind.to_pyo3_ast(py)?), - )?; + + let Self { + value, + kind, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (value.to_pyo3_ast(py)?, kind.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1775,14 +2127,22 @@ impl ToPyo3Ast for crate::ExprAttribute { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + attr, + ctx, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.value.to_pyo3_ast(py)?, - self.attr.to_pyo3_ast(py)?, - self.ctx.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, + attr.to_pyo3_ast(py)?, + ctx.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1791,14 +2151,22 @@ impl ToPyo3Ast for crate::ExprSubscript { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + slice, + ctx, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.value.to_pyo3_ast(py)?, - self.slice.to_pyo3_ast(py)?, - self.ctx.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, + slice.to_pyo3_ast(py)?, + ctx.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1807,9 +2175,16 @@ impl ToPyo3Ast for crate::ExprStarred { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + ctx, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.value.to_pyo3_ast(py)?, self.ctx.to_pyo3_ast(py)?))?; + .call1(py, (value.to_pyo3_ast(py)?, ctx.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1818,9 +2193,16 @@ impl ToPyo3Ast for crate::ExprName { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + id, + ctx, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.id.to_pyo3_ast(py)?, self.ctx.to_pyo3_ast(py)?))?; + .call1(py, (id.to_pyo3_ast(py)?, ctx.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1829,9 +2211,16 @@ impl ToPyo3Ast for crate::ExprList { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elts, + ctx, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.elts.to_pyo3_ast(py)?, self.ctx.to_pyo3_ast(py)?))?; + .call1(py, (elts.to_pyo3_ast(py)?, ctx.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1840,9 +2229,16 @@ impl ToPyo3Ast for crate::ExprTuple { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elts, + ctx, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.elts.to_pyo3_ast(py)?, self.ctx.to_pyo3_ast(py)?))?; + .call1(py, (elts.to_pyo3_ast(py)?, ctx.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1851,14 +2247,22 @@ impl ToPyo3Ast for crate::ExprSlice { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + lower, + upper, + step, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.lower.to_pyo3_ast(py)?, - self.upper.to_pyo3_ast(py)?, - self.step.to_pyo3_ast(py)?, + lower.to_pyo3_ast(py)?, + upper.to_pyo3_ast(py)?, + step.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1867,15 +2271,24 @@ impl ToPyo3Ast for crate::Comprehension { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + iter, + ifs, + is_async, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.target.to_pyo3_ast(py)?, - self.iter.to_pyo3_ast(py)?, - self.ifs.to_pyo3_ast(py)?, - self.is_async.to_pyo3_ast(py)?, + target.to_pyo3_ast(py)?, + iter.to_pyo3_ast(py)?, + ifs.to_pyo3_ast(py)?, + is_async.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1894,14 +2307,22 @@ impl ToPyo3Ast for crate::ExcepthandlerExceptHandler { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + type_, + name, + body, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.type_.to_pyo3_ast(py)?, - self.name.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, + type_.to_pyo3_ast(py)?, + name.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1910,18 +2331,30 @@ impl ToPyo3Ast for crate::Arguments { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + posonlyargs, + args, + vararg, + kwonlyargs, + kw_defaults, + kwarg, + defaults, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.posonlyargs.to_pyo3_ast(py)?, - self.args.to_pyo3_ast(py)?, - self.vararg.to_pyo3_ast(py)?, - self.kwonlyargs.to_pyo3_ast(py)?, - self.kw_defaults.to_pyo3_ast(py)?, - self.kwarg.to_pyo3_ast(py)?, - self.defaults.to_pyo3_ast(py)?, + posonlyargs.to_pyo3_ast(py)?, + args.to_pyo3_ast(py)?, + vararg.to_pyo3_ast(py)?, + kwonlyargs.to_pyo3_ast(py)?, + kw_defaults.to_pyo3_ast(py)?, + kwarg.to_pyo3_ast(py)?, + defaults.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1930,14 +2363,22 @@ impl ToPyo3Ast for crate::Arg { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + arg, + annotation, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.arg.to_pyo3_ast(py)?, - self.annotation.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + arg.to_pyo3_ast(py)?, + annotation.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1946,9 +2387,16 @@ impl ToPyo3Ast for crate::Keyword { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + arg, + value, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.arg.to_pyo3_ast(py)?, self.value.to_pyo3_ast(py)?))?; + .call1(py, (arg.to_pyo3_ast(py)?, value.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1957,10 +2405,16 @@ impl ToPyo3Ast for crate::Alias { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.name.to_pyo3_ast(py)?, self.asname.to_pyo3_ast(py)?), - )?; + + let Self { + name, + asname, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (name.to_pyo3_ast(py)?, asname.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -1969,13 +2423,20 @@ impl ToPyo3Ast for crate::Withitem { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + context_expr, + optional_vars, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.context_expr.to_pyo3_ast(py)?, - self.optional_vars.to_pyo3_ast(py)?, + context_expr.to_pyo3_ast(py)?, + optional_vars.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -1984,14 +2445,22 @@ impl ToPyo3Ast for crate::MatchCase { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + pattern, + guard, + body, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.pattern.to_pyo3_ast(py)?, - self.guard.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, + pattern.to_pyo3_ast(py)?, + guard.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -2017,7 +2486,13 @@ impl ToPyo3Ast for crate::PatternMatchValue { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -2026,7 +2501,13 @@ impl ToPyo3Ast for crate::PatternMatchSingleton { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -2035,7 +2516,13 @@ impl ToPyo3Ast for crate::PatternMatchSequence { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.patterns.to_pyo3_ast(py)?,))?; + + let Self { + patterns, + range: _range, + } = self; + let instance = cache.0.call1(py, (patterns.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -2044,14 +2531,22 @@ impl ToPyo3Ast for crate::PatternMatchMapping { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + keys, + patterns, + rest, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.keys.to_pyo3_ast(py)?, - self.patterns.to_pyo3_ast(py)?, - self.rest.to_pyo3_ast(py)?, + keys.to_pyo3_ast(py)?, + patterns.to_pyo3_ast(py)?, + rest.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -2060,15 +2555,24 @@ impl ToPyo3Ast for crate::PatternMatchClass { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + cls, + patterns, + kwd_attrs, + kwd_patterns, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.cls.to_pyo3_ast(py)?, - self.patterns.to_pyo3_ast(py)?, - self.kwd_attrs.to_pyo3_ast(py)?, - self.kwd_patterns.to_pyo3_ast(py)?, + cls.to_pyo3_ast(py)?, + patterns.to_pyo3_ast(py)?, + kwd_attrs.to_pyo3_ast(py)?, + kwd_patterns.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -2077,7 +2581,13 @@ impl ToPyo3Ast for crate::PatternMatchStar { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.name.to_pyo3_ast(py)?,))?; + + let Self { + name, + range: _range, + } = self; + let instance = cache.0.call1(py, (name.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -2086,10 +2596,16 @@ impl ToPyo3Ast for crate::PatternMatchAs { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.pattern.to_pyo3_ast(py)?, self.name.to_pyo3_ast(py)?), - )?; + + let Self { + pattern, + name, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (pattern.to_pyo3_ast(py)?, name.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -2098,7 +2614,13 @@ impl ToPyo3Ast for crate::PatternMatchOr { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.patterns.to_pyo3_ast(py)?,))?; + + let Self { + patterns, + range: _range, + } = self; + let instance = cache.0.call1(py, (patterns.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -2117,10 +2639,16 @@ impl ToPyo3Ast for crate::TypeIgnoreTypeIgnore { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.lineno.to_pyo3_ast(py)?, self.tag.to_pyo3_ast(py)?), - )?; + + let Self { + lineno, + tag, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (lineno.to_pyo3_ast(py)?, tag.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -2142,13 +2670,16 @@ impl ToPyo3Ast for crate::ModModule { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - ( - self.body.to_pyo3_ast(py)?, - self.type_ignores.to_pyo3_ast(py)?, - ), - )?; + + let Self { + body, + type_ignores, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (body.to_pyo3_ast(py)?, type_ignores.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -2157,7 +2688,13 @@ impl ToPyo3Ast for crate::ModInteractive { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.body.to_pyo3_ast(py)?,))?; + + let Self { + body, + range: _range, + } = self; + let instance = cache.0.call1(py, (body.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -2166,7 +2703,13 @@ impl ToPyo3Ast for crate::ModExpression { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.body.to_pyo3_ast(py)?,))?; + + let Self { + body, + range: _range, + } = self; + let instance = cache.0.call1(py, (body.to_pyo3_ast(py)?,))?; + Ok(instance) } } @@ -2175,13 +2718,16 @@ impl ToPyo3Ast for crate::ModFunctionType { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - ( - self.argtypes.to_pyo3_ast(py)?, - self.returns.to_pyo3_ast(py)?, - ), - )?; + + let Self { + argtypes, + returns, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (argtypes.to_pyo3_ast(py)?, returns.to_pyo3_ast(py)?))?; + Ok(instance) } } @@ -2226,17 +2772,36 @@ impl ToPyo3Ast for crate::StmtFunctionDef { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + args, + body, + decorator_list, + returns, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.name.to_pyo3_ast(py)?, - self.args.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.decorator_list.to_pyo3_ast(py)?, - self.returns.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + name.to_pyo3_ast(py)?, + args.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + decorator_list.to_pyo3_ast(py)?, + returns.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2245,17 +2810,36 @@ impl ToPyo3Ast for crate::StmtAsyncFunctionDef { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + args, + body, + decorator_list, + returns, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.name.to_pyo3_ast(py)?, - self.args.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.decorator_list.to_pyo3_ast(py)?, - self.returns.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + name.to_pyo3_ast(py)?, + args.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + decorator_list.to_pyo3_ast(py)?, + returns.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2264,16 +2848,34 @@ impl ToPyo3Ast for crate::StmtClassDef { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + bases, + keywords, + body, + decorator_list, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.name.to_pyo3_ast(py)?, - self.bases.to_pyo3_ast(py)?, - self.keywords.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.decorator_list.to_pyo3_ast(py)?, + name.to_pyo3_ast(py)?, + bases.to_pyo3_ast(py)?, + keywords.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + decorator_list.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2282,7 +2884,21 @@ impl ToPyo3Ast for crate::StmtReturn { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2291,7 +2907,21 @@ impl ToPyo3Ast for crate::StmtDelete { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.targets.to_pyo3_ast(py)?,))?; + + let Self { + targets, + range: _range, + } = self; + let instance = cache.0.call1(py, (targets.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2300,14 +2930,30 @@ impl ToPyo3Ast for crate::StmtAssign { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + targets, + value, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.targets.to_pyo3_ast(py)?, - self.value.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + targets.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2316,14 +2962,30 @@ impl ToPyo3Ast for crate::StmtAugAssign { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + op, + value, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.target.to_pyo3_ast(py)?, - self.op.to_pyo3_ast(py)?, - self.value.to_pyo3_ast(py)?, + target.to_pyo3_ast(py)?, + op.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2332,15 +2994,32 @@ impl ToPyo3Ast for crate::StmtAnnAssign { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + annotation, + value, + simple, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.target.to_pyo3_ast(py)?, - self.annotation.to_pyo3_ast(py)?, - self.value.to_pyo3_ast(py)?, - self.simple.to_pyo3_ast(py)?, + target.to_pyo3_ast(py)?, + annotation.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, + simple.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2349,16 +3028,34 @@ impl ToPyo3Ast for crate::StmtFor { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + iter, + body, + orelse, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.target.to_pyo3_ast(py)?, - self.iter.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + target.to_pyo3_ast(py)?, + iter.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2367,16 +3064,34 @@ impl ToPyo3Ast for crate::StmtAsyncFor { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + iter, + body, + orelse, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.target.to_pyo3_ast(py)?, - self.iter.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + target.to_pyo3_ast(py)?, + iter.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2385,14 +3100,30 @@ impl ToPyo3Ast for crate::StmtWhile { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + body, + orelse, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.test.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, + test.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2401,14 +3132,30 @@ impl ToPyo3Ast for crate::StmtIf { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + body, + orelse, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.test.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, + test.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2417,14 +3164,30 @@ impl ToPyo3Ast for crate::StmtWith { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + items, + body, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.items.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + items.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2433,14 +3196,30 @@ impl ToPyo3Ast for crate::StmtAsyncWith { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + items, + body, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.items.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + items.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2449,10 +3228,24 @@ impl ToPyo3Ast for crate::StmtMatch { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.subject.to_pyo3_ast(py)?, self.cases.to_pyo3_ast(py)?), - )?; + + let Self { + subject, + cases, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (subject.to_pyo3_ast(py)?, cases.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2461,9 +3254,24 @@ impl ToPyo3Ast for crate::StmtRaise { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + exc, + cause, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.exc.to_pyo3_ast(py)?, self.cause.to_pyo3_ast(py)?))?; + .call1(py, (exc.to_pyo3_ast(py)?, cause.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2472,15 +3280,32 @@ impl ToPyo3Ast for crate::StmtTry { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + handlers, + orelse, + finalbody, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.body.to_pyo3_ast(py)?, - self.handlers.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, - self.finalbody.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + handlers.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, + finalbody.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2489,15 +3314,32 @@ impl ToPyo3Ast for crate::StmtTryStar { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + handlers, + orelse, + finalbody, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.body.to_pyo3_ast(py)?, - self.handlers.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, - self.finalbody.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + handlers.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, + finalbody.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2506,9 +3348,24 @@ impl ToPyo3Ast for crate::StmtAssert { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + msg, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.test.to_pyo3_ast(py)?, self.msg.to_pyo3_ast(py)?))?; + .call1(py, (test.to_pyo3_ast(py)?, msg.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2517,7 +3374,21 @@ impl ToPyo3Ast for crate::StmtImport { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.names.to_pyo3_ast(py)?,))?; + + let Self { + names, + range: _range, + } = self; + let instance = cache.0.call1(py, (names.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2526,14 +3397,30 @@ impl ToPyo3Ast for crate::StmtImportFrom { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + module, + names, + level, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.module.to_pyo3_ast(py)?, - self.names.to_pyo3_ast(py)?, - self.level.to_pyo3_ast(py)?, + module.to_pyo3_ast(py)?, + names.to_pyo3_ast(py)?, + level.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2542,7 +3429,21 @@ impl ToPyo3Ast for crate::StmtGlobal { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.names.to_pyo3_ast(py)?,))?; + + let Self { + names, + range: _range, + } = self; + let instance = cache.0.call1(py, (names.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2551,7 +3452,21 @@ impl ToPyo3Ast for crate::StmtNonlocal { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.names.to_pyo3_ast(py)?,))?; + + let Self { + names, + range: _range, + } = self; + let instance = cache.0.call1(py, (names.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2560,7 +3475,21 @@ impl ToPyo3Ast for crate::StmtExpr { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2569,7 +3498,18 @@ impl ToPyo3Ast for crate::StmtPass { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + let instance = cache.0.call0(py)?; + let Self { range: _range } = self; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2578,7 +3518,18 @@ impl ToPyo3Ast for crate::StmtBreak { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + let instance = cache.0.call0(py)?; + let Self { range: _range } = self; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2587,7 +3538,18 @@ impl ToPyo3Ast for crate::StmtContinue { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + let instance = cache.0.call0(py)?; + let Self { range: _range } = self; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2632,9 +3594,24 @@ impl ToPyo3Ast for crate::ExprBoolOp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + op, + values, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.op.to_pyo3_ast(py)?, self.values.to_pyo3_ast(py)?))?; + .call1(py, (op.to_pyo3_ast(py)?, values.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2643,10 +3620,24 @@ impl ToPyo3Ast for crate::ExprNamedExpr { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.target.to_pyo3_ast(py)?, self.value.to_pyo3_ast(py)?), - )?; + + let Self { + target, + value, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (target.to_pyo3_ast(py)?, value.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2655,14 +3646,30 @@ impl ToPyo3Ast for crate::ExprBinOp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + left, + op, + right, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.left.to_pyo3_ast(py)?, - self.op.to_pyo3_ast(py)?, - self.right.to_pyo3_ast(py)?, + left.to_pyo3_ast(py)?, + op.to_pyo3_ast(py)?, + right.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2671,10 +3678,24 @@ impl ToPyo3Ast for crate::ExprUnaryOp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.op.to_pyo3_ast(py)?, self.operand.to_pyo3_ast(py)?), - )?; + + let Self { + op, + operand, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (op.to_pyo3_ast(py)?, operand.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2683,9 +3704,24 @@ impl ToPyo3Ast for crate::ExprLambda { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + args, + body, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.args.to_pyo3_ast(py)?, self.body.to_pyo3_ast(py)?))?; + .call1(py, (args.to_pyo3_ast(py)?, body.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2694,14 +3730,30 @@ impl ToPyo3Ast for crate::ExprIfExp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + body, + orelse, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.test.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, - self.orelse.to_pyo3_ast(py)?, + test.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, + orelse.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2710,10 +3762,24 @@ impl ToPyo3Ast for crate::ExprDict { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.keys.to_pyo3_ast(py)?, self.values.to_pyo3_ast(py)?), - )?; + + let Self { + keys, + values, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (keys.to_pyo3_ast(py)?, values.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2722,7 +3788,21 @@ impl ToPyo3Ast for crate::ExprSet { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.elts.to_pyo3_ast(py)?,))?; + + let Self { + elts, + range: _range, + } = self; + let instance = cache.0.call1(py, (elts.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2731,10 +3811,24 @@ impl ToPyo3Ast for crate::ExprListComp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.elt.to_pyo3_ast(py)?, self.generators.to_pyo3_ast(py)?), - )?; + + let Self { + elt, + generators, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (elt.to_pyo3_ast(py)?, generators.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2743,10 +3837,24 @@ impl ToPyo3Ast for crate::ExprSetComp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.elt.to_pyo3_ast(py)?, self.generators.to_pyo3_ast(py)?), - )?; + + let Self { + elt, + generators, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (elt.to_pyo3_ast(py)?, generators.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2755,14 +3863,30 @@ impl ToPyo3Ast for crate::ExprDictComp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + key, + value, + generators, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.key.to_pyo3_ast(py)?, - self.value.to_pyo3_ast(py)?, - self.generators.to_pyo3_ast(py)?, + key.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, + generators.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2771,10 +3895,24 @@ impl ToPyo3Ast for crate::ExprGeneratorExp { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.elt.to_pyo3_ast(py)?, self.generators.to_pyo3_ast(py)?), - )?; + + let Self { + elt, + generators, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (elt.to_pyo3_ast(py)?, generators.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2783,7 +3921,21 @@ impl ToPyo3Ast for crate::ExprAwait { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2792,7 +3944,21 @@ impl ToPyo3Ast for crate::ExprYield { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2801,7 +3967,21 @@ impl ToPyo3Ast for crate::ExprYieldFrom { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2810,14 +3990,30 @@ impl ToPyo3Ast for crate::ExprCompare { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + left, + ops, + comparators, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.left.to_pyo3_ast(py)?, - self.ops.to_pyo3_ast(py)?, - self.comparators.to_pyo3_ast(py)?, + left.to_pyo3_ast(py)?, + ops.to_pyo3_ast(py)?, + comparators.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2826,14 +4022,30 @@ impl ToPyo3Ast for crate::ExprCall { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + func, + args, + keywords, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.func.to_pyo3_ast(py)?, - self.args.to_pyo3_ast(py)?, - self.keywords.to_pyo3_ast(py)?, + func.to_pyo3_ast(py)?, + args.to_pyo3_ast(py)?, + keywords.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2842,14 +4054,30 @@ impl ToPyo3Ast for crate::ExprFormattedValue { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + conversion, + format_spec, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.value.to_pyo3_ast(py)?, - self.conversion.to_pyo3_ast(py)?, - self.format_spec.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, + conversion.to_pyo3_ast(py)?, + format_spec.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2858,7 +4086,21 @@ impl ToPyo3Ast for crate::ExprJoinedStr { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.values.to_pyo3_ast(py)?,))?; + + let Self { + values, + range: _range, + } = self; + let instance = cache.0.call1(py, (values.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2867,10 +4109,24 @@ impl ToPyo3Ast for crate::ExprConstant { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.value.to_pyo3_ast(py)?, self.kind.to_pyo3_ast(py)?), - )?; + + let Self { + value, + kind, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (value.to_pyo3_ast(py)?, kind.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2879,14 +4135,30 @@ impl ToPyo3Ast for crate::ExprAttribute { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + attr, + ctx, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.value.to_pyo3_ast(py)?, - self.attr.to_pyo3_ast(py)?, - self.ctx.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, + attr.to_pyo3_ast(py)?, + ctx.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2895,14 +4167,30 @@ impl ToPyo3Ast for crate::ExprSubscript { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + slice, + ctx, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.value.to_pyo3_ast(py)?, - self.slice.to_pyo3_ast(py)?, - self.ctx.to_pyo3_ast(py)?, + value.to_pyo3_ast(py)?, + slice.to_pyo3_ast(py)?, + ctx.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2911,9 +4199,24 @@ impl ToPyo3Ast for crate::ExprStarred { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + ctx, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.value.to_pyo3_ast(py)?, self.ctx.to_pyo3_ast(py)?))?; + .call1(py, (value.to_pyo3_ast(py)?, ctx.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2922,9 +4225,24 @@ impl ToPyo3Ast for crate::ExprName { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + id, + ctx, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.id.to_pyo3_ast(py)?, self.ctx.to_pyo3_ast(py)?))?; + .call1(py, (id.to_pyo3_ast(py)?, ctx.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2933,9 +4251,24 @@ impl ToPyo3Ast for crate::ExprList { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elts, + ctx, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.elts.to_pyo3_ast(py)?, self.ctx.to_pyo3_ast(py)?))?; + .call1(py, (elts.to_pyo3_ast(py)?, ctx.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2944,9 +4277,24 @@ impl ToPyo3Ast for crate::ExprTuple { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elts, + ctx, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.elts.to_pyo3_ast(py)?, self.ctx.to_pyo3_ast(py)?))?; + .call1(py, (elts.to_pyo3_ast(py)?, ctx.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2955,14 +4303,30 @@ impl ToPyo3Ast for crate::ExprSlice { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + lower, + upper, + step, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.lower.to_pyo3_ast(py)?, - self.upper.to_pyo3_ast(py)?, - self.step.to_pyo3_ast(py)?, + lower.to_pyo3_ast(py)?, + upper.to_pyo3_ast(py)?, + step.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -2971,15 +4335,24 @@ impl ToPyo3Ast for crate::Comprehension { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + iter, + ifs, + is_async, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.target.to_pyo3_ast(py)?, - self.iter.to_pyo3_ast(py)?, - self.ifs.to_pyo3_ast(py)?, - self.is_async.to_pyo3_ast(py)?, + target.to_pyo3_ast(py)?, + iter.to_pyo3_ast(py)?, + ifs.to_pyo3_ast(py)?, + is_async.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -2998,14 +4371,30 @@ impl ToPyo3Ast for crate::ExcepthandlerExceptHandler { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + type_, + name, + body, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.type_.to_pyo3_ast(py)?, - self.name.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, + type_.to_pyo3_ast(py)?, + name.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -3014,18 +4403,30 @@ impl ToPyo3Ast for crate::Arguments { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + posonlyargs, + args, + vararg, + kwonlyargs, + kw_defaults, + kwarg, + defaults, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.posonlyargs.to_pyo3_ast(py)?, - self.args.to_pyo3_ast(py)?, - self.vararg.to_pyo3_ast(py)?, - self.kwonlyargs.to_pyo3_ast(py)?, - self.kw_defaults.to_pyo3_ast(py)?, - self.kwarg.to_pyo3_ast(py)?, - self.defaults.to_pyo3_ast(py)?, + posonlyargs.to_pyo3_ast(py)?, + args.to_pyo3_ast(py)?, + vararg.to_pyo3_ast(py)?, + kwonlyargs.to_pyo3_ast(py)?, + kw_defaults.to_pyo3_ast(py)?, + kwarg.to_pyo3_ast(py)?, + defaults.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -3034,14 +4435,30 @@ impl ToPyo3Ast for crate::Arg { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + arg, + annotation, + type_comment, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.arg.to_pyo3_ast(py)?, - self.annotation.to_pyo3_ast(py)?, - self.type_comment.to_pyo3_ast(py)?, + arg.to_pyo3_ast(py)?, + annotation.to_pyo3_ast(py)?, + type_comment.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -3050,9 +4467,24 @@ impl ToPyo3Ast for crate::Keyword { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + arg, + value, + range: _range, + } = self; let instance = cache .0 - .call1(py, (self.arg.to_pyo3_ast(py)?, self.value.to_pyo3_ast(py)?))?; + .call1(py, (arg.to_pyo3_ast(py)?, value.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -3061,10 +4493,24 @@ impl ToPyo3Ast for crate::Alias { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.name.to_pyo3_ast(py)?, self.asname.to_pyo3_ast(py)?), - )?; + + let Self { + name, + asname, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (name.to_pyo3_ast(py)?, asname.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -3073,13 +4519,20 @@ impl ToPyo3Ast for crate::Withitem { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + context_expr, + optional_vars, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.context_expr.to_pyo3_ast(py)?, - self.optional_vars.to_pyo3_ast(py)?, + context_expr.to_pyo3_ast(py)?, + optional_vars.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -3088,14 +4541,22 @@ impl ToPyo3Ast for crate::MatchCase { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + pattern, + guard, + body, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.pattern.to_pyo3_ast(py)?, - self.guard.to_pyo3_ast(py)?, - self.body.to_pyo3_ast(py)?, + pattern.to_pyo3_ast(py)?, + guard.to_pyo3_ast(py)?, + body.to_pyo3_ast(py)?, ), )?; + Ok(instance) } } @@ -3121,7 +4582,21 @@ impl ToPyo3Ast for crate::PatternMatchValue { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -3130,7 +4605,21 @@ impl ToPyo3Ast for crate::PatternMatchSingleton { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.value.to_pyo3_ast(py)?,))?; + + let Self { + value, + range: _range, + } = self; + let instance = cache.0.call1(py, (value.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -3139,7 +4628,21 @@ impl ToPyo3Ast for crate::PatternMatchSequence { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.patterns.to_pyo3_ast(py)?,))?; + + let Self { + patterns, + range: _range, + } = self; + let instance = cache.0.call1(py, (patterns.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -3148,14 +4651,30 @@ impl ToPyo3Ast for crate::PatternMatchMapping { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + keys, + patterns, + rest, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.keys.to_pyo3_ast(py)?, - self.patterns.to_pyo3_ast(py)?, - self.rest.to_pyo3_ast(py)?, + keys.to_pyo3_ast(py)?, + patterns.to_pyo3_ast(py)?, + rest.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -3164,15 +4683,32 @@ impl ToPyo3Ast for crate::PatternMatchClass { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); + + let Self { + cls, + patterns, + kwd_attrs, + kwd_patterns, + range: _range, + } = self; let instance = cache.0.call1( py, ( - self.cls.to_pyo3_ast(py)?, - self.patterns.to_pyo3_ast(py)?, - self.kwd_attrs.to_pyo3_ast(py)?, - self.kwd_patterns.to_pyo3_ast(py)?, + cls.to_pyo3_ast(py)?, + patterns.to_pyo3_ast(py)?, + kwd_attrs.to_pyo3_ast(py)?, + kwd_patterns.to_pyo3_ast(py)?, ), )?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -3181,7 +4717,21 @@ impl ToPyo3Ast for crate::PatternMatchStar { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.name.to_pyo3_ast(py)?,))?; + + let Self { + name, + range: _range, + } = self; + let instance = cache.0.call1(py, (name.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -3190,10 +4740,24 @@ impl ToPyo3Ast for crate::PatternMatchAs { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.pattern.to_pyo3_ast(py)?, self.name.to_pyo3_ast(py)?), - )?; + + let Self { + pattern, + name, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (pattern.to_pyo3_ast(py)?, name.to_pyo3_ast(py)?))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -3202,7 +4766,21 @@ impl ToPyo3Ast for crate::PatternMatchOr { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1(py, (self.patterns.to_pyo3_ast(py)?,))?; + + let Self { + patterns, + range: _range, + } = self; + let instance = cache.0.call1(py, (patterns.to_pyo3_ast(py)?,))?; + + let cache = ast_key_cache().get().unwrap(); + instance.setattr(py, cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(py, cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(py, cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(py, cache.end_col_offset.as_ref(py), end.column.get())?; + } + Ok(instance) } } @@ -3221,15 +4799,21 @@ impl ToPyo3Ast for crate::TypeIgnoreTypeIgnore { #[inline] fn to_pyo3_ast(&self, py: Python) -> PyResult> { let cache = Self::py_type_cache().get().unwrap(); - let instance = cache.0.call1( - py, - (self.lineno.to_pyo3_ast(py)?, self.tag.to_pyo3_ast(py)?), - )?; + + let Self { + lineno, + tag, + range: _range, + } = self; + let instance = cache + .0 + .call1(py, (lineno.to_pyo3_ast(py)?, tag.to_pyo3_ast(py)?))?; + Ok(instance) } } -pub fn init(py: Python) -> PyResult<()> { +fn init_types(py: Python) -> PyResult<()> { let ast_module = PyModule::import(py, "_ast")?; cache_py_type::(ast_module)?; cache_py_type::(ast_module)?; diff --git a/ast/src/lib.rs b/ast/src/lib.rs index 814650ef..12d37144 100644 --- a/ast/src/lib.rs +++ b/ast/src/lib.rs @@ -50,3 +50,5 @@ pub use optimizer::ConstantOptimizer; #[cfg(feature = "pyo3")] pub mod pyo3; +#[cfg(feature = "pyo3-wrapper")] +pub mod pyo3_wrapper; diff --git a/ast/src/pyo3.rs b/ast/src/pyo3.rs index b1769700..e54fff2e 100644 --- a/ast/src/pyo3.rs +++ b/ast/src/pyo3.rs @@ -1,8 +1,10 @@ use crate::{source_code::SourceRange, text_size::TextRange, ConversionFlag, Node}; use num_complex::Complex64; use once_cell::sync::OnceCell; -use pyo3::prelude::*; -use pyo3::types::{PyBytes, PyList, PyTuple}; +use pyo3::{ + prelude::*, + types::{PyBytes, PyList, PyString, PyTuple}, +}; pub trait Pyo3Node { fn py_type_cache() -> &'static OnceCell<(Py, Py)> { @@ -113,11 +115,39 @@ impl AST { } fn cache_py_type(ast_module: &PyAny) -> PyResult<()> { - let class = ast_module.getattr(N::NAME).unwrap(); - let base = class.getattr("__new__").unwrap(); + let class = ast_module.getattr(N::NAME)?; + let base = if std::mem::size_of::() == 0 { + class.call0()? + } else { + class.getattr("__new__")? + }; N::py_type_cache().get_or_init(|| (class.into(), base.into())); - Ok(()) } +struct AstKeyCache { + lineno: Py, + col_offset: Py, + end_lineno: Py, + end_col_offset: Py, +} + +fn ast_key_cache() -> &'static OnceCell { + { + static PY_TYPE: OnceCell = OnceCell::new(); + &PY_TYPE + } +} + +pub fn init(py: Python) -> PyResult<()> { + ast_key_cache().get_or_init(|| AstKeyCache { + lineno: pyo3::intern!(py, "lineno").into_py(py), + col_offset: pyo3::intern!(py, "col_offset").into_py(py), + end_lineno: pyo3::intern!(py, "end_lineno").into_py(py), + end_col_offset: pyo3::intern!(py, "end_col_offset").into_py(py), + }); + + init_types(py) +} + include!("gen/to_pyo3.rs"); diff --git a/ast/src/pyo3_wrapper.rs b/ast/src/pyo3_wrapper.rs new file mode 100644 index 00000000..a622ed06 --- /dev/null +++ b/ast/src/pyo3_wrapper.rs @@ -0,0 +1,128 @@ +use crate::pyo3::{Pyo3Node, AST}; +use crate::{source_code::SourceRange, text_size::TextRange, ConversionFlag, Node}; +use num_complex::Complex64; +use pyo3::prelude::*; +use pyo3::types::{PyBytes, PyList, PyTuple}; + +pub trait ToPyo3Wrapper { + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult>; +} + +impl ToPyo3Wrapper for Box { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + (**self).to_pyo3_wrapper(py) + } +} + +impl ToPyo3Wrapper for Option { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match self { + Some(ast) => ast.to_pyo3_wrapper(py), + None => Ok(py.None()), + } + } +} + +impl ToPyo3Wrapper for crate::Identifier { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(self.as_str().to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::String { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok(self.as_str().to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::Int { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok((self.to_u32()).to_object(py)) + } +} + +impl ToPyo3Wrapper for bool { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok((*self as u32).to_object(py)) + } +} + +impl ToPyo3Wrapper for ConversionFlag { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + Ok((*self as i8).to_object(py)) + } +} + +impl ToPyo3Wrapper for crate::Constant { + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + let value = match self { + crate::Constant::None => py.None(), + crate::Constant::Bool(bool) => bool.to_object(py), + crate::Constant::Str(string) => string.to_object(py), + crate::Constant::Bytes(bytes) => PyBytes::new(py, bytes).into(), + crate::Constant::Int(int) => int.to_object(py), + crate::Constant::Tuple(elts) => { + let elts: PyResult> = elts.iter().map(|c| c.to_pyo3_wrapper(py)).collect(); + PyTuple::new(py, elts?).into() + } + crate::Constant::Float(f64) => f64.to_object(py), + crate::Constant::Complex { real, imag } => Complex64::new(*real, *imag).to_object(py), + crate::Constant::Ellipsis => py.Ellipsis(), + }; + Ok(value) + } +} + +impl ToPyo3Wrapper for Vec { + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + let list = PyList::empty(py); + for item in self { + let py_item = item.to_pyo3_wrapper(py)?; + list.append(py_item)?; + } + Ok(list.into()) + } +} + +pub mod located { + use super::*; + pub use crate::pyo3::AST; + include!("gen/pyo3_wrapper_located.rs"); +} + +pub mod ranged { + use super::*; + pub use crate::pyo3::AST; + include!("gen/pyo3_wrapper_ranged.rs"); +} + +fn init_type(py: Python, m: &PyModule) -> PyResult<()> { + m.add_class::

()?; + let node = m.getattr(P::NAME)?; + if P::NAME != N::NAME { + // TODO: no idea how to escape rust keyword on #[pyclass] + m.setattr(P::NAME, node)?; + } + let names: Vec<&'static str> = N::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + Ok(()) +} + +/// A Python module implemented in Rust. +fn init_module(py: Python, m: &PyModule) -> PyResult<()> { + m.add_class::()?; + + let ast = m.getattr("AST")?; + let fields = PyTuple::empty(py); + ast.setattr("_fields", fields)?; + + Ok(()) +}