PyObject_Del(self);
}
//----------------------------------------------------------------------------
-static PyObject* tag_setU8(PyObject * self, PyObject*other)
-{
- return NULL;
-}
-//----------------------------------------------------------------------------
-static PyMethodDef common_tagfunctions[] =
-{{"setU8", tag_setU8, METH_VARARGS, "sets a byte to the tag data"},
- {NULL, NULL, 0, NULL}
-};
-
static int fillTAG(PyObject*self)
{
TagObject*tag = (TagObject*)self;
}
return 1;
}
+//----------------------------------------------------------------------------
+static PyObject* tag_isShape(PyObject * _self, PyObject*args)
+{
+ TagObject*self = (TagObject*)_self;
+ if(!PyArg_ParseTuple(args, "")) return NULL;
+ if(!fillTAG((PyObject*)self)) return NULL;
+ return PyInt_FromLong(swf_isShapeTag(self->internals.tag));
+}
+static PyObject* tag_isFont(PyObject * _self, PyObject*args)
+{
+ TagObject*self = (TagObject*)_self;
+ if(!PyArg_ParseTuple(args, "")) return NULL;
+ if(!fillTAG((PyObject*)self)) return NULL;
+ int id = self->internals.tag->id;
+ int isfont=0;
+ if(id == ST_DEFINEFONT || id == ST_DEFINEFONT2)
+ isfont = 1;
+ return PyInt_FromLong(isfont);
+}
+static PyObject* tag_isImage(PyObject * _self, PyObject*args)
+{
+ TagObject*self = (TagObject*)_self;
+ if(!PyArg_ParseTuple(args, "")) return NULL;
+ if(!fillTAG((PyObject*)self)) return NULL;
+ return PyInt_FromLong(swf_isImageTag(self->internals.tag));
+}
+static PyObject* tag_isDefiningTag(PyObject * _self, PyObject*args)
+{
+ TagObject*self = (TagObject*)_self;
+ if(!PyArg_ParseTuple(args, "")) return NULL;
+ if(!fillTAG((PyObject*)self)) return NULL;
+ return PyInt_FromLong(swf_isDefiningTag(self->internals.tag));
+}
+static PyObject* tag_isPlacement(PyObject * _self, PyObject*args)
+{
+ TagObject*self = (TagObject*)_self;
+ if(!PyArg_ParseTuple(args, "")) return NULL;
+ if(!fillTAG((PyObject*)self)) return NULL;
+ return PyInt_FromLong((self->internals.tag->id == ST_PLACEOBJECT ||
+ self->internals.tag->id == ST_PLACEOBJECT2));
+}
+static PyObject* tag_getBBox(PyObject * _self, PyObject*args)
+{
+ TagObject*self = (TagObject*)_self;
+ if(!PyArg_ParseTuple(args, "")) return NULL;
+ if(!fillTAG((PyObject*)self)) return NULL;
+ return f_BBox2(swf_GetDefineBBox(self->internals.tag));
+}
+static PyObject* tag_setBBox(PyObject * _self, PyObject*args)
+{
+ TagObject*self = (TagObject*)_self;
+ PyObject*bbox = 0;
+ if(!PyArg_ParseTuple(args, "O!", &BBoxClass, &bbox)) return NULL;
+ if(!fillTAG((PyObject*)self)) return NULL;
+ swf_SetDefineBBox(self->internals.tag, bbox_getSRECT(bbox));
+ return PY_NONE;
+}
+//----------------------------------------------------------------------------
+static PyMethodDef common_tagfunctions[] =
+{{"isShape", tag_isShape, METH_VARARGS, "tests whether the tag is a shape tag"},
+ {"isImage", tag_isImage, METH_VARARGS, "tests whether the tag is an image"},
+ {"isFont", tag_isFont, METH_VARARGS, "tests whether the tag is a font"},
+ {"isDefiningTag", tag_isDefiningTag, METH_VARARGS, "tests whether the tag is a defining tag"},
+ {"isPlacement", tag_isPlacement, METH_VARARGS, "tests whether the tag is a placement"},
+ {"getBBox", tag_getBBox, METH_VARARGS, "get's the tags bounding box"},
+ {"setBBox", tag_setBBox, METH_VARARGS, "set's the tags bounding box"},
+ {NULL, NULL, 0, NULL}
+};
+
static PyObject* tag_getattr(PyObject * self, char* a)
{
TagObject*tag = (TagObject*)self;
char* name = swf_TagGetName(tag->internals.tag);
return Py_BuildValue("s", name);
}
+ if(tag->internals.getattr) {
+ PyObject* ret = tag->internals.getattr(&tag->internals, a);
+ if(ret) return ret;
+ }
/* search for a tag specific function */
if(tag->internals.tagfunctions) {
mylog(" %08x(%d) tag_getattr: tag has specific functions\n", (int)self, self->ob_refcnt);
ret = Py_FindMethod(tag->internals.tagfunctions, self, a);
- if(!ret) return ret;
+ if(ret) return ret;
+ PyErr_Clear();
ret = FindMethodMore(ret, common_tagfunctions, self, a);
mylog(" %08x(%d) tag_getattr %s: %08x\n", (int)self, self->ob_refcnt, a, ret);
- return ret;
+ if(ret) return ret;
+ PyErr_Clear();
}
-
+
ret = Py_FindMethod(common_tagfunctions, self, a);
mylog(" %08x(%d) tag_getattr %s: %08x\n", (int)self, self->ob_refcnt, a, ret);
return ret;
}
+static int tag_setattr(PyObject * _self, char* a, PyObject * o)
+{
+ TagObject*self= (TagObject*)_self;
+ /* a setattr will almost certainly change the tag data,
+ so delete the tag */
+ if(self->internals.tag) {
+ swf_DeleteTag(self->internals.tag);
+ self->internals.tag = 0;
+ }
+ if(self->internals.setattr) {
+ int ret = self->internals.setattr(&self->internals, a, o);
+ return ret;
+ }
+ return 1;
+}
//----------------------------------------------------------------------------
// Tag Constructors
//----------------------------------------------------------------------------
}
//int newid = tagmap_obj2id(tag->internals.tagmap, obj);
int newid = tagmap_obj2id(tagmap, obj);
- if(newid<0) {
- PyErr_SetString(PyExc_Exception, setError("Unknown object %08x", obj));return 0;
+ if(newid>=0) {
+ mylog(" %08x(%d) tag_getTAG: dependency %d) %d->%08x -> assigning(%08x) id %d", (int)self, self->ob_refcnt, i, id, obj, tagmap, newid);
+ } else {
+ /* TODO: this is only needed for sprites, so maybe it should throw an
+ exception otherwise */
+ newid = tagmap_add(tagmap, obj);
+ mylog(" %08x(%d) tag_getTAG: added dependency %d) %d->%08x -> assigning(%08x) id %d", (int)self, self->ob_refcnt, i, id, obj, tagmap, newid);
}
- mylog(" %08x(%d) tag_getTAG: dependency %d) %d->%08x -> assigning(%08x) id %d", (int)self, self->ob_refcnt, i, id, obj, tagmap, newid);
PUT16(&t->data[positions[i]], newid);
}
free(positions);
mylog(" %08x(%d) tag_print flags=%08x\n", (int)self, self->ob_refcnt, flags);
if(!fillTAG(self))
return -1;
- fprintf(fi, "tag-%08x-%d-%s", (int)tag->internals.tag, tag->internals.tag->id, swf_TagGetName(tag->internals.tag));
+ //fprintf(fi, "tag-%08x-%d-%s", (int)tag->internals.tag, tag->internals.tag->id, swf_TagGetName(tag->internals.tag));
+ fprintf(fi, "%s", swf_TagGetName(tag->internals.tag));
return 0;
}
//----------------------------------------------------------------------------
tp_dealloc: tag_dealloc,
tp_print: tag_print,
tp_getattr: tag_getattr,
+ tp_setattr: tag_setattr,
};