mono-api-methods.html

Methods

Invoking Methods

mono_runtime_invoke
MonoObject* mono_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc)

Parameters

method:
method to invoke
obJ:
object instance
params:
arguments to the method
exc:
exception information.
Remarks

Invokes the method represented by method on the object obj. obj is the 'this' pointer, it should be NULL for static methods, a MonoObject* for object instances and a pointer to the value type for value types. The params array contains the arguments to the method with the same convention: MonoObject* pointers for object instances and pointers to the value type otherwise.

From unmanaged code you'll usually use the mono_runtime_invoke() variant. Note that this function doesn't handle virtual methods for you, it will exec the exact method you pass: we still need to expose a function to lookup the derived class implementation of a virtual method (there are examples of this in the code, though).

You can pass NULL as the exc argument if you don't want to catch exceptions, otherwise, *exc will be set to the exception thrown, if any. if an exception is thrown, you can't use the MonoObject* result from the function.

If the method returns a value type, it is boxed in an object reference. If you want to invoke generic methods, you must call the method on the "inflated" class, which you can obtain from the mono_object_get_class()

MonoClass *clazz; MonoMethod *method; clazz = mono_object_get_class (obj); /* * If there are more Add methods declared, you * may use mono_method_desc_search_in_class (clazz, ":Add(T)"), * you must substitute ":Add(T)" with the correct type, for example * for List<int>, you would use ":Add(int)". */ method = mono_class_get_method_from_name (clazz, "Add", 1); mono_runtime_invoke (method, obj, args, &exception);
mono_runtime_invoke_array
MonoObject* mono_runtime_invoke_array (MonoMethod *method, void *obj, MonoArray *params, MonoObject **exc)

Parameters

method:
method to invoke
obJ:
object instance
params:
arguments to the method
exc:
exception information.
Remarks

Invokes the method represented by method on the object obj. obj is the 'this' pointer, it should be NULL for static methods, a MonoObject* for object instances and a pointer to the value type for value types. The params array contains the arguments to the method with the same convention: MonoObject* pointers for object instances and pointers to the value type otherwise. The _invoke_array variant takes a C# object[] as the params argument (MonoArray *params): in this case the value types are boxed inside the respective reference representation.

From unmanaged code you'll usually use the mono_runtime_invoke() variant. Note that this function doesn't handle virtual methods for you, it will exec the exact method you pass: we still need to expose a function to lookup the derived class implementation of a virtual method (there are examples of this in the code, though).

You can pass NULL as the exc argument if you don't want to catch exceptions, otherwise, *exc will be set to the exception thrown, if any. if an exception is thrown, you can't use the MonoObject* result from the function.

If the method returns a value type, it is boxed in an object reference.

mono_runtime_delegate_invoke
MonoObject* mono_runtime_delegate_invoke (MonoObject *delegate, void **params, MonoObject **exc)

Parameters

delegate:
pointer to a delegate object.
params:
parameters for the delegate.
exc:
Pointer to the exception result.
Remarks

Invokes the delegate method delegate with the parameters provided. You can pass NULL as the exc argument if you don't want to catch exceptions, otherwise, *exc will be set to the exception thrown, if any. if an exception is thrown, you can't use the MonoObject* result from the function.

mono_method_body_get_object
Prototype: mono_method_body_get_object

mono_method_desc_free
void mono_method_desc_free (MonoMethodDesc *desc)

Parameters

desc:
method description to be released
Remarks

Releases the MonoMethodDesc object desc.

mono_method_desc_from_method
Prototype: mono_method_desc_from_method

mono_method_desc_full_match
Prototype: mono_method_desc_full_match

mono_method_desc_match
Prototype: mono_method_desc_match

mono_method_desc_new
MonoMethodDesc* mono_method_desc_new (const char *name, gboolean include_namespace)

Parameters

name:
the method name.
include_namespace:
whether the name includes a namespace or not.
Returns
a parsed representation of the method description.
Remarks

Creates a method description for name, which conforms to the following specification: [namespace.]classname:methodname[(args...)] in all the loaded assemblies. Both classname and methodname can contain '*' which matches anything.

mono_method_desc_search_in_class
Prototype: mono_method_desc_search_in_class

mono_method_desc_search_in_image
Prototype: mono_method_desc_search_in_image

mono_method_full_name
Prototype: mono_method_full_name

mono_method_get_class
Prototype: mono_method_get_class

mono_method_get_flags
Prototype: mono_method_get_flags

mono_method_get_last_managed
Prototype: mono_method_get_last_managed

mono_method_get_marshal_info
Prototype: mono_method_get_marshal_info

mono_method_get_name
Prototype: mono_method_get_name

mono_method_get_object
Prototype: mono_method_get_object

mono_method_get_param_names
Prototype: mono_method_get_param_names

mono_method_get_param_token
Prototype: mono_method_get_param_token

mono_method_get_signature
Prototype: mono_method_get_signature

mono_method_get_index
Prototype: mono_method_get_index

mono_method_get_signature_full
Prototype: mono_method_get_signature_full

mono_method_get_token
Prototype: mono_method_get_token

mono_method_has_marshal_info
Prototype: mono_method_has_marshal_info

mono_method_verify
Prototype: mono_method_verify

Method Signatures

mono_method_signature
MonoMethodSignature* mono_method_signature (MonoMethod *m)

Remarks

Return the signature of the method M. On failure, returns NULL.

mono_signature_explicit_this
gboolean mono_signature_explicit_this (MonoMethodSignature *sig)

Parameters

sig:
the method signature inspected
Returns
TRUE if this the method signature sig has an explicit instance argument. FALSE otherwise.
mono_signature_get_call_conv
guint32 mono_signature_get_call_conv (MonoMethodSignature *sig)

Parameters

sig:
the method signature inspected
Returns
the call convention of the method signature sig.
mono_signature_get_desc
Prototype: mono_signature_get_desc

mono_signature_get_param_count
guint32 mono_signature_get_param_count (MonoMethodSignature *sig)

Parameters

sig:
the method signature inspected
Returns
the number of parameters in the method signature sig.
mono_signature_get_params
MonoType* mono_signature_get_params (MonoMethodSignature *sig, gpointer *iter)

Parameters

sig:
the method signature inspected
iter:
pointer to an iterator
Returns
the next parameter type of the method signature sig, NULL when finished.
Remarks

Iterates over the parameters for the method signature sig. A void* pointer must be initualized to NULL to start the iteration and it's address is passed to this function repeteadly until it returns NULL.

mono_signature_get_return_type
MonoType* mono_signature_get_return_type (MonoMethodSignature *sig)

Parameters

sig:
the method signature inspected
Returns
the return type of the method signature sig
mono_signature_hash
Prototype: mono_signature_hash

mono_signature_is_instance
gboolean mono_signature_is_instance (MonoMethodSignature *sig)

Parameters

sig:
the method signature inspected
Returns
TRUE if this the method signature sig has an implicit first instance argument. FALSE otherwise.
mono_signature_vararg_start
int mono_signature_vararg_start (MonoMethodSignature *sig)

Parameters

sig:
the method signature inspected
Returns
the number of the first vararg parameter in the method signature sig. -1 if this is not a vararg signature.
mono_param_get_objects
Prototype: mono_param_get_objects

mono_get_method_full
Prototype: mono_get_method_full

mono_get_method
Prototype: mono_get_method

Methods Header Operations

mono_method_get_header
Prototype: mono_method_get_header

mono_method_header_get_clauses
Prototype: mono_method_header_get_clauses

mono_method_header_get_code
Prototype: mono_method_header_get_code

mono_method_header_get_locals
Prototype: mono_method_header_get_locals