return c;
}
-/* function pointers get their own type class */
+/* function and class pointers get their own type class */
static dict_t* functionobjects = 0;
classinfo_t* registry_getfunctionclass(memberinfo_t*f) {
if(!functionobjects) {
dict_put(functionobjects, f, c);
return c;
}
+static dict_t* classobjects = 0;
+classinfo_t* registry_getclassclass(classinfo_t*a) {
+ if(!classobjects) {
+ classobjects = dict_new2(&ptr_type);
+ } else {
+ classinfo_t*c = dict_lookup(classobjects, a);
+ if(c)
+ return c;
+ }
+
+ NEW(classinfo_t,c);
+ 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);
+
+ dict_put(classobjects, a, c);
+ return c;
+}
memberinfo_t* memberinfo_register(classinfo_t*cls, const char*name, U8 kind)
{
return (c && c->package && c->name &&
!strcmp(c->package, "") && !strcmp(c->name, "Function"));
}
+char registry_isclassclass(classinfo_t*c) {
+ return (c && c->package && c->name &&
+ !strcmp(c->package, "") && !strcmp(c->name, "Class"));
+}
classinfo_t* registry_getobjectclass() {
static classinfo_t*c = 0;
DECLARE(memberinfo);
struct _classinfo {
- /* this is very similar to a QNAME */
U8 access;
U8 flags;
const char*package;
const char*name;
+ int slot;
classinfo_t*superclass;
dict_t members;
char classinfo_equals(classinfo_t*c1, classinfo_t*c2);
#define MEMBER_SLOT 1
-#define MEMBER_METHOD 2
+#define MEMBER_GET 2
+#define MEMBER_SET 4
+#define MEMBER_GETSET 6
+#define MEMBER_METHOD 8
+
struct _memberinfo {
U8 kind;
+ U8 flags;
const char*name;
union {
classinfo_t*return_type;
classinfo_t* registry_getfunctionclass();
classinfo_t* registry_getMovieClip();
classinfo_t* registry_getfunctionclass(memberinfo_t*f);
+classinfo_t* registry_getclassclass(classinfo_t*a);
classinfo_t* registry_findclass(const char*package, const char*name);
memberinfo_t* registry_findmember(classinfo_t*cls, const char*name);
multiname_t* classinfo_to_multiname(classinfo_t*cls);
char registry_isfunctionclass();
+char registry_isclassclass();
+
/* convenience functions */
#define sig2mname(x) classinfo_to_multiname(x)
#define TYPE_ANY registry_getanytype()
#define TYPE_FUNCTION(f) registry_getfunctionclass(f)
#define TYPE_IS_FUNCTION(t) registry_isfunctionclass(t)
+#define TYPE_CLASS(f) registry_getclassclass(f)
+#define TYPE_IS_CLASS(t) registry_isclassclass(t)
+
#define TYPE_NULL registry_getnullclass()
#define TYPE_IS_NULL(t) ((t) == registry_getnullclass())