[2020-02] Fix leak in assembly-specific dllmap lookups (#21053)
[mono-project.git] / mono / metadata / class.h
blob8966e029b7c6c2e7ae86cabd33bdcc94194ffe4d
1 /**
2 * \file
3 */
5 #ifndef _MONO_CLI_CLASS_H_
6 #define _MONO_CLI_CLASS_H_
8 #include <mono/metadata/metadata.h>
9 #include <mono/metadata/image.h>
10 #include <mono/metadata/loader.h>
11 #include <mono/utils/mono-error.h>
13 MONO_BEGIN_DECLS
15 typedef struct MonoVTable MonoVTable;
17 typedef struct _MonoClassField MonoClassField;
18 typedef struct _MonoProperty MonoProperty;
19 typedef struct _MonoEvent MonoEvent;
21 typedef enum {
22 MONO_TYPE_NAME_FORMAT_IL,
23 MONO_TYPE_NAME_FORMAT_REFLECTION,
24 MONO_TYPE_NAME_FORMAT_FULL_NAME,
25 MONO_TYPE_NAME_FORMAT_ASSEMBLY_QUALIFIED
26 } MonoTypeNameFormat;
28 MONO_API MONO_RT_EXTERNAL_ONLY
29 MonoClass *
30 mono_class_get (MonoImage *image, uint32_t type_token);
32 MONO_API MONO_RT_EXTERNAL_ONLY
33 MonoClass *
34 mono_class_get_full (MonoImage *image, uint32_t type_token, MonoGenericContext *context);
36 MONO_API MONO_RT_EXTERNAL_ONLY mono_bool
37 mono_class_init (MonoClass *klass);
39 MONO_API MONO_RT_EXTERNAL_ONLY
40 MonoVTable *
41 mono_class_vtable (MonoDomain *domain, MonoClass *klass);
43 MONO_API MONO_RT_EXTERNAL_ONLY MonoClass *
44 mono_class_from_name (MonoImage *image, const char* name_space, const char *name);
46 MONO_API MONO_RT_EXTERNAL_ONLY MonoClass *
47 mono_class_from_name_case (MonoImage *image, const char* name_space, const char *name);
49 MONO_API MONO_RT_EXTERNAL_ONLY MonoMethod *
50 mono_class_get_method_from_name_flags (MonoClass *klass, const char *name, int param_count, int flags);
52 MONO_API MONO_RT_EXTERNAL_ONLY MonoClass *
53 mono_class_from_typeref (MonoImage *image, uint32_t type_token);
55 MONO_API MonoClass *
56 mono_class_from_typeref_checked (MonoImage *image, uint32_t type_token, MonoError *error);
58 MONO_API MONO_RT_EXTERNAL_ONLY
59 MonoClass *
60 mono_class_from_generic_parameter (MonoGenericParam *param, MonoImage *image, mono_bool is_mvar);
62 MONO_API MONO_RT_EXTERNAL_ONLY MonoType*
63 mono_class_inflate_generic_type (MonoType *type, MonoGenericContext *context) /* MONO_DEPRECATED */;
65 MONO_API MONO_RT_EXTERNAL_ONLY
66 MonoMethod*
67 mono_class_inflate_generic_method (MonoMethod *method, MonoGenericContext *context);
69 MONO_API MONO_RT_EXTERNAL_ONLY
70 MonoMethod *
71 mono_get_inflated_method (MonoMethod *method);
73 MONO_API MONO_RT_EXTERNAL_ONLY
74 MonoClassField*
75 mono_field_from_token (MonoImage *image, uint32_t token, MonoClass **retklass, MonoGenericContext *context);
77 MONO_API MONO_RT_EXTERNAL_ONLY
78 MonoClass *
79 mono_bounded_array_class_get (MonoClass *element_class, uint32_t rank, mono_bool bounded);
81 MONO_API MONO_RT_EXTERNAL_ONLY
82 MonoClass *
83 mono_array_class_get (MonoClass *element_class, uint32_t rank);
85 MONO_API MONO_RT_EXTERNAL_ONLY
86 MonoClass *
87 mono_ptr_class_get (MonoType *type);
89 MONO_API MonoClassField *
90 mono_class_get_field (MonoClass *klass, uint32_t field_token);
92 MONO_API MONO_RT_EXTERNAL_ONLY
93 MonoClassField *
94 mono_class_get_field_from_name (MonoClass *klass, const char *name);
96 MONO_API uint32_t
97 mono_class_get_field_token (MonoClassField *field);
99 MONO_API uint32_t
100 mono_class_get_event_token (MonoEvent *event);
102 MONO_API MONO_RT_EXTERNAL_ONLY MonoProperty *
103 mono_class_get_property_from_name (MonoClass *klass, const char *name);
105 MONO_API uint32_t
106 mono_class_get_property_token (MonoProperty *prop);
108 MONO_API int32_t
109 mono_array_element_size (MonoClass *ac);
111 MONO_API int32_t
112 mono_class_instance_size (MonoClass *klass);
114 MONO_API int32_t
115 mono_class_array_element_size (MonoClass *klass);
117 MONO_API int32_t
118 mono_class_data_size (MonoClass *klass);
120 MONO_API int32_t
121 mono_class_value_size (MonoClass *klass, uint32_t *align);
123 MONO_API int32_t
124 mono_class_min_align (MonoClass *klass);
126 MONO_API MONO_RT_EXTERNAL_ONLY MonoClass *
127 mono_class_from_mono_type (MonoType *type);
129 MONO_API MONO_RT_EXTERNAL_ONLY mono_bool
130 mono_class_is_subclass_of (MonoClass *klass, MonoClass *klassc,
131 mono_bool check_interfaces);
133 MONO_API MONO_RT_EXTERNAL_ONLY mono_bool
134 mono_class_is_assignable_from (MonoClass *klass, MonoClass *oklass);
136 MONO_API MONO_RT_EXTERNAL_ONLY
137 void*
138 mono_ldtoken (MonoImage *image, uint32_t token, MonoClass **retclass, MonoGenericContext *context);
140 MONO_API char *
141 mono_type_get_name_full (MonoType *type, MonoTypeNameFormat format);
143 MONO_API char*
144 mono_type_get_name (MonoType *type);
146 MONO_API MonoType*
147 mono_type_get_underlying_type (MonoType *type);
149 /* MonoClass accessors */
150 MONO_API MonoImage*
151 mono_class_get_image (MonoClass *klass);
153 MONO_API MONO_RT_EXTERNAL_ONLY
154 MonoClass*
155 mono_class_get_element_class (MonoClass *klass);
157 MONO_API MONO_RT_EXTERNAL_ONLY
158 mono_bool
159 mono_class_is_valuetype (MonoClass *klass);
161 MONO_API MONO_RT_EXTERNAL_ONLY
162 mono_bool
163 mono_class_is_enum (MonoClass *klass);
165 MONO_API MONO_RT_EXTERNAL_ONLY MonoType*
166 mono_class_enum_basetype (MonoClass *klass);
168 MONO_API MONO_RT_EXTERNAL_ONLY
169 MonoClass*
170 mono_class_get_parent (MonoClass *klass);
172 MONO_API MonoClass*
173 mono_class_get_nesting_type (MonoClass *klass);
175 MONO_API int
176 mono_class_get_rank (MonoClass *klass);
178 MONO_API uint32_t
179 mono_class_get_flags (MonoClass *klass);
181 MONO_API MONO_RT_EXTERNAL_ONLY
182 const char*
183 mono_class_get_name (MonoClass *klass);
185 MONO_API MONO_RT_EXTERNAL_ONLY
186 const char*
187 mono_class_get_namespace (MonoClass *klass);
189 MONO_API MONO_RT_EXTERNAL_ONLY MonoType*
190 mono_class_get_type (MonoClass *klass);
192 MONO_API uint32_t
193 mono_class_get_type_token (MonoClass *klass);
195 MONO_API MonoType*
196 mono_class_get_byref_type (MonoClass *klass);
198 MONO_API int
199 mono_class_num_fields (MonoClass *klass);
201 MONO_API int
202 mono_class_num_methods (MonoClass *klass);
204 MONO_API int
205 mono_class_num_properties (MonoClass *klass);
207 MONO_API int
208 mono_class_num_events (MonoClass *klass);
210 MONO_API MONO_RT_EXTERNAL_ONLY
211 MonoClassField*
212 mono_class_get_fields (MonoClass* klass, void **iter);
214 MONO_API MonoMethod*
215 mono_class_get_methods (MonoClass* klass, void **iter);
217 MONO_API MonoProperty*
218 mono_class_get_properties (MonoClass* klass, void **iter);
220 MONO_API MonoEvent*
221 mono_class_get_events (MonoClass* klass, void **iter);
223 MONO_API MonoClass*
224 mono_class_get_interfaces (MonoClass* klass, void **iter);
226 MONO_API MonoClass*
227 mono_class_get_nested_types (MonoClass* klass, void **iter);
229 MONO_API MONO_RT_EXTERNAL_ONLY
230 mono_bool
231 mono_class_is_delegate (MonoClass* klass);
233 MONO_API MONO_RT_EXTERNAL_ONLY mono_bool
234 mono_class_implements_interface (MonoClass* klass, MonoClass* iface);
236 /* MonoClassField accessors */
237 MONO_API const char*
238 mono_field_get_name (MonoClassField *field);
240 MONO_API MonoType*
241 mono_field_get_type (MonoClassField *field);
243 MONO_API MonoClass*
244 mono_field_get_parent (MonoClassField *field);
246 MONO_API uint32_t
247 mono_field_get_flags (MonoClassField *field);
249 MONO_API uint32_t
250 mono_field_get_offset (MonoClassField *field);
252 MONO_API const char *
253 mono_field_get_data (MonoClassField *field);
255 /* MonoProperty acessors */
256 MONO_API const char*
257 mono_property_get_name (MonoProperty *prop);
259 MONO_API MonoMethod*
260 mono_property_get_set_method (MonoProperty *prop);
262 MONO_API MonoMethod*
263 mono_property_get_get_method (MonoProperty *prop);
265 MONO_API MonoClass*
266 mono_property_get_parent (MonoProperty *prop);
268 MONO_API uint32_t
269 mono_property_get_flags (MonoProperty *prop);
271 /* MonoEvent accessors */
272 MONO_API const char*
273 mono_event_get_name (MonoEvent *event);
275 MONO_API MonoMethod*
276 mono_event_get_add_method (MonoEvent *event);
278 MONO_API MonoMethod*
279 mono_event_get_remove_method (MonoEvent *event);
281 MONO_API MonoMethod*
282 mono_event_get_remove_method (MonoEvent *event);
284 MONO_API MonoMethod*
285 mono_event_get_raise_method (MonoEvent *event);
287 MONO_API MonoClass*
288 mono_event_get_parent (MonoEvent *event);
290 MONO_API uint32_t
291 mono_event_get_flags (MonoEvent *event);
293 MONO_API MONO_RT_EXTERNAL_ONLY MonoMethod *
294 mono_class_get_method_from_name (MonoClass *klass, const char *name, int param_count);
296 MONO_API char *
297 mono_class_name_from_token (MonoImage *image, uint32_t type_token);
299 MONO_API mono_bool
300 mono_method_can_access_field (MonoMethod *method, MonoClassField *field);
302 MONO_API mono_bool
303 mono_method_can_access_method (MonoMethod *method, MonoMethod *called);
305 MONO_API mono_bool
306 mono_class_is_nullable (MonoClass *klass);
308 MONO_API MONO_RT_EXTERNAL_ONLY MonoClass*
309 mono_class_get_nullable_param (MonoClass *klass);
311 MONO_END_DECLS
313 #endif /* _MONO_CLI_CLASS_H_ */