resonance 1.0.1
Loading...
Searching...
No Matches
Py::Tuple Class Reference

Handle on a Python tuple. More...

#include <tuple.h>

Inheritance diagram for Py::Tuple:
Collaboration diagram for Py::Tuple:

Public Member Functions

 Tuple (PyObject *pyob)
 Take a borrowed reference to an existing tuple.
 Tuple (int nSize)
 Create a tuple of a given length.
 Tuple (const Object &ob)
 Take another handle's reference as a tuple.
virtual void setItem (int i, const Object &value)
 Write one element.
virtual bool accepts (PyObject *pyob) const
 Accept only a tuple.
Public Member Functions inherited from Py::SeqBase< Object >
 SeqBase (const Object &ob)
 Take a new reference to an existing object as a sequence.
virtual int max_size () const
 Longest sequence this handle could address.
virtual int capacity () const
 Elements this handle could address without reallocating, which is its length.
virtual void swap (SeqBase< Object > &other)
 Exchange references with another handle of the same kind.
virtual int size () const
 Number of elements.
virtual Object getItem (int i) const
 Read one element.
int length () const
 Number of elements, read without the table.
seqref< Object > operator[] (int i)
 Address one element.
iterator begin ()
 Address the first element.
iterator end ()
 Address one past the last element.
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.

Additional Inherited Members

Public Attributes inherited from Py::Object
PyObject * mPtr
 Wrapped reference, null only between release() and the next assignment.
Protected Member Functions inherited from Py::SeqBase< Object >
 SeqBase ()
 Produce a handle on None for a derived class that fills it in afterwards.
 SeqBase (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.

Detailed Description

Handle on a Python tuple.

Its RTTI descriptor is at 0x00901d80. It has Py::SeqBase<Py::Object> at offset 0 as its one base. Its accessor is at 0x004c67e8.

The vtable at 0x00821c18 has nine entries, and only the type function, the destructor, accepts (), and slot 8 differ from the base table.

Slot Member Address
0 compiler-generated type function 0x004c67e8
1 compiler-generated destructor 0x004c6770
2 accepts 0x004c75c0
3 inherited max_size 0x0012ad48
4 inherited capacity 0x0012b378
5 inherited swap 0x0012b3a0
6 inherited size 0x0012b358
7 inherited getItem 0x0012ac48
8 setItem 0x004c7428

Constructor & Destructor Documentation

◆ Tuple() [1/3]

Py::Tuple::Tuple ( PyObject * pyob)
inlineexplicit

Take a borrowed reference to an existing tuple.

The routine takes two arguments and no third. Released PyCXX gives the same constructor an owned flag, and this build has none, which is one of the two established differences between the shipped binding and the release.

Parameters
pyobThe tuple to wrap.
Ghidra address:
NTSC-U/C: 0x004c5448
Ghidra address:
PAL: 0x005036d0

◆ Tuple() [2/3]

Py::Tuple::Tuple ( int nSize)
explicit

Create a tuple of a given length.

The base starts on an empty tuple. The body replaces it with a new tuple of the requested length through set() and fills every slot with None, throwing Py::Exception when a slot cannot be written. PyShell::ReportError() creates a two-element tuple this way.

Parameters
nSizeThe number of elements.
Ghidra address:
NTSC-U/C: 0x004c5690
Ghidra address:
PAL: 0x00503918

◆ Tuple() [3/3]

Py::Tuple::Tuple ( const Object & ob)
explicit

Take another handle's reference as a tuple.

The body is out of line. It belongs to the vendored binding and is not reconstructed.

Parameters
obThe handle to copy.
Ghidra address:
NTSC-U/C: 0x004c5568
Ghidra address:
PAL: 0x005037f0

Member Function Documentation

◆ setItem()

virtual void Py::Tuple::setItem ( int i,
const Object & value )
inlinevirtual

Write one element.

The override exists for the reference count. PyTuple_SetItem() steals a reference, so the body adds one before the call, where the base's PySequence_SetItem() path borrows and needs no such step.

Parameters
iThe index.
valueThe element to store.
Ghidra address:
NTSC-U/C: 0x004c7428
Ghidra address:
PAL: 0x00505650

Reimplemented from Py::SeqBase< Object >.

◆ accepts()

virtual bool Py::Tuple::accepts ( PyObject * pyob) const
inlinevirtual

Accept only a tuple.

Parameters
pyobThe reference to test.
Returns
True when the reference is a tuple.
Ghidra address:
NTSC-U/C: 0x004c75c0
Ghidra address:
PAL: 0x005057e8

Reimplemented from Py::SeqBase< Object >.


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