X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fregistry.c;h=069f923a18491da4cff4713958b1627123cd4b80;hb=ff7bd81590dc66a135f8ac513d0fb9d5c4c95bf9;hp=5aa254dc2ae23445785f55925d6964edbe373f9b;hpb=63ab6b923efea7ec197ccd4f232325543f08beeb;p=swftools.git diff --git a/lib/as3/registry.c b/lib/as3/registry.c index 5aa254d..069f923 100644 --- a/lib/as3/registry.c +++ b/lib/as3/registry.c @@ -81,7 +81,7 @@ type_t memberinfo_type = { // ------------------------- constructors -------------------------------- #define AVERAGE_NUMBER_OF_MEMBERS 8 -classinfo_t* classinfo_register(int access, char*package, char*name, int num_interfaces) +classinfo_t* classinfo_register(int access, const char*package, const char*name, int num_interfaces) { classinfo_t*c = rfx_calloc(sizeof(classinfo_t)+(sizeof(classinfo_t*)*(num_interfaces+1))); c->interfaces[0] = 0; @@ -103,7 +103,7 @@ classinfo_t* registry_getclassclass(classinfo_t*a) { return c; } - NEW(classinfo_t,c); + classinfo_t*c = rfx_calloc(sizeof(classinfo_t)+sizeof(classinfo_t*)); c->access = ACCESS_PUBLIC; c->package = ""; c->name = "Class"; @@ -123,6 +123,20 @@ memberinfo_t* memberinfo_register(classinfo_t*cls, const char*name, U8 kind) dict_put(&cls->members, name, m); return m; } +memberinfo_t* memberinfo_register_global(U8 access, const char*package, const char*name, U8 kind) +{ + NEW(memberinfo_t, m); + m->kind = kind; + m->flags = FLAG_STATIC; + m->name = name; + m->parent = 0; + + classinfo_t*c = classinfo_register(access, package, name, 0); + c->function = m; + c->flags |= FLAG_METHOD; + return m; +} + // --------------- builtin classes (from builtin.c) ---------------------- @@ -136,6 +150,7 @@ classinfo_t* registry_safefindclass(const char*package, const char*name) assert(c); return c; } + classinfo_t* registry_findclass(const char*package, const char*name) { assert(classes); @@ -147,6 +162,20 @@ classinfo_t* registry_findclass(const char*package, const char*name) printf("%s.%s->%08x (%s.%s)\n", package, name, c, c->package, c->name);*/ return c; } +void registry_dumpclasses() +{ + int t; + for(t=0;thashsize;t++) { + dictentry_t*e = classes->slots[t]; + while(e) { + dictentry_t*next = e->next; + classinfo_t*i = (classinfo_t*)e->key; + printf("%s.%s\n", i->package, i->name); + e = e->next; + } + } +} + memberinfo_t* registry_findmember(classinfo_t*cls, const char*name, char recursive) { if(!recursive) { @@ -205,7 +234,7 @@ classinfo_t* memberinfo_asclass(memberinfo_t*f) { return c; } - NEW(classinfo_t,c); + classinfo_t*c = rfx_calloc(sizeof(classinfo_t)+sizeof(classinfo_t*)); c->access = ACCESS_PUBLIC; c->package = ""; c->name = "Function"; @@ -276,6 +305,11 @@ classinfo_t* registry_getnumberclass() { if(!c) c = registry_safefindclass("", "Number"); return c; } +classinfo_t* registry_getregexpclass() { + static classinfo_t*c = 0; + if(!c) c = registry_safefindclass("", "RegExp"); + return c; +} classinfo_t* registry_getMovieClip() { static classinfo_t*c = 0; if(!c) c = registry_safefindclass("flash.display", "MovieClip"); @@ -290,3 +324,23 @@ classinfo_t* registry_getnullclass() { return &nullclass; } +// --------------------------------------------------------------------- +namespace_t flags2namespace(int flags, char*package) +{ + namespace_t ns; + ns.name = package; + if(flags&FLAG_PUBLIC) { + ns.access = ACCESS_PACKAGE; + } else if(flags&FLAG_PRIVATE) { + ns.access = ACCESS_PRIVATE; + } else if(flags&FLAG_PROTECTED) { + ns.access = ACCESS_PROTECTED; + } else if(flags&FLAG_NAMESPACE_ADOBE) { + ns.access = ACCESS_NAMESPACE; + assert(!package || !package[0]); + ns.name = "http://adobe.com/AS3/2006/builtin"; + } else { + ns.access = ACCESS_PACKAGEINTERNAL; + } + return ns; +}