[Mono-list] Embedded API: calling explicit operators
robertj at gmx.net
Wed Sep 4 23:01:48 UTC 2013
On 31.08.2013 23:16, jonathan at mugginsoft.com wrote:
> How is an explicit operator called using the embedded api?
> For example mscorlib contains a number of explicit operators for NSDecimal:
> Reflection returns the operators as methods which I naively attempt to call like so in Obj-C:
> - (uint8_t)op_Explicit_withValue:(NSDecimalNumber *)p1
> MonoObject *monoObject = [self invokeMonoMethod:"op_Explicit(decimal)" withNumArgs:1, [p1 monoValue]];
> return DB_UNBOX_UINT8(monoObject);
> However all the operator methods will have the same signature as only the return type differs, so how do I differentiate them?
Assuming that you're using mono_method_desc_search_in_class () for
method look-ups, there is actually no way to specify the return
type. You may want to enumerate the methods yourself using
However, what makes you think that you need these operators in the
first place? :) Decimal implements a full set of ToXyz methods which
are more readable and accessible from unmanaged code. IConvertible
is implemented as well...
More information about the Mono-list