2008-08-20 Mike Kestner <mkestner@novell.com>

* generator/ReturnValue.cs: use new ListPtrToArray marshaler for
	lists with known element types.
	* glib/Marshaller.cs: new ListPtrToArray marshaller with more
	aggressive list disposal.
	* gtk/Container.custom: remove manual Children impl.  Use Children
	in GetEnumerator instead of pinvoking directly.
	* gtk/Gtk.metadata: remove hidden attr and add element type and owned 
	for Container.GetChildren to generate it properly.

svn path=/trunk/gtk-sharp/; revision=111173
This commit is contained in:
Mike Kestner 2008-08-20 19:48:26 +00:00
parent b2e51e9989
commit cab2f46db5
5 changed files with 28 additions and 24 deletions

View file

@ -1,3 +1,14 @@
2008-08-20 Mike Kestner <mkestner@novell.com>
* generator/ReturnValue.cs: use new ListPtrToArray marshaler for
lists with known element types.
* glib/Marshaller.cs: new ListPtrToArray marshaller with more
aggressive list disposal.
* gtk/Container.custom: remove manual Children impl. Use Children
in GetEnumerator instead of pinvoking directly.
* gtk/Gtk.metadata: remove hidden attr and add element type and owned
for Container.GetChildren to generate it properly.
2008-08-20 Mike Kestner <mkestner@novell.com>
Patch from Christian Hoff fixing bug #396195.

View file

@ -124,9 +124,8 @@ namespace GtkSharp.Generation {
return String.Empty;
if (ElementType != String.Empty) {
string type_str = "typeof (" + ElementType + ")";
string args = type_str + ", " + (owned ? "true" : "false") + ", " + (elements_owned ? "true" : "false");
return String.Format ("({0}[]) GLib.Marshaller.ListToArray ({1}, {2})", ElementType, IGen.FromNativeReturn (var + ", " + args), type_str);
string args = (owned ? "true" : "false") + ", " + (elements_owned ? "true" : "false");
return String.Format ("({0}[]) GLib.Marshaller.ListPtrToArray ({1}, typeof({2}), {3}, typeof({0}))", ElementType, var, IGen.QualifiedName, args);
} else if (IGen is HandleBase)
return ((HandleBase)IGen).FromNative (var, owned);
else if (is_null_term)

View file

@ -351,6 +351,18 @@ namespace GLib {
return result;
}
public static Array ListPtrToArray (IntPtr list_ptr, Type list_type, bool owned, bool elements_owned, Type elem_type)
{
ListBase list;
if (list_type == typeof(GLib.List))
list = new GLib.List (list_ptr, elem_type, owned, elements_owned);
else
list = new GLib.SList (list_ptr, elem_type, owned, elements_owned);
using (list)
return ListToArray (list, elem_type);
}
public static Array ListToArray (ListBase list, System.Type type)
{
Array result = Array.CreateInstance (type, list.Count);

View file

@ -31,28 +31,9 @@ public GLib.Value ChildGetProperty (Gtk.Widget child, string property_name) {
return value;
}
[DllImport("libgtk-win32-2.0-0.dll")]
static extern IntPtr gtk_container_get_children (IntPtr raw);
public Widget[] Children {
get {
IntPtr list_ptr = gtk_container_get_children (Handle);
if (list_ptr == IntPtr.Zero)
return new Widget [0];
GLib.List list = new GLib.List (list_ptr);
Widget[] result = new Widget [list.Count];
for (int i = 0; i < list.Count; i++)
result [i] = list [i] as Widget;
return result;
}
}
public IEnumerator GetEnumerator ()
{
IntPtr list_ptr = gtk_container_get_children (Handle);
GLib.List list = new GLib.List (list_ptr);
return list.GetEnumerator ();
return Children.GetEnumerator ();
}
class ChildAccumulator {

View file

@ -317,7 +317,8 @@
<attr path="/api/namespace/object[@cname='GtkContainer']/method[@name='Forall']/*/*[@name='callback']" name="scope">call</attr>
<attr path="/api/namespace/object[@cname='GtkContainer']/method[@name='Foreach']/*/*[@name='callback']" name="scope">call</attr>
<attr path="/api/namespace/object[@cname='GtkContainer']/method[@name='ForeachFull']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GtkContainer']/method[@name='GetChildren']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GtkContainer']/method[@name='GetChildren']/return-type" name="element_type">GtkWidget*</attr>
<attr path="/api/namespace/object[@cname='GtkContainer']/method[@name='GetChildren']/return-type" name="owned">true</attr>
<attr path="/api/namespace/object[@cname='GtkContainer']/method[@name='GetFocusChain']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GtkContainer']/method[@name='SetFocusChain']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GtkContainer']/signal[@name='Add']" name="name">Added</attr>