1 #ifndef _MONO_CLI_OBJECT_H_
2 #define _MONO_CLI_OBJECT_H_
4 #include <mono/metadata/class.h>
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
;
28 MonoThreadsSync
*synchronisation
;
38 /* bounds is NULL for szarrays */
39 MonoArrayBounds
*bounds
;
40 /* total number of elements of the array */
42 /* we use double to ensure proper alignment on platforms that need it */
43 double vector
[MONO_ZERO_LEN_ARRAY
];
49 gunichar2 chars
[MONO_ZERO_LEN_ARRAY
];
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);*/ \
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) \
70 type *__p = (type *) mono_array_addr ((array), type, (index)); \
73 #define mono_array_setref(array,index,value) \
75 gpointer *__p = (gpointer *) mono_array_addr ((array), gpointer, (index)); \
76 mono_gc_wbarrier_set_arrayref ((array), __p, (MonoObject*)(value)); \
77 /* *__p = (value);*/ \
79 #define mono_array_memcpy_refs(dest,destidx,src,srcidx,count) \
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)); \
86 #define mono_string_chars(s) ((gunichar2*)(s)->chars)
87 #define mono_string_length(s) ((s)->length)
90 mono_object_new (MonoDomain
*domain
, MonoClass
*klass
);
93 mono_object_new_specific (MonoVTable
*vtable
);
95 /* can be used for classes without finalizer in non-profiling mode */
97 mono_object_new_fast (MonoVTable
*vtable
);
100 mono_object_new_alloc_specific (MonoVTable
*vtable
);
103 mono_object_new_from_token (MonoDomain
*domain
, MonoImage
*image
, guint32 token
);
106 mono_array_new (MonoDomain
*domain
, MonoClass
*eclass
, guint32 n
);
109 mono_array_new_full (MonoDomain
*domain
, MonoClass
*array_class
,
110 guint32
*lengths
, guint32
*lower_bounds
);
113 mono_array_new_specific (MonoVTable
*vtable
, guint32 n
);
116 mono_array_clone (MonoArray
*array
);
119 mono_string_new_utf16 (MonoDomain
*domain
, const guint16
*text
, gint32 len
);
122 mono_string_new_size (MonoDomain
*domain
, gint32 len
);
125 mono_ldstr (MonoDomain
*domain
, MonoImage
*image
, guint32 str_index
);
128 mono_string_is_interned (MonoString
*str
);
131 mono_string_intern (MonoString
*str
);
134 mono_string_new (MonoDomain
*domain
, const char *text
);
137 mono_string_new_wrapper (const char *text
);
140 mono_string_new_len (MonoDomain
*domain
, const char *text
, guint length
);
143 mono_string_to_utf8 (MonoString
*string_obj
);
146 mono_string_to_utf16 (MonoString
*string_obj
);
149 mono_string_from_utf16 (gunichar2
*data
);
152 mono_string_equal (MonoString
*s1
, MonoString
*s2
);
155 mono_string_hash (MonoString
*s
);
158 mono_object_hash (MonoObject
* obj
);
161 mono_value_box (MonoDomain
*domain
, MonoClass
*klass
, gpointer val
);
164 mono_value_copy (gpointer dest
, gpointer src
, MonoClass
*klass
);
167 mono_value_copy_array (MonoArray
*dest
, int dest_idx
, gpointer src
, int count
);
170 mono_object_get_domain (MonoObject
*obj
);
173 mono_object_get_class (MonoObject
*obj
);
176 mono_object_unbox (MonoObject
*obj
);
179 mono_object_clone (MonoObject
*obj
);
182 mono_object_isinst (MonoObject
*obj
, MonoClass
*klass
);
185 mono_object_isinst_mbyref (MonoObject
*obj
, MonoClass
*klass
);
188 mono_object_castclass_mbyref (MonoObject
*obj
, MonoClass
*klass
);
191 mono_monitor_try_enter (MonoObject
*obj
, guint32 ms
);
194 mono_monitor_enter (MonoObject
*obj
);
197 mono_object_get_size (MonoObject
*o
);
200 mono_monitor_exit (MonoObject
*obj
);
203 mono_raise_exception (MonoException
*ex
);
206 mono_runtime_object_init (MonoObject
*this_obj
);
209 mono_runtime_class_init (MonoVTable
*vtable
);
212 mono_object_get_virtual_method (MonoObject
*obj
, MonoMethod
*method
);
215 mono_runtime_invoke (MonoMethod
*method
, void *obj
, void **params
,
219 mono_get_delegate_invoke (MonoClass
*klass
);
222 mono_runtime_delegate_invoke (MonoObject
*delegate
, void **params
,
226 mono_runtime_invoke_array (MonoMethod
*method
, void *obj
, MonoArray
*params
,
230 mono_runtime_get_main_args (void);
233 mono_runtime_exec_managed_code (MonoDomain
*domain
,
234 MonoMainThreadFunc main_func
,
238 mono_runtime_run_main (MonoMethod
*method
, int argc
, char* argv
[],
242 mono_runtime_exec_main (MonoMethod
*method
, MonoArray
*args
,
246 mono_load_remote_field (MonoObject
*this_obj
, MonoClass
*klass
, MonoClassField
*field
, gpointer
*res
);
249 mono_load_remote_field_new (MonoObject
*this_obj
, MonoClass
*klass
, MonoClassField
*field
);
252 mono_store_remote_field (MonoObject
*this_obj
, MonoClass
*klass
, MonoClassField
*field
, gpointer val
);
255 mono_store_remote_field_new (MonoObject
*this_obj
, MonoClass
*klass
, MonoClassField
*field
, MonoObject
*arg
);
258 mono_unhandled_exception (MonoObject
*exc
);
261 mono_print_unhandled_exception (MonoObject
*exc
);
264 mono_compile_method (MonoMethod
*method
);
267 mono_remote_class (MonoDomain
*domain
, MonoString
*class_name
, MonoClass
*proxy_class
);
269 /* accessors for fields and properties */
271 mono_field_set_value (MonoObject
*obj
, MonoClassField
*field
, void *value
);
274 mono_field_static_set_value (MonoVTable
*vt
, MonoClassField
*field
, void *value
);
277 mono_field_get_value (MonoObject
*obj
, MonoClassField
*field
, void *value
);
280 mono_field_static_get_value (MonoVTable
*vt
, MonoClassField
*field
, void *value
);
283 mono_field_get_value_object (MonoDomain
*domain
, MonoClassField
*field
, MonoObject
*obj
);
286 mono_property_set_value (MonoProperty
*prop
, void *obj
, void **params
, MonoObject
**exc
);
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
);