update the man page too match last changes
[mono.git] / mono / metadata / object.h
blob91c42a955f709e4b30a7945b672f982dae9d2c9d
1 #ifndef _MONO_CLI_OBJECT_H_
2 #define _MONO_CLI_OBJECT_H_
4 #include <mono/metadata/class.h>
6 G_BEGIN_DECLS
8 typedef guchar MonoBoolean;
10 typedef struct _MonoReflectionMethod MonoReflectionMethod;
11 typedef struct _MonoReflectionAssembly MonoReflectionAssembly;
12 typedef struct _MonoReflectionModule MonoReflectionModule;
13 typedef struct _MonoReflectionField MonoReflectionField;
14 typedef struct _MonoReflectionProperty MonoReflectionProperty;
15 typedef struct _MonoReflectionEvent MonoReflectionEvent;
16 typedef struct _MonoReflectionType MonoReflectionType;
17 typedef struct _MonoDelegate MonoDelegate;
18 typedef struct _MonoException MonoException;
19 typedef struct _MonoThreadsSync MonoThreadsSync;
20 typedef struct _MonoThread MonoThread;
21 typedef struct _MonoDynamicAssembly MonoDynamicAssembly;
22 typedef struct _MonoDynamicImage MonoDynamicImage;
23 typedef struct _MonoReflectionMethodBody MonoReflectionMethodBody;
24 typedef struct _MonoAppContext MonoAppContext;
26 typedef struct {
27 MonoVTable *vtable;
28 MonoThreadsSync *synchronisation;
29 } MonoObject;
31 typedef struct {
32 guint32 length;
33 guint32 lower_bound;
34 } MonoArrayBounds;
36 typedef struct {
37 MonoObject obj;
38 /* bounds is NULL for szarrays */
39 MonoArrayBounds *bounds;
40 /* total number of elements of the array */
41 guint32 max_length;
42 /* we use double to ensure proper alignment on platforms that need it */
43 double vector [MONO_ZERO_LEN_ARRAY];
44 } MonoArray;
46 typedef struct {
47 MonoObject object;
48 gint32 length;
49 gunichar2 chars [MONO_ZERO_LEN_ARRAY];
50 } MonoString;
52 typedef MonoObject* (*MonoInvokeFunc) (MonoMethod *method, void *obj, void **params, MonoObject **exc);
53 typedef gpointer (*MonoCompileFunc) (MonoMethod *method);
54 typedef void (*MonoMainThreadFunc) (gpointer user_data);
56 #define mono_object_class(obj) (((MonoObject*)(obj))->vtable->klass)
57 #define mono_object_domain(obj) (((MonoObject*)(obj))->vtable->domain)
59 #define MONO_OBJECT_SETREF(obj,fieldname,value) do { \
60 mono_gc_wbarrier_set_field ((MonoObject*)(obj), &((obj)->fieldname), (MonoObject*)value); \
61 /*(obj)->fieldname = (value);*/ \
62 } while (0)
64 #define mono_array_length(array) ((array)->max_length)
65 #define mono_array_addr(array,type,index) ((type*)(gpointer) mono_array_addr_with_size (array, sizeof (type), index))
66 #define mono_array_addr_with_size(array,size,index) ( ((char*)(array)->vector) + (size) * (index) )
67 #define mono_array_get(array,type,index) ( *(type*)mono_array_addr ((array), type, (index)) )
68 #define mono_array_set(array,type,index,value) \
69 do { \
70 type *__p = (type *) mono_array_addr ((array), type, (index)); \
71 *__p = (value); \
72 } while (0)
73 #define mono_array_setref(array,index,value) \
74 do { \
75 gpointer *__p = (gpointer *) mono_array_addr ((array), gpointer, (index)); \
76 mono_gc_wbarrier_set_arrayref ((array), __p, (MonoObject*)(value)); \
77 /* *__p = (value);*/ \
78 } while (0)
79 #define mono_array_memcpy_refs(dest,destidx,src,srcidx,count) \
80 do { \
81 gpointer *__p = (gpointer *) mono_array_addr ((dest), gpointer, (destidx)); \
82 mono_gc_wbarrier_arrayref_copy ((dest), __p, (count)); \
83 memmove (__p, mono_array_addr ((src), gpointer, (srcidx)), (count) * sizeof (gpointer)); \
84 } while (0)
86 #define mono_string_chars(s) ((gunichar2*)(s)->chars)
87 #define mono_string_length(s) ((s)->length)
89 MonoObject *
90 mono_object_new (MonoDomain *domain, MonoClass *klass);
92 MonoObject *
93 mono_object_new_specific (MonoVTable *vtable);
95 /* can be used for classes without finalizer in non-profiling mode */
96 MonoObject *
97 mono_object_new_fast (MonoVTable *vtable);
99 MonoObject *
100 mono_object_new_alloc_specific (MonoVTable *vtable);
102 MonoObject *
103 mono_object_new_from_token (MonoDomain *domain, MonoImage *image, guint32 token);
105 MonoArray*
106 mono_array_new (MonoDomain *domain, MonoClass *eclass, guint32 n);
108 MonoArray*
109 mono_array_new_full (MonoDomain *domain, MonoClass *array_class,
110 guint32 *lengths, guint32 *lower_bounds);
112 MonoArray *
113 mono_array_new_specific (MonoVTable *vtable, guint32 n);
115 MonoArray*
116 mono_array_clone (MonoArray *array);
118 MonoString*
119 mono_string_new_utf16 (MonoDomain *domain, const guint16 *text, gint32 len);
121 MonoString*
122 mono_string_new_size (MonoDomain *domain, gint32 len);
124 MonoString*
125 mono_ldstr (MonoDomain *domain, MonoImage *image, guint32 str_index);
127 MonoString*
128 mono_string_is_interned (MonoString *str);
130 MonoString*
131 mono_string_intern (MonoString *str);
133 MonoString*
134 mono_string_new (MonoDomain *domain, const char *text);
136 MonoString*
137 mono_string_new_wrapper (const char *text);
139 MonoString*
140 mono_string_new_len (MonoDomain *domain, const char *text, guint length);
142 char *
143 mono_string_to_utf8 (MonoString *string_obj);
145 gunichar2 *
146 mono_string_to_utf16 (MonoString *string_obj);
148 MonoString *
149 mono_string_from_utf16 (gunichar2 *data);
151 gboolean
152 mono_string_equal (MonoString *s1, MonoString *s2);
154 guint
155 mono_string_hash (MonoString *s);
158 mono_object_hash (MonoObject* obj);
160 MonoObject *
161 mono_value_box (MonoDomain *domain, MonoClass *klass, gpointer val);
163 void
164 mono_value_copy (gpointer dest, gpointer src, MonoClass *klass);
166 void
167 mono_value_copy_array (MonoArray *dest, int dest_idx, gpointer src, int count);
169 MonoDomain*
170 mono_object_get_domain (MonoObject *obj);
172 MonoClass*
173 mono_object_get_class (MonoObject *obj);
175 gpointer
176 mono_object_unbox (MonoObject *obj);
178 MonoObject *
179 mono_object_clone (MonoObject *obj);
181 MonoObject *
182 mono_object_isinst (MonoObject *obj, MonoClass *klass);
184 MonoObject *
185 mono_object_isinst_mbyref (MonoObject *obj, MonoClass *klass);
187 MonoObject *
188 mono_object_castclass_mbyref (MonoObject *obj, MonoClass *klass);
190 gboolean
191 mono_monitor_try_enter (MonoObject *obj, guint32 ms);
193 gboolean
194 mono_monitor_enter (MonoObject *obj);
196 guint
197 mono_object_get_size (MonoObject *o);
199 void
200 mono_monitor_exit (MonoObject *obj);
202 void
203 mono_raise_exception (MonoException *ex);
205 void
206 mono_runtime_object_init (MonoObject *this_obj);
208 void
209 mono_runtime_class_init (MonoVTable *vtable);
211 MonoMethod*
212 mono_object_get_virtual_method (MonoObject *obj, MonoMethod *method);
214 MonoObject*
215 mono_runtime_invoke (MonoMethod *method, void *obj, void **params,
216 MonoObject **exc);
218 MonoMethod *
219 mono_get_delegate_invoke (MonoClass *klass);
221 MonoObject*
222 mono_runtime_delegate_invoke (MonoObject *delegate, void **params,
223 MonoObject **exc);
225 MonoObject*
226 mono_runtime_invoke_array (MonoMethod *method, void *obj, MonoArray *params,
227 MonoObject **exc);
229 MonoArray*
230 mono_runtime_get_main_args (void);
232 void
233 mono_runtime_exec_managed_code (MonoDomain *domain,
234 MonoMainThreadFunc main_func,
235 gpointer main_args);
238 mono_runtime_run_main (MonoMethod *method, int argc, char* argv[],
239 MonoObject **exc);
242 mono_runtime_exec_main (MonoMethod *method, MonoArray *args,
243 MonoObject **exc);
245 gpointer
246 mono_load_remote_field (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, gpointer *res);
248 MonoObject *
249 mono_load_remote_field_new (MonoObject *this_obj, MonoClass *klass, MonoClassField *field);
251 void
252 mono_store_remote_field (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, gpointer val);
254 void
255 mono_store_remote_field_new (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, MonoObject *arg);
257 void
258 mono_unhandled_exception (MonoObject *exc);
260 void
261 mono_print_unhandled_exception (MonoObject *exc);
263 gpointer
264 mono_compile_method (MonoMethod *method);
266 MonoRemoteClass*
267 mono_remote_class (MonoDomain *domain, MonoString *class_name, MonoClass *proxy_class);
269 /* accessors for fields and properties */
270 void
271 mono_field_set_value (MonoObject *obj, MonoClassField *field, void *value);
273 void
274 mono_field_static_set_value (MonoVTable *vt, MonoClassField *field, void *value);
276 void
277 mono_field_get_value (MonoObject *obj, MonoClassField *field, void *value);
279 void
280 mono_field_static_get_value (MonoVTable *vt, MonoClassField *field, void *value);
282 MonoObject *
283 mono_field_get_value_object (MonoDomain *domain, MonoClassField *field, MonoObject *obj);
285 void
286 mono_property_set_value (MonoProperty *prop, void *obj, void **params, MonoObject **exc);
288 MonoObject*
289 mono_property_get_value (MonoProperty *prop, void *obj, void **params, MonoObject **exc);
291 /* GC handles support
293 * A handle can be created to refer to a managed object and either prevent it
294 * from being garbage collected or moved or to be able to know if it has been
295 * collected or not (weak references).
296 * mono_gchandle_new () is used to prevent an object from being garbage collected
297 * until mono_gchandle_free() is called. Use a TRUE value for the pinned argument to
298 * prevent the object from being moved (this should be avoided as much as possible
299 * and this should be used only for shorts periods of time or performance will suffer).
300 * To create a weakref use mono_gchandle_new_weakref (): track_resurrection should
301 * usually be false (see the GC docs for more details).
302 * mono_gchandle_get_target () can be used to get the object referenced by both kinds
303 * of handle: for a weakref handle, if an object has been collected, it will return NULL.
305 guint32 mono_gchandle_new (MonoObject *obj, gboolean pinned);
306 guint32 mono_gchandle_new_weakref (MonoObject *obj, gboolean track_resurrection);
307 MonoObject* mono_gchandle_get_target (guint32 gchandle);
308 void mono_gchandle_free (guint32 gchandle);
310 /* GC write barriers support */
311 void mono_gc_wbarrier_set_field (MonoObject *obj, gpointer field_ptr, MonoObject* value);
312 void mono_gc_wbarrier_set_arrayref (MonoArray *arr, gpointer slot_ptr, MonoObject* value);
313 void mono_gc_wbarrier_arrayref_copy (MonoArray *arr, gpointer slot_ptr, int count);
314 void mono_gc_wbarrier_generic_store (gpointer ptr, MonoObject* value);
315 void mono_gc_wbarrier_value_copy (gpointer dest, gpointer src, int count, MonoClass *klass);
316 void mono_gc_wbarrier_object (MonoObject* obj);
318 G_END_DECLS
320 #endif