Py/RNA api - real collection iterator

Previously the api just converted the collection to a list and got the iterator from the list to return.

This has the advantage that it uses minimal memory on large collections where before it would make an array.

Though the main reason for this change is to support a bugfix for collections which free memory when they are done, this currently crashes the python api since once the list is built, the data is freed which is used by the list items in some cases (dynamic enums for eg).
This commit is contained in:
2011-03-03 07:41:09 +00:00
parent b535c738d9
commit 3a2ce2be83
2 changed files with 169 additions and 0 deletions

View File

@@ -40,6 +40,8 @@
/* different method */
//#define USE_PYRNA_INVALIDATE_WEAKREF
/* use real collection iterators rather then faking with a list */
#define USE_PYRNA_ITER
/* sanity checks on above defs */
#if defined(USE_PYRNA_INVALIDATE_WEAKREF) && !defined(USE_WEAKREFS)
@@ -113,6 +115,16 @@ typedef struct {
int arrayoffset; /* array first item offset, e.g. if face.uv is [4][2], arrayoffset for face.uv[n] is 2n */
} BPy_PropertyArrayRNA;
typedef struct {
PyObject_HEAD /* required python macro */
#ifdef USE_WEAKREFS
PyObject *in_weakreflist;
#endif
/* collection iterator spesific parts */
CollectionPropertyIterator iter;
} BPy_PropertyCollectionIterRNA;
/* cheap trick */
#define BPy_BaseTypeRNA BPy_PropertyRNA