protected virtual void CreateNativeObject(string[] names, GLib.Value[] vals) { GType gtype = LookupGType(); bool is_managed_subclass = GType.IsManaged(gtype); GParameter[] parms = new GParameter [is_managed_subclass ? names.Length + 1 : names.Length]; for (int i = 0; i < names.Length; i++) { parms [i].name = GLib.Marshaller.StringToPtrGStrdup(names [i]); parms [i].val = vals [i]; } if (is_managed_subclass) { GCHandle gch = GCHandle.Alloc(this); parms[names.Length].name = GLib.Marshaller.StringToPtrGStrdup("gtk-sharp-managed-instance"); parms[names.Length].val = new GLib.Value((IntPtr)gch); Raw = g_object_newv(gtype.Val, parms.Length, parms); gch.Free(); } else { Raw = g_object_newv(gtype.Val, parms.Length, parms); } foreach (GParameter p in parms) { GLib.Marshaller.Free(p.name); } }
protected virtual void CreateNativeObject(string[] names, GLib.Value[] vals) { GType gtype = LookupGType (); bool is_managed_subclass = gtype.ToString ().StartsWith ("__gtksharp"); GParameter[] parms = new GParameter [is_managed_subclass ? names.Length + 1 : names.Length]; for (int i = 0; i < names.Length; i++) { parms [i].name = GLib.Marshaller.StringToPtrGStrdup (names [i]); parms [i].val = vals [i]; } if (is_managed_subclass) { GCHandle gch = GCHandle.Alloc (this); parms[names.Length].name = GLib.Marshaller.StringToPtrGStrdup ("gtk-sharp-managed-instance"); parms[names.Length].val = new GLib.Value ((IntPtr) gch); Raw = g_object_newv (gtype.Val, parms.Length, parms); gch.Free (); } else { Raw = g_object_newv (gtype.Val, parms.Length, parms); } foreach (GParameter p in parms) GLib.Marshaller.Free (p.name); }
static extern IntPtr g_object_newv(IntPtr gtype, int n_params, GParameter[] parms);
protected virtual void CreateNativeObject(string[] names, GObject.Value[] vals) { GParameter[] parms = new GParameter [names.Length]; for (int i = 0; i < names.Length; i++) { parms [i].name = GObject.Marshaller.StringToPtrGStrdup (names [i]); parms [i].val = vals [i]; } Raw = g_object_newv (LookupGType ().Val, parms.Length, parms); foreach (GParameter p in parms) GObject.Marshaller.Free (p.name); }