[Mono-list] embedding mono and returning GList

2011-05-22 Thread Nils Andresen
Hi, I'd like to call a managed method from c which returns a GLib.List. I seem to be unable to do this, however.. my managed code looks like: public GLib.List Test() { GLib.List list = new GLib.List(typeof(string)); list.Append(eins); list.Append(zwei);

Re: [Mono-list] embedding mono and returning GList

2011-05-22 Thread Miguel de Icaza
I'd like to call a managed method from c which returns a GLib.List. I seem to be unable to do this, however.. my managed code looks like: public GLib.List Test() { GLib.List list = new GLib.List(typeof(string)); list.Append(eins); list.Append(zwei);

Re: [Mono-list] embedding mono and returning GList

2011-05-22 Thread Robert Jordan
On 22.05.2011 15:05, Nils Andresen wrote: 2011/5/22 Miguel de Icazamig...@xamarin.com: What you are getting back is not a pointer to the C GList, but a pointer to the managed GList; What you need to do is return the unmanaged pointer that is wrapped by the C# GList, that would be the

Re: [Mono-list] embedding mono and returning GList

2011-05-22 Thread Alan
Print out the value of the 'Handle' property in your c# code before the method returns and then print the value you get in native after you unbox. If they're not the same value you're done something wrong. Give that a shot and see what happens. Maybe it'll help you diagnose the issue. Alan On 22

Re: [Mono-list] embedding mono and returning GList

2011-05-22 Thread Robert Jordan
On 22.05.2011 19:52, Nils Andresen wrote: 2011/5/22 Robert Jordanrobe...@gmx.net: You must unbox the returned object. See mono_object_unbox(). Robert Yes, I tried that, too. The code looks like this: MonoObject *o = mono_runtime_invoke (method, instance, NULL,ex); GList *list = (GList

Re: [Mono-list] embedding mono and returning GList

2011-05-22 Thread Nils Andresen
2011/5/22 Alan alan.mcgov...@gmail.com: Print out the value of the 'Handle' property in your c# code before the method returns and then print the value you get in native after you unbox. If they're not the same value you're done something wrong. Give that a shot and see what happens. Maybe

Re: [Mono-list] embedding mono and returning GList

2011-05-22 Thread Nils Andresen
2011/5/22 Robert Jordan robe...@gmx.net: mono_object_unbox() returns a pointer to your intptr, so you have to dereference it: GList *list = *(GList**)mono_object_unbox (o); Thank you, Robert - you are amazing!! And I definitively have to read up on the usage of pointers - and on how many