Re: Populate array of PointF

Robert Jordan <[email protected]>
Newsgroups gmane.comp.gnome.mono.devel
Message-ID <[email protected]>
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


_______________________________________________
Mono-devel-list mailing list
[email protected]
http://lists.dot.net/mailman/listinfo/mono-devel-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.