/// <summary> /// Free the boxed structure @boxed which is of type @boxed_type. /// </summary> /// <param name="boxedType"> /// The type of @boxed. /// </param> /// <param name="boxed"> /// The boxed structure to be freed. /// </param> public static void Free(GType boxedType, TypeInstance boxed) { if (!boxedType.IsA(GType.Boxed)) { throw new ArgumentException("Not a boxed type", nameof(boxedType)); } if (boxed == null) { throw new ArgumentNullException(nameof(boxed)); } g_boxed_free(boxedType, boxed.Handle); }
/// <summary> /// Provide a copy of a boxed structure @src_boxed which is of type @boxed_type. /// </summary> /// <param name="boxedType"> /// The type of <paramref name="srcBoxed" />. /// </param> /// <param name="srcBoxed"> /// The boxed structure to be copied. /// </param> /// <returns> /// The newly created copy of the boxed structure. /// </returns> public static T Copy <T> (GType boxedType, T srcBoxed) where T : TypeInstance { if (!boxedType.IsA(GType.Boxed)) { throw new ArgumentException("Not a boxed type", nameof(boxedType)); } if (srcBoxed == null) { throw new ArgumentNullException(nameof(srcBoxed)); } var ret_ = g_boxed_copy(boxedType, srcBoxed.Handle); return((T)Activator.CreateInstance(typeof(T), ret_, Transfer.Full)); }
static IntPtr New(string name, string nick, string blurb, GType objectType, ParamFlags flags) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (nick == null) { throw new ArgumentNullException(nameof(nick)); } if (blurb == null) { throw new ArgumentNullException(nameof(blurb)); } if (!objectType.IsA(GType.Object)) { throw new ArgumentException("Expecting object type.", nameof(objectType)); } var namePtr = GMarshal.StringToUtf8Ptr(name); var nickPtr = GMarshal.StringToUtf8Ptr(nick); var blurbPtr = GMarshal.StringToUtf8Ptr(blurb); var ret = g_param_spec_object(namePtr, nickPtr, blurbPtr, objectType, flags); // Any strings that have the cooresponding static flag set must not // be freed because they are passed to g_intern_static_string(). if (!flags.HasFlag(ParamFlags.StaticName)) { GMarshal.Free(namePtr); } if (!flags.HasFlag(ParamFlags.StaticNick)) { GMarshal.Free(nickPtr); } if (!flags.HasFlag(ParamFlags.StaticBlurb)) { GMarshal.Free(blurbPtr); } return(ret); }