renamed class_signature to classinfo
[swftools.git] / lib / as3 / registry.h
1 /* registry.h
2
3    Routines for compiling Flash2 AVM2 ABC Actionscript
4
5    Extension module for the rfxswf library.
6    Part of the swftools package.
7
8    Copyright (c) 2008 Matthias Kramm <kramm@quiss.org>
9  
10    This program is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 2 of the License, or
13    (at your option) any later version.
14
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
23
24 #ifndef __abc_registry_h__
25 #define __abc_registry_h__
26
27 #include "pool.h"
28
29 DECLARE(classinfo);
30 DECLARE_LIST(classinfo);
31 DECLARE(memberinfo);
32
33 struct _classinfo {
34     /* this is very similar to a QNAME */
35     U8 access;
36     U8 flags;
37     const char*package;
38     const char*name;
39
40     classinfo_t*superclass;
41     dict_t members;
42     classinfo_t*interfaces[];
43 };
44 char classinfo_equals(classinfo_t*c1, classinfo_t*c2);
45
46 #define MEMBER_SLOT 1
47 #define MEMBER_METHOD 2
48 struct _memberinfo {
49     U8 type;
50     const char*name;
51     union {
52         classinfo_t*returnvalue;
53         classinfo_t*type;
54     };
55     classinfo_list_t*params;
56 };
57
58 extern type_t classinfo_type;
59 extern type_t function_signature_type;
60
61 void registry_init();
62         
63 classinfo_t* classinfo_register(int access, char*package, char*name);
64
65 // static multinames
66 classinfo_t* registry_getanytype();
67 classinfo_t* registry_getobjectclass();
68 classinfo_t* registry_getnumberclass();
69 classinfo_t* registry_getstringclass();
70 classinfo_t* registry_getintclass();
71 classinfo_t* registry_getuintclass();
72 classinfo_t* registry_getnullclass();
73 classinfo_t* registry_getbooleanclass();
74 classinfo_t* registry_getMovieClip();
75
76 classinfo_t* registry_findclass(const char*package, const char*name);
77
78 void registry_fill_multiname(multiname_t*m, namespace_t*n, classinfo_t*c);
79 multiname_t* classinfo_to_multiname(classinfo_t*cls);
80
81 /* convenience functions */
82 #define sig2mname(x) classinfo_to_multiname(x)
83 #define TYPE_ANY                  registry_getanytype()
84 #define TYPE_IS_ANY(t)    ((t) == registry_getanytype())
85 #define TYPE_INT                  registry_getintclass()
86 #define TYPE_IS_INT(t)    ((t) == registry_getintclass())
87 #define TYPE_UINT                 registry_getuintclass()
88 #define TYPE_IS_UINT(t)   ((t) == registry_getuintclass())
89 #define TYPE_NUMBER               registry_getnumberclass()
90 #define TYPE_IS_NUMBER(t) ((t) == registry_getnumberclass())
91 #define TYPE_FLOAT                registry_getnumberclass()
92 #define TYPE_IS_FLOAT(t)  ((t) == registry_getnumberclass())
93 #define TYPE_BOOLEAN              registry_getbooleanclass()
94 #define TYPE_IS_BOOLEAN(t)((t) == registry_getbooleanclass())
95 #define TYPE_STRING               registry_getstringclass()
96 #define TYPE_IS_STRING(t) ((t) == registry_getstringclass())
97 #define TYPE_NULL                 registry_getnullclass()
98 #define TYPE_IS_NULL(t)   ((t) == registry_getnullclass())
99         
100 #define TYPE_IS_BUILTIN_SIMPLE(type) (TYPE_IS_INT(type) || \
101                                       TYPE_IS_UINT(type) || \
102                                       TYPE_IS_FLOAT(type) || \
103                                       TYPE_IS_BOOLEAN(type) || \
104                                       TYPE_IS_STRING(type))
105
106
107 #endif