diff options
author | kramm <kramm> | 2009-01-09 11:50:40 +0000 |
---|---|---|
committer | kramm <kramm> | 2009-01-09 11:50:40 +0000 |
commit | 3242b563c5a81a02976e36c6760bb463c153b481 (patch) | |
tree | de4f825250e202166011ff76c29a32865363560a /lib | |
parent | f6034fbeebf05ea9fd30469861e16111b448cd4d (diff) |
new function pool_dump
Diffstat (limited to 'lib')
-rw-r--r-- | lib/as3/pool.c | 51 | ||||
-rw-r--r-- | lib/as3/pool.h | 8 |
2 files changed, 56 insertions, 3 deletions
diff --git a/lib/as3/pool.c b/lib/as3/pool.c index 56007cc9..2ed429e0 100644 --- a/lib/as3/pool.c +++ b/lib/as3/pool.c @@ -734,7 +734,7 @@ constant_t* constant_fromindex(pool_t*pool, int index, int type) char* constant_tostring(constant_t*c) { if(!c) - return 0; + return strdup("NULL"); char buf[32]; if(NS_TYPE(c->type)) { return namespace_tostring(c->ns); @@ -1121,6 +1121,55 @@ void pool_read(pool_t*pool, TAG*tag) } } +void pool_dump(pool_t*pool, FILE*fo) +{ + int t; + fprintf(fo, "%d integers:\n", pool->x_ints->num); + for(t=1;t<pool->x_ints->num;t++) { + S32 val = *(int*)array_getkey(pool->x_ints, t); + fprintf(fo, "%d) %d\n", t, val); + } + fprintf(fo, "%d integers:\n", pool->x_uints->num); + for(t=1;t<pool->x_uints->num;t++) { + U32 val = *(unsigned int*)array_getkey(pool->x_uints, t); + fprintf(fo, "%d) %d\n", t, val); + } + fprintf(fo, "%d floats:\n", pool->x_floats->num); + for(t=1;t<pool->x_floats->num;t++) { + double d = pool_lookup_float(pool, t); + fprintf(fo, "%d) %f\n", t, d); + } + fprintf(fo, "%d strings:\n", pool->x_strings->num); + for(t=1;t<pool->x_strings->num;t++) { + string_t str = pool_lookup_string2(pool, t); + fprintf(fo, "%d) ", t); + fwrite(str.str, str.len, 1, fo); + fprintf(fo, "\n", t); + } + fprintf(fo, "%d namespaces:\n", pool->x_namespaces->num); + for(t=1;t<pool->x_namespaces->num;t++) { + namespace_t*ns= (namespace_t*)array_getkey(pool->x_namespaces, t); + char*s = namespace_tostring(ns); + fprintf(fo, "%d) %s\n", t, s); + free(s); + } + fprintf(fo, "%d namespace sets:\n", pool->x_namespace_sets->num); + for(t=1;t<pool->x_namespace_sets->num;t++) { + namespace_set_t*set = (namespace_set_t*)array_getkey(pool->x_namespace_sets, t); + char*s = namespace_set_tostring(set); + fprintf(fo, "%d) %s\n", t, s); + free(s); + } + + fprintf(fo, "%d multinames:\n", pool->x_multinames->num); + for(t=1;t<pool->x_multinames->num;t++) { + multiname_t*m = (multiname_t*)array_getkey(pool->x_multinames, t); + char*s = multiname_tostring(m); + fprintf(fo, "%d) %s\n", t, s); + free(s); + } +} + void pool_write(pool_t*pool, TAG*tag) { int t; diff --git a/lib/as3/pool.h b/lib/as3/pool.h index 50f1b3a8..3758c2cc 100644 --- a/lib/as3/pool.h +++ b/lib/as3/pool.h @@ -87,7 +87,7 @@ struct _constant { double f; int i; unsigned int u; - char*s; + string_t* s; namespace_t*ns; }; int type; @@ -97,6 +97,7 @@ 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(); @@ -148,7 +149,8 @@ char* namespace_tostring(namespace_t*ns); 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); -char*pool_lookup_string(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); @@ -167,6 +169,7 @@ 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); @@ -201,5 +204,6 @@ 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 |