add blend mode tests
[swfdec.git] / swfdec / swfdec_as_internal.h
blobcf066d3f09728c5de286626ea0f85a49a304cf2e
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_INTERNAL_H_
21 #define _SWFDEC_AS_INTERNAL_H_
23 #include <swfdec/swfdec_as_gcable.h>
24 #include <swfdec/swfdec_as_movie_value.h>
25 #include <swfdec/swfdec_as_object.h>
26 #include <swfdec/swfdec_as_types.h>
27 #include <swfdec/swfdec_movie.h>
29 G_BEGIN_DECLS
31 /* This header contains all the non-exported symbols that can't go into
32 * exported headers
34 #define SWFDEC_AS_NATIVE(x, y, func) void func (SwfdecAsContext *cx, \
35 SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret);
37 #define SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT 256
39 /* swfdec_as_types.h */
40 #define SWFDEC_AS_TYPE_IS_GCABLE(type) ((type) & 4)
42 #define SWFDEC_AS_VALUE_IS_COMPOSITE(val) (SWFDEC_AS_VALUE_GET_TYPE (val) >= SWFDEC_AS_TYPE_OBJECT)
43 #define SWFDEC_AS_VALUE_IS_PRIMITIVE(val) (!SWFDEC_AS_VALUE_IS_COMPOSITE(val))
44 /* FIXME: ugly macro */
45 #define SWFDEC_AS_VALUE_GET_COMPOSITE(val) (SWFDEC_AS_VALUE_IS_OBJECT (val) ? \
46 SWFDEC_AS_VALUE_GET_OBJECT (val) : (SWFDEC_AS_VALUE_GET_MOVIE (val) ? \
47 swfdec_as_relay_get_as_object (SWFDEC_AS_RELAY (SWFDEC_AS_VALUE_GET_MOVIE (val))) : NULL))
48 #define SWFDEC_AS_VALUE_SET_COMPOSITE(val,o) G_STMT_START { \
49 SwfdecAsObject *_o = (o); \
50 if (_o->movie) { \
51 SWFDEC_AS_VALUE_SET_MOVIE ((val), SWFDEC_MOVIE (_o->relay)); \
52 } else { \
53 SWFDEC_AS_VALUE_SET_OBJECT ((val), _o); \
54 } \
55 } G_STMT_END
57 #define SWFDEC_AS_VALUE_IS_MOVIE(val) (SWFDEC_AS_VALUE_GET_TYPE (val) == SWFDEC_AS_TYPE_MOVIE)
58 #define SWFDEC_AS_VALUE_GET_MOVIE(val) (((SwfdecAsMovieValue *) SWFDEC_AS_VALUE_GET_VALUE (val))->movie ? \
59 ((SwfdecAsMovieValue *) SWFDEC_AS_VALUE_GET_VALUE (val))->movie : swfdec_as_movie_value_get (SWFDEC_AS_VALUE_GET_VALUE (val)))
60 #define SWFDEC_AS_VALUE_FROM_MOVIE(m) SWFDEC_AS_VALUE_COMBINE (m->as_value, SWFDEC_AS_TYPE_MOVIE)
61 #define SWFDEC_AS_VALUE_SET_MOVIE(val,m) G_STMT_START { \
62 SwfdecMovie *__m = (m); \
63 g_assert (SWFDEC_IS_MOVIE (__m)); \
64 g_assert (__m->as_value); \
65 *(val) = SWFDEC_AS_VALUE_FROM_MOVIE (__m); \
66 } G_STMT_END
68 /* swfdec_as_context.c */
69 gboolean swfdec_as_context_check_continue (SwfdecAsContext * context);
70 void swfdec_as_context_return (SwfdecAsContext * context,
71 SwfdecAsValue * return_value);
72 void swfdec_as_context_run (SwfdecAsContext * context);
73 void swfdec_as_context_run_init_script (SwfdecAsContext * context,
74 const guint8 * data,
75 gsize length,
76 guint version);
77 void swfdec_as_context_gc_alloc (SwfdecAsContext * context,
78 gsize size);
79 #define swfdec_as_context_gc_new(context,type) ((type *)swfdec_as_context_gc_alloc ((context), sizeof (type)))
81 /* swfdec_as_object.c */
82 typedef SwfdecAsVariableForeach SwfdecAsVariableForeachRemove;
83 typedef const char *(* SwfdecAsVariableForeachRename) (SwfdecAsObject *object,
84 const char *variable, SwfdecAsValue *value, guint flags, gpointer data);
86 void swfdec_as_object_free (SwfdecAsContext * context,
87 SwfdecAsObject * object);
88 SwfdecAsValue * swfdec_as_object_peek_variable (SwfdecAsObject * object,
89 const char * name);
90 guint swfdec_as_object_foreach_remove (SwfdecAsObject * object,
91 SwfdecAsVariableForeach func,
92 gpointer data);
93 void swfdec_as_object_foreach_rename (SwfdecAsObject * object,
94 SwfdecAsVariableForeachRename func,
95 gpointer data);
97 void swfdec_as_object_init_context (SwfdecAsContext * context);
98 void swfdec_as_object_decode (SwfdecAsObject * obj,
99 const char * str);
100 SwfdecAsObject * swfdec_as_object_get_prototype (SwfdecAsObject * object);
101 void swfdec_as_object_add_native_variable (SwfdecAsObject * object,
102 const char * variable,
103 SwfdecAsNative get,
104 SwfdecAsNative set);
106 /* swfdec_as_native_function.h */
107 SwfdecAsFunction *
108 swfdec_as_native_function_new_bare
109 (SwfdecAsContext * context,
110 const char * name,
111 SwfdecAsNative native);
113 /* swfdec_as_array.h */
114 void swfdec_as_array_remove_range (SwfdecAsObject * object,
115 gint32 start_index,
116 gint32 num);
119 G_END_DECLS
120 #endif