3 Routines for handling Flash2 AVM2 ABC contantpool entries.
5 Extension module for the rfxswf library.
6 Part of the swftools package.
8 Copyright (c) 2008 Matthias Kramm <kramm@quiss.org>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
28 #include "../rfxswf.h"
32 DECLARE_LIST(constant);
35 DECLARE(namespace_set);
36 DECLARE_LIST(multiname);
37 DECLARE_LIST(namespace);
40 /* abc file constant pool */
47 array_t*x_namespace_sets;
51 typedef enum access_type
52 {ACCESS_STANDARD=0x16,
55 ACCESS_PACKAGEINTERNAL=0x17,
56 ACCESS_PROTECTED=0x18,
58 ACCESS_STATICPROTECTED=0x1a,
64 typedef enum constant_type
74 CONSTANT_UNDEFINED=0x00,
76 CONSTANT_NAMESPACE=0x08,
77 CONSTANT_NAMESPACE_PACKAGE=0x16,
78 CONSTANT_NAMESPACE_PACKAGEINTERNAL=0x17,
79 CONSTANT_NAMESPACE_PROTECTED=0x18,
80 CONSTANT_NAMESPACE_EXPLICIT=0x19,
81 CONSTANT_NAMESPACE_STATICPROTECTED=0x1A,
82 CONSTANT_NAMESPACE_PRIVATE=0x05,
96 constant_t* constant_new_int(int x);
97 constant_t* constant_new_uint(unsigned int x);
98 constant_t* constant_new_float(double x);
99 constant_t* constant_new_string(char*s);
100 constant_t* constant_new_namespace(namespace_t*ns);
101 constant_t* constant_new_true();
102 constant_t* constant_new_false();
103 constant_t* constant_new_null();
104 constant_t* constant_new_undefined();
105 char constant_has_index(constant_t*c);
106 constant_t* constant_fromindex(pool_t*pool, int index, int type);
107 char* constant_tostring(constant_t*c);
108 int constant_get_index(pool_t*pool, constant_t*c);
109 void constant_free(constant_t*c);
111 typedef enum multiname_type
124 char* access2str(int type);
130 struct _namespace_set {
131 namespace_list_t*namespaces;
134 extern type_t multiname_type;
136 multiname_type_t type;
138 namespace_set_t*namespace_set;
142 /* object -> string */
143 char* namespace_set_tostring(namespace_set_t*set);
144 char* multiname_tostring(multiname_t*m);
145 char* namespace_tostring(namespace_t*ns);
147 /* integer -> object */
148 int pool_lookup_int(pool_t*pool, int i);
149 unsigned int pool_lookup_uint(pool_t*pool, int i);
150 double pool_lookup_float(pool_t*pool, int i);
151 char*pool_lookup_string(pool_t*pool, int i);
152 namespace_t*pool_lookup_namespace(pool_t*pool, int i);
153 namespace_set_t*pool_lookup_namespace_set(pool_t*pool, int i);
154 multiname_t*pool_lookup_multiname(pool_t*pool, int i);
156 /* object -> integer (lookup) */
157 int pool_find_int(pool_t*pool, int x);
158 int pool_find_uint(pool_t*pool, unsigned int x);
159 int pool_find_double(pool_t*pool, double x);
160 int pool_find_namespace(pool_t*pool, namespace_t*ns);
161 int pool_find_namespace_set(pool_t*pool, namespace_set_t*set);
162 int pool_find_string(pool_t*pool, const char*s);
163 int pool_find_multiname(pool_t*pool, multiname_t*name);
165 /* object -> integer (lookup/creation) */
166 int pool_register_int(pool_t*p, int i);
167 int pool_register_uint(pool_t*p, unsigned int i);
168 int pool_register_float(pool_t*p, double d);
169 int pool_register_string(pool_t*pool, const char*s);
170 int pool_register_namespace(pool_t*pool, namespace_t*ns);
171 int pool_register_namespace_set(pool_t*pool, namespace_set_t*set);
172 int pool_register_multiname(pool_t*pool, multiname_t*n);
173 int pool_register_multiname2(pool_t*pool, char*name);
176 namespace_t* namespace_new(U8 access, const char*name);
177 namespace_t* namespace_new_package(const char*name);
178 namespace_t* namespace_new_packageinternal(const char*name);
179 namespace_t* namespace_new_protected(const char*name);
180 namespace_t* namespace_new_explicit(const char*name);
181 namespace_t* namespace_new_staticprotected(const char*name);
182 namespace_t* namespace_new_private(const char*name);
183 namespace_t* namespace_clone(namespace_t*ns);
185 namespace_t* namespace_fromstring(const char*name);
187 multiname_t* multiname_fromstring(const char*name);
188 multiname_t* multiname_new(namespace_t*ns, const char*name);
189 multiname_t* multiname_clone(multiname_t*other);
192 char multiname_late_namespace(multiname_t*m);
193 char multiname_late_name(multiname_t*m);
196 void multiname_destroy(multiname_t*m);
197 void namespace_destroy(namespace_t*n);
199 /* pool constructors/destructors */
201 void pool_read(pool_t*pool, TAG*tag);
202 void pool_write(pool_t*pool, TAG*tag);
203 void pool_destroy(pool_t*pool);