fix build for --disable-gtk-doc
[swfdec.git] / swfdec / swfdec_as_context.h
blobb3492f45c73e625ec6995427cb2cf5033d331812
1 /* Swfdec
2 * Copyright (C) 2007-2008 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 <swfdec/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 or NULL if not initialized yet.
49 In SwfdecPlayer is NULL unless a sandbox is in use */
50 GRand * rand; /* random number generator */
51 GTimeVal start_time; /* time this movie started (for GetTime action) */
53 /* GC properties */
54 gsize memory_until_gc;/* amount of memory allocations that trigger a GC */
56 /* bookkeeping for GC */
57 gsize memory; /* total memory currently in use */
58 gsize memory_since_gc;/* memory allocated since last GC run */
59 GHashTable * interned_strings;/* string => memory mapping the context manages */
60 gpointer gc_objects; /* all SwfdecGcObjects the context manages */
61 gpointer objects; /* all objects the context manages */
62 gpointer strings; /* all strings the context manages */
63 gpointer numbers; /* all numbers the context manages */
64 gpointer movies; /* all movies the context manages */
65 GHashTable * constant_pools; /* memory address => SwfdecConstantPool for all gc'ed pools */
67 /* execution state */
68 unsigned int version; /* currently active version */
69 unsigned int call_depth; /* current depth of call stack (equals length of frame list) */
70 SwfdecAsFrame * frame; /* topmost stack frame */
71 gboolean exception; /* whether we are throwing an exception */
72 SwfdecAsValue exception_value; /* value of the exception being thrown, can be anything including undefined */
74 /* stack */
75 SwfdecAsValue * base; /* stack base */
76 SwfdecAsValue * end; /* end of stack */
77 SwfdecAsValue * cur; /* pointer to current top of stack */
78 SwfdecAsStack * stack; /* current stack */
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);
92 /* overwrite if you want to abort on infinite loops */
93 gboolean (* check_continue) (SwfdecAsContext * context);
96 GType swfdec_as_context_get_type (void);
98 void swfdec_as_context_startup (SwfdecAsContext * context);
100 gboolean swfdec_as_context_is_aborted (SwfdecAsContext * context);
101 gboolean swfdec_as_context_is_constructing
102 (SwfdecAsContext * context);
103 SwfdecAsFrame * swfdec_as_context_get_frame (SwfdecAsContext * context);
104 void swfdec_as_context_get_time (SwfdecAsContext * context,
105 GTimeVal * tv);
106 const char * swfdec_as_context_get_string (SwfdecAsContext * context,
107 const char * string);
108 const char * swfdec_as_context_give_string (SwfdecAsContext * context,
109 char * string);
111 void swfdec_as_context_abort (SwfdecAsContext * context,
112 const char * reason);
114 void swfdec_as_context_throw (SwfdecAsContext * context,
115 const SwfdecAsValue * value);
116 gboolean swfdec_as_context_catch (SwfdecAsContext * context,
117 SwfdecAsValue * value);
119 gboolean swfdec_as_context_try_use_mem (SwfdecAsContext * context,
120 gsize bytes);
121 void swfdec_as_context_use_mem (SwfdecAsContext * context,
122 gsize bytes);
123 void swfdec_as_context_unuse_mem (SwfdecAsContext * context,
124 gsize bytes);
125 void swfdec_as_value_mark (SwfdecAsValue * value);
126 void swfdec_as_string_mark (const char * string);
127 void swfdec_as_context_gc (SwfdecAsContext * context);
128 void swfdec_as_context_maybe_gc (SwfdecAsContext * context);
131 G_END_DECLS
132 #endif