#include "../rfxswf.h"
#include "../log.h"
#include "./pyutils.h"
-#include "./tag.h"
+#include "./tags.h"
#include "./taglist.h"
+#include "./primitives.h"
+#include "./action.h"
/*
TODO:
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|idOs",
kwlist, &version, &framerate,
- &obbox, filename))
+ &obbox, &filename))
return NULL;
- if (!PyArg_Parse(obbox, "(iiii)", &bbox.xmin, &bbox.ymin, &bbox.xmax, &bbox.ymax))
- return NULL;
+ if (!PY_CHECK_TYPE(obbox, &BBoxClass)) {
+ obbox = f_BBox(0, obbox, 0);
+ if(!obbox)
+ return NULL;
+ }
+ bbox = bbox_getSRECT(obbox);
memset(&swf->swf, 0, sizeof(SWF));
if(filename)
mylog("+%08x(%d) f_load\n", (int)swf, swf->ob_refcnt);
memset(&swf->swf, 0, sizeof(SWF));
- swf->filename = strdup(filename);
if(!filename) {
PyErr_SetString(PyExc_Exception, setError("Couldn't open file %s", filename));
return 0;
}
+ swf->filename = strdup(filename);
fi = open(filename,O_RDONLY|O_BINARY);
if (fi<0) {
PyErr_SetString(PyExc_Exception, setError("Couldn't open file %s", filename));
return 0;
}
close(fi);
+ swf_FoldAll(&swf->swf);
swf->taglist = taglist_new2(swf->swf.firstTag);
if(swf->taglist == NULL) {
int fi;
char*filename = 0;
int compress = 0;
-
+
if(!self)
return NULL;
}
close(fi);
- /* TODO: why is this segfaulting?? */
- /* swf_FreeTags(swf);
- swf->firstTag = 0;*/
+ swf_FreeTags(swf);
+ /*{ TAG * t = swf->firstTag;
+ while (t)
+ {
+ mylog("tag: %08x\n",t);
+ mylog(" id: %d (%s)\n", t->id, swf_TagGetName(t));
+ mylog(" data: %08x (%d bytes)\n", t->data, t->len);
+ mylog(" next: %08x\n", t->next);
+ TAG * tnew = t->next;
+ mylog("->free data\n");
+ if (t->data) free(t->data);
+ mylog("->free tag\n");
+ free(t);
+ t = tnew;
+ }
+ }*/
+ swf->firstTag = 0;
+
+ mylog(" %08x(%d) f_save filename=%s done\n", (int)self, self->ob_refcnt, filename);
return PY_NONE;
}
if(!swf->swf.firstTag)
return NULL;
swf_WriteCGI(&swf->swf);
+ swf_FreeTags(&swf->swf);
swf->swf.firstTag = 0;
return PY_NONE;
}
mylog(" %08x(%d) swf_getattr %s = %s\n", (int)self, self->ob_refcnt, a, filename);
return Py_BuildValue("s", filename);
} else if(!strcmp(a, "bbox")) {
- int xmin,ymin,xmax,ymax;
- xmin = swf->swf.movieSize.xmin;
- ymin = swf->swf.movieSize.ymin;
- xmax = swf->swf.movieSize.xmax;
- ymax = swf->swf.movieSize.ymax;
- mylog(" %08x(%d) swf_getattr %s = (%d,%d,%d,%d)\n", (int)self, self->ob_refcnt, a, xmin,ymin,xmax,ymax);
- return Py_BuildValue("(iiii)", xmin, ymin, xmax, ymax);
+ return f_BBox2(swf->swf.movieSize);
} else if(!strcmp(a, "tags")) {
PyObject*ret = (PyObject*)(swf->taglist);
Py_INCREF(ret);
mylog(" %08x(%d) swf_setattr %s = %s\n", (int)self, self->ob_refcnt, a, filename);
return 0;
} else if(!strcmp(a, "bbox")) {
- int xmin=0,ymin=0,xmax=0,ymax=0;
- if (!PyArg_Parse(o, "(iiii)", &xmin, &ymin, &xmax, &ymax))
- goto err;
+ PyObject *obbox = o;
+ if (!PY_CHECK_TYPE(obbox, &BBoxClass)) {
+ obbox = f_BBox(0, o, 0);
+ if(!obbox)
+ return 1;
+ }
+ SRECT bbox = bbox_getSRECT(obbox);
- swf->swf.movieSize.xmin = xmin;
- swf->swf.movieSize.ymin = ymin;
- swf->swf.movieSize.xmax = xmax;
- swf->swf.movieSize.ymax = ymax;
- mylog(" %08x(%d) swf_setattr %s = (%d,%d,%d,%d)\n", (int)self, self->ob_refcnt, a, xmin,ymin,xmax,ymax);
+ swf->swf.movieSize = bbox;
+ mylog(" %08x(%d) swf_setattr %s = (%d,%d,%d,%d)\n", (int)self, self->ob_refcnt, a, bbox.xmin,bbox.ymin,bbox.xmax,bbox.ymax);
return 0;
} else if(!strcmp(a, "tags")) {
PyObject* taglist;
- /*if (!PyArg_Parse(o, "O!", &TagListClass, &taglist));
- goto err;*/
- // TODO: check if it's really a taglist
taglist = o;
+ PY_ASSERT_TYPE(taglist,&TagListClass);
Py_DECREF(swf->taglist);
swf->taglist = taglist;
Py_INCREF(swf->taglist);
{
int _verbose = 0;
static char *kwlist[] = {"verbosity", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &verbose))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &_verbose))
return NULL;
setVerbosity(_verbose);
{"verbose", (PyCFunction)module_verbose, METH_KEYWORDS, "Set the module verbosity"},
{0,0,0,0}
};
-
+
void initSWF(void)
{
PyObject*module;
PyMethodDef* primitive_methods = primitive_getMethods();
- PyMethodDef* tag_methods = tag_getMethods();
+ PyMethodDef* tag_methods = tags_getMethods();
PyMethodDef* action_methods = action_getMethods();
PyMethodDef* swf_methods = swf_getMethods();
all_methods = addMethods(all_methods, LoggingMethods);
module = Py_InitModule("SWF", all_methods);
+
+ /* Python doesn't copy the PyMethodDef struct, so we need
+ to keep it around */
+ // free(all_methods)
}
+