523260dbf0a670ba0b999fb16a0a2860d7ff8a44
[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         const char     *name;
16         const char     *data;
17         /* add marshal data, too */
18 } MonoClassField;
19
20 typedef struct {
21         const char *name;
22         MonoMethod *get;
23         MonoMethod *set;
24         guint32 attrs;
25 } MonoProperty;
26
27 struct _MonoClass {
28         MonoImage *image;
29         guint32    type_token;
30
31         guint dummy           : 1; /* temorary hack */
32         guint inited          : 1;
33         guint valuetype       : 1; /* derives from System.ValueType */
34         guint enumtype        : 1; /* derives from System.Enum */
35         guint min_align       : 4;
36
37         MonoClass  *parent;
38         MonoClass  *nested_in;
39         GList      *subclasses; /* list of all subclasses */
40
41         const char *name;
42         const char *name_space;
43         
44         guint       interface_id; /* unique inderface id (for interfaces) */
45         guint       max_interface_id;
46         gpointer   *interface_offsets;
47         guint       interface_count;
48         MonoClass **interfaces;
49
50         /*
51          * Computed object instance size, total.
52          */
53         int        instance_size;
54         int        class_size;
55         int        vtable_size; /* number of slots */
56
57         /*
58          * relative numbering for fast type checking
59          */
60         unsigned int baseval;
61         unsigned int diffval;
62
63         /*
64          * From the TypeDef table
65          */
66         guint32    flags;
67         struct {
68                 guint32 first, last;
69                 int count;
70         } field, method, property;
71
72         /*
73          * Field information: Type and location from object base
74          */
75         MonoClassField *fields;
76
77         MonoProperty *properties;
78
79         MonoMethod **methods;
80
81         /* The underlying type of the enum */
82         MonoType *enum_basetype;
83         /* for arrays */
84         MonoClass *element_class; /* element class */
85         guint32    rank;          /* array dimension */
86
87         /* used as the type of the this argument and when passing the arg by value */
88         MonoType this_arg;
89         MonoType byval_arg;
90         
91         gpointer data;
92
93         gpointer vtable [0];
94 };
95
96 typedef gpointer (*MonoTrampoline)       (MonoMethod *method);
97 typedef void     (*MonoRuntimeClassInit) (MonoClass *klass);
98
99 MonoClass *
100 mono_class_get             (MonoImage *image, guint32 type_token);
101
102 void
103 mono_class_init            (MonoClass *klass);
104
105 MonoClass *
106 mono_class_from_name       (MonoImage *image, const char* name_space, const char *name);
107
108 MonoClassField*
109 mono_field_from_memberref  (MonoImage *image, guint32 token, MonoClass **retklass);
110
111 MonoClass *
112 mono_array_class_get       (MonoClass *eclass, guint32 rank);
113
114 MonoClassField *
115 mono_class_get_field       (MonoClass *klass, guint32 field_token);
116
117 MonoClassField *
118 mono_class_get_field_from_name (MonoClass *klass, const char *name);
119
120 gint32
121 mono_array_element_size    (MonoClass *ac);
122
123 gint32
124 mono_class_instance_size   (MonoClass *klass);
125
126 gint32
127 mono_class_value_size      (MonoClass *klass, guint32 *align);
128
129 gint32
130 mono_class_data_size       (MonoClass *klass);
131
132 MonoClass *
133 mono_class_from_mono_type  (MonoType *type);
134
135 gpointer
136 mono_ldtoken               (MonoImage *image, guint32 token, MonoClass **retclass);
137
138 void
139 mono_install_trampoline (MonoTrampoline func);
140
141 void
142 mono_install_runtime_class_init (MonoRuntimeClassInit func);
143
144 #endif /* _MONO_CLI_CLASS_H_ */