[Mono-dev] Populate array of PointF
Robert Jordan
robertj at gmx.net
Fri Mar 10 17:38:31 UTC 2017
No idea why mono_object_unbox () is failing on you. It might
be a side effect of a different issue.
Since PointF is a struct (a value type), arrays of this type
are looking like a C/C++ array: a contiguous block of memory
which can store n elements of sizeof(PointF).
You should declare an unmanaged version of PointF, something
like that:
/* double check the layout of PointF as I didn't. */
typedef struct {
float x, y;
} PointF;
Then manipulate array elements like this:
PointF *ptr = (PointF*) mono_array_addr_with_size (
arrayPtF, sizeof(PointF), /*index*/ 0);
ptr->x = 0;
ptr->y = 1;
Robert
On 10.03.2017 16:29, howard.rubin wrote:
> Thanks, @Robert Jordan for the reply. I don't see how to do what you suggest:
> "store unboxed PointF values into the array". I can't even get the unboxed
> point because this line segfaults.
> void* unboxedPoint = mono_object_unbox(ptF);
>
> Thread 1 (Thread 0x7f667faf3780 (LWP 31655)):
> #0 0x00007f667ed52fdb in waitpid () from /lib64/libpthread.so.0
> #1 0x00007f667f441ad6 in mono_handle_native_sigsegv
> (signal=signal at entry=11, ctx=ctx at entry=0x7f667fb01ac0,
> info=info at entry=0x7f667fb01bf0) at mini-exceptions.c:2347
> #2 0x00007f667f49d07e in mono_arch_handle_altstack_exception
> (sigctx=sigctx at entry=0x7f667fb01ac0, siginfo=siginfo at entry=0x7f667fb01bf0,
> fault_addr=<optimized out>, stack_ovf=stack_ovf at entry=0) at
> exceptions-amd64.c:851
> #3 0x00007f667f3af96c in mono_sigsegv_signal_handler (_dummy=11,
> _info=0x7f667fb01bf0, context=0x7f667fb01ac0) at mini.c:6810
> #4 <signal handler called>
> #5 0x00007f667f5496a3 in mono_object_unbox (obj=0x7f667fa62f60) at
> object.c:5318
> #6 0x00000000004010a6 in main () at array.cpp:46
>
> =================================================================
> Got a SIGSEGV while executing native code. This usually indicates
> a fatal error in the mono runtime or one of the native libraries
> used by your application.
> =================================================================
>
>
>
>
> --
> View this message in context: http://mono.1490590.n4.nabble.com/Populate-array-of-PointF-tp4670214p4670220.html
> Sent from the Mono - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.dot.net
> http://lists.dot.net/mailman/listinfo/mono-devel-list
>
More information about the Mono-devel-list
mailing list