|
resonance 1.0.1
|
Reference-counted handle on any Python object, and the root of the PyCXX object hierarchy. More...
#include <object.h>

Public Member Functions | |
| 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. | |
| virtual bool | accepts (PyObject *pyob) const |
| Whether a reference is acceptable for this handle's type. | |
| 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. | |
Public Attributes | |
| PyObject * | mPtr |
| Wrapped reference, null only between release() and the next assignment. | |
Protected Member Functions | |
| 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. | |
Reference-counted handle on any Python object, and the root of the PyCXX object hierarchy.
Its RTTI descriptor is at 0x0086f6f8. It has no base. The object is eight bytes, the reference at +0x00 and the vptr after it at +0x04. This compiler places the vptr of a class with no base after the data.
The vtable at 0x007cdd00 has three entries, and several translation units emit a private copy of the same three.
| Slot | Member | Address |
|---|---|---|
| 0 | compiler-generated type function | 0x0010ee30 |
| 1 | ~Object | 0x0010ee70 |
| 2 | accepts | 0x0010eee8 |
Every derived class in the hierarchy inherits those three slots and appends its own, so a slot index above 2 always belongs to a derived class.
Two differences from released PyCXX are established rather than assumed. The port has no owned constructor flag, and the constructor below always adds a reference; an owned reference arrives through Py::FromAPI instead. The port also replaced std::string with HxStr throughout.
|
inlineexplicit |
Take a borrowed reference and add a count of its own.
The default produces a handle on None, which is what a member of this type gets when its owner supplies no initialiser.
| pyob | The reference to wrap. |
|
inline |
Copy another handle and add a count of its own.
No out-of-line copy survives, because this compiler builds every returned Object directly in the caller's slot. The body comes instead from the inlined copy inside PyShell::ReportError() at 0x005082e0, where a Py::Callable is built from a temporary Py::Object and the three steps are all visible.
| other | The handle to copy. |
|
inlinevirtual |
Release the reference.
Replace the reference with another handle's.
| other | The handle to copy. |
|
inlinevirtual |
Whether a reference is acceptable for this handle's type.
The base test accepts any non-null reference, so a bare Object wraps anything. A derived class narrows it, and validate() enforces the narrowed test.
| pyob | The reference to test. |
Reimplemented in Py::Callable, Py::Char, Py::Dict, Py::Float, Py::Int, Py::List, Py::MapBase< T >, Py::MapBase< Object >, Py::SeqBase< T >, Py::SeqBase< Char >, Py::SeqBase< Object >, Py::String, Py::Tuple, and Py::Type.
Read one attribute.
Only the signature is recovered, from the call in PyShell::ReportError() that fetches traceback_str out of the hxutl module. The body is not worked out, so none is written.
| name | The attribute name. |
| String Py::Object::str | ( | ) | const |
Produce the text of str() applied to the object.
| HxStr Py::Object::as_string | ( | ) | const |
Produce the text of str() applied to the object, as a game string.
| Type Py::Object::type | ( | ) | const |
Produce the object's type.
| bool Py::Object::isType | ( | const Type & | type | ) | const |
Report whether the object's type is a given type.
| type | The type to compare with. |
|
inline |
Report whether the object is a tuple.
Inline. The type word is compared with PyTuple_Type without a null test, which is how MetHelpScreen::FillTexts() at 0x00313208 expands it.
|
inline |
Report whether the object is a list.
Inline, expanded the same way as isTuple().
|
inlineprotected |
Release the reference and empty the handle.
No address of its own survives. The body appears inlined in the destructor, and released PyCXX declares the member, so it is reconstructed here as the shared form.
|
inlineprotected |
Replace the reference with a borrowed one and add a count of its own.
The old reference is released before the new one is stored, and the handle is never left empty in between, which is why the body does not use release().
| pyob | The reference to wrap. |
|
inlineprotected |
Enforce this type's accepts() test on the stored reference.
A reference the type rejects is released first. A Python error already posted is then rethrown as a bare Py::Exception, because the interpreter already holds the detail; otherwise a Py::TypeError posts CXX: type error. and is thrown instead.
The message form settles the build configuration of the binding. Released PyCXX writes the failing type name into the message when run-time type information is available and falls back on this fixed text otherwise, and the image has the fixed text, so the binding was built with neither _CPPRTTI nor __GNUG__ reaching that block.
| PyObject* Py::Object::mPtr |
Wrapped reference, null only between release() and the next assignment.
Public because new_reference_to() and several call sites across the script layer read it directly and the image has no accessor for it. A trivial accessor and a public member compile to the same single load, so the evidence cannot distinguish them, and the public member adds no function that no address can be attached to.
+0x00