From 64f10ec167d2f6af640c1625ee03a9d4a33e2365 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sun, 7 Apr 2024 02:52:29 +0900 Subject: [PATCH] Split repository from RustPython/Parser --- .gitignore | 73 + Cargo.toml | 29 + LICENSE | 21 + pyproject.toml | 15 + rustpython_ast/__init__.py | 3 + src/gen/to_py_ast.rs | 5100 ++++++++++++++++++++++++++++++++++++ src/gen/wrapper_located.rs | 4630 ++++++++++++++++++++++++++++++++ src/gen/wrapper_ranged.rs | 4334 ++++++++++++++++++++++++++++++ src/lib.rs | 49 + src/py_ast.rs | 219 ++ src/wrapper.rs | 153 ++ test_ast.py | 56 + 12 files changed, 14682 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 LICENSE create mode 100644 pyproject.toml create mode 100644 rustpython_ast/__init__.py create mode 100644 src/gen/to_py_ast.rs create mode 100644 src/gen/wrapper_located.rs create mode 100644 src/gen/wrapper_ranged.rs create mode 100644 src/lib.rs create mode 100644 src/py_ast.rs create mode 100644 src/wrapper.rs create mode 100644 test_ast.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..86afa93 --- /dev/null +++ b/.gitignore @@ -0,0 +1,73 @@ +Cargo.lock +/target + +# Byte-compiled / optimized / DLL files +__pycache__/ +.pytest_cache/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +.venv/ +env/ +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +include/ +man/ +venv/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt +pip-selfcheck.json + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Django stuff: +*.log +*.pot + +.DS_Store + +# Sphinx documentation +docs/_build/ + +# PyCharm +.idea/ + +# VSCode +.vscode/ + +# Pyenv +.python-version diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..782fd53 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "rustpython-ast-pyo3" +version = "0.0.1" +authors = ["Jeong, Yunwon"] +rust-version = "1.72.1" +edition = "2021" +description = "rustpython-ast PyO3 bindings" +repository = "https://github.com/RustPython/rustpython-ast-pyo3" +license = "MIT" + +[features] +abi3 = ["pyo3/abi3-py37"] +# This feature is experimental +# It reimplements AST types, but currently both slower than python AST types and limited to use in other API +wrapper = [] + +[lib] +name = "rustpython_ast" +crate-type = ["cdylib"] + +[dependencies] +rustpython-ast = { version = "0.3.1", default-features = false, features = ["num-bigint", "location"] } +rustpython-parser = { workspace = "0.3.1", default-features = false, features = ["num-bigint"] } + +num-complex = "0.4.0" +num-traits = "0.2" +once_cell = "1.18.0" + +pyo3 = { version = "0.20", features = ["num-bigint", "num-complex"] } diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..daeceaf --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Jeong, Yunwon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f6e6dbc --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,15 @@ +[build-system] +requires = ["maturin>=0.15,<0.16"] +build-backend = "maturin" + +[project] +name = "rustpython_ast" +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Rust", + "Programming Language :: Python :: Implementation :: CPython", +] + +[tool.maturin] +# module-name = "_rustpython_ast" +features = ["pyo3/extension-module"] diff --git a/rustpython_ast/__init__.py b/rustpython_ast/__init__.py new file mode 100644 index 0000000..a013bb1 --- /dev/null +++ b/rustpython_ast/__init__.py @@ -0,0 +1,3 @@ +from rustpython_ast.rustpython_ast import parse + +__all__ = ["parse"] diff --git a/src/gen/to_py_ast.rs b/src/gen/to_py_ast.rs new file mode 100644 index 0000000..8c8ea3e --- /dev/null +++ b/src/gen/to_py_ast.rs @@ -0,0 +1,5100 @@ +// File automatically generated by ast/asdl_rs.py. + +impl PyNode for ast::Mod { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ModModule { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ModInteractive { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ModExpression { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ModFunctionType { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::Stmt { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtFunctionDef { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtAsyncFunctionDef { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtClassDef { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtReturn { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtDelete { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtAssign { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtTypeAlias { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtAugAssign { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtAnnAssign { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtFor { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtAsyncFor { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtWhile { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtIf { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtWith { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtAsyncWith { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtMatch { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtRaise { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtTry { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtTryStar { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtAssert { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtImport { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtImportFrom { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtGlobal { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtNonlocal { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtExpr { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtPass { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtBreak { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::StmtContinue { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::Expr { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprBoolOp { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprNamedExpr { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprBinOp { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprUnaryOp { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprLambda { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprIfExp { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprDict { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprSet { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprListComp { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprSetComp { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprDictComp { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprGeneratorExp { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprAwait { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprYield { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprYieldFrom { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprCompare { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprCall { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprFormattedValue { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprJoinedStr { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprConstant { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprAttribute { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprSubscript { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprStarred { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprName { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprList { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprTuple { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprSlice { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprContext { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprContextLoad { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprContextStore { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExprContextDel { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::BoolOp { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::BoolOpAnd { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::BoolOpOr { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::Operator { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::OperatorAdd { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::OperatorSub { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::OperatorMult { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::OperatorMatMult { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::OperatorDiv { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::OperatorMod { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::OperatorPow { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::OperatorLShift { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::OperatorRShift { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::OperatorBitOr { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::OperatorBitXor { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::OperatorBitAnd { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::OperatorFloorDiv { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::UnaryOp { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::UnaryOpInvert { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::UnaryOpNot { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::UnaryOpUAdd { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::UnaryOpUSub { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::CmpOp { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::CmpOpEq { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::CmpOpNotEq { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::CmpOpLt { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::CmpOpLtE { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::CmpOpGt { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::CmpOpGtE { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::CmpOpIs { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::CmpOpIsNot { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::CmpOpIn { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::CmpOpNotIn { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::Comprehension { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExceptHandler { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::ExceptHandlerExceptHandler { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::PythonArguments { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::Arg { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::Keyword { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::Alias { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::WithItem { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::MatchCase { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::Pattern { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::PatternMatchValue { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::PatternMatchSingleton { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::PatternMatchSequence { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::PatternMatchMapping { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::PatternMatchClass { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::PatternMatchStar { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::PatternMatchAs { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::PatternMatchOr { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::TypeIgnore { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::TypeIgnoreTypeIgnore { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::TypeParam { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::TypeParamTypeVar { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::TypeParamParamSpec { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl PyNode for ast::TypeParamTypeVarTuple { + #[inline] + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } +} + +impl ToPyAst for ast::ExprContext { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cell = match &self { + ast::ExprContext::Load => ast::ExprContextLoad::py_type_cache(), + ast::ExprContext::Store => ast::ExprContextStore::py_type_cache(), + ast::ExprContext::Del => ast::ExprContextDel::py_type_cache(), + }; + Ok(Py::::as_ref(&cell.get().unwrap().1, py)) + } +} + +impl ToPyAst for ast::BoolOp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cell = match &self { + ast::BoolOp::And => ast::BoolOpAnd::py_type_cache(), + ast::BoolOp::Or => ast::BoolOpOr::py_type_cache(), + }; + Ok(Py::::as_ref(&cell.get().unwrap().1, py)) + } +} + +impl ToPyAst for ast::Operator { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cell = match &self { + ast::Operator::Add => ast::OperatorAdd::py_type_cache(), + ast::Operator::Sub => ast::OperatorSub::py_type_cache(), + ast::Operator::Mult => ast::OperatorMult::py_type_cache(), + ast::Operator::MatMult => ast::OperatorMatMult::py_type_cache(), + ast::Operator::Div => ast::OperatorDiv::py_type_cache(), + ast::Operator::Mod => ast::OperatorMod::py_type_cache(), + ast::Operator::Pow => ast::OperatorPow::py_type_cache(), + ast::Operator::LShift => ast::OperatorLShift::py_type_cache(), + ast::Operator::RShift => ast::OperatorRShift::py_type_cache(), + ast::Operator::BitOr => ast::OperatorBitOr::py_type_cache(), + ast::Operator::BitXor => ast::OperatorBitXor::py_type_cache(), + ast::Operator::BitAnd => ast::OperatorBitAnd::py_type_cache(), + ast::Operator::FloorDiv => ast::OperatorFloorDiv::py_type_cache(), + }; + Ok(Py::::as_ref(&cell.get().unwrap().1, py)) + } +} + +impl ToPyAst for ast::UnaryOp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cell = match &self { + ast::UnaryOp::Invert => ast::UnaryOpInvert::py_type_cache(), + ast::UnaryOp::Not => ast::UnaryOpNot::py_type_cache(), + ast::UnaryOp::UAdd => ast::UnaryOpUAdd::py_type_cache(), + ast::UnaryOp::USub => ast::UnaryOpUSub::py_type_cache(), + }; + Ok(Py::::as_ref(&cell.get().unwrap().1, py)) + } +} + +impl ToPyAst for ast::CmpOp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cell = match &self { + ast::CmpOp::Eq => ast::CmpOpEq::py_type_cache(), + ast::CmpOp::NotEq => ast::CmpOpNotEq::py_type_cache(), + ast::CmpOp::Lt => ast::CmpOpLt::py_type_cache(), + ast::CmpOp::LtE => ast::CmpOpLtE::py_type_cache(), + ast::CmpOp::Gt => ast::CmpOpGt::py_type_cache(), + ast::CmpOp::GtE => ast::CmpOpGtE::py_type_cache(), + ast::CmpOp::Is => ast::CmpOpIs::py_type_cache(), + ast::CmpOp::IsNot => ast::CmpOpIsNot::py_type_cache(), + ast::CmpOp::In => ast::CmpOpIn::py_type_cache(), + ast::CmpOp::NotIn => ast::CmpOpNotIn::py_type_cache(), + }; + Ok(Py::::as_ref(&cell.get().unwrap().1, py)) + } +} + +impl ToPyAst for ast::Mod { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::Mod::Module(cons) => cons.to_py_ast(py)?, + ast::Mod::Interactive(cons) => cons.to_py_ast(py)?, + ast::Mod::Expression(cons) => cons.to_py_ast(py)?, + ast::Mod::FunctionType(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::ModModule { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + type_ignores, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((body.to_py_ast(py)?, type_ignores.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ModInteractive { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((body.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ModExpression { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((body.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ModFunctionType { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + argtypes, + returns, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((argtypes.to_py_ast(py)?, returns.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::Stmt { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::Stmt::FunctionDef(cons) => cons.to_py_ast(py)?, + ast::Stmt::AsyncFunctionDef(cons) => cons.to_py_ast(py)?, + ast::Stmt::ClassDef(cons) => cons.to_py_ast(py)?, + ast::Stmt::Return(cons) => cons.to_py_ast(py)?, + ast::Stmt::Delete(cons) => cons.to_py_ast(py)?, + ast::Stmt::Assign(cons) => cons.to_py_ast(py)?, + ast::Stmt::TypeAlias(cons) => cons.to_py_ast(py)?, + ast::Stmt::AugAssign(cons) => cons.to_py_ast(py)?, + ast::Stmt::AnnAssign(cons) => cons.to_py_ast(py)?, + ast::Stmt::For(cons) => cons.to_py_ast(py)?, + ast::Stmt::AsyncFor(cons) => cons.to_py_ast(py)?, + ast::Stmt::While(cons) => cons.to_py_ast(py)?, + ast::Stmt::If(cons) => cons.to_py_ast(py)?, + ast::Stmt::With(cons) => cons.to_py_ast(py)?, + ast::Stmt::AsyncWith(cons) => cons.to_py_ast(py)?, + ast::Stmt::Match(cons) => cons.to_py_ast(py)?, + ast::Stmt::Raise(cons) => cons.to_py_ast(py)?, + ast::Stmt::Try(cons) => cons.to_py_ast(py)?, + ast::Stmt::TryStar(cons) => cons.to_py_ast(py)?, + ast::Stmt::Assert(cons) => cons.to_py_ast(py)?, + ast::Stmt::Import(cons) => cons.to_py_ast(py)?, + ast::Stmt::ImportFrom(cons) => cons.to_py_ast(py)?, + ast::Stmt::Global(cons) => cons.to_py_ast(py)?, + ast::Stmt::Nonlocal(cons) => cons.to_py_ast(py)?, + ast::Stmt::Expr(cons) => cons.to_py_ast(py)?, + ast::Stmt::Pass(cons) => cons.to_py_ast(py)?, + ast::Stmt::Break(cons) => cons.to_py_ast(py)?, + ast::Stmt::Continue(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::StmtFunctionDef { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + args, + body, + decorator_list, + returns, + type_comment, + type_params, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + name.to_py_ast(py)?, + args.to_py_ast(py)?, + body.to_py_ast(py)?, + decorator_list.to_py_ast(py)?, + returns.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + type_params.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAsyncFunctionDef { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + args, + body, + decorator_list, + returns, + type_comment, + type_params, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + name.to_py_ast(py)?, + args.to_py_ast(py)?, + body.to_py_ast(py)?, + decorator_list.to_py_ast(py)?, + returns.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + type_params.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtClassDef { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + bases, + keywords, + body, + decorator_list, + type_params, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + name.to_py_ast(py)?, + bases.to_py_ast(py)?, + keywords.to_py_ast(py)?, + body.to_py_ast(py)?, + decorator_list.to_py_ast(py)?, + type_params.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtReturn { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtDelete { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + targets, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((targets.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAssign { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + targets, + value, + type_comment, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + targets.to_py_ast(py)?, + value.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtTypeAlias { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + type_params, + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + name.to_py_ast(py)?, + type_params.to_py_ast(py)?, + value.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAugAssign { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + op, + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + target.to_py_ast(py)?, + op.to_py_ast(py)?, + value.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAnnAssign { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + annotation, + value, + simple, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + target.to_py_ast(py)?, + annotation.to_py_ast(py)?, + value.to_py_ast(py)?, + simple.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtFor { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + iter, + body, + orelse, + type_comment, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + target.to_py_ast(py)?, + iter.to_py_ast(py)?, + body.to_py_ast(py)?, + orelse.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAsyncFor { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + iter, + body, + orelse, + type_comment, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + target.to_py_ast(py)?, + iter.to_py_ast(py)?, + body.to_py_ast(py)?, + orelse.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtWhile { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + body, + orelse, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + test.to_py_ast(py)?, + body.to_py_ast(py)?, + orelse.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtIf { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + body, + orelse, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + test.to_py_ast(py)?, + body.to_py_ast(py)?, + orelse.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtWith { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + items, + body, + type_comment, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + items.to_py_ast(py)?, + body.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAsyncWith { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + items, + body, + type_comment, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + items.to_py_ast(py)?, + body.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtMatch { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + subject, + cases, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((subject.to_py_ast(py)?, cases.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtRaise { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + exc, + cause, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((exc.to_py_ast(py)?, cause.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtTry { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + handlers, + orelse, + finalbody, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + body.to_py_ast(py)?, + handlers.to_py_ast(py)?, + orelse.to_py_ast(py)?, + finalbody.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtTryStar { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + handlers, + orelse, + finalbody, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + body.to_py_ast(py)?, + handlers.to_py_ast(py)?, + orelse.to_py_ast(py)?, + finalbody.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAssert { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + msg, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((test.to_py_ast(py)?, msg.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtImport { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + names, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((names.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtImportFrom { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + module, + names, + level, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + module.to_py_ast(py)?, + names.to_py_ast(py)?, + level.map_or_else(|| py.None(), |level| level.to_u32().to_object(py)), + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtGlobal { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + names, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((names.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtNonlocal { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + names, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((names.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtExpr { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtPass { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { range: _range } = self; + let instance = Py::::as_ref(&cache.0, py).call0()?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtBreak { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { range: _range } = self; + let instance = Py::::as_ref(&cache.0, py).call0()?; + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtContinue { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { range: _range } = self; + let instance = Py::::as_ref(&cache.0, py).call0()?; + + Ok(instance) + } +} + +impl ToPyAst for ast::Expr { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::Expr::BoolOp(cons) => cons.to_py_ast(py)?, + ast::Expr::NamedExpr(cons) => cons.to_py_ast(py)?, + ast::Expr::BinOp(cons) => cons.to_py_ast(py)?, + ast::Expr::UnaryOp(cons) => cons.to_py_ast(py)?, + ast::Expr::Lambda(cons) => cons.to_py_ast(py)?, + ast::Expr::IfExp(cons) => cons.to_py_ast(py)?, + ast::Expr::Dict(cons) => cons.to_py_ast(py)?, + ast::Expr::Set(cons) => cons.to_py_ast(py)?, + ast::Expr::ListComp(cons) => cons.to_py_ast(py)?, + ast::Expr::SetComp(cons) => cons.to_py_ast(py)?, + ast::Expr::DictComp(cons) => cons.to_py_ast(py)?, + ast::Expr::GeneratorExp(cons) => cons.to_py_ast(py)?, + ast::Expr::Await(cons) => cons.to_py_ast(py)?, + ast::Expr::Yield(cons) => cons.to_py_ast(py)?, + ast::Expr::YieldFrom(cons) => cons.to_py_ast(py)?, + ast::Expr::Compare(cons) => cons.to_py_ast(py)?, + ast::Expr::Call(cons) => cons.to_py_ast(py)?, + ast::Expr::FormattedValue(cons) => cons.to_py_ast(py)?, + ast::Expr::JoinedStr(cons) => cons.to_py_ast(py)?, + ast::Expr::Constant(cons) => cons.to_py_ast(py)?, + ast::Expr::Attribute(cons) => cons.to_py_ast(py)?, + ast::Expr::Subscript(cons) => cons.to_py_ast(py)?, + ast::Expr::Starred(cons) => cons.to_py_ast(py)?, + ast::Expr::Name(cons) => cons.to_py_ast(py)?, + ast::Expr::List(cons) => cons.to_py_ast(py)?, + ast::Expr::Tuple(cons) => cons.to_py_ast(py)?, + ast::Expr::Slice(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::ExprBoolOp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + op, + values, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((op.to_py_ast(py)?, values.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprNamedExpr { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((target.to_py_ast(py)?, value.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprBinOp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + left, + op, + right, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + left.to_py_ast(py)?, + op.to_py_ast(py)?, + right.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprUnaryOp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + op, + operand, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((op.to_py_ast(py)?, operand.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprLambda { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + args, + body, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((args.to_py_ast(py)?, body.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprIfExp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + body, + orelse, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + test.to_py_ast(py)?, + body.to_py_ast(py)?, + orelse.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprDict { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + keys, + values, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((keys.to_py_ast(py)?, values.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprSet { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elts, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((elts.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprListComp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elt, + generators, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((elt.to_py_ast(py)?, generators.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprSetComp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elt, + generators, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((elt.to_py_ast(py)?, generators.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprDictComp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + key, + value, + generators, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + key.to_py_ast(py)?, + value.to_py_ast(py)?, + generators.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprGeneratorExp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elt, + generators, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((elt.to_py_ast(py)?, generators.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprAwait { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprYield { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprYieldFrom { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprCompare { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + left, + ops, + comparators, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + left.to_py_ast(py)?, + ops.to_py_ast(py)?, + comparators.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprCall { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + func, + args, + keywords, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + func.to_py_ast(py)?, + args.to_py_ast(py)?, + keywords.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprFormattedValue { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + conversion, + format_spec, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + value.to_py_ast(py)?, + conversion.to_py_ast(py)?, + format_spec.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprJoinedStr { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + values, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((values.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprConstant { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + kind, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((constant_to_object(value, py), kind.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprAttribute { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + attr, + ctx, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + value.to_py_ast(py)?, + attr.to_py_ast(py)?, + ctx.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprSubscript { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + slice, + ctx, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + value.to_py_ast(py)?, + slice.to_py_ast(py)?, + ctx.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprStarred { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + ctx, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?, ctx.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprName { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + id, + ctx, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((id.to_py_ast(py)?, ctx.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprList { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elts, + ctx, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((elts.to_py_ast(py)?, ctx.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprTuple { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elts, + ctx, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((elts.to_py_ast(py)?, ctx.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprSlice { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + lower, + upper, + step, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + lower.to_py_ast(py)?, + upper.to_py_ast(py)?, + step.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::Comprehension { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + iter, + ifs, + is_async, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + target.to_py_ast(py)?, + iter.to_py_ast(py)?, + ifs.to_py_ast(py)?, + is_async.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExceptHandler { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::ExceptHandler::ExceptHandler(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::ExceptHandlerExceptHandler { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + type_, + name, + body, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + type_.to_py_ast(py)?, + name.to_py_ast(py)?, + body.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::PythonArguments { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + posonlyargs, + args, + vararg, + kwonlyargs, + kw_defaults, + kwarg, + defaults, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + posonlyargs.to_py_ast(py)?, + args.to_py_ast(py)?, + vararg.to_py_ast(py)?, + kwonlyargs.to_py_ast(py)?, + kw_defaults.to_py_ast(py)?, + kwarg.to_py_ast(py)?, + defaults.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::Arg { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + arg, + annotation, + type_comment, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + arg.to_py_ast(py)?, + annotation.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::Keyword { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + arg, + value, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((arg.to_py_ast(py)?, value.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::Alias { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + asname, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((name.to_py_ast(py)?, asname.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::WithItem { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + context_expr, + optional_vars, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((context_expr.to_py_ast(py)?, optional_vars.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::MatchCase { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + pattern, + guard, + body, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + pattern.to_py_ast(py)?, + guard.to_py_ast(py)?, + body.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::Pattern { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::Pattern::MatchValue(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchSingleton(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchSequence(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchMapping(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchClass(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchStar(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchAs(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchOr(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchValue { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchSingleton { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((constant_to_object(value, py),))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchSequence { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + patterns, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((patterns.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchMapping { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + keys, + patterns, + rest, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + keys.to_py_ast(py)?, + patterns.to_py_ast(py)?, + rest.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchClass { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + cls, + patterns, + kwd_attrs, + kwd_patterns, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + cls.to_py_ast(py)?, + patterns.to_py_ast(py)?, + kwd_attrs.to_py_ast(py)?, + kwd_patterns.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchStar { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((name.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchAs { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + pattern, + name, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((pattern.to_py_ast(py)?, name.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchOr { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + patterns, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((patterns.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::TypeIgnore { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::TypeIgnore::TypeIgnore(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::TypeIgnoreTypeIgnore { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + lineno, + tag, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((lineno.to_u32().to_object(py), tag.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::TypeParam { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::TypeParam::TypeVar(cons) => cons.to_py_ast(py)?, + ast::TypeParam::ParamSpec(cons) => cons.to_py_ast(py)?, + ast::TypeParam::TypeVarTuple(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::TypeParamTypeVar { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + bound, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((name.to_py_ast(py)?, bound.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::TypeParamParamSpec { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((name.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::TypeParamTypeVarTuple { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((name.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::Mod { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::Mod::Module(cons) => cons.to_py_ast(py)?, + ast::Mod::Interactive(cons) => cons.to_py_ast(py)?, + ast::Mod::Expression(cons) => cons.to_py_ast(py)?, + ast::Mod::FunctionType(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::ModModule { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + type_ignores, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((body.to_py_ast(py)?, type_ignores.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ModInteractive { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((body.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ModExpression { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((body.to_py_ast(py)?,))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ModFunctionType { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + argtypes, + returns, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((argtypes.to_py_ast(py)?, returns.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::Stmt { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::Stmt::FunctionDef(cons) => cons.to_py_ast(py)?, + ast::Stmt::AsyncFunctionDef(cons) => cons.to_py_ast(py)?, + ast::Stmt::ClassDef(cons) => cons.to_py_ast(py)?, + ast::Stmt::Return(cons) => cons.to_py_ast(py)?, + ast::Stmt::Delete(cons) => cons.to_py_ast(py)?, + ast::Stmt::Assign(cons) => cons.to_py_ast(py)?, + ast::Stmt::TypeAlias(cons) => cons.to_py_ast(py)?, + ast::Stmt::AugAssign(cons) => cons.to_py_ast(py)?, + ast::Stmt::AnnAssign(cons) => cons.to_py_ast(py)?, + ast::Stmt::For(cons) => cons.to_py_ast(py)?, + ast::Stmt::AsyncFor(cons) => cons.to_py_ast(py)?, + ast::Stmt::While(cons) => cons.to_py_ast(py)?, + ast::Stmt::If(cons) => cons.to_py_ast(py)?, + ast::Stmt::With(cons) => cons.to_py_ast(py)?, + ast::Stmt::AsyncWith(cons) => cons.to_py_ast(py)?, + ast::Stmt::Match(cons) => cons.to_py_ast(py)?, + ast::Stmt::Raise(cons) => cons.to_py_ast(py)?, + ast::Stmt::Try(cons) => cons.to_py_ast(py)?, + ast::Stmt::TryStar(cons) => cons.to_py_ast(py)?, + ast::Stmt::Assert(cons) => cons.to_py_ast(py)?, + ast::Stmt::Import(cons) => cons.to_py_ast(py)?, + ast::Stmt::ImportFrom(cons) => cons.to_py_ast(py)?, + ast::Stmt::Global(cons) => cons.to_py_ast(py)?, + ast::Stmt::Nonlocal(cons) => cons.to_py_ast(py)?, + ast::Stmt::Expr(cons) => cons.to_py_ast(py)?, + ast::Stmt::Pass(cons) => cons.to_py_ast(py)?, + ast::Stmt::Break(cons) => cons.to_py_ast(py)?, + ast::Stmt::Continue(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::StmtFunctionDef { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + args, + body, + decorator_list, + returns, + type_comment, + type_params, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + name.to_py_ast(py)?, + args.to_py_ast(py)?, + body.to_py_ast(py)?, + decorator_list.to_py_ast(py)?, + returns.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + type_params.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAsyncFunctionDef { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + args, + body, + decorator_list, + returns, + type_comment, + type_params, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + name.to_py_ast(py)?, + args.to_py_ast(py)?, + body.to_py_ast(py)?, + decorator_list.to_py_ast(py)?, + returns.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + type_params.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtClassDef { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + bases, + keywords, + body, + decorator_list, + type_params, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + name.to_py_ast(py)?, + bases.to_py_ast(py)?, + keywords.to_py_ast(py)?, + body.to_py_ast(py)?, + decorator_list.to_py_ast(py)?, + type_params.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtReturn { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtDelete { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + targets, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((targets.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAssign { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + targets, + value, + type_comment, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + targets.to_py_ast(py)?, + value.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtTypeAlias { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + type_params, + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + name.to_py_ast(py)?, + type_params.to_py_ast(py)?, + value.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAugAssign { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + op, + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + target.to_py_ast(py)?, + op.to_py_ast(py)?, + value.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAnnAssign { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + annotation, + value, + simple, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + target.to_py_ast(py)?, + annotation.to_py_ast(py)?, + value.to_py_ast(py)?, + simple.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtFor { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + iter, + body, + orelse, + type_comment, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + target.to_py_ast(py)?, + iter.to_py_ast(py)?, + body.to_py_ast(py)?, + orelse.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAsyncFor { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + iter, + body, + orelse, + type_comment, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + target.to_py_ast(py)?, + iter.to_py_ast(py)?, + body.to_py_ast(py)?, + orelse.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtWhile { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + body, + orelse, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + test.to_py_ast(py)?, + body.to_py_ast(py)?, + orelse.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtIf { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + body, + orelse, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + test.to_py_ast(py)?, + body.to_py_ast(py)?, + orelse.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtWith { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + items, + body, + type_comment, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + items.to_py_ast(py)?, + body.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAsyncWith { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + items, + body, + type_comment, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + items.to_py_ast(py)?, + body.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtMatch { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + subject, + cases, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((subject.to_py_ast(py)?, cases.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtRaise { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + exc, + cause, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((exc.to_py_ast(py)?, cause.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtTry { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + handlers, + orelse, + finalbody, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + body.to_py_ast(py)?, + handlers.to_py_ast(py)?, + orelse.to_py_ast(py)?, + finalbody.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtTryStar { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + body, + handlers, + orelse, + finalbody, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + body.to_py_ast(py)?, + handlers.to_py_ast(py)?, + orelse.to_py_ast(py)?, + finalbody.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtAssert { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + msg, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((test.to_py_ast(py)?, msg.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtImport { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + names, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((names.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtImportFrom { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + module, + names, + level, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + module.to_py_ast(py)?, + names.to_py_ast(py)?, + level.map_or_else(|| py.None(), |level| level.to_u32().to_object(py)), + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtGlobal { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + names, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((names.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtNonlocal { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + names, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((names.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtExpr { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtPass { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { range: _range } = self; + let instance = Py::::as_ref(&cache.0, py).call0()?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtBreak { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { range: _range } = self; + let instance = Py::::as_ref(&cache.0, py).call0()?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::StmtContinue { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { range: _range } = self; + let instance = Py::::as_ref(&cache.0, py).call0()?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::Expr { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::Expr::BoolOp(cons) => cons.to_py_ast(py)?, + ast::Expr::NamedExpr(cons) => cons.to_py_ast(py)?, + ast::Expr::BinOp(cons) => cons.to_py_ast(py)?, + ast::Expr::UnaryOp(cons) => cons.to_py_ast(py)?, + ast::Expr::Lambda(cons) => cons.to_py_ast(py)?, + ast::Expr::IfExp(cons) => cons.to_py_ast(py)?, + ast::Expr::Dict(cons) => cons.to_py_ast(py)?, + ast::Expr::Set(cons) => cons.to_py_ast(py)?, + ast::Expr::ListComp(cons) => cons.to_py_ast(py)?, + ast::Expr::SetComp(cons) => cons.to_py_ast(py)?, + ast::Expr::DictComp(cons) => cons.to_py_ast(py)?, + ast::Expr::GeneratorExp(cons) => cons.to_py_ast(py)?, + ast::Expr::Await(cons) => cons.to_py_ast(py)?, + ast::Expr::Yield(cons) => cons.to_py_ast(py)?, + ast::Expr::YieldFrom(cons) => cons.to_py_ast(py)?, + ast::Expr::Compare(cons) => cons.to_py_ast(py)?, + ast::Expr::Call(cons) => cons.to_py_ast(py)?, + ast::Expr::FormattedValue(cons) => cons.to_py_ast(py)?, + ast::Expr::JoinedStr(cons) => cons.to_py_ast(py)?, + ast::Expr::Constant(cons) => cons.to_py_ast(py)?, + ast::Expr::Attribute(cons) => cons.to_py_ast(py)?, + ast::Expr::Subscript(cons) => cons.to_py_ast(py)?, + ast::Expr::Starred(cons) => cons.to_py_ast(py)?, + ast::Expr::Name(cons) => cons.to_py_ast(py)?, + ast::Expr::List(cons) => cons.to_py_ast(py)?, + ast::Expr::Tuple(cons) => cons.to_py_ast(py)?, + ast::Expr::Slice(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::ExprBoolOp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + op, + values, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((op.to_py_ast(py)?, values.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprNamedExpr { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((target.to_py_ast(py)?, value.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprBinOp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + left, + op, + right, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + left.to_py_ast(py)?, + op.to_py_ast(py)?, + right.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprUnaryOp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + op, + operand, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((op.to_py_ast(py)?, operand.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprLambda { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + args, + body, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((args.to_py_ast(py)?, body.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprIfExp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + test, + body, + orelse, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + test.to_py_ast(py)?, + body.to_py_ast(py)?, + orelse.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprDict { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + keys, + values, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((keys.to_py_ast(py)?, values.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprSet { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elts, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((elts.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprListComp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elt, + generators, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((elt.to_py_ast(py)?, generators.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprSetComp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elt, + generators, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((elt.to_py_ast(py)?, generators.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprDictComp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + key, + value, + generators, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + key.to_py_ast(py)?, + value.to_py_ast(py)?, + generators.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprGeneratorExp { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elt, + generators, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((elt.to_py_ast(py)?, generators.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprAwait { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprYield { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprYieldFrom { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprCompare { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + left, + ops, + comparators, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + left.to_py_ast(py)?, + ops.to_py_ast(py)?, + comparators.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprCall { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + func, + args, + keywords, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + func.to_py_ast(py)?, + args.to_py_ast(py)?, + keywords.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprFormattedValue { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + conversion, + format_spec, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + value.to_py_ast(py)?, + conversion.to_py_ast(py)?, + format_spec.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprJoinedStr { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + values, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((values.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprConstant { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + kind, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((constant_to_object(value, py), kind.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprAttribute { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + attr, + ctx, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + value.to_py_ast(py)?, + attr.to_py_ast(py)?, + ctx.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprSubscript { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + slice, + ctx, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + value.to_py_ast(py)?, + slice.to_py_ast(py)?, + ctx.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprStarred { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + ctx, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?, ctx.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprName { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + id, + ctx, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((id.to_py_ast(py)?, ctx.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprList { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elts, + ctx, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((elts.to_py_ast(py)?, ctx.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprTuple { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + elts, + ctx, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((elts.to_py_ast(py)?, ctx.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::ExprSlice { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + lower, + upper, + step, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + lower.to_py_ast(py)?, + upper.to_py_ast(py)?, + step.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::Comprehension { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + target, + iter, + ifs, + is_async, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + target.to_py_ast(py)?, + iter.to_py_ast(py)?, + ifs.to_py_ast(py)?, + is_async.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::ExceptHandler { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::ExceptHandler::ExceptHandler(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::ExceptHandlerExceptHandler { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + type_, + name, + body, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + type_.to_py_ast(py)?, + name.to_py_ast(py)?, + body.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::PythonArguments { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + posonlyargs, + args, + vararg, + kwonlyargs, + kw_defaults, + kwarg, + defaults, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + posonlyargs.to_py_ast(py)?, + args.to_py_ast(py)?, + vararg.to_py_ast(py)?, + kwonlyargs.to_py_ast(py)?, + kw_defaults.to_py_ast(py)?, + kwarg.to_py_ast(py)?, + defaults.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::Arg { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + arg, + annotation, + type_comment, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + arg.to_py_ast(py)?, + annotation.to_py_ast(py)?, + type_comment.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::Keyword { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + arg, + value, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((arg.to_py_ast(py)?, value.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::Alias { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + asname, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((name.to_py_ast(py)?, asname.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::WithItem { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + context_expr, + optional_vars, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((context_expr.to_py_ast(py)?, optional_vars.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::MatchCase { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + pattern, + guard, + body, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + pattern.to_py_ast(py)?, + guard.to_py_ast(py)?, + body.to_py_ast(py)?, + ))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::Pattern { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::Pattern::MatchValue(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchSingleton(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchSequence(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchMapping(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchClass(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchStar(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchAs(cons) => cons.to_py_ast(py)?, + ast::Pattern::MatchOr(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchValue { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((value.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchSingleton { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + value, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((constant_to_object(value, py),))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchSequence { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + patterns, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((patterns.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchMapping { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + keys, + patterns, + rest, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + keys.to_py_ast(py)?, + patterns.to_py_ast(py)?, + rest.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchClass { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + cls, + patterns, + kwd_attrs, + kwd_patterns, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1(( + cls.to_py_ast(py)?, + patterns.to_py_ast(py)?, + kwd_attrs.to_py_ast(py)?, + kwd_patterns.to_py_ast(py)?, + ))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchStar { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((name.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchAs { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + pattern, + name, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((pattern.to_py_ast(py)?, name.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::PatternMatchOr { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + patterns, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((patterns.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::TypeIgnore { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::TypeIgnore::TypeIgnore(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::TypeIgnoreTypeIgnore { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + lineno, + tag, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py) + .call1((lineno.to_u32().to_object(py), tag.to_py_ast(py)?))?; + + Ok(instance) + } +} + +impl ToPyAst for ast::TypeParam { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let instance = match &self { + ast::TypeParam::TypeVar(cons) => cons.to_py_ast(py)?, + ast::TypeParam::ParamSpec(cons) => cons.to_py_ast(py)?, + ast::TypeParam::TypeVarTuple(cons) => cons.to_py_ast(py)?, + }; + Ok(instance) + } +} + +impl ToPyAst for ast::TypeParamTypeVar { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + bound, + range: _range, + } = self; + + let instance = + Py::::as_ref(&cache.0, py).call1((name.to_py_ast(py)?, bound.to_py_ast(py)?))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::TypeParamParamSpec { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((name.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +impl ToPyAst for ast::TypeParamTypeVarTuple { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let cache = Self::py_type_cache().get().unwrap(); + + let Self { + name, + range: _range, + } = self; + + let instance = Py::::as_ref(&cache.0, py).call1((name.to_py_ast(py)?,))?; + + let cache = ast_cache(); + instance.setattr(cache.lineno.as_ref(py), _range.start.row.get())?; + instance.setattr(cache.col_offset.as_ref(py), _range.start.column.get())?; + if let Some(end) = _range.end { + instance.setattr(cache.end_lineno.as_ref(py), end.row.get())?; + instance.setattr(cache.end_col_offset.as_ref(py), end.column.get())?; + } + + Ok(instance) + } +} + +fn init_types(py: Python) -> PyResult<()> { + let ast_module = PyModule::import(py, "_ast")?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + cache_py_type::(ast_module)?; + Ok(()) +} diff --git a/src/gen/wrapper_located.rs b/src/gen/wrapper_located.rs new file mode 100644 index 0000000..b6d56dd --- /dev/null +++ b/src/gen/wrapper_located.rs @@ -0,0 +1,4630 @@ +// File automatically generated by ast/asdl_rs.py. + +#[pyclass(module="rustpython_ast.located", name="_mod", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Mod; + +impl From<&'static ast::Mod> for Mod { + fn from(_node: &'static ast::Mod) -> Self { + Mod + } +} + +#[pymethods] +impl Mod { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for Mod { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Mod { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::Module(cons) => cons.to_py_wrapper(py), + Self::Interactive(cons) => cons.to_py_wrapper(py), + Self::Expression(cons) => cons.to_py_wrapper(py), + Self::FunctionType(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.located", name="_Module", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModModule(pub &'static ast::ModModule); + +impl From<&'static ast::ModModule> for ModModule { + fn from(node: &'static ast::ModModule) -> Self { + ModModule(node) + } +} + +impl ToPyObject for ModModule { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ModModule { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModModule(self).to_object(py)) + } +} + +#[pymethods] +impl ModModule { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_ignores(&self, py: Python) -> PyResult { + self.0.type_ignores.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Interactive", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModInteractive(pub &'static ast::ModInteractive); + +impl From<&'static ast::ModInteractive> for ModInteractive { + fn from(node: &'static ast::ModInteractive) -> Self { + ModInteractive(node) + } +} + +impl ToPyObject for ModInteractive { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ModInteractive { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModInteractive(self).to_object(py)) + } +} + +#[pymethods] +impl ModInteractive { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Expression", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModExpression(pub &'static ast::ModExpression); + +impl From<&'static ast::ModExpression> for ModExpression { + fn from(node: &'static ast::ModExpression) -> Self { + ModExpression(node) + } +} + +impl ToPyObject for ModExpression { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ModExpression { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModExpression(self).to_object(py)) + } +} + +#[pymethods] +impl ModExpression { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_FunctionType", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModFunctionType(pub &'static ast::ModFunctionType); + +impl From<&'static ast::ModFunctionType> for ModFunctionType { + fn from(node: &'static ast::ModFunctionType) -> Self { + ModFunctionType(node) + } +} + +impl ToPyObject for ModFunctionType { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ModFunctionType { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModFunctionType(self).to_object(py)) + } +} + +#[pymethods] +impl ModFunctionType { + #[getter] + #[inline] + fn get_argtypes(&self, py: Python) -> PyResult { + self.0.argtypes.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_returns(&self, py: Python) -> PyResult { + self.0.returns.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_stmt", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Stmt; + +impl From<&'static ast::Stmt> for Stmt { + fn from(_node: &'static ast::Stmt) -> Self { + Stmt + } +} + +#[pymethods] +impl Stmt { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for Stmt { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Stmt { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::FunctionDef(cons) => cons.to_py_wrapper(py), + Self::AsyncFunctionDef(cons) => cons.to_py_wrapper(py), + Self::ClassDef(cons) => cons.to_py_wrapper(py), + Self::Return(cons) => cons.to_py_wrapper(py), + Self::Delete(cons) => cons.to_py_wrapper(py), + Self::Assign(cons) => cons.to_py_wrapper(py), + Self::TypeAlias(cons) => cons.to_py_wrapper(py), + Self::AugAssign(cons) => cons.to_py_wrapper(py), + Self::AnnAssign(cons) => cons.to_py_wrapper(py), + Self::For(cons) => cons.to_py_wrapper(py), + Self::AsyncFor(cons) => cons.to_py_wrapper(py), + Self::While(cons) => cons.to_py_wrapper(py), + Self::If(cons) => cons.to_py_wrapper(py), + Self::With(cons) => cons.to_py_wrapper(py), + Self::AsyncWith(cons) => cons.to_py_wrapper(py), + Self::Match(cons) => cons.to_py_wrapper(py), + Self::Raise(cons) => cons.to_py_wrapper(py), + Self::Try(cons) => cons.to_py_wrapper(py), + Self::TryStar(cons) => cons.to_py_wrapper(py), + Self::Assert(cons) => cons.to_py_wrapper(py), + Self::Import(cons) => cons.to_py_wrapper(py), + Self::ImportFrom(cons) => cons.to_py_wrapper(py), + Self::Global(cons) => cons.to_py_wrapper(py), + Self::Nonlocal(cons) => cons.to_py_wrapper(py), + Self::Expr(cons) => cons.to_py_wrapper(py), + Self::Pass(cons) => cons.to_py_wrapper(py), + Self::Break(cons) => cons.to_py_wrapper(py), + Self::Continue(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.located", name="_FunctionDef", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtFunctionDef(pub &'static ast::StmtFunctionDef); + +impl From<&'static ast::StmtFunctionDef> for StmtFunctionDef { + fn from(node: &'static ast::StmtFunctionDef) -> Self { + StmtFunctionDef(node) + } +} + +impl ToPyObject for StmtFunctionDef { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtFunctionDef { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtFunctionDef(self).to_object(py)) + } +} + +#[pymethods] +impl StmtFunctionDef { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_decorator_list(&self, py: Python) -> PyResult { + self.0.decorator_list.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_returns(&self, py: Python) -> PyResult { + self.0.returns.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_params(&self, py: Python) -> PyResult { + self.0.type_params.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_AsyncFunctionDef", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAsyncFunctionDef(pub &'static ast::StmtAsyncFunctionDef); + +impl From<&'static ast::StmtAsyncFunctionDef> for StmtAsyncFunctionDef { + fn from(node: &'static ast::StmtAsyncFunctionDef) -> Self { + StmtAsyncFunctionDef(node) + } +} + +impl ToPyObject for StmtAsyncFunctionDef { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAsyncFunctionDef { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAsyncFunctionDef(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAsyncFunctionDef { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_decorator_list(&self, py: Python) -> PyResult { + self.0.decorator_list.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_returns(&self, py: Python) -> PyResult { + self.0.returns.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_params(&self, py: Python) -> PyResult { + self.0.type_params.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_ClassDef", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtClassDef(pub &'static ast::StmtClassDef); + +impl From<&'static ast::StmtClassDef> for StmtClassDef { + fn from(node: &'static ast::StmtClassDef) -> Self { + StmtClassDef(node) + } +} + +impl ToPyObject for StmtClassDef { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtClassDef { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtClassDef(self).to_object(py)) + } +} + +#[pymethods] +impl StmtClassDef { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_bases(&self, py: Python) -> PyResult { + self.0.bases.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_keywords(&self, py: Python) -> PyResult { + self.0.keywords.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_decorator_list(&self, py: Python) -> PyResult { + self.0.decorator_list.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_params(&self, py: Python) -> PyResult { + self.0.type_params.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Return", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtReturn(pub &'static ast::StmtReturn); + +impl From<&'static ast::StmtReturn> for StmtReturn { + fn from(node: &'static ast::StmtReturn) -> Self { + StmtReturn(node) + } +} + +impl ToPyObject for StmtReturn { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtReturn { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtReturn(self).to_object(py)) + } +} + +#[pymethods] +impl StmtReturn { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Delete", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtDelete(pub &'static ast::StmtDelete); + +impl From<&'static ast::StmtDelete> for StmtDelete { + fn from(node: &'static ast::StmtDelete) -> Self { + StmtDelete(node) + } +} + +impl ToPyObject for StmtDelete { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtDelete { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtDelete(self).to_object(py)) + } +} + +#[pymethods] +impl StmtDelete { + #[getter] + #[inline] + fn get_targets(&self, py: Python) -> PyResult { + self.0.targets.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Assign", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAssign(pub &'static ast::StmtAssign); + +impl From<&'static ast::StmtAssign> for StmtAssign { + fn from(node: &'static ast::StmtAssign) -> Self { + StmtAssign(node) + } +} + +impl ToPyObject for StmtAssign { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAssign { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAssign(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAssign { + #[getter] + #[inline] + fn get_targets(&self, py: Python) -> PyResult { + self.0.targets.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_TypeAlias", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtTypeAlias(pub &'static ast::StmtTypeAlias); + +impl From<&'static ast::StmtTypeAlias> for StmtTypeAlias { + fn from(node: &'static ast::StmtTypeAlias) -> Self { + StmtTypeAlias(node) + } +} + +impl ToPyObject for StmtTypeAlias { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtTypeAlias { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtTypeAlias(self).to_object(py)) + } +} + +#[pymethods] +impl StmtTypeAlias { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_params(&self, py: Python) -> PyResult { + self.0.type_params.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_AugAssign", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAugAssign(pub &'static ast::StmtAugAssign); + +impl From<&'static ast::StmtAugAssign> for StmtAugAssign { + fn from(node: &'static ast::StmtAugAssign) -> Self { + StmtAugAssign(node) + } +} + +impl ToPyObject for StmtAugAssign { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAugAssign { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAugAssign(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAugAssign { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_AnnAssign", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAnnAssign(pub &'static ast::StmtAnnAssign); + +impl From<&'static ast::StmtAnnAssign> for StmtAnnAssign { + fn from(node: &'static ast::StmtAnnAssign) -> Self { + StmtAnnAssign(node) + } +} + +impl ToPyObject for StmtAnnAssign { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAnnAssign { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAnnAssign(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAnnAssign { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_annotation(&self, py: Python) -> PyResult { + self.0.annotation.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_simple(&self, py: Python) -> PyResult { + self.0.simple.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_For", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtFor(pub &'static ast::StmtFor); + +impl From<&'static ast::StmtFor> for StmtFor { + fn from(node: &'static ast::StmtFor) -> Self { + StmtFor(node) + } +} + +impl ToPyObject for StmtFor { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtFor { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtFor(self).to_object(py)) + } +} + +#[pymethods] +impl StmtFor { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_iter(&self, py: Python) -> PyResult { + self.0.iter.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_AsyncFor", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAsyncFor(pub &'static ast::StmtAsyncFor); + +impl From<&'static ast::StmtAsyncFor> for StmtAsyncFor { + fn from(node: &'static ast::StmtAsyncFor) -> Self { + StmtAsyncFor(node) + } +} + +impl ToPyObject for StmtAsyncFor { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAsyncFor { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAsyncFor(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAsyncFor { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_iter(&self, py: Python) -> PyResult { + self.0.iter.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_While", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtWhile(pub &'static ast::StmtWhile); + +impl From<&'static ast::StmtWhile> for StmtWhile { + fn from(node: &'static ast::StmtWhile) -> Self { + StmtWhile(node) + } +} + +impl ToPyObject for StmtWhile { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtWhile { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtWhile(self).to_object(py)) + } +} + +#[pymethods] +impl StmtWhile { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_If", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtIf(pub &'static ast::StmtIf); + +impl From<&'static ast::StmtIf> for StmtIf { + fn from(node: &'static ast::StmtIf) -> Self { + StmtIf(node) + } +} + +impl ToPyObject for StmtIf { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtIf { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtIf(self).to_object(py)) + } +} + +#[pymethods] +impl StmtIf { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_With", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtWith(pub &'static ast::StmtWith); + +impl From<&'static ast::StmtWith> for StmtWith { + fn from(node: &'static ast::StmtWith) -> Self { + StmtWith(node) + } +} + +impl ToPyObject for StmtWith { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtWith { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtWith(self).to_object(py)) + } +} + +#[pymethods] +impl StmtWith { + #[getter] + #[inline] + fn get_items(&self, py: Python) -> PyResult { + self.0.items.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_AsyncWith", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAsyncWith(pub &'static ast::StmtAsyncWith); + +impl From<&'static ast::StmtAsyncWith> for StmtAsyncWith { + fn from(node: &'static ast::StmtAsyncWith) -> Self { + StmtAsyncWith(node) + } +} + +impl ToPyObject for StmtAsyncWith { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAsyncWith { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAsyncWith(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAsyncWith { + #[getter] + #[inline] + fn get_items(&self, py: Python) -> PyResult { + self.0.items.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Match", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtMatch(pub &'static ast::StmtMatch); + +impl From<&'static ast::StmtMatch> for StmtMatch { + fn from(node: &'static ast::StmtMatch) -> Self { + StmtMatch(node) + } +} + +impl ToPyObject for StmtMatch { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtMatch { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtMatch(self).to_object(py)) + } +} + +#[pymethods] +impl StmtMatch { + #[getter] + #[inline] + fn get_subject(&self, py: Python) -> PyResult { + self.0.subject.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_cases(&self, py: Python) -> PyResult { + self.0.cases.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Raise", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtRaise(pub &'static ast::StmtRaise); + +impl From<&'static ast::StmtRaise> for StmtRaise { + fn from(node: &'static ast::StmtRaise) -> Self { + StmtRaise(node) + } +} + +impl ToPyObject for StmtRaise { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtRaise { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtRaise(self).to_object(py)) + } +} + +#[pymethods] +impl StmtRaise { + #[getter] + #[inline] + fn get_exc(&self, py: Python) -> PyResult { + self.0.exc.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_cause(&self, py: Python) -> PyResult { + self.0.cause.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Try", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtTry(pub &'static ast::StmtTry); + +impl From<&'static ast::StmtTry> for StmtTry { + fn from(node: &'static ast::StmtTry) -> Self { + StmtTry(node) + } +} + +impl ToPyObject for StmtTry { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtTry { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtTry(self).to_object(py)) + } +} + +#[pymethods] +impl StmtTry { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_handlers(&self, py: Python) -> PyResult { + self.0.handlers.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_finalbody(&self, py: Python) -> PyResult { + self.0.finalbody.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_TryStar", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtTryStar(pub &'static ast::StmtTryStar); + +impl From<&'static ast::StmtTryStar> for StmtTryStar { + fn from(node: &'static ast::StmtTryStar) -> Self { + StmtTryStar(node) + } +} + +impl ToPyObject for StmtTryStar { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtTryStar { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtTryStar(self).to_object(py)) + } +} + +#[pymethods] +impl StmtTryStar { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_handlers(&self, py: Python) -> PyResult { + self.0.handlers.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_finalbody(&self, py: Python) -> PyResult { + self.0.finalbody.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Assert", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAssert(pub &'static ast::StmtAssert); + +impl From<&'static ast::StmtAssert> for StmtAssert { + fn from(node: &'static ast::StmtAssert) -> Self { + StmtAssert(node) + } +} + +impl ToPyObject for StmtAssert { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAssert { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAssert(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAssert { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_msg(&self, py: Python) -> PyResult { + self.0.msg.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Import", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtImport(pub &'static ast::StmtImport); + +impl From<&'static ast::StmtImport> for StmtImport { + fn from(node: &'static ast::StmtImport) -> Self { + StmtImport(node) + } +} + +impl ToPyObject for StmtImport { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtImport { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtImport(self).to_object(py)) + } +} + +#[pymethods] +impl StmtImport { + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_ImportFrom", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtImportFrom(pub &'static ast::StmtImportFrom); + +impl From<&'static ast::StmtImportFrom> for StmtImportFrom { + fn from(node: &'static ast::StmtImportFrom) -> Self { + StmtImportFrom(node) + } +} + +impl ToPyObject for StmtImportFrom { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtImportFrom { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtImportFrom(self).to_object(py)) + } +} + +#[pymethods] +impl StmtImportFrom { + #[getter] + #[inline] + fn get_module(&self, py: Python) -> PyResult { + self.0.module.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_level(&self, py: Python) -> PyResult { + self.0.level.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Global", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtGlobal(pub &'static ast::StmtGlobal); + +impl From<&'static ast::StmtGlobal> for StmtGlobal { + fn from(node: &'static ast::StmtGlobal) -> Self { + StmtGlobal(node) + } +} + +impl ToPyObject for StmtGlobal { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtGlobal { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtGlobal(self).to_object(py)) + } +} + +#[pymethods] +impl StmtGlobal { + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Nonlocal", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtNonlocal(pub &'static ast::StmtNonlocal); + +impl From<&'static ast::StmtNonlocal> for StmtNonlocal { + fn from(node: &'static ast::StmtNonlocal) -> Self { + StmtNonlocal(node) + } +} + +impl ToPyObject for StmtNonlocal { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtNonlocal { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtNonlocal(self).to_object(py)) + } +} + +#[pymethods] +impl StmtNonlocal { + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Expr", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtExpr(pub &'static ast::StmtExpr); + +impl From<&'static ast::StmtExpr> for StmtExpr { + fn from(node: &'static ast::StmtExpr) -> Self { + StmtExpr(node) + } +} + +impl ToPyObject for StmtExpr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtExpr { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtExpr(self).to_object(py)) + } +} + +#[pymethods] +impl StmtExpr { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Pass", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtPass(pub &'static ast::StmtPass); + +impl From<&'static ast::StmtPass> for StmtPass { + fn from(node: &'static ast::StmtPass) -> Self { + StmtPass(node) + } +} + +impl ToPyObject for StmtPass { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtPass { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtPass(self).to_object(py)) + } +} + +#[pymethods] +impl StmtPass {} + +#[pyclass(module="rustpython_ast.located", name="_Break", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtBreak(pub &'static ast::StmtBreak); + +impl From<&'static ast::StmtBreak> for StmtBreak { + fn from(node: &'static ast::StmtBreak) -> Self { + StmtBreak(node) + } +} + +impl ToPyObject for StmtBreak { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtBreak { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtBreak(self).to_object(py)) + } +} + +#[pymethods] +impl StmtBreak {} + +#[pyclass(module="rustpython_ast.located", name="_Continue", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtContinue(pub &'static ast::StmtContinue); + +impl From<&'static ast::StmtContinue> for StmtContinue { + fn from(node: &'static ast::StmtContinue) -> Self { + StmtContinue(node) + } +} + +impl ToPyObject for StmtContinue { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtContinue { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtContinue(self).to_object(py)) + } +} + +#[pymethods] +impl StmtContinue {} + +#[pyclass(module="rustpython_ast.located", name="_expr", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Expr; + +impl From<&'static ast::Expr> for Expr { + fn from(_node: &'static ast::Expr) -> Self { + Expr + } +} + +#[pymethods] +impl Expr { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for Expr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Expr { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::BoolOp(cons) => cons.to_py_wrapper(py), + Self::NamedExpr(cons) => cons.to_py_wrapper(py), + Self::BinOp(cons) => cons.to_py_wrapper(py), + Self::UnaryOp(cons) => cons.to_py_wrapper(py), + Self::Lambda(cons) => cons.to_py_wrapper(py), + Self::IfExp(cons) => cons.to_py_wrapper(py), + Self::Dict(cons) => cons.to_py_wrapper(py), + Self::Set(cons) => cons.to_py_wrapper(py), + Self::ListComp(cons) => cons.to_py_wrapper(py), + Self::SetComp(cons) => cons.to_py_wrapper(py), + Self::DictComp(cons) => cons.to_py_wrapper(py), + Self::GeneratorExp(cons) => cons.to_py_wrapper(py), + Self::Await(cons) => cons.to_py_wrapper(py), + Self::Yield(cons) => cons.to_py_wrapper(py), + Self::YieldFrom(cons) => cons.to_py_wrapper(py), + Self::Compare(cons) => cons.to_py_wrapper(py), + Self::Call(cons) => cons.to_py_wrapper(py), + Self::FormattedValue(cons) => cons.to_py_wrapper(py), + Self::JoinedStr(cons) => cons.to_py_wrapper(py), + Self::Constant(cons) => cons.to_py_wrapper(py), + Self::Attribute(cons) => cons.to_py_wrapper(py), + Self::Subscript(cons) => cons.to_py_wrapper(py), + Self::Starred(cons) => cons.to_py_wrapper(py), + Self::Name(cons) => cons.to_py_wrapper(py), + Self::List(cons) => cons.to_py_wrapper(py), + Self::Tuple(cons) => cons.to_py_wrapper(py), + Self::Slice(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.located", name="_BoolOp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprBoolOp(pub &'static ast::ExprBoolOp); + +impl From<&'static ast::ExprBoolOp> for ExprBoolOp { + fn from(node: &'static ast::ExprBoolOp) -> Self { + ExprBoolOp(node) + } +} + +impl ToPyObject for ExprBoolOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprBoolOp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprBoolOp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprBoolOp { + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_values(&self, py: Python) -> PyResult { + self.0.values.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_NamedExpr", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprNamedExpr(pub &'static ast::ExprNamedExpr); + +impl From<&'static ast::ExprNamedExpr> for ExprNamedExpr { + fn from(node: &'static ast::ExprNamedExpr) -> Self { + ExprNamedExpr(node) + } +} + +impl ToPyObject for ExprNamedExpr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprNamedExpr { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprNamedExpr(self).to_object(py)) + } +} + +#[pymethods] +impl ExprNamedExpr { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_BinOp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprBinOp(pub &'static ast::ExprBinOp); + +impl From<&'static ast::ExprBinOp> for ExprBinOp { + fn from(node: &'static ast::ExprBinOp) -> Self { + ExprBinOp(node) + } +} + +impl ToPyObject for ExprBinOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprBinOp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprBinOp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprBinOp { + #[getter] + #[inline] + fn get_left(&self, py: Python) -> PyResult { + self.0.left.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_right(&self, py: Python) -> PyResult { + self.0.right.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_UnaryOp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprUnaryOp(pub &'static ast::ExprUnaryOp); + +impl From<&'static ast::ExprUnaryOp> for ExprUnaryOp { + fn from(node: &'static ast::ExprUnaryOp) -> Self { + ExprUnaryOp(node) + } +} + +impl ToPyObject for ExprUnaryOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprUnaryOp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprUnaryOp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprUnaryOp { + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_operand(&self, py: Python) -> PyResult { + self.0.operand.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Lambda", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprLambda(pub &'static ast::ExprLambda); + +impl From<&'static ast::ExprLambda> for ExprLambda { + fn from(node: &'static ast::ExprLambda) -> Self { + ExprLambda(node) + } +} + +impl ToPyObject for ExprLambda { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprLambda { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprLambda(self).to_object(py)) + } +} + +#[pymethods] +impl ExprLambda { + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_IfExp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprIfExp(pub &'static ast::ExprIfExp); + +impl From<&'static ast::ExprIfExp> for ExprIfExp { + fn from(node: &'static ast::ExprIfExp) -> Self { + ExprIfExp(node) + } +} + +impl ToPyObject for ExprIfExp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprIfExp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprIfExp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprIfExp { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Dict", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprDict(pub &'static ast::ExprDict); + +impl From<&'static ast::ExprDict> for ExprDict { + fn from(node: &'static ast::ExprDict) -> Self { + ExprDict(node) + } +} + +impl ToPyObject for ExprDict { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprDict { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprDict(self).to_object(py)) + } +} + +#[pymethods] +impl ExprDict { + #[getter] + #[inline] + fn get_keys(&self, py: Python) -> PyResult { + self.0.keys.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_values(&self, py: Python) -> PyResult { + self.0.values.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Set", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSet(pub &'static ast::ExprSet); + +impl From<&'static ast::ExprSet> for ExprSet { + fn from(node: &'static ast::ExprSet) -> Self { + ExprSet(node) + } +} + +impl ToPyObject for ExprSet { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprSet { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSet(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSet { + #[getter] + #[inline] + fn get_elts(&self, py: Python) -> PyResult { + self.0.elts.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_ListComp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprListComp(pub &'static ast::ExprListComp); + +impl From<&'static ast::ExprListComp> for ExprListComp { + fn from(node: &'static ast::ExprListComp) -> Self { + ExprListComp(node) + } +} + +impl ToPyObject for ExprListComp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprListComp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprListComp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprListComp { + #[getter] + #[inline] + fn get_elt(&self, py: Python) -> PyResult { + self.0.elt.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_SetComp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSetComp(pub &'static ast::ExprSetComp); + +impl From<&'static ast::ExprSetComp> for ExprSetComp { + fn from(node: &'static ast::ExprSetComp) -> Self { + ExprSetComp(node) + } +} + +impl ToPyObject for ExprSetComp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprSetComp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSetComp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSetComp { + #[getter] + #[inline] + fn get_elt(&self, py: Python) -> PyResult { + self.0.elt.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_DictComp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprDictComp(pub &'static ast::ExprDictComp); + +impl From<&'static ast::ExprDictComp> for ExprDictComp { + fn from(node: &'static ast::ExprDictComp) -> Self { + ExprDictComp(node) + } +} + +impl ToPyObject for ExprDictComp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprDictComp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprDictComp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprDictComp { + #[getter] + #[inline] + fn get_key(&self, py: Python) -> PyResult { + self.0.key.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_GeneratorExp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprGeneratorExp(pub &'static ast::ExprGeneratorExp); + +impl From<&'static ast::ExprGeneratorExp> for ExprGeneratorExp { + fn from(node: &'static ast::ExprGeneratorExp) -> Self { + ExprGeneratorExp(node) + } +} + +impl ToPyObject for ExprGeneratorExp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprGeneratorExp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprGeneratorExp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprGeneratorExp { + #[getter] + #[inline] + fn get_elt(&self, py: Python) -> PyResult { + self.0.elt.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Await", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprAwait(pub &'static ast::ExprAwait); + +impl From<&'static ast::ExprAwait> for ExprAwait { + fn from(node: &'static ast::ExprAwait) -> Self { + ExprAwait(node) + } +} + +impl ToPyObject for ExprAwait { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprAwait { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprAwait(self).to_object(py)) + } +} + +#[pymethods] +impl ExprAwait { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Yield", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprYield(pub &'static ast::ExprYield); + +impl From<&'static ast::ExprYield> for ExprYield { + fn from(node: &'static ast::ExprYield) -> Self { + ExprYield(node) + } +} + +impl ToPyObject for ExprYield { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprYield { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprYield(self).to_object(py)) + } +} + +#[pymethods] +impl ExprYield { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_YieldFrom", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprYieldFrom(pub &'static ast::ExprYieldFrom); + +impl From<&'static ast::ExprYieldFrom> for ExprYieldFrom { + fn from(node: &'static ast::ExprYieldFrom) -> Self { + ExprYieldFrom(node) + } +} + +impl ToPyObject for ExprYieldFrom { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprYieldFrom { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprYieldFrom(self).to_object(py)) + } +} + +#[pymethods] +impl ExprYieldFrom { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Compare", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprCompare(pub &'static ast::ExprCompare); + +impl From<&'static ast::ExprCompare> for ExprCompare { + fn from(node: &'static ast::ExprCompare) -> Self { + ExprCompare(node) + } +} + +impl ToPyObject for ExprCompare { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprCompare { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprCompare(self).to_object(py)) + } +} + +#[pymethods] +impl ExprCompare { + #[getter] + #[inline] + fn get_left(&self, py: Python) -> PyResult { + self.0.left.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ops(&self, py: Python) -> PyResult { + self.0.ops.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_comparators(&self, py: Python) -> PyResult { + self.0.comparators.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Call", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprCall(pub &'static ast::ExprCall); + +impl From<&'static ast::ExprCall> for ExprCall { + fn from(node: &'static ast::ExprCall) -> Self { + ExprCall(node) + } +} + +impl ToPyObject for ExprCall { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprCall { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprCall(self).to_object(py)) + } +} + +#[pymethods] +impl ExprCall { + #[getter] + #[inline] + fn get_func(&self, py: Python) -> PyResult { + self.0.func.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_keywords(&self, py: Python) -> PyResult { + self.0.keywords.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_FormattedValue", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprFormattedValue(pub &'static ast::ExprFormattedValue); + +impl From<&'static ast::ExprFormattedValue> for ExprFormattedValue { + fn from(node: &'static ast::ExprFormattedValue) -> Self { + ExprFormattedValue(node) + } +} + +impl ToPyObject for ExprFormattedValue { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprFormattedValue { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprFormattedValue(self).to_object(py)) + } +} + +#[pymethods] +impl ExprFormattedValue { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_conversion(&self, py: Python) -> PyResult { + self.0.conversion.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_format_spec(&self, py: Python) -> PyResult { + self.0.format_spec.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_JoinedStr", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprJoinedStr(pub &'static ast::ExprJoinedStr); + +impl From<&'static ast::ExprJoinedStr> for ExprJoinedStr { + fn from(node: &'static ast::ExprJoinedStr) -> Self { + ExprJoinedStr(node) + } +} + +impl ToPyObject for ExprJoinedStr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprJoinedStr { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprJoinedStr(self).to_object(py)) + } +} + +#[pymethods] +impl ExprJoinedStr { + #[getter] + #[inline] + fn get_values(&self, py: Python) -> PyResult { + self.0.values.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Constant", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprConstant(pub &'static ast::ExprConstant); + +impl From<&'static ast::ExprConstant> for ExprConstant { + fn from(node: &'static ast::ExprConstant) -> Self { + ExprConstant(node) + } +} + +impl ToPyObject for ExprConstant { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprConstant { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprConstant(self).to_object(py)) + } +} + +#[pymethods] +impl ExprConstant { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_kind(&self, py: Python) -> PyResult { + self.0.kind.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Attribute", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprAttribute(pub &'static ast::ExprAttribute); + +impl From<&'static ast::ExprAttribute> for ExprAttribute { + fn from(node: &'static ast::ExprAttribute) -> Self { + ExprAttribute(node) + } +} + +impl ToPyObject for ExprAttribute { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprAttribute { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprAttribute(self).to_object(py)) + } +} + +#[pymethods] +impl ExprAttribute { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_attr(&self, py: Python) -> PyResult { + self.0.attr.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Subscript", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSubscript(pub &'static ast::ExprSubscript); + +impl From<&'static ast::ExprSubscript> for ExprSubscript { + fn from(node: &'static ast::ExprSubscript) -> Self { + ExprSubscript(node) + } +} + +impl ToPyObject for ExprSubscript { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprSubscript { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSubscript(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSubscript { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_slice(&self, py: Python) -> PyResult { + self.0.slice.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Starred", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprStarred(pub &'static ast::ExprStarred); + +impl From<&'static ast::ExprStarred> for ExprStarred { + fn from(node: &'static ast::ExprStarred) -> Self { + ExprStarred(node) + } +} + +impl ToPyObject for ExprStarred { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprStarred { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprStarred(self).to_object(py)) + } +} + +#[pymethods] +impl ExprStarred { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Name", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprName(pub &'static ast::ExprName); + +impl From<&'static ast::ExprName> for ExprName { + fn from(node: &'static ast::ExprName) -> Self { + ExprName(node) + } +} + +impl ToPyObject for ExprName { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprName { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprName(self).to_object(py)) + } +} + +#[pymethods] +impl ExprName { + #[getter] + #[inline] + fn get_id(&self, py: Python) -> PyResult { + self.0.id.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_List", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprList(pub &'static ast::ExprList); + +impl From<&'static ast::ExprList> for ExprList { + fn from(node: &'static ast::ExprList) -> Self { + ExprList(node) + } +} + +impl ToPyObject for ExprList { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprList { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprList(self).to_object(py)) + } +} + +#[pymethods] +impl ExprList { + #[getter] + #[inline] + fn get_elts(&self, py: Python) -> PyResult { + self.0.elts.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Tuple", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprTuple(pub &'static ast::ExprTuple); + +impl From<&'static ast::ExprTuple> for ExprTuple { + fn from(node: &'static ast::ExprTuple) -> Self { + ExprTuple(node) + } +} + +impl ToPyObject for ExprTuple { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprTuple { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprTuple(self).to_object(py)) + } +} + +#[pymethods] +impl ExprTuple { + #[getter] + #[inline] + fn get_elts(&self, py: Python) -> PyResult { + self.0.elts.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Slice", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSlice(pub &'static ast::ExprSlice); + +impl From<&'static ast::ExprSlice> for ExprSlice { + fn from(node: &'static ast::ExprSlice) -> Self { + ExprSlice(node) + } +} + +impl ToPyObject for ExprSlice { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprSlice { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSlice(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSlice { + #[getter] + #[inline] + fn get_lower(&self, py: Python) -> PyResult { + self.0.lower.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_upper(&self, py: Python) -> PyResult { + self.0.upper.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_step(&self, py: Python) -> PyResult { + self.0.step.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_expr_context", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct ExprContext; + +impl From<&'static ast::ExprContext> for ExprContext { + fn from(_node: &'static ast::ExprContext) -> Self { + ExprContext + } +} + +#[pymethods] +impl ExprContext { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for ExprContext { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Load", extends=ExprContext)] +pub struct ExprContextLoad; + +impl ToPyObject for ExprContextLoad { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(ExprContext) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Store", extends=ExprContext)] +pub struct ExprContextStore; + +impl ToPyObject for ExprContextStore { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(ExprContext) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Del", extends=ExprContext)] +pub struct ExprContextDel; + +impl ToPyObject for ExprContextDel { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(ExprContext) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_boolop", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct BoolOp; + +impl From<&'static ast::BoolOp> for BoolOp { + fn from(_node: &'static ast::BoolOp) -> Self { + BoolOp + } +} + +#[pymethods] +impl BoolOp { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for BoolOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_And", extends=BoolOp)] +pub struct BoolOpAnd; + +impl ToPyObject for BoolOpAnd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(BoolOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Or", extends=BoolOp)] +pub struct BoolOpOr; + +impl ToPyObject for BoolOpOr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(BoolOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_operator", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Operator; + +impl From<&'static ast::Operator> for Operator { + fn from(_node: &'static ast::Operator) -> Self { + Operator + } +} + +#[pymethods] +impl Operator { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for Operator { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Add", extends=Operator)] +pub struct OperatorAdd; + +impl ToPyObject for OperatorAdd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Sub", extends=Operator)] +pub struct OperatorSub; + +impl ToPyObject for OperatorSub { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Mult", extends=Operator)] +pub struct OperatorMult; + +impl ToPyObject for OperatorMult { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatMult", extends=Operator)] +pub struct OperatorMatMult; + +impl ToPyObject for OperatorMatMult { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Div", extends=Operator)] +pub struct OperatorDiv; + +impl ToPyObject for OperatorDiv { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Mod", extends=Operator)] +pub struct OperatorMod; + +impl ToPyObject for OperatorMod { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Pow", extends=Operator)] +pub struct OperatorPow; + +impl ToPyObject for OperatorPow { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_LShift", extends=Operator)] +pub struct OperatorLShift; + +impl ToPyObject for OperatorLShift { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_RShift", extends=Operator)] +pub struct OperatorRShift; + +impl ToPyObject for OperatorRShift { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_BitOr", extends=Operator)] +pub struct OperatorBitOr; + +impl ToPyObject for OperatorBitOr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_BitXor", extends=Operator)] +pub struct OperatorBitXor; + +impl ToPyObject for OperatorBitXor { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_BitAnd", extends=Operator)] +pub struct OperatorBitAnd; + +impl ToPyObject for OperatorBitAnd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_FloorDiv", extends=Operator)] +pub struct OperatorFloorDiv; + +impl ToPyObject for OperatorFloorDiv { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_unaryop", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct UnaryOp; + +impl From<&'static ast::UnaryOp> for UnaryOp { + fn from(_node: &'static ast::UnaryOp) -> Self { + UnaryOp + } +} + +#[pymethods] +impl UnaryOp { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for UnaryOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Invert", extends=UnaryOp)] +pub struct UnaryOpInvert; + +impl ToPyObject for UnaryOpInvert { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(UnaryOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Not", extends=UnaryOp)] +pub struct UnaryOpNot; + +impl ToPyObject for UnaryOpNot { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(UnaryOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_UAdd", extends=UnaryOp)] +pub struct UnaryOpUAdd; + +impl ToPyObject for UnaryOpUAdd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(UnaryOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_USub", extends=UnaryOp)] +pub struct UnaryOpUSub; + +impl ToPyObject for UnaryOpUSub { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(UnaryOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_cmpop", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct CmpOp; + +impl From<&'static ast::CmpOp> for CmpOp { + fn from(_node: &'static ast::CmpOp) -> Self { + CmpOp + } +} + +#[pymethods] +impl CmpOp { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for CmpOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Eq", extends=CmpOp)] +pub struct CmpOpEq; + +impl ToPyObject for CmpOpEq { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_NotEq", extends=CmpOp)] +pub struct CmpOpNotEq; + +impl ToPyObject for CmpOpNotEq { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Lt", extends=CmpOp)] +pub struct CmpOpLt; + +impl ToPyObject for CmpOpLt { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_LtE", extends=CmpOp)] +pub struct CmpOpLtE; + +impl ToPyObject for CmpOpLtE { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Gt", extends=CmpOp)] +pub struct CmpOpGt; + +impl ToPyObject for CmpOpGt { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_GtE", extends=CmpOp)] +pub struct CmpOpGtE; + +impl ToPyObject for CmpOpGtE { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_Is", extends=CmpOp)] +pub struct CmpOpIs; + +impl ToPyObject for CmpOpIs { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_IsNot", extends=CmpOp)] +pub struct CmpOpIsNot; + +impl ToPyObject for CmpOpIsNot { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_In", extends=CmpOp)] +pub struct CmpOpIn; + +impl ToPyObject for CmpOpIn { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_NotIn", extends=CmpOp)] +pub struct CmpOpNotIn; + +impl ToPyObject for CmpOpNotIn { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_comprehension", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct Comprehension(pub &'static ast::Comprehension); + +impl From<&'static ast::Comprehension> for Comprehension { + fn from(node: &'static ast::Comprehension) -> Self { + Comprehension(node) + } +} + +impl ToPyObject for Comprehension { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Comprehension { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Comprehension(self).to_object(py)) + } +} + +#[pymethods] +impl Comprehension { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_iter(&self, py: Python) -> PyResult { + self.0.iter.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ifs(&self, py: Python) -> PyResult { + self.0.ifs.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_is_async(&self, py: Python) -> PyResult { + self.0.is_async.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_excepthandler", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct ExceptHandler; + +impl From<&'static ast::ExceptHandler> for ExceptHandler { + fn from(_node: &'static ast::ExceptHandler) -> Self { + ExceptHandler + } +} + +#[pymethods] +impl ExceptHandler { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for ExceptHandler { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExceptHandler { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::ExceptHandler(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.located", name="_ExceptHandler", extends=ExceptHandler, frozen)] +#[derive(Clone, Debug)] +pub struct ExceptHandlerExceptHandler(pub &'static ast::ExceptHandlerExceptHandler); + +impl From<&'static ast::ExceptHandlerExceptHandler> for ExceptHandlerExceptHandler { + fn from(node: &'static ast::ExceptHandlerExceptHandler) -> Self { + ExceptHandlerExceptHandler(node) + } +} + +impl ToPyObject for ExceptHandlerExceptHandler { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(ExceptHandler) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExceptHandlerExceptHandler { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExceptHandlerExceptHandler(self).to_object(py)) + } +} + +#[pymethods] +impl ExceptHandlerExceptHandler { + #[getter] + #[inline] + fn get_type(&self, py: Python) -> PyResult { + self.0.type_.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_arguments", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct Arguments(pub &'static ast::PythonArguments); + +impl From<&'static ast::PythonArguments> for Arguments { + fn from(node: &'static ast::PythonArguments) -> Self { + Arguments(node) + } +} + +impl ToPyObject for Arguments { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PythonArguments { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Arguments(self).to_object(py)) + } +} + +#[pymethods] +impl Arguments { + #[getter] + #[inline] + fn get_posonlyargs(&self, py: Python) -> PyResult { + self.0.posonlyargs.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_vararg(&self, py: Python) -> PyResult { + self.0.vararg.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwonlyargs(&self, py: Python) -> PyResult { + self.0.kwonlyargs.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_kw_defaults(&self, py: Python) -> PyResult { + self.0.kw_defaults.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwarg(&self, py: Python) -> PyResult { + self.0.kwarg.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_defaults(&self, py: Python) -> PyResult { + self.0.defaults.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_arg", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct Arg(pub &'static ast::Arg); + +impl From<&'static ast::Arg> for Arg { + fn from(node: &'static ast::Arg) -> Self { + Arg(node) + } +} + +impl ToPyObject for Arg { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Arg { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Arg(self).to_object(py)) + } +} + +#[pymethods] +impl Arg { + #[getter] + #[inline] + fn get_arg(&self, py: Python) -> PyResult { + self.0.arg.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_annotation(&self, py: Python) -> PyResult { + self.0.annotation.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_keyword", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct Keyword(pub &'static ast::Keyword); + +impl From<&'static ast::Keyword> for Keyword { + fn from(node: &'static ast::Keyword) -> Self { + Keyword(node) + } +} + +impl ToPyObject for Keyword { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Keyword { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Keyword(self).to_object(py)) + } +} + +#[pymethods] +impl Keyword { + #[getter] + #[inline] + fn get_arg(&self, py: Python) -> PyResult { + self.0.arg.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_alias", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct Alias(pub &'static ast::Alias); + +impl From<&'static ast::Alias> for Alias { + fn from(node: &'static ast::Alias) -> Self { + Alias(node) + } +} + +impl ToPyObject for Alias { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Alias { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Alias(self).to_object(py)) + } +} + +#[pymethods] +impl Alias { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_asname(&self, py: Python) -> PyResult { + self.0.asname.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_withitem", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct WithItem(pub &'static ast::WithItem); + +impl From<&'static ast::WithItem> for WithItem { + fn from(node: &'static ast::WithItem) -> Self { + WithItem(node) + } +} + +impl ToPyObject for WithItem { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::WithItem { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(WithItem(self).to_object(py)) + } +} + +#[pymethods] +impl WithItem { + #[getter] + #[inline] + fn get_context_expr(&self, py: Python) -> PyResult { + self.0.context_expr.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_optional_vars(&self, py: Python) -> PyResult { + self.0.optional_vars.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_match_case", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct MatchCase(pub &'static ast::MatchCase); + +impl From<&'static ast::MatchCase> for MatchCase { + fn from(node: &'static ast::MatchCase) -> Self { + MatchCase(node) + } +} + +impl ToPyObject for MatchCase { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::MatchCase { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(MatchCase(self).to_object(py)) + } +} + +#[pymethods] +impl MatchCase { + #[getter] + #[inline] + fn get_pattern(&self, py: Python) -> PyResult { + self.0.pattern.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_guard(&self, py: Python) -> PyResult { + self.0.guard.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_pattern", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Pattern; + +impl From<&'static ast::Pattern> for Pattern { + fn from(_node: &'static ast::Pattern) -> Self { + Pattern + } +} + +#[pymethods] +impl Pattern { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for Pattern { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Pattern { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::MatchValue(cons) => cons.to_py_wrapper(py), + Self::MatchSingleton(cons) => cons.to_py_wrapper(py), + Self::MatchSequence(cons) => cons.to_py_wrapper(py), + Self::MatchMapping(cons) => cons.to_py_wrapper(py), + Self::MatchClass(cons) => cons.to_py_wrapper(py), + Self::MatchStar(cons) => cons.to_py_wrapper(py), + Self::MatchAs(cons) => cons.to_py_wrapper(py), + Self::MatchOr(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchValue", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchValue(pub &'static ast::PatternMatchValue); + +impl From<&'static ast::PatternMatchValue> for PatternMatchValue { + fn from(node: &'static ast::PatternMatchValue) -> Self { + PatternMatchValue(node) + } +} + +impl ToPyObject for PatternMatchValue { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchValue { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchValue(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchValue { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchSingleton", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchSingleton(pub &'static ast::PatternMatchSingleton); + +impl From<&'static ast::PatternMatchSingleton> for PatternMatchSingleton { + fn from(node: &'static ast::PatternMatchSingleton) -> Self { + PatternMatchSingleton(node) + } +} + +impl ToPyObject for PatternMatchSingleton { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchSingleton { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchSingleton(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchSingleton { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchSequence", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchSequence(pub &'static ast::PatternMatchSequence); + +impl From<&'static ast::PatternMatchSequence> for PatternMatchSequence { + fn from(node: &'static ast::PatternMatchSequence) -> Self { + PatternMatchSequence(node) + } +} + +impl ToPyObject for PatternMatchSequence { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchSequence { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchSequence(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchSequence { + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchMapping", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchMapping(pub &'static ast::PatternMatchMapping); + +impl From<&'static ast::PatternMatchMapping> for PatternMatchMapping { + fn from(node: &'static ast::PatternMatchMapping) -> Self { + PatternMatchMapping(node) + } +} + +impl ToPyObject for PatternMatchMapping { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchMapping { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchMapping(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchMapping { + #[getter] + #[inline] + fn get_keys(&self, py: Python) -> PyResult { + self.0.keys.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_rest(&self, py: Python) -> PyResult { + self.0.rest.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchClass", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchClass(pub &'static ast::PatternMatchClass); + +impl From<&'static ast::PatternMatchClass> for PatternMatchClass { + fn from(node: &'static ast::PatternMatchClass) -> Self { + PatternMatchClass(node) + } +} + +impl ToPyObject for PatternMatchClass { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchClass { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchClass(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchClass { + #[getter] + #[inline] + fn get_cls(&self, py: Python) -> PyResult { + self.0.cls.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwd_attrs(&self, py: Python) -> PyResult { + self.0.kwd_attrs.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwd_patterns(&self, py: Python) -> PyResult { + self.0.kwd_patterns.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchStar", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchStar(pub &'static ast::PatternMatchStar); + +impl From<&'static ast::PatternMatchStar> for PatternMatchStar { + fn from(node: &'static ast::PatternMatchStar) -> Self { + PatternMatchStar(node) + } +} + +impl ToPyObject for PatternMatchStar { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchStar { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchStar(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchStar { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchAs", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchAs(pub &'static ast::PatternMatchAs); + +impl From<&'static ast::PatternMatchAs> for PatternMatchAs { + fn from(node: &'static ast::PatternMatchAs) -> Self { + PatternMatchAs(node) + } +} + +impl ToPyObject for PatternMatchAs { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchAs { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchAs(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchAs { + #[getter] + #[inline] + fn get_pattern(&self, py: Python) -> PyResult { + self.0.pattern.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_MatchOr", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchOr(pub &'static ast::PatternMatchOr); + +impl From<&'static ast::PatternMatchOr> for PatternMatchOr { + fn from(node: &'static ast::PatternMatchOr) -> Self { + PatternMatchOr(node) + } +} + +impl ToPyObject for PatternMatchOr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchOr { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchOr(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchOr { + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_type_ignore", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct TypeIgnore; + +impl From<&'static ast::TypeIgnore> for TypeIgnore { + fn from(_node: &'static ast::TypeIgnore) -> Self { + TypeIgnore + } +} + +#[pymethods] +impl TypeIgnore { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for TypeIgnore { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::TypeIgnore { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::TypeIgnore(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.located", name="_TypeIgnore", extends=TypeIgnore, frozen)] +#[derive(Clone, Debug)] +pub struct TypeIgnoreTypeIgnore(pub &'static ast::TypeIgnoreTypeIgnore); + +impl From<&'static ast::TypeIgnoreTypeIgnore> for TypeIgnoreTypeIgnore { + fn from(node: &'static ast::TypeIgnoreTypeIgnore) -> Self { + TypeIgnoreTypeIgnore(node) + } +} + +impl ToPyObject for TypeIgnoreTypeIgnore { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(TypeIgnore) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::TypeIgnoreTypeIgnore { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(TypeIgnoreTypeIgnore(self).to_object(py)) + } +} + +#[pymethods] +impl TypeIgnoreTypeIgnore { + #[getter] + #[inline] + fn get_lineno(&self, py: Python) -> PyResult { + self.0.lineno.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_tag(&self, py: Python) -> PyResult { + self.0.tag.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_type_param", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct TypeParam; + +impl From<&'static ast::TypeParam> for TypeParam { + fn from(_node: &'static ast::TypeParam) -> Self { + TypeParam + } +} + +#[pymethods] +impl TypeParam { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for TypeParam { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::TypeParam { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::TypeVar(cons) => cons.to_py_wrapper(py), + Self::ParamSpec(cons) => cons.to_py_wrapper(py), + Self::TypeVarTuple(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.located", name="_TypeVar", extends=TypeParam, frozen)] +#[derive(Clone, Debug)] +pub struct TypeParamTypeVar(pub &'static ast::TypeParamTypeVar); + +impl From<&'static ast::TypeParamTypeVar> for TypeParamTypeVar { + fn from(node: &'static ast::TypeParamTypeVar) -> Self { + TypeParamTypeVar(node) + } +} + +impl ToPyObject for TypeParamTypeVar { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(TypeParam) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::TypeParamTypeVar { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(TypeParamTypeVar(self).to_object(py)) + } +} + +#[pymethods] +impl TypeParamTypeVar { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_bound(&self, py: Python) -> PyResult { + self.0.bound.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_ParamSpec", extends=TypeParam, frozen)] +#[derive(Clone, Debug)] +pub struct TypeParamParamSpec(pub &'static ast::TypeParamParamSpec); + +impl From<&'static ast::TypeParamParamSpec> for TypeParamParamSpec { + fn from(node: &'static ast::TypeParamParamSpec) -> Self { + TypeParamParamSpec(node) + } +} + +impl ToPyObject for TypeParamParamSpec { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(TypeParam) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::TypeParamParamSpec { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(TypeParamParamSpec(self).to_object(py)) + } +} + +#[pymethods] +impl TypeParamParamSpec { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.located", name="_TypeVarTuple", extends=TypeParam, frozen)] +#[derive(Clone, Debug)] +pub struct TypeParamTypeVarTuple(pub &'static ast::TypeParamTypeVarTuple); + +impl From<&'static ast::TypeParamTypeVarTuple> for TypeParamTypeVarTuple { + fn from(node: &'static ast::TypeParamTypeVarTuple) -> Self { + TypeParamTypeVarTuple(node) + } +} + +impl ToPyObject for TypeParamTypeVarTuple { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(TypeParam) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::TypeParamTypeVarTuple { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(TypeParamTypeVarTuple(self).to_object(py)) + } +} + +#[pymethods] +impl TypeParamTypeVarTuple { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } +} + +impl ToPyWrapper for ast::ExprContext { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + match &self { + Self::Load => Ok(ExprContextLoad.to_object(py)), + Self::Store => Ok(ExprContextStore.to_object(py)), + Self::Del => Ok(ExprContextDel.to_object(py)), + } + } +} + +impl ToPyWrapper for ast::ExprContextLoad { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(ExprContextLoad.to_object(py)) + } +} + +impl ToPyWrapper for ast::ExprContextStore { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(ExprContextStore.to_object(py)) + } +} + +impl ToPyWrapper for ast::ExprContextDel { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(ExprContextDel.to_object(py)) + } +} + +impl ToPyWrapper for ast::BoolOp { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + match &self { + Self::And => Ok(BoolOpAnd.to_object(py)), + Self::Or => Ok(BoolOpOr.to_object(py)), + } + } +} + +impl ToPyWrapper for ast::BoolOpAnd { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(BoolOpAnd.to_object(py)) + } +} + +impl ToPyWrapper for ast::BoolOpOr { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(BoolOpOr.to_object(py)) + } +} + +impl ToPyWrapper for ast::Operator { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + match &self { + Self::Add => Ok(OperatorAdd.to_object(py)), + Self::Sub => Ok(OperatorSub.to_object(py)), + Self::Mult => Ok(OperatorMult.to_object(py)), + Self::MatMult => Ok(OperatorMatMult.to_object(py)), + Self::Div => Ok(OperatorDiv.to_object(py)), + Self::Mod => Ok(OperatorMod.to_object(py)), + Self::Pow => Ok(OperatorPow.to_object(py)), + Self::LShift => Ok(OperatorLShift.to_object(py)), + Self::RShift => Ok(OperatorRShift.to_object(py)), + Self::BitOr => Ok(OperatorBitOr.to_object(py)), + Self::BitXor => Ok(OperatorBitXor.to_object(py)), + Self::BitAnd => Ok(OperatorBitAnd.to_object(py)), + Self::FloorDiv => Ok(OperatorFloorDiv.to_object(py)), + } + } +} + +impl ToPyWrapper for ast::OperatorAdd { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorAdd.to_object(py)) + } +} + +impl ToPyWrapper for ast::OperatorSub { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorSub.to_object(py)) + } +} + +impl ToPyWrapper for ast::OperatorMult { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorMult.to_object(py)) + } +} + +impl ToPyWrapper for ast::OperatorMatMult { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorMatMult.to_object(py)) + } +} + +impl ToPyWrapper for ast::OperatorDiv { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorDiv.to_object(py)) + } +} + +impl ToPyWrapper for ast::OperatorMod { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorMod.to_object(py)) + } +} + +impl ToPyWrapper for ast::OperatorPow { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorPow.to_object(py)) + } +} + +impl ToPyWrapper for ast::OperatorLShift { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorLShift.to_object(py)) + } +} + +impl ToPyWrapper for ast::OperatorRShift { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorRShift.to_object(py)) + } +} + +impl ToPyWrapper for ast::OperatorBitOr { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorBitOr.to_object(py)) + } +} + +impl ToPyWrapper for ast::OperatorBitXor { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorBitXor.to_object(py)) + } +} + +impl ToPyWrapper for ast::OperatorBitAnd { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorBitAnd.to_object(py)) + } +} + +impl ToPyWrapper for ast::OperatorFloorDiv { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(OperatorFloorDiv.to_object(py)) + } +} + +impl ToPyWrapper for ast::UnaryOp { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + match &self { + Self::Invert => Ok(UnaryOpInvert.to_object(py)), + Self::Not => Ok(UnaryOpNot.to_object(py)), + Self::UAdd => Ok(UnaryOpUAdd.to_object(py)), + Self::USub => Ok(UnaryOpUSub.to_object(py)), + } + } +} + +impl ToPyWrapper for ast::UnaryOpInvert { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(UnaryOpInvert.to_object(py)) + } +} + +impl ToPyWrapper for ast::UnaryOpNot { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(UnaryOpNot.to_object(py)) + } +} + +impl ToPyWrapper for ast::UnaryOpUAdd { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(UnaryOpUAdd.to_object(py)) + } +} + +impl ToPyWrapper for ast::UnaryOpUSub { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(UnaryOpUSub.to_object(py)) + } +} + +impl ToPyWrapper for ast::CmpOp { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + match &self { + Self::Eq => Ok(CmpOpEq.to_object(py)), + Self::NotEq => Ok(CmpOpNotEq.to_object(py)), + Self::Lt => Ok(CmpOpLt.to_object(py)), + Self::LtE => Ok(CmpOpLtE.to_object(py)), + Self::Gt => Ok(CmpOpGt.to_object(py)), + Self::GtE => Ok(CmpOpGtE.to_object(py)), + Self::Is => Ok(CmpOpIs.to_object(py)), + Self::IsNot => Ok(CmpOpIsNot.to_object(py)), + Self::In => Ok(CmpOpIn.to_object(py)), + Self::NotIn => Ok(CmpOpNotIn.to_object(py)), + } + } +} + +impl ToPyWrapper for ast::CmpOpEq { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpOpEq.to_object(py)) + } +} + +impl ToPyWrapper for ast::CmpOpNotEq { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpOpNotEq.to_object(py)) + } +} + +impl ToPyWrapper for ast::CmpOpLt { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpOpLt.to_object(py)) + } +} + +impl ToPyWrapper for ast::CmpOpLtE { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpOpLtE.to_object(py)) + } +} + +impl ToPyWrapper for ast::CmpOpGt { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpOpGt.to_object(py)) + } +} + +impl ToPyWrapper for ast::CmpOpGtE { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpOpGtE.to_object(py)) + } +} + +impl ToPyWrapper for ast::CmpOpIs { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpOpIs.to_object(py)) + } +} + +impl ToPyWrapper for ast::CmpOpIsNot { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpOpIsNot.to_object(py)) + } +} + +impl ToPyWrapper for ast::CmpOpIn { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpOpIn.to_object(py)) + } +} + +impl ToPyWrapper for ast::CmpOpNotIn { + #[inline] + fn to_py_wrapper(&self, py: Python) -> PyResult> { + Ok(CmpOpNotIn.to_object(py)) + } +} + +pub fn add_to_module(py: Python, m: &PyModule) -> PyResult<()> { + super::init_module(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + Ok(()) +} diff --git a/src/gen/wrapper_ranged.rs b/src/gen/wrapper_ranged.rs new file mode 100644 index 0000000..53416ad --- /dev/null +++ b/src/gen/wrapper_ranged.rs @@ -0,0 +1,4334 @@ +// File automatically generated by ast/asdl_rs.py. + +#[pyclass(module="rustpython_ast.ranged", name="_mod", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Mod; + +impl From<&'static ast::Mod> for Mod { + fn from(_node: &'static ast::Mod) -> Self { + Mod + } +} + +#[pymethods] +impl Mod { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for Mod { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Mod { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::Module(cons) => cons.to_py_wrapper(py), + Self::Interactive(cons) => cons.to_py_wrapper(py), + Self::Expression(cons) => cons.to_py_wrapper(py), + Self::FunctionType(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Module", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModModule(pub &'static ast::ModModule); + +impl From<&'static ast::ModModule> for ModModule { + fn from(node: &'static ast::ModModule) -> Self { + ModModule(node) + } +} + +impl ToPyObject for ModModule { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ModModule { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModModule(self).to_object(py)) + } +} + +#[pymethods] +impl ModModule { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_ignores(&self, py: Python) -> PyResult { + self.0.type_ignores.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Interactive", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModInteractive(pub &'static ast::ModInteractive); + +impl From<&'static ast::ModInteractive> for ModInteractive { + fn from(node: &'static ast::ModInteractive) -> Self { + ModInteractive(node) + } +} + +impl ToPyObject for ModInteractive { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ModInteractive { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModInteractive(self).to_object(py)) + } +} + +#[pymethods] +impl ModInteractive { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Expression", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModExpression(pub &'static ast::ModExpression); + +impl From<&'static ast::ModExpression> for ModExpression { + fn from(node: &'static ast::ModExpression) -> Self { + ModExpression(node) + } +} + +impl ToPyObject for ModExpression { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ModExpression { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModExpression(self).to_object(py)) + } +} + +#[pymethods] +impl ModExpression { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_FunctionType", extends=Mod, frozen)] +#[derive(Clone, Debug)] +pub struct ModFunctionType(pub &'static ast::ModFunctionType); + +impl From<&'static ast::ModFunctionType> for ModFunctionType { + fn from(node: &'static ast::ModFunctionType) -> Self { + ModFunctionType(node) + } +} + +impl ToPyObject for ModFunctionType { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Mod) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ModFunctionType { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ModFunctionType(self).to_object(py)) + } +} + +#[pymethods] +impl ModFunctionType { + #[getter] + #[inline] + fn get_argtypes(&self, py: Python) -> PyResult { + self.0.argtypes.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_returns(&self, py: Python) -> PyResult { + self.0.returns.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_stmt", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Stmt; + +impl From<&'static ast::Stmt> for Stmt { + fn from(_node: &'static ast::Stmt) -> Self { + Stmt + } +} + +#[pymethods] +impl Stmt { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for Stmt { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Stmt { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::FunctionDef(cons) => cons.to_py_wrapper(py), + Self::AsyncFunctionDef(cons) => cons.to_py_wrapper(py), + Self::ClassDef(cons) => cons.to_py_wrapper(py), + Self::Return(cons) => cons.to_py_wrapper(py), + Self::Delete(cons) => cons.to_py_wrapper(py), + Self::Assign(cons) => cons.to_py_wrapper(py), + Self::TypeAlias(cons) => cons.to_py_wrapper(py), + Self::AugAssign(cons) => cons.to_py_wrapper(py), + Self::AnnAssign(cons) => cons.to_py_wrapper(py), + Self::For(cons) => cons.to_py_wrapper(py), + Self::AsyncFor(cons) => cons.to_py_wrapper(py), + Self::While(cons) => cons.to_py_wrapper(py), + Self::If(cons) => cons.to_py_wrapper(py), + Self::With(cons) => cons.to_py_wrapper(py), + Self::AsyncWith(cons) => cons.to_py_wrapper(py), + Self::Match(cons) => cons.to_py_wrapper(py), + Self::Raise(cons) => cons.to_py_wrapper(py), + Self::Try(cons) => cons.to_py_wrapper(py), + Self::TryStar(cons) => cons.to_py_wrapper(py), + Self::Assert(cons) => cons.to_py_wrapper(py), + Self::Import(cons) => cons.to_py_wrapper(py), + Self::ImportFrom(cons) => cons.to_py_wrapper(py), + Self::Global(cons) => cons.to_py_wrapper(py), + Self::Nonlocal(cons) => cons.to_py_wrapper(py), + Self::Expr(cons) => cons.to_py_wrapper(py), + Self::Pass(cons) => cons.to_py_wrapper(py), + Self::Break(cons) => cons.to_py_wrapper(py), + Self::Continue(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_FunctionDef", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtFunctionDef(pub &'static ast::StmtFunctionDef); + +impl From<&'static ast::StmtFunctionDef> for StmtFunctionDef { + fn from(node: &'static ast::StmtFunctionDef) -> Self { + StmtFunctionDef(node) + } +} + +impl ToPyObject for StmtFunctionDef { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtFunctionDef { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtFunctionDef(self).to_object(py)) + } +} + +#[pymethods] +impl StmtFunctionDef { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_decorator_list(&self, py: Python) -> PyResult { + self.0.decorator_list.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_returns(&self, py: Python) -> PyResult { + self.0.returns.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_params(&self, py: Python) -> PyResult { + self.0.type_params.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_AsyncFunctionDef", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAsyncFunctionDef(pub &'static ast::StmtAsyncFunctionDef); + +impl From<&'static ast::StmtAsyncFunctionDef> for StmtAsyncFunctionDef { + fn from(node: &'static ast::StmtAsyncFunctionDef) -> Self { + StmtAsyncFunctionDef(node) + } +} + +impl ToPyObject for StmtAsyncFunctionDef { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAsyncFunctionDef { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAsyncFunctionDef(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAsyncFunctionDef { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_decorator_list(&self, py: Python) -> PyResult { + self.0.decorator_list.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_returns(&self, py: Python) -> PyResult { + self.0.returns.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_params(&self, py: Python) -> PyResult { + self.0.type_params.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_ClassDef", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtClassDef(pub &'static ast::StmtClassDef); + +impl From<&'static ast::StmtClassDef> for StmtClassDef { + fn from(node: &'static ast::StmtClassDef) -> Self { + StmtClassDef(node) + } +} + +impl ToPyObject for StmtClassDef { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtClassDef { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtClassDef(self).to_object(py)) + } +} + +#[pymethods] +impl StmtClassDef { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_bases(&self, py: Python) -> PyResult { + self.0.bases.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_keywords(&self, py: Python) -> PyResult { + self.0.keywords.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_decorator_list(&self, py: Python) -> PyResult { + self.0.decorator_list.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_params(&self, py: Python) -> PyResult { + self.0.type_params.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Return", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtReturn(pub &'static ast::StmtReturn); + +impl From<&'static ast::StmtReturn> for StmtReturn { + fn from(node: &'static ast::StmtReturn) -> Self { + StmtReturn(node) + } +} + +impl ToPyObject for StmtReturn { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtReturn { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtReturn(self).to_object(py)) + } +} + +#[pymethods] +impl StmtReturn { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Delete", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtDelete(pub &'static ast::StmtDelete); + +impl From<&'static ast::StmtDelete> for StmtDelete { + fn from(node: &'static ast::StmtDelete) -> Self { + StmtDelete(node) + } +} + +impl ToPyObject for StmtDelete { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtDelete { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtDelete(self).to_object(py)) + } +} + +#[pymethods] +impl StmtDelete { + #[getter] + #[inline] + fn get_targets(&self, py: Python) -> PyResult { + self.0.targets.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Assign", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAssign(pub &'static ast::StmtAssign); + +impl From<&'static ast::StmtAssign> for StmtAssign { + fn from(node: &'static ast::StmtAssign) -> Self { + StmtAssign(node) + } +} + +impl ToPyObject for StmtAssign { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAssign { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAssign(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAssign { + #[getter] + #[inline] + fn get_targets(&self, py: Python) -> PyResult { + self.0.targets.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_TypeAlias", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtTypeAlias(pub &'static ast::StmtTypeAlias); + +impl From<&'static ast::StmtTypeAlias> for StmtTypeAlias { + fn from(node: &'static ast::StmtTypeAlias) -> Self { + StmtTypeAlias(node) + } +} + +impl ToPyObject for StmtTypeAlias { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtTypeAlias { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtTypeAlias(self).to_object(py)) + } +} + +#[pymethods] +impl StmtTypeAlias { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_params(&self, py: Python) -> PyResult { + self.0.type_params.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_AugAssign", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAugAssign(pub &'static ast::StmtAugAssign); + +impl From<&'static ast::StmtAugAssign> for StmtAugAssign { + fn from(node: &'static ast::StmtAugAssign) -> Self { + StmtAugAssign(node) + } +} + +impl ToPyObject for StmtAugAssign { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAugAssign { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAugAssign(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAugAssign { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_AnnAssign", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAnnAssign(pub &'static ast::StmtAnnAssign); + +impl From<&'static ast::StmtAnnAssign> for StmtAnnAssign { + fn from(node: &'static ast::StmtAnnAssign) -> Self { + StmtAnnAssign(node) + } +} + +impl ToPyObject for StmtAnnAssign { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAnnAssign { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAnnAssign(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAnnAssign { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_annotation(&self, py: Python) -> PyResult { + self.0.annotation.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_simple(&self, py: Python) -> PyResult { + self.0.simple.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_For", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtFor(pub &'static ast::StmtFor); + +impl From<&'static ast::StmtFor> for StmtFor { + fn from(node: &'static ast::StmtFor) -> Self { + StmtFor(node) + } +} + +impl ToPyObject for StmtFor { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtFor { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtFor(self).to_object(py)) + } +} + +#[pymethods] +impl StmtFor { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_iter(&self, py: Python) -> PyResult { + self.0.iter.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_AsyncFor", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAsyncFor(pub &'static ast::StmtAsyncFor); + +impl From<&'static ast::StmtAsyncFor> for StmtAsyncFor { + fn from(node: &'static ast::StmtAsyncFor) -> Self { + StmtAsyncFor(node) + } +} + +impl ToPyObject for StmtAsyncFor { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAsyncFor { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAsyncFor(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAsyncFor { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_iter(&self, py: Python) -> PyResult { + self.0.iter.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_While", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtWhile(pub &'static ast::StmtWhile); + +impl From<&'static ast::StmtWhile> for StmtWhile { + fn from(node: &'static ast::StmtWhile) -> Self { + StmtWhile(node) + } +} + +impl ToPyObject for StmtWhile { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtWhile { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtWhile(self).to_object(py)) + } +} + +#[pymethods] +impl StmtWhile { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_If", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtIf(pub &'static ast::StmtIf); + +impl From<&'static ast::StmtIf> for StmtIf { + fn from(node: &'static ast::StmtIf) -> Self { + StmtIf(node) + } +} + +impl ToPyObject for StmtIf { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtIf { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtIf(self).to_object(py)) + } +} + +#[pymethods] +impl StmtIf { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_With", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtWith(pub &'static ast::StmtWith); + +impl From<&'static ast::StmtWith> for StmtWith { + fn from(node: &'static ast::StmtWith) -> Self { + StmtWith(node) + } +} + +impl ToPyObject for StmtWith { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtWith { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtWith(self).to_object(py)) + } +} + +#[pymethods] +impl StmtWith { + #[getter] + #[inline] + fn get_items(&self, py: Python) -> PyResult { + self.0.items.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_AsyncWith", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAsyncWith(pub &'static ast::StmtAsyncWith); + +impl From<&'static ast::StmtAsyncWith> for StmtAsyncWith { + fn from(node: &'static ast::StmtAsyncWith) -> Self { + StmtAsyncWith(node) + } +} + +impl ToPyObject for StmtAsyncWith { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAsyncWith { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAsyncWith(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAsyncWith { + #[getter] + #[inline] + fn get_items(&self, py: Python) -> PyResult { + self.0.items.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Match", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtMatch(pub &'static ast::StmtMatch); + +impl From<&'static ast::StmtMatch> for StmtMatch { + fn from(node: &'static ast::StmtMatch) -> Self { + StmtMatch(node) + } +} + +impl ToPyObject for StmtMatch { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtMatch { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtMatch(self).to_object(py)) + } +} + +#[pymethods] +impl StmtMatch { + #[getter] + #[inline] + fn get_subject(&self, py: Python) -> PyResult { + self.0.subject.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_cases(&self, py: Python) -> PyResult { + self.0.cases.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Raise", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtRaise(pub &'static ast::StmtRaise); + +impl From<&'static ast::StmtRaise> for StmtRaise { + fn from(node: &'static ast::StmtRaise) -> Self { + StmtRaise(node) + } +} + +impl ToPyObject for StmtRaise { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtRaise { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtRaise(self).to_object(py)) + } +} + +#[pymethods] +impl StmtRaise { + #[getter] + #[inline] + fn get_exc(&self, py: Python) -> PyResult { + self.0.exc.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_cause(&self, py: Python) -> PyResult { + self.0.cause.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Try", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtTry(pub &'static ast::StmtTry); + +impl From<&'static ast::StmtTry> for StmtTry { + fn from(node: &'static ast::StmtTry) -> Self { + StmtTry(node) + } +} + +impl ToPyObject for StmtTry { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtTry { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtTry(self).to_object(py)) + } +} + +#[pymethods] +impl StmtTry { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_handlers(&self, py: Python) -> PyResult { + self.0.handlers.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_finalbody(&self, py: Python) -> PyResult { + self.0.finalbody.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_TryStar", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtTryStar(pub &'static ast::StmtTryStar); + +impl From<&'static ast::StmtTryStar> for StmtTryStar { + fn from(node: &'static ast::StmtTryStar) -> Self { + StmtTryStar(node) + } +} + +impl ToPyObject for StmtTryStar { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtTryStar { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtTryStar(self).to_object(py)) + } +} + +#[pymethods] +impl StmtTryStar { + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_handlers(&self, py: Python) -> PyResult { + self.0.handlers.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_finalbody(&self, py: Python) -> PyResult { + self.0.finalbody.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Assert", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtAssert(pub &'static ast::StmtAssert); + +impl From<&'static ast::StmtAssert> for StmtAssert { + fn from(node: &'static ast::StmtAssert) -> Self { + StmtAssert(node) + } +} + +impl ToPyObject for StmtAssert { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtAssert { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtAssert(self).to_object(py)) + } +} + +#[pymethods] +impl StmtAssert { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_msg(&self, py: Python) -> PyResult { + self.0.msg.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Import", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtImport(pub &'static ast::StmtImport); + +impl From<&'static ast::StmtImport> for StmtImport { + fn from(node: &'static ast::StmtImport) -> Self { + StmtImport(node) + } +} + +impl ToPyObject for StmtImport { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtImport { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtImport(self).to_object(py)) + } +} + +#[pymethods] +impl StmtImport { + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_ImportFrom", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtImportFrom(pub &'static ast::StmtImportFrom); + +impl From<&'static ast::StmtImportFrom> for StmtImportFrom { + fn from(node: &'static ast::StmtImportFrom) -> Self { + StmtImportFrom(node) + } +} + +impl ToPyObject for StmtImportFrom { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtImportFrom { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtImportFrom(self).to_object(py)) + } +} + +#[pymethods] +impl StmtImportFrom { + #[getter] + #[inline] + fn get_module(&self, py: Python) -> PyResult { + self.0.module.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_level(&self, py: Python) -> PyResult { + self.0.level.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Global", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtGlobal(pub &'static ast::StmtGlobal); + +impl From<&'static ast::StmtGlobal> for StmtGlobal { + fn from(node: &'static ast::StmtGlobal) -> Self { + StmtGlobal(node) + } +} + +impl ToPyObject for StmtGlobal { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtGlobal { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtGlobal(self).to_object(py)) + } +} + +#[pymethods] +impl StmtGlobal { + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Nonlocal", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtNonlocal(pub &'static ast::StmtNonlocal); + +impl From<&'static ast::StmtNonlocal> for StmtNonlocal { + fn from(node: &'static ast::StmtNonlocal) -> Self { + StmtNonlocal(node) + } +} + +impl ToPyObject for StmtNonlocal { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtNonlocal { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtNonlocal(self).to_object(py)) + } +} + +#[pymethods] +impl StmtNonlocal { + #[getter] + #[inline] + fn get_names(&self, py: Python) -> PyResult { + self.0.names.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Expr", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtExpr(pub &'static ast::StmtExpr); + +impl From<&'static ast::StmtExpr> for StmtExpr { + fn from(node: &'static ast::StmtExpr) -> Self { + StmtExpr(node) + } +} + +impl ToPyObject for StmtExpr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtExpr { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtExpr(self).to_object(py)) + } +} + +#[pymethods] +impl StmtExpr { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Pass", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtPass(pub &'static ast::StmtPass); + +impl From<&'static ast::StmtPass> for StmtPass { + fn from(node: &'static ast::StmtPass) -> Self { + StmtPass(node) + } +} + +impl ToPyObject for StmtPass { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtPass { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtPass(self).to_object(py)) + } +} + +#[pymethods] +impl StmtPass {} + +#[pyclass(module="rustpython_ast.ranged", name="_Break", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtBreak(pub &'static ast::StmtBreak); + +impl From<&'static ast::StmtBreak> for StmtBreak { + fn from(node: &'static ast::StmtBreak) -> Self { + StmtBreak(node) + } +} + +impl ToPyObject for StmtBreak { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtBreak { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtBreak(self).to_object(py)) + } +} + +#[pymethods] +impl StmtBreak {} + +#[pyclass(module="rustpython_ast.ranged", name="_Continue", extends=Stmt, frozen)] +#[derive(Clone, Debug)] +pub struct StmtContinue(pub &'static ast::StmtContinue); + +impl From<&'static ast::StmtContinue> for StmtContinue { + fn from(node: &'static ast::StmtContinue) -> Self { + StmtContinue(node) + } +} + +impl ToPyObject for StmtContinue { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Stmt) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::StmtContinue { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(StmtContinue(self).to_object(py)) + } +} + +#[pymethods] +impl StmtContinue {} + +#[pyclass(module="rustpython_ast.ranged", name="_expr", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Expr; + +impl From<&'static ast::Expr> for Expr { + fn from(_node: &'static ast::Expr) -> Self { + Expr + } +} + +#[pymethods] +impl Expr { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for Expr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Expr { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::BoolOp(cons) => cons.to_py_wrapper(py), + Self::NamedExpr(cons) => cons.to_py_wrapper(py), + Self::BinOp(cons) => cons.to_py_wrapper(py), + Self::UnaryOp(cons) => cons.to_py_wrapper(py), + Self::Lambda(cons) => cons.to_py_wrapper(py), + Self::IfExp(cons) => cons.to_py_wrapper(py), + Self::Dict(cons) => cons.to_py_wrapper(py), + Self::Set(cons) => cons.to_py_wrapper(py), + Self::ListComp(cons) => cons.to_py_wrapper(py), + Self::SetComp(cons) => cons.to_py_wrapper(py), + Self::DictComp(cons) => cons.to_py_wrapper(py), + Self::GeneratorExp(cons) => cons.to_py_wrapper(py), + Self::Await(cons) => cons.to_py_wrapper(py), + Self::Yield(cons) => cons.to_py_wrapper(py), + Self::YieldFrom(cons) => cons.to_py_wrapper(py), + Self::Compare(cons) => cons.to_py_wrapper(py), + Self::Call(cons) => cons.to_py_wrapper(py), + Self::FormattedValue(cons) => cons.to_py_wrapper(py), + Self::JoinedStr(cons) => cons.to_py_wrapper(py), + Self::Constant(cons) => cons.to_py_wrapper(py), + Self::Attribute(cons) => cons.to_py_wrapper(py), + Self::Subscript(cons) => cons.to_py_wrapper(py), + Self::Starred(cons) => cons.to_py_wrapper(py), + Self::Name(cons) => cons.to_py_wrapper(py), + Self::List(cons) => cons.to_py_wrapper(py), + Self::Tuple(cons) => cons.to_py_wrapper(py), + Self::Slice(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_BoolOp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprBoolOp(pub &'static ast::ExprBoolOp); + +impl From<&'static ast::ExprBoolOp> for ExprBoolOp { + fn from(node: &'static ast::ExprBoolOp) -> Self { + ExprBoolOp(node) + } +} + +impl ToPyObject for ExprBoolOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprBoolOp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprBoolOp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprBoolOp { + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_values(&self, py: Python) -> PyResult { + self.0.values.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_NamedExpr", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprNamedExpr(pub &'static ast::ExprNamedExpr); + +impl From<&'static ast::ExprNamedExpr> for ExprNamedExpr { + fn from(node: &'static ast::ExprNamedExpr) -> Self { + ExprNamedExpr(node) + } +} + +impl ToPyObject for ExprNamedExpr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprNamedExpr { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprNamedExpr(self).to_object(py)) + } +} + +#[pymethods] +impl ExprNamedExpr { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_BinOp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprBinOp(pub &'static ast::ExprBinOp); + +impl From<&'static ast::ExprBinOp> for ExprBinOp { + fn from(node: &'static ast::ExprBinOp) -> Self { + ExprBinOp(node) + } +} + +impl ToPyObject for ExprBinOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprBinOp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprBinOp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprBinOp { + #[getter] + #[inline] + fn get_left(&self, py: Python) -> PyResult { + self.0.left.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_right(&self, py: Python) -> PyResult { + self.0.right.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_UnaryOp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprUnaryOp(pub &'static ast::ExprUnaryOp); + +impl From<&'static ast::ExprUnaryOp> for ExprUnaryOp { + fn from(node: &'static ast::ExprUnaryOp) -> Self { + ExprUnaryOp(node) + } +} + +impl ToPyObject for ExprUnaryOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprUnaryOp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprUnaryOp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprUnaryOp { + #[getter] + #[inline] + fn get_op(&self, py: Python) -> PyResult { + self.0.op.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_operand(&self, py: Python) -> PyResult { + self.0.operand.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Lambda", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprLambda(pub &'static ast::ExprLambda); + +impl From<&'static ast::ExprLambda> for ExprLambda { + fn from(node: &'static ast::ExprLambda) -> Self { + ExprLambda(node) + } +} + +impl ToPyObject for ExprLambda { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprLambda { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprLambda(self).to_object(py)) + } +} + +#[pymethods] +impl ExprLambda { + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_IfExp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprIfExp(pub &'static ast::ExprIfExp); + +impl From<&'static ast::ExprIfExp> for ExprIfExp { + fn from(node: &'static ast::ExprIfExp) -> Self { + ExprIfExp(node) + } +} + +impl ToPyObject for ExprIfExp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprIfExp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprIfExp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprIfExp { + #[getter] + #[inline] + fn get_test(&self, py: Python) -> PyResult { + self.0.test.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_orelse(&self, py: Python) -> PyResult { + self.0.orelse.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Dict", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprDict(pub &'static ast::ExprDict); + +impl From<&'static ast::ExprDict> for ExprDict { + fn from(node: &'static ast::ExprDict) -> Self { + ExprDict(node) + } +} + +impl ToPyObject for ExprDict { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprDict { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprDict(self).to_object(py)) + } +} + +#[pymethods] +impl ExprDict { + #[getter] + #[inline] + fn get_keys(&self, py: Python) -> PyResult { + self.0.keys.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_values(&self, py: Python) -> PyResult { + self.0.values.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Set", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSet(pub &'static ast::ExprSet); + +impl From<&'static ast::ExprSet> for ExprSet { + fn from(node: &'static ast::ExprSet) -> Self { + ExprSet(node) + } +} + +impl ToPyObject for ExprSet { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprSet { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSet(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSet { + #[getter] + #[inline] + fn get_elts(&self, py: Python) -> PyResult { + self.0.elts.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_ListComp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprListComp(pub &'static ast::ExprListComp); + +impl From<&'static ast::ExprListComp> for ExprListComp { + fn from(node: &'static ast::ExprListComp) -> Self { + ExprListComp(node) + } +} + +impl ToPyObject for ExprListComp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprListComp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprListComp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprListComp { + #[getter] + #[inline] + fn get_elt(&self, py: Python) -> PyResult { + self.0.elt.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_SetComp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSetComp(pub &'static ast::ExprSetComp); + +impl From<&'static ast::ExprSetComp> for ExprSetComp { + fn from(node: &'static ast::ExprSetComp) -> Self { + ExprSetComp(node) + } +} + +impl ToPyObject for ExprSetComp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprSetComp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSetComp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSetComp { + #[getter] + #[inline] + fn get_elt(&self, py: Python) -> PyResult { + self.0.elt.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_DictComp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprDictComp(pub &'static ast::ExprDictComp); + +impl From<&'static ast::ExprDictComp> for ExprDictComp { + fn from(node: &'static ast::ExprDictComp) -> Self { + ExprDictComp(node) + } +} + +impl ToPyObject for ExprDictComp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprDictComp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprDictComp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprDictComp { + #[getter] + #[inline] + fn get_key(&self, py: Python) -> PyResult { + self.0.key.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_GeneratorExp", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprGeneratorExp(pub &'static ast::ExprGeneratorExp); + +impl From<&'static ast::ExprGeneratorExp> for ExprGeneratorExp { + fn from(node: &'static ast::ExprGeneratorExp) -> Self { + ExprGeneratorExp(node) + } +} + +impl ToPyObject for ExprGeneratorExp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprGeneratorExp { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprGeneratorExp(self).to_object(py)) + } +} + +#[pymethods] +impl ExprGeneratorExp { + #[getter] + #[inline] + fn get_elt(&self, py: Python) -> PyResult { + self.0.elt.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_generators(&self, py: Python) -> PyResult { + self.0.generators.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Await", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprAwait(pub &'static ast::ExprAwait); + +impl From<&'static ast::ExprAwait> for ExprAwait { + fn from(node: &'static ast::ExprAwait) -> Self { + ExprAwait(node) + } +} + +impl ToPyObject for ExprAwait { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprAwait { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprAwait(self).to_object(py)) + } +} + +#[pymethods] +impl ExprAwait { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Yield", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprYield(pub &'static ast::ExprYield); + +impl From<&'static ast::ExprYield> for ExprYield { + fn from(node: &'static ast::ExprYield) -> Self { + ExprYield(node) + } +} + +impl ToPyObject for ExprYield { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprYield { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprYield(self).to_object(py)) + } +} + +#[pymethods] +impl ExprYield { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_YieldFrom", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprYieldFrom(pub &'static ast::ExprYieldFrom); + +impl From<&'static ast::ExprYieldFrom> for ExprYieldFrom { + fn from(node: &'static ast::ExprYieldFrom) -> Self { + ExprYieldFrom(node) + } +} + +impl ToPyObject for ExprYieldFrom { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprYieldFrom { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprYieldFrom(self).to_object(py)) + } +} + +#[pymethods] +impl ExprYieldFrom { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Compare", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprCompare(pub &'static ast::ExprCompare); + +impl From<&'static ast::ExprCompare> for ExprCompare { + fn from(node: &'static ast::ExprCompare) -> Self { + ExprCompare(node) + } +} + +impl ToPyObject for ExprCompare { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprCompare { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprCompare(self).to_object(py)) + } +} + +#[pymethods] +impl ExprCompare { + #[getter] + #[inline] + fn get_left(&self, py: Python) -> PyResult { + self.0.left.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ops(&self, py: Python) -> PyResult { + self.0.ops.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_comparators(&self, py: Python) -> PyResult { + self.0.comparators.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Call", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprCall(pub &'static ast::ExprCall); + +impl From<&'static ast::ExprCall> for ExprCall { + fn from(node: &'static ast::ExprCall) -> Self { + ExprCall(node) + } +} + +impl ToPyObject for ExprCall { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprCall { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprCall(self).to_object(py)) + } +} + +#[pymethods] +impl ExprCall { + #[getter] + #[inline] + fn get_func(&self, py: Python) -> PyResult { + self.0.func.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_keywords(&self, py: Python) -> PyResult { + self.0.keywords.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_FormattedValue", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprFormattedValue(pub &'static ast::ExprFormattedValue); + +impl From<&'static ast::ExprFormattedValue> for ExprFormattedValue { + fn from(node: &'static ast::ExprFormattedValue) -> Self { + ExprFormattedValue(node) + } +} + +impl ToPyObject for ExprFormattedValue { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprFormattedValue { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprFormattedValue(self).to_object(py)) + } +} + +#[pymethods] +impl ExprFormattedValue { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_conversion(&self, py: Python) -> PyResult { + self.0.conversion.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_format_spec(&self, py: Python) -> PyResult { + self.0.format_spec.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_JoinedStr", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprJoinedStr(pub &'static ast::ExprJoinedStr); + +impl From<&'static ast::ExprJoinedStr> for ExprJoinedStr { + fn from(node: &'static ast::ExprJoinedStr) -> Self { + ExprJoinedStr(node) + } +} + +impl ToPyObject for ExprJoinedStr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprJoinedStr { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprJoinedStr(self).to_object(py)) + } +} + +#[pymethods] +impl ExprJoinedStr { + #[getter] + #[inline] + fn get_values(&self, py: Python) -> PyResult { + self.0.values.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Constant", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprConstant(pub &'static ast::ExprConstant); + +impl From<&'static ast::ExprConstant> for ExprConstant { + fn from(node: &'static ast::ExprConstant) -> Self { + ExprConstant(node) + } +} + +impl ToPyObject for ExprConstant { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprConstant { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprConstant(self).to_object(py)) + } +} + +#[pymethods] +impl ExprConstant { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_kind(&self, py: Python) -> PyResult { + self.0.kind.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Attribute", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprAttribute(pub &'static ast::ExprAttribute); + +impl From<&'static ast::ExprAttribute> for ExprAttribute { + fn from(node: &'static ast::ExprAttribute) -> Self { + ExprAttribute(node) + } +} + +impl ToPyObject for ExprAttribute { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprAttribute { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprAttribute(self).to_object(py)) + } +} + +#[pymethods] +impl ExprAttribute { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_attr(&self, py: Python) -> PyResult { + self.0.attr.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Subscript", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSubscript(pub &'static ast::ExprSubscript); + +impl From<&'static ast::ExprSubscript> for ExprSubscript { + fn from(node: &'static ast::ExprSubscript) -> Self { + ExprSubscript(node) + } +} + +impl ToPyObject for ExprSubscript { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprSubscript { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSubscript(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSubscript { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_slice(&self, py: Python) -> PyResult { + self.0.slice.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Starred", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprStarred(pub &'static ast::ExprStarred); + +impl From<&'static ast::ExprStarred> for ExprStarred { + fn from(node: &'static ast::ExprStarred) -> Self { + ExprStarred(node) + } +} + +impl ToPyObject for ExprStarred { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprStarred { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprStarred(self).to_object(py)) + } +} + +#[pymethods] +impl ExprStarred { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Name", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprName(pub &'static ast::ExprName); + +impl From<&'static ast::ExprName> for ExprName { + fn from(node: &'static ast::ExprName) -> Self { + ExprName(node) + } +} + +impl ToPyObject for ExprName { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprName { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprName(self).to_object(py)) + } +} + +#[pymethods] +impl ExprName { + #[getter] + #[inline] + fn get_id(&self, py: Python) -> PyResult { + self.0.id.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_List", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprList(pub &'static ast::ExprList); + +impl From<&'static ast::ExprList> for ExprList { + fn from(node: &'static ast::ExprList) -> Self { + ExprList(node) + } +} + +impl ToPyObject for ExprList { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprList { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprList(self).to_object(py)) + } +} + +#[pymethods] +impl ExprList { + #[getter] + #[inline] + fn get_elts(&self, py: Python) -> PyResult { + self.0.elts.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Tuple", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprTuple(pub &'static ast::ExprTuple); + +impl From<&'static ast::ExprTuple> for ExprTuple { + fn from(node: &'static ast::ExprTuple) -> Self { + ExprTuple(node) + } +} + +impl ToPyObject for ExprTuple { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprTuple { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprTuple(self).to_object(py)) + } +} + +#[pymethods] +impl ExprTuple { + #[getter] + #[inline] + fn get_elts(&self, py: Python) -> PyResult { + self.0.elts.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ctx(&self, py: Python) -> PyResult { + self.0.ctx.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Slice", extends=Expr, frozen)] +#[derive(Clone, Debug)] +pub struct ExprSlice(pub &'static ast::ExprSlice); + +impl From<&'static ast::ExprSlice> for ExprSlice { + fn from(node: &'static ast::ExprSlice) -> Self { + ExprSlice(node) + } +} + +impl ToPyObject for ExprSlice { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Expr) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExprSlice { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExprSlice(self).to_object(py)) + } +} + +#[pymethods] +impl ExprSlice { + #[getter] + #[inline] + fn get_lower(&self, py: Python) -> PyResult { + self.0.lower.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_upper(&self, py: Python) -> PyResult { + self.0.upper.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_step(&self, py: Python) -> PyResult { + self.0.step.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_expr_context", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct ExprContext; + +impl From<&'static ast::ExprContext> for ExprContext { + fn from(_node: &'static ast::ExprContext) -> Self { + ExprContext + } +} + +#[pymethods] +impl ExprContext { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for ExprContext { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Load", extends=ExprContext)] +pub struct ExprContextLoad; + +impl ToPyObject for ExprContextLoad { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(ExprContext) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Store", extends=ExprContext)] +pub struct ExprContextStore; + +impl ToPyObject for ExprContextStore { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(ExprContext) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Del", extends=ExprContext)] +pub struct ExprContextDel; + +impl ToPyObject for ExprContextDel { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(ExprContext) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_boolop", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct BoolOp; + +impl From<&'static ast::BoolOp> for BoolOp { + fn from(_node: &'static ast::BoolOp) -> Self { + BoolOp + } +} + +#[pymethods] +impl BoolOp { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for BoolOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_And", extends=BoolOp)] +pub struct BoolOpAnd; + +impl ToPyObject for BoolOpAnd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(BoolOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Or", extends=BoolOp)] +pub struct BoolOpOr; + +impl ToPyObject for BoolOpOr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(BoolOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_operator", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Operator; + +impl From<&'static ast::Operator> for Operator { + fn from(_node: &'static ast::Operator) -> Self { + Operator + } +} + +#[pymethods] +impl Operator { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for Operator { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Add", extends=Operator)] +pub struct OperatorAdd; + +impl ToPyObject for OperatorAdd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Sub", extends=Operator)] +pub struct OperatorSub; + +impl ToPyObject for OperatorSub { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Mult", extends=Operator)] +pub struct OperatorMult; + +impl ToPyObject for OperatorMult { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatMult", extends=Operator)] +pub struct OperatorMatMult; + +impl ToPyObject for OperatorMatMult { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Div", extends=Operator)] +pub struct OperatorDiv; + +impl ToPyObject for OperatorDiv { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Mod", extends=Operator)] +pub struct OperatorMod; + +impl ToPyObject for OperatorMod { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Pow", extends=Operator)] +pub struct OperatorPow; + +impl ToPyObject for OperatorPow { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_LShift", extends=Operator)] +pub struct OperatorLShift; + +impl ToPyObject for OperatorLShift { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_RShift", extends=Operator)] +pub struct OperatorRShift; + +impl ToPyObject for OperatorRShift { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_BitOr", extends=Operator)] +pub struct OperatorBitOr; + +impl ToPyObject for OperatorBitOr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_BitXor", extends=Operator)] +pub struct OperatorBitXor; + +impl ToPyObject for OperatorBitXor { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_BitAnd", extends=Operator)] +pub struct OperatorBitAnd; + +impl ToPyObject for OperatorBitAnd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_FloorDiv", extends=Operator)] +pub struct OperatorFloorDiv; + +impl ToPyObject for OperatorFloorDiv { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Operator) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_unaryop", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct UnaryOp; + +impl From<&'static ast::UnaryOp> for UnaryOp { + fn from(_node: &'static ast::UnaryOp) -> Self { + UnaryOp + } +} + +#[pymethods] +impl UnaryOp { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for UnaryOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Invert", extends=UnaryOp)] +pub struct UnaryOpInvert; + +impl ToPyObject for UnaryOpInvert { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(UnaryOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Not", extends=UnaryOp)] +pub struct UnaryOpNot; + +impl ToPyObject for UnaryOpNot { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(UnaryOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_UAdd", extends=UnaryOp)] +pub struct UnaryOpUAdd; + +impl ToPyObject for UnaryOpUAdd { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(UnaryOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_USub", extends=UnaryOp)] +pub struct UnaryOpUSub; + +impl ToPyObject for UnaryOpUSub { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(UnaryOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_cmpop", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct CmpOp; + +impl From<&'static ast::CmpOp> for CmpOp { + fn from(_node: &'static ast::CmpOp) -> Self { + CmpOp + } +} + +#[pymethods] +impl CmpOp { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for CmpOp { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Eq", extends=CmpOp)] +pub struct CmpOpEq; + +impl ToPyObject for CmpOpEq { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_NotEq", extends=CmpOp)] +pub struct CmpOpNotEq; + +impl ToPyObject for CmpOpNotEq { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Lt", extends=CmpOp)] +pub struct CmpOpLt; + +impl ToPyObject for CmpOpLt { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_LtE", extends=CmpOp)] +pub struct CmpOpLtE; + +impl ToPyObject for CmpOpLtE { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Gt", extends=CmpOp)] +pub struct CmpOpGt; + +impl ToPyObject for CmpOpGt { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_GtE", extends=CmpOp)] +pub struct CmpOpGtE; + +impl ToPyObject for CmpOpGtE { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_Is", extends=CmpOp)] +pub struct CmpOpIs; + +impl ToPyObject for CmpOpIs { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_IsNot", extends=CmpOp)] +pub struct CmpOpIsNot; + +impl ToPyObject for CmpOpIsNot { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_In", extends=CmpOp)] +pub struct CmpOpIn; + +impl ToPyObject for CmpOpIn { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_NotIn", extends=CmpOp)] +pub struct CmpOpNotIn; + +impl ToPyObject for CmpOpNotIn { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(CmpOp) + .add_subclass(Self); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_comprehension", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct Comprehension(pub &'static ast::Comprehension); + +impl From<&'static ast::Comprehension> for Comprehension { + fn from(node: &'static ast::Comprehension) -> Self { + Comprehension(node) + } +} + +impl ToPyObject for Comprehension { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Comprehension { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Comprehension(self).to_object(py)) + } +} + +#[pymethods] +impl Comprehension { + #[getter] + #[inline] + fn get_target(&self, py: Python) -> PyResult { + self.0.target.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_iter(&self, py: Python) -> PyResult { + self.0.iter.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_ifs(&self, py: Python) -> PyResult { + self.0.ifs.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_is_async(&self, py: Python) -> PyResult { + self.0.is_async.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_excepthandler", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct ExceptHandler; + +impl From<&'static ast::ExceptHandler> for ExceptHandler { + fn from(_node: &'static ast::ExceptHandler) -> Self { + ExceptHandler + } +} + +#[pymethods] +impl ExceptHandler { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for ExceptHandler { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExceptHandler { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::ExceptHandler(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_ExceptHandler", extends=ExceptHandler, frozen)] +#[derive(Clone, Debug)] +pub struct ExceptHandlerExceptHandler(pub &'static ast::ExceptHandlerExceptHandler); + +impl From<&'static ast::ExceptHandlerExceptHandler> for ExceptHandlerExceptHandler { + fn from(node: &'static ast::ExceptHandlerExceptHandler) -> Self { + ExceptHandlerExceptHandler(node) + } +} + +impl ToPyObject for ExceptHandlerExceptHandler { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(ExceptHandler) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::ExceptHandlerExceptHandler { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(ExceptHandlerExceptHandler(self).to_object(py)) + } +} + +#[pymethods] +impl ExceptHandlerExceptHandler { + #[getter] + #[inline] + fn get_type(&self, py: Python) -> PyResult { + self.0.type_.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_arguments", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct Arguments(pub &'static ast::PythonArguments); + +impl From<&'static ast::PythonArguments> for Arguments { + fn from(node: &'static ast::PythonArguments) -> Self { + Arguments(node) + } +} + +impl ToPyObject for Arguments { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PythonArguments { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Arguments(self).to_object(py)) + } +} + +#[pymethods] +impl Arguments { + #[getter] + #[inline] + fn get_posonlyargs(&self, py: Python) -> PyResult { + self.0.posonlyargs.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_args(&self, py: Python) -> PyResult { + self.0.args.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_vararg(&self, py: Python) -> PyResult { + self.0.vararg.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwonlyargs(&self, py: Python) -> PyResult { + self.0.kwonlyargs.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_kw_defaults(&self, py: Python) -> PyResult { + self.0.kw_defaults.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwarg(&self, py: Python) -> PyResult { + self.0.kwarg.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_defaults(&self, py: Python) -> PyResult { + self.0.defaults.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_arg", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct Arg(pub &'static ast::Arg); + +impl From<&'static ast::Arg> for Arg { + fn from(node: &'static ast::Arg) -> Self { + Arg(node) + } +} + +impl ToPyObject for Arg { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Arg { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Arg(self).to_object(py)) + } +} + +#[pymethods] +impl Arg { + #[getter] + #[inline] + fn get_arg(&self, py: Python) -> PyResult { + self.0.arg.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_annotation(&self, py: Python) -> PyResult { + self.0.annotation.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_type_comment(&self, py: Python) -> PyResult { + self.0.type_comment.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_keyword", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct Keyword(pub &'static ast::Keyword); + +impl From<&'static ast::Keyword> for Keyword { + fn from(node: &'static ast::Keyword) -> Self { + Keyword(node) + } +} + +impl ToPyObject for Keyword { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Keyword { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Keyword(self).to_object(py)) + } +} + +#[pymethods] +impl Keyword { + #[getter] + #[inline] + fn get_arg(&self, py: Python) -> PyResult { + self.0.arg.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_alias", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct Alias(pub &'static ast::Alias); + +impl From<&'static ast::Alias> for Alias { + fn from(node: &'static ast::Alias) -> Self { + Alias(node) + } +} + +impl ToPyObject for Alias { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Alias { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(Alias(self).to_object(py)) + } +} + +#[pymethods] +impl Alias { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_asname(&self, py: Python) -> PyResult { + self.0.asname.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_withitem", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct WithItem(pub &'static ast::WithItem); + +impl From<&'static ast::WithItem> for WithItem { + fn from(node: &'static ast::WithItem) -> Self { + WithItem(node) + } +} + +impl ToPyObject for WithItem { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::WithItem { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(WithItem(self).to_object(py)) + } +} + +#[pymethods] +impl WithItem { + #[getter] + #[inline] + fn get_context_expr(&self, py: Python) -> PyResult { + self.0.context_expr.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_optional_vars(&self, py: Python) -> PyResult { + self.0.optional_vars.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_match_case", extends=super::Ast, frozen)] +#[derive(Clone, Debug)] +pub struct MatchCase(pub &'static ast::MatchCase); + +impl From<&'static ast::MatchCase> for MatchCase { + fn from(node: &'static ast::MatchCase) -> Self { + MatchCase(node) + } +} + +impl ToPyObject for MatchCase { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast).add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::MatchCase { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(MatchCase(self).to_object(py)) + } +} + +#[pymethods] +impl MatchCase { + #[getter] + #[inline] + fn get_pattern(&self, py: Python) -> PyResult { + self.0.pattern.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_guard(&self, py: Python) -> PyResult { + self.0.guard.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_body(&self, py: Python) -> PyResult { + self.0.body.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_pattern", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct Pattern; + +impl From<&'static ast::Pattern> for Pattern { + fn from(_node: &'static ast::Pattern) -> Self { + Pattern + } +} + +#[pymethods] +impl Pattern { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for Pattern { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::Pattern { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::MatchValue(cons) => cons.to_py_wrapper(py), + Self::MatchSingleton(cons) => cons.to_py_wrapper(py), + Self::MatchSequence(cons) => cons.to_py_wrapper(py), + Self::MatchMapping(cons) => cons.to_py_wrapper(py), + Self::MatchClass(cons) => cons.to_py_wrapper(py), + Self::MatchStar(cons) => cons.to_py_wrapper(py), + Self::MatchAs(cons) => cons.to_py_wrapper(py), + Self::MatchOr(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchValue", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchValue(pub &'static ast::PatternMatchValue); + +impl From<&'static ast::PatternMatchValue> for PatternMatchValue { + fn from(node: &'static ast::PatternMatchValue) -> Self { + PatternMatchValue(node) + } +} + +impl ToPyObject for PatternMatchValue { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchValue { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchValue(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchValue { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchSingleton", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchSingleton(pub &'static ast::PatternMatchSingleton); + +impl From<&'static ast::PatternMatchSingleton> for PatternMatchSingleton { + fn from(node: &'static ast::PatternMatchSingleton) -> Self { + PatternMatchSingleton(node) + } +} + +impl ToPyObject for PatternMatchSingleton { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchSingleton { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchSingleton(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchSingleton { + #[getter] + #[inline] + fn get_value(&self, py: Python) -> PyResult { + self.0.value.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchSequence", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchSequence(pub &'static ast::PatternMatchSequence); + +impl From<&'static ast::PatternMatchSequence> for PatternMatchSequence { + fn from(node: &'static ast::PatternMatchSequence) -> Self { + PatternMatchSequence(node) + } +} + +impl ToPyObject for PatternMatchSequence { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchSequence { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchSequence(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchSequence { + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchMapping", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchMapping(pub &'static ast::PatternMatchMapping); + +impl From<&'static ast::PatternMatchMapping> for PatternMatchMapping { + fn from(node: &'static ast::PatternMatchMapping) -> Self { + PatternMatchMapping(node) + } +} + +impl ToPyObject for PatternMatchMapping { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchMapping { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchMapping(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchMapping { + #[getter] + #[inline] + fn get_keys(&self, py: Python) -> PyResult { + self.0.keys.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_rest(&self, py: Python) -> PyResult { + self.0.rest.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchClass", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchClass(pub &'static ast::PatternMatchClass); + +impl From<&'static ast::PatternMatchClass> for PatternMatchClass { + fn from(node: &'static ast::PatternMatchClass) -> Self { + PatternMatchClass(node) + } +} + +impl ToPyObject for PatternMatchClass { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchClass { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchClass(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchClass { + #[getter] + #[inline] + fn get_cls(&self, py: Python) -> PyResult { + self.0.cls.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwd_attrs(&self, py: Python) -> PyResult { + self.0.kwd_attrs.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_kwd_patterns(&self, py: Python) -> PyResult { + self.0.kwd_patterns.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchStar", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchStar(pub &'static ast::PatternMatchStar); + +impl From<&'static ast::PatternMatchStar> for PatternMatchStar { + fn from(node: &'static ast::PatternMatchStar) -> Self { + PatternMatchStar(node) + } +} + +impl ToPyObject for PatternMatchStar { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchStar { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchStar(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchStar { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchAs", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchAs(pub &'static ast::PatternMatchAs); + +impl From<&'static ast::PatternMatchAs> for PatternMatchAs { + fn from(node: &'static ast::PatternMatchAs) -> Self { + PatternMatchAs(node) + } +} + +impl ToPyObject for PatternMatchAs { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchAs { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchAs(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchAs { + #[getter] + #[inline] + fn get_pattern(&self, py: Python) -> PyResult { + self.0.pattern.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_MatchOr", extends=Pattern, frozen)] +#[derive(Clone, Debug)] +pub struct PatternMatchOr(pub &'static ast::PatternMatchOr); + +impl From<&'static ast::PatternMatchOr> for PatternMatchOr { + fn from(node: &'static ast::PatternMatchOr) -> Self { + PatternMatchOr(node) + } +} + +impl ToPyObject for PatternMatchOr { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(Pattern) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::PatternMatchOr { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(PatternMatchOr(self).to_object(py)) + } +} + +#[pymethods] +impl PatternMatchOr { + #[getter] + #[inline] + fn get_patterns(&self, py: Python) -> PyResult { + self.0.patterns.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_type_ignore", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct TypeIgnore; + +impl From<&'static ast::TypeIgnore> for TypeIgnore { + fn from(_node: &'static ast::TypeIgnore) -> Self { + TypeIgnore + } +} + +#[pymethods] +impl TypeIgnore { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for TypeIgnore { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::TypeIgnore { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::TypeIgnore(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_TypeIgnore", extends=TypeIgnore, frozen)] +#[derive(Clone, Debug)] +pub struct TypeIgnoreTypeIgnore(pub &'static ast::TypeIgnoreTypeIgnore); + +impl From<&'static ast::TypeIgnoreTypeIgnore> for TypeIgnoreTypeIgnore { + fn from(node: &'static ast::TypeIgnoreTypeIgnore) -> Self { + TypeIgnoreTypeIgnore(node) + } +} + +impl ToPyObject for TypeIgnoreTypeIgnore { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(TypeIgnore) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::TypeIgnoreTypeIgnore { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(TypeIgnoreTypeIgnore(self).to_object(py)) + } +} + +#[pymethods] +impl TypeIgnoreTypeIgnore { + #[getter] + #[inline] + fn get_lineno(&self, py: Python) -> PyResult { + self.0.lineno.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_tag(&self, py: Python) -> PyResult { + self.0.tag.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_type_param", extends=super::Ast, frozen, subclass)] +#[derive(Clone, Debug)] +pub struct TypeParam; + +impl From<&'static ast::TypeParam> for TypeParam { + fn from(_node: &'static ast::TypeParam) -> Self { + TypeParam + } +} + +#[pymethods] +impl TypeParam { + #[new] + fn new() -> PyClassInitializer { + PyClassInitializer::from(Ast).add_subclass(Self) + } +} +impl ToPyObject for TypeParam { + fn to_object(&self, py: Python) -> PyObject { + let initializer = Self::new(); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::TypeParam { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match &self { + Self::TypeVar(cons) => cons.to_py_wrapper(py), + Self::ParamSpec(cons) => cons.to_py_wrapper(py), + Self::TypeVarTuple(cons) => cons.to_py_wrapper(py), + } + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_TypeVar", extends=TypeParam, frozen)] +#[derive(Clone, Debug)] +pub struct TypeParamTypeVar(pub &'static ast::TypeParamTypeVar); + +impl From<&'static ast::TypeParamTypeVar> for TypeParamTypeVar { + fn from(node: &'static ast::TypeParamTypeVar) -> Self { + TypeParamTypeVar(node) + } +} + +impl ToPyObject for TypeParamTypeVar { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(TypeParam) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::TypeParamTypeVar { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(TypeParamTypeVar(self).to_object(py)) + } +} + +#[pymethods] +impl TypeParamTypeVar { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } + + #[getter] + #[inline] + fn get_bound(&self, py: Python) -> PyResult { + self.0.bound.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_ParamSpec", extends=TypeParam, frozen)] +#[derive(Clone, Debug)] +pub struct TypeParamParamSpec(pub &'static ast::TypeParamParamSpec); + +impl From<&'static ast::TypeParamParamSpec> for TypeParamParamSpec { + fn from(node: &'static ast::TypeParamParamSpec) -> Self { + TypeParamParamSpec(node) + } +} + +impl ToPyObject for TypeParamParamSpec { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(TypeParam) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::TypeParamParamSpec { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(TypeParamParamSpec(self).to_object(py)) + } +} + +#[pymethods] +impl TypeParamParamSpec { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } +} + +#[pyclass(module="rustpython_ast.ranged", name="_TypeVarTuple", extends=TypeParam, frozen)] +#[derive(Clone, Debug)] +pub struct TypeParamTypeVarTuple(pub &'static ast::TypeParamTypeVarTuple); + +impl From<&'static ast::TypeParamTypeVarTuple> for TypeParamTypeVarTuple { + fn from(node: &'static ast::TypeParamTypeVarTuple) -> Self { + TypeParamTypeVarTuple(node) + } +} + +impl ToPyObject for TypeParamTypeVarTuple { + fn to_object(&self, py: Python) -> PyObject { + let initializer = PyClassInitializer::from(Ast) + .add_subclass(TypeParam) + .add_subclass(self.clone()); + Py::new(py, initializer).unwrap().into_py(py) + } +} + +impl ToPyWrapper for ast::TypeParamTypeVarTuple { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(TypeParamTypeVarTuple(self).to_object(py)) + } +} + +#[pymethods] +impl TypeParamTypeVarTuple { + #[getter] + #[inline] + fn get_name(&self, py: Python) -> PyResult { + self.0.name.to_py_wrapper(py) + } +} + +pub fn add_to_module(py: Python, m: &PyModule) -> PyResult<()> { + super::init_module(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + super::init_type::(py, m)?; + Ok(()) +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..65a336b --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,49 @@ +mod py_ast; +#[cfg(feature = "wrapper")] +pub mod wrapper; + +pub use py_ast::{init, PyNode, ToPyAst}; +use pyo3::prelude::*; +use rustpython_parser::ast::{source_code::LinearLocator, Fold}; + +#[pyfunction] +#[pyo3(signature = (source, filename="", *, type_comments=false, locate=true))] +pub fn parse<'py>( + source: &str, + filename: &str, + type_comments: bool, + locate: bool, + py: Python<'py>, +) -> PyResult<&'py PyAny> { + if type_comments { + todo!("'type_comments' is not implemented yet"); + } + let parsed = rustpython_parser::parse(source, rustpython_parser::Mode::Module, filename) + .map_err(|e| PyErr::new::(e.to_string()))?; + if locate { + let parsed = LinearLocator::new(source).fold(parsed).unwrap(); + parsed.module().unwrap().to_py_ast(py) + } else { + parsed.module().unwrap().to_py_ast(py) + } +} + +#[pymodule] +fn rustpython_ast(py: Python, m: &PyModule) -> PyResult<()> { + py_ast::init(py)?; + + #[cfg(feature = "wrapper")] + { + let ast = PyModule::new(py, "ast")?; + wrapper::located::add_to_module(py, ast)?; + m.add_submodule(ast)?; + + let ast = PyModule::new(py, "unlocated_ast")?; + wrapper::ranged::add_to_module(py, ast)?; + m.add_submodule(ast)?; + } + + m.add_function(wrap_pyfunction!(parse, m)?)?; + + Ok(()) +} diff --git a/src/py_ast.rs b/src/py_ast.rs new file mode 100644 index 0000000..6d2bb41 --- /dev/null +++ b/src/py_ast.rs @@ -0,0 +1,219 @@ +use num_complex::Complex64; +use num_traits::cast::ToPrimitive; +use once_cell::sync::OnceCell; +use pyo3::{ + prelude::*, + types::{PyBool, PyBytes, PyList, PyString, PyTuple}, + ToPyObject, +}; +use rustpython_ast::{ + self as ast, source_code::SourceRange, text_size::TextRange, ConversionFlag, Node, +}; + +pub trait PyNode { + fn py_type_cache() -> &'static OnceCell<(Py, Py)> { + { + static PY_TYPE: OnceCell<(Py, Py)> = OnceCell::new(); + &PY_TYPE + } + } +} + +pub trait ToPyAst { + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny>; +} + +impl ToPyAst for Box { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + (**self).to_py_ast(py) + } +} + +impl ToPyAst for Option { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + match self { + Some(ast) => ast.to_py_ast(py), + None => Ok(ast_cache().none_ref(py)), + } + } +} + +impl ToPyAst for Vec { + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let elts = self + .iter() + .map(|item| item.to_py_ast(py)) + .collect::, _>>()?; + let list = PyList::new(py, elts); + Ok(list.into()) + } +} + +impl ToPyAst for ast::Identifier { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + Ok(PyString::new(py, self.as_str()).into()) + } +} + +impl ToPyAst for ast::String { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + Ok(PyString::new(py, self.as_str()).into()) + } +} + +impl ToPyAst for bool { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + Ok(ast_cache().bool_int(py, *self)) + } +} + +impl ToPyAst for ConversionFlag { + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + Ok(ast_cache().conversion_flag(py, *self)) + } +} + +impl ToPyAst for ast::Arguments +where + R: Clone, + ast::PythonArguments: ToPyAst, +{ + #[inline] + fn to_py_ast<'py>(&self, py: Python<'py>) -> PyResult<&'py PyAny> { + let arguments = self.to_python_arguments(); + arguments.to_py_ast(py) + } +} + +fn constant_to_object(constant: &ast::Constant, py: Python) -> PyObject { + let cache = ast_cache(); + match constant { + ast::Constant::None => cache.none.clone_ref(py), + ast::Constant::Bool(bool) => cache.bool(py, *bool).into(), + ast::Constant::Str(string) => string.to_object(py), + ast::Constant::Bytes(bytes) => PyBytes::new(py, bytes).into(), + ast::Constant::Int(int) => match int.to_i64() { + Some(small_int) => small_int.to_object(py), + None => int.to_object(py), + }, + ast::Constant::Tuple(elts) => { + let elts: Vec<_> = elts.iter().map(|c| constant_to_object(c, py)).collect(); + PyTuple::new(py, elts).into() + } + ast::Constant::Float(f64) => f64.to_object(py), + ast::Constant::Complex { real, imag } => Complex64::new(*real, *imag).to_object(py), + ast::Constant::Ellipsis => py.Ellipsis(), + } +} + +#[pyclass(module = "rustpython_ast", subclass)] +pub struct Ast; + +#[pymethods] +impl Ast { + #[new] + fn new() -> Self { + Self + } +} + +fn cache_py_type(ast_module: &PyAny) -> PyResult<()> { + let class = ast_module.getattr(N::NAME)?; + let base = if std::mem::size_of::() == 0 { + class.call0()? + } else { + class.getattr("__new__")? + }; + N::py_type_cache().get_or_init(|| (class.into(), base.into())); + Ok(()) +} + +// TODO: This cache must be bound to 'py +struct AstCache { + lineno: Py, + col_offset: Py, + end_lineno: Py, + end_col_offset: Py, + none: Py, + bool_values: (Py, Py), + bool_int_values: (Py, Py), + conversion_flags: (Py, Py, Py, Py), +} + +impl AstCache { + // fn location_vec<'py>(&'static self, py: Python<'py>, range: &SourceRange) -> &'py PyDict { + // let attributes = PyDict::new(py); + // attributes.set_item(self.lineno.as_ref(py), range.start.row.get()).unwrap(); + // attributes.set_item(self.col_offset.as_ref(py), range.start.column.to_zero_indexed()).unwrap(); + // if let Some(end) = range.end { + // attributes.set_item(self.end_lineno.as_ref(py), end.row.get()).unwrap(); + // attributes.set_item( + // self.end_col_offset.as_ref(py), + // end.column.to_zero_indexed(), + // ).unwrap(); + // } + // attributes + // } + #[inline] + fn none_ref<'py>(&'static self, py: Python<'py>) -> &'py PyAny { + Py::::as_ref(&self.none, py) + } + #[inline] + fn bool_int<'py>(&'static self, py: Python<'py>, value: bool) -> &'py PyAny { + let v = &self.bool_int_values; + Py::::as_ref(if value { &v.1 } else { &v.0 }, py) + } + #[inline] + fn bool(&'static self, py: Python, value: bool) -> Py { + let v = &self.bool_values; + (if value { &v.1 } else { &v.0 }).clone_ref(py) + } + fn conversion_flag<'py>(&'static self, py: Python<'py>, value: ConversionFlag) -> &'py PyAny { + let v = &self.conversion_flags; + match value { + ConversionFlag::None => v.0.as_ref(py), + ConversionFlag::Str => v.1.as_ref(py), + ConversionFlag::Ascii => v.2.as_ref(py), + ConversionFlag::Repr => v.3.as_ref(py), + } + } +} + +fn ast_cache_cell() -> &'static OnceCell { + { + static PY_TYPE: OnceCell = OnceCell::new(); + &PY_TYPE + } +} + +fn ast_cache() -> &'static AstCache { + ast_cache_cell().get().unwrap() +} + +pub fn init(py: Python) -> PyResult<()> { + ast_cache_cell().get_or_init(|| AstCache { + lineno: pyo3::intern!(py, "lineno").into_py(py), + col_offset: pyo3::intern!(py, "col_offset").into_py(py), + end_lineno: pyo3::intern!(py, "end_lineno").into_py(py), + end_col_offset: pyo3::intern!(py, "end_col_offset").into_py(py), + none: py.None(), + bool_values: (PyBool::new(py, false).into(), PyBool::new(py, true).into()), + bool_int_values: ((0).to_object(py), (1).to_object(py)), + conversion_flags: ( + (-1).to_object(py), + (b's').to_object(py), + (b'a').to_object(py), + (b'r').to_object(py), + ), + }); + + init_types(py) +} + +include!("gen/to_py_ast.rs"); diff --git a/src/wrapper.rs b/src/wrapper.rs new file mode 100644 index 0000000..1ac8f1c --- /dev/null +++ b/src/wrapper.rs @@ -0,0 +1,153 @@ +use crate::PyNode; +use num_complex::Complex64; +use pyo3::prelude::*; +use pyo3::types::{PyBytes, PyList, PyTuple}; +use rustpython_ast::{ + self as ast, source_code::SourceRange, text_size::TextRange, ConversionFlag, Node, +}; + +pub trait ToPyWrapper { + fn to_py_wrapper(&'static self, py: Python) -> PyResult>; +} + +impl ToPyWrapper for Box { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + (**self).to_py_wrapper(py) + } +} + +impl ToPyWrapper for Option { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + match self { + Some(ast) => ast.to_py_wrapper(py), + None => Ok(py.None()), + } + } +} + +impl ToPyWrapper for ast::Identifier { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(self.as_str().to_object(py)) + } +} + +impl ToPyWrapper for ast::String { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok(self.as_str().to_object(py)) + } +} + +impl ToPyWrapper for ast::Int { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok((self.to_u32()).to_object(py)) + } +} + +impl ToPyWrapper for bool { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok((*self as u32).to_object(py)) + } +} + +impl ToPyWrapper for ConversionFlag { + #[inline] + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + Ok((*self as i8).to_object(py)) + } +} + +impl ToPyWrapper for ast::Constant { + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + let value = match self { + ast::Constant::None => py.None(), + ast::Constant::Bool(bool) => bool.to_object(py), + ast::Constant::Str(string) => string.to_object(py), + ast::Constant::Bytes(bytes) => PyBytes::new(py, bytes).into(), + ast::Constant::Int(int) => int.to_object(py), + ast::Constant::Tuple(elts) => { + let elts: PyResult> = elts.iter().map(|c| c.to_py_wrapper(py)).collect(); + PyTuple::new(py, elts?).into() + } + ast::Constant::Float(f64) => f64.to_object(py), + ast::Constant::Complex { real, imag } => Complex64::new(*real, *imag).to_object(py), + ast::Constant::Ellipsis => py.Ellipsis(), + }; + Ok(value) + } +} + +impl ToPyWrapper for Vec { + fn to_py_wrapper(&'static self, py: Python) -> PyResult> { + let list = PyList::empty(py); + for item in self { + let py_item = item.to_py_wrapper(py)?; + list.append(py_item)?; + } + Ok(list.into()) + } +} + +impl ToPyWrapper for ast::Arguments +where + Self: Clone, + ast::PythonArguments: ToPyWrapper, +{ + #[inline] + fn to_py_wrapper(&'static self, _py: Python) -> PyResult> { + todo!() + // Ok(FunctionArguments(self).to_object(py)) + } +} + +#[pyclass(module = "rustpython_ast", name = "AST", subclass)] +pub struct Ast; + +#[pymethods] +impl Ast { + #[new] + fn new() -> Self { + Self + } +} + +pub mod located { + pub use super::Ast; + use super::*; + include!("gen/wrapper_located.rs"); +} + +pub mod ranged { + pub use super::Ast; + use super::*; + include!("gen/wrapper_ranged.rs"); +} + +fn init_type(py: Python, m: &PyModule) -> PyResult<()> { + m.add_class::

()?; + let node = m.getattr(P::NAME)?; + if P::NAME != N::NAME { + // TODO: no idea how to escape rust keyword on #[pyclass] + m.setattr(P::NAME, node)?; + } + let names: Vec<&'static str> = N::FIELD_NAMES.to_vec(); + let fields = PyTuple::new(py, names); + node.setattr("_fields", fields)?; + Ok(()) +} + +/// A Python module implemented in Rust. +fn init_module(py: Python, m: &PyModule) -> PyResult<()> { + m.add_class::()?; + + let ast = m.getattr("AST")?; + let fields = PyTuple::empty(py); + ast.setattr("_fields", fields)?; + + Ok(()) +} diff --git a/test_ast.py b/test_ast.py new file mode 100644 index 0000000..e09d189 --- /dev/null +++ b/test_ast.py @@ -0,0 +1,56 @@ +import re +import difflib +import pytest + +import ast as py_ast +import rustpython_ast as rust_ast + + +from glob import glob + +files = {} +for path in glob("../../cpython/Lib/**/*.py"): + try: + txt = open(path, "r").read() + except UnicodeDecodeError: + continue + + # try: + # if py_ast.dump(py_ast.parse(txt)) != py_ast.dump(rust_ast.parse(txt)): + # continue + # except SyntaxError: + # continue + files[path] = txt + + +@pytest.mark.parametrize("path", files.keys()) +def test_roundtrip(path): + txt = files[path] + module_p = py_ast.parse(txt) + dump_p = py_ast.dump(module_p, indent=True) + module_r = rust_ast.parse(txt) + dump_r = py_ast.dump(module_r, indent=True) + p = re.compile("object at 0x[0-9a-f]+") + dump_p2 = re.sub(p, "object at 0x????????", dump_p) + dump_r2 = re.sub(p, "object at 0x????????", dump_r) + try: + assert dump_p2 == dump_r2 + except AssertionError: + last_sign = ' ' + for s in difflib.ndiff(dump_p2, dump_r2): + if s[0]==' ': continue + if s[0] == last_sign: + print(s[2:], end='') + else: + print() + print(s, end='') + last_sign = s[0] + # with open("dump_code.py", "w") as f: + # f.write(path) + # f.write('\n') + # f.write(txt) + # with open("dump_p.txt", "w") as f: + # f.write(dump_p2) + # with open("dump_r.txt", "w") as f: + # f.write(dump_r2) + raise