+/* serialize */
+TAG* tag_getTAG(PyObject*self, TAG*prevTag, PyObject*tagmap)
+{
+ TagObject*tag = (TagObject*)self;
+
+ mylog(" %08x(%d) tag_getTAG: tag=%08x id=%d (%s)", (int)self, self->ob_refcnt, tag->tag, tag->tag->id, swf_TagGetName(tag->tag));
+
+ TAG* t = swf_InsertTag(prevTag, tag->tag->id);
+ swf_SetBlock(t, tag->tag->data, tag->tag->len);
+
+ if(swf_isDefiningTag(t)) {
+ int newid = tagmap_add(tagmap, self);
+ swf_SetDefineID(t, newid);
+ }
+
+ int num = swf_GetNumUsedIDs(t);
+ if(num) { // tag has dependencies
+ int * positions = malloc(num*sizeof(int));
+ swf_GetUsedIDs(t, positions);
+ int i;
+ for(i=0;i<num;i++) {
+ int id = GET16(&t->data[positions[i]]);
+ PyObject* obj = tagmap_id2obj(tag->tagmap, id);
+ if(obj==NULL) {
+ PyErr_SetString(PyExc_Exception, setError("Internal error: id %d not known in taglist:"));
+ free(positions);
+ return 0;
+ }
+ int newid = tagmap_obj2id(tagmap, obj);
+ PUT16(&t->data[positions[i]], newid);
+ }
+ free(positions);
+ }
+ return t;
+}
+
+PyObject* tag_getDependencies(PyObject*self)
+{
+ TagObject*tag = (TagObject*)self;
+ mylog(" %08x(%d) tag_getDependencies id=%d tag=%s\n", (int)self, self->ob_refcnt, tag->tag->id, swf_TagGetName(tag->tag));
+ return tagmap_getObjectList(tag->tagmap);
+}
+
+int tag_print (PyObject * self, FILE * fi, int flags)