fix jsut committed crasher by rewriting startDrag action
[swfdec.git] / libswfdec / swfdec_as_context.h
blobfbcb6e99f55b1df668f3d130575b05e751715e1c
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_CONTEXT_H_
21 #define _SWFDEC_AS_CONTEXT_H_
23 #include <glib-object.h>
24 #include <libswfdec/swfdec_as_types.h>
26 G_BEGIN_DECLS
28 typedef enum {
29 SWFDEC_AS_CONTEXT_NEW,
30 SWFDEC_AS_CONTEXT_RUNNING,
31 SWFDEC_AS_CONTEXT_INTERRUPTED,
32 SWFDEC_AS_CONTEXT_ABORTED
33 } SwfdecAsContextState;
35 typedef struct _SwfdecAsContextClass SwfdecAsContextClass;
37 #define SWFDEC_TYPE_AS_CONTEXT (swfdec_as_context_get_type())
38 #define SWFDEC_IS_AS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_CONTEXT))
39 #define SWFDEC_IS_AS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_CONTEXT))
40 #define SWFDEC_AS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_CONTEXT, SwfdecAsContext))
41 #define SWFDEC_AS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_CONTEXT, SwfdecAsContextClass))
42 #define SWFDEC_AS_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_CONTEXT, SwfdecAsContextClass))
44 struct _SwfdecAsContext {
45 GObject object;
47 SwfdecAsContextState state; /* our current state */
48 SwfdecAsObject * global; /* the global object */
49 GRand * rand; /* random number generator */
50 GTimeVal start_time; /* time this movie started (for GetTime action) */
52 /* GC properties */
53 gsize memory_until_gc;/* amount of memory allocations that trigger a GC */
55 /* bookkeeping for GC */
56 gsize memory; /* total memory currently in use */
57 gsize memory_since_gc;/* memory allocated since last GC run */
58 GHashTable * strings; /* string=>memory mapping the context manages */
59 GHashTable * objects; /* all objects the context manages */
61 /* execution state */
62 unsigned int version; /* currently active version */
63 unsigned int call_depth; /* current depth of call stack (equals length of frame list) */
64 SwfdecAsFrame * frame; /* topmost stack frame */
65 SwfdecAsFrame * last_frame; /* last frame before calling context_run */
67 /* stack */
68 SwfdecAsValue * base; /* stack base */
69 SwfdecAsValue * end; /* end of stack */
70 SwfdecAsValue * cur; /* pointer to current top of stack */
71 SwfdecAsStack * stack; /* current stack */
73 /* magic objects - initialized during swfdec_as_context_startup() */
74 SwfdecAsObject * Function; /* Function */
75 SwfdecAsObject * Function_prototype; /* Function.prototype - NULL in Flash 5 */
76 SwfdecAsObject * Object; /* Object */
77 SwfdecAsObject * Object_prototype; /* Object.prototype */
78 SwfdecAsObject * Array; /* Array */
80 /* debugging */
81 SwfdecAsDebugger * debugger; /* debugger (or NULL if none) */
84 struct _SwfdecAsContextClass {
85 GObjectClass object_class;
87 /* mark all objects that should not be collected */
88 void (* mark) (SwfdecAsContext * context);
89 /* overwrite if you want to report a different time than gettimeofday */
90 void (* get_time) (SwfdecAsContext * context,
91 GTimeVal * tv);
94 GType swfdec_as_context_get_type (void);
96 void swfdec_as_context_startup (SwfdecAsContext * context,
97 guint version);
99 gboolean swfdec_as_context_is_constructing
100 (SwfdecAsContext * context);
101 SwfdecAsFrame * swfdec_as_context_get_frame (SwfdecAsContext * context);
102 void swfdec_as_context_get_time (SwfdecAsContext * context,
103 GTimeVal * tv);
104 const char * swfdec_as_context_get_string (SwfdecAsContext * context,
105 const char * string);
106 const char * swfdec_as_context_give_string (SwfdecAsContext * context,
107 char * string);
109 void swfdec_as_context_abort (SwfdecAsContext * context,
110 const char * reason);
112 gboolean swfdec_as_context_use_mem (SwfdecAsContext * context,
113 gsize bytes);
114 void swfdec_as_context_unuse_mem (SwfdecAsContext * context,
115 gsize bytes);
116 void swfdec_as_object_mark (SwfdecAsObject * object);
117 void swfdec_as_value_mark (SwfdecAsValue * value);
118 void swfdec_as_string_mark (const char * string);
119 void swfdec_as_context_gc (SwfdecAsContext * context);
120 void swfdec_as_context_maybe_gc (SwfdecAsContext * context);
122 void swfdec_as_context_run (SwfdecAsContext * context);
124 void swfdec_as_context_eval (SwfdecAsContext * context,
125 SwfdecAsObject * obj,
126 const char * str,
127 SwfdecAsValue * val);
128 void swfdec_as_context_eval_set (SwfdecAsContext * context,
129 SwfdecAsObject * obj,
130 const char * str,
131 const SwfdecAsValue * val);
133 G_END_DECLS
134 #endif