X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=lib%2Fas3%2Fabc.c;h=b37dea89e2816a3207116a4ea05c41262838cca1;hb=1042606c080e543c2c03e0c16cc593c6f156f539;hp=d03977d9798592ad7e48413d6e4010398a900f17;hpb=cecf84b4cc9ba4d47beaac8adac6ba727c4a04dd;p=swftools.git diff --git a/lib/as3/abc.c b/lib/as3/abc.c index d03977d..b37dea8 100644 --- a/lib/as3/abc.c +++ b/lib/as3/abc.c @@ -136,12 +136,12 @@ abc_file_t*abc_file_new() #define CLASS_INTERFACE 4 #define CLASS_PROTECTED_NS 8 -abc_class_t* abc_class_new(abc_file_t*pool, multiname_t*classname, multiname_t*superclass) { +abc_class_t* abc_class_new(abc_file_t*file, multiname_t*classname, multiname_t*superclass) { NEW(abc_class_t,c); - array_append(pool->classes, NO_KEY, c); + array_append(file->classes, NO_KEY, c); - c->pool = pool; + c->file = file; c->classname = classname; c->superclass = superclass; c->flags = 0; @@ -177,18 +177,18 @@ void abc_class_add_interface(abc_class_t*c, multiname_t*interface) list_append(c->interfaces, interface); } -abc_method_body_t* add_method(abc_file_t*pool, abc_class_t*cls, char*returntype, int num_params, va_list va) +abc_method_body_t* add_method(abc_file_t*file, abc_class_t*cls, char*returntype, int num_params, va_list va) { /* construct code (method body) object */ NEW(abc_method_body_t,c); - array_append(pool->method_bodies, NO_KEY, c); - c->pool = pool; + array_append(file->method_bodies, NO_KEY, c); + c->file = file; c->traits = list_new(); c->code = 0; /* construct method object */ NEW(abc_method_t,m); - array_append(pool->methods, NO_KEY, m); + array_append(file->methods, NO_KEY, m); if(returntype && strcmp(returntype, "void")) { m->return_type = multiname_fromstring(returntype); @@ -212,7 +212,7 @@ abc_method_body_t* abc_class_constructor(abc_class_t*cls, char*returntype, int n { va_list va; va_start(va, num_params); - abc_method_body_t* c = add_method(cls->pool, cls, returntype, num_params, va); + abc_method_body_t* c = add_method(cls->file, cls, returntype, num_params, va); va_end(va); cls->constructor = c->method; return c; @@ -222,7 +222,7 @@ abc_method_body_t* abc_class_staticconstructor(abc_class_t*cls, char*returntype, { va_list va; va_start(va, num_params); - abc_method_body_t* c = add_method(cls->pool, cls, returntype, num_params, va); + abc_method_body_t* c = add_method(cls->file, cls, returntype, num_params, va); va_end(va); cls->static_constructor = c->method; return c; @@ -255,10 +255,10 @@ trait_t*trait_new_method(multiname_t*name, abc_method_t*m) abc_method_body_t* abc_class_method(abc_class_t*cls, char*returntype, char*name, int num_params, ...) { - abc_file_t*pool = cls->pool; + abc_file_t*file = cls->file; va_list va; va_start(va, num_params); - abc_method_body_t* c = add_method(cls->pool, cls, returntype, num_params, va); + abc_method_body_t* c = add_method(cls->file, cls, returntype, num_params, va); va_end(va); list_append(cls->traits, trait_new_method(multiname_fromstring(name), c->method)); return c; @@ -266,14 +266,14 @@ abc_method_body_t* abc_class_method(abc_class_t*cls, char*returntype, char*name, void abc_AddSlot(abc_class_t*cls, char*name, int slot, char*multiname) { - abc_file_t*pool = cls->pool; + abc_file_t*file = cls->file; multiname_t*m = multiname_fromstring(multiname); list_append(cls->traits, trait_new(TRAIT_SLOT, m, slot, 0, 0, 0)); } void abc_method_body_addClassTrait(abc_method_body_t*code, char*multiname, int slotid, abc_class_t*cls) { - abc_file_t*pool = code->pool; + abc_file_t*file = code->file; multiname_t*m = multiname_fromstring(multiname); trait_t*trait = trait_new(TRAIT_CLASS, m, slotid, 0, 0, 0); trait->cls = cls; @@ -284,23 +284,23 @@ void abc_method_body_addClassTrait(abc_method_body_t*code, char*multiname, int s and traits of the init script are *not* the same thing */ void abc_initscript_addClassTrait(abc_script_t*script, char*multiname, int slotid, abc_class_t*cls) { - abc_file_t*pool = script->pool; + abc_file_t*file = script->file; multiname_t*m = multiname_fromstring(multiname); trait_t*trait = trait_new(TRAIT_CLASS, m, slotid, 0, 0, 0); trait->cls = cls; list_append(script->traits, trait); } -abc_script_t* abc_initscript(abc_file_t*pool, char*returntype, int num_params, ...) +abc_script_t* abc_initscript(abc_file_t*file, char*returntype, int num_params, ...) { va_list va; va_start(va, num_params); - abc_method_body_t* c = add_method(pool, 0, returntype, num_params, va); + abc_method_body_t* c = add_method(file, 0, returntype, num_params, va); abc_script_t* s = malloc(sizeof(abc_script_t)); s->method = c->method; s->traits = list_new(); - s->pool = pool; - array_append(pool->scripts, NO_KEY, s); + s->file = file; + array_append(file->scripts, NO_KEY, s); va_end(va); return s; } @@ -309,13 +309,15 @@ static void dump_traits(FILE*fo, const char*prefix, trait_list_t*traits, abc_fil static void dump_method(FILE*fo, const char*prefix, const char*type, const char*name, abc_method_t*m, abc_file_t*file) { - const char*return_type = "void"; + char*return_type = 0; if(m->return_type) return_type = multiname_to_string(m->return_type); - + else + return_type = strdup("void"); char*paramstr = params_to_string(m->parameters); - fprintf(fo, "%s%s %s %s=%s %s\n", prefix, type, return_type, name, m->name, paramstr); + free(paramstr);paramstr=0; + free(return_type);return_type=0; abc_method_body_t*c = m->body; if(!c) { @@ -651,7 +653,7 @@ void* swf_ReadABC(TAG*tag) DEBUG printf("method %d) %s flags=%02x\n", t, params_to_string(m->parameters), m->flags); if(m->flags&0x08) { - /* optional parameters */ + /* TODO optional parameters */ int num = swf_GetU30(tag); int s; for(s=0;s