18#include <structmember.h>
38 for (
auto it = cache.begin(); it != cache.end(); ++it) {
41 Py_INCREF(it->second);
52 if (!address || (intptr_t)address == -1 )
58 dm->
fFlags &= ~kIsEnumPrep;
69 PyObject* pyEnumType = PyObject_GetAttrString(pyscope,
70 enum_type.substr(enum_scope.size() ? enum_scope.size()+2 : 0, std::string::npos).c_str());
72 PyObject* pyval = PyObject_GetAttrString(pyEnumType,
73 lookup.substr(enum_type.size()+2, std::string::npos).c_str());
74 Py_DECREF(pyEnumType);
119 PyErr_Format(PyExc_NotImplementedError,
120 "no converter available for \"%s\"", dm->
GetName().c_str());
128 const int errret = -1;
134 PyErr_SetString(PyExc_TypeError,
"data member deletion is not supported");
147 PyErr_SetString(PyExc_TypeError,
"assignment to const data not allowed");
154 for (
auto it = cache.begin(); it != cache.end(); ++it) {
155 if (it->first == dm->
fOffset) {
156 Py_XDECREF(it->second);
163 intptr_t address = (intptr_t)dm->
GetAddress(pyobj);
164 if (!address || address == -1 )
168 void* ptr = (
void*)address;
177 if (!PyErr_Occurred())
178 PyErr_SetString(PyExc_RuntimeError,
"property type mismatch or assignment not allowed");
209 Py_XDECREF(dm->
fDoc);
217 {(
char*)
"__doc__", T_OBJECT, offsetof(
CPPDataMember, fDoc), 0,
218 (
char*)
"writable documentation"},
219 {NULL, 0, 0, 0,
nullptr}
228 if (!PyArg_ParseTuple(args,
const_cast<char*
>(
"i|i:__cpp_reflex__"), &request, &
format))
236 return PyLong_FromLong(dm->
fOffset);
239 PyErr_Format(PyExc_ValueError,
"unsupported reflex request %d or format %d", request,
format);
245 {(
char*)
"__cpp_reflex__", (PyCFunction)
dm_reflex, METH_VARARGS,
246 (
char*)
"C++ datamember reflection information" },
247 {(
char*)
nullptr,
nullptr, 0,
nullptr }
254 (
char*)
"cppyy.CPPDataMember",
273 (
char*)
"cppyy data member (internal)",
298#
if PY_VERSION_HEX >= 0x02030000
301#
if PY_VERSION_HEX >= 0x02060000
304#
if PY_VERSION_HEX >= 0x03040000
307#
if PY_VERSION_HEX >= 0x03080000
310#
if PY_VERSION_HEX >= 0x030c0000
313#
if PY_VERSION_HEX >= 0x030d0000
328 std::vector<dim_t> dims;
334 if (ndim == 1) dims.reserve(4);
343 if (
fFullType.find(
"(anonymous)") == std::string::npos &&
344 fFullType.find(
"(unnamed)") == std::string::npos) {
358 if (!dims.empty() &&
fFullType.back() !=
'*') {
377 fEnclosingScope = scope;
379 fOffset = (intptr_t)address;
382 fFullType =
"unsigned int";
391 return (
void*)fOffset;
395 PyErr_SetString(PyExc_AttributeError,
"attribute access requires an instance");
401 PyErr_Format(PyExc_TypeError,
402 "object instance required for access to property \"%s\"", GetName().c_str());
408 PyErr_SetString(PyExc_ReferenceError,
"attempt to access a null-pointer");
415 if (oisa != fEnclosingScope)
418 return (
void*)((intptr_t)obj +
offset + fOffset);
426 PyObject* repr = PyObject_Repr(fDescription);
436 return fullName.substr(fullName.rfind(
"::")+2, std::string::npos);
#define CPyCppyy_PyText_AsString
#define CPyCppyy_PyText_FromString
#define PyVarObject_HEAD_INIT(type, size)
std::ios_base::fmtflags fFlags
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
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)
std::string extract_namespace(const std::string &name)
PyObject * GetScopeProxy(Cppyy::TCppScope_t)
PyObject * CreateScopeProxy(Cppyy::TCppScope_t, const unsigned flags=0)
static PyObject * dm_get(CPPDataMember *dm, CPPInstance *pyobj, PyObject *)
std::vector< std::pair< ptrdiff_t, PyObject * > > CI_DatamemberCache_t
static const dim_t UNKNOWN_SIZE
bool LowLevelView_CheckExact(T *object)
bool CPPInstance_Check(T *object)
static void dm_dealloc(CPPDataMember *dm)
static PyMemberDef dm_members[]
static PyMethodDef dm_methods[]
static CPPDataMember * dm_new(PyTypeObject *pytype, PyObject *, PyObject *)
static int dm_set(CPPDataMember *dm, CPPInstance *pyobj, PyObject *value)
CPYCPPYY_EXTERN Converter * CreateConverter(const std::string &name, cdims_t=0)
static PyObject * dm_reflex(CPPDataMember *dm, PyObject *args)
PyTypeObject CPPDataMember_Type
const FormatId_t AS_STRING
RPY_EXPORTED ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
RPY_EXPORTED bool IsEnumData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED bool IsConstData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED TCppScope_t gGlobalScope
RPY_EXPORTED int GetDimensionSize(TCppScope_t scope, TCppIndex_t idata, int dimension)
RPY_EXPORTED std::string ResolveEnum(const std::string &enum_type)
RPY_EXPORTED bool IsNamespace(TCppScope_t scope)
RPY_EXPORTED bool IsStaticData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED std::string GetDatamemberType(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED TCppScope_t GetScope(const std::string &scope_name)
RPY_EXPORTED std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED intptr_t GetDatamemberOffset(TCppScope_t scope, TCppIndex_t idata)