swf->taglist->firstTag = swf->swf.firstTag;
swf->taglist->searchTag = swf->swf.firstTag;
swf->taglist->lastTag = swf->swf.firstTag;
+ while(swf->taglist->lastTag->next)
+ swf->taglist->lastTag = swf->taglist->lastTag->next;
swf->taglist->currentID = 1;
swf->taglist->char2id = (PyDictObject*)PyDict_New();
swf->taglist->id2char = (PyDictObject*)PyDict_New();
{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);
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;
+ if(!ret) return ret;
+ ret = FindMethodMore(ret, common_tagfunctions, self, a);
+ mylog("tag_getattr %08x(%d) %s: %08x\n", (int)self, self->ob_refcnt, a, ret);
+ return ret;
}
}
+
+ ret = Py_FindMethod(common_tagfunctions, self, a);
- /* 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;
};
//----------------------------------------------------------------------------
+static PyObject* module_verbose(PyObject* self, PyObject* args)
+{
+ if (!PyArg_ParseTuple(args,"i", &verbose))
+ return NULL;
+ return Py_BuildValue("s", 0);
+}
+
+
static PyMethodDef SWFMethods[] =
{
+ /* Module functions */
+ {"verbose", module_verbose, METH_VARARGS, "Set the module verbosity"},
+
/* SWF creation*/
{"load", f_load, METH_VARARGS, "Load a SWF from disc."},
{"create", (PyCFunction)f_create, METH_KEYWORDS, "Create a new SWF from scratch."},
/* 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."},