|
resonance 1.0.1
|
Handle on a Python module. More...
#include <module.h>


Public Member Functions | |
| Module (const HxStr &name) | |
| Import a module by name and wrap it. | |
| Dict | getDict () const |
| Produce a handle on the module's namespace. | |
| 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. | |
| 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. | |
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::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. | |
Handle on a Python module.
Its RTTI descriptor is at 0x008f0930. It has Py::Object at offset 0 as its one base. Its accessor is at 0x005ab958.
The vtable at 0x008257d8, copied at 0x00833228, has three entries, and slot 2 repeats Py::Object's own address.
| Slot | Member | Address |
|---|---|---|
| 0 | compiler-generated type function | 0x0050d408 |
| 1 | compiler-generated destructor | 0x0050d390 |
| 2 | inherited accepts | 0x0010eee8 |
The inherited slot is the interesting one. Every other narrowing class in the hierarchy overrides accepts(), and this class does not, so a Py::Module accepts any non-null reference. That is surprising rather than wrong, and it is recorded here so that a reader does not mistake the missing override for an omission in the reconstruction.
|
inlineexplicit |
Import a module by name and wrap it.
The interpreter call is PyImport_ImportModule() rather than PyImport_AddModule(), which released PyCXX uses. Recovered from PyShell's constructor, which imports __main__ this way with the body inlined. The out-of-line copy is never called. set() adds a count to the new reference the import returns. Every import through this constructor therefore retains one extra reference to the module.
| name | The module name. An empty string arrives at the interpreter as g_szEmptyString rather than as a null pointer. |
|
inline |
Produce a handle on the module's namespace.
Recovered from PyShell's constructor. The body is inlined at that site and has no address of its own.