X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpython%2Ftaglist.c;h=0a30c08e3ad9371bd5072fcef4f17b305f6a35e7;hb=879d0eec420fe0fd5ddcd56c8fe62b82a6744edd;hp=7e101c8457f01e0fa400766c958a69530ce896f2;hpb=6d72eaadfcc19eb917ca15ada059210e2b63a91f;p=swftools.git diff --git a/lib/python/taglist.c b/lib/python/taglist.c index 7e101c8..0a30c08 100644 --- a/lib/python/taglist.c +++ b/lib/python/taglist.c @@ -15,6 +15,16 @@ typedef struct { PyObject* taglist; } TagListObject; //---------------------------------------------------------------------------- +static void taglist_showcontents(PyObject* self) +{ + TagListObject*taglist = (TagListObject*)self; + int t, l = PyList_Size(taglist->taglist); + for(t=0;ttaglist, t); + mylog(" %08x(%d) taglist_showcontents item=%08x(%d)\n", (int)self, self->ob_refcnt, item, item->ob_refcnt); + } +} +//---------------------------------------------------------------------------- PyObject * taglist_new() { TagListObject* taglist = PyObject_New(TagListObject, &TagListClass); @@ -35,7 +45,7 @@ PyObject * taglist_new2(TAG*tag) while(t) {len++;last=t;t=t->next;} if(last && last->id==ST_END) { - swf_DeleteTag(last); last = 0; + swf_DeleteTag(0, last); last = 0; len--; if(len==0) tag = 0; } @@ -58,6 +68,7 @@ PyObject * taglist_new2(TAG*tag) } nr++; t=t->next; + Py_DECREF(newtag); } Py_DECREF(tagmap); return (PyObject*)taglist; @@ -66,6 +77,13 @@ PyObject * taglist_new2(TAG*tag) TAG* taglist_getTAGs(PyObject*self) { PyObject* tagmap = tagmap_new(); + TAG* tag = taglist_getTAGs2(self, tagmap, 1); + Py_DECREF(tagmap); + return tag; +} +//---------------------------------------------------------------------------- +TAG* taglist_getTAGs2(PyObject*self, PyObject*tagmap, int addDependencies) +{ if(!PY_CHECK_TYPE(self,&TagListClass)) { PyErr_SetString(PyExc_Exception, setError("Not a taglist (%08x).", self)); return 0; @@ -81,16 +99,30 @@ TAG* taglist_getTAGs(PyObject*self) mylog(" %08x(%d) taglist_getTAGs", (int)self, self->ob_refcnt); for(t=0;ttaglist, t); - tag = tag_getTAG(item, tag, tagmap); - if(!tag) { - //pass through errors - Py_DECREF(tagmap); - return 0; + if(addDependencies) { + PyObject* deps = tag_getDependencies(item); + int l = PyList_Size(deps); + int t; + for(t=0;tob_refcnt, taglist->taglist, taglist->taglist->ob_refcnt); - Py_DECREF(taglist->taglist); - taglist->taglist = 0; - PyObject_Del(self); -} -//---------------------------------------------------------------------------- static PyMethodDef taglist_functions[] = {{"foldAll", taglist_foldAll, METH_VARARGS, "fold all sprites (movieclips) in the list"}, {"unfoldAll", taglist_unfoldAll, METH_VARARGS, "unfold (expand) all sprites (movieclips) in the list"}, @@ -190,15 +213,6 @@ static PyObject * taglist_concat(PyObject * self, PyObject* list) mylog(" %08x(%d) taglist_concat %08x(%d)", (int)self, self->ob_refcnt, list, list->ob_refcnt); if (PyArg_Parse(list, "O!", &TagClass, &tag)) { - list = tag_getDependencies(tag); - int l = PyList_Size(list); - int t; - for(t=0;tob_refcnt, tag, tag->ob_refcnt); PyList_Append(taglist->taglist, tag); @@ -272,11 +286,23 @@ static PyObject * taglist_item(PyObject * self, int index) { TagListObject*taglist = (TagListObject*)self; PyObject*tag; - mylog(" %08x(%d) taglist_item(%d)", (int)self, self->ob_refcnt, index); tag = PyList_GetItem(taglist->taglist, index); + if(!tag) + return 0; + mylog(" %08x(%d) taglist_item(%d): %08x", (int)self, self->ob_refcnt, index, tag); Py_INCREF(tag); return tag; } +//---------------------------------------------------------------------------- +static void taglist_dealloc(PyObject* self) +{ + TagListObject*taglist = (TagListObject*)self; + mylog("-%08x(%d) taglist_dealloc list=%08x(%d)\n", (int)self, self->ob_refcnt, taglist->taglist, taglist->taglist->ob_refcnt); + Py_DECREF(taglist->taglist); + taglist->taglist = 0; + PyObject_Del(self); +} +//---------------------------------------------------------------------------- static PySequenceMethods taglist_as_sequence = { sq_length: taglist_length, // len(obj)