class_signature now contains flags
[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(class_signature);
30 DECLARE_LIST(class_signature);
31 DECLARE(function_signature);
32
33 struct _class_signature {
34     /* this is very similar to a QNAME */
35     U8 access;
36     U8 flags;
37     const char*package;
38     const char*name;
39
40     class_signature_t*superclass;
41     dict_t members;
42     class_signature_t*interfaces[];
43 };
44 char class_signature_equals(class_signature_t*c1, class_signature_t*c2);
45 extern type_t class_signature_type;
46
47 struct _function_signature {
48     const char*name;
49     class_signature_list_t*params;
50 };
51 extern type_t function_signature_type;
52
53 void registry_init();
54         
55 class_signature_t* class_signature_register(int access, char*package, char*name);
56
57 // static multinames
58 class_signature_t* registry_getanytype();
59 class_signature_t* registry_getobjectclass();
60 class_signature_t* registry_getnumberclass();
61 class_signature_t* registry_getstringclass();
62 class_signature_t* registry_getintclass();
63 class_signature_t* registry_getuintclass();
64 class_signature_t* registry_getnullclass();
65 class_signature_t* registry_getbooleanclass();
66 class_signature_t* registry_getMovieClip();
67
68 class_signature_t* registry_findclass(const char*package, const char*name);
69
70 void registry_fill_multiname(multiname_t*m, namespace_t*n, class_signature_t*c);
71 multiname_t* class_signature_to_multiname(class_signature_t*cls);
72
73 /* convenience functions */
74 #define sig2mname(x) class_signature_to_multiname(x)
75 #define TYPE_ANY                  registry_getanytype()
76 #define TYPE_IS_ANY(t)    ((t) == registry_getanytype())
77 #define TYPE_INT                  registry_getintclass()
78 #define TYPE_IS_INT(t)    ((t) == registry_getintclass())
79 #define TYPE_UINT                 registry_getuintclass()
80 #define TYPE_IS_UINT(t)   ((t) == registry_getuintclass())
81 #define TYPE_NUMBER               registry_getnumberclass()
82 #define TYPE_IS_NUMBER(t) ((t) == registry_getnumberclass())
83 #define TYPE_FLOAT                registry_getnumberclass()
84 #define TYPE_IS_FLOAT(t)  ((t) == registry_getnumberclass())
85 #define TYPE_BOOLEAN              registry_getbooleanclass()
86 #define TYPE_IS_BOOLEAN(t)((t) == registry_getbooleanclass())
87 #define TYPE_STRING               registry_getstringclass()
88 #define TYPE_IS_STRING(t) ((t) == registry_getstringclass())
89 #define TYPE_NULL                 registry_getnullclass()
90 #define TYPE_IS_NULL(t)   ((t) == registry_getnullclass())
91         
92 #define TYPE_IS_BUILTIN_SIMPLE(type) (TYPE_IS_INT(type) || \
93                                       TYPE_IS_UINT(type) || \
94                                       TYPE_IS_FLOAT(type) || \
95                                       TYPE_IS_BOOLEAN(type) || \
96                                       TYPE_IS_STRING(type))
97
98
99 #endif