32 for (
auto it = cache.begin(); it != cache.end(); ++it) {
33 if (it->first == pyprop->
fOffset) {
35 Py_INCREF(it->second);
46 if (!address || (intptr_t)address == -1 )
55 if (!ptr || (intptr_t)ptr == -1 ) {
86 PyErr_Format(PyExc_NotImplementedError,
87 "no converter available for \"%s\"", pyprop->
GetName().c_str());
95 const int errret = -1;
99 PyErr_SetString(PyExc_TypeError,
"assignment to const data not allowed");
106 for (
auto it = cache.begin(); it != cache.end(); ++it) {
107 if (it->first == pyprop->
fOffset) {
108 Py_XDECREF(it->second);
115 intptr_t address = (intptr_t)pyprop->
GetAddress(pyobj);
116 if (!address || address == -1 )
120 void* ptr = (
void*)address;
129 if (!PyErr_Occurred())
130 PyErr_SetString(PyExc_RuntimeError,
"property type mismatch or assignment not allowed");
146 pyprop->
fName =
nullptr;
157 Py_XDECREF(pyprop->
fName);
166 (
char*)
"cppyy.CPPDataMember",
185 (
char*)
"cppyy data member (internal)",
210#
if PY_VERSION_HEX >= 0x02030000
213#
if PY_VERSION_HEX >= 0x02060000
216#
if PY_VERSION_HEX >= 0x03040000
232 std::vector<dim_t> dims;
238 if (ndim == 1) { dims.reserve(4); dims.push_back(0); }
239 dims.push_back(
size);
260 fEnclosingScope = scope;
262 fOffset = (intptr_t)address;
273 return (
void*)fOffset;
277 PyErr_SetString(PyExc_AttributeError,
"attribute access requires an instance");
283 PyErr_Format(PyExc_TypeError,
284 "object instance required for access to property \"%s\"", GetName().c_str());
290 PyErr_SetString(PyExc_ReferenceError,
"attempt to access a null-pointer");
295 ptrdiff_t offset = 0;
296 if (pyobj->
ObjectIsA() != fEnclosingScope)
299 return (
void*)((intptr_t)obj + offset + fOffset);
#define CPyCppyy_PyText_FromString
#define PyVarObject_HEAD_INIT(type, size)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
PyObject_HEAD intptr_t fOffset
Cppyy::TCppScope_t fEnclosingScope
void * GetAddress(CPPInstance *pyobj)
void Set(Cppyy::TCppScope_t scope, Cppyy::TCppIndex_t idata)
CI_DatamemberCache_t & GetDatamemberCache()
Cppyy::TCppType_t ObjectIsA(bool check_smart=true) const
virtual bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr)
virtual PyObject * FromMemory(void *address)
Set of helper functions that are invoked from the pythonizors, on the Python side.
static PyObject * pp_get(CPPDataMember *pyprop, CPPInstance *pyobj, PyObject *)
static int pp_set(CPPDataMember *pyprop, CPPInstance *pyobj, PyObject *value)
static void pp_dealloc(CPPDataMember *pyprop)
std::vector< std::pair< ptrdiff_t, PyObject * > > CI_DatamemberCache_t
bool LowLevelView_CheckExact(T *object)
bool CPPInstance_Check(T *object)
static CPPDataMember * pp_new(PyTypeObject *pytype, PyObject *, PyObject *)
PyTypeObject CPPDataMember_Type
CPYCPPYY_EXTERN Converter * CreateConverter(const std::string &name, Py_ssize_t *dims=nullptr)
RPY_EXPORTED ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
RPY_EXPORTED int GetDimensionSize(TCppScope_t scope, TCppIndex_t idata, int dimension)
RPY_EXPORTED intptr_t GetDatamemberOffset(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED bool IsEnumData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED bool IsStaticData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED bool IsConstData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED std::string ResolveEnum(const std::string &enum_type)
RPY_EXPORTED std::string GetDatamemberType(TCppScope_t scope, TCppIndex_t idata)