public Package[] Query(params QueryPart[] queryParts) { // FIXME: Set owned and items owned correctly GLib.SList query = new GLib.SList(IntPtr.Zero, typeof(IntPtr)); foreach (QueryPart part in queryParts) { IntPtr key_as_native = GLib.Marshaller.StringToPtrGStrdup(part.Key); IntPtr query_str_as_native = GLib.Marshaller.StringToPtrGStrdup(part.QueryStr); IntPtr rawPart = rc_query_part_new(key_as_native, (int)part.Type, query_str_as_native); GLib.Marshaller.Free(key_as_native); GLib.Marshaller.Free(query_str_as_native); query.Append(rawPart); } IntPtr raw_ret = rc_query_packages(Handle, query.Handle); foreach (IntPtr p in query) { rc_query_part_free(p); } query.Dispose(); return((RC.Package[])GLib.Marshaller.ListToArray(new GLib.SList(raw_ret, typeof(RC.Package), false, false), typeof(RC.Package))); }
public void AddTags(SourceTag[] tags) { GLib.SList list = new GLib.SList(typeof(SourceTag)); foreach (SourceTag tag in tags) { list.Append(tag.Handle); } gtk_source_tag_table_add_tags(Handle, list.Handle); }
internal static GLib.SList ToSList(PackageDep[] deps) { GLib.SList ret = new GLib.SList(typeof(PackageDep)); foreach (PackageDep d in deps) { ret.Append(d.Handle); } return(ret); }
public void SetInstructionsTake(Cdn.Instruction[] instructions) { GLib.SList ptr = new GLib.SList(typeof(IntPtr)); for (int i = 0; i < instructions.Length; ++i) { ptr.Append(instructions[i].Handle); } cdn_expression_set_instructions_take(Handle, ptr.Handle); }
public static Gtk.TextTag KeywordListTagNew(string id, string name, string[] keywords, bool case_sensitive, bool match_empty_string_at_beginning, bool match_empty_string_at_end, string beginning_regex, string end_regex) { GLib.SList list = new GLib.SList(typeof(string)); foreach (string s in keywords) { list.Append(s); } IntPtr raw_ret = gtk_keyword_list_tag_new(id, name, list.Handle, case_sensitive, match_empty_string_at_beginning, match_empty_string_at_end, beginning_regex, end_regex); Gtk.TextTag ret; if (raw_ret == IntPtr.Zero) { ret = null; } else { ret = (Gtk.TextTag)GLib.Object.GetObject(raw_ret); } return(ret); }
public Package[] Query (params QueryPart[] queryParts) { // FIXME: Set owned and items owned correctly GLib.SList query = new GLib.SList (IntPtr.Zero, typeof (IntPtr)); foreach (QueryPart part in queryParts) { IntPtr key_as_native = GLib.Marshaller.StringToPtrGStrdup (part.Key); IntPtr query_str_as_native = GLib.Marshaller.StringToPtrGStrdup (part.QueryStr); IntPtr rawPart = rc_query_part_new (key_as_native, (int) part.Type, query_str_as_native); GLib.Marshaller.Free (key_as_native); GLib.Marshaller.Free (query_str_as_native); query.Append (rawPart); } IntPtr raw_ret = rc_query_packages (Handle, query.Handle); foreach (IntPtr p in query) rc_query_part_free (p); query.Dispose (); return (RC.Package[]) GLib.Marshaller.ListToArray (new GLib.SList (raw_ret, typeof (RC.Package), false, false), typeof (RC.Package)); }
GLib.SList GetListFromCollection (ICollection data, out ValueType listType) { object [] arr = (object []) Array.CreateInstance (typeof (object), data.Count); data.CopyTo (arr, 0); listType = ValueType.Invalid; GLib.SList list = new GLib.SList (IntPtr.Zero); GC.SuppressFinalize (list); if (data.Count == 0) { if (data is string []) listType = ValueType.String; else if (data is int []) listType = ValueType.Int; else if (data is double []) listType = ValueType.Float; else if (data is bool []) listType = ValueType.Bool; } if (arr.Length == 0) { if (data is Array) listType = LookupType (data.GetType ().GetElementType ()); else throw new InvalidValueTypeException (); return list; } foreach (object o in arr) { ValueType type = LookupType (o.GetType ()); if (listType == ValueType.Invalid) listType = type; if (listType == ValueType.Invalid || type != listType) throw new InvalidValueTypeException (); Value v = new Value (o); GC.SuppressFinalize (v); list.Append (v.Raw); } return list; }
GLib.SList GetListFromCollection(ICollection data, out ValueType listType) { object [] arr = (object [])Array.CreateInstance(typeof(object), data.Count); data.CopyTo(arr, 0); listType = ValueType.Invalid; GLib.SList list = new GLib.SList(IntPtr.Zero); GC.SuppressFinalize(list); if (data.Count == 0) { if (data is string []) { listType = ValueType.String; } else if (data is int []) { listType = ValueType.Int; } else if (data is double []) { listType = ValueType.Float; } else if (data is bool []) { listType = ValueType.Bool; } } if (arr.Length == 0) { if (data is Array) { listType = LookupType(data.GetType().GetElementType()); } else { throw new InvalidValueTypeException(); } return(list); } foreach (object o in arr) { ValueType type = LookupType(o.GetType()); if (listType == ValueType.Invalid) { listType = type; } if (listType == ValueType.Invalid || type != listType) { throw new InvalidValueTypeException(); } Value v = new Value(o); GC.SuppressFinalize(v); list.Append(v.Raw); } return(list); }