[Mono-dev] interacting with method signatures from C (embedded)
Robert Jordan
robertj at gmx.net
Fri Oct 28 04:12:14 EDT 2011
On 28.10.2011 01:23, Jonathan Shore wrote:
> MonoMethod* find_method (
> MonoDomain* domain,
> MonoClass* type,
> const char* name,
> int nargs,
> MonoClass** types)
>
>
> I can iterate over the memebers with mono_signature_get_params(), however,
> this returns a MonoType* struct reference. I cannot examine the "type"
> field of this struct as is not seen to be a complete structure without
> including the<mono/metadata/*-internals.h> files.
The accessor is called mono_type_get_type()
> I am aware of the "debug-helpers" interface which allows for the search of a
> class and method signature using a string. This interface is oriented
> towards use cases where the method one is trying to locate is fixed. The
> construction of the string signature is expensive. Additionally in scanning
> methods, each method matching a name is rendered as a MonoMethodDesc,
> creating strings for the classname, namespace, and parameters. This seems
> like a lot of overhead.
IMHO, the debug helpers are not suitable for what you're trying
to achieve.
If you really want to implement the lookup in C w/out using
C# helper (see Miguel's answer), then you have to enumerate
the methods yourself:
1) use mono_class_get_method_from_name(type, name, argument_count)
2) check the signature. If it doesn't match, then enumerate
all methods with mono_class_get_methods().
Note that the functions above do not handle inherited
methods. You'd need to loop like this:
while (klass != NULL) {
/* check methods */
...
/* check parent's methods */
klass = mono_class_get_parent (klass);
}
Robert
More information about the Mono-devel-list
mailing list