X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fregistry.c;h=f160b5c9181925cb8475e72943cb8947f0e6d4a4;hb=3fb75ef418267cb0f7370d365b3a37b8013fbee9;hp=06ae5c55d8b2e5b409b42ac6fff27f2a2b853cc9;hpb=fb56342d9ce82d70ea6d5d544ff8df485fee3afc;p=swftools.git diff --git a/lib/as3/registry.c b/lib/as3/registry.c index 06ae5c5..f160b5c 100644 --- a/lib/as3/registry.c +++ b/lib/as3/registry.c @@ -93,27 +93,6 @@ classinfo_t* classinfo_register(int access, char*package, char*name, int num_int return c; } -/* function and class pointers get their own type class */ -static dict_t* functionobjects = 0; -classinfo_t* registry_getfunctionclass(memberinfo_t*f) { - if(!functionobjects) { - functionobjects = dict_new2(&ptr_type); - } else { - classinfo_t*c = dict_lookup(functionobjects, f); - if(c) - return c; - } - - NEW(classinfo_t,c); - c->access = ACCESS_PUBLIC; - c->package = ""; - c->name = "Function"; - dict_init(&c->members,1); - dict_put(&c->members, "call", f); - - dict_put(functionobjects, f, c); - return c; -} static dict_t* classobjects = 0; classinfo_t* registry_getclassclass(classinfo_t*a) { if(!classobjects) { @@ -128,14 +107,8 @@ classinfo_t* registry_getclassclass(classinfo_t*a) { c->access = ACCESS_PUBLIC; c->package = ""; c->name = "Class"; - - NEW(memberinfo_t,m); - m->kind = MEMBER_SLOT; - m->name = "prototype"; - m->type = a; - dict_init(&c->members,1); - dict_put(&c->members, "prototype", m); + c->cls = a; dict_put(classobjects, a, c); return c; @@ -195,6 +168,43 @@ multiname_t* classinfo_to_multiname(classinfo_t*cls) return multiname_new(ns,cls->name); } +// ----------------------- memberinfo methods ------------------------------ + +/* function and class pointers get their own type class */ +static dict_t* functionobjects = 0; +classinfo_t* memberinfo_asclass(memberinfo_t*f) { + if(!functionobjects) { + functionobjects = dict_new2(&ptr_type); + } else { + classinfo_t*c = dict_lookup(functionobjects, f); + if(c) + return c; + } + + NEW(classinfo_t,c); + c->access = ACCESS_PUBLIC; + c->package = ""; + c->name = "Function"; + + dict_init(&c->members,1); + c->function = f; + + dict_put(functionobjects, f, c); + return c; +} + +classinfo_t* memberinfo_gettype(memberinfo_t*f) +{ + if(f) { + if(f->kind == MEMBER_METHOD) { + return memberinfo_asclass(f); + } else { + return f->type; + } + } else { + return registry_getanytype(); + } +} // ----------------------- builtin types ------------------------------ classinfo_t* registry_getanytype() {return 0;} @@ -217,6 +227,11 @@ classinfo_t* registry_getstringclass() { if(!c) c = registry_safefindclass("", "String"); return c; } +classinfo_t* registry_getarrayclass() { + static classinfo_t*c = 0; + if(!c) c = registry_safefindclass("", "Array"); + return c; +} classinfo_t* registry_getintclass() { static classinfo_t*c = 0; if(!c) c = registry_safefindclass("", "int");