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_string2(const char*s, int len);
101 constant_t* constant_new_namespace(namespace_t*ns);
102 constant_t* constant_new_true();
103 constant_t* constant_new_false();
104 constant_t* constant_new_null();
105 constant_t* constant_new_undefined();
106 char constant_has_index(constant_t*c);
107 constant_t* constant_fromindex(pool_t*pool, int index, int type);
108 char* constant_tostring(constant_t*c);
109 int constant_get_index(pool_t*pool, constant_t*c);
110 void constant_free(constant_t*c);
112 typedef enum multiname_type
126 char* access2str(int type);
132 struct _namespace_set {
133 namespace_list_t*namespaces;
136 extern type_t multiname_type;
138 multiname_type_t type;
140 namespace_set_t*namespace_set;
144 /* object -> string */
145 char* namespace_set_tostring(namespace_set_t*set);
146 char* multiname_tostring(multiname_t*m);
147 char* namespace_tostring(namespace_t*ns);
149 /* integer -> object */
150 int pool_lookup_int(pool_t*pool, int i);
151 unsigned int pool_lookup_uint(pool_t*pool, int i);
152 double pool_lookup_float(pool_t*pool, int i);
153 const char*pool_lookup_string(pool_t*pool, int i);
154 string_t pool_lookup_string2(pool_t*pool, int i);
155 namespace_t*pool_lookup_namespace(pool_t*pool, int i);
156 namespace_set_t*pool_lookup_namespace_set(pool_t*pool, int i);
157 multiname_t*pool_lookup_multiname(pool_t*pool, int i);
159 /* object -> integer (lookup) */
160 int pool_find_int(pool_t*pool, int x);
161 int pool_find_uint(pool_t*pool, unsigned int x);
162 int pool_find_double(pool_t*pool, double x);
163 int pool_find_namespace(pool_t*pool, namespace_t*ns);
164 int pool_find_namespace_set(pool_t*pool, namespace_set_t*set);
165 int pool_find_string(pool_t*pool, const char*s);
166 int pool_find_multiname(pool_t*pool, multiname_t*name);
168 /* object -> integer (lookup/creation) */
169 int pool_register_int(pool_t*p, int i);
170 int pool_register_uint(pool_t*p, unsigned int i);
171 int pool_register_float(pool_t*p, double d);
172 int pool_register_string(pool_t*pool, const char*s);
173 int pool_register_string2(pool_t*pool, string_t*s);
174 int pool_register_namespace(pool_t*pool, namespace_t*ns);
175 int pool_register_namespace_set(pool_t*pool, namespace_set_t*set);
176 int pool_register_multiname(pool_t*pool, multiname_t*n);
177 int pool_register_multiname2(pool_t*pool, char*name);
180 namespace_t* namespace_new(U8 access, const char*name);
181 namespace_t* namespace_new_package(const char*name);
182 namespace_t* namespace_new_packageinternal(const char*name);
183 namespace_t* namespace_new_protected(const char*name);
184 namespace_t* namespace_new_explicit(const char*name);
185 namespace_t* namespace_new_staticprotected(const char*name);
186 namespace_t* namespace_new_private(const char*name);
187 namespace_t* namespace_clone(namespace_t*ns);
189 namespace_t* namespace_fromstring(const char*name);
191 multiname_t* multiname_fromstring(const char*name);
192 multiname_t* multiname_new(namespace_t*ns, const char*name);
193 multiname_t* multiname_clone(multiname_t*other);
196 char multiname_late_namespace(multiname_t*m);
197 char multiname_late_name(multiname_t*m);
200 void multiname_destroy(multiname_t*m);
201 void namespace_destroy(namespace_t*n);
203 /* pool constructors/destructors */
205 void pool_optimize();
206 void pool_read(pool_t*pool, TAG*tag);
207 void pool_write(pool_t*pool, TAG*tag);
208 void pool_destroy(pool_t*pool);
209 void pool_dump(pool_t*pool, FILE*fo, char flags);