resonance 1.0.1
Loading...
Searching...
No Matches
Py::PythonExtension< T > Class Template Reference

Curiously recurring base that gives a C++ class its Python extension type. More...

#include <pythonextension.h>

Inheritance diagram for Py::PythonExtension< T >:
Collaboration diagram for Py::PythonExtension< T >:

Public Member Functions

virtual ~PythonExtension ()
 Destroy the object.
virtual Object getattr_methods (const char *pszName)
 Resolve a method by name, or list the method names for __methods__.
Public Member Functions inherited from Py::PythonExtensionBase
virtual ~PythonExtensionBase ()
 Destroy the object.
virtual int print (FILE *pFile, int nFlags)
 Print the object.
virtual Object getattr (const char *pszName)
 Read an attribute by name.
virtual int setattr (const char *pszName, const Object &value)
 Write an attribute by name.
virtual Object getattro (const Object &name)
 Read an attribute by name object.
virtual int setattro (const Object &name, const Object &value)
 Write an attribute by name object.
virtual int compare (const Object &other)
 Compare with another object.
virtual Object repr ()
 Produce the repr() text.
virtual Object str ()
 Produce the str() text.
virtual Py_LONG hash ()
 Produce the hash.
virtual Object call (const Object &args, const Object &keywords)
 Call the object.
virtual int sequence_length ()
 Report the sequence length.
virtual Object sequence_concat (const Object &other)
 Concatenate a sequence.
virtual Object sequence_repeat (int nCount)
 Repeat the sequence.
virtual Object sequence_item (int nIndex)
 Read one sequence element.
virtual Object sequence_slice (int nFirst, int nLast)
 Read a sequence slice.
virtual int sequence_ass_item (int nIndex, const Object &value)
 Write one sequence element.
virtual int sequence_ass_slice (int nFirst, int nLast, const Object &value)
 Write a sequence slice.
virtual int mapping_length ()
 Report the mapping length.
virtual Object mapping_subscript (const Object &key)
 Read one mapping entry.
virtual int mapping_ass_subscript (const Object &key, const Object &value)
 Write one mapping entry.
virtual int number_nonzero ()
 Report whether the number is nonzero.
virtual Object number_negative ()
 Negate the number.
virtual Object number_positive ()
 Apply unary plus.
virtual Object number_absolute ()
 Produce the absolute value.
virtual Object number_invert ()
 Invert the bits.
virtual Object number_int ()
 Convert to an integer.
virtual Object number_float ()
 Convert to a float.
virtual Object number_long ()
 Convert to a long integer.
virtual Object number_oct ()
 Produce the octal text.
virtual Object number_hex ()
 Produce the hexadecimal text.
virtual Object number_add (const Object &other)
 Add a number.
virtual Object number_subtract (const Object &other)
 Subtract a number.
virtual Object number_multiply (const Object &other)
 Multiply by a number.
virtual Object number_divide (const Object &other)
 Divide by a number.
virtual Object number_remainder (const Object &other)
 Produce the remainder.
virtual Object number_divmod (const Object &other)
 Produce the quotient and remainder.
virtual Object number_lshift (const Object &other)
 Shift left.
virtual Object number_rshift (const Object &other)
 Shift right.
virtual Object number_and (const Object &other)
 Apply bitwise and.
virtual Object number_xor (const Object &other)
 Apply bitwise exclusive or.
virtual Object number_or (const Object &other)
 Apply bitwise or.
virtual Object number_power (const Object &exponent, const Object &modulus)
 Raise to a power.
virtual int buffer_getreadbuffer (int nSegment, void **ppData)
 Expose a read buffer segment.
virtual int buffer_getwritebuffer (int nSegment, void **ppData)
 Expose a write buffer segment.
virtual int buffer_getsegcount (int *pnLength)
 Count the buffer segments.

Static Public Member Functions

static PyTypeObject * type_object ()
 Read the type object every instance of T shares.
Static Public Member Functions inherited from Py::PythonExtensionBase
static int print_handler (PyObject *self, FILE *pFile, int nFlags)
 Forward tp_print to print().
static Py_LONG hash_handler (PyObject *self)
 Forward tp_hash to hash().
static int sequence_length_handler (PyObject *self)
 Forward sq_length to sequence_length().
static int mapping_length_handler (PyObject *self)
 Forward mp_length to mapping_length().
static int number_nonzero_handler (PyObject *self)
 Forward nb_nonzero to number_nonzero().
static int buffer_getreadbuffer_handler (PyObject *self, int nSegment, void **ppData)
 Forward bf_getreadbuffer to buffer_getreadbuffer().
static int buffer_getwritebuffer_handler (PyObject *self, int nSegment, void **ppData)
 Forward bf_getwritebuffer to buffer_getwritebuffer().
static int buffer_getsegcount_handler (PyObject *self, int *pnLength)
 Forward bf_getsegcount to buffer_getsegcount().
static PyObject * sequence_concat_handler (PyObject *self, PyObject *other)
 Forward sq_concat to sequence_concat().
static PyObject * sequence_repeat_handler (PyObject *self, int nCount)
 Forward sq_repeat to sequence_repeat().
static PyObject * sequence_item_handler (PyObject *self, int nIndex)
 Forward sq_item to sequence_item().
static PyObject * sequence_slice_handler (PyObject *self, int nFirst, int nLast)
 Forward sq_slice to sequence_slice().
static int sequence_ass_item_handler (PyObject *self, int nIndex, PyObject *value)
 Forward sq_ass_item to sequence_ass_item().
static int sequence_ass_slice_handler (PyObject *self, int nFirst, int nLast, PyObject *value)
 Forward sq_ass_slice to sequence_ass_slice().
static PyObject * mapping_subscript_handler (PyObject *self, PyObject *key)
 Forward mp_subscript to mapping_subscript().
static int mapping_ass_subscript_handler (PyObject *self, PyObject *key, PyObject *value)
 Forward mp_ass_subscript to mapping_ass_subscript().

Protected Member Functions

 PythonExtension ()
 Start with one reference, typed as T.

Static Protected Member Functions

static PythonType & behaviors ()
 Build T's type object on first use.

Detailed Description

template<typename T>
class Py::PythonExtension< T >

Curiously recurring base that gives a C++ class its Python extension type.

One instantiation exists in the image, Py::PythonExtension<Py::ExtensionModuleBasePtr>, with its descriptor at 0x009029f0, deriving from Py::PythonExtensionBase at offset 0. Its type name string is at 0x00833450.

The one derived class is Py::ExtensionModuleBasePtr, which passes itself as the parameter, so the instantiation is the usual recurring-template shape.

The vtable at 0x00832ed8 repeats Py::PythonExtensionBase's and appends getattr_methods() as slot 47. The type function is at 0x005abd30 and the destructor at 0x005abf00.

Template Parameters
TThe extension type.

Constructor & Destructor Documentation

◆ ~PythonExtension()

template<typename T>
virtual Py::PythonExtension< T >::~PythonExtension ( )
inlinevirtual

Destroy the object.

Ghidra address:
NTSC-U/C: 0x005abf00
Ghidra address:
PAL: 0x005ee428

◆ PythonExtension()

template<typename T>
Py::PythonExtension< T >::PythonExtension ( )
inlineprotected

Start with one reference, typed as T.

Member Function Documentation

◆ type_object()

template<typename T>
PyTypeObject * Py::PythonExtension< T >::type_object ( )
inlinestatic

Read the type object every instance of T shares.

Returns
The type object.

◆ getattr_methods()

template<typename T>
virtual Object Py::PythonExtension< T >::getattr_methods ( const char * pszName)
inlinevirtual

Resolve a method by name, or list the method names for __methods__.

A name is looked up in methods() first, and a missing name posts and throws Py::AttributeError. A found name produces a bound built-in function whose self is the pair of this object and the name.

Parameters
pszNameThe attribute name.
Returns
The list of names, or the bound function.
Ghidra address:
NTSC-U/C: 0x005ad5e0
Ghidra address:
PAL: 0x005efb08

◆ behaviors()

template<typename T>
PythonType & Py::PythonExtension< T >::behaviors ( )
inlinestaticprotected

Build T's type object on first use.

Returns
The type object builder.
Ghidra address:
NTSC-U/C: 0x005abe70
Ghidra address:
PAL: 0x005ee398

The documentation for this class was generated from the following file: