3 <p>The object API deals with all the operations shared by
4 <a href=
"#objects">objects
</a>,
<a href=
"#valuetypes">value
5 types
</a>,
<a href=
"#arrays">arrays
</a> and
<a
6 href=
"#nullable">nullable types
</a>.
8 <p>The object API has methods for accessing
<a
9 href=
"#fields">fields
</a>,
<a
10 href=
"#properties">properties
</a>,
<a
11 href=
"#events">events
</a>,
<a href=
"#delegates">delegates
</a>.
13 <p>There are some advanced uses that are useful to document
14 here dealing with
<a href=
"#async">AsyncResults
</a> and
<a
15 href=
"#remote">remote fields
</a>.
20 #include
<metadata/object.h
>
22 typedef struct MonoVTable MonoVTable;
23 typedef struct _MonoThreadsSync MonoThreadsSync;
27 MonoThreadsSync *synchronisation;
37 /* bounds is NULL for szarrays */
38 MonoArrayBounds *bounds;
39 /* total number of elements of the array */
41 /* we use double to ensure proper alignment on platforms that need it */
42 double vector [MONO_ZERO_LEN_ARRAY];
48 <p>MonoObject is the base definition for all managed objects
49 in the Mono runtime, it represents the
<a
50 href=
"http://www.mono-project.com/monodoc/T:System.Object">System.Object
</a>
53 <p>All objects that derive from
<a
54 href=
"http://www.mono-project.com/monodoc/T:System.Object">System.Object
</a>
55 do have this base definition. Derived objects are declared
56 following the pattern where the parent class is the first
57 field of a structure definition, for example:
66 <a name=
"objects"></a>
67 <h2>Core Object Methods
</h2>
69 <h4><a name=
"api:mono_object_new">mono_object_new
</a></h4>
71 <p>For example, if you wanted to create an object of type
72 System.Version, you would use a piece of code like this:
75 MonoClass *version_class;
78 /* Get the class from mscorlib */
79 version_class = mono_class_from_name (mono_get_corlib (),
82 /* Create an object of that class */
83 result = mono_object_new (mono_domain_get (), version_class);
86 <h4><a name=
"api:mono_object_new_alloc_specific">mono_object_new_alloc_specific
</a></h4>
87 <h4><a name=
"api:mono_object_new_fast">mono_object_new_fast
</a></h4>
88 <h4><a name=
"api:mono_object_new_from_token">mono_object_new_from_token
</a></h4>
89 <h4><a name=
"api:mono_object_new_specific">mono_object_new_specific
</a></h4>
90 <h4><a name=
"api:mono_object_clone">mono_object_clone
</a></h4>
91 <h4><a name=
"api:mono_object_get_class">mono_object_get_class
</a></h4>
92 <h4><a name=
"api:mono_object_get_domain">mono_object_get_domain
</a></h4>
93 <h4><a name=
"api:mono_object_get_virtual_method">mono_object_get_virtual_method
</a></h4>
94 <h4><a name=
"api:mono_object_isinst_mbyref">mono_object_isinst_mbyref
</a></h4>
95 <h4><a name=
"api:mono_object_isinst">mono_object_isinst
</a></h4>
96 <h4><a name=
"api:mono_object_register_finalizer">mono_object_register_finalizer
</a></h4>
97 <h4><a name=
"api:mono_object_unbox">mono_object_unbox
</a></h4>
98 <h4><a name=
"api:mono_object_castclass_mbyref">mono_object_castclass_mbyref
</a></h4>
99 <h4><a name=
"api:mono_object_is_alive">mono_object_is_alive
</a></h4>
100 <h4><a name=
"api:mono_object_get_size">mono_object_get_size
</a></h4>
102 <a name=
"valuetypes"></a>
105 <h4><a name=
"api:mono_value_box">mono_value_box
</a></h4>
106 <h4><a name=
"api:mono_value_copy">mono_value_copy
</a></h4>
107 <h4><a name=
"api:mono_value_copy_array">mono_value_copy_array
</a></h4>
109 <a name=
"arrays"></a>
110 <h2>Array Methods
</h2>
112 <p>Use the
<tt>mono_array_new_*
</tt> methods to create arrays
115 <p>For example, the following code creates an array with two
116 elements of type
<tt>System.Byte
</tt>, and sets the values
121 MonoArray *CreateByteArray (MonoDomain *domain)
125 data = mono_array_new (domain, mono_get_byte_class (),
2);
126 mono_array_set (data, guint8,
0,
0xca);
127 mono_array_set (data, guint8,
0,
0xfe);
134 <h3>Creating Arrays
</h3>
136 <h4><a name=
"api:mono_array_new">mono_array_new
</a></h4>
137 <h4><a name=
"api:mono_array_new_full">mono_array_new_full
</a></h4>
138 <h4><a name=
"api:mono_array_new_specific">mono_array_new_specific
</a></h4>
139 <h4><a name=
"api:mono_array_class_get">mono_array_class_get
</a></h4>
140 <h4><a name=
"api:mono_array_clone_in_domain">mono_array_clone_in_domain
</a></h4>
141 <h4><a name=
"api:mono_array_clone">mono_array_clone
</a></h4>
142 <h4><a name=
"api:mono_array_full_copy">mono_array_full_copy
</a></h4>
143 <h4><a name=
"api:mono_array_to_lparray">mono_array_to_lparray
</a></h4>
144 <h4><a name=
"api:mono_array_to_savearray">mono_array_to_savearray
</a></h4>
145 <h4><a name=
"api:mono_dup_array_type">mono_dup_array_type
</a></h4>
147 <h3>Using Arrays
</h3>
149 <h4><a name=
"api:mono_array_set">mono_array_set
</a></h4>
150 <h4><a name=
"api:mono_array_setref">mono_array_setref
</a></h4>
151 <h4><a name=
"api:mono_array_length">mono_array_length
</a></h4>
152 <h4><a name=
"api:mono_array_addr">mono_array_addr
</a></h4>
153 <h4><a name=
"api:mono_array_addr_with_size">mono_array_addr_with_size
</a></h4>
154 <h4><a name=
"api:mono_array_get">mono_array_get
</a></h4>
155 <h4><a name=
"api:mono_array_element_size">mono_array_element_size
</a></h4>
157 <a name=
"fields"></a>
160 <h4><a name=
"api:mono_field_from_token">mono_field_from_token
</a></h4>
161 <h4><a name=
"api:mono_field_get_flags">mono_field_get_flags
</a></h4>
162 <h4><a name=
"api:mono_field_get_name">mono_field_get_name
</a></h4>
163 <h4><a name=
"api:mono_field_get_parent">mono_field_get_parent
</a></h4>
164 <h4><a name=
"api:mono_field_get_type">mono_field_get_type
</a></h4>
165 <h4><a name=
"api:mono_field_get_value">mono_field_get_value
</a></h4>
166 <h4><a name=
"api:mono_field_get_value_object">mono_field_get_value_object
</a></h4>
167 <h4><a name=
"api:mono_field_set_value">mono_field_set_value
</a></h4>
168 <h4><a name=
"api:mono_field_static_get_value">mono_field_static_get_value
</a></h4>
169 <h4><a name=
"api:mono_field_static_set_value">mono_field_static_set_value
</a></h4>
171 <a name=
"properties"></a>
174 <h4><a name=
"api:mono_property_get_flags">mono_property_get_flags
</a></h4>
175 <h4><a name=
"api:mono_property_get_get_method">mono_property_get_get_method
</a></h4>
176 <h4><a name=
"api:mono_property_get_name">mono_property_get_name
</a></h4>
177 <h4><a name=
"api:mono_property_get_parent">mono_property_get_parent
</a></h4>
178 <h4><a name=
"api:mono_property_get_set_method">mono_property_get_set_method
</a></h4>
179 <h4><a name=
"api:mono_property_get_value">mono_property_get_value
</a></h4>
180 <h4><a name=
"api:mono_property_set_value">mono_property_set_value
</a></h4>
182 <a name=
"events"></a>
185 <h4><a name=
"api:mono_event_get_add_method">mono_event_get_add_method
</a></h4>
186 <h4><a name=
"api:mono_event_get_flags">mono_event_get_flags
</a></h4>
187 <h4><a name=
"api:mono_event_get_name">mono_event_get_name
</a></h4>
188 <h4><a name=
"api:mono_event_get_parent">mono_event_get_parent
</a></h4>
189 <h4><a name=
"api:mono_event_get_raise_method">mono_event_get_raise_method
</a></h4>
190 <h4><a name=
"api:mono_event_get_remove_method">mono_event_get_remove_method
</a></h4>
192 <a name=
"delegates"></a>
194 <h4><a name=
"api:mono_delegate_ctor">mono_delegate_ctor
</a></h4>
197 <h2>AsyncResults
</h2>
198 <h4><a name=
"api:mono_async_result_new">mono_async_result_new
</a></h4>
200 <a name=
"remote"></a>
201 <h2>Remote Fields
</h2>
202 <h4><a name=
"api:mono_load_remote_field">mono_load_remote_field
</a></h4>
203 <h4><a name=
"api:mono_load_remote_field_new">mono_load_remote_field_new
</a></h4>
204 <h4><a name=
"api:mono_store_remote_field">mono_store_remote_field
</a></h4>
205 <h4><a name=
"api:mono_store_remote_field_new">mono_store_remote_field_new
</a></h4>
207 <a name=
"nullable"></a>
208 <h2>Nullable Objects
</h2>
210 <p>These methods are used to manipulate objects of type
211 System.Nullable
<T
>
213 <h4><a name=
"api:mono_nullable_box">mono_nullable_box
</a></h4>
214 <h4><a name=
"api:mono_nullable_init">mono_nullable_init
</a></h4>