[Mono-dev] Populate array of PointF
Robert Jordan
robertj at gmx.net
Fri Mar 10 22:58:59 UTC 2017
On 10.03.2017 23:30, Robert Jordan wrote:
> On 10.03.2017 21:54, howard.rubin wrote:
>> Maybe I'm missing something, but changing
>> mono_runtime_invoke(ptFCtor, ptF, args, &exception);
>> to
>> mono_runtime_invoke(ptFCtor, mono_object_unbox(ptF), args,
>> &exception);
>
>
> There are more mono_runtime_invokes in your code
> which must be changed. For example, this one:
>
> args[0] = ptF;
> mono_runtime_invoke(MyClassMethod, nullptr, args, &exception);
>
> It must be:
>
> args[0] = mono_object_unbox(ptF);
> mono_runtime_invoke(MyClassMethod, nullptr, args, &exception);
>
Long story short, here is the array manipulation code
which should go right above the invocation of
MyNamespace.MyClass:PrintArray(System.Drawing.PointF[])
// create 1 element array of PointF
MonoArray* arrayPtF = mono_array_new(domain, ptFClass, 1);
// compute size of an array element
int esize = mono_array_element_size (
mono_object_get_class ((MonoObject *)arrayPtF));
// get a ptr to the array element at index 0
void *ptr = mono_array_addr_with_size(arrayPtF, esize, 0);
// copy ptF into the array
memcpy(ptr, mono_object_unbox(ptF), esize);
Robert
More information about the Mono-devel-list
mailing list