68 const HxStr name(pszName);
69 method_map_t &methodMap = methods();
70 if (name ==
"__methods__") {
72 for (
auto it = methodMap.begin(); it != methodMap.end(); ++it) {
77 if (methodMap.find(name) == methodMap.end()) {
105 if (pType ==
nullptr) {
107 pType->
dealloc(extension_object_deallocator);
113 typedef std::map<HxStr, MethodDefExt<T> *> method_map_t;
116 static method_map_t &methods() {
117 static method_map_t *pMethods =
nullptr;
118 if (pMethods ==
nullptr) {
119 pMethods =
new method_map_t;
125 static void extension_object_deallocator(PyObject *pyob) {
126 delete static_cast<T *
>(pyob);
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Exception for a missing attribute, mirroring Python's AttributeError.
Definition attributeerror.h:16
Temporary owner of a new reference returned by the CPython API.
Definition fromapi.h:25
PyObject * mPtr
Adopted reference, null when the API call failed.
Definition fromapi.h:55
Handle on a Python list.
Definition list.h:21
void append(const Object &ob)
Append one element.
Definition list.h:85
Method record of an extension type, keyed by name in PythonExtension::methods().
Definition methoddefext.h:20
PyMethodDef mExtMethodDef
The record handed to the interpreter.
Definition methoddefext.h:23
Reference-counted handle on any Python object, and the root of the PyCXX object hierarchy.
Definition object.h:42
PyObject * mPtr
Wrapped reference, null only between release() and the next assignment.
Definition object.h:191
Base of every C++ object the binding exposes to Python as an extension object.
Definition pythonextensionbase.h:33
static PyTypeObject * type_object()
Read the type object every instance of T shares.
Definition pythonextension.h:42
static PythonType & behaviors()
Build T's type object on first use.
Definition pythonextension.h:103
virtual Object getattr_methods(const char *pszName)
Resolve a method by name, or list the method names for __methods__.
Definition pythonextension.h:67
virtual ~PythonExtension()
Destroy the object.
Definition pythonextension.h:52
PythonExtension()
Start with one reference, typed as T.
Definition pythonextension.h:91
Builder for the CPython type object of an extension type.
Definition pythontype.h:20
PyTypeObject * type_object() const
Read the type object.
Definition pythontype.h:47
void dealloc(destructor pfnDealloc)
Set the deallocator.
Definition pythontype.h:58
Handle on a Python string.
Definition string.h:34
Handle on a Python tuple.
Definition tuple.h:31
Configuration header of the PyCXX binding layer.
C++ wrappers for the embedded Python interpreter's objects, types, and extension modules.
Definition attributeerror.h:7