33 PyErr_Format(PyExc_RuntimeError,
"Failed to create new object at index %d of TClonesArray", index);
37 auto baseOffset = obj->IsA()->GetBaseClassOffset(
TObject::Class());
38 auto newObj = (
TObject *)(arrObj + baseOffset);
43 const_cast<TObject *
>(obj)->Streamer(buffer);
50 newObj->Streamer(buffer);
67 PyErr_SetString(PyExc_RuntimeError,
"unable to get the size of TClonesArray");
73 if (idx >= size || (idx < 0 && idx < -size)) {
74 PyErr_SetString(PyExc_IndexError,
"index out of range");
83 pyindex = PyLong_FromSsize_t(size + idx);
95 if (!PyArg_ParseTuple(args,
const_cast<char *
>(
"OO!:__setitem__"), &idx, &
CPPInstance_Type, &pyobj))
99 PyErr_SetString(PyExc_TypeError,
"unsubscriptable object");
106 auto index = (
int)PyLong_AsLong(pyindex);
113 PyErr_SetString(PyExc_TypeError,
"attempt to call with null object");
118 PyErr_Format(PyExc_TypeError,
"require object of type %s, but %s given", cla->GetClass()->GetName(),
134 auto pyclass = PyObject_GetAttrString((
PyObject*)pyobj,
"__class__");
135 MemoryRegulator::UnregisterPyObject(pyobj, pyclass);
139 if (pyobj->fFlags & CPPInstance::kIsOwner)
140 delete static_cast<TObject *
>(pyobj->GetObject());
144 MemoryRegulator::RegisterPyObject(pyobj,
object);
169 PyObject *pyclass = PyTuple_GetItem(args, 0);
TClass * GetTClass(const CPyCppyy::CPPInstance *pyobj)
PyObject * CallPyObjMethod(PyObject *obj, const char *meth)
Set of helper functions that are invoked from the C++ implementation of pythonizations.
static PyObject * PyStyleIndex(PyObject *self, PyObject *index)
PyObject * SetItem(CPPInstance *self, PyObject *args)
static TObject * CloneObjectInPlace(const TObject *obj, TClonesArray *cla, int index)
Cppyy::TCppType_t ObjectIsA(bool check_smart=true) const
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
void MapObject(const TObject *obj, UInt_t offset=1) override
Add object to the fMap container.
void ResetMap() override
Delete existing fMap and reset map counter.
void SetBufferOffset(Int_t offset=0)
void SetReadMode()
Set buffer in read mode.
void * DynamicCast(const TClass *base, void *obj, Bool_t up=kTRUE)
Cast obj of this class type up to baseclass cl if up is true.
Int_t Size() const
Return size of object of this class.
An array of clone (identical) objects.
TClass * GetClass() const
virtual TObject * RemoveAt(Int_t idx)
Remove object at index idx.
TObject * ConstructedAt(Int_t idx)
Get an object at index 'idx' that is guaranteed to have been constructed.
Mother of all ROOT objects.
bool AddToClass(PyObject *pyclass, const char *label, PyCFunction cfunc, int flags=METH_VARARGS)
PyTypeObject CPPInstance_Type
RPY_EXPORTED std::string GetFinalName(TCppType_t type)
RPY_EXPORTED TCppScope_t GetScope(const std::string &scope_name)
PyObject * AddSetItemTCAPyz(PyObject *self, PyObject *args)
Customize the setting of an item of a TClonesArray.