2001-08-28 Dietmar Maurer <dietmar@ximian.com>
[mono.git] / mono / metadata / class.h
1 #ifndef _MONO_CLI_CLASS_H_
2 #define _MONO_CLI_CLASS_H_
3
4 #include <mono/metadata/metadata.h>
5 #include <mono/metadata/image.h>
6 #include <mono/metadata/loader.h>
7
8 #define MONO_CLASS_IS_ARRAY(c) (c->type_token == 0)
9
10 #define MONO_CLASS_STATIC_FIELDS_BASE(c) (c->data)
11
12 typedef struct {
13         MonoType *type;
14         int       offset;
15 } MonoClassField;
16
17 struct _MonoClass {
18         MonoImage *image;
19         guint32    type_token;
20
21         guint dummy           : 1; /* temorary hack */
22         guint inited          : 1;
23         guint metadata_inited : 1;
24         guint valuetype       : 1; /* derives from System.ValueType */
25         guint enumtype        : 1; /* derives from System.Enum */
26
27         MonoClass *parent;
28         MonoClass **interfaces;
29
30         const char *name;
31         const char *name_space;
32         
33         /*
34          * Computed object instance size, total.
35          */
36         int        instance_size;
37         int        class_size;
38
39         /*
40          * From the TypeDef table
41          */
42         guint32    flags;
43         struct {
44                 guint32 first, last;
45                 int count;
46         } field, method;
47
48         /*
49          * Field information: Type and location from object base
50          */
51         MonoClassField *fields;
52
53         MonoMethod **methods;
54
55         /* used as the type of the this argument */
56         MonoType this_arg;
57         
58         /* 
59          * Static class data 
60          */
61         gpointer data;
62 };
63
64 typedef struct {
65         MonoClass  klass;
66         MonoClass *element_class; /* element class */
67         guint32    rank;          /* array dimension */
68 } MonoArrayClass;
69
70 MonoClass *
71 mono_class_get             (MonoImage *image, guint32 type_token);
72
73 void
74 mono_class_metadata_init   (MonoClass *klass);
75
76 MonoClass *
77 mono_class_from_name       (MonoImage *image, const char* name_space, const char *name);
78
79 MonoClass *
80 mono_array_class_get       (MonoClass *eclass, guint32 rank);
81
82 MonoClassField *
83 mono_class_get_field       (MonoClass *klass, guint32 field_token);
84
85 gint32
86 mono_array_element_size    (MonoArrayClass *ac);
87
88 gint32
89 mono_class_instance_size   (MonoClass *klass);
90
91 gint32
92 mono_class_value_size      (MonoClass *klass, guint32 *align);
93
94 gint32
95 mono_class_data_size       (MonoClass *klass);
96
97 MonoClass *
98 mono_class_from_mono_type  (MonoType *type);
99
100 #endif /* _MONO_CLI_CLASS_H_ */