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