|
resonance 1.0.1
|
Handle on any Python sequence, and the base of Py::List, Py::Tuple, and Py::String. More...
#include <seqbase.h>


Classes | |
| class | iterator |
| Position within a sequence, as PyCXX's SeqBase<T>::iterator is laid out. More... | |
Public Member Functions | |
| SeqBase (const Object &ob) | |
| Take a new reference to an existing object as a sequence. | |
| virtual bool | accepts (PyObject *pyob) const |
| Accept any reference the sequence protocol supports. | |
| 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< T > &other) |
| Exchange references with another handle of the same kind. | |
| virtual int | size () const |
| Number of elements. | |
| virtual T | getItem (int i) const |
| Read one element. | |
| virtual void | setItem (int i, const T &value) |
| Write one element. | |
| int | length () const |
| Number of elements, read without the table. | |
| seqref< T > | 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. | |
Protected Member Functions | |
| 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. | |
Additional Inherited Members | |
| Public Attributes inherited from Py::Object | |
| PyObject * | mPtr |
| Wrapped reference, null only between release() and the next assignment. | |
Handle on any Python sequence, and the base of Py::List, Py::Tuple, and Py::String.
Two instantiations exist in the image. Py::SeqBase<Py::Object> has its descriptor at 0x00902990, and Py::SeqBase<Py::Char> has its descriptor at 0x00902000. Both derive from Py::Object at offset 0.
The vtable has nine entries, the three Py::Object slots plus six of its own. The six below are declared in table order, and that order is itself corroboration: released PyCXX declares max_size, capacity, swap, and size in exactly this sequence ahead of the element accessors.
| Slot | Member | SeqBase<Object> | SeqBase<Char> |
|---|---|---|---|
| 0 | compiler-generated type function | 0x0012abd0 | 0x004c64e8 |
| 1 | inherited destructor | 0x0012ab58 | 0x004c6470 |
| 2 | accepts | 0x0012b328 | 0x004c7c30 |
| 3 | max_size | 0x0012ad48 | 0x004c7260 |
| 4 | capacity | 0x0012b378 | 0x004c7c80 |
| 5 | swap | 0x0012b3a0 | 0x004c7890 |
| 6 | size | 0x0012b358 | 0x004c73d0 |
| 7 | getItem | 0x0012ac48 | 0x004c7a48 |
| 8 | setItem | 0x0012b4d0 | 0x004c7bb8 |
The three vtables for SeqBase<Object> at 0x007d0ff0, 0x00821c68, and 0x00825878 are identical copies that the linker did not fold. SeqBase<Char> sits at 0x00821d08.
|
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 a derived default constructor establishes. This compiler omits the intermediate vptr store when the intermediate constructor runs no code between the two stores.
|
inlineexplicitprotected |
Take a borrowed reference on behalf of a derived class.
Recovered from Py::Tuple's constructor at 0x004c5448, where the three vptr stores and the three validate() calls of the chain are all visible in one routine.
| pyob | The reference to wrap. |
|
inlineexplicit |
Take a new reference to an existing object as a sequence.
Inline. The configuration queries at 0x00509b78 and 0x0050a1a0 expand it as Object's copy, Object's validate(), the store of this class's vptr, and this class's validate(). MetNullRenderer::OnRawController() at 0x0030e4c0 expands it the same way, with the 0x007d0ff0 vptr.
| ob | The object to wrap. |
|
inlinevirtual |
Accept any reference the sequence protocol supports.
| pyob | The reference to test. |
Reimplemented from Py::Object.
Reimplemented in Py::List, Py::String, and Py::Tuple.
|
virtual |
Longest sequence this handle could address.
The routine is three instructions and loads one word, the shared not-found sentinel at 0x008211bc, which is 0xffffffff. That word sits in HxStr's own literal pool, one word past the empty string the string class returns for a null buffer, and four routines outside the binding read it as well, among them RndText::BuildGlyphMesh(). It is HxStr's npos, and released PyCXX returns std::string::npos from the same member, which is what settles the reading.
The bodies are explicit specialisations that read the sentinel from os/hxstr.h.
|
inlinevirtual |
Elements this handle could address without reallocating, which is its length.
The routine tail-calls slot 6 through the table, so the value tracks size() in a derived class that narrows either one. Py::String overrides it to return max_size() instead.
Reimplemented in Py::List, and Py::String.
|
virtual |
Exchange references with another handle of the same kind.
Copies the argument into a temporary handle, gives the argument this handle's reference unless the two already match, and then takes the temporary's reference through set(). Each set() runs validate(). A reference the receiving type rejects throws.
| other | The handle to exchange with. |
|
virtual |
Number of elements.
The two instantiations do not share a body, and that is the one finding here worth pausing on. SeqBase<Object> calls PySequence_Length() at 0x004a53f0 and SeqBase<Char> calls PyString_Size() at 0x005a1ca0, so a single template body cannot produce both. Whether the port wrote an explicit specialisation or routed the call through the element type is not recovered. The bodies are explicit specialisations.
|
inlinevirtual |
Read one element.
The new reference from the interpreter is adopted through a Py::FromAPI temporary, so the returned handle owns exactly one count.
| i | The index. |
|
inlinevirtual |
Write one element.
| i | The index. |
| value | The element to store. |
Reimplemented in Py::Tuple.
|
inline |
Number of elements, read without the table.
Inline. Unlike size(), the call goes straight to PySequence_Length() at 0x004a53f0, which is how MetHelpScreen::FillTexts() at 0x00313208 expands it.
|
inline |
Address one element.
Inline. The proxy fetches the element through getItem() as it is built.
| i | The index. |
|
inline |
Address the first element.
|
inline |
Address one past the last element.