[Mono-list] passing MonoArray from c#
Robert Jordan
robertj at gmx.net
Sun May 3 17:16:40 EDT 2009
fozzie wrote:
> Thanks B-)! That cleans up the property/field/getStrings/getLinks tests
> nicely.
>
> Once i hit the MonoEmbed:LinksRefExample i'm in the rough again. Do you know
> if there is a way to pass an unmanaged pointer as a ref (or even out)
> argument to a managed method and get it filled with data? There are
> situations where it would be convenient to fill more than one data structure
> since calls to the managed side are expensive.
// invoking MonoEmbed:LinksRefExample
MonoArray *links; // <- must not be allocated
params[0] = &links; // <- note the double reference
exc = NULL;
mono_runtime_invoke(method, instance, params, &exc);
if (exc != NULL)
abort ();
// was "links" populated?
if (links) {
// get links[1] just for kicks
link = mono_array_addr(linksArg, DataLink, 1);
printf ("link type: %d\n", link->type);
}
> Speaking of which, the moonlight code makes heavy use of delegates.. perhaps
> because of performance? I tried to use a delegate to get the link data, but
> the test
>
> retLinks = (*the_delegates.the_stringsfield_delegate)();
>
> crashes immediately on entry. Can you tell me if i'm doing something wrong?
I'll look at this tomorrow.
Robert
More information about the Mono-list
mailing list