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,
54 ACCESS_PACKAGEINTERNAL=0x17,
55 ACCESS_PROTECTED=0x18,
57 ACCESS_STATICPROTECTED=0x1a,
62 typedef enum constant_type
72 CONSTANT_UNDEFINED=0x00,
74 CONSTANT_NAMESPACE=0x08,
75 CONSTANT_NAMESPACE_PACKAGE=0x16,
76 CONSTANT_NAMESPACE_PACKAGEINTERNAL=0x17,
77 CONSTANT_NAMESPACE_PROTECTED=0x18,
78 CONSTANT_NAMESPACE_EXPLICIT=0x19,
79 CONSTANT_NAMESPACE_STATICPROTECTED=0x1A,
80 CONSTANT_NAMESPACE_PRIVATE=0x05,
94 constant_t* constant_new_int(int x);
95 constant_t* constant_new_uint(unsigned int x);
96 constant_t* constant_new_float(double x);
97 constant_t* constant_new_string(char*s);
98 constant_t* constant_new_namespace(namespace_t*ns);
99 constant_t* constant_new_true();
100 constant_t* constant_new_false();
101 constant_t* constant_new_null();
102 constant_t* constant_new_undefined();
103 char constant_has_index(constant_t*c);
104 constant_t* constant_fromindex(pool_t*pool, int index, int type);
105 char* constant_tostring(constant_t*c);
106 int constant_get_index(pool_t*pool, constant_t*c);
107 void constant_free(constant_t*c);
109 typedef enum multiname_type
122 char* access2str(int type);
128 struct _namespace_set {
129 namespace_list_t*namespaces;
132 extern type_t multiname_type;
134 multiname_type_t type;
136 namespace_set_t*namespace_set;
140 /* object -> string */
141 char* namespace_set_tostring(namespace_set_t*set);
142 char* multiname_tostring(multiname_t*m);
143 char* namespace_tostring(namespace_t*ns);
145 /* integer -> object */
146 int pool_lookup_int(pool_t*pool, int i);
147 unsigned int pool_lookup_uint(pool_t*pool, int i);
148 double pool_lookup_float(pool_t*pool, int i);
149 char*pool_lookup_string(pool_t*pool, int i);
150 namespace_t*pool_lookup_namespace(pool_t*pool, int i);
151 namespace_set_t*pool_lookup_namespace_set(pool_t*pool, int i);
152 multiname_t*pool_lookup_multiname(pool_t*pool, int i);
154 /* object -> integer (lookup) */
155 int pool_find_int(pool_t*pool, int x);
156 int pool_find_uint(pool_t*pool, unsigned int x);
157 int pool_find_double(pool_t*pool, double x);
158 int pool_find_namespace(pool_t*pool, namespace_t*ns);
159 int pool_find_namespace_set(pool_t*pool, namespace_set_t*set);
160 int pool_find_string(pool_t*pool, const char*s);
161 int pool_find_multiname(pool_t*pool, multiname_t*name);
163 /* object -> integer (lookup/creation) */
164 int pool_register_int(pool_t*p, int i);
165 int pool_register_uint(pool_t*p, unsigned int i);
166 int pool_register_float(pool_t*p, double d);
167 int pool_register_string(pool_t*pool, const char*s);
168 int pool_register_namespace(pool_t*pool, namespace_t*ns);
169 int pool_register_namespace_set(pool_t*pool, namespace_set_t*set);
170 int pool_register_multiname(pool_t*pool, multiname_t*n);
171 int pool_register_multiname2(pool_t*pool, char*name);
174 namespace_t* namespace_new(U8 access, const char*name);
175 namespace_t* namespace_new_package(const char*name);
176 namespace_t* namespace_new_packageinternal(const char*name);
177 namespace_t* namespace_new_protected(const char*name);
178 namespace_t* namespace_new_explicit(const char*name);
179 namespace_t* namespace_new_staticprotected(const char*name);
180 namespace_t* namespace_new_private(const char*name);
181 namespace_t* namespace_clone(namespace_t*ns);
183 namespace_t* namespace_fromstring(const char*name);
185 multiname_t* multiname_fromstring(const char*name);
186 multiname_t* multiname_new(namespace_t*ns, const char*name);
187 multiname_t* multiname_clone(multiname_t*other);
190 char multiname_late_namespace(multiname_t*m);
191 char multiname_late_name(multiname_t*m);
194 void multiname_destroy(multiname_t*m);
195 void namespace_destroy(namespace_t*n);
197 /* pool constructors/destructors */
199 void pool_read(pool_t*pool, TAG*tag);
200 void pool_write(pool_t*pool, TAG*tag);
201 void pool_destroy(pool_t*pool);