diff --git a/Cargo.toml b/Cargo.toml index 38cedc5..8e43b18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" @@ -30,6 +32,7 @@ log = "0.4.16" num-complex = "0.4.0" num-bigint = "0.4.3" num-traits = "0.2" +pyo3 = { version = "0.18.3" } rand = "0.8.5" serde = "1.0" static_assertions = "1.1" diff --git a/ast/Cargo.toml b/ast/Cargo.toml index 3f4f390..dfd18c4 100644 --- a/ast/Cargo.toml +++ b/ast/Cargo.toml @@ -23,3 +23,6 @@ rustpython-literal = { workspace = true, optional = true } is-macro = { workspace = true } num-bigint = { workspace = true } static_assertions = "1.1.0" +num-complex = { workspace = true } +once_cell = { workspace = true } +pyo3 = { workspace = true, optional = true, features = ["num-bigint", "num-complex"] } diff --git a/ast/asdl_rs.py b/ast/asdl_rs.py index 5ec4cfd..c8e2431 100755 --- a/ast/asdl_rs.py +++ b/ast/asdl_rs.py @@ -711,6 +711,583 @@ class VisitorModuleVisitor(EmitVisitor): VisitorTraitDefVisitor(self.file, self.type_info).visit(mod, depth) +class ToPyo3AstVisitor(EmitVisitor): + """Visitor to generate type-defs for AST.""" + + def __init__(self, namespace, *args, **kw): + super().__init__(*args, **kw) + self.namespace = namespace + + 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( + f""" + // product + impl ToPyo3Ast for crate::{self.namespace}::{rust_name} {{ + fn to_pyo3_ast(&self, _py: Python) -> PyResult> {{ + let class = ranged::{rust_name}::py_type_cell().get().unwrap(); + let instance = class.call1(_py, ( + """, + 0, + ) + for field in product.fields: + self.emit(f"""self.{field.name}.to_pyo3_ast(_py)?,""", depth + 1) + self.emit( + """ + ))?; + Ok(instance.into()) + } + } + """, + 0, + ) + + def visitSum(self, sum, name, depth=0): + rust_name = rust_type_name(name) + + self.emit( + f""" + impl ToPyo3Ast for crate::{self.namespace}::{rust_name} {{ + fn to_pyo3_ast(&self, _py: Python) -> PyResult> {{ + let instance = match &self {{ + """, + 0, + ) + + for cons in sum.types: + if not is_simple(sum): + self.emit( + f"""crate::{rust_name}::{cons.name}(cons) => cons.to_pyo3_ast(_py)?,""", + depth, + ) + else: + self.emit( + f"""crate::{rust_name}::{cons.name} => ranged::{rust_name}{cons.name}::py_type_cell().get().unwrap().clone(),""", + depth, + ) + + self.emit( + """ + }; + Ok(instance) + } + } + """, + 0, + ) + + if is_simple(sum): + return + + for cons in sum.types: + self.visit(cons, rust_name, depth) + + def visitConstructor(self, cons, parent, depth): + self.emit( + f""" + // constructor + impl ToPyo3Ast for crate::{self.namespace}::{parent}{cons.name} {{ + fn to_pyo3_ast(&self, _py: Python) -> PyResult> {{ + let class = ranged::{parent}{cons.name}::py_type_cell().get().unwrap(); + let instance = class.call1(_py, ( + """, + depth, + ) + for field in cons.fields: + self.emit( + f"self.{rust_field(field.name)}.to_pyo3_ast(_py)?,", + depth + 1, + ) + self.emit( + """ + ))?; + Ok(instance.into()) + } + } + """, + depth, + ) + + +class RangedDefVisitor(EmitVisitor): + 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 visitSum(self, sum, name, depth): + info = self.type_info[name] + + self.emit_type_alias(info) + + if info.is_simple: + return + + sum_match_arms = "" + + for ty in sum.types: + variant_info = self.type_info[ty.name] + sum_match_arms += ( + f" Self::{variant_info.rust_name}(node) => node.range()," + ) + self.emit_type_alias(variant_info) + self.emit_ranged_impl(variant_info) + + if not info.no_cfg(self.type_info): + self.emit('#[cfg(feature = "all-nodes-with-ranges")]', 0) + + self.emit( + f""" + impl Ranged for crate::{info.rust_sum_name} {{ + fn range(&self) -> TextRange {{ + match self {{ + {sum_match_arms} + }} + }} + }} + """.lstrip(), + 0, + ) + + def visitProduct(self, product, name, depth): + info = self.type_info[name] + + self.emit_type_alias(info) + self.emit_ranged_impl(info) + + def emit_type_alias(self, info): + generics = "" if info.is_simple else "::" + + self.emit( + f"pub type {info.rust_sum_name} = crate::generic::{info.rust_sum_name}{generics};", + 0, + ) + self.emit("", 0) + + def emit_ranged_impl(self, info): + if not info.no_cfg(self.type_info): + self.emit('#[cfg(feature = "all-nodes-with-ranges")]', 0) + + self.file.write( + f""" + impl Ranged for crate::generic::{info.rust_sum_name}:: {{ + fn range(&self) -> TextRange {{ + self.range + }} + }} + """.strip() + ) + + +class LocatedDefVisitor(EmitVisitor): + 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 visitSum(self, sum, name, depth): + info = self.type_info[name] + + self.emit_type_alias(info) + + if info.is_simple: + return + + sum_match_arms = "" + + for ty in sum.types: + variant_info = self.type_info[ty.name] + sum_match_arms += ( + f" Self::{variant_info.rust_name}(node) => node.range()," + ) + self.emit_type_alias(variant_info) + self.emit_located_impl(variant_info) + + if not info.no_cfg(self.type_info): + self.emit('#[cfg(feature = "all-nodes-with-ranges")]', 0) + + self.emit( + f""" + impl Located for {info.rust_sum_name} {{ + fn range(&self) -> SourceRange {{ + match self {{ + {sum_match_arms} + }} + }} + }} + """.lstrip(), + 0, + ) + + def visitProduct(self, product, name, depth): + info = self.type_info[name] + + self.emit_type_alias(info) + self.emit_located_impl(info) + + def emit_type_alias(self, info): + generics = "" if info.is_simple else "::" + + self.emit( + f"pub type {info.rust_sum_name} = crate::generic::{info.rust_sum_name}{generics};", + 0, + ) + self.emit("", 0) + + def emit_located_impl(self, info): + if not info.no_cfg(self.type_info): + self.emit('#[cfg(feature = "all-nodes-with-ranges")]', 0) + + self.emit( + f""" + impl Located for {info.rust_sum_name} {{ + fn range(&self) -> SourceRange {{ + self.range + }} + }} + """, + 0, + ) + + +class Pyo3StructVisitor(EmitVisitor): + """Visitor to generate type-defs for AST.""" + + def __init__(self, namespace, *args, borrow=False, **kw): + self.namespace = namespace + self.borrow = borrow + super().__init__(*args, **kw) + + @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, subclass, base="super::AST"): + if subclass: + subclass = ", subclass" + body = "" + into = f"{rust_name}" + else: + subclass = "" + body = f"(pub {self.ref_def} crate::{self.namespace}::{rust_name})" + into = f"{rust_name}(node)" + + self.emit( + textwrap.dedent( + f""" + #[pyclass(module="{self.module_name}", name="_{name}", extends={base}{subclass})] + #[derive(Clone, Debug)] + pub struct {rust_name} {body}; + + impl {rust_name} {{ + #[inline] + pub fn py_type_cell() -> &'static OnceCell> {{ + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + }} + }} + + impl From<{self.ref_def} crate::{self.namespace}::{rust_name}> for {rust_name} {{ + fn from({"" if body else "_"}node: {self.ref_def} crate::{self.namespace}::{rust_name}) -> 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 = PyClassInitializer::from(AST) + .add_subclass(self.clone()); + 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 self.borrow and not subclass: + self.emit_wrapper(rust_name) + + def emit_getter(self, owner, type_name): + self.emit( + textwrap.dedent( + f""" + #[pymethods] + impl {type_name} {{ + """ + ), + 0, + ) + + for field in owner.fields: + self.emit( + textwrap.dedent( + f""" + #[getter] + #[inline] + 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::{self.namespace}::{rust_name} {{ + #[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.name, depth) + + def visitSum(self, sum, name, depth=0): + rust_name = rust_type_name(name) + self.emit_class(name, rust_name, True) + + simple = is_simple(sum) + + if self.borrow: + self.emit( + f""" + impl ToPyo3Wrapper for crate::{self.namespace}::{rust_name} {{ + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> {{ + match &self {{ + """, + 0, + ) + + for cons in sum.types: + if simple: + self.emit( + f"Self::{cons.name} => Ok({rust_name}{cons.name}.to_object(py)),", + 3, + ) + else: + self.emit( + f"Self::{cons.name}(cons) => cons.to_pyo3_wrapper(py),", 3 + ) + + self.emit( + f""" + }} + }} + }} + """, + 0, + ) + + for cons in sum.types: + self.visit(cons, rust_name, simple, depth + 1) + + def visitProduct(self, product, name, depth=0): + rust_name = rust_type_name(name) + self.emit_class(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 {parent}{cons.name} {{ + #[inline] + pub fn py_type_cell() -> &'static OnceCell> {{ + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + }} +}} + +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}", subclass=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, depth) + + def visitSum(self, sum, name, depth): + rust_name = rust_type_name(name) + simple = is_simple(sum) + self.emit_fields(name, rust_name, True, depth) + + 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, depth) + + def emit_fields(self, name, rust_name, simple, depth): + if simple: + call = ".call0().unwrap()" + else: + call = "" + self.emit( + f""" +{rust_name}::py_type_cell().get_or_init(|| {{ + ast_module.getattr("{name}").unwrap(){call}.into_py(py) +}}); + """, + depth, + ) + if simple: + return + self.emit( + f""" +{{ + m.add_class::<{rust_name}>()?; + let node = m.getattr("_{name}")?; + m.setattr("{name}", node)?; + let names: Vec<&'static str> = crate::{self.namespace}::{rust_name}::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; +}} + """, + depth, + ) + + class StdlibClassDefVisitor(EmitVisitor): def visitModule(self, mod): for dfn in mod.dfns: @@ -1011,138 +1588,6 @@ class StdlibTraitImplVisitor(EmitVisitor): return f"Node::ast_from_object(_vm, get_node_field(_vm, &_object, {name}, {json.dumps(typename)})?)?" -class RangedDefVisitor(EmitVisitor): - 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 visitSum(self, sum, name, depth): - info = self.type_info[name] - - if info.is_simple: - return - - sum_match_arms = "" - - for ty in sum.types: - variant_info = self.type_info[ty.name] - sum_match_arms += ( - f" Self::{variant_info.rust_name}(node) => node.range()," - ) - self.emit_ranged_impl(variant_info) - - if not info.no_cfg(self.type_info): - self.emit('#[cfg(feature = "all-nodes-with-ranges")]', 0) - - self.emit( - f""" - impl Ranged for crate::{info.rust_sum_name} {{ - fn range(&self) -> TextRange {{ - match self {{ - {sum_match_arms} - }} - }} - }} - """.lstrip(), - 0, - ) - - def visitProduct(self, product, name, depth): - info = self.type_info[name] - - self.emit_ranged_impl(info) - - def emit_ranged_impl(self, info): - if not info.no_cfg(self.type_info): - self.emit('#[cfg(feature = "all-nodes-with-ranges")]', 0) - - self.file.write( - f""" - impl Ranged for crate::generic::{info.rust_sum_name}:: {{ - fn range(&self) -> TextRange {{ - self.range - }} - }} - """.strip() - ) - - -class LocatedDefVisitor(EmitVisitor): - 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 visitSum(self, sum, name, depth): - info = self.type_info[name] - - self.emit_type_alias(info) - - if info.is_simple: - return - - sum_match_arms = "" - - for ty in sum.types: - variant_info = self.type_info[ty.name] - sum_match_arms += ( - f" Self::{variant_info.rust_name}(node) => node.range()," - ) - self.emit_type_alias(variant_info) - self.emit_located_impl(variant_info) - - if not info.no_cfg(self.type_info): - self.emit('#[cfg(feature = "all-nodes-with-ranges")]', 0) - - self.emit( - f""" - impl Located for {info.rust_sum_name} {{ - fn range(&self) -> SourceRange {{ - match self {{ - {sum_match_arms} - }} - }} - }} - """.lstrip(), - 0, - ) - - def visitProduct(self, product, name, depth): - info = self.type_info[name] - - self.emit_type_alias(info) - self.emit_located_impl(info) - - def emit_type_alias(self, info): - generics = "" if info.is_simple else "::" - - self.emit( - f"pub type {info.rust_sum_name} = crate::generic::{info.rust_sum_name}{generics};", - 0, - ) - self.emit("", 0) - - def emit_located_impl(self, info): - if not info.no_cfg(self.type_info): - self.emit('#[cfg(feature = "all-nodes-with-ranges")]', 0) - - self.emit( - f""" - impl Located for {info.rust_sum_name} {{ - fn range(&self) -> SourceRange {{ - self.range - }} - }} - """, - 0, - ) - - class ChainOfVisitors: def __init__(self, *visitors): self.visitors = visitors @@ -1174,6 +1619,27 @@ def write_located_def(mod, type_info, f): LocatedDefVisitor(f, type_info).visit(mod) +def write_ast_pyo3(mod, type_info, namespace, f): + ToPyo3AstVisitor(namespace, f, type_info).visit(mod) + + +def write_pyo3_def(mod, type_info, namespace, borrow, f): + Pyo3StructVisitor(namespace, f, type_info, borrow=borrow).visit(mod) + + f.write( + """ + use once_cell::sync::OnceCell; + + pub fn add_to_module(py: Python, m: &PyModule) -> PyResult<()> { + super::init_module(py, m)?; + + let ast_module = PyModule::import(py, "_ast")?; + """ + ) + Pyo3PymoduleVisitor(namespace, f, type_info).visit(mod) + f.write("Ok(())\n}") + + def write_ast_mod(mod, type_info, f): f.write( textwrap.dedent( @@ -1211,16 +1677,29 @@ def main( type_info = {} FindUserDataTypesVisitor(type_info).visit(mod) + from functools import partial as p + for filename, write in [ - ("generic", write_ast_def), - ("fold", write_fold_def), - ("ranged", write_ranged_def), - ("located", write_located_def), - ("visitor", write_visitor_def), + ("generic", p(write_ast_def, mod, type_info)), + ("fold", p(write_fold_def, mod, type_info)), + ("ranged", p(write_ranged_def, mod, type_info)), + ("located", p(write_located_def, mod, type_info)), + ("visitor", p(write_visitor_def, mod, type_info)), + ("to_pyo3_located", p(write_ast_pyo3, mod, type_info, "located")), + ("to_pyo3_ranged", p(write_ast_pyo3, mod, type_info, "ranged")), + # ("pyo3_located", p(write_pyo3_def, mod, type_info, "located", True)), + ("pyo3_ranged", p(write_pyo3_def, mod, type_info, "ranged", True)), ]: with (ast_dir / f"{filename}.rs").open("w") as f: f.write(auto_gen_msg) - write(mod, type_info, f) + write(f) + + # for filename, write in [ + + # ]: + # with (pyo3_dir / f"{filename}.rs").open("w") as f: + # f.write(auto_gen_msg) + # write(mod, type_info, f) with module_filename.open("w") as module_file: module_file.write(auto_gen_msg) diff --git a/ast/src/gen/pyo3_ranged.rs b/ast/src/gen/pyo3_ranged.rs new file mode 100644 index 0000000..d598f4e --- /dev/null +++ b/ast/src/gen/pyo3_ranged.rs @@ -0,0 +1,6267 @@ +// File automatically generated by ast/asdl_rs.py. + +#[pyclass(module="rustpython_ast.ranged", name="_mod", extends=super::AST, subclass)] +#[derive(Clone, Debug)] +pub struct Mod; + +impl Mod { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Mod> for Mod { + fn from(_node: &'static crate::ranged::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 = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ranged::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)] +#[derive(Clone, Debug)] +pub struct ModModule(pub &'static crate::ranged::ModModule); + +impl ModModule { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ModModule> for ModModule { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ModInteractive(pub &'static crate::ranged::ModInteractive); + +impl ModInteractive { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ModInteractive> for ModInteractive { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ModExpression(pub &'static crate::ranged::ModExpression); + +impl ModExpression { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ModExpression> for ModExpression { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ModFunctionType(pub &'static crate::ranged::ModFunctionType); + +impl ModFunctionType { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ModFunctionType> for ModFunctionType { + fn from(node: &'static crate::ranged::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::ranged::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, subclass)] +#[derive(Clone, Debug)] +pub struct Stmt; + +impl Stmt { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Stmt> for Stmt { + fn from(_node: &'static crate::ranged::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 = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtFunctionDef(pub &'static crate::ranged::StmtFunctionDef); + +impl StmtFunctionDef { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtFunctionDef> for StmtFunctionDef { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtAsyncFunctionDef(pub &'static crate::ranged::StmtAsyncFunctionDef); + +impl StmtAsyncFunctionDef { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtAsyncFunctionDef> for StmtAsyncFunctionDef { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtClassDef(pub &'static crate::ranged::StmtClassDef); + +impl StmtClassDef { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtClassDef> for StmtClassDef { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtReturn(pub &'static crate::ranged::StmtReturn); + +impl StmtReturn { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtReturn> for StmtReturn { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtDelete(pub &'static crate::ranged::StmtDelete); + +impl StmtDelete { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtDelete> for StmtDelete { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtAssign(pub &'static crate::ranged::StmtAssign); + +impl StmtAssign { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtAssign> for StmtAssign { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtAugAssign(pub &'static crate::ranged::StmtAugAssign); + +impl StmtAugAssign { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtAugAssign> for StmtAugAssign { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtAnnAssign(pub &'static crate::ranged::StmtAnnAssign); + +impl StmtAnnAssign { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtAnnAssign> for StmtAnnAssign { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtFor(pub &'static crate::ranged::StmtFor); + +impl StmtFor { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtFor> for StmtFor { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtAsyncFor(pub &'static crate::ranged::StmtAsyncFor); + +impl StmtAsyncFor { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtAsyncFor> for StmtAsyncFor { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtWhile(pub &'static crate::ranged::StmtWhile); + +impl StmtWhile { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtWhile> for StmtWhile { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtIf(pub &'static crate::ranged::StmtIf); + +impl StmtIf { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtIf> for StmtIf { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtWith(pub &'static crate::ranged::StmtWith); + +impl StmtWith { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtWith> for StmtWith { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtAsyncWith(pub &'static crate::ranged::StmtAsyncWith); + +impl StmtAsyncWith { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtAsyncWith> for StmtAsyncWith { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtMatch(pub &'static crate::ranged::StmtMatch); + +impl StmtMatch { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtMatch> for StmtMatch { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtRaise(pub &'static crate::ranged::StmtRaise); + +impl StmtRaise { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtRaise> for StmtRaise { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtTry(pub &'static crate::ranged::StmtTry); + +impl StmtTry { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtTry> for StmtTry { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtTryStar(pub &'static crate::ranged::StmtTryStar); + +impl StmtTryStar { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtTryStar> for StmtTryStar { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtAssert(pub &'static crate::ranged::StmtAssert); + +impl StmtAssert { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtAssert> for StmtAssert { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtImport(pub &'static crate::ranged::StmtImport); + +impl StmtImport { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtImport> for StmtImport { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtImportFrom(pub &'static crate::ranged::StmtImportFrom); + +impl StmtImportFrom { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtImportFrom> for StmtImportFrom { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtGlobal(pub &'static crate::ranged::StmtGlobal); + +impl StmtGlobal { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtGlobal> for StmtGlobal { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtNonlocal(pub &'static crate::ranged::StmtNonlocal); + +impl StmtNonlocal { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtNonlocal> for StmtNonlocal { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtExpr(pub &'static crate::ranged::StmtExpr); + +impl StmtExpr { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtExpr> for StmtExpr { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtPass(pub &'static crate::ranged::StmtPass); + +impl StmtPass { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtPass> for StmtPass { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtBreak(pub &'static crate::ranged::StmtBreak); + +impl StmtBreak { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtBreak> for StmtBreak { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct StmtContinue(pub &'static crate::ranged::StmtContinue); + +impl StmtContinue { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::StmtContinue> for StmtContinue { + fn from(node: &'static crate::ranged::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::ranged::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, subclass)] +#[derive(Clone, Debug)] +pub struct Expr; + +impl Expr { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Expr> for Expr { + fn from(_node: &'static crate::ranged::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 = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprBoolOp(pub &'static crate::ranged::ExprBoolOp); + +impl ExprBoolOp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprBoolOp> for ExprBoolOp { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprNamedExpr(pub &'static crate::ranged::ExprNamedExpr); + +impl ExprNamedExpr { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprNamedExpr> for ExprNamedExpr { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprBinOp(pub &'static crate::ranged::ExprBinOp); + +impl ExprBinOp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprBinOp> for ExprBinOp { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprUnaryOp(pub &'static crate::ranged::ExprUnaryOp); + +impl ExprUnaryOp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprUnaryOp> for ExprUnaryOp { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprLambda(pub &'static crate::ranged::ExprLambda); + +impl ExprLambda { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprLambda> for ExprLambda { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprIfExp(pub &'static crate::ranged::ExprIfExp); + +impl ExprIfExp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprIfExp> for ExprIfExp { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprDict(pub &'static crate::ranged::ExprDict); + +impl ExprDict { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprDict> for ExprDict { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprSet(pub &'static crate::ranged::ExprSet); + +impl ExprSet { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprSet> for ExprSet { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprListComp(pub &'static crate::ranged::ExprListComp); + +impl ExprListComp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprListComp> for ExprListComp { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprSetComp(pub &'static crate::ranged::ExprSetComp); + +impl ExprSetComp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprSetComp> for ExprSetComp { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprDictComp(pub &'static crate::ranged::ExprDictComp); + +impl ExprDictComp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprDictComp> for ExprDictComp { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprGeneratorExp(pub &'static crate::ranged::ExprGeneratorExp); + +impl ExprGeneratorExp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprGeneratorExp> for ExprGeneratorExp { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprAwait(pub &'static crate::ranged::ExprAwait); + +impl ExprAwait { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprAwait> for ExprAwait { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprYield(pub &'static crate::ranged::ExprYield); + +impl ExprYield { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprYield> for ExprYield { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprYieldFrom(pub &'static crate::ranged::ExprYieldFrom); + +impl ExprYieldFrom { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprYieldFrom> for ExprYieldFrom { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprCompare(pub &'static crate::ranged::ExprCompare); + +impl ExprCompare { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprCompare> for ExprCompare { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprCall(pub &'static crate::ranged::ExprCall); + +impl ExprCall { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprCall> for ExprCall { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprFormattedValue(pub &'static crate::ranged::ExprFormattedValue); + +impl ExprFormattedValue { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprFormattedValue> for ExprFormattedValue { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprJoinedStr(pub &'static crate::ranged::ExprJoinedStr); + +impl ExprJoinedStr { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprJoinedStr> for ExprJoinedStr { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprConstant(pub &'static crate::ranged::ExprConstant); + +impl ExprConstant { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprConstant> for ExprConstant { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprAttribute(pub &'static crate::ranged::ExprAttribute); + +impl ExprAttribute { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprAttribute> for ExprAttribute { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprSubscript(pub &'static crate::ranged::ExprSubscript); + +impl ExprSubscript { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprSubscript> for ExprSubscript { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprStarred(pub &'static crate::ranged::ExprStarred); + +impl ExprStarred { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprStarred> for ExprStarred { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprName(pub &'static crate::ranged::ExprName); + +impl ExprName { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprName> for ExprName { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprList(pub &'static crate::ranged::ExprList); + +impl ExprList { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprList> for ExprList { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprTuple(pub &'static crate::ranged::ExprTuple); + +impl ExprTuple { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprTuple> for ExprTuple { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExprSlice(pub &'static crate::ranged::ExprSlice); + +impl ExprSlice { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprSlice> for ExprSlice { + fn from(node: &'static crate::ranged::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::ranged::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, subclass)] +#[derive(Clone, Debug)] +pub struct ExprContext; + +impl ExprContext { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExprContext> for ExprContext { + fn from(_node: &'static crate::ranged::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 = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ranged::ExprContext { + #[inline] + fn to_pyo3_wrapper(&'static 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)), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Load", extends=ExprContext)] +pub struct ExprContextLoad; + +impl ExprContextLoad { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 ExprContextStore { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 ExprContextDel { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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, subclass)] +#[derive(Clone, Debug)] +pub struct Boolop; + +impl Boolop { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Boolop> for Boolop { + fn from(_node: &'static crate::ranged::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 = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ranged::Boolop { + #[inline] + fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::And => Ok(BoolopAnd.to_object(py)), + Self::Or => Ok(BoolopOr.to_object(py)), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_And", extends=Boolop)] +pub struct BoolopAnd; + +impl BoolopAnd { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 BoolopOr { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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, subclass)] +#[derive(Clone, Debug)] +pub struct Operator; + +impl Operator { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Operator> for Operator { + fn from(_node: &'static crate::ranged::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 = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ranged::Operator { + #[inline] + fn to_pyo3_wrapper(&'static 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)), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Add", extends=Operator)] +pub struct OperatorAdd; + +impl OperatorAdd { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 OperatorSub { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 OperatorMult { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 OperatorMatMult { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 OperatorDiv { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 OperatorMod { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 OperatorPow { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 OperatorLShift { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 OperatorRShift { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 OperatorBitOr { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 OperatorBitXor { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 OperatorBitAnd { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 OperatorFloorDiv { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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, subclass)] +#[derive(Clone, Debug)] +pub struct Unaryop; + +impl Unaryop { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Unaryop> for Unaryop { + fn from(_node: &'static crate::ranged::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 = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ranged::Unaryop { + #[inline] + fn to_pyo3_wrapper(&'static 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)), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Invert", extends=Unaryop)] +pub struct UnaryopInvert; + +impl UnaryopInvert { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 UnaryopNot { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 UnaryopUAdd { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 UnaryopUSub { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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, subclass)] +#[derive(Clone, Debug)] +pub struct Cmpop; + +impl Cmpop { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Cmpop> for Cmpop { + fn from(_node: &'static crate::ranged::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 = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ranged::Cmpop { + #[inline] + fn to_pyo3_wrapper(&'static 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)), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Eq", extends=Cmpop)] +pub struct CmpopEq; + +impl CmpopEq { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 CmpopNotEq { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 CmpopLt { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 CmpopLtE { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 CmpopGt { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 CmpopGtE { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 CmpopIs { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 CmpopIsNot { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 CmpopIn { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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 CmpopNotIn { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +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)] +#[derive(Clone, Debug)] +pub struct Comprehension(pub &'static crate::ranged::Comprehension); + +impl Comprehension { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Comprehension> for Comprehension { + fn from(node: &'static crate::ranged::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::ranged::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, subclass)] +#[derive(Clone, Debug)] +pub struct Excepthandler; + +impl Excepthandler { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Excepthandler> for Excepthandler { + fn from(_node: &'static crate::ranged::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 = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ranged::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)] +#[derive(Clone, Debug)] +pub struct ExcepthandlerExceptHandler(pub &'static crate::ranged::ExcepthandlerExceptHandler); + +impl ExcepthandlerExceptHandler { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::ExcepthandlerExceptHandler> for ExcepthandlerExceptHandler { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct Arguments(pub &'static crate::ranged::Arguments); + +impl Arguments { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Arguments> for Arguments { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct Arg(pub &'static crate::ranged::Arg); + +impl Arg { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Arg> for Arg { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct Keyword(pub &'static crate::ranged::Keyword); + +impl Keyword { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Keyword> for Keyword { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct Alias(pub &'static crate::ranged::Alias); + +impl Alias { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Alias> for Alias { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct Withitem(pub &'static crate::ranged::Withitem); + +impl Withitem { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Withitem> for Withitem { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct MatchCase(pub &'static crate::ranged::MatchCase); + +impl MatchCase { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::MatchCase> for MatchCase { + fn from(node: &'static crate::ranged::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::ranged::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, subclass)] +#[derive(Clone, Debug)] +pub struct Pattern; + +impl Pattern { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::Pattern> for Pattern { + fn from(_node: &'static crate::ranged::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 = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ranged::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)] +#[derive(Clone, Debug)] +pub struct PatternMatchValue(pub &'static crate::ranged::PatternMatchValue); + +impl PatternMatchValue { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::PatternMatchValue> for PatternMatchValue { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct PatternMatchSingleton(pub &'static crate::ranged::PatternMatchSingleton); + +impl PatternMatchSingleton { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::PatternMatchSingleton> for PatternMatchSingleton { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct PatternMatchSequence(pub &'static crate::ranged::PatternMatchSequence); + +impl PatternMatchSequence { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::PatternMatchSequence> for PatternMatchSequence { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct PatternMatchMapping(pub &'static crate::ranged::PatternMatchMapping); + +impl PatternMatchMapping { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::PatternMatchMapping> for PatternMatchMapping { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct PatternMatchClass(pub &'static crate::ranged::PatternMatchClass); + +impl PatternMatchClass { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::PatternMatchClass> for PatternMatchClass { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct PatternMatchStar(pub &'static crate::ranged::PatternMatchStar); + +impl PatternMatchStar { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::PatternMatchStar> for PatternMatchStar { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct PatternMatchAs(pub &'static crate::ranged::PatternMatchAs); + +impl PatternMatchAs { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::PatternMatchAs> for PatternMatchAs { + fn from(node: &'static crate::ranged::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::ranged::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)] +#[derive(Clone, Debug)] +pub struct PatternMatchOr(pub &'static crate::ranged::PatternMatchOr); + +impl PatternMatchOr { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::PatternMatchOr> for PatternMatchOr { + fn from(node: &'static crate::ranged::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::ranged::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, subclass)] +#[derive(Clone, Debug)] +pub struct TypeIgnore; + +impl TypeIgnore { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::TypeIgnore> for TypeIgnore { + fn from(_node: &'static crate::ranged::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 = PyClassInitializer::from(AST).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyo3Wrapper for crate::ranged::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)] +#[derive(Clone, Debug)] +pub struct TypeIgnoreTypeIgnore(pub &'static crate::ranged::TypeIgnoreTypeIgnore); + +impl TypeIgnoreTypeIgnore { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + +impl From<&'static crate::ranged::TypeIgnoreTypeIgnore> for TypeIgnoreTypeIgnore { + fn from(node: &'static crate::ranged::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::ranged::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) + } +} + +use once_cell::sync::OnceCell; + +pub fn add_to_module(py: Python, m: &PyModule) -> PyResult<()> { + super::init_module(py, m)?; + + let ast_module = PyModule::import(py, "_ast")?; + + Mod::py_type_cell().get_or_init(|| { + ast_module + .getattr("mod") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + ModModule::py_type_cell().get_or_init(|| ast_module.getattr("Module").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Module")?; + m.setattr("Module", node)?; + let names: Vec<&'static str> = crate::ranged::ModModule::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ModInteractive::py_type_cell() + .get_or_init(|| ast_module.getattr("Interactive").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Interactive")?; + m.setattr("Interactive", node)?; + let names: Vec<&'static str> = crate::ranged::ModInteractive::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ModExpression::py_type_cell() + .get_or_init(|| ast_module.getattr("Expression").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Expression")?; + m.setattr("Expression", node)?; + let names: Vec<&'static str> = crate::ranged::ModExpression::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ModFunctionType::py_type_cell() + .get_or_init(|| ast_module.getattr("FunctionType").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_FunctionType")?; + m.setattr("FunctionType", node)?; + let names: Vec<&'static str> = crate::ranged::ModFunctionType::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + Stmt::py_type_cell().get_or_init(|| { + ast_module + .getattr("stmt") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + StmtFunctionDef::py_type_cell() + .get_or_init(|| ast_module.getattr("FunctionDef").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_FunctionDef")?; + m.setattr("FunctionDef", node)?; + let names: Vec<&'static str> = crate::ranged::StmtFunctionDef::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtAsyncFunctionDef::py_type_cell() + .get_or_init(|| ast_module.getattr("AsyncFunctionDef").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_AsyncFunctionDef")?; + m.setattr("AsyncFunctionDef", node)?; + let names: Vec<&'static str> = crate::ranged::StmtAsyncFunctionDef::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtClassDef::py_type_cell() + .get_or_init(|| ast_module.getattr("ClassDef").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_ClassDef")?; + m.setattr("ClassDef", node)?; + let names: Vec<&'static str> = crate::ranged::StmtClassDef::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtReturn::py_type_cell().get_or_init(|| ast_module.getattr("Return").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Return")?; + m.setattr("Return", node)?; + let names: Vec<&'static str> = crate::ranged::StmtReturn::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtDelete::py_type_cell().get_or_init(|| ast_module.getattr("Delete").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Delete")?; + m.setattr("Delete", node)?; + let names: Vec<&'static str> = crate::ranged::StmtDelete::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtAssign::py_type_cell().get_or_init(|| ast_module.getattr("Assign").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Assign")?; + m.setattr("Assign", node)?; + let names: Vec<&'static str> = crate::ranged::StmtAssign::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtAugAssign::py_type_cell() + .get_or_init(|| ast_module.getattr("AugAssign").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_AugAssign")?; + m.setattr("AugAssign", node)?; + let names: Vec<&'static str> = crate::ranged::StmtAugAssign::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtAnnAssign::py_type_cell() + .get_or_init(|| ast_module.getattr("AnnAssign").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_AnnAssign")?; + m.setattr("AnnAssign", node)?; + let names: Vec<&'static str> = crate::ranged::StmtAnnAssign::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtFor::py_type_cell().get_or_init(|| ast_module.getattr("For").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_For")?; + m.setattr("For", node)?; + let names: Vec<&'static str> = crate::ranged::StmtFor::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtAsyncFor::py_type_cell() + .get_or_init(|| ast_module.getattr("AsyncFor").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_AsyncFor")?; + m.setattr("AsyncFor", node)?; + let names: Vec<&'static str> = crate::ranged::StmtAsyncFor::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtWhile::py_type_cell().get_or_init(|| ast_module.getattr("While").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_While")?; + m.setattr("While", node)?; + let names: Vec<&'static str> = crate::ranged::StmtWhile::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtIf::py_type_cell().get_or_init(|| ast_module.getattr("If").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_If")?; + m.setattr("If", node)?; + let names: Vec<&'static str> = crate::ranged::StmtIf::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtWith::py_type_cell().get_or_init(|| ast_module.getattr("With").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_With")?; + m.setattr("With", node)?; + let names: Vec<&'static str> = crate::ranged::StmtWith::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtAsyncWith::py_type_cell() + .get_or_init(|| ast_module.getattr("AsyncWith").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_AsyncWith")?; + m.setattr("AsyncWith", node)?; + let names: Vec<&'static str> = crate::ranged::StmtAsyncWith::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtMatch::py_type_cell().get_or_init(|| ast_module.getattr("Match").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Match")?; + m.setattr("Match", node)?; + let names: Vec<&'static str> = crate::ranged::StmtMatch::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtRaise::py_type_cell().get_or_init(|| ast_module.getattr("Raise").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Raise")?; + m.setattr("Raise", node)?; + let names: Vec<&'static str> = crate::ranged::StmtRaise::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtTry::py_type_cell().get_or_init(|| ast_module.getattr("Try").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Try")?; + m.setattr("Try", node)?; + let names: Vec<&'static str> = crate::ranged::StmtTry::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtTryStar::py_type_cell().get_or_init(|| ast_module.getattr("TryStar").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_TryStar")?; + m.setattr("TryStar", node)?; + let names: Vec<&'static str> = crate::ranged::StmtTryStar::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtAssert::py_type_cell().get_or_init(|| ast_module.getattr("Assert").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Assert")?; + m.setattr("Assert", node)?; + let names: Vec<&'static str> = crate::ranged::StmtAssert::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtImport::py_type_cell().get_or_init(|| ast_module.getattr("Import").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Import")?; + m.setattr("Import", node)?; + let names: Vec<&'static str> = crate::ranged::StmtImport::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtImportFrom::py_type_cell() + .get_or_init(|| ast_module.getattr("ImportFrom").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_ImportFrom")?; + m.setattr("ImportFrom", node)?; + let names: Vec<&'static str> = crate::ranged::StmtImportFrom::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtGlobal::py_type_cell().get_or_init(|| ast_module.getattr("Global").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Global")?; + m.setattr("Global", node)?; + let names: Vec<&'static str> = crate::ranged::StmtGlobal::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtNonlocal::py_type_cell() + .get_or_init(|| ast_module.getattr("Nonlocal").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Nonlocal")?; + m.setattr("Nonlocal", node)?; + let names: Vec<&'static str> = crate::ranged::StmtNonlocal::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtExpr::py_type_cell().get_or_init(|| ast_module.getattr("Expr").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Expr")?; + m.setattr("Expr", node)?; + let names: Vec<&'static str> = crate::ranged::StmtExpr::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtPass::py_type_cell().get_or_init(|| ast_module.getattr("Pass").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Pass")?; + m.setattr("Pass", node)?; + let names: Vec<&'static str> = crate::ranged::StmtPass::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtBreak::py_type_cell().get_or_init(|| ast_module.getattr("Break").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Break")?; + m.setattr("Break", node)?; + let names: Vec<&'static str> = crate::ranged::StmtBreak::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + StmtContinue::py_type_cell() + .get_or_init(|| ast_module.getattr("Continue").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Continue")?; + m.setattr("Continue", node)?; + let names: Vec<&'static str> = crate::ranged::StmtContinue::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + Expr::py_type_cell().get_or_init(|| { + ast_module + .getattr("expr") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + ExprBoolOp::py_type_cell().get_or_init(|| ast_module.getattr("BoolOp").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_BoolOp")?; + m.setattr("BoolOp", node)?; + let names: Vec<&'static str> = crate::ranged::ExprBoolOp::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprNamedExpr::py_type_cell() + .get_or_init(|| ast_module.getattr("NamedExpr").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_NamedExpr")?; + m.setattr("NamedExpr", node)?; + let names: Vec<&'static str> = crate::ranged::ExprNamedExpr::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprBinOp::py_type_cell().get_or_init(|| ast_module.getattr("BinOp").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_BinOp")?; + m.setattr("BinOp", node)?; + let names: Vec<&'static str> = crate::ranged::ExprBinOp::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprUnaryOp::py_type_cell().get_or_init(|| ast_module.getattr("UnaryOp").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_UnaryOp")?; + m.setattr("UnaryOp", node)?; + let names: Vec<&'static str> = crate::ranged::ExprUnaryOp::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprLambda::py_type_cell().get_or_init(|| ast_module.getattr("Lambda").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Lambda")?; + m.setattr("Lambda", node)?; + let names: Vec<&'static str> = crate::ranged::ExprLambda::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprIfExp::py_type_cell().get_or_init(|| ast_module.getattr("IfExp").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_IfExp")?; + m.setattr("IfExp", node)?; + let names: Vec<&'static str> = crate::ranged::ExprIfExp::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprDict::py_type_cell().get_or_init(|| ast_module.getattr("Dict").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Dict")?; + m.setattr("Dict", node)?; + let names: Vec<&'static str> = crate::ranged::ExprDict::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprSet::py_type_cell().get_or_init(|| ast_module.getattr("Set").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Set")?; + m.setattr("Set", node)?; + let names: Vec<&'static str> = crate::ranged::ExprSet::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprListComp::py_type_cell() + .get_or_init(|| ast_module.getattr("ListComp").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_ListComp")?; + m.setattr("ListComp", node)?; + let names: Vec<&'static str> = crate::ranged::ExprListComp::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprSetComp::py_type_cell().get_or_init(|| ast_module.getattr("SetComp").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_SetComp")?; + m.setattr("SetComp", node)?; + let names: Vec<&'static str> = crate::ranged::ExprSetComp::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprDictComp::py_type_cell() + .get_or_init(|| ast_module.getattr("DictComp").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_DictComp")?; + m.setattr("DictComp", node)?; + let names: Vec<&'static str> = crate::ranged::ExprDictComp::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprGeneratorExp::py_type_cell() + .get_or_init(|| ast_module.getattr("GeneratorExp").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_GeneratorExp")?; + m.setattr("GeneratorExp", node)?; + let names: Vec<&'static str> = crate::ranged::ExprGeneratorExp::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprAwait::py_type_cell().get_or_init(|| ast_module.getattr("Await").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Await")?; + m.setattr("Await", node)?; + let names: Vec<&'static str> = crate::ranged::ExprAwait::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprYield::py_type_cell().get_or_init(|| ast_module.getattr("Yield").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Yield")?; + m.setattr("Yield", node)?; + let names: Vec<&'static str> = crate::ranged::ExprYield::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprYieldFrom::py_type_cell() + .get_or_init(|| ast_module.getattr("YieldFrom").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_YieldFrom")?; + m.setattr("YieldFrom", node)?; + let names: Vec<&'static str> = crate::ranged::ExprYieldFrom::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprCompare::py_type_cell().get_or_init(|| ast_module.getattr("Compare").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Compare")?; + m.setattr("Compare", node)?; + let names: Vec<&'static str> = crate::ranged::ExprCompare::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprCall::py_type_cell().get_or_init(|| ast_module.getattr("Call").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Call")?; + m.setattr("Call", node)?; + let names: Vec<&'static str> = crate::ranged::ExprCall::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprFormattedValue::py_type_cell() + .get_or_init(|| ast_module.getattr("FormattedValue").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_FormattedValue")?; + m.setattr("FormattedValue", node)?; + let names: Vec<&'static str> = crate::ranged::ExprFormattedValue::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprJoinedStr::py_type_cell() + .get_or_init(|| ast_module.getattr("JoinedStr").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_JoinedStr")?; + m.setattr("JoinedStr", node)?; + let names: Vec<&'static str> = crate::ranged::ExprJoinedStr::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprConstant::py_type_cell() + .get_or_init(|| ast_module.getattr("Constant").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Constant")?; + m.setattr("Constant", node)?; + let names: Vec<&'static str> = crate::ranged::ExprConstant::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprAttribute::py_type_cell() + .get_or_init(|| ast_module.getattr("Attribute").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Attribute")?; + m.setattr("Attribute", node)?; + let names: Vec<&'static str> = crate::ranged::ExprAttribute::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprSubscript::py_type_cell() + .get_or_init(|| ast_module.getattr("Subscript").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Subscript")?; + m.setattr("Subscript", node)?; + let names: Vec<&'static str> = crate::ranged::ExprSubscript::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprStarred::py_type_cell().get_or_init(|| ast_module.getattr("Starred").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Starred")?; + m.setattr("Starred", node)?; + let names: Vec<&'static str> = crate::ranged::ExprStarred::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprName::py_type_cell().get_or_init(|| ast_module.getattr("Name").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Name")?; + m.setattr("Name", node)?; + let names: Vec<&'static str> = crate::ranged::ExprName::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprList::py_type_cell().get_or_init(|| ast_module.getattr("List").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_List")?; + m.setattr("List", node)?; + let names: Vec<&'static str> = crate::ranged::ExprList::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprTuple::py_type_cell().get_or_init(|| ast_module.getattr("Tuple").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Tuple")?; + m.setattr("Tuple", node)?; + let names: Vec<&'static str> = crate::ranged::ExprTuple::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprSlice::py_type_cell().get_or_init(|| ast_module.getattr("Slice").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_Slice")?; + m.setattr("Slice", node)?; + let names: Vec<&'static str> = crate::ranged::ExprSlice::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + ExprContext::py_type_cell().get_or_init(|| { + ast_module + .getattr("expr_context") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + ExprContextLoad::py_type_cell().get_or_init(|| { + ast_module + .getattr("Load") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + ExprContextStore::py_type_cell().get_or_init(|| { + ast_module + .getattr("Store") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + ExprContextDel::py_type_cell().get_or_init(|| { + ast_module + .getattr("Del") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + Boolop::py_type_cell().get_or_init(|| { + ast_module + .getattr("boolop") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + BoolopAnd::py_type_cell().get_or_init(|| { + ast_module + .getattr("And") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + BoolopOr::py_type_cell().get_or_init(|| { + ast_module + .getattr("Or") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + Operator::py_type_cell().get_or_init(|| { + ast_module + .getattr("operator") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + OperatorAdd::py_type_cell().get_or_init(|| { + ast_module + .getattr("Add") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + OperatorSub::py_type_cell().get_or_init(|| { + ast_module + .getattr("Sub") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + OperatorMult::py_type_cell().get_or_init(|| { + ast_module + .getattr("Mult") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + OperatorMatMult::py_type_cell().get_or_init(|| { + ast_module + .getattr("MatMult") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + OperatorDiv::py_type_cell().get_or_init(|| { + ast_module + .getattr("Div") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + OperatorMod::py_type_cell().get_or_init(|| { + ast_module + .getattr("Mod") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + OperatorPow::py_type_cell().get_or_init(|| { + ast_module + .getattr("Pow") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + OperatorLShift::py_type_cell().get_or_init(|| { + ast_module + .getattr("LShift") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + OperatorRShift::py_type_cell().get_or_init(|| { + ast_module + .getattr("RShift") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + OperatorBitOr::py_type_cell().get_or_init(|| { + ast_module + .getattr("BitOr") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + OperatorBitXor::py_type_cell().get_or_init(|| { + ast_module + .getattr("BitXor") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + OperatorBitAnd::py_type_cell().get_or_init(|| { + ast_module + .getattr("BitAnd") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + OperatorFloorDiv::py_type_cell().get_or_init(|| { + ast_module + .getattr("FloorDiv") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + Unaryop::py_type_cell().get_or_init(|| { + ast_module + .getattr("unaryop") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + UnaryopInvert::py_type_cell().get_or_init(|| { + ast_module + .getattr("Invert") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + UnaryopNot::py_type_cell().get_or_init(|| { + ast_module + .getattr("Not") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + UnaryopUAdd::py_type_cell().get_or_init(|| { + ast_module + .getattr("UAdd") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + UnaryopUSub::py_type_cell().get_or_init(|| { + ast_module + .getattr("USub") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + Cmpop::py_type_cell().get_or_init(|| { + ast_module + .getattr("cmpop") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + CmpopEq::py_type_cell().get_or_init(|| { + ast_module + .getattr("Eq") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + CmpopNotEq::py_type_cell().get_or_init(|| { + ast_module + .getattr("NotEq") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + CmpopLt::py_type_cell().get_or_init(|| { + ast_module + .getattr("Lt") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + CmpopLtE::py_type_cell().get_or_init(|| { + ast_module + .getattr("LtE") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + CmpopGt::py_type_cell().get_or_init(|| { + ast_module + .getattr("Gt") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + CmpopGtE::py_type_cell().get_or_init(|| { + ast_module + .getattr("GtE") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + CmpopIs::py_type_cell().get_or_init(|| { + ast_module + .getattr("Is") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + CmpopIsNot::py_type_cell().get_or_init(|| { + ast_module + .getattr("IsNot") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + CmpopIn::py_type_cell().get_or_init(|| { + ast_module + .getattr("In") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + CmpopNotIn::py_type_cell().get_or_init(|| { + ast_module + .getattr("NotIn") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + Comprehension::py_type_cell() + .get_or_init(|| ast_module.getattr("comprehension").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_comprehension")?; + m.setattr("comprehension", node)?; + let names: Vec<&'static str> = crate::ranged::Comprehension::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + Excepthandler::py_type_cell().get_or_init(|| { + ast_module + .getattr("excepthandler") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + ExcepthandlerExceptHandler::py_type_cell() + .get_or_init(|| ast_module.getattr("ExceptHandler").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_ExceptHandler")?; + m.setattr("ExceptHandler", node)?; + let names: Vec<&'static str> = + crate::ranged::ExcepthandlerExceptHandler::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + Arguments::py_type_cell().get_or_init(|| ast_module.getattr("arguments").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_arguments")?; + m.setattr("arguments", node)?; + let names: Vec<&'static str> = crate::ranged::Arguments::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + Arg::py_type_cell().get_or_init(|| ast_module.getattr("arg").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_arg")?; + m.setattr("arg", node)?; + let names: Vec<&'static str> = crate::ranged::Arg::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + Keyword::py_type_cell().get_or_init(|| ast_module.getattr("keyword").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_keyword")?; + m.setattr("keyword", node)?; + let names: Vec<&'static str> = crate::ranged::Keyword::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + Alias::py_type_cell().get_or_init(|| ast_module.getattr("alias").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_alias")?; + m.setattr("alias", node)?; + let names: Vec<&'static str> = crate::ranged::Alias::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + Withitem::py_type_cell().get_or_init(|| ast_module.getattr("withitem").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_withitem")?; + m.setattr("withitem", node)?; + let names: Vec<&'static str> = crate::ranged::Withitem::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + MatchCase::py_type_cell().get_or_init(|| ast_module.getattr("match_case").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_match_case")?; + m.setattr("match_case", node)?; + let names: Vec<&'static str> = crate::ranged::MatchCase::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + Pattern::py_type_cell().get_or_init(|| { + ast_module + .getattr("pattern") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + PatternMatchValue::py_type_cell() + .get_or_init(|| ast_module.getattr("MatchValue").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_MatchValue")?; + m.setattr("MatchValue", node)?; + let names: Vec<&'static str> = crate::ranged::PatternMatchValue::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + PatternMatchSingleton::py_type_cell() + .get_or_init(|| ast_module.getattr("MatchSingleton").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_MatchSingleton")?; + m.setattr("MatchSingleton", node)?; + let names: Vec<&'static str> = crate::ranged::PatternMatchSingleton::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + PatternMatchSequence::py_type_cell() + .get_or_init(|| ast_module.getattr("MatchSequence").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_MatchSequence")?; + m.setattr("MatchSequence", node)?; + let names: Vec<&'static str> = crate::ranged::PatternMatchSequence::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + PatternMatchMapping::py_type_cell() + .get_or_init(|| ast_module.getattr("MatchMapping").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_MatchMapping")?; + m.setattr("MatchMapping", node)?; + let names: Vec<&'static str> = crate::ranged::PatternMatchMapping::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + PatternMatchClass::py_type_cell() + .get_or_init(|| ast_module.getattr("MatchClass").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_MatchClass")?; + m.setattr("MatchClass", node)?; + let names: Vec<&'static str> = crate::ranged::PatternMatchClass::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + PatternMatchStar::py_type_cell() + .get_or_init(|| ast_module.getattr("MatchStar").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_MatchStar")?; + m.setattr("MatchStar", node)?; + let names: Vec<&'static str> = crate::ranged::PatternMatchStar::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + PatternMatchAs::py_type_cell() + .get_or_init(|| ast_module.getattr("MatchAs").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_MatchAs")?; + m.setattr("MatchAs", node)?; + let names: Vec<&'static str> = crate::ranged::PatternMatchAs::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + PatternMatchOr::py_type_cell() + .get_or_init(|| ast_module.getattr("MatchOr").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_MatchOr")?; + m.setattr("MatchOr", node)?; + let names: Vec<&'static str> = crate::ranged::PatternMatchOr::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + TypeIgnore::py_type_cell().get_or_init(|| { + ast_module + .getattr("type_ignore") + .unwrap() + .call0() + .unwrap() + .into_py(py) + }); + + TypeIgnoreTypeIgnore::py_type_cell() + .get_or_init(|| ast_module.getattr("TypeIgnore").unwrap().into_py(py)); + + { + m.add_class::()?; + let node = m.getattr("_TypeIgnore")?; + m.setattr("TypeIgnore", node)?; + let names: Vec<&'static str> = crate::ranged::TypeIgnoreTypeIgnore::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + } + + Ok(()) +} diff --git a/ast/src/gen/ranged.rs b/ast/src/gen/ranged.rs index f74f9aa..a28deff 100644 --- a/ast/src/gen/ranged.rs +++ b/ast/src/gen/ranged.rs @@ -1,23 +1,33 @@ // File automatically generated by ast/asdl_rs.py. +pub type Mod = crate::generic::Mod; + +pub type ModModule = crate::generic::ModModule; + #[cfg(feature = "all-nodes-with-ranges")] impl Ranged for crate::generic::ModModule { fn range(&self) -> TextRange { self.range } } +pub type ModInteractive = crate::generic::ModInteractive; + #[cfg(feature = "all-nodes-with-ranges")] impl Ranged for crate::generic::ModInteractive { fn range(&self) -> TextRange { self.range } } +pub type ModExpression = crate::generic::ModExpression; + #[cfg(feature = "all-nodes-with-ranges")] impl Ranged for crate::generic::ModExpression { fn range(&self) -> TextRange { self.range } } +pub type ModFunctionType = crate::generic::ModFunctionType; + #[cfg(feature = "all-nodes-with-ranges")] impl Ranged for crate::generic::ModFunctionType { fn range(&self) -> TextRange { @@ -36,136 +46,192 @@ impl Ranged for crate::Mod { } } +pub type Stmt = crate::generic::Stmt; + +pub type StmtFunctionDef = crate::generic::StmtFunctionDef; + impl Ranged for crate::generic::StmtFunctionDef { fn range(&self) -> TextRange { self.range } } +pub type StmtAsyncFunctionDef = crate::generic::StmtAsyncFunctionDef; + impl Ranged for crate::generic::StmtAsyncFunctionDef { fn range(&self) -> TextRange { self.range } } +pub type StmtClassDef = crate::generic::StmtClassDef; + impl Ranged for crate::generic::StmtClassDef { fn range(&self) -> TextRange { self.range } } +pub type StmtReturn = crate::generic::StmtReturn; + impl Ranged for crate::generic::StmtReturn { fn range(&self) -> TextRange { self.range } } +pub type StmtDelete = crate::generic::StmtDelete; + impl Ranged for crate::generic::StmtDelete { fn range(&self) -> TextRange { self.range } } +pub type StmtAssign = crate::generic::StmtAssign; + impl Ranged for crate::generic::StmtAssign { fn range(&self) -> TextRange { self.range } } +pub type StmtAugAssign = crate::generic::StmtAugAssign; + impl Ranged for crate::generic::StmtAugAssign { fn range(&self) -> TextRange { self.range } } +pub type StmtAnnAssign = crate::generic::StmtAnnAssign; + impl Ranged for crate::generic::StmtAnnAssign { fn range(&self) -> TextRange { self.range } } +pub type StmtFor = crate::generic::StmtFor; + impl Ranged for crate::generic::StmtFor { fn range(&self) -> TextRange { self.range } } +pub type StmtAsyncFor = crate::generic::StmtAsyncFor; + impl Ranged for crate::generic::StmtAsyncFor { fn range(&self) -> TextRange { self.range } } +pub type StmtWhile = crate::generic::StmtWhile; + impl Ranged for crate::generic::StmtWhile { fn range(&self) -> TextRange { self.range } } +pub type StmtIf = crate::generic::StmtIf; + impl Ranged for crate::generic::StmtIf { fn range(&self) -> TextRange { self.range } } +pub type StmtWith = crate::generic::StmtWith; + impl Ranged for crate::generic::StmtWith { fn range(&self) -> TextRange { self.range } } +pub type StmtAsyncWith = crate::generic::StmtAsyncWith; + impl Ranged for crate::generic::StmtAsyncWith { fn range(&self) -> TextRange { self.range } } +pub type StmtMatch = crate::generic::StmtMatch; + impl Ranged for crate::generic::StmtMatch { fn range(&self) -> TextRange { self.range } } +pub type StmtRaise = crate::generic::StmtRaise; + impl Ranged for crate::generic::StmtRaise { fn range(&self) -> TextRange { self.range } } +pub type StmtTry = crate::generic::StmtTry; + impl Ranged for crate::generic::StmtTry { fn range(&self) -> TextRange { self.range } } +pub type StmtTryStar = crate::generic::StmtTryStar; + impl Ranged for crate::generic::StmtTryStar { fn range(&self) -> TextRange { self.range } } +pub type StmtAssert = crate::generic::StmtAssert; + impl Ranged for crate::generic::StmtAssert { fn range(&self) -> TextRange { self.range } } +pub type StmtImport = crate::generic::StmtImport; + impl Ranged for crate::generic::StmtImport { fn range(&self) -> TextRange { self.range } } +pub type StmtImportFrom = crate::generic::StmtImportFrom; + impl Ranged for crate::generic::StmtImportFrom { fn range(&self) -> TextRange { self.range } } +pub type StmtGlobal = crate::generic::StmtGlobal; + impl Ranged for crate::generic::StmtGlobal { fn range(&self) -> TextRange { self.range } } +pub type StmtNonlocal = crate::generic::StmtNonlocal; + impl Ranged for crate::generic::StmtNonlocal { fn range(&self) -> TextRange { self.range } } +pub type StmtExpr = crate::generic::StmtExpr; + impl Ranged for crate::generic::StmtExpr { fn range(&self) -> TextRange { self.range } } +pub type StmtPass = crate::generic::StmtPass; + impl Ranged for crate::generic::StmtPass { fn range(&self) -> TextRange { self.range } } +pub type StmtBreak = crate::generic::StmtBreak; + impl Ranged for crate::generic::StmtBreak { fn range(&self) -> TextRange { self.range } } +pub type StmtContinue = crate::generic::StmtContinue; + impl Ranged for crate::generic::StmtContinue { fn range(&self) -> TextRange { self.range @@ -205,136 +271,192 @@ impl Ranged for crate::Stmt { } } +pub type Expr = crate::generic::Expr; + +pub type ExprBoolOp = crate::generic::ExprBoolOp; + impl Ranged for crate::generic::ExprBoolOp { fn range(&self) -> TextRange { self.range } } +pub type ExprNamedExpr = crate::generic::ExprNamedExpr; + impl Ranged for crate::generic::ExprNamedExpr { fn range(&self) -> TextRange { self.range } } +pub type ExprBinOp = crate::generic::ExprBinOp; + impl Ranged for crate::generic::ExprBinOp { fn range(&self) -> TextRange { self.range } } +pub type ExprUnaryOp = crate::generic::ExprUnaryOp; + impl Ranged for crate::generic::ExprUnaryOp { fn range(&self) -> TextRange { self.range } } +pub type ExprLambda = crate::generic::ExprLambda; + impl Ranged for crate::generic::ExprLambda { fn range(&self) -> TextRange { self.range } } +pub type ExprIfExp = crate::generic::ExprIfExp; + impl Ranged for crate::generic::ExprIfExp { fn range(&self) -> TextRange { self.range } } +pub type ExprDict = crate::generic::ExprDict; + impl Ranged for crate::generic::ExprDict { fn range(&self) -> TextRange { self.range } } +pub type ExprSet = crate::generic::ExprSet; + impl Ranged for crate::generic::ExprSet { fn range(&self) -> TextRange { self.range } } +pub type ExprListComp = crate::generic::ExprListComp; + impl Ranged for crate::generic::ExprListComp { fn range(&self) -> TextRange { self.range } } +pub type ExprSetComp = crate::generic::ExprSetComp; + impl Ranged for crate::generic::ExprSetComp { fn range(&self) -> TextRange { self.range } } +pub type ExprDictComp = crate::generic::ExprDictComp; + impl Ranged for crate::generic::ExprDictComp { fn range(&self) -> TextRange { self.range } } +pub type ExprGeneratorExp = crate::generic::ExprGeneratorExp; + impl Ranged for crate::generic::ExprGeneratorExp { fn range(&self) -> TextRange { self.range } } +pub type ExprAwait = crate::generic::ExprAwait; + impl Ranged for crate::generic::ExprAwait { fn range(&self) -> TextRange { self.range } } +pub type ExprYield = crate::generic::ExprYield; + impl Ranged for crate::generic::ExprYield { fn range(&self) -> TextRange { self.range } } +pub type ExprYieldFrom = crate::generic::ExprYieldFrom; + impl Ranged for crate::generic::ExprYieldFrom { fn range(&self) -> TextRange { self.range } } +pub type ExprCompare = crate::generic::ExprCompare; + impl Ranged for crate::generic::ExprCompare { fn range(&self) -> TextRange { self.range } } +pub type ExprCall = crate::generic::ExprCall; + impl Ranged for crate::generic::ExprCall { fn range(&self) -> TextRange { self.range } } +pub type ExprFormattedValue = crate::generic::ExprFormattedValue; + impl Ranged for crate::generic::ExprFormattedValue { fn range(&self) -> TextRange { self.range } } +pub type ExprJoinedStr = crate::generic::ExprJoinedStr; + impl Ranged for crate::generic::ExprJoinedStr { fn range(&self) -> TextRange { self.range } } +pub type ExprConstant = crate::generic::ExprConstant; + impl Ranged for crate::generic::ExprConstant { fn range(&self) -> TextRange { self.range } } +pub type ExprAttribute = crate::generic::ExprAttribute; + impl Ranged for crate::generic::ExprAttribute { fn range(&self) -> TextRange { self.range } } +pub type ExprSubscript = crate::generic::ExprSubscript; + impl Ranged for crate::generic::ExprSubscript { fn range(&self) -> TextRange { self.range } } +pub type ExprStarred = crate::generic::ExprStarred; + impl Ranged for crate::generic::ExprStarred { fn range(&self) -> TextRange { self.range } } +pub type ExprName = crate::generic::ExprName; + impl Ranged for crate::generic::ExprName { fn range(&self) -> TextRange { self.range } } +pub type ExprList = crate::generic::ExprList; + impl Ranged for crate::generic::ExprList { fn range(&self) -> TextRange { self.range } } +pub type ExprTuple = crate::generic::ExprTuple; + impl Ranged for crate::generic::ExprTuple { fn range(&self) -> TextRange { self.range } } +pub type ExprSlice = crate::generic::ExprSlice; + impl Ranged for crate::generic::ExprSlice { fn range(&self) -> TextRange { self.range @@ -374,12 +496,28 @@ impl Ranged for crate::Expr { } } +pub type ExprContext = crate::generic::ExprContext; + +pub type Boolop = crate::generic::Boolop; + +pub type Operator = crate::generic::Operator; + +pub type Unaryop = crate::generic::Unaryop; + +pub type Cmpop = crate::generic::Cmpop; + +pub type Comprehension = crate::generic::Comprehension; + #[cfg(feature = "all-nodes-with-ranges")] impl Ranged for crate::generic::Comprehension { fn range(&self) -> TextRange { self.range } } +pub type Excepthandler = crate::generic::Excepthandler; + +pub type ExcepthandlerExceptHandler = crate::generic::ExcepthandlerExceptHandler; + impl Ranged for crate::generic::ExcepthandlerExceptHandler { fn range(&self) -> TextRange { self.range @@ -393,74 +531,104 @@ impl Ranged for crate::Excepthandler { } } +pub type Arguments = crate::generic::Arguments; + #[cfg(feature = "all-nodes-with-ranges")] impl Ranged for crate::generic::Arguments { fn range(&self) -> TextRange { self.range } } +pub type Arg = crate::generic::Arg; + impl Ranged for crate::generic::Arg { fn range(&self) -> TextRange { self.range } } +pub type Keyword = crate::generic::Keyword; + impl Ranged for crate::generic::Keyword { fn range(&self) -> TextRange { self.range } } +pub type Alias = crate::generic::Alias; + impl Ranged for crate::generic::Alias { fn range(&self) -> TextRange { self.range } } +pub type Withitem = crate::generic::Withitem; + #[cfg(feature = "all-nodes-with-ranges")] impl Ranged for crate::generic::Withitem { fn range(&self) -> TextRange { self.range } } +pub type MatchCase = crate::generic::MatchCase; + #[cfg(feature = "all-nodes-with-ranges")] impl Ranged for crate::generic::MatchCase { fn range(&self) -> TextRange { self.range } } +pub type Pattern = crate::generic::Pattern; + +pub type PatternMatchValue = crate::generic::PatternMatchValue; + impl Ranged for crate::generic::PatternMatchValue { fn range(&self) -> TextRange { self.range } } +pub type PatternMatchSingleton = crate::generic::PatternMatchSingleton; + impl Ranged for crate::generic::PatternMatchSingleton { fn range(&self) -> TextRange { self.range } } +pub type PatternMatchSequence = crate::generic::PatternMatchSequence; + impl Ranged for crate::generic::PatternMatchSequence { fn range(&self) -> TextRange { self.range } } +pub type PatternMatchMapping = crate::generic::PatternMatchMapping; + impl Ranged for crate::generic::PatternMatchMapping { fn range(&self) -> TextRange { self.range } } +pub type PatternMatchClass = crate::generic::PatternMatchClass; + impl Ranged for crate::generic::PatternMatchClass { fn range(&self) -> TextRange { self.range } } +pub type PatternMatchStar = crate::generic::PatternMatchStar; + impl Ranged for crate::generic::PatternMatchStar { fn range(&self) -> TextRange { self.range } } +pub type PatternMatchAs = crate::generic::PatternMatchAs; + impl Ranged for crate::generic::PatternMatchAs { fn range(&self) -> TextRange { self.range } } +pub type PatternMatchOr = crate::generic::PatternMatchOr; + impl Ranged for crate::generic::PatternMatchOr { fn range(&self) -> TextRange { self.range @@ -481,6 +649,10 @@ impl Ranged for crate::Pattern { } } +pub type TypeIgnore = crate::generic::TypeIgnore; + +pub type TypeIgnoreTypeIgnore = crate::generic::TypeIgnoreTypeIgnore; + #[cfg(feature = "all-nodes-with-ranges")] impl Ranged for crate::generic::TypeIgnoreTypeIgnore { fn range(&self) -> TextRange { diff --git a/ast/src/gen/to_pyo3_located.rs b/ast/src/gen/to_pyo3_located.rs new file mode 100644 index 0000000..ed60dec --- /dev/null +++ b/ast/src/gen/to_pyo3_located.rs @@ -0,0 +1,1215 @@ +// File automatically generated by ast/asdl_rs.py. + +impl ToPyo3Ast for crate::located::Mod { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Mod::Module(cons) => cons.to_pyo3_ast(_py)?, + crate::Mod::Interactive(cons) => cons.to_pyo3_ast(_py)?, + crate::Mod::Expression(cons) => cons.to_pyo3_ast(_py)?, + crate::Mod::FunctionType(cons) => cons.to_pyo3_ast(_py)?, + }; + Ok(instance) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ModModule { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ModModule::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.body.to_pyo3_ast(_py)?, + self.type_ignores.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ModInteractive { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ModInteractive::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.body.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ModExpression { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ModExpression::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.body.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ModFunctionType { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ModFunctionType::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.argtypes.to_pyo3_ast(_py)?, + self.returns.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +impl ToPyo3Ast for crate::located::Stmt { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Stmt::FunctionDef(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::AsyncFunctionDef(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::ClassDef(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Return(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Delete(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Assign(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::AugAssign(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::AnnAssign(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::For(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::AsyncFor(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::While(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::If(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::With(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::AsyncWith(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Match(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Raise(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Try(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::TryStar(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Assert(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Import(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::ImportFrom(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Global(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Nonlocal(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Expr(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Pass(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Break(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Continue(cons) => cons.to_pyo3_ast(_py)?, + }; + Ok(instance) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtFunctionDef { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtFunctionDef::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtAsyncFunctionDef { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAsyncFunctionDef::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtClassDef { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtClassDef::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtReturn { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtReturn::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtDelete { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtDelete::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.targets.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtAssign { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAssign::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.targets.to_pyo3_ast(_py)?, + self.value.to_pyo3_ast(_py)?, + self.type_comment.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtAugAssign { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAugAssign::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.target.to_pyo3_ast(_py)?, + self.op.to_pyo3_ast(_py)?, + self.value.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtAnnAssign { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAnnAssign::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtFor { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtFor::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtAsyncFor { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAsyncFor::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtWhile { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtWhile::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.test.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + self.orelse.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtIf { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtIf::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.test.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + self.orelse.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtWith { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtWith::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.items.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + self.type_comment.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtAsyncWith { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAsyncWith::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.items.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + self.type_comment.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtMatch { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtMatch::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.subject.to_pyo3_ast(_py)?, self.cases.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtRaise { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtRaise::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.exc.to_pyo3_ast(_py)?, self.cause.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtTry { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtTry::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtTryStar { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtTryStar::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtAssert { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAssert::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.test.to_pyo3_ast(_py)?, self.msg.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtImport { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtImport::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.names.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtImportFrom { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtImportFrom::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.module.to_pyo3_ast(_py)?, + self.names.to_pyo3_ast(_py)?, + self.level.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtGlobal { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtGlobal::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.names.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtNonlocal { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtNonlocal::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.names.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtExpr { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtExpr::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtPass { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtPass::py_type_cell().get().unwrap(); + let instance = class.call1(_py, ())?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtBreak { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtBreak::py_type_cell().get().unwrap(); + let instance = class.call1(_py, ())?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::StmtContinue { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtContinue::py_type_cell().get().unwrap(); + let instance = class.call1(_py, ())?; + Ok(instance.into()) + } +} + +impl ToPyo3Ast for crate::located::Expr { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Expr::BoolOp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::NamedExpr(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::BinOp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::UnaryOp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Lambda(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::IfExp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Dict(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Set(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::ListComp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::SetComp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::DictComp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::GeneratorExp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Await(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Yield(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::YieldFrom(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Compare(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Call(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::FormattedValue(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::JoinedStr(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Constant(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Attribute(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Subscript(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Starred(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Name(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::List(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Tuple(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Slice(cons) => cons.to_pyo3_ast(_py)?, + }; + Ok(instance) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprBoolOp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprBoolOp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.op.to_pyo3_ast(_py)?, self.values.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprNamedExpr { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprNamedExpr::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.target.to_pyo3_ast(_py)?, self.value.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprBinOp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprBinOp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.left.to_pyo3_ast(_py)?, + self.op.to_pyo3_ast(_py)?, + self.right.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprUnaryOp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprUnaryOp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.op.to_pyo3_ast(_py)?, self.operand.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprLambda { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprLambda::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.args.to_pyo3_ast(_py)?, self.body.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprIfExp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprIfExp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.test.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + self.orelse.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprDict { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprDict::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.keys.to_pyo3_ast(_py)?, self.values.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprSet { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprSet::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.elts.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprListComp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprListComp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.elt.to_pyo3_ast(_py)?, + self.generators.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprSetComp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprSetComp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.elt.to_pyo3_ast(_py)?, + self.generators.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprDictComp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprDictComp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.key.to_pyo3_ast(_py)?, + self.value.to_pyo3_ast(_py)?, + self.generators.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprGeneratorExp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprGeneratorExp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.elt.to_pyo3_ast(_py)?, + self.generators.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprAwait { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprAwait::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprYield { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprYield::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprYieldFrom { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprYieldFrom::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprCompare { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprCompare::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.left.to_pyo3_ast(_py)?, + self.ops.to_pyo3_ast(_py)?, + self.comparators.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprCall { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprCall::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.func.to_pyo3_ast(_py)?, + self.args.to_pyo3_ast(_py)?, + self.keywords.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprFormattedValue { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprFormattedValue::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.value.to_pyo3_ast(_py)?, + self.conversion.to_pyo3_ast(_py)?, + self.format_spec.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprJoinedStr { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprJoinedStr::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.values.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprConstant { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprConstant::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.value.to_pyo3_ast(_py)?, self.kind.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprAttribute { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprAttribute::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.value.to_pyo3_ast(_py)?, + self.attr.to_pyo3_ast(_py)?, + self.ctx.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprSubscript { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprSubscript::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.value.to_pyo3_ast(_py)?, + self.slice.to_pyo3_ast(_py)?, + self.ctx.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprStarred { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprStarred::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.value.to_pyo3_ast(_py)?, self.ctx.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprName { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprName::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.id.to_pyo3_ast(_py)?, self.ctx.to_pyo3_ast(_py)?))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprList { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprList::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.elts.to_pyo3_ast(_py)?, self.ctx.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprTuple { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprTuple::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.elts.to_pyo3_ast(_py)?, self.ctx.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExprSlice { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprSlice::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.lower.to_pyo3_ast(_py)?, + self.upper.to_pyo3_ast(_py)?, + self.step.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +impl ToPyo3Ast for crate::located::ExprContext { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::ExprContext::Load => ranged::ExprContextLoad::py_type_cell() + .get() + .unwrap() + .clone(), + crate::ExprContext::Store => ranged::ExprContextStore::py_type_cell() + .get() + .unwrap() + .clone(), + crate::ExprContext::Del => ranged::ExprContextDel::py_type_cell() + .get() + .unwrap() + .clone(), + }; + Ok(instance) + } +} + +impl ToPyo3Ast for crate::located::Boolop { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Boolop::And => ranged::BoolopAnd::py_type_cell().get().unwrap().clone(), + crate::Boolop::Or => ranged::BoolopOr::py_type_cell().get().unwrap().clone(), + }; + Ok(instance) + } +} + +impl ToPyo3Ast for crate::located::Operator { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Operator::Add => ranged::OperatorAdd::py_type_cell().get().unwrap().clone(), + crate::Operator::Sub => ranged::OperatorSub::py_type_cell().get().unwrap().clone(), + crate::Operator::Mult => ranged::OperatorMult::py_type_cell().get().unwrap().clone(), + crate::Operator::MatMult => ranged::OperatorMatMult::py_type_cell() + .get() + .unwrap() + .clone(), + crate::Operator::Div => ranged::OperatorDiv::py_type_cell().get().unwrap().clone(), + crate::Operator::Mod => ranged::OperatorMod::py_type_cell().get().unwrap().clone(), + crate::Operator::Pow => ranged::OperatorPow::py_type_cell().get().unwrap().clone(), + crate::Operator::LShift => ranged::OperatorLShift::py_type_cell() + .get() + .unwrap() + .clone(), + crate::Operator::RShift => ranged::OperatorRShift::py_type_cell() + .get() + .unwrap() + .clone(), + crate::Operator::BitOr => ranged::OperatorBitOr::py_type_cell().get().unwrap().clone(), + crate::Operator::BitXor => ranged::OperatorBitXor::py_type_cell() + .get() + .unwrap() + .clone(), + crate::Operator::BitAnd => ranged::OperatorBitAnd::py_type_cell() + .get() + .unwrap() + .clone(), + crate::Operator::FloorDiv => ranged::OperatorFloorDiv::py_type_cell() + .get() + .unwrap() + .clone(), + }; + Ok(instance) + } +} + +impl ToPyo3Ast for crate::located::Unaryop { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Unaryop::Invert => ranged::UnaryopInvert::py_type_cell().get().unwrap().clone(), + crate::Unaryop::Not => ranged::UnaryopNot::py_type_cell().get().unwrap().clone(), + crate::Unaryop::UAdd => ranged::UnaryopUAdd::py_type_cell().get().unwrap().clone(), + crate::Unaryop::USub => ranged::UnaryopUSub::py_type_cell().get().unwrap().clone(), + }; + Ok(instance) + } +} + +impl ToPyo3Ast for crate::located::Cmpop { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Cmpop::Eq => ranged::CmpopEq::py_type_cell().get().unwrap().clone(), + crate::Cmpop::NotEq => ranged::CmpopNotEq::py_type_cell().get().unwrap().clone(), + crate::Cmpop::Lt => ranged::CmpopLt::py_type_cell().get().unwrap().clone(), + crate::Cmpop::LtE => ranged::CmpopLtE::py_type_cell().get().unwrap().clone(), + crate::Cmpop::Gt => ranged::CmpopGt::py_type_cell().get().unwrap().clone(), + crate::Cmpop::GtE => ranged::CmpopGtE::py_type_cell().get().unwrap().clone(), + crate::Cmpop::Is => ranged::CmpopIs::py_type_cell().get().unwrap().clone(), + crate::Cmpop::IsNot => ranged::CmpopIsNot::py_type_cell().get().unwrap().clone(), + crate::Cmpop::In => ranged::CmpopIn::py_type_cell().get().unwrap().clone(), + crate::Cmpop::NotIn => ranged::CmpopNotIn::py_type_cell().get().unwrap().clone(), + }; + Ok(instance) + } +} + +// product +impl ToPyo3Ast for crate::located::Comprehension { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::Comprehension::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +impl ToPyo3Ast for crate::located::Excepthandler { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Excepthandler::ExceptHandler(cons) => cons.to_pyo3_ast(_py)?, + }; + Ok(instance) + } +} + +// constructor +impl ToPyo3Ast for crate::located::ExcepthandlerExceptHandler { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExcepthandlerExceptHandler::py_type_cell() + .get() + .unwrap(); + let instance = class.call1( + _py, + ( + self.type_.to_pyo3_ast(_py)?, + self.name.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// product +impl ToPyo3Ast for crate::located::Arguments { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::Arguments::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// product +impl ToPyo3Ast for crate::located::Arg { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::Arg::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.arg.to_pyo3_ast(_py)?, + self.annotation.to_pyo3_ast(_py)?, + self.type_comment.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// product +impl ToPyo3Ast for crate::located::Keyword { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::Keyword::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.arg.to_pyo3_ast(_py)?, self.value.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// product +impl ToPyo3Ast for crate::located::Alias { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::Alias::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.name.to_pyo3_ast(_py)?, self.asname.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// product +impl ToPyo3Ast for crate::located::Withitem { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::Withitem::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.context_expr.to_pyo3_ast(_py)?, + self.optional_vars.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// product +impl ToPyo3Ast for crate::located::MatchCase { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::MatchCase::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.pattern.to_pyo3_ast(_py)?, + self.guard.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +impl ToPyo3Ast for crate::located::Pattern { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Pattern::MatchValue(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchSingleton(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchSequence(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchMapping(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchClass(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchStar(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchAs(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchOr(cons) => cons.to_pyo3_ast(_py)?, + }; + Ok(instance) + } +} + +// constructor +impl ToPyo3Ast for crate::located::PatternMatchValue { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchValue::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::PatternMatchSingleton { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchSingleton::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::PatternMatchSequence { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchSequence::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.patterns.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::PatternMatchMapping { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchMapping::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.keys.to_pyo3_ast(_py)?, + self.patterns.to_pyo3_ast(_py)?, + self.rest.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::PatternMatchClass { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchClass::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::PatternMatchStar { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchStar::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.name.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::PatternMatchAs { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchAs::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.pattern.to_pyo3_ast(_py)?, self.name.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::located::PatternMatchOr { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchOr::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.patterns.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +impl ToPyo3Ast for crate::located::TypeIgnore { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::TypeIgnore::TypeIgnore(cons) => cons.to_pyo3_ast(_py)?, + }; + Ok(instance) + } +} + +// constructor +impl ToPyo3Ast for crate::located::TypeIgnoreTypeIgnore { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::TypeIgnoreTypeIgnore::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.lineno.to_pyo3_ast(_py)?, self.tag.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} diff --git a/ast/src/gen/to_pyo3_ranged.rs b/ast/src/gen/to_pyo3_ranged.rs new file mode 100644 index 0000000..32c009f --- /dev/null +++ b/ast/src/gen/to_pyo3_ranged.rs @@ -0,0 +1,1215 @@ +// File automatically generated by ast/asdl_rs.py. + +impl ToPyo3Ast for crate::ranged::Mod { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Mod::Module(cons) => cons.to_pyo3_ast(_py)?, + crate::Mod::Interactive(cons) => cons.to_pyo3_ast(_py)?, + crate::Mod::Expression(cons) => cons.to_pyo3_ast(_py)?, + crate::Mod::FunctionType(cons) => cons.to_pyo3_ast(_py)?, + }; + Ok(instance) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ModModule { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ModModule::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.body.to_pyo3_ast(_py)?, + self.type_ignores.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ModInteractive { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ModInteractive::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.body.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ModExpression { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ModExpression::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.body.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ModFunctionType { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ModFunctionType::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.argtypes.to_pyo3_ast(_py)?, + self.returns.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +impl ToPyo3Ast for crate::ranged::Stmt { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Stmt::FunctionDef(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::AsyncFunctionDef(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::ClassDef(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Return(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Delete(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Assign(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::AugAssign(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::AnnAssign(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::For(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::AsyncFor(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::While(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::If(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::With(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::AsyncWith(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Match(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Raise(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Try(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::TryStar(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Assert(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Import(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::ImportFrom(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Global(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Nonlocal(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Expr(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Pass(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Break(cons) => cons.to_pyo3_ast(_py)?, + crate::Stmt::Continue(cons) => cons.to_pyo3_ast(_py)?, + }; + Ok(instance) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtFunctionDef { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtFunctionDef::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtAsyncFunctionDef { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAsyncFunctionDef::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtClassDef { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtClassDef::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtReturn { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtReturn::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtDelete { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtDelete::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.targets.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtAssign { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAssign::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.targets.to_pyo3_ast(_py)?, + self.value.to_pyo3_ast(_py)?, + self.type_comment.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtAugAssign { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAugAssign::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.target.to_pyo3_ast(_py)?, + self.op.to_pyo3_ast(_py)?, + self.value.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtAnnAssign { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAnnAssign::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtFor { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtFor::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtAsyncFor { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAsyncFor::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtWhile { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtWhile::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.test.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + self.orelse.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtIf { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtIf::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.test.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + self.orelse.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtWith { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtWith::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.items.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + self.type_comment.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtAsyncWith { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAsyncWith::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.items.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + self.type_comment.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtMatch { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtMatch::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.subject.to_pyo3_ast(_py)?, self.cases.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtRaise { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtRaise::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.exc.to_pyo3_ast(_py)?, self.cause.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtTry { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtTry::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtTryStar { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtTryStar::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtAssert { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtAssert::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.test.to_pyo3_ast(_py)?, self.msg.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtImport { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtImport::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.names.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtImportFrom { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtImportFrom::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.module.to_pyo3_ast(_py)?, + self.names.to_pyo3_ast(_py)?, + self.level.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtGlobal { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtGlobal::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.names.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtNonlocal { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtNonlocal::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.names.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtExpr { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtExpr::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtPass { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtPass::py_type_cell().get().unwrap(); + let instance = class.call1(_py, ())?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtBreak { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtBreak::py_type_cell().get().unwrap(); + let instance = class.call1(_py, ())?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::StmtContinue { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::StmtContinue::py_type_cell().get().unwrap(); + let instance = class.call1(_py, ())?; + Ok(instance.into()) + } +} + +impl ToPyo3Ast for crate::ranged::Expr { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Expr::BoolOp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::NamedExpr(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::BinOp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::UnaryOp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Lambda(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::IfExp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Dict(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Set(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::ListComp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::SetComp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::DictComp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::GeneratorExp(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Await(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Yield(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::YieldFrom(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Compare(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Call(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::FormattedValue(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::JoinedStr(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Constant(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Attribute(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Subscript(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Starred(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Name(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::List(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Tuple(cons) => cons.to_pyo3_ast(_py)?, + crate::Expr::Slice(cons) => cons.to_pyo3_ast(_py)?, + }; + Ok(instance) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprBoolOp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprBoolOp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.op.to_pyo3_ast(_py)?, self.values.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprNamedExpr { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprNamedExpr::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.target.to_pyo3_ast(_py)?, self.value.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprBinOp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprBinOp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.left.to_pyo3_ast(_py)?, + self.op.to_pyo3_ast(_py)?, + self.right.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprUnaryOp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprUnaryOp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.op.to_pyo3_ast(_py)?, self.operand.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprLambda { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprLambda::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.args.to_pyo3_ast(_py)?, self.body.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprIfExp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprIfExp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.test.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + self.orelse.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprDict { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprDict::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.keys.to_pyo3_ast(_py)?, self.values.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprSet { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprSet::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.elts.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprListComp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprListComp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.elt.to_pyo3_ast(_py)?, + self.generators.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprSetComp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprSetComp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.elt.to_pyo3_ast(_py)?, + self.generators.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprDictComp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprDictComp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.key.to_pyo3_ast(_py)?, + self.value.to_pyo3_ast(_py)?, + self.generators.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprGeneratorExp { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprGeneratorExp::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.elt.to_pyo3_ast(_py)?, + self.generators.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprAwait { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprAwait::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprYield { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprYield::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprYieldFrom { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprYieldFrom::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprCompare { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprCompare::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.left.to_pyo3_ast(_py)?, + self.ops.to_pyo3_ast(_py)?, + self.comparators.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprCall { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprCall::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.func.to_pyo3_ast(_py)?, + self.args.to_pyo3_ast(_py)?, + self.keywords.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprFormattedValue { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprFormattedValue::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.value.to_pyo3_ast(_py)?, + self.conversion.to_pyo3_ast(_py)?, + self.format_spec.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprJoinedStr { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprJoinedStr::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.values.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprConstant { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprConstant::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.value.to_pyo3_ast(_py)?, self.kind.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprAttribute { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprAttribute::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.value.to_pyo3_ast(_py)?, + self.attr.to_pyo3_ast(_py)?, + self.ctx.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprSubscript { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprSubscript::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.value.to_pyo3_ast(_py)?, + self.slice.to_pyo3_ast(_py)?, + self.ctx.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprStarred { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprStarred::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.value.to_pyo3_ast(_py)?, self.ctx.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprName { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprName::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.id.to_pyo3_ast(_py)?, self.ctx.to_pyo3_ast(_py)?))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprList { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprList::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.elts.to_pyo3_ast(_py)?, self.ctx.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprTuple { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprTuple::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.elts.to_pyo3_ast(_py)?, self.ctx.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExprSlice { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExprSlice::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.lower.to_pyo3_ast(_py)?, + self.upper.to_pyo3_ast(_py)?, + self.step.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +impl ToPyo3Ast for crate::ranged::ExprContext { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::ExprContext::Load => ranged::ExprContextLoad::py_type_cell() + .get() + .unwrap() + .clone(), + crate::ExprContext::Store => ranged::ExprContextStore::py_type_cell() + .get() + .unwrap() + .clone(), + crate::ExprContext::Del => ranged::ExprContextDel::py_type_cell() + .get() + .unwrap() + .clone(), + }; + Ok(instance) + } +} + +impl ToPyo3Ast for crate::ranged::Boolop { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Boolop::And => ranged::BoolopAnd::py_type_cell().get().unwrap().clone(), + crate::Boolop::Or => ranged::BoolopOr::py_type_cell().get().unwrap().clone(), + }; + Ok(instance) + } +} + +impl ToPyo3Ast for crate::ranged::Operator { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Operator::Add => ranged::OperatorAdd::py_type_cell().get().unwrap().clone(), + crate::Operator::Sub => ranged::OperatorSub::py_type_cell().get().unwrap().clone(), + crate::Operator::Mult => ranged::OperatorMult::py_type_cell().get().unwrap().clone(), + crate::Operator::MatMult => ranged::OperatorMatMult::py_type_cell() + .get() + .unwrap() + .clone(), + crate::Operator::Div => ranged::OperatorDiv::py_type_cell().get().unwrap().clone(), + crate::Operator::Mod => ranged::OperatorMod::py_type_cell().get().unwrap().clone(), + crate::Operator::Pow => ranged::OperatorPow::py_type_cell().get().unwrap().clone(), + crate::Operator::LShift => ranged::OperatorLShift::py_type_cell() + .get() + .unwrap() + .clone(), + crate::Operator::RShift => ranged::OperatorRShift::py_type_cell() + .get() + .unwrap() + .clone(), + crate::Operator::BitOr => ranged::OperatorBitOr::py_type_cell().get().unwrap().clone(), + crate::Operator::BitXor => ranged::OperatorBitXor::py_type_cell() + .get() + .unwrap() + .clone(), + crate::Operator::BitAnd => ranged::OperatorBitAnd::py_type_cell() + .get() + .unwrap() + .clone(), + crate::Operator::FloorDiv => ranged::OperatorFloorDiv::py_type_cell() + .get() + .unwrap() + .clone(), + }; + Ok(instance) + } +} + +impl ToPyo3Ast for crate::ranged::Unaryop { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Unaryop::Invert => ranged::UnaryopInvert::py_type_cell().get().unwrap().clone(), + crate::Unaryop::Not => ranged::UnaryopNot::py_type_cell().get().unwrap().clone(), + crate::Unaryop::UAdd => ranged::UnaryopUAdd::py_type_cell().get().unwrap().clone(), + crate::Unaryop::USub => ranged::UnaryopUSub::py_type_cell().get().unwrap().clone(), + }; + Ok(instance) + } +} + +impl ToPyo3Ast for crate::ranged::Cmpop { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Cmpop::Eq => ranged::CmpopEq::py_type_cell().get().unwrap().clone(), + crate::Cmpop::NotEq => ranged::CmpopNotEq::py_type_cell().get().unwrap().clone(), + crate::Cmpop::Lt => ranged::CmpopLt::py_type_cell().get().unwrap().clone(), + crate::Cmpop::LtE => ranged::CmpopLtE::py_type_cell().get().unwrap().clone(), + crate::Cmpop::Gt => ranged::CmpopGt::py_type_cell().get().unwrap().clone(), + crate::Cmpop::GtE => ranged::CmpopGtE::py_type_cell().get().unwrap().clone(), + crate::Cmpop::Is => ranged::CmpopIs::py_type_cell().get().unwrap().clone(), + crate::Cmpop::IsNot => ranged::CmpopIsNot::py_type_cell().get().unwrap().clone(), + crate::Cmpop::In => ranged::CmpopIn::py_type_cell().get().unwrap().clone(), + crate::Cmpop::NotIn => ranged::CmpopNotIn::py_type_cell().get().unwrap().clone(), + }; + Ok(instance) + } +} + +// product +impl ToPyo3Ast for crate::ranged::Comprehension { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::Comprehension::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +impl ToPyo3Ast for crate::ranged::Excepthandler { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Excepthandler::ExceptHandler(cons) => cons.to_pyo3_ast(_py)?, + }; + Ok(instance) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::ExcepthandlerExceptHandler { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::ExcepthandlerExceptHandler::py_type_cell() + .get() + .unwrap(); + let instance = class.call1( + _py, + ( + self.type_.to_pyo3_ast(_py)?, + self.name.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// product +impl ToPyo3Ast for crate::ranged::Arguments { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::Arguments::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// product +impl ToPyo3Ast for crate::ranged::Arg { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::Arg::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.arg.to_pyo3_ast(_py)?, + self.annotation.to_pyo3_ast(_py)?, + self.type_comment.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// product +impl ToPyo3Ast for crate::ranged::Keyword { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::Keyword::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.arg.to_pyo3_ast(_py)?, self.value.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// product +impl ToPyo3Ast for crate::ranged::Alias { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::Alias::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.name.to_pyo3_ast(_py)?, self.asname.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// product +impl ToPyo3Ast for crate::ranged::Withitem { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::Withitem::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.context_expr.to_pyo3_ast(_py)?, + self.optional_vars.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// product +impl ToPyo3Ast for crate::ranged::MatchCase { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::MatchCase::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.pattern.to_pyo3_ast(_py)?, + self.guard.to_pyo3_ast(_py)?, + self.body.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +impl ToPyo3Ast for crate::ranged::Pattern { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::Pattern::MatchValue(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchSingleton(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchSequence(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchMapping(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchClass(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchStar(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchAs(cons) => cons.to_pyo3_ast(_py)?, + crate::Pattern::MatchOr(cons) => cons.to_pyo3_ast(_py)?, + }; + Ok(instance) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::PatternMatchValue { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchValue::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::PatternMatchSingleton { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchSingleton::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.value.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::PatternMatchSequence { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchSequence::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.patterns.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::PatternMatchMapping { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchMapping::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + ( + self.keys.to_pyo3_ast(_py)?, + self.patterns.to_pyo3_ast(_py)?, + self.rest.to_pyo3_ast(_py)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::PatternMatchClass { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchClass::py_type_cell().get().unwrap(); + let instance = class.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)?, + ), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::PatternMatchStar { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchStar::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.name.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::PatternMatchAs { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchAs::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.pattern.to_pyo3_ast(_py)?, self.name.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::PatternMatchOr { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::PatternMatchOr::py_type_cell().get().unwrap(); + let instance = class.call1(_py, (self.patterns.to_pyo3_ast(_py)?,))?; + Ok(instance.into()) + } +} + +impl ToPyo3Ast for crate::ranged::TypeIgnore { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let instance = match &self { + crate::TypeIgnore::TypeIgnore(cons) => cons.to_pyo3_ast(_py)?, + }; + Ok(instance) + } +} + +// constructor +impl ToPyo3Ast for crate::ranged::TypeIgnoreTypeIgnore { + fn to_pyo3_ast(&self, _py: Python) -> PyResult> { + let class = ranged::TypeIgnoreTypeIgnore::py_type_cell().get().unwrap(); + let instance = class.call1( + _py, + (self.lineno.to_pyo3_ast(_py)?, self.tag.to_pyo3_ast(_py)?), + )?; + Ok(instance.into()) + } +} diff --git a/ast/src/lib.rs b/ast/src/lib.rs index d1f63d1..814650e 100644 --- a/ast/src/lib.rs +++ b/ast/src/lib.rs @@ -47,3 +47,6 @@ pub use visitor::Visitor; mod optimizer; #[cfg(feature = "constant-optimization")] pub use optimizer::ConstantOptimizer; + +#[cfg(feature = "pyo3")] +pub mod pyo3; diff --git a/ast/src/pyo3.rs b/ast/src/pyo3.rs new file mode 100644 index 0000000..07ab136 --- /dev/null +++ b/ast/src/pyo3.rs @@ -0,0 +1,350 @@ +use crate::Node; +use num_complex::Complex64; +use pyo3::prelude::*; +use pyo3::types::{PyBytes, PyList, PyTuple}; + +pub trait ToPyo3Ast { + fn to_pyo3_ast(&self, py: Python) -> PyResult>; +} + +impl ToPyo3Ast for Box { + #[inline] + fn to_pyo3_ast(&self, py: Python) -> PyResult> { + (**self).to_pyo3_ast(py) + } +} + +impl ToPyo3Ast for Option { + #[inline] + fn to_pyo3_ast(&self, py: Python) -> PyResult> { + match self { + Some(ast) => ast.to_pyo3_ast(py), + None => Ok(py.None()), + } + } +} + +impl ToPyo3Ast for Vec { + fn to_pyo3_ast(&self, py: Python) -> PyResult> { + let list = PyList::empty(py); + for item in self { + let py_item = item.to_pyo3_ast(py)?; + list.append(py_item)?; + } + Ok(list.into()) + } +} + +impl ToPyo3Ast for crate::Identifier { + #[inline] + fn to_pyo3_ast(&self, py: Python) -> PyResult> { + Ok(self.as_str().to_object(py)) + } +} + +impl ToPyo3Ast for crate::String { + #[inline] + fn to_pyo3_ast(&self, py: Python) -> PyResult> { + Ok(self.as_str().to_object(py)) + } +} + +impl ToPyo3Ast for crate::Int { + #[inline] + fn to_pyo3_ast(&self, py: Python) -> PyResult> { + Ok((self.to_u32()).to_object(py)) + } +} + +impl ToPyo3Ast for bool { + #[inline] + fn to_pyo3_ast(&self, py: Python) -> PyResult> { + Ok((*self as u32).to_object(py)) + } +} + +impl ToPyo3Ast for crate::Constant { + #[inline] + fn to_pyo3_ast(&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_ast(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) + } +} + +// pub trait FromAst { +// fn from_ast(py: Python, ast: A) -> PyResult>; +// } + +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()), + } + } +} + +// for Vec needs refactoring +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()) + } +} + +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()) + } +} + +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()) + } +} + +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()) + } +} + +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()) + } +} + +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()) + } +} + +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()) + } +} + +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()) + } +} + +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()) + } +} + +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()) + } +} + +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()) + } +} + +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()) + } +} + +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()) + } +} + +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()) + } +} + +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 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) + } +} + +include!("gen/to_pyo3_ranged.rs"); +// include!("gen/to_pyo3_located.rs"); + +pub mod located { + pub use super::AST; + use super::*; + // include!("gen/pyo3_located.rs"); +} + +pub mod ranged { + pub use super::AST; + use super::*; + include!("gen/pyo3_ranged.rs"); +} + +#[pyclass(module = "rustpython_ast", subclass)] +pub struct AST; + +#[pymethods] +impl AST { + #[new] + fn new() -> Self { + Self + } +} + +/// 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(()) +}