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

Handle on any Python mapping, and the base of Py::Dict. More...

#include <mapbase.h>

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

Public Member Functions

virtual bool accepts (PyObject *pyob) const
 Accept any reference the mapping protocol supports.
virtual void setItem (const HxStr &key, const Object &value)
 Store a value under a name.
virtual void setItem (const Object &key, const Object &value)
 Store a value under a key object.
Public Member Functions inherited from Py::Object
 Object (PyObject *pyob=Py_None)
 Take a borrowed reference and add a count of its own.
 Object (const Object &other)
 Copy another handle and add a count of its own.
virtual ~Object ()
 Release the reference.
Object & operator= (const Object &other)
 Replace the reference with another handle's.
Object getAttr (const HxStr &name) const
 Read one attribute.
String str () const
 Produce the text of str() applied to the object.
HxStr as_string () const
 Produce the text of str() applied to the object, as a game string.
Type type () const
 Produce the object's type.
bool isType (const Type &type) const
 Report whether the object's type is a given type.
bool isTuple () const
 Report whether the object is a tuple.
bool isList () const
 Report whether the object is a list.

Protected Member Functions

 MapBase ()
 Produce a handle on None for a derived class that fills it in afterwards.
 MapBase (PyObject *pyob)
 Take a borrowed reference on behalf of a derived class.
Protected Member Functions inherited from Py::Object
void release ()
 Release the reference and empty the handle.
void set (PyObject *pyob)
 Replace the reference with a borrowed one and add a count of its own.
void validate ()
 Enforce this type's accepts() test on the stored reference.

Additional Inherited Members

Public Attributes inherited from Py::Object
PyObject * mPtr
 Wrapped reference, null only between release() and the next assignment.

Detailed Description

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

Handle on any Python mapping, and the base of Py::Dict.

One instantiation exists in the image, Py::MapBase<Py::Object>, with its descriptor at 0x009029a0, deriving from Py::Object at offset 0.

The vtable at 0x00825848, copied at 0x00833278, has five entries, the three Py::Object slots plus two of its own.

Slot Member Address
0 compiler-generated type function 0x0050d0b0
1 inherited destructor 0x0050d038
2 accepts 0x0050d7f8
3 setItem taking a name 0x0050d6f8
4 setItem taking a key object 0x0050d780

Both setItem() bodies are shared with Py::Dict rather than overridden, so the derived table repeats the same two addresses.

Released PyCXX declares a reading half as well, with size(), getItem(), and a mapping reference proxy. None of it is in the table, so none is reconstructed. The image therefore establishes that this instantiation is write-only.

Constructor & Destructor Documentation

◆ MapBase() [1/2]

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

Produce a handle on None for a derived class that fills it in afterwards.

The body is empty, which is what the folded vptr write in Py::Dict's default constructor establishes. This compiler omits the intermediate vptr store when the intermediate constructor runs no code between the two stores.

◆ MapBase() [2/2]

template<typename T>
Py::MapBase< T >::MapBase ( PyObject * pyob)
inlineexplicitprotected

Take a borrowed reference on behalf of a derived class.

Parameters
pyobThe reference to wrap.

Member Function Documentation

◆ accepts()

template<typename T>
virtual bool Py::MapBase< T >::accepts ( PyObject * pyob) const
inlinevirtual

Accept any reference the mapping protocol supports.

Parameters
pyobThe reference to test.
Returns
True when the reference is a mapping.
Ghidra address:
NTSC-U/C: 0x0050d7f8
Ghidra address:
PAL: 0x0054ccb0

Reimplemented from Py::Object.

Reimplemented in Py::Dict.

◆ setItem() [1/2]

template<typename T>
virtual void Py::MapBase< T >::setItem ( const HxStr & key,
const Object & value )
inlinevirtual

Store a value under a name.

Parameters
keyThe key, as text. An empty string arrives at the interpreter as g_szEmptyString rather than as a null pointer.
valueThe value to store.
Ghidra address:
NTSC-U/C: 0x0050d6f8
Ghidra address:
PAL: 0x0054cbb0

◆ setItem() [2/2]

template<typename T>
virtual void Py::MapBase< T >::setItem ( const Object & key,
const Object & value )
inlinevirtual

Store a value under a key object.

Parameters
keyThe key.
valueThe value to store.
Ghidra address:
NTSC-U/C: 0x0050d780
Ghidra address:
PAL: 0x0054cc38

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