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,
83 CONSTANT_UNKNOWN=0x55, /*used internally */
86 #define NS_TYPE(x) ((x) == 0x08 || (x) == 0x16 || (x) == 0x17 || (x) == 0x18 || (x) == 0x19 || (x) == 0x1a || (x) == 0x05)
99 constant_t* constant_clone();
100 constant_t* constant_new_int(int x);
101 constant_t* constant_new_uint(unsigned int x);
102 constant_t* constant_new_float(double x);
103 constant_t* constant_new_string(char*s);
104 constant_t* constant_new_string2(const char*s, int len);
105 constant_t* constant_new_namespace(namespace_t*ns);
106 constant_t* constant_new_true();
107 constant_t* constant_new_false();
108 constant_t* constant_new_null();
109 constant_t* constant_new_undefined();
110 char constant_has_index(constant_t*c);
111 constant_t* constant_fromindex(pool_t*pool, int index, int type);
112 char* constant_tostring(constant_t*c);
113 int constant_get_index(pool_t*pool, constant_t*c);
114 void constant_free(constant_t*c);
116 typedef enum multiname_type
130 char* access2str(int type);
136 struct _namespace_set {
137 namespace_list_t*namespaces;
140 extern type_t multiname_type;
142 multiname_type_t type;
144 namespace_set_t*namespace_set;
148 /* object -> string */
149 char* namespace_set_tostring(namespace_set_t*set);
150 char* multiname_tostring(multiname_t*m);
151 char* namespace_tostring(namespace_t*ns);
153 /* integer -> object */
154 int pool_lookup_int(pool_t*pool, int i);
155 unsigned int pool_lookup_uint(pool_t*pool, int i);
156 double pool_lookup_float(pool_t*pool, int i);
157 const char*pool_lookup_string(pool_t*pool, int i);
158 string_t pool_lookup_string2(pool_t*pool, int i);
159 namespace_t*pool_lookup_namespace(pool_t*pool, int i);
160 namespace_set_t*pool_lookup_namespace_set(pool_t*pool, int i);
161 multiname_t*pool_lookup_multiname(pool_t*pool, int i);
163 /* object -> integer (lookup) */
164 int pool_find_int(pool_t*pool, int x);
165 int pool_find_uint(pool_t*pool, unsigned int x);
166 int pool_find_double(pool_t*pool, double x);
167 int pool_find_namespace(pool_t*pool, namespace_t*ns);
168 int pool_find_namespace_set(pool_t*pool, namespace_set_t*set);
169 int pool_find_string(pool_t*pool, const char*s);
170 int pool_find_multiname(pool_t*pool, multiname_t*name);
172 /* object -> integer (lookup/creation) */
173 int pool_register_int(pool_t*p, int i);
174 int pool_register_uint(pool_t*p, unsigned int i);
175 int pool_register_float(pool_t*p, double d);
176 int pool_register_string(pool_t*pool, const char*s);
177 int pool_register_string2(pool_t*pool, string_t*s);
178 int pool_register_namespace(pool_t*pool, namespace_t*ns);
179 int pool_register_namespace_set(pool_t*pool, namespace_set_t*set);
180 int pool_register_multiname(pool_t*pool, multiname_t*n);
181 int pool_register_multiname2(pool_t*pool, char*name);
184 namespace_t* namespace_new(U8 access, const char*name);
185 namespace_t* namespace_new_namespace(const char*name);
186 namespace_t* namespace_new_package(const char*name);
187 namespace_t* namespace_new_packageinternal(const char*name);
188 namespace_t* namespace_new_protected(const char*name);
189 namespace_t* namespace_new_explicit(const char*name);
190 namespace_t* namespace_new_staticprotected(const char*name);
191 namespace_t* namespace_new_private(const char*name);
192 namespace_t* namespace_clone(namespace_t*ns);
194 namespace_t* namespace_fromstring(const char*name);
196 multiname_t* multiname_fromstring(const char*name);
197 multiname_t* multiname_new(namespace_t*ns, const char*name);
198 multiname_t* multiname_clone(multiname_t*other);
201 char multiname_late_namespace(multiname_t*m);
202 char multiname_late_name(multiname_t*m);
205 void multiname_destroy(multiname_t*m);
206 void namespace_destroy(namespace_t*n);
208 /* pool constructors/destructors */
210 void pool_optimize();
211 void pool_read(pool_t*pool, TAG*tag);
212 void pool_write(pool_t*pool, TAG*tag);
213 void pool_destroy(pool_t*pool);
214 void pool_dump(pool_t*pool, FILE*fo, char flags);