1 #ifndef _MONO_CLI_CLASS_H_
2 #define _MONO_CLI_CLASS_H_
4 #include <mono/metadata/metadata.h>
5 #include <mono/metadata/image.h>
6 #include <mono/metadata/loader.h>
8 #define MONO_CLASS_IS_ARRAY(c) ((c)->rank)
10 #define MONO_DEFAULT_SUPERTABLE_SIZE 6
12 extern gboolean mono_print_vtable;
13 typedef struct MonoVTable MonoVTable;
24 MonoClassField *field;
26 MonoMarshalSpec *mspec;
32 MonoMarshalField fields [MONO_ZERO_LEN_ARRAY];
55 * relative numbering for fast type checking
60 /* The underlying type of the enum */
61 MonoType *enum_basetype;
62 /* element class for arrays and enum */
63 MonoClass *element_class;
64 /* used for subtype checks */
65 MonoClass *cast_class;
70 /* We use init_pending to detect cyclic calls to mono_class_init */
71 guint init_pending : 1;
73 /* A class contains static and non static data. Static data can be
74 * of the same type as the class itselfs, but it does not influence
75 * the instance size of the class. To avoid cyclic calls to
76 * mono_class_init (from mono_class_instance_size ()) we first
77 * initialise all non static fields. After that we set size_inited
78 * to 1, because we know the instance size now. After that we
79 * initialise all static fields.
81 guint size_inited : 1;
82 guint valuetype : 1; /* derives from System.ValueType */
83 guint enumtype : 1; /* derives from System.Enum */
84 guint blittable : 1; /* class is blittable */
85 guint unicode : 1; /* class uses unicode char when marshalled */
86 guint wastypebuilder : 1; /* class was created at runtime from a TypeBuilder */
89 guint packing_size : 4;
91 guint ghcimpl : 1; /* class has its own GetHashCode impl */
92 guint has_finalize : 1; /* class has its own Finalize impl */
93 guint marshalbyref : 1; /* class is a MarshalByRefObject */
94 guint contextbound : 1; /* class is a ContextBoundObject */
95 guint delegate : 1; /* class is a Delegate */
96 guint dummy : 1; /* temorary hack */
100 GList *nested_classes;
101 GList *subclasses; /* list of all subclasses */
105 const char *name_space;
107 guint interface_count;
108 guint interface_id; /* unique inderface id (for interfaces) */
109 guint max_interface_id;
110 gint *interface_offsets;
111 MonoClass **interfaces;
113 /* for fast subtype checks */
115 MonoClass **supertypes;
118 * Computed object instance size, total.
122 int vtable_size; /* number of slots */
125 * From the TypeDef table
131 } field, method, property, event;
133 /* loaded on demand */
134 MonoMarshalType *marshal_info;
137 * Field information: Type and location from object base
139 MonoClassField *fields;
141 MonoProperty *properties;
145 MonoMethod **methods;
147 /* used as the type of the this argument and when passing the arg by value */
151 void *reflection_info;
153 MonoMethod *ptr_to_str;
154 MonoMethod *str_to_ptr;
156 MonoVTable *cached_vtable;
162 MonoDomain *domain; /* each object/vtable belongs to exactly one domain */
163 guint max_interface_id;
164 gpointer *interface_offsets;
165 gpointer data; /* to store static class data */
166 guint remote : 1; /* class is remotely activated */
167 /* do not add any fields after vtable, the structure is dynamically extended */
168 gpointer vtable [MONO_ZERO_LEN_ARRAY];
172 gulong new_object_count;
173 gulong initialized_class_count;
174 gulong used_class_count;
175 gulong class_vtable_size;
176 gulong class_static_data_size;
179 extern MonoStats mono_stats;
181 typedef gpointer (*MonoTrampoline) (MonoMethod *method);
183 typedef gpointer (*MonoLookupDynamicToken) (MonoImage *image, guint32 token);
186 mono_class_get (MonoImage *image, guint32 type_token);
189 mono_class_init (MonoClass *klass);
192 mono_class_layout_fields (MonoClass *klass);
195 mono_class_setup_vtable (MonoClass *klass, MonoMethod **overrides, int onum);
198 mono_class_vtable (MonoDomain *domain, MonoClass *klass);
201 mono_class_proxy_vtable (MonoDomain *domain, MonoClass *klass);
204 mono_class_setup_mono_type (MonoClass *klass);
207 mono_class_setup_parent (MonoClass *klass, MonoClass *parent);
210 mono_class_from_name (MonoImage *image, const char* name_space, const char *name);
213 mono_class_from_name_case (MonoImage *image, const char* name_space, const char *name);
216 mono_class_from_typeref (MonoImage *image, guint32 type_token);
219 mono_field_from_memberref (MonoImage *image, guint32 token, MonoClass **retklass);
222 mono_field_from_token (MonoImage *image, guint32 token, MonoClass **retklass);
225 mono_class_get_overrides (MonoImage *image, guint32 type_token, gint32 *num_overrides);
228 mono_array_class_get (MonoType *element_type, guint32 rank);
231 mono_ptr_class_get (MonoType *type);
234 mono_class_get_field (MonoClass *klass, guint32 field_token);
237 mono_class_get_field_from_name (MonoClass *klass, const char *name);
240 mono_class_get_property_from_name (MonoClass *klass, const char *name);
243 mono_array_element_size (MonoClass *ac);
246 mono_class_instance_size (MonoClass *klass);
249 mono_class_array_element_size (MonoClass *klass);
252 mono_class_data_size (MonoClass *klass);
255 mono_class_value_size (MonoClass *klass, guint32 *align);
258 mono_class_native_size (MonoClass *klass, guint32 *align);
261 mono_marshal_load_type_info (MonoClass* klass);
264 mono_class_min_align (MonoClass *klass);
267 mono_class_from_mono_type (MonoType *type);
270 mono_ldtoken (MonoImage *image, guint32 token, MonoClass **retclass);
273 mono_install_trampoline (MonoTrampoline func);
276 mono_install_remoting_trampoline (MonoTrampoline func);
279 mono_lookup_dynamic_token (MonoImage *image, guint32 token);
282 mono_install_lookup_dynamic_token (MonoLookupDynamicToken func);
285 mono_install_get_config_dir(void);
287 #endif /* _MONO_CLI_CLASS_H_ */