[Mono-list] Embedded API: thunk value type parameters and return types
robertj at gmx.net
Fri Sep 23 11:17:37 UTC 2016
On 22.09.2016 22:22, Jonathan Mitchell wrote:
> I am trying to upgrade some method invoke based code to used thunks.
> The comments for mono_method_get_unmanaged_thunk() say:
> * LIMITATIONS
> * Value type arguments and return values are treated as they were objects:
> * C#: public static Rectangle Intersect (Rectangle a, Rectangle b);
> * C: typedef MonoObject* (*Intersect)(MonoObject*, MonoObject*, MonoException**);
> * Arguments must be properly boxed upon trunk's invocation, while return
> * values must be unboxed.
> However it seems that primitive value types are returned unboxed while non primitive value types are not.
> Does the same apply for thunk parameters?
> Are primitive value parameters based by value and non primitive value parameters as a boxed reference?
The limitation only applies to "complex" value types:
(type.IsValueType && !type.IsPrimitive) == true
More information about the Mono-list