[ctypes-commit] ctypes/source _ctypes.c,1.336,1.337
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2006-06-09 18:04:54
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv19110 Modified Files: _ctypes.c Log Message: Remove the restriction that pointer item assignments only work with index of zero. Another fix for the cast function to keep needed objects alive. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.336 retrieving revision 1.337 diff -C2 -d -r1.336 -r1.337 *** _ctypes.c 9 Jun 2006 07:09:10 -0000 1.336 --- _ctypes.c 9 Jun 2006 18:04:45 -0000 1.337 *************** *** 4075,4079 **** { CDataObject *self = (CDataObject *)_self; ! int size, offset; StgDictObject *stgdict, *itemdict; PyObject *proto; --- 4075,4080 ---- { CDataObject *self = (CDataObject *)_self; ! int size; ! Py_ssize_t offset; StgDictObject *stgdict, *itemdict; PyObject *proto; *************** *** 4104,4107 **** --- 4105,4109 ---- CDataObject *self = (CDataObject *)_self; int size; + Py_ssize_t offset; StgDictObject *stgdict; *************** *** 4120,4127 **** stgdict = PyObject_stgdict((PyObject *)self); size = stgdict->size / stgdict->length; /* XXXXX Make sure proto is NOT NULL! */ return CData_set((PyObject *)self, stgdict->proto, stgdict->setfunc, value, ! index, size, *(void **)self->b_ptr); } --- 4122,4130 ---- stgdict = PyObject_stgdict((PyObject *)self); size = stgdict->size / stgdict->length; + offset = index * size; /* XXXXX Make sure proto is NOT NULL! */ return CData_set((PyObject *)self, stgdict->proto, stgdict->setfunc, value, ! index, size, (*(char **)self->b_ptr) + offset); } *************** *** 4140,4145 **** assert(stgdict); return CData_FromBaseObj(stgdict->proto, ! (PyObject *)self, 0, ! *(void **)self->b_ptr); } --- 4143,4148 ---- assert(stgdict); return CData_FromBaseObj(stgdict->proto, ! (PyObject *)self, 0, ! *(void **)self->b_ptr); } *************** *** 4498,4501 **** --- 4501,4510 ---- return NULL; + /* + The casted objects '_objects' member: + + It must certainly contain the source objects one. + It must contain the source object itself. + */ if (CDataObject_Check(src)) { CDataObject *obj = (CDataObject *)src; *************** *** 4503,4511 **** this so it can be shared */ CData_GetContainer(obj); ! Py_XINCREF(obj->b_objects); result->b_objects = obj->b_objects; ! ! Py_XINCREF(obj->b_base); ! result->b_base = obj->b_base; } /* Should we assert that result is a pointer type? */ --- 4512,4532 ---- this so it can be shared */ CData_GetContainer(obj); ! /* But we need a dictionary! */ ! if (obj->b_objects == Py_None) { ! Py_DECREF(Py_None); ! obj->b_objects = PyDict_New(); ! } ! Py_INCREF(obj->b_objects); result->b_objects = obj->b_objects; ! if (result->b_objects) { ! PyObject *index = PyLong_FromVoidPtr((void *)src); ! int rc; ! if (index == NULL) ! return NULL; ! rc = PyDict_SetItem(result->b_objects, index, src); ! Py_DECREF(index); ! if (rc == -1) ! return NULL; ! } } /* Should we assert that result is a pointer type? */ |