int nr=0;
TAG*t = tag;
- while(t) {nr++;t=t->next;}
+ TAG*last = t;
+ while(t) {nr++;last=t;t=t->next;}
+
+ if(last && last->id==ST_END) {
+ swf_DeleteTag(last);
+ nr--;
+ }
+
taglist->taglist = PyList_New(nr);
mylog("+%08x(%d) taglist_new2: %d items", (int)taglist, taglist->ob_refcnt, nr);
nr = 0;
t = tag;
while(t) {
- PyObject*newtag = tag_new2(tag, taglist->tagmap);
+ PyObject*newtag = tag_new2(t, taglist->tagmap);
+ if(newtag==NULL) {
+ // pass through exception
+ return NULL;
+ }
PyList_SET_ITEM(taglist->taglist,nr,newtag);Py_INCREF(newtag);
if(swf_isDefiningTag(t)) {
- tagmap_add(taglist->tagmap, newtag);
+ int id = swf_GetDefineID(t);
+ tagmap_addMapping(taglist->tagmap, id, newtag);
}
nr++;
t=t->next;
tag = tag_getTAG(item, tag, taglist->tagmap);
if(!firstTag)
firstTag = tag;
+ mylog(" %08x(%d) taglist_getTAGs: added tag %08x", (int)self, self->ob_refcnt, tag);
}
return firstTag;
}
//----------------------------------------------------------------------------
static int taglist_contains(PyObject * self, PyObject * tag)
{
- mylog(" %08x(%d) taglist_contains %08x", (int)self, self->ob_refcnt, tag);
+ /* TODO: optimize! */
TagListObject*taglist = (TagListObject*)self;
PyObject*list = taglist->taglist;
int l = PyList_Size(list);
for(t=0;t<l;t++) {
PyObject*item = PyList_GetItem(list, t);
if(item == tag) {
- mylog(" %08x(%d) taglist_contains: yes", (int)self, self->ob_refcnt);
return 1;
}
}
- mylog(" %08x(%d) taglist_contains: no", (int)self, self->ob_refcnt);
return 0;
}
//----------------------------------------------------------------------------
PyObject*tag;
mylog(" %08x(%d) taglist_item(%d)", (int)self, self->ob_refcnt, index);
tag = PyList_GetItem(taglist->taglist, index);
- Py_INCREF(tag); //TODO-REF
+ Py_INCREF(tag);
return tag;
}
static PySequenceMethods taglist_as_sequence =