git.asbjorn.biz
/
swftools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added TYPE_ macros
[swftools.git]
/
lib
/
as3
/
pool.c
diff --git
a/lib/as3/pool.c
b/lib/as3/pool.c
index
ffea0e6
..
6ce37d3
100644
(file)
--- a/
lib/as3/pool.c
+++ b/
lib/as3/pool.c
@@
-211,6
+211,7
@@
namespace_t* namespace_fromstring(const char*name)
if(!strcmp(a, "")) access=0x16;
else if(!strcmp(a, "undefined")) access=0x08; // public??
else if(!strcmp(a, "package")) access=0x16;
if(!strcmp(a, "")) access=0x16;
else if(!strcmp(a, "undefined")) access=0x08; // public??
else if(!strcmp(a, "package")) access=0x16;
+ else if(!strcmp(a, "public")) access=0x16;
else if(!strcmp(a, "packageinternal")) access=0x17;
else if(!strcmp(a, "protected")) access=0x18;
else if(!strcmp(a, "explicit")) access=0x19;
else if(!strcmp(a, "packageinternal")) access=0x17;
else if(!strcmp(a, "protected")) access=0x18;
else if(!strcmp(a, "explicit")) access=0x19;
@@
-472,7
+473,7
@@
multiname_t* multiname_clone(multiname_t*other)
char* access2str(int type)
{
if(type==0x08) return "access08";
char* access2str(int type)
{
if(type==0x08) return "access08";
- else if(type==0x16) return "package";
+ else if(type==0x16) return "public";
else if(type==0x17) return "packageinternal";
else if(type==0x18) return "protected";
else if(type==0x19) return "explicit";
else if(type==0x17) return "packageinternal";
else if(type==0x18) return "protected";
else if(type==0x19) return "explicit";
@@
-719,7
+720,7
@@
char* constant_tostring(constant_t*c)
{
if(!c)
return 0;
{
if(!c)
return 0;
- char buf[30];
+ char buf[32];
if(NS_TYPE(c->type)) {
return namespace_tostring(c->ns);
} else if(c->type == CONSTANT_INT) {
if(NS_TYPE(c->type)) {
return namespace_tostring(c->ns);
} else if(c->type == CONSTANT_INT) {
@@
-729,6
+730,7
@@
char* constant_tostring(constant_t*c)
sprintf(buf, "%u", c->u);
return strdup(buf);
} else if(c->type == CONSTANT_FLOAT) {
sprintf(buf, "%u", c->u);
return strdup(buf);
} else if(c->type == CONSTANT_FLOAT) {
+ char buf[1024];
sprintf(buf, "%f", c->f);
return strdup(buf);
} else if(c->type == CONSTANT_STRING) {
sprintf(buf, "%f", c->f);
return strdup(buf);
} else if(c->type == CONSTANT_STRING) {
@@
-812,7
+814,8
@@
int pool_register_float(pool_t*p, double d)
int pool_register_string(pool_t*pool, const char*s)
{
if(!s) return 0;
int pool_register_string(pool_t*pool, const char*s)
{
if(!s) return 0;
- int pos = array_append_if_new(pool->x_strings, s, 0);
+ ptroff_t l = strlen(s);
+ int pos = array_append_if_new(pool->x_strings, s, (void*)l);
assert(pos!=0);
return pos;
}
assert(pos!=0);
return pos;
}
@@
-834,9
+837,6
@@
int pool_register_multiname(pool_t*pool, multiname_t*n)
{
if(!n) return 0;
int pos = array_append_if_new(pool->x_multinames, n, 0);
{
if(!n) return 0;
int pos = array_append_if_new(pool->x_multinames, n, 0);
- if(pos==0) {
- *(int*)0=0xdead;
- }
assert(pos!=0);
return pos;
}
assert(pos!=0);
return pos;
}
@@
-948,6
+948,12
@@
char*pool_lookup_string(pool_t*pool, int i)
{
return (char*)array_getkey(pool->x_strings, i);
}
{
return (char*)array_getkey(pool->x_strings, i);
}
+string_t pool_lookup_string2(pool_t*pool, int i)
+{
+ char*s = (char*)array_getkey(pool->x_strings, i);
+ int len = (int)(ptroff_t)array_getvalue(pool->x_strings, i);
+ return string_new(s,len);
+}
namespace_t*pool_lookup_namespace(pool_t*pool, int i)
{
return (namespace_t*)array_getkey(pool->x_namespaces, i);
namespace_t*pool_lookup_namespace(pool_t*pool, int i)
{
return (namespace_t*)array_getkey(pool->x_namespaces, i);
@@
-994,7
+1000,7
@@
void pool_read(pool_t*pool, TAG*tag)
DEBUG printf("%d ints\n", num_ints);
int t;
for(t=1;t<num_ints;t++) {
DEBUG printf("%d ints\n", num_ints);
int t;
for(t=1;t<num_ints;t++) {
- S32 v = swf_GetS30(tag);
+ S32 v = swf_GetABCS32(tag);
DEBUG printf("int %d) %d\n", t, v);
array_append(pool->x_ints, &v, 0);
}
DEBUG printf("int %d) %d\n", t, v);
array_append(pool->x_ints, &v, 0);
}
@@
-1002,7
+1008,7
@@
void pool_read(pool_t*pool, TAG*tag)
int num_uints = swf_GetU30(tag);
DEBUG printf("%d uints\n", num_uints);
for(t=1;t<num_uints;t++) {
int num_uints = swf_GetU30(tag);
DEBUG printf("%d uints\n", num_uints);
for(t=1;t<num_uints;t++) {
- U32 v = swf_GetU30(tag);
+ U32 v = swf_GetABCU32(tag);
DEBUG printf("uint %d) %d\n", t, v);
array_append(pool->x_uints, &v, 0);
}
DEBUG printf("uint %d) %d\n", t, v);
array_append(pool->x_uints, &v, 0);
}
@@
-1022,7
+1028,7
@@
void pool_read(pool_t*pool, TAG*tag)
char*s = malloc(len+1);
swf_GetBlock(tag, s, len);
s[len] = 0;
char*s = malloc(len+1);
swf_GetBlock(tag, s, len);
s[len] = 0;
- array_append(pool->x_strings, s, 0);
+ array_append(pool->x_strings, s, (void*)(ptroff_t)len);
free(s);
DEBUG printf("%d) \"%s\"\n", t, pool->x_strings->d[t].name);
}
free(s);
DEBUG printf("%d) \"%s\"\n", t, pool->x_strings->d[t].name);
}
@@
-1125,7
+1131,7
@@
void pool_write(pool_t*pool, TAG*tag)
However when actually using zero strings as empty namespaces, the
flash player breaks.*/
//if(ns->name && ns->name[0])
However when actually using zero strings as empty namespaces, the
flash player breaks.*/
//if(ns->name && ns->name[0])
- array_append_if_new(pool->x_strings, ns->name, 0);
+ pool_register_string(pool, ns->name);
}
//pool_register_int(pool, 15);
}
//pool_register_int(pool, 15);
@@
-1136,11
+1142,11
@@
void pool_write(pool_t*pool, TAG*tag)
swf_SetU30(tag, pool->x_ints->num>1?pool->x_ints->num:0);
for(t=1;t<pool->x_ints->num;t++) {
S32 val = *(int*)array_getkey(pool->x_ints, t);
swf_SetU30(tag, pool->x_ints->num>1?pool->x_ints->num:0);
for(t=1;t<pool->x_ints->num;t++) {
S32 val = *(int*)array_getkey(pool->x_ints, t);
- swf_SetS30(tag, val);
+ swf_SetABCS32(tag, val);
}
swf_SetU30(tag, pool->x_uints->num>1?pool->x_uints->num:0);
for(t=1;t<pool->x_uints->num;t++) {
}
swf_SetU30(tag, pool->x_uints->num>1?pool->x_uints->num:0);
for(t=1;t<pool->x_uints->num;t++) {
- swf_SetU30(tag, *(unsigned int*)array_getkey(pool->x_uints, t));
+ swf_SetABCU32(tag, *(unsigned int*)array_getkey(pool->x_uints, t));
}
swf_SetU30(tag, pool->x_floats->num>1?pool->x_floats->num:0);
for(t=1;t<pool->x_floats->num;t++) {
}
swf_SetU30(tag, pool->x_floats->num>1?pool->x_floats->num:0);
for(t=1;t<pool->x_floats->num;t++) {
@@
-1149,7
+1155,8
@@
void pool_write(pool_t*pool, TAG*tag)
}
swf_SetU30(tag, pool->x_strings->num>1?pool->x_strings->num:0);
for(t=1;t<pool->x_strings->num;t++) {
}
swf_SetU30(tag, pool->x_strings->num>1?pool->x_strings->num:0);
for(t=1;t<pool->x_strings->num;t++) {
- swf_SetU30String(tag, array_getkey(pool->x_strings, t));
+ string_t str = pool_lookup_string2(pool, t);
+ swf_SetU30String(tag, str.str, str.len);
}
swf_SetU30(tag, pool->x_namespaces->num>1?pool->x_namespaces->num:0);
for(t=1;t<pool->x_namespaces->num;t++) {
}
swf_SetU30(tag, pool->x_namespaces->num>1?pool->x_namespaces->num:0);
for(t=1;t<pool->x_namespaces->num;t++) {