more fiddling with edgestyles
[swftools.git] / lib / python / action.c
1 /* action.c
2
3    Python wrapper for librfxswf- actionscript stuff
4
5    Part of the swftools package.
6
7    Copyright (c) 2003 Matthias Kramm <kramm@quiss.org>
8  
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.
13
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.
18
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 */
22
23 #include <Python.h>
24 #undef HAVE_STAT
25 #include "../rfxswf.h"
26 #include "../log.h"
27 #include "./pyutils.h"
28 #include "action.h"
29
30
31 typedef struct {
32     PyObject_HEAD
33     ActionTAG*action;
34 } ActionObject;
35
36 PyObject* f_Action(PyObject* self, PyObject* args, PyObject* kwargs)
37 {
38     static char *kwlist[] = {"code", NULL};
39     ActionObject* action;
40     char*code = 0;
41     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", kwlist, &code))
42         return NULL;
43     action = PyObject_New(ActionObject, &ActionClass);
44     action->action = 0;
45     return (PyObject*)action;
46 }
47 static PyObject* action_getattr(PyObject * self, char* a)
48 {
49     ActionObject*action = (ActionObject*)self;
50 /*    if(!strcmp(a, "r")) {
51         return Py_BuildValue("r", action->rgba.r);
52     } else if(!strcmp(a, "g")) {
53         return Py_BuildValue("g", action->rgba.g);
54     } else if(!strcmp(a, "b")) {
55         return Py_BuildValue("b", action->rgba.b);
56     } else if(!strcmp(a, "a")) {
57         return Py_BuildValue("a", action->rgba.a);
58     }*/
59     return NULL;
60 }
61 static int action_setattr(PyObject * self, char* attr, PyObject* o)
62 {
63     ActionObject*action = (ActionObject*)self;
64 /*    if(!strcmp(attr, "r")) {
65         if (!PyArg_Parse(o, "d", &action->rgba.r)) goto err;
66         return 0;
67     } else if(!strcmp(attr, "g")) {
68         if (!PyArg_Parse(o, "d", &action->rgba.g)) goto err;
69         return 0;
70     } else if(!strcmp(attr, "b")) {
71         if (!PyArg_Parse(o, "d", &action->rgba.b)) goto err;
72         return 0;
73     } else if(!strcmp(attr, "a")) {
74         if (!PyArg_Parse(o, "d", &action->rgba.a)) goto err;
75         return 0;
76     } 
77 err:
78     mylog("swf_setattr %08x(%d) %s = ? (%08x)\n", (int)self, self->ob_refcnt, attr, o);*/
79     return 1;
80 }
81
82 ActionTAG* action_getAction(PyObject*self)
83 {
84     ActionObject*action= 0;
85     if (!PyArg_Parse(self, "O!", &ActionClass, &action)) {
86         return 0;
87     }
88     return action->action;
89 }
90
91 PyTypeObject ActionClass = 
92 {
93     PyObject_HEAD_INIT(NULL)
94     0,
95     tp_name: "Action",
96     tp_basicsize: sizeof(ActionObject),
97     tp_itemsize: 0,
98     tp_dealloc: dummy_dealloc,
99     tp_print: 0,
100     tp_getattr: action_getattr,
101     tp_setattr: action_setattr,
102 };
103
104 static PyMethodDef action_methods[] = 
105 {
106     {"Action", (PyCFunction)f_Action, METH_KEYWORDS, "Create a new action object."},
107     {NULL, NULL, 0, NULL}
108 };
109
110 PyMethodDef* action_getMethods()
111 {
112     ActionClass.ob_type = &PyType_Type;
113     return action_methods;
114 }
115