TAG*firstTag;
TAG*searchTag;
TAG*lastTag;
+ PyDictObject* char2id;
+ PyDictObject* id2char;
+ U16 currentID;
} TagListObject;
typedef struct {
swf->taglist->firstTag = 0;
swf->taglist->searchTag = 0;
swf->taglist->lastTag = 0;
+ swf->taglist->currentID = 1;
+ swf->taglist->char2id = (PyDictObject*)PyDict_New();
+ swf->taglist->id2char = (PyDictObject*)PyDict_New();
if(swf->swf.fileVersion>=6)
swf->swf.compressed = 1;
swf->taglist->firstTag = swf->swf.firstTag;
swf->taglist->searchTag = swf->swf.firstTag;
swf->taglist->lastTag = swf->swf.firstTag;
+ swf->taglist->currentID = 1;
+ swf->taglist->char2id = (PyDictObject*)PyDict_New();
+ swf->taglist->id2char = (PyDictObject*)PyDict_New();
swf->swf.firstTag = 0;
mylog("load %08x -> %08x\n", (int)self, (int)swf);
{NULL, NULL, 0, NULL}
};
-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"},
- {"optimizeOrder", taglist_optimizeOrder, METH_VARARGS, "Reorder the Tag structure"},
- {NULL, NULL, 0, NULL}
-};
-
//----------------------------------------------------------------------------
static void swf_dealloc(PyObject* 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"},
+ {"optimizeOrder", taglist_optimizeOrder, METH_VARARGS, "Reorder the Tag structure"},
+ {NULL, NULL, 0, NULL}
+};
+
static PyObject* taglist_getattr(PyObject * self, char* a)
{
PyObject* ret = Py_FindMethod(taglist_functions, self, a);
{
TagObject*tag;
TagListObject*taglist = (TagListObject*)self;
- mylog("taglist_concat %08x(%d)", (int)self, self->ob_refcnt);
+ mylog("taglist_concat %08x(%d) %08x", (int)self, self->ob_refcnt, list);
if (PyArg_Parse(list, "O!", &TagClass, &tag)) {
/* copy tag, so we don't have to do INCREF(tag) (and don't
if(!taglist->firstTag) {
taglist->firstTag = taglist->searchTag = taglist->lastTag;
}
+ if(swf_isDefiningTag(tag->tag)) {
+ PyObject*id = PyLong_FromLong(taglist->currentID);
+ PyDict_SetItem((PyObject*)(taglist->char2id), list, id);
+ Py_INCREF(id);
+ PyDict_SetItem((PyObject*)(taglist->id2char), id, list);
+ Py_INCREF(id);
+ }
Py_INCREF(self);
return self;
}
PyErr_Clear();
if (PyList_Check(list)) {
+ int l = PyList_Size(list);
+ int t;
mylog("taglist_concat: PythonList", (int)self, self->ob_refcnt);
+ for(t=0;t<l;t++) {
+ PyObject*item = PyList_GetItem(list, t);
+ self = taglist_concat(self, item);
+ if(!self)
+ return 0;
+ }
Py_INCREF(self);
return self;
}
- return 0;
-}
-//----------------------------------------------------------------------------
-static int taglist_contains(PyObject * self, PyObject* other)
-{
- mylog("taglist_contains %08x(%d)", (int)self, self->ob_refcnt);
+ PyErr_SetString(PyExc_Exception, setError("taglist concatenation only works with tags and lists (%08x).", list));
return 0;
}
//----------------------------------------------------------------------------
TAG*tag;
TagObject*tagobject;
int i = 0;
- mylog("taglist_item %08x(%d) [%d]", (int)self, self->ob_refcnt, i);
+ mylog("taglist_item %08x(%d) [%d]", (int)self, self->ob_refcnt, index);
- if(i<0) {
+ if(index<0) {
PyErr_SetString(PyExc_Exception, setError("Negative Indices not supported."));
return NULL;
}
tag = taglist->firstTag;
while(tag && i<index) {
tag = tag->next;
+ i++;
}
if(!tag || i != index) {
- PyErr_SetString(PyExc_Exception, setError("No Tag at position %d", index));
+ if(index> i+10) {
+ PyErr_SetString(PyExc_Exception, setError("No Tag at position %d", index));
+ return NULL;
+ }
+
+ mylog("taglist_item %08x(%d)->IndexError (%d)", (int)self, self->ob_refcnt, index);
+
+ Py_INCREF(PyExc_IndexError);
+ PyErr_SetObject(PyExc_IndexError, Py_None);
return NULL;
}
for(t=0;t<sizeof(tagfunctions)/sizeof(tagfunctions[0]);t++)
{
if(id==tagfunctions[t].id) {
- mylog("taglist_getattr: id %d found\n", id);
+ mylog("tag_getattr: id %d found\n", id);
ret = Py_FindMethod(tagfunctions[t].f, self, a);
break;
}
/* search in the functions common to all tags */
FindMethodMore(ret, common_tagfunctions, self, a);
- mylog("taglist_getattr %08x(%d) %s: %08x\n", (int)self, self->ob_refcnt, a, ret);
+ mylog("tag_getattr %08x(%d) %s: %08x\n", (int)self, self->ob_refcnt, a, ret);
return ret;
}
//----------------------------------------------------------------------------
return (PyObject*)tag;
}
//----------------------------------------------------------------------------
+static PyObject* f_Protect(PyObject* self, PyObject* args, PyObject* kwargs)
+{
+ static char *kwlist[] = {"password", NULL};
+ char*password = 0;
+ TagObject*tag;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", kwlist, &password))
+ return NULL;
+
+ tag = TagObject_New();
+ tag->tag = swf_InsertTag(0, ST_PROTECT);
+ if(password) {
+ swf_SetPassword(tag->tag, password);
+ }
+ mylog("f_Protect %08x -> %08x\n", (int)self, (int)tag);
+ return (PyObject*)tag;
+}
+//----------------------------------------------------------------------------
static PyObject* f_DefineText(PyObject* self, PyObject* args, PyObject* kwargs)
{
static char *kwlist[] = {"font", "text", "size", "color", NULL};
//----------------------------------------------------------------------------
static PyObject* f_PlaceObject(PyObject* self, PyObject* args, PyObject* kwargs)
{
- static char *kwlist[] = {"character", "depth", "matrix", "colortransform", "ratio", "name", "clipdepth", "action"};
+ static char *kwlist[] = {"character", "depth", "matrix", "colortransform", "ratio", "name", "clipdepth", "action", NULL};
TagObject*tag;
TagObject*character = 0;
sq_slice: 0, // x[i:j] intintargfunc
sq_ass_item: 0, // x[i] = y intobjargproc
sq_ass_slice: 0, // x[i:j] = v intintobjargproc
- sq_contains: taglist_contains, //???
+ sq_contains: 0, //???
};
static PyTypeObject TagListClass =
{
/* TAGS */
{"SetBackgroundColor", (PyCFunction)f_SetBackgroundColor, METH_KEYWORDS, "Create a SetBackGroundColor Tag."},
+ {"Protect", (PyCFunction)f_Protect, METH_KEYWORDS, "Create a Protect Tag."},
{"DefineFont", (PyCFunction)f_DefineFont, METH_KEYWORDS, "Create a DefineFont Tag."},
{"DefineText", (PyCFunction)f_DefineText, METH_KEYWORDS, "Create a DefineText Tag."},
{"PlaceObject", (PyCFunction)f_PlaceObject, METH_KEYWORDS, "Create a PlaceObject Tag."},