Re: [Mono-dev] Usage of construct properties in a wrapped GObject library
On Mon, 2009-04-27 at 11:42 -0700, MardyTardi wrote: = public Map () : base (IntPtr.Zero) { if (GetType () != typeof (Map)) { CreateNativeObject (new string [0], new GLib.Value[0]); return; } Raw = osm_gps_map_new(); } = osm_gps_map_new() is the C constructor of my GObject, but what I'd like to have is a constructor which accepts a list of properties + values, and pass it to g_object_newv(). But I cannot find an equivalent for g_object_newv() in C#, that's why I'm stuck. Any hints? You may have figured this out already, but the CreateNativeObject call in that generated call is the equivalent of g_object_newv. The string[] is a list of property names. The GLib.Value[] is their corresponding values. -- Mike Kestner mkest...@gmail.com ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] Usage of construct properties in a wrapped GObject library
Hi all, I hope this is the right list for this kind of questions. I have a GObject-based library, written in C, which I want to use from a C# application (f-spot). I generated the bindings with the GAPI tools, but I'm not satisfied with the result. The problem is that the C API for that GObject provides a method that is called my_object_new(), which simply calls g_object_new() with the proper arguments. But the object supports many other construct-only properties, which I want to set from the C# application, and apparently I cannot, because the GAPI tools only generated one constructor which takes no parameters. I guess that by modifying the C library by adding more _new() methods I can get more constructors in the C# API, but is there some other way around it, without modifying the C API? TIA! Alberto -- View this message in context: http://www.nabble.com/Usage-of-construct-properties-in-a-wrapped-GObject-library-tp23243364p23243364.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Usage of construct properties in a wrapped GObject library
Hi Alberto, you may want to try this out if GAPI does not work out for you: http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120 Pinvoke Interop Assistant works much like GAPI: It will parse header files and generate the Pinvokes for you. It's not perfect, but it worked well enough for me when I ran it through OpenGL's gl.h file to import a few hundred methods. (I took care of the errors with some regex replaces and manual tweaking) Koush On 4/26/09 8:38 AM, mardy.tardi ma...@users.sourceforge.net wrote: Hi all, I hope this is the right list for this kind of questions. I have a GObject-based library, written in C, which I want to use from a C# application (f-spot). I generated the bindings with the GAPI tools, but I'm not satisfied with the result. The problem is that the C API for that GObject provides a method that is called my_object_new(), which simply calls g_object_new() with the proper arguments. But the object supports many other construct-only properties, which I want to set from the C# application, and apparently I cannot, because the GAPI tools only generated one constructor which takes no parameters. I guess that by modifying the C library by adding more _new() methods I can get more constructors in the C# API, but is there some other way around it, without modifying the C API? TIA! Alberto -- View this message in context: http://www.nabble.com/Usage-of-construct-properties-in-a-wrapped-GObject-library-tp23243364p23243364.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Usage of construct properties in a wrapped GObject library
On Sun, Apr 26, 2009 at 11:38 AM, mardy.tardi ma...@users.sourceforge.net wrote: I guess that by modifying the C library by adding more _new() methods I can get more constructors in the C# API, but is there some other way around it, without modifying the C API? Use .custom files to add custom constructors into the C# wrapper. http://mono-project.com/GAPI#.custom_files -- Michael Hutchinson http://mjhutchinson.com ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Usage of construct properties in a wrapped GObject library
Michael Hutchinson wrote: On Sun, Apr 26, 2009 at 11:38 AM, mardy.tardi ma...@users.sourceforge.net wrote: I guess that by modifying the C library by adding more _new() methods I can get more constructors in the C# API, but is there some other way around it, without modifying the C API? Use .custom files to add custom constructors into the C# wrapper. http://mono-project.com/GAPI#.custom_files Thank you both. Actually what I need is an explanation on how to write the actual code; I know GObject well, but I'm totally new to C#. The auto generated constructor is: = public Map () : base (IntPtr.Zero) { if (GetType () != typeof (Map)) { CreateNativeObject (new string [0], new GLib.Value[0]); return; } Raw = osm_gps_map_new(); } = osm_gps_map_new() is the C constructor of my GObject, but what I'd like to have is a constructor which accepts a list of properties + values, and pass it to g_object_newv(). But I cannot find an equivalent for g_object_newv() in C#, that's why I'm stuck. Any hints? Ciao, Alberto -- http://www.mardy.it - geek in un lingua international! -- View this message in context: http://n2.nabble.com/Usage-of-construct-properties-in-a-wrapped-GObject-library-tp2726035p2727814.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Usage of construct properties in a wrapped GObject library
You simply write a new constructor using the already existing one, for instance: public Map(string propertyName, string propertyValue) : this() { Add(propertyName, propertyValue) } Hope it helps, On Mon, Apr 27, 2009 at 3:42 PM, MardyTardi ma...@users.sourceforge.netwrote: Michael Hutchinson wrote: On Sun, Apr 26, 2009 at 11:38 AM, mardy.tardi ma...@users.sourceforge.net wrote: I guess that by modifying the C library by adding more _new() methods I can get more constructors in the C# API, but is there some other way around it, without modifying the C API? Use .custom files to add custom constructors into the C# wrapper. http://mono-project.com/GAPI#.custom_files Thank you both. Actually what I need is an explanation on how to write the actual code; I know GObject well, but I'm totally new to C#. The auto generated constructor is: = public Map () : base (IntPtr.Zero) { if (GetType () != typeof (Map)) { CreateNativeObject (new string [0], new GLib.Value[0]); return; } Raw = osm_gps_map_new(); } = osm_gps_map_new() is the C constructor of my GObject, but what I'd like to have is a constructor which accepts a list of properties + values, and pass it to g_object_newv(). But I cannot find an equivalent for g_object_newv() in C#, that's why I'm stuck. Any hints? Ciao, Alberto -- http://www.mardy.it - geek in un lingua international! -- View this message in context: http://n2.nabble.com/Usage-of-construct-properties-in-a-wrapped-GObject-library-tp2726035p2727814.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list -- Rafael Monoman Teixeira --- To be creative means to be in love with life. You can be creative only if you love life enough that you want to enhance its beauty, you want to bring a little more music to it, a little more poetry to it, a little more dance to it. Osho ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list