fix jsut committed crasher by rewriting startDrag action
[swfdec.git] / libswfdec / swfdec_as_object.h
blob2de6d0426459f0d0f305086ece9e84a4ccd23790
1 /* Swfdec
2 * Copyright (C) 2007 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #ifndef _SWFDEC_AS_OBJECT_H_
21 #define _SWFDEC_AS_OBJECT_H_
23 #include <glib-object.h>
24 #include <libswfdec/swfdec_as_types.h>
26 G_BEGIN_DECLS
28 /* NB: matches ASSetPropFlags */
29 typedef enum {
30 SWFDEC_AS_VARIABLE_HIDDEN = (1 << 0),
31 SWFDEC_AS_VARIABLE_PERMANENT = (1 << 1),
32 SWFDEC_AS_VARIABLE_CONSTANT = (1 << 2),
34 SWFDEC_AS_VARIABLE_VERSION_6_UP = (1 << 7),
35 SWFDEC_AS_VARIABLE_VERSION_NOT_6 = (1 << 8),
36 SWFDEC_AS_VARIABLE_VERSION_7_UP = (1 << 10),
37 SWFDEC_AS_VARIABLE_VERSION_8_UP = (1 << 12),
38 } SwfdecAsVariableFlag;
40 typedef enum {
41 SWFDEC_AS_DELETE_NOT_FOUND = 0,
42 SWFDEC_AS_DELETE_DELETED,
43 SWFDEC_AS_DELETE_NOT_DELETED
44 } SwfdecAsDeleteReturn;
46 typedef struct _SwfdecAsObjectClass SwfdecAsObjectClass;
47 typedef gboolean (* SwfdecAsVariableForeach) (SwfdecAsObject *object,
48 const char *variable, SwfdecAsValue *value, guint flags, gpointer data);
50 #define SWFDEC_TYPE_AS_OBJECT (swfdec_as_object_get_type())
51 #define SWFDEC_IS_AS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_OBJECT))
52 #define SWFDEC_IS_AS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_OBJECT))
53 #define SWFDEC_AS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_OBJECT, SwfdecAsObject))
54 #define SWFDEC_AS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_OBJECT, SwfdecAsObjectClass))
55 #define SWFDEC_AS_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_OBJECT, SwfdecAsObjectClass))
57 struct _SwfdecAsObject {
58 /*< protected >*/
59 GObject object;
60 SwfdecAsContext * context; /* context the object belongs to */
61 /*< private >*/
62 SwfdecAsObject * prototype; /* prototype object (referred to as __proto__) */
63 GHashTable * properties; /* string->SwfdecAsVariable mapping or NULL when not in GC */
64 guint8 flags; /* GC flags */
65 gsize size; /* size reserved in GC */
68 struct _SwfdecAsObjectClass {
69 GObjectClass object_class;
71 /* mark everything that should survive during GC */
72 void (* mark) (SwfdecAsObject * object);
73 /* object was added to the context */
74 void (* add) (SwfdecAsObject * object);
75 /* get the value and flags for a variables */
76 gboolean (* get) (SwfdecAsObject * object,
77 SwfdecAsObject * orig,
78 const char * variable,
79 SwfdecAsValue * val,
80 guint * flags);
81 /* set the variable - and return it (or NULL on error) */
82 void (* set) (SwfdecAsObject * object,
83 const char * variable,
84 const SwfdecAsValue * val,
85 guint default_flags);
86 /* set flags of a variable */
87 void (* set_flags) (SwfdecAsObject * object,
88 const char * variable,
89 guint flags,
90 guint mask);
91 /* delete the variable - return TRUE if it exists */
92 SwfdecAsDeleteReturn (* del) (SwfdecAsObject * object,
93 const char * variable);
94 /* call with every variable until func returns FALSE */
95 gboolean (* foreach) (SwfdecAsObject * object,
96 SwfdecAsVariableForeach func,
97 gpointer data);
98 /* get the real object referenced by this object (useful for internal objects) */
99 SwfdecAsObject * (* resolve) (SwfdecAsObject * object);
100 /* get a debug string representation for this object */
101 char * (* debug) (SwfdecAsObject * object);
104 GType swfdec_as_object_get_type (void);
106 SwfdecAsObject *swfdec_as_object_new (SwfdecAsContext * context);
107 SwfdecAsObject *swfdec_as_object_new_empty (SwfdecAsContext * context);
108 void swfdec_as_object_create (SwfdecAsFunction * fun,
109 guint n_args,
110 const SwfdecAsValue * args);
111 void swfdec_as_object_set_constructor(SwfdecAsObject * object,
112 SwfdecAsObject * construct);
113 SwfdecAsObject *swfdec_as_object_resolve (SwfdecAsObject * object);
114 char * swfdec_as_object_get_debug (SwfdecAsObject * object);
116 void swfdec_as_object_add (SwfdecAsObject * object,
117 SwfdecAsContext * context,
118 gsize size);
120 /* I'd like to name these [gs]et_property, but binding authors will complain
121 * about overlap with g_object_[gs]et_property then */
122 #define swfdec_as_object_set_variable(object, variable, value) \
123 swfdec_as_object_set_variable_and_flags (object, variable, value, 0)
124 void swfdec_as_object_set_variable_and_flags
125 (SwfdecAsObject * object,
126 const char * variable,
127 const SwfdecAsValue * value,
128 guint default_flags);
129 void swfdec_as_object_add_variable (SwfdecAsObject * object,
130 const char * variable,
131 SwfdecAsFunction * get,
132 SwfdecAsFunction * set);
133 #define swfdec_as_object_get_variable(object, variable, value) \
134 swfdec_as_object_get_variable_and_flags (object, variable, value, NULL, NULL)
135 gboolean swfdec_as_object_get_variable_and_flags
136 (SwfdecAsObject * object,
137 const char * variable,
138 SwfdecAsValue * value,
139 guint * flags,
140 SwfdecAsObject ** pobject);
141 SwfdecAsDeleteReturn
142 swfdec_as_object_delete_variable(SwfdecAsObject * object,
143 const char * variable);
144 void swfdec_as_object_set_variable_flags
145 (SwfdecAsObject * object,
146 const char * variable,
147 SwfdecAsVariableFlag flags);
148 void swfdec_as_object_unset_variable_flags
149 (SwfdecAsObject * object,
150 const char * variable,
151 SwfdecAsVariableFlag flags);
152 gboolean swfdec_as_object_foreach (SwfdecAsObject * object,
153 SwfdecAsVariableForeach func,
154 gpointer data);
156 SwfdecAsFunction *swfdec_as_object_add_function (SwfdecAsObject * object,
157 const char * name,
158 GType type,
159 SwfdecAsNative native,
160 guint min_args);
161 SwfdecAsFunction *swfdec_as_object_add_constructor
162 (SwfdecAsObject * object,
163 const char * name,
164 GType type,
165 GType construct_type,
166 SwfdecAsNative native,
167 guint min_args,
168 SwfdecAsObject * prototype);
170 gboolean swfdec_as_object_has_function (SwfdecAsObject * object,
171 const char * name);
172 void swfdec_as_object_call (SwfdecAsObject * object,
173 const char * name,
174 guint argc,
175 SwfdecAsValue * argv,
176 SwfdecAsValue * return_value);
177 void swfdec_as_object_run (SwfdecAsObject * object,
178 SwfdecScript * script);
180 const char* swfdec_as_object_to_string (SwfdecAsContext * context,
181 SwfdecAsObject * object);
184 G_END_DECLS
185 #endif