From 58ea174eb2e8d4426a4635f1ee02b4acb1088259 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 3 Aug 2024 21:50:19 +0200 Subject: [PATCH] interrogate: Use the limited Python API for simple Python back-end --- dtool/src/interrogate/interfaceMakerPythonSimple.cxx | 12 ++++++++++++ dtool/src/interrogate/interfaceMakerPythonSimple.h | 1 + 2 files changed, 13 insertions(+) diff --git a/dtool/src/interrogate/interfaceMakerPythonSimple.cxx b/dtool/src/interrogate/interfaceMakerPythonSimple.cxx index cda042efd7..637e6eefad 100644 --- a/dtool/src/interrogate/interfaceMakerPythonSimple.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonSimple.cxx @@ -42,6 +42,18 @@ InterfaceMakerPythonSimple:: ~InterfaceMakerPythonSimple() { } +/** + * Generates the list of #include ... whatever that's required by this + * particular interface to the indicated output stream. + */ +void InterfaceMakerPythonSimple:: +write_includes(std::ostream &out) { + out << "#if PY_VERSION_HEX >= 0x30300000\n"; + out << "#define Py_LIMITED_API 0x30300000\n"; + out << "#endif\n\n"; + InterfaceMakerPython::write_includes(out); +} + /** * Generates the list of function prototypes corresponding to the functions * that will be output in write_functions(). diff --git a/dtool/src/interrogate/interfaceMakerPythonSimple.h b/dtool/src/interrogate/interfaceMakerPythonSimple.h index 18cfc4d590..6e6621ea6d 100644 --- a/dtool/src/interrogate/interfaceMakerPythonSimple.h +++ b/dtool/src/interrogate/interfaceMakerPythonSimple.h @@ -35,6 +35,7 @@ public: InterfaceMakerPythonSimple(InterrogateModuleDef *def); virtual ~InterfaceMakerPythonSimple(); + virtual void write_includes(std::ostream &out); virtual void write_prototypes(std::ostream &out,std::ostream *out_h); virtual void write_functions(std::ostream &out);