3 Python wrapper for librfxswf- actionscript stuff
5 Part of the swftools package.
7 Copyright (c) 2003 Matthias Kramm <kramm@quiss.org>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
25 #include "../rfxswf.h"
27 #include "./pyutils.h"
30 PyObject* f_Action(PyObject* self, PyObject* args, PyObject* kwargs)
32 static char *kwlist[] = {"r", "g", "b", "a", NULL};
34 int r=0,g=0,b=0,a=255;
35 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iii|i", kwlist, &r,&g,&b,&a))
37 action = PyObject_New(ActionObject, &ActionClass);
42 return (PyObject*)action;
44 static PyObject* action_getattr(PyObject * self, char* a)
46 ActionObject*action = (ActionObject*)self;
48 return Py_BuildValue("r", action->rgba.r);
49 } else if(!strcmp(a, "g")) {
50 return Py_BuildValue("g", action->rgba.g);
51 } else if(!strcmp(a, "b")) {
52 return Py_BuildValue("b", action->rgba.b);
53 } else if(!strcmp(a, "a")) {
54 return Py_BuildValue("a", action->rgba.a);
58 static int action_setattr(PyObject * self, char* attr, PyObject* o)
60 ActionObject*action = (ActionObject*)self;
61 if(!strcmp(attr, "r")) {
62 if (!PyArg_Parse(o, "d", &action->rgba.r)) goto err;
64 } else if(!strcmp(attr, "g")) {
65 if (!PyArg_Parse(o, "d", &action->rgba.g)) goto err;
67 } else if(!strcmp(attr, "b")) {
68 if (!PyArg_Parse(o, "d", &action->rgba.b)) goto err;
70 } else if(!strcmp(attr, "a")) {
71 if (!PyArg_Parse(o, "d", &action->rgba.a)) goto err;
75 mylog("swf_setattr %08x(%d) %s = ? (%08x)\n", (int)self, self->ob_refcnt, attr, o);
79 PyTypeObject ActionClass =
81 PyObject_HEAD_INIT(NULL)
84 tp_basicsize: sizeof(ActionObject),
86 tp_dealloc: dummy_dealloc,
88 tp_getattr: action_getattr,
89 tp_setattr: action_setattr,