[Mono-dev] mono embed: passing arrays from and to unmanaged code
davide.morelli at parser.it
Fri Jan 13 08:00:51 EST 2006
thank you, that was really useful!
now my problem is that i'd need to pass an array of struct.
a very simple struct like this one
- in C
typedef struct atom_simple
- in C#
public struct Atom
public int type;
public float float_value;
public string string_value;
I'd like to put those struct in an array but i need a MonoClass to create
the MonoArray, something like:
MonoClass *c = mono_class_from_name (image, "PureData", "Atom");
mono_array_new (domain, c, argc);
but is this the right thing to do? i mean does mono_class_from_name () work
on struct also?
if not, is there another way i can create a monoarray ?
sadly the examples in samples/embed don't cover this.
----- Original Message -----
From: "Paolo Molaro" <lupus at ximian.com>
To: <mono-devel-list at lists.ximian.com>
Sent: Thursday, January 12, 2006 4:48 PM
Subject: Re: [Mono-dev] mono embed: passing arrays from and to unmanaged
> On 01/11/06 Davide Morelli wrote:
>> I'm trying to pass arrays of floats and strings from and to mono embed
>> a C software with no luck.
>> I'd need to call (from C) managed functions like:
>> void TakeManyStrings(string  list);
>> void TakeManyFloats(float  list);
>> i'd also need to do the same from managed to umnanaged: call a C function
>> from C# passing an array of strings and floats.
>> I couldn't find any useful manual page or source code on how to do so..
>> could anybody point out any reference to me?
> See mono/docs/internal-calls.
> An array argument passed to an icall will look like a MonoArray*
> argument on the C side.
> A MonoArray* is a reference so it is passed to managed functions like
> any other reference. See mono/samples/embed/*.c for many invocation
> lupus at debian.org debian/rules
> lupus at ximian.com Monkeys do it better
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
More information about the Mono-devel-list