1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
/* pool.h
Routines for handling Flash2 AVM2 ABC contantpool entries.
Extension module for the rfxswf library.
Part of the swftools package.
Copyright (c) 2008 Matthias Kramm <kramm@quiss.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef __pool_h__
#define __pool_h__
#include "../q.h"
#include "../rfxswf.h"
DECLARE(pool);
DECLARE(constant);
DECLARE_LIST(constant);
DECLARE(multiname);
DECLARE(namespace);
DECLARE(namespace_set);
DECLARE_LIST(multiname);
DECLARE_LIST(namespace);
DECLARE_LIST(trait);
/* abc file constant pool */
struct _pool {
array_t*x_ints;
array_t*x_uints;
array_t*x_floats;
array_t*x_strings;
array_t*x_namespaces;
array_t*x_namespace_sets;
array_t*x_multinames;
};
typedef enum access_type
{ACCESS_STANDARD=0x16,
ACCESS_PACKAGE=0x16,
ACCESS_PUBLIC=0x16,
ACCESS_PACKAGEINTERNAL=0x17,
ACCESS_PROTECTED=0x18,
ACCESS_EXPLICIT=0x19,
ACCESS_STATICPROTECTED=0x1a,
ACCESS_PRIVATE=0x05,
ACCESS_NAMESPACE=0x08
} access_type_t;
typedef enum constant_type
{
CONSTANT_STRING=0x01,
CONSTANT_INT=0x03,
CONSTANT_UINT=0x04,
CONSTANT_FLOAT=0x06,
CONSTANT_TRUE=0x0B,
CONSTANT_FALSE=0x0A,
CONSTANT_NULL=0x0C,
CONSTANT_UNDEFINED=0x00,
CONSTANT_NAMESPACE=0x08,
CONSTANT_NAMESPACE_PACKAGE=0x16,
CONSTANT_NAMESPACE_PACKAGEINTERNAL=0x17,
CONSTANT_NAMESPACE_PROTECTED=0x18,
CONSTANT_NAMESPACE_EXPLICIT=0x19,
CONSTANT_NAMESPACE_STATICPROTECTED=0x1A,
CONSTANT_NAMESPACE_PRIVATE=0x05,
} contant_type_t;
struct _constant {
union {
double f;
int i;
unsigned int u;
string_t* s;
namespace_t*ns;
};
int type;
};
constant_t* constant_new_int(int x);
constant_t* constant_new_uint(unsigned int x);
constant_t* constant_new_float(double x);
constant_t* constant_new_string(char*s);
constant_t* constant_new_string2(const char*s, int len);
constant_t* constant_new_namespace(namespace_t*ns);
constant_t* constant_new_true();
constant_t* constant_new_false();
constant_t* constant_new_null();
constant_t* constant_new_undefined();
char constant_has_index(constant_t*c);
constant_t* constant_fromindex(pool_t*pool, int index, int type);
char* constant_tostring(constant_t*c);
int constant_get_index(pool_t*pool, constant_t*c);
void constant_free(constant_t*c);
typedef enum multiname_type
{QNAME=0x07,
RTQNAME=0x0F,
RTQNAMEL=0x11,
MULTINAME=0x09,
MULTINAMEL=0x1B,
QNAMEA=0x0D,
RTQNAMEA=0x10,
RTQNAMELA=0x12,
MULTINAMEA=0x0E,
MULTINAMELA=0x1C
} multiname_type_t;
char* access2str(int type);
struct _namespace {
U8 access;
char*name;
};
struct _namespace_set {
namespace_list_t*namespaces;
};
extern type_t multiname_type;
struct _multiname {
multiname_type_t type;
namespace_t*ns;
namespace_set_t*namespace_set;
const char*name;
};
/* object -> string */
char* namespace_set_tostring(namespace_set_t*set);
char* multiname_tostring(multiname_t*m);
char* namespace_tostring(namespace_t*ns);
/* integer -> object */
int pool_lookup_int(pool_t*pool, int i);
unsigned int pool_lookup_uint(pool_t*pool, int i);
double pool_lookup_float(pool_t*pool, int i);
const char*pool_lookup_string(pool_t*pool, int i);
string_t pool_lookup_string2(pool_t*pool, int i);
namespace_t*pool_lookup_namespace(pool_t*pool, int i);
namespace_set_t*pool_lookup_namespace_set(pool_t*pool, int i);
multiname_t*pool_lookup_multiname(pool_t*pool, int i);
/* object -> integer (lookup) */
int pool_find_int(pool_t*pool, int x);
int pool_find_uint(pool_t*pool, unsigned int x);
int pool_find_double(pool_t*pool, double x);
int pool_find_namespace(pool_t*pool, namespace_t*ns);
int pool_find_namespace_set(pool_t*pool, namespace_set_t*set);
int pool_find_string(pool_t*pool, const char*s);
int pool_find_multiname(pool_t*pool, multiname_t*name);
/* object -> integer (lookup/creation) */
int pool_register_int(pool_t*p, int i);
int pool_register_uint(pool_t*p, unsigned int i);
int pool_register_float(pool_t*p, double d);
int pool_register_string(pool_t*pool, const char*s);
int pool_register_string2(pool_t*pool, string_t*s);
int pool_register_namespace(pool_t*pool, namespace_t*ns);
int pool_register_namespace_set(pool_t*pool, namespace_set_t*set);
int pool_register_multiname(pool_t*pool, multiname_t*n);
int pool_register_multiname2(pool_t*pool, char*name);
/* creation */
namespace_t* namespace_new(U8 access, const char*name);
namespace_t* namespace_new_package(const char*name);
namespace_t* namespace_new_packageinternal(const char*name);
namespace_t* namespace_new_protected(const char*name);
namespace_t* namespace_new_explicit(const char*name);
namespace_t* namespace_new_staticprotected(const char*name);
namespace_t* namespace_new_private(const char*name);
namespace_t* namespace_clone(namespace_t*ns);
namespace_t* namespace_fromstring(const char*name);
multiname_t* multiname_fromstring(const char*name);
multiname_t* multiname_new(namespace_t*ns, const char*name);
multiname_t* multiname_clone(multiname_t*other);
/* accessors etc. */
char multiname_late_namespace(multiname_t*m);
char multiname_late_name(multiname_t*m);
/* freeing */
void multiname_destroy(multiname_t*m);
void namespace_destroy(namespace_t*n);
/* pool constructors/destructors */
pool_t*pool_new();
void pool_read(pool_t*pool, TAG*tag);
void pool_write(pool_t*pool, TAG*tag);
void pool_destroy(pool_t*pool);
void pool_dump(pool_t*pool, FILE*fo);
#endif
|