diff --git a/ast/asdl_rs.py b/ast/asdl_rs.py index ca7bb72..6dd32f5 100755 --- a/ast/asdl_rs.py +++ b/ast/asdl_rs.py @@ -10,7 +10,7 @@ import re from argparse import ArgumentParser from pathlib import Path -from typing import Optional, Dict +from typing import Optional, Dict, Any import asdl @@ -87,6 +87,7 @@ class TypeInfo: is_simple: bool empty_field: bool children: set + fields: Optional[Any] boxed: bool product: bool has_expr: bool = False @@ -99,6 +100,7 @@ class TypeInfo: self.is_simple = False self.empty_field = False self.children = set() + self.fields = None self.boxed = False self.product = False self.product_has_expr = False @@ -212,6 +214,7 @@ class FindUserDataTypesVisitor(asdl.VisitorBase): t_info = TypeInfo(t.name) t_info.enum_name = name t_info.empty_field = not t.fields + t_info.fields = t.fields self.type_info[t.name] = t_info self.add_children(t.name, t.fields) if len(sum.types) > 1: @@ -226,6 +229,7 @@ class FindUserDataTypesVisitor(asdl.VisitorBase): def visitProduct(self, product, name): info = self.type_info[name] + info.fields = product.fields if product.attributes: # attributes means located, which has the `range: R` field info.has_user_data = True @@ -982,6 +986,22 @@ class Pyo3StructVisitor(EmitVisitor): def ref(self): return "&" if self.borrow else "" + def emit_class_cache(self, rust_name, fields): + self.emit( + textwrap.dedent( + f""" + impl {rust_name} {{ + #[inline] + pub fn py_type_cell() -> &'static OnceCell> {{ + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + }} + }} + """ + ), + 0, + ) + def emit_class(self, name, rust_name, subclass, base="super::AST"): if subclass: subclass = ", subclass" @@ -995,18 +1015,10 @@ class Pyo3StructVisitor(EmitVisitor): self.emit( textwrap.dedent( f""" - #[pyclass(module="{self.module_name}", name="_{name}", extends={base}{subclass})] + #[pyclass(module="{self.module_name}", name="_{name}", extends={base}, frozen{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} @@ -1153,6 +1165,7 @@ class Pyo3StructVisitor(EmitVisitor): def visitSum(self, sum, name, depth=0): rust_name = rust_type_name(name) self.emit_class(name, rust_name, True) + self.emit_class_cache(rust_name, []) simple = is_simple(sum) @@ -1193,6 +1206,7 @@ class Pyo3StructVisitor(EmitVisitor): def visitProduct(self, product, name, depth=0): rust_name = rust_type_name(name) self.emit_class(name, rust_name, False) + self.emit_class_cache(rust_name, product.fields) if self.borrow: self.emit_getter(product, rust_name) @@ -1203,14 +1217,6 @@ class Pyo3StructVisitor(EmitVisitor): #[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) @@ -1222,10 +1228,15 @@ impl ToPyObject for {parent}{cons.name} {{ """, depth, ) + self.emit_class_cache(f"{parent}{cons.name}", []) else: self.emit_class( - cons.name, f"{parent}{cons.name}", subclass=False, base=parent + cons.name, + f"{parent}{cons.name}", + subclass=False, + base=parent, ) + self.emit_class_cache(f"{parent}{cons.name}", cons.fields) if self.borrow: self.emit_getter(cons, f"{parent}{cons.name}") @@ -1244,21 +1255,21 @@ class Pyo3PymoduleVisitor(EmitVisitor): def visitProduct(self, product, name, depth=0): rust_name = rust_type_name(name) - self.emit_fields(name, rust_name, False, depth) + self.emit_fields(name, rust_name, product.fields, 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) + 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) + self.emit_fields(cons.name, rust_name, cons.fields, simple, depth) - def emit_fields(self, name, rust_name, simple, depth): + def emit_fields(self, name, rust_name, fields, simple, depth): if simple: call = ".call0().unwrap()" else: @@ -1413,7 +1424,10 @@ class StdlibTraitImplVisitor(EmitVisitor): depth, ) self.emit("};", depth + 3) - self.emit("NodeAst.into_ref_with_type(vm, node_type.to_owned()).unwrap().into()", depth + 2) + self.emit( + "NodeAst.into_ref_with_type(vm, node_type.to_owned()).unwrap().into()", + depth + 2, + ) else: self.emit("match self {", depth + 2) for cons in sum.types: @@ -1619,7 +1633,7 @@ def write_located_def(mod, type_info, f): LocatedDefVisitor(f, type_info).visit(mod) -def write_ast_pyo3(mod, type_info, namespace, f): +def write_pyo3_ast(mod, type_info, namespace, f): ToPyo3AstVisitor(namespace, f, type_info).visit(mod) @@ -1636,6 +1650,7 @@ def write_pyo3_def(mod, type_info, namespace, borrow, f): let ast_module = PyModule::import(py, "_ast")?; """ ) + Pyo3PymoduleVisitor(namespace, f, type_info).visit(mod) f.write("Ok(())\n}") @@ -1686,8 +1701,8 @@ def main( ("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")), + ("to_pyo3_located", p(write_pyo3_ast, mod, type_info, "located")), + ("to_pyo3_ranged", p(write_pyo3_ast, 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)), ]: diff --git a/ast/src/gen/pyo3_ranged.rs b/ast/src/gen/pyo3_ranged.rs index d598f4e..9adac8b 100644 --- a/ast/src/gen/pyo3_ranged.rs +++ b/ast/src/gen/pyo3_ranged.rs @@ -1,17 +1,9 @@ // File automatically generated by ast/asdl_rs.py. -#[pyclass(module="rustpython_ast.ranged", name="_mod", extends=super::AST, subclass)] +#[pyclass(module="rustpython_ast.ranged", name="_mod", extends=super::AST, frozen, 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 @@ -32,6 +24,14 @@ impl ToPyObject for Mod { } } +impl Mod { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + impl ToPyo3Wrapper for crate::ranged::Mod { #[inline] fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { @@ -44,18 +44,10 @@ impl ToPyo3Wrapper for crate::ranged::Mod { } } -#[pyclass(module="rustpython_ast.ranged", name="_Module", extends=Mod)] +#[pyclass(module="rustpython_ast.ranged", name="_Module", extends=Mod, frozen)] #[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) @@ -78,6 +70,14 @@ impl ToPyo3Wrapper for crate::ranged::ModModule { } } +impl ModModule { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ModModule { #[getter] @@ -93,18 +93,10 @@ impl ModModule { } } -#[pyclass(module="rustpython_ast.ranged", name="_Interactive", extends=Mod)] +#[pyclass(module="rustpython_ast.ranged", name="_Interactive", extends=Mod, frozen)] #[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) @@ -127,6 +119,14 @@ impl ToPyo3Wrapper for crate::ranged::ModInteractive { } } +impl ModInteractive { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ModInteractive { #[getter] @@ -136,18 +136,10 @@ impl ModInteractive { } } -#[pyclass(module="rustpython_ast.ranged", name="_Expression", extends=Mod)] +#[pyclass(module="rustpython_ast.ranged", name="_Expression", extends=Mod, frozen)] #[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) @@ -170,6 +162,14 @@ impl ToPyo3Wrapper for crate::ranged::ModExpression { } } +impl ModExpression { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ModExpression { #[getter] @@ -179,18 +179,10 @@ impl ModExpression { } } -#[pyclass(module="rustpython_ast.ranged", name="_FunctionType", extends=Mod)] +#[pyclass(module="rustpython_ast.ranged", name="_FunctionType", extends=Mod, frozen)] #[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) @@ -213,6 +205,14 @@ impl ToPyo3Wrapper for crate::ranged::ModFunctionType { } } +impl ModFunctionType { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ModFunctionType { #[getter] @@ -228,18 +228,10 @@ impl ModFunctionType { } } -#[pyclass(module="rustpython_ast.ranged", name="_stmt", extends=super::AST, subclass)] +#[pyclass(module="rustpython_ast.ranged", name="_stmt", extends=super::AST, frozen, 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 @@ -260,6 +252,14 @@ impl ToPyObject for Stmt { } } +impl Stmt { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + impl ToPyo3Wrapper for crate::ranged::Stmt { #[inline] fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { @@ -295,18 +295,10 @@ impl ToPyo3Wrapper for crate::ranged::Stmt { } } -#[pyclass(module="rustpython_ast.ranged", name="_FunctionDef", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_FunctionDef", extends=Stmt, frozen)] #[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) @@ -329,6 +321,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtFunctionDef { } } +impl StmtFunctionDef { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtFunctionDef { #[getter] @@ -368,18 +368,10 @@ impl StmtFunctionDef { } } -#[pyclass(module="rustpython_ast.ranged", name="_AsyncFunctionDef", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_AsyncFunctionDef", extends=Stmt, frozen)] #[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) @@ -402,6 +394,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtAsyncFunctionDef { } } +impl StmtAsyncFunctionDef { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtAsyncFunctionDef { #[getter] @@ -441,18 +441,10 @@ impl StmtAsyncFunctionDef { } } -#[pyclass(module="rustpython_ast.ranged", name="_ClassDef", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_ClassDef", extends=Stmt, frozen)] #[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) @@ -475,6 +467,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtClassDef { } } +impl StmtClassDef { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtClassDef { #[getter] @@ -508,18 +508,10 @@ impl StmtClassDef { } } -#[pyclass(module="rustpython_ast.ranged", name="_Return", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_Return", extends=Stmt, frozen)] #[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) @@ -542,6 +534,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtReturn { } } +impl StmtReturn { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtReturn { #[getter] @@ -551,18 +551,10 @@ impl StmtReturn { } } -#[pyclass(module="rustpython_ast.ranged", name="_Delete", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_Delete", extends=Stmt, frozen)] #[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) @@ -585,6 +577,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtDelete { } } +impl StmtDelete { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtDelete { #[getter] @@ -594,18 +594,10 @@ impl StmtDelete { } } -#[pyclass(module="rustpython_ast.ranged", name="_Assign", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_Assign", extends=Stmt, frozen)] #[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) @@ -628,6 +620,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtAssign { } } +impl StmtAssign { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtAssign { #[getter] @@ -649,18 +649,10 @@ impl StmtAssign { } } -#[pyclass(module="rustpython_ast.ranged", name="_AugAssign", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_AugAssign", extends=Stmt, frozen)] #[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) @@ -683,6 +675,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtAugAssign { } } +impl StmtAugAssign { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtAugAssign { #[getter] @@ -704,18 +704,10 @@ impl StmtAugAssign { } } -#[pyclass(module="rustpython_ast.ranged", name="_AnnAssign", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_AnnAssign", extends=Stmt, frozen)] #[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) @@ -738,6 +730,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtAnnAssign { } } +impl StmtAnnAssign { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtAnnAssign { #[getter] @@ -765,18 +765,10 @@ impl StmtAnnAssign { } } -#[pyclass(module="rustpython_ast.ranged", name="_For", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_For", extends=Stmt, frozen)] #[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) @@ -799,6 +791,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtFor { } } +impl StmtFor { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtFor { #[getter] @@ -832,18 +832,10 @@ impl StmtFor { } } -#[pyclass(module="rustpython_ast.ranged", name="_AsyncFor", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_AsyncFor", extends=Stmt, frozen)] #[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) @@ -866,6 +858,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtAsyncFor { } } +impl StmtAsyncFor { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtAsyncFor { #[getter] @@ -899,18 +899,10 @@ impl StmtAsyncFor { } } -#[pyclass(module="rustpython_ast.ranged", name="_While", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_While", extends=Stmt, frozen)] #[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) @@ -933,6 +925,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtWhile { } } +impl StmtWhile { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtWhile { #[getter] @@ -954,18 +954,10 @@ impl StmtWhile { } } -#[pyclass(module="rustpython_ast.ranged", name="_If", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_If", extends=Stmt, frozen)] #[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) @@ -988,6 +980,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtIf { } } +impl StmtIf { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtIf { #[getter] @@ -1009,18 +1009,10 @@ impl StmtIf { } } -#[pyclass(module="rustpython_ast.ranged", name="_With", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_With", extends=Stmt, frozen)] #[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) @@ -1043,6 +1035,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtWith { } } +impl StmtWith { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtWith { #[getter] @@ -1064,18 +1064,10 @@ impl StmtWith { } } -#[pyclass(module="rustpython_ast.ranged", name="_AsyncWith", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_AsyncWith", extends=Stmt, frozen)] #[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) @@ -1098,6 +1090,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtAsyncWith { } } +impl StmtAsyncWith { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtAsyncWith { #[getter] @@ -1119,18 +1119,10 @@ impl StmtAsyncWith { } } -#[pyclass(module="rustpython_ast.ranged", name="_Match", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_Match", extends=Stmt, frozen)] #[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) @@ -1153,6 +1145,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtMatch { } } +impl StmtMatch { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtMatch { #[getter] @@ -1168,18 +1168,10 @@ impl StmtMatch { } } -#[pyclass(module="rustpython_ast.ranged", name="_Raise", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_Raise", extends=Stmt, frozen)] #[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) @@ -1202,6 +1194,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtRaise { } } +impl StmtRaise { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtRaise { #[getter] @@ -1217,18 +1217,10 @@ impl StmtRaise { } } -#[pyclass(module="rustpython_ast.ranged", name="_Try", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_Try", extends=Stmt, frozen)] #[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) @@ -1251,6 +1243,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtTry { } } +impl StmtTry { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtTry { #[getter] @@ -1278,18 +1278,10 @@ impl StmtTry { } } -#[pyclass(module="rustpython_ast.ranged", name="_TryStar", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_TryStar", extends=Stmt, frozen)] #[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) @@ -1312,6 +1304,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtTryStar { } } +impl StmtTryStar { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtTryStar { #[getter] @@ -1339,18 +1339,10 @@ impl StmtTryStar { } } -#[pyclass(module="rustpython_ast.ranged", name="_Assert", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_Assert", extends=Stmt, frozen)] #[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) @@ -1373,6 +1365,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtAssert { } } +impl StmtAssert { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtAssert { #[getter] @@ -1388,18 +1388,10 @@ impl StmtAssert { } } -#[pyclass(module="rustpython_ast.ranged", name="_Import", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_Import", extends=Stmt, frozen)] #[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) @@ -1422,6 +1414,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtImport { } } +impl StmtImport { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtImport { #[getter] @@ -1431,18 +1431,10 @@ impl StmtImport { } } -#[pyclass(module="rustpython_ast.ranged", name="_ImportFrom", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_ImportFrom", extends=Stmt, frozen)] #[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) @@ -1465,6 +1457,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtImportFrom { } } +impl StmtImportFrom { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtImportFrom { #[getter] @@ -1486,18 +1486,10 @@ impl StmtImportFrom { } } -#[pyclass(module="rustpython_ast.ranged", name="_Global", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_Global", extends=Stmt, frozen)] #[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) @@ -1520,6 +1512,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtGlobal { } } +impl StmtGlobal { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtGlobal { #[getter] @@ -1529,18 +1529,10 @@ impl StmtGlobal { } } -#[pyclass(module="rustpython_ast.ranged", name="_Nonlocal", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_Nonlocal", extends=Stmt, frozen)] #[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) @@ -1563,6 +1555,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtNonlocal { } } +impl StmtNonlocal { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtNonlocal { #[getter] @@ -1572,18 +1572,10 @@ impl StmtNonlocal { } } -#[pyclass(module="rustpython_ast.ranged", name="_Expr", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_Expr", extends=Stmt, frozen)] #[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) @@ -1606,6 +1598,14 @@ impl ToPyo3Wrapper for crate::ranged::StmtExpr { } } +impl StmtExpr { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl StmtExpr { #[getter] @@ -1615,18 +1615,10 @@ impl StmtExpr { } } -#[pyclass(module="rustpython_ast.ranged", name="_Pass", extends=Stmt)] +#[pyclass(module="rustpython_ast.ranged", name="_Pass", extends=Stmt, frozen)] #[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) @@ -1649,14 +1641,7 @@ impl ToPyo3Wrapper for crate::ranged::StmtPass { } } -#[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 { +impl StmtPass { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -1664,6 +1649,13 @@ impl StmtBreak { } } +#[pymethods] +impl StmtPass {} + +#[pyclass(module="rustpython_ast.ranged", name="_Break", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtBreak(pub &'static crate::ranged::StmtBreak); + impl From<&'static crate::ranged::StmtBreak> for StmtBreak { fn from(node: &'static crate::ranged::StmtBreak) -> Self { StmtBreak(node) @@ -1686,14 +1678,7 @@ impl ToPyo3Wrapper for crate::ranged::StmtBreak { } } -#[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 { +impl StmtBreak { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -1701,6 +1686,13 @@ impl StmtContinue { } } +#[pymethods] +impl StmtBreak {} + +#[pyclass(module="rustpython_ast.ranged", name="_Continue", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtContinue(pub &'static crate::ranged::StmtContinue); + impl From<&'static crate::ranged::StmtContinue> for StmtContinue { fn from(node: &'static crate::ranged::StmtContinue) -> Self { StmtContinue(node) @@ -1723,14 +1715,7 @@ impl ToPyo3Wrapper for crate::ranged::StmtContinue { } } -#[pymethods] -impl StmtContinue {} - -#[pyclass(module="rustpython_ast.ranged", name="_expr", extends=super::AST, subclass)] -#[derive(Clone, Debug)] -pub struct Expr; - -impl Expr { +impl StmtContinue { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -1738,6 +1723,13 @@ impl Expr { } } +#[pymethods] +impl StmtContinue {} + +#[pyclass(module="rustpython_ast.ranged", name="_expr", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Expr; + impl From<&'static crate::ranged::Expr> for Expr { fn from(_node: &'static crate::ranged::Expr) -> Self { Expr @@ -1758,6 +1750,14 @@ impl ToPyObject for Expr { } } +impl Expr { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + impl ToPyo3Wrapper for crate::ranged::Expr { #[inline] fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { @@ -1793,18 +1793,10 @@ impl ToPyo3Wrapper for crate::ranged::Expr { } } -#[pyclass(module="rustpython_ast.ranged", name="_BoolOp", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_BoolOp", extends=Expr, frozen)] #[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) @@ -1827,6 +1819,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprBoolOp { } } +impl ExprBoolOp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprBoolOp { #[getter] @@ -1842,18 +1842,10 @@ impl ExprBoolOp { } } -#[pyclass(module="rustpython_ast.ranged", name="_NamedExpr", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_NamedExpr", extends=Expr, frozen)] #[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) @@ -1876,6 +1868,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprNamedExpr { } } +impl ExprNamedExpr { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprNamedExpr { #[getter] @@ -1891,18 +1891,10 @@ impl ExprNamedExpr { } } -#[pyclass(module="rustpython_ast.ranged", name="_BinOp", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_BinOp", extends=Expr, frozen)] #[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) @@ -1925,6 +1917,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprBinOp { } } +impl ExprBinOp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprBinOp { #[getter] @@ -1946,18 +1946,10 @@ impl ExprBinOp { } } -#[pyclass(module="rustpython_ast.ranged", name="_UnaryOp", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_UnaryOp", extends=Expr, frozen)] #[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) @@ -1980,6 +1972,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprUnaryOp { } } +impl ExprUnaryOp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprUnaryOp { #[getter] @@ -1995,18 +1995,10 @@ impl ExprUnaryOp { } } -#[pyclass(module="rustpython_ast.ranged", name="_Lambda", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Lambda", extends=Expr, frozen)] #[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) @@ -2029,6 +2021,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprLambda { } } +impl ExprLambda { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprLambda { #[getter] @@ -2044,18 +2044,10 @@ impl ExprLambda { } } -#[pyclass(module="rustpython_ast.ranged", name="_IfExp", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_IfExp", extends=Expr, frozen)] #[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) @@ -2078,6 +2070,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprIfExp { } } +impl ExprIfExp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprIfExp { #[getter] @@ -2099,18 +2099,10 @@ impl ExprIfExp { } } -#[pyclass(module="rustpython_ast.ranged", name="_Dict", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Dict", extends=Expr, frozen)] #[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) @@ -2133,6 +2125,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprDict { } } +impl ExprDict { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprDict { #[getter] @@ -2148,18 +2148,10 @@ impl ExprDict { } } -#[pyclass(module="rustpython_ast.ranged", name="_Set", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Set", extends=Expr, frozen)] #[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) @@ -2182,6 +2174,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprSet { } } +impl ExprSet { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprSet { #[getter] @@ -2191,18 +2191,10 @@ impl ExprSet { } } -#[pyclass(module="rustpython_ast.ranged", name="_ListComp", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_ListComp", extends=Expr, frozen)] #[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) @@ -2225,6 +2217,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprListComp { } } +impl ExprListComp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprListComp { #[getter] @@ -2240,18 +2240,10 @@ impl ExprListComp { } } -#[pyclass(module="rustpython_ast.ranged", name="_SetComp", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_SetComp", extends=Expr, frozen)] #[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) @@ -2274,6 +2266,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprSetComp { } } +impl ExprSetComp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprSetComp { #[getter] @@ -2289,18 +2289,10 @@ impl ExprSetComp { } } -#[pyclass(module="rustpython_ast.ranged", name="_DictComp", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_DictComp", extends=Expr, frozen)] #[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) @@ -2323,6 +2315,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprDictComp { } } +impl ExprDictComp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprDictComp { #[getter] @@ -2344,18 +2344,10 @@ impl ExprDictComp { } } -#[pyclass(module="rustpython_ast.ranged", name="_GeneratorExp", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_GeneratorExp", extends=Expr, frozen)] #[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) @@ -2378,6 +2370,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprGeneratorExp { } } +impl ExprGeneratorExp { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprGeneratorExp { #[getter] @@ -2393,18 +2393,10 @@ impl ExprGeneratorExp { } } -#[pyclass(module="rustpython_ast.ranged", name="_Await", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Await", extends=Expr, frozen)] #[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) @@ -2427,6 +2419,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprAwait { } } +impl ExprAwait { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprAwait { #[getter] @@ -2436,18 +2436,10 @@ impl ExprAwait { } } -#[pyclass(module="rustpython_ast.ranged", name="_Yield", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Yield", extends=Expr, frozen)] #[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) @@ -2470,6 +2462,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprYield { } } +impl ExprYield { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprYield { #[getter] @@ -2479,18 +2479,10 @@ impl ExprYield { } } -#[pyclass(module="rustpython_ast.ranged", name="_YieldFrom", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_YieldFrom", extends=Expr, frozen)] #[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) @@ -2513,6 +2505,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprYieldFrom { } } +impl ExprYieldFrom { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprYieldFrom { #[getter] @@ -2522,18 +2522,10 @@ impl ExprYieldFrom { } } -#[pyclass(module="rustpython_ast.ranged", name="_Compare", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Compare", extends=Expr, frozen)] #[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) @@ -2556,6 +2548,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprCompare { } } +impl ExprCompare { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprCompare { #[getter] @@ -2577,18 +2577,10 @@ impl ExprCompare { } } -#[pyclass(module="rustpython_ast.ranged", name="_Call", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Call", extends=Expr, frozen)] #[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) @@ -2611,6 +2603,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprCall { } } +impl ExprCall { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprCall { #[getter] @@ -2632,18 +2632,10 @@ impl ExprCall { } } -#[pyclass(module="rustpython_ast.ranged", name="_FormattedValue", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_FormattedValue", extends=Expr, frozen)] #[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) @@ -2666,6 +2658,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprFormattedValue { } } +impl ExprFormattedValue { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprFormattedValue { #[getter] @@ -2687,18 +2687,10 @@ impl ExprFormattedValue { } } -#[pyclass(module="rustpython_ast.ranged", name="_JoinedStr", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_JoinedStr", extends=Expr, frozen)] #[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) @@ -2721,6 +2713,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprJoinedStr { } } +impl ExprJoinedStr { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprJoinedStr { #[getter] @@ -2730,18 +2730,10 @@ impl ExprJoinedStr { } } -#[pyclass(module="rustpython_ast.ranged", name="_Constant", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Constant", extends=Expr, frozen)] #[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) @@ -2764,6 +2756,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprConstant { } } +impl ExprConstant { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprConstant { #[getter] @@ -2779,18 +2779,10 @@ impl ExprConstant { } } -#[pyclass(module="rustpython_ast.ranged", name="_Attribute", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Attribute", extends=Expr, frozen)] #[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) @@ -2813,6 +2805,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprAttribute { } } +impl ExprAttribute { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprAttribute { #[getter] @@ -2834,18 +2834,10 @@ impl ExprAttribute { } } -#[pyclass(module="rustpython_ast.ranged", name="_Subscript", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Subscript", extends=Expr, frozen)] #[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) @@ -2868,6 +2860,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprSubscript { } } +impl ExprSubscript { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprSubscript { #[getter] @@ -2889,18 +2889,10 @@ impl ExprSubscript { } } -#[pyclass(module="rustpython_ast.ranged", name="_Starred", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Starred", extends=Expr, frozen)] #[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) @@ -2923,6 +2915,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprStarred { } } +impl ExprStarred { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprStarred { #[getter] @@ -2938,18 +2938,10 @@ impl ExprStarred { } } -#[pyclass(module="rustpython_ast.ranged", name="_Name", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Name", extends=Expr, frozen)] #[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) @@ -2972,6 +2964,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprName { } } +impl ExprName { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprName { #[getter] @@ -2987,18 +2987,10 @@ impl ExprName { } } -#[pyclass(module="rustpython_ast.ranged", name="_List", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_List", extends=Expr, frozen)] #[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) @@ -3021,6 +3013,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprList { } } +impl ExprList { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprList { #[getter] @@ -3036,18 +3036,10 @@ impl ExprList { } } -#[pyclass(module="rustpython_ast.ranged", name="_Tuple", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Tuple", extends=Expr, frozen)] #[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) @@ -3070,6 +3062,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprTuple { } } +impl ExprTuple { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprTuple { #[getter] @@ -3085,18 +3085,10 @@ impl ExprTuple { } } -#[pyclass(module="rustpython_ast.ranged", name="_Slice", extends=Expr)] +#[pyclass(module="rustpython_ast.ranged", name="_Slice", extends=Expr, frozen)] #[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) @@ -3119,6 +3111,14 @@ impl ToPyo3Wrapper for crate::ranged::ExprSlice { } } +impl ExprSlice { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExprSlice { #[getter] @@ -3140,18 +3140,10 @@ impl ExprSlice { } } -#[pyclass(module="rustpython_ast.ranged", name="_expr_context", extends=super::AST, subclass)] +#[pyclass(module="rustpython_ast.ranged", name="_expr_context", extends=super::AST, frozen, 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 @@ -3172,6 +3164,14 @@ impl ToPyObject for ExprContext { } } +impl ExprContext { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + impl ToPyo3Wrapper for crate::ranged::ExprContext { #[inline] fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { @@ -3186,14 +3186,6 @@ impl ToPyo3Wrapper for crate::ranged::ExprContext { #[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) @@ -3203,10 +3195,7 @@ impl ToPyObject for ExprContextLoad { } } -#[pyclass(module="rustpython_ast.ranged", name="_Store", extends=ExprContext)] -pub struct ExprContextStore; - -impl ExprContextStore { +impl ExprContextLoad { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3214,6 +3203,9 @@ impl ExprContextStore { } } +#[pyclass(module="rustpython_ast.ranged", name="_Store", extends=ExprContext)] +pub struct ExprContextStore; + impl ToPyObject for ExprContextStore { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3223,10 +3215,7 @@ impl ToPyObject for ExprContextStore { } } -#[pyclass(module="rustpython_ast.ranged", name="_Del", extends=ExprContext)] -pub struct ExprContextDel; - -impl ExprContextDel { +impl ExprContextStore { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3234,6 +3223,9 @@ impl ExprContextDel { } } +#[pyclass(module="rustpython_ast.ranged", name="_Del", extends=ExprContext)] +pub struct ExprContextDel; + impl ToPyObject for ExprContextDel { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3243,11 +3235,7 @@ impl ToPyObject for ExprContextDel { } } -#[pyclass(module="rustpython_ast.ranged", name="_boolop", extends=super::AST, subclass)] -#[derive(Clone, Debug)] -pub struct Boolop; - -impl Boolop { +impl ExprContextDel { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3255,6 +3243,10 @@ impl Boolop { } } +#[pyclass(module="rustpython_ast.ranged", name="_boolop", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Boolop; + impl From<&'static crate::ranged::Boolop> for Boolop { fn from(_node: &'static crate::ranged::Boolop) -> Self { Boolop @@ -3275,6 +3267,14 @@ impl ToPyObject for Boolop { } } +impl Boolop { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + impl ToPyo3Wrapper for crate::ranged::Boolop { #[inline] fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { @@ -3288,14 +3288,6 @@ impl ToPyo3Wrapper for crate::ranged::Boolop { #[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) @@ -3305,10 +3297,7 @@ impl ToPyObject for BoolopAnd { } } -#[pyclass(module="rustpython_ast.ranged", name="_Or", extends=Boolop)] -pub struct BoolopOr; - -impl BoolopOr { +impl BoolopAnd { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3316,6 +3305,9 @@ impl BoolopOr { } } +#[pyclass(module="rustpython_ast.ranged", name="_Or", extends=Boolop)] +pub struct BoolopOr; + impl ToPyObject for BoolopOr { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3325,11 +3317,7 @@ impl ToPyObject for BoolopOr { } } -#[pyclass(module="rustpython_ast.ranged", name="_operator", extends=super::AST, subclass)] -#[derive(Clone, Debug)] -pub struct Operator; - -impl Operator { +impl BoolopOr { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3337,6 +3325,10 @@ impl Operator { } } +#[pyclass(module="rustpython_ast.ranged", name="_operator", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Operator; + impl From<&'static crate::ranged::Operator> for Operator { fn from(_node: &'static crate::ranged::Operator) -> Self { Operator @@ -3357,6 +3349,14 @@ impl ToPyObject for Operator { } } +impl Operator { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + impl ToPyo3Wrapper for crate::ranged::Operator { #[inline] fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { @@ -3381,14 +3381,6 @@ impl ToPyo3Wrapper for crate::ranged::Operator { #[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) @@ -3398,10 +3390,7 @@ impl ToPyObject for OperatorAdd { } } -#[pyclass(module="rustpython_ast.ranged", name="_Sub", extends=Operator)] -pub struct OperatorSub; - -impl OperatorSub { +impl OperatorAdd { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3409,6 +3398,9 @@ impl OperatorSub { } } +#[pyclass(module="rustpython_ast.ranged", name="_Sub", extends=Operator)] +pub struct OperatorSub; + impl ToPyObject for OperatorSub { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3418,10 +3410,7 @@ impl ToPyObject for OperatorSub { } } -#[pyclass(module="rustpython_ast.ranged", name="_Mult", extends=Operator)] -pub struct OperatorMult; - -impl OperatorMult { +impl OperatorSub { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3429,6 +3418,9 @@ impl OperatorMult { } } +#[pyclass(module="rustpython_ast.ranged", name="_Mult", extends=Operator)] +pub struct OperatorMult; + impl ToPyObject for OperatorMult { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3438,10 +3430,7 @@ impl ToPyObject for OperatorMult { } } -#[pyclass(module="rustpython_ast.ranged", name="_MatMult", extends=Operator)] -pub struct OperatorMatMult; - -impl OperatorMatMult { +impl OperatorMult { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3449,6 +3438,9 @@ impl OperatorMatMult { } } +#[pyclass(module="rustpython_ast.ranged", name="_MatMult", extends=Operator)] +pub struct OperatorMatMult; + impl ToPyObject for OperatorMatMult { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3458,10 +3450,7 @@ impl ToPyObject for OperatorMatMult { } } -#[pyclass(module="rustpython_ast.ranged", name="_Div", extends=Operator)] -pub struct OperatorDiv; - -impl OperatorDiv { +impl OperatorMatMult { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3469,6 +3458,9 @@ impl OperatorDiv { } } +#[pyclass(module="rustpython_ast.ranged", name="_Div", extends=Operator)] +pub struct OperatorDiv; + impl ToPyObject for OperatorDiv { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3478,10 +3470,7 @@ impl ToPyObject for OperatorDiv { } } -#[pyclass(module="rustpython_ast.ranged", name="_Mod", extends=Operator)] -pub struct OperatorMod; - -impl OperatorMod { +impl OperatorDiv { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3489,6 +3478,9 @@ impl OperatorMod { } } +#[pyclass(module="rustpython_ast.ranged", name="_Mod", extends=Operator)] +pub struct OperatorMod; + impl ToPyObject for OperatorMod { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3498,10 +3490,7 @@ impl ToPyObject for OperatorMod { } } -#[pyclass(module="rustpython_ast.ranged", name="_Pow", extends=Operator)] -pub struct OperatorPow; - -impl OperatorPow { +impl OperatorMod { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3509,6 +3498,9 @@ impl OperatorPow { } } +#[pyclass(module="rustpython_ast.ranged", name="_Pow", extends=Operator)] +pub struct OperatorPow; + impl ToPyObject for OperatorPow { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3518,10 +3510,7 @@ impl ToPyObject for OperatorPow { } } -#[pyclass(module="rustpython_ast.ranged", name="_LShift", extends=Operator)] -pub struct OperatorLShift; - -impl OperatorLShift { +impl OperatorPow { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3529,6 +3518,9 @@ impl OperatorLShift { } } +#[pyclass(module="rustpython_ast.ranged", name="_LShift", extends=Operator)] +pub struct OperatorLShift; + impl ToPyObject for OperatorLShift { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3538,10 +3530,7 @@ impl ToPyObject for OperatorLShift { } } -#[pyclass(module="rustpython_ast.ranged", name="_RShift", extends=Operator)] -pub struct OperatorRShift; - -impl OperatorRShift { +impl OperatorLShift { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3549,6 +3538,9 @@ impl OperatorRShift { } } +#[pyclass(module="rustpython_ast.ranged", name="_RShift", extends=Operator)] +pub struct OperatorRShift; + impl ToPyObject for OperatorRShift { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3558,10 +3550,7 @@ impl ToPyObject for OperatorRShift { } } -#[pyclass(module="rustpython_ast.ranged", name="_BitOr", extends=Operator)] -pub struct OperatorBitOr; - -impl OperatorBitOr { +impl OperatorRShift { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3569,6 +3558,9 @@ impl OperatorBitOr { } } +#[pyclass(module="rustpython_ast.ranged", name="_BitOr", extends=Operator)] +pub struct OperatorBitOr; + impl ToPyObject for OperatorBitOr { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3578,10 +3570,7 @@ impl ToPyObject for OperatorBitOr { } } -#[pyclass(module="rustpython_ast.ranged", name="_BitXor", extends=Operator)] -pub struct OperatorBitXor; - -impl OperatorBitXor { +impl OperatorBitOr { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3589,6 +3578,9 @@ impl OperatorBitXor { } } +#[pyclass(module="rustpython_ast.ranged", name="_BitXor", extends=Operator)] +pub struct OperatorBitXor; + impl ToPyObject for OperatorBitXor { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3598,10 +3590,7 @@ impl ToPyObject for OperatorBitXor { } } -#[pyclass(module="rustpython_ast.ranged", name="_BitAnd", extends=Operator)] -pub struct OperatorBitAnd; - -impl OperatorBitAnd { +impl OperatorBitXor { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3609,6 +3598,9 @@ impl OperatorBitAnd { } } +#[pyclass(module="rustpython_ast.ranged", name="_BitAnd", extends=Operator)] +pub struct OperatorBitAnd; + impl ToPyObject for OperatorBitAnd { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3618,10 +3610,7 @@ impl ToPyObject for OperatorBitAnd { } } -#[pyclass(module="rustpython_ast.ranged", name="_FloorDiv", extends=Operator)] -pub struct OperatorFloorDiv; - -impl OperatorFloorDiv { +impl OperatorBitAnd { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3629,6 +3618,9 @@ impl OperatorFloorDiv { } } +#[pyclass(module="rustpython_ast.ranged", name="_FloorDiv", extends=Operator)] +pub struct OperatorFloorDiv; + impl ToPyObject for OperatorFloorDiv { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3638,11 +3630,7 @@ impl ToPyObject for OperatorFloorDiv { } } -#[pyclass(module="rustpython_ast.ranged", name="_unaryop", extends=super::AST, subclass)] -#[derive(Clone, Debug)] -pub struct Unaryop; - -impl Unaryop { +impl OperatorFloorDiv { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3650,6 +3638,10 @@ impl Unaryop { } } +#[pyclass(module="rustpython_ast.ranged", name="_unaryop", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Unaryop; + impl From<&'static crate::ranged::Unaryop> for Unaryop { fn from(_node: &'static crate::ranged::Unaryop) -> Self { Unaryop @@ -3670,6 +3662,14 @@ impl ToPyObject for Unaryop { } } +impl Unaryop { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + impl ToPyo3Wrapper for crate::ranged::Unaryop { #[inline] fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { @@ -3685,14 +3685,6 @@ impl ToPyo3Wrapper for crate::ranged::Unaryop { #[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) @@ -3702,10 +3694,7 @@ impl ToPyObject for UnaryopInvert { } } -#[pyclass(module="rustpython_ast.ranged", name="_Not", extends=Unaryop)] -pub struct UnaryopNot; - -impl UnaryopNot { +impl UnaryopInvert { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3713,6 +3702,9 @@ impl UnaryopNot { } } +#[pyclass(module="rustpython_ast.ranged", name="_Not", extends=Unaryop)] +pub struct UnaryopNot; + impl ToPyObject for UnaryopNot { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3722,10 +3714,7 @@ impl ToPyObject for UnaryopNot { } } -#[pyclass(module="rustpython_ast.ranged", name="_UAdd", extends=Unaryop)] -pub struct UnaryopUAdd; - -impl UnaryopUAdd { +impl UnaryopNot { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3733,6 +3722,9 @@ impl UnaryopUAdd { } } +#[pyclass(module="rustpython_ast.ranged", name="_UAdd", extends=Unaryop)] +pub struct UnaryopUAdd; + impl ToPyObject for UnaryopUAdd { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3742,10 +3734,7 @@ impl ToPyObject for UnaryopUAdd { } } -#[pyclass(module="rustpython_ast.ranged", name="_USub", extends=Unaryop)] -pub struct UnaryopUSub; - -impl UnaryopUSub { +impl UnaryopUAdd { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3753,6 +3742,9 @@ impl UnaryopUSub { } } +#[pyclass(module="rustpython_ast.ranged", name="_USub", extends=Unaryop)] +pub struct UnaryopUSub; + impl ToPyObject for UnaryopUSub { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3762,11 +3754,7 @@ impl ToPyObject for UnaryopUSub { } } -#[pyclass(module="rustpython_ast.ranged", name="_cmpop", extends=super::AST, subclass)] -#[derive(Clone, Debug)] -pub struct Cmpop; - -impl Cmpop { +impl UnaryopUSub { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3774,6 +3762,10 @@ impl Cmpop { } } +#[pyclass(module="rustpython_ast.ranged", name="_cmpop", extends=super::AST, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Cmpop; + impl From<&'static crate::ranged::Cmpop> for Cmpop { fn from(_node: &'static crate::ranged::Cmpop) -> Self { Cmpop @@ -3794,6 +3786,14 @@ impl ToPyObject for Cmpop { } } +impl Cmpop { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + impl ToPyo3Wrapper for crate::ranged::Cmpop { #[inline] fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { @@ -3815,14 +3815,6 @@ impl ToPyo3Wrapper for crate::ranged::Cmpop { #[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) @@ -3832,10 +3824,7 @@ impl ToPyObject for CmpopEq { } } -#[pyclass(module="rustpython_ast.ranged", name="_NotEq", extends=Cmpop)] -pub struct CmpopNotEq; - -impl CmpopNotEq { +impl CmpopEq { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3843,6 +3832,9 @@ impl CmpopNotEq { } } +#[pyclass(module="rustpython_ast.ranged", name="_NotEq", extends=Cmpop)] +pub struct CmpopNotEq; + impl ToPyObject for CmpopNotEq { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3852,10 +3844,7 @@ impl ToPyObject for CmpopNotEq { } } -#[pyclass(module="rustpython_ast.ranged", name="_Lt", extends=Cmpop)] -pub struct CmpopLt; - -impl CmpopLt { +impl CmpopNotEq { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3863,6 +3852,9 @@ impl CmpopLt { } } +#[pyclass(module="rustpython_ast.ranged", name="_Lt", extends=Cmpop)] +pub struct CmpopLt; + impl ToPyObject for CmpopLt { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3872,10 +3864,7 @@ impl ToPyObject for CmpopLt { } } -#[pyclass(module="rustpython_ast.ranged", name="_LtE", extends=Cmpop)] -pub struct CmpopLtE; - -impl CmpopLtE { +impl CmpopLt { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3883,6 +3872,9 @@ impl CmpopLtE { } } +#[pyclass(module="rustpython_ast.ranged", name="_LtE", extends=Cmpop)] +pub struct CmpopLtE; + impl ToPyObject for CmpopLtE { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3892,10 +3884,7 @@ impl ToPyObject for CmpopLtE { } } -#[pyclass(module="rustpython_ast.ranged", name="_Gt", extends=Cmpop)] -pub struct CmpopGt; - -impl CmpopGt { +impl CmpopLtE { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3903,6 +3892,9 @@ impl CmpopGt { } } +#[pyclass(module="rustpython_ast.ranged", name="_Gt", extends=Cmpop)] +pub struct CmpopGt; + impl ToPyObject for CmpopGt { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3912,10 +3904,7 @@ impl ToPyObject for CmpopGt { } } -#[pyclass(module="rustpython_ast.ranged", name="_GtE", extends=Cmpop)] -pub struct CmpopGtE; - -impl CmpopGtE { +impl CmpopGt { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3923,6 +3912,9 @@ impl CmpopGtE { } } +#[pyclass(module="rustpython_ast.ranged", name="_GtE", extends=Cmpop)] +pub struct CmpopGtE; + impl ToPyObject for CmpopGtE { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3932,10 +3924,7 @@ impl ToPyObject for CmpopGtE { } } -#[pyclass(module="rustpython_ast.ranged", name="_Is", extends=Cmpop)] -pub struct CmpopIs; - -impl CmpopIs { +impl CmpopGtE { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3943,6 +3932,9 @@ impl CmpopIs { } } +#[pyclass(module="rustpython_ast.ranged", name="_Is", extends=Cmpop)] +pub struct CmpopIs; + impl ToPyObject for CmpopIs { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3952,10 +3944,7 @@ impl ToPyObject for CmpopIs { } } -#[pyclass(module="rustpython_ast.ranged", name="_IsNot", extends=Cmpop)] -pub struct CmpopIsNot; - -impl CmpopIsNot { +impl CmpopIs { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3963,6 +3952,9 @@ impl CmpopIsNot { } } +#[pyclass(module="rustpython_ast.ranged", name="_IsNot", extends=Cmpop)] +pub struct CmpopIsNot; + impl ToPyObject for CmpopIsNot { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3972,10 +3964,7 @@ impl ToPyObject for CmpopIsNot { } } -#[pyclass(module="rustpython_ast.ranged", name="_In", extends=Cmpop)] -pub struct CmpopIn; - -impl CmpopIn { +impl CmpopIsNot { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -3983,6 +3972,9 @@ impl CmpopIn { } } +#[pyclass(module="rustpython_ast.ranged", name="_In", extends=Cmpop)] +pub struct CmpopIn; + impl ToPyObject for CmpopIn { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -3992,10 +3984,7 @@ impl ToPyObject for CmpopIn { } } -#[pyclass(module="rustpython_ast.ranged", name="_NotIn", extends=Cmpop)] -pub struct CmpopNotIn; - -impl CmpopNotIn { +impl CmpopIn { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -4003,6 +3992,9 @@ impl CmpopNotIn { } } +#[pyclass(module="rustpython_ast.ranged", name="_NotIn", extends=Cmpop)] +pub struct CmpopNotIn; + impl ToPyObject for CmpopNotIn { fn to_object(&self, py: Python) -> PyObject { let initializer = PyClassInitializer::from(AST) @@ -4012,11 +4004,7 @@ impl ToPyObject for CmpopNotIn { } } -#[pyclass(module="rustpython_ast.ranged", name="_comprehension", extends=super::AST)] -#[derive(Clone, Debug)] -pub struct Comprehension(pub &'static crate::ranged::Comprehension); - -impl Comprehension { +impl CmpopNotIn { #[inline] pub fn py_type_cell() -> &'static OnceCell> { static PY_TYPE: OnceCell> = OnceCell::new(); @@ -4024,6 +4012,10 @@ impl Comprehension { } } +#[pyclass(module="rustpython_ast.ranged", name="_comprehension", extends=super::AST, frozen)] +#[derive(Clone, Debug)] +pub struct Comprehension(pub &'static crate::ranged::Comprehension); + impl From<&'static crate::ranged::Comprehension> for Comprehension { fn from(node: &'static crate::ranged::Comprehension) -> Self { Comprehension(node) @@ -4044,6 +4036,14 @@ impl ToPyo3Wrapper for crate::ranged::Comprehension { } } +impl Comprehension { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl Comprehension { #[getter] @@ -4071,18 +4071,10 @@ impl Comprehension { } } -#[pyclass(module="rustpython_ast.ranged", name="_excepthandler", extends=super::AST, subclass)] +#[pyclass(module="rustpython_ast.ranged", name="_excepthandler", extends=super::AST, frozen, 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 @@ -4103,6 +4095,14 @@ impl ToPyObject for Excepthandler { } } +impl Excepthandler { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + impl ToPyo3Wrapper for crate::ranged::Excepthandler { #[inline] fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { @@ -4112,18 +4112,10 @@ impl ToPyo3Wrapper for crate::ranged::Excepthandler { } } -#[pyclass(module="rustpython_ast.ranged", name="_ExceptHandler", extends=Excepthandler)] +#[pyclass(module="rustpython_ast.ranged", name="_ExceptHandler", extends=Excepthandler, frozen)] #[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) @@ -4146,6 +4138,14 @@ impl ToPyo3Wrapper for crate::ranged::ExcepthandlerExceptHandler { } } +impl ExcepthandlerExceptHandler { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl ExcepthandlerExceptHandler { #[getter] @@ -4167,18 +4167,10 @@ impl ExcepthandlerExceptHandler { } } -#[pyclass(module="rustpython_ast.ranged", name="_arguments", extends=super::AST)] +#[pyclass(module="rustpython_ast.ranged", name="_arguments", extends=super::AST, frozen)] #[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) @@ -4199,6 +4191,14 @@ impl ToPyo3Wrapper for crate::ranged::Arguments { } } +impl Arguments { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl Arguments { #[getter] @@ -4244,18 +4244,10 @@ impl Arguments { } } -#[pyclass(module="rustpython_ast.ranged", name="_arg", extends=super::AST)] +#[pyclass(module="rustpython_ast.ranged", name="_arg", extends=super::AST, frozen)] #[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) @@ -4276,6 +4268,14 @@ impl ToPyo3Wrapper for crate::ranged::Arg { } } +impl Arg { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl Arg { #[getter] @@ -4297,18 +4297,10 @@ impl Arg { } } -#[pyclass(module="rustpython_ast.ranged", name="_keyword", extends=super::AST)] +#[pyclass(module="rustpython_ast.ranged", name="_keyword", extends=super::AST, frozen)] #[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) @@ -4329,6 +4321,14 @@ impl ToPyo3Wrapper for crate::ranged::Keyword { } } +impl Keyword { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl Keyword { #[getter] @@ -4344,18 +4344,10 @@ impl Keyword { } } -#[pyclass(module="rustpython_ast.ranged", name="_alias", extends=super::AST)] +#[pyclass(module="rustpython_ast.ranged", name="_alias", extends=super::AST, frozen)] #[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) @@ -4376,6 +4368,14 @@ impl ToPyo3Wrapper for crate::ranged::Alias { } } +impl Alias { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl Alias { #[getter] @@ -4391,18 +4391,10 @@ impl Alias { } } -#[pyclass(module="rustpython_ast.ranged", name="_withitem", extends=super::AST)] +#[pyclass(module="rustpython_ast.ranged", name="_withitem", extends=super::AST, frozen)] #[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) @@ -4423,6 +4415,14 @@ impl ToPyo3Wrapper for crate::ranged::Withitem { } } +impl Withitem { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl Withitem { #[getter] @@ -4438,18 +4438,10 @@ impl Withitem { } } -#[pyclass(module="rustpython_ast.ranged", name="_match_case", extends=super::AST)] +#[pyclass(module="rustpython_ast.ranged", name="_match_case", extends=super::AST, frozen)] #[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) @@ -4470,6 +4462,14 @@ impl ToPyo3Wrapper for crate::ranged::MatchCase { } } +impl MatchCase { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl MatchCase { #[getter] @@ -4491,18 +4491,10 @@ impl MatchCase { } } -#[pyclass(module="rustpython_ast.ranged", name="_pattern", extends=super::AST, subclass)] +#[pyclass(module="rustpython_ast.ranged", name="_pattern", extends=super::AST, frozen, 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 @@ -4523,6 +4515,14 @@ impl ToPyObject for Pattern { } } +impl Pattern { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + impl ToPyo3Wrapper for crate::ranged::Pattern { #[inline] fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { @@ -4539,18 +4539,10 @@ impl ToPyo3Wrapper for crate::ranged::Pattern { } } -#[pyclass(module="rustpython_ast.ranged", name="_MatchValue", extends=Pattern)] +#[pyclass(module="rustpython_ast.ranged", name="_MatchValue", extends=Pattern, frozen)] #[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) @@ -4573,6 +4565,14 @@ impl ToPyo3Wrapper for crate::ranged::PatternMatchValue { } } +impl PatternMatchValue { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl PatternMatchValue { #[getter] @@ -4582,18 +4582,10 @@ impl PatternMatchValue { } } -#[pyclass(module="rustpython_ast.ranged", name="_MatchSingleton", extends=Pattern)] +#[pyclass(module="rustpython_ast.ranged", name="_MatchSingleton", extends=Pattern, frozen)] #[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) @@ -4616,6 +4608,14 @@ impl ToPyo3Wrapper for crate::ranged::PatternMatchSingleton { } } +impl PatternMatchSingleton { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl PatternMatchSingleton { #[getter] @@ -4625,18 +4625,10 @@ impl PatternMatchSingleton { } } -#[pyclass(module="rustpython_ast.ranged", name="_MatchSequence", extends=Pattern)] +#[pyclass(module="rustpython_ast.ranged", name="_MatchSequence", extends=Pattern, frozen)] #[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) @@ -4659,6 +4651,14 @@ impl ToPyo3Wrapper for crate::ranged::PatternMatchSequence { } } +impl PatternMatchSequence { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl PatternMatchSequence { #[getter] @@ -4668,18 +4668,10 @@ impl PatternMatchSequence { } } -#[pyclass(module="rustpython_ast.ranged", name="_MatchMapping", extends=Pattern)] +#[pyclass(module="rustpython_ast.ranged", name="_MatchMapping", extends=Pattern, frozen)] #[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) @@ -4702,6 +4694,14 @@ impl ToPyo3Wrapper for crate::ranged::PatternMatchMapping { } } +impl PatternMatchMapping { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl PatternMatchMapping { #[getter] @@ -4723,18 +4723,10 @@ impl PatternMatchMapping { } } -#[pyclass(module="rustpython_ast.ranged", name="_MatchClass", extends=Pattern)] +#[pyclass(module="rustpython_ast.ranged", name="_MatchClass", extends=Pattern, frozen)] #[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) @@ -4757,6 +4749,14 @@ impl ToPyo3Wrapper for crate::ranged::PatternMatchClass { } } +impl PatternMatchClass { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl PatternMatchClass { #[getter] @@ -4784,18 +4784,10 @@ impl PatternMatchClass { } } -#[pyclass(module="rustpython_ast.ranged", name="_MatchStar", extends=Pattern)] +#[pyclass(module="rustpython_ast.ranged", name="_MatchStar", extends=Pattern, frozen)] #[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) @@ -4818,6 +4810,14 @@ impl ToPyo3Wrapper for crate::ranged::PatternMatchStar { } } +impl PatternMatchStar { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl PatternMatchStar { #[getter] @@ -4827,18 +4827,10 @@ impl PatternMatchStar { } } -#[pyclass(module="rustpython_ast.ranged", name="_MatchAs", extends=Pattern)] +#[pyclass(module="rustpython_ast.ranged", name="_MatchAs", extends=Pattern, frozen)] #[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) @@ -4861,6 +4853,14 @@ impl ToPyo3Wrapper for crate::ranged::PatternMatchAs { } } +impl PatternMatchAs { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl PatternMatchAs { #[getter] @@ -4876,18 +4876,10 @@ impl PatternMatchAs { } } -#[pyclass(module="rustpython_ast.ranged", name="_MatchOr", extends=Pattern)] +#[pyclass(module="rustpython_ast.ranged", name="_MatchOr", extends=Pattern, frozen)] #[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) @@ -4910,6 +4902,14 @@ impl ToPyo3Wrapper for crate::ranged::PatternMatchOr { } } +impl PatternMatchOr { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl PatternMatchOr { #[getter] @@ -4919,18 +4919,10 @@ impl PatternMatchOr { } } -#[pyclass(module="rustpython_ast.ranged", name="_type_ignore", extends=super::AST, subclass)] +#[pyclass(module="rustpython_ast.ranged", name="_type_ignore", extends=super::AST, frozen, 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 @@ -4951,6 +4943,14 @@ impl ToPyObject for TypeIgnore { } } +impl TypeIgnore { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + impl ToPyo3Wrapper for crate::ranged::TypeIgnore { #[inline] fn to_pyo3_wrapper(&'static self, py: Python) -> PyResult> { @@ -4960,18 +4960,10 @@ impl ToPyo3Wrapper for crate::ranged::TypeIgnore { } } -#[pyclass(module="rustpython_ast.ranged", name="_TypeIgnore", extends=TypeIgnore)] +#[pyclass(module="rustpython_ast.ranged", name="_TypeIgnore", extends=TypeIgnore, frozen)] #[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) @@ -4994,6 +4986,14 @@ impl ToPyo3Wrapper for crate::ranged::TypeIgnoreTypeIgnore { } } +impl TypeIgnoreTypeIgnore { + #[inline] + pub fn py_type_cell() -> &'static OnceCell> { + static PY_TYPE: OnceCell> = OnceCell::new(); + &PY_TYPE + } +} + #[pymethods] impl TypeIgnoreTypeIgnore { #[getter] diff --git a/ast/src/pyo3.rs b/ast/src/pyo3.rs index 07ab136..3828a28 100644 --- a/ast/src/pyo3.rs +++ b/ast/src/pyo3.rs @@ -1,7 +1,7 @@ use crate::Node; use num_complex::Complex64; -use pyo3::prelude::*; -use pyo3::types::{PyBytes, PyList, PyTuple}; +use pyo3::{intern, prelude::*}; +use pyo3::types::{PyBytes, PyList, PyString, PyTuple}; pub trait ToPyo3Ast { fn to_pyo3_ast(&self, py: Python) -> PyResult>;