2005-04-04 Mike Kestner <mkestner@novell.com>

* gdk/Gdk.metadata : hide some manually implemented callback methods.
	* gdk/*.custom : implement several methods containing persistent
	callback parameters.
	* generator/BoxedGen.cs : set gen_info.CurrentType in Generate.
	* generator/ClassGen.cs : set gen_info.CurrentType in Generate.
	* generator/Ctor.cs : set gen_info.CurrentMember in Generate.
	* generator/GenerationInfo.cs : add CurrentMember and CurrentType.
	* generator/Method.cs : set gen_info.CurrentMember in Generate.
	* generator/MethodBody.cs : always generate null guarding for array
	parameters, and add a nag for callback parameters without a scope attr.
	* generator/ObjectGen.cs : set gen_info.CurrentType in Generate.
	* generator/OpaqueGen.cs : set gen_info.CurrentType in Generate.
	* generator/Parameters.cs : kill NullOk. add Scope property.
	* generator/StructGen.cs : set gen_info.CurrentType in Generate.
	* gtk/Gtk.metadata : kill a few null_ok attrs.
	* pango/Pango.metadata : mark the callback params as call scope. kill
	a couple null_ok attrs.

svn path=/trunk/gtk-sharp/; revision=42529
This commit is contained in:
Mike Kestner 2005-04-04 16:27:08 +00:00
parent 246d4e1620
commit 96f81cfbd4
22 changed files with 203 additions and 36 deletions

View file

@ -1,3 +1,23 @@
2005-04-04 Mike Kestner <mkestner@novell.com>
* gdk/Gdk.metadata : hide some manually implemented callback methods.
* gdk/*.custom : implement several methods containing persistent
callback parameters.
* generator/BoxedGen.cs : set gen_info.CurrentType in Generate.
* generator/ClassGen.cs : set gen_info.CurrentType in Generate.
* generator/Ctor.cs : set gen_info.CurrentMember in Generate.
* generator/GenerationInfo.cs : add CurrentMember and CurrentType.
* generator/Method.cs : set gen_info.CurrentMember in Generate.
* generator/MethodBody.cs : always generate null guarding for array
parameters, and add a nag for callback parameters without a scope attr.
* generator/ObjectGen.cs : set gen_info.CurrentType in Generate.
* generator/OpaqueGen.cs : set gen_info.CurrentType in Generate.
* generator/Parameters.cs : kill NullOk. add Scope property.
* generator/StructGen.cs : set gen_info.CurrentType in Generate.
* gtk/Gtk.metadata : kill a few null_ok attrs.
* pango/Pango.metadata : mark the callback params as call scope. kill
a couple null_ok attrs.
2005-04-01 Dan Winship <danw@novell.com> 2005-04-01 Dan Winship <danw@novell.com>
* samples/GtkDemo/*.cs: General fixup and cleanup; Remove some * samples/GtkDemo/*.cs: General fixup and cleanup; Remove some

View file

@ -1,5 +1,5 @@
<Type Name="DestroyNotify" FullName="Gdk.DestroyNotify"> <Type Name="DestroyNotify" FullName="Gdk.DestroyNotify">
<TypeSignature Language="C#" Value="public sealed delegate void DestroyNotify ();" Maintainer="auto" /> <TypeSignature Language="C#" Maintainer="auto" Value="public sealed delegate void DestroyNotify ();" />
<AssemblyInfo> <AssemblyInfo>
<AssemblyName>gdk-sharp</AssemblyName> <AssemblyName>gdk-sharp</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion> <AssemblyVersion>0.0.0.0</AssemblyVersion>

View file

@ -73,3 +73,16 @@
return result; return result;
} }
[DllImport("libgdk-win32-2.0-0.dll")]
static extern void gdk_display_add_client_message_filter (IntPtr raw, IntPtr message_type, GdkSharp.FilterFuncNative func, IntPtr data);
public void AddClientMessageFilter (Gdk.Atom message_type, Gdk.FilterFunc func)
{
GdkSharp.FilterFuncWrapper func_wrapper = new GdkSharp.FilterFuncWrapper (func);
if (!PersistentData.Contains ("client_message_filter_func_list"))
PersistentData ["client_message_filter_func_list"] = new ArrayList ();
ArrayList func_list = PersistentData ["client_message_filter_func_list"] as ArrayList;
func_list.Add (func_wrapper);
gdk_display_add_client_message_filter (Handle, message_type == null ? IntPtr.Zero : message_type.Handle, func_wrapper.NativeDelegate, IntPtr.Zero);
}

View file

@ -15,12 +15,15 @@
<attr path="/api/namespace/class[@cname='GdkDrag_']/method[@name='FindWindowForScreen']/*/*[@name='dest_window']" name="pass_as">out</attr> <attr path="/api/namespace/class[@cname='GdkDrag_']/method[@name='FindWindowForScreen']/*/*[@name='dest_window']" name="pass_as">out</attr>
<attr path="/api/namespace/class[@cname='GdkEvent_']/method[@name='HandlerSet']" name="hidden">1</attr> <attr path="/api/namespace/class[@cname='GdkEvent_']/method[@name='HandlerSet']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='GdkEvent_']" name="name">EventHelper</attr> <attr path="/api/namespace/class[@cname='GdkEvent_']" name="name">EventHelper</attr>
<attr path="/api/namespace/class[@cname='GdkInput_']/method[@name='Add']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='GdkInput_']/method[@name='AddFull']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='GdkKeyval_']/method[@name='Name']/return-type" name="type">const-gchar*</attr> <attr path="/api/namespace/class[@cname='GdkKeyval_']/method[@name='Name']/return-type" name="type">const-gchar*</attr>
<attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='DevicesList']" name="hidden">1</attr> <attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='DevicesList']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='FreeTextList']" name="hidden">1</attr> <attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='FreeTextList']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='InitCheck']" name="hidden">1</attr> <attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='InitCheck']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='ListVisuals']" name="hidden">1</attr> <attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='ListVisuals']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='ParseArgs']" name="hidden">1</attr> <attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='ParseArgs']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='AddClientMessageFilter']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='StringToCompoundText']" name="hidden">1</attr> <attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='StringToCompoundText']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='StringToCompoundTextForDisplay']" name="hidden">1</attr> <attr path="/api/namespace/class[@cname='GdkGlobal']/method[@name='StringToCompoundTextForDisplay']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='GdkPango_']" name="name">PangoHelper</attr> <attr path="/api/namespace/class[@cname='GdkPango_']" name="name">PangoHelper</attr>
@ -47,6 +50,7 @@
<attr path="/api/namespace/object[@cname='GdkDevice']/method[@name='GetHistory']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkDevice']/method[@name='GetHistory']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkDevice']/method[@name='GetState']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkDevice']/method[@name='GetState']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkDevice']/method[@name='SetSource']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkDevice']/method[@name='SetSource']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkDisplay']/method[@name='AddClientMessageFilter']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkDisplay']/method[@name='GetPointer']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkDisplay']/method[@name='GetPointer']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkDisplay']/method[@name='ListDevices']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkDisplay']/method[@name='ListDevices']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkDisplayManager']/method[@name='ListDisplays']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkDisplayManager']/method[@name='ListDisplays']" name="hidden">1</attr>
@ -61,7 +65,7 @@
<attr path="/api/namespace/object[@cname='GdkDrawable']/method[@name='GetSize']/*/*[@type='gint*']" name="pass_as">out</attr> <attr path="/api/namespace/object[@cname='GdkDrawable']/method[@name='GetSize']/*/*[@type='gint*']" name="pass_as">out</attr>
<attr path="/api/namespace/object[@cname='GdkKeymap']/method[@name='GetEntriesForKeycode']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkKeymap']/method[@name='GetEntriesForKeycode']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkKeymap']/method[@name='GetEntriesForKeyval']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkKeymap']/method[@name='GetEntriesForKeyval']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkPixbuf']/constructor[@cname='gdk_pixbuf_new_from_data']/*/*[@name='data']" name="array">1</attr> <attr path="/api/namespace/object[@cname='GdkPixbuf']/constructor[@cname='gdk_pixbuf_new_from_data']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkPixbuf']/constructor[@cname='gdk_pixbuf_new_from_file']" name="preferred">1</attr> <attr path="/api/namespace/object[@cname='GdkPixbuf']/constructor[@cname='gdk_pixbuf_new_from_file']" name="preferred">1</attr>
<attr path="/api/namespace/object[@cname='GdkPixbuf']/constructor[@cname='gdk_pixbuf_new_from_inline']/*/*[@name='data']" name="array">1</attr> <attr path="/api/namespace/object[@cname='GdkPixbuf']/constructor[@cname='gdk_pixbuf_new_from_inline']/*/*[@name='data']" name="array">1</attr>
<attr path="/api/namespace/object[@cname='GdkPixbuf']/constructor[@cname='gdk_pixbuf_new_from_xpm_data']/*/*[@name='data']" name="array">1</attr> <attr path="/api/namespace/object[@cname='GdkPixbuf']/constructor[@cname='gdk_pixbuf_new_from_xpm_data']/*/*[@name='data']" name="array">1</attr>
@ -104,9 +108,10 @@
<attr path="/api/namespace/object[@cname='GdkScreen']/method[@name='ListVisuals']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkScreen']/method[@name='ListVisuals']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkScreen']/method[@name='Width']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkScreen']/method[@name='Width']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkScreen']/method[@name='WidthMm']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkScreen']/method[@name='WidthMm']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']" name="parent">GdkDrawable</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='AddFilter']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='Destroy']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='Destroy']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetChildren']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetChildren']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']" name="parent">GdkDrawable</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetFrameExtents']/*/*[@name='rect']" name="pass_as">out</attr> <attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetFrameExtents']/*/*[@name='rect']" name="pass_as">out</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetInternalPaintInfo']/*/*[@type='gint*']" name="pass_as">out</attr> <attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetInternalPaintInfo']/*/*[@type='gint*']" name="pass_as">out</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetInternalPaintInfo']/*/*[@type='GdkDrawable**']" name="pass_as">out</attr> <attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetInternalPaintInfo']/*/*[@type='GdkDrawable**']" name="pass_as">out</attr>
@ -115,6 +120,7 @@
<attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetPointer']/*/*[@type='GdkModifierType*']" name="pass_as">out</attr> <attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetPointer']/*/*[@type='GdkModifierType*']" name="pass_as">out</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetToplevels']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetToplevels']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='PeekChildren']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='PeekChildren']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='RemoveFilter']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='SetIconList']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='SetIconList']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetUserData']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkWindow']/method[@name='GetUserData']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkWindow']/method[@cname='gdk_window_set_user_data']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GdkWindow']/method[@cname='gdk_window_set_user_data']" name="hidden">1</attr>
@ -146,6 +152,7 @@
<attr path="/api/namespace/struct[@cname='GdkRegion']/method[@name='GetRectangles']" name="hidden">1</attr> <attr path="/api/namespace/struct[@cname='GdkRegion']/method[@name='GetRectangles']" name="hidden">1</attr>
<attr path="/api/namespace/struct[@cname='GdkRegion']/method[@name='Polygon']/*/*[@name='points']" name="array">1</attr> <attr path="/api/namespace/struct[@cname='GdkRegion']/method[@name='Polygon']/*/*[@name='points']" name="array">1</attr>
<attr path="/api/namespace/struct[@cname='GdkRegion']/method[@name='Polygon']/*/*[@name='npoints']" name="name">n_points</attr> <attr path="/api/namespace/struct[@cname='GdkRegion']/method[@name='Polygon']/*/*[@name='npoints']" name="name">n_points</attr>
<attr path="/api/namespace/struct[@cname='GdkRegion']/method[@name='SpansIntersectForeach']/*/*[@name='function']" name="scope">call</attr>
<attr path="/api/namespace/struct[@cname='GdkTimeCoord']/field[@cname='axes']" name="array_len">128</attr> <attr path="/api/namespace/struct[@cname='GdkTimeCoord']/field[@cname='axes']" name="array_len">128</attr>
<attr path="/api/namespace/struct[@cname='GdkWindowObject']" name="hidden">1</attr> <attr path="/api/namespace/struct[@cname='GdkWindowObject']" name="hidden">1</attr>
</metadata> </metadata>

View file

@ -191,3 +191,8 @@
return result; return result;
} }
public static void AddClientMessageFilter (Gdk.Atom message_type, Gdk.FilterFunc func)
{
Gdk.Display.Default.AddClientMessageFilter (message_type, func);
}

58
gdk/Input.custom Normal file
View file

@ -0,0 +1,58 @@
// Gdk.Input.custom - Gdk Input class customizations
//
// Author: Mike Kestner <mkestner@ximian.com>
//
// Copyright (C) 2005 Novell, Inc.
//
// This code is inserted after the automatically generated code.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
[GLib.CDeclCallback]
delegate void DestroyNotify (IntPtr data);
static void ReleaseGCHandle (IntPtr data)
{
if (data == IntPtr.Zero)
return;
GCHandle gch = (GCHandle) data;
gch.Free ();
}
static DestroyNotify release_gchandle;
[DllImport("libgdk-win32-2.0-0.dll")]
static extern int gdk_input_add_full (int source, int condition, GdkSharp.InputFunctionNative function, IntPtr data, DestroyNotify destroy);
[Obsolete]
public static int AddFull (int source, Gdk.InputCondition condition, Gdk.InputFunction function, IntPtr data, Gdk.DestroyNotify destroy)
{
if (release_gchandle == null)
release_gchandle = new DestroyNotify (ReleaseGCHandle);
GdkSharp.InputFunctionWrapper function_wrapper = new GdkSharp.InputFunctionWrapper (function);
GCHandle gch = GCHandle.Alloc (function_wrapper);
return gdk_input_add_full (source, (int) condition, function_wrapper.NativeDelegate, (IntPtr) gch, release_gchandle);
}
[Obsolete]
public static int Add (int source, Gdk.InputCondition condition, Gdk.InputFunction function)
{
if (release_gchandle == null)
release_gchandle = new DestroyNotify (ReleaseGCHandle);
GdkSharp.InputFunctionWrapper function_wrapper = new GdkSharp.InputFunctionWrapper (function);
GCHandle gch = GCHandle.Alloc (function_wrapper);
return gdk_input_add_full (source, (int) condition, function_wrapper.NativeDelegate, (IntPtr) gch, release_gchandle);
}

View file

@ -38,6 +38,7 @@ customs = \
DragContext.custom \ DragContext.custom \
Drawable.custom \ Drawable.custom \
Global.custom \ Global.custom \
Input.custom \
Keymap.custom \ Keymap.custom \
Pixmap.custom \ Pixmap.custom \
Pixbuf.custom \ Pixbuf.custom \

View file

@ -133,14 +133,22 @@
return ret; return ret;
} }
// overload to default the colorspace [DllImport("libgdk_pixbuf-2.0-0.dll")]
public Pixbuf(byte [] data, bool has_alpha, int bits_per_sample, int width, int height, int rowstride, Gdk.PixbufDestroyNotify destroy_fn) : base (IntPtr.Zero) static extern IntPtr gdk_pixbuf_new_from_data(byte[] data, int colorspace, bool has_alpha, int bits_per_sample, int width, int height, int rowstride, GdkSharp.PixbufDestroyNotifyNative destroy_fn, IntPtr destroy_fn_data);
public Pixbuf (byte[] data, Gdk.Colorspace colorspace, bool has_alpha, int bits_per_sample, int width, int height, int rowstride, Gdk.PixbufDestroyNotify destroy_fn) : base (IntPtr.Zero)
{ {
GdkSharp.PixbufDestroyNotifyWrapper destroy_fn_wrapper = null; if (GetType () != typeof (Pixbuf)) {
destroy_fn_wrapper = new GdkSharp.PixbufDestroyNotifyWrapper (destroy_fn); throw new InvalidOperationException ("Can't override this constructor.");
Raw = gdk_pixbuf_new_from_data(data, (int) Gdk.Colorspace.Rgb, has_alpha, bits_per_sample, width, height, rowstride, destroy_fn_wrapper.NativeDelegate, IntPtr.Zero); }
GdkSharp.PixbufDestroyNotifyWrapper destroy_fn_wrapper = new GdkSharp.PixbufDestroyNotifyWrapper (destroy_fn);
Raw = gdk_pixbuf_new_from_data(data, (int) colorspace, has_alpha, bits_per_sample, width, height, rowstride, destroy_fn_wrapper.NativeDelegate, IntPtr.Zero);
PersistentData ["new_from_data_destroy_fn_wrapper"] = destroy_fn_wrapper;
} }
// overload to default the colorspace
public Pixbuf(byte [] data, bool has_alpha, int bits_per_sample, int width, int height, int rowstride, Gdk.PixbufDestroyNotify destroy_fn) : this (data, Gdk.Colorspace.Rgb, has_alpha, bits_per_sample, width, height, rowstride, destroy_fn) {}
public unsafe Pixbuf(byte[] data, bool copy_pixels) : base (IntPtr.Zero) public unsafe Pixbuf(byte[] data, bool copy_pixels) : base (IntPtr.Zero)
{ {
IntPtr error = IntPtr.Zero; IntPtr error = IntPtr.Zero;
@ -289,8 +297,7 @@
public unsafe void SaveToCallback (PixbufSaveFunc save_func, string type, string[] option_keys, string[] option_values) public unsafe void SaveToCallback (PixbufSaveFunc save_func, string type, string[] option_keys, string[] option_values)
{ {
GdkSharp.PixbufSaveFuncWrapper save_func_wrapper = null; GdkSharp.PixbufSaveFuncWrapper save_func_wrapper = new GdkSharp.PixbufSaveFuncWrapper (save_func);
save_func_wrapper = new GdkSharp.PixbufSaveFuncWrapper (save_func);
IntPtr error = IntPtr.Zero; IntPtr error = IntPtr.Zero;
IntPtr ntype = GLib.Marshaller.StringToPtrGStrdup (type); IntPtr ntype = GLib.Marshaller.StringToPtrGStrdup (type);
IntPtr[] nkeys = NullTerm (option_keys); IntPtr[] nkeys = NullTerm (option_keys);

View file

@ -24,7 +24,6 @@
public Window (Gdk.Window parent, Gdk.WindowAttr attributes, Gdk.WindowAttributesType attributes_mask) : this (parent, attributes, (int)attributes_mask) {} public Window (Gdk.Window parent, Gdk.WindowAttr attributes, Gdk.WindowAttributesType attributes_mask) : this (parent, attributes, (int)attributes_mask) {}
[DllImport("libgdk-win32-2.0-0.dll")] [DllImport("libgdk-win32-2.0-0.dll")]
static extern IntPtr gdk_window_get_children(IntPtr raw); static extern IntPtr gdk_window_get_children(IntPtr raw);
@ -104,6 +103,12 @@
} }
} }
[DllImport("libgdk-win32-2.0-0.dll")]
static extern void gdk_window_add_filter (IntPtr handle, GdkSharp.FilterFuncNative wrapper, IntPtr data);
[DllImport("libgdk-win32-2.0-0.dll")]
static extern void gdk_window_remove_filter (IntPtr handle, GdkSharp.FilterFuncNative wrapper, IntPtr data);
static Hashtable filter_all_hash; static Hashtable filter_all_hash;
static Hashtable FilterAllHash { static Hashtable FilterAllHash {
get { get {
@ -129,6 +134,26 @@
gdk_window_remove_filter (IntPtr.Zero, wrapper.NativeDelegate, IntPtr.Zero); gdk_window_remove_filter (IntPtr.Zero, wrapper.NativeDelegate, IntPtr.Zero);
} }
public void AddFilter (FilterFunc function)
{
if (!PersistentData.Contains ("filter_func_hash"))
PersistentData ["filter_func_hash"] = new Hashtable ();
Hashtable hash = PersistentData ["filter_func_hash"] as Hashtable;
GdkSharp.FilterFuncWrapper wrapper = new GdkSharp.FilterFuncWrapper (function);
hash [function] = wrapper;
gdk_window_add_filter (Handle, wrapper.NativeDelegate, IntPtr.Zero);
}
public void RemoveFilter (FilterFunc function)
{
Hashtable hash = PersistentData ["filter_func_hash"] as Hashtable;
GdkSharp.FilterFuncWrapper wrapper = hash [function] as GdkSharp.FilterFuncWrapper;
if (wrapper == null)
return;
hash.Remove (function);
gdk_window_remove_filter (Handle, wrapper.NativeDelegate, IntPtr.Zero);
}
#if MANLY_ENOUGH_TO_INCLUDE #if MANLY_ENOUGH_TO_INCLUDE
public Cairo.Graphics CairoGraphics (out int offset_x, out int offset_y) public Cairo.Graphics CairoGraphics (out int offset_x, out int offset_y)
{ {

View file

@ -31,6 +31,8 @@ namespace GtkSharp.Generation {
public override void Generate (GenerationInfo gen_info) public override void Generate (GenerationInfo gen_info)
{ {
gen_info.CurrentType = Name;
if (!Validate ()) if (!Validate ())
return; return;

View file

@ -160,6 +160,7 @@ namespace GtkSharp.Generation {
public override void Generate (GenerationInfo gen_info) public override void Generate (GenerationInfo gen_info)
{ {
gen_info.CurrentType = Name;
if (!retval.Validate ()) { if (!retval.Validate ()) {
Console.WriteLine("rettype: " + retval.CType + " in callback " + CName); Console.WriteLine("rettype: " + retval.CType + " in callback " + CName);
Statistics.ThrottledCount++; Statistics.ThrottledCount++;

View file

@ -36,6 +36,8 @@ namespace GtkSharp.Generation {
public override void Generate (GenerationInfo gen_info) public override void Generate (GenerationInfo gen_info)
{ {
gen_info.CurrentType = Name;
StreamWriter sw = gen_info.Writer = gen_info.OpenStream(Name); StreamWriter sw = gen_info.Writer = gen_info.OpenStream(Name);
sw.WriteLine ("namespace " + NS + " {"); sw.WriteLine ("namespace " + NS + " {");

View file

@ -87,6 +87,7 @@ namespace GtkSharp.Generation {
public void Generate (GenerationInfo gen_info) public void Generate (GenerationInfo gen_info)
{ {
StreamWriter sw = gen_info.Writer; StreamWriter sw = gen_info.Writer;
gen_info.CurrentMember = CName;
SymbolTable table = SymbolTable.Table; SymbolTable table = SymbolTable.Table;

View file

@ -2,7 +2,7 @@
// //
// Author: Mike Kestner <mkestner@ximian.com> // Author: Mike Kestner <mkestner@ximian.com>
// //
// Copyright (c) 2003 Ximian Inc. // Copyright (c) 2003-2005 Novell Inc.
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public // modify it under the terms of version 2 of the GNU General Public
@ -127,6 +127,26 @@ namespace GtkSharp.Generation {
glue_sw.Close (); glue_sw.Close ();
} }
string member;
public string CurrentMember {
get {
return typename + "." + member;
}
set {
member = value;
}
}
string typename;
public string CurrentType {
get {
return typename;
}
set {
typename = value;
}
}
public StreamWriter OpenStream (string name) public StreamWriter OpenStream (string name)
{ {
char sep = Path.DirectorySeparatorChar; char sep = Path.DirectorySeparatorChar;

View file

@ -252,6 +252,7 @@ namespace GtkSharp.Generation {
if (!Initialize ()) if (!Initialize ())
return; return;
gen_info.CurrentMember = Name;
if (implementor != null && IsStatic) if (implementor != null && IsStatic)
return; return;

View file

@ -49,9 +49,9 @@ namespace GtkSharp.Generation {
private string CallArrayLength (Parameter array, Parameter length) private string CallArrayLength (Parameter array, Parameter length)
{ {
string result = array.NullOk ? array.Name + " != null ? " : ""; string result = array.Name + " != null ? ";
result += CastFromInt (length.CSType) + array.Name + ".Length"; result += CastFromInt (length.CSType) + array.Name + ".Length";
result += array.NullOk ? ": 0" : ""; result += ": 0";
return length.Generatable.CallByName (result); return length.Generatable.CallByName (result);
} }
@ -126,8 +126,9 @@ namespace GtkSharp.Generation {
if ((is_get || p.PassAs == "out") && p.CSType != p.MarshalType && !(gen is StructBase || gen is ByRefGen)) if ((is_get || p.PassAs == "out") && p.CSType != p.MarshalType && !(gen is StructBase || gen is ByRefGen))
sw.WriteLine(indent + "\t\t\t" + gen.MarshalType + " " + name + "_as_native;"); sw.WriteLine(indent + "\t\t\t" + gen.MarshalType + " " + name + "_as_native;");
else if (p.IsArray && p.MarshalType != p.CSType) { else if (p.IsArray && p.MarshalType != p.CSType) {
sw.WriteLine(indent + "\t\t\t{0}[] native_" + p.Name + " = new {0} [{1}.Length];", p.MarshalType.TrimEnd('[', ']'), name); sw.WriteLine(indent + "\t\t\tint cnt_" + p.Name + " = {0} == null ? 0 : {0}.Length;", name);
sw.WriteLine(indent + "\t\t\tfor (int i = 0; i < {0}.Length; i++)", name); sw.WriteLine(indent + "\t\t\t{0}[] native_" + p.Name + " = new {0} [cnt_{1}];", p.MarshalType.TrimEnd('[', ']'), name);
sw.WriteLine(indent + "\t\t\tfor (int i = 0; i < cnt_{0}; i++)", name);
if (gen is IManualMarshaler) if (gen is IManualMarshaler)
sw.WriteLine(indent + "\t\t\t\tnative_{0} [i] = {1};", p.Name, (gen as IManualMarshaler).AllocNative (name + "[i]")); sw.WriteLine(indent + "\t\t\t\tnative_{0} [i] = {1};", p.Name, (gen as IManualMarshaler).AllocNative (name + "[i]"));
else else
@ -137,14 +138,17 @@ namespace GtkSharp.Generation {
if (gen is CallbackGen) { if (gen is CallbackGen) {
//Console.WriteLine ("***Callback parameter " + gen.Name + " generated in method***" );
CallbackGen cbgen = gen as CallbackGen; CallbackGen cbgen = gen as CallbackGen;
string wrapper = cbgen.GenWrapper(impl_ns, gen_info); string wrapper = cbgen.GenWrapper(impl_ns, gen_info);
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = null;", wrapper, name); switch (p.Scope) {
sw.Write (indent + "\t\t\t"); case "call":
if (p.NullOk) default:
sw.Write ("if ({0} != null) ", name); if (p.Scope == String.Empty)
sw.WriteLine ("{1}_wrapper = new {0} ({1});", wrapper, p.Name); Console.WriteLine ("Defaulting " + gen.Name + " param to 'call' scope in method " + gen_info.CurrentMember);
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = new {0} ({2});", wrapper, name, p.Name);
break;
}
} }
} }

View file

@ -116,6 +116,8 @@ namespace GtkSharp.Generation {
public override void Generate (GenerationInfo gen_info) public override void Generate (GenerationInfo gen_info)
{ {
gen_info.CurrentType = Name;
DirectoryInfo di = GetDirectoryInfo (gen_info.Dir, gen_info.AssemblyName); DirectoryInfo di = GetDirectoryInfo (gen_info.Dir, gen_info.AssemblyName);
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name); StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);

View file

@ -43,6 +43,8 @@ namespace GtkSharp.Generation {
public override void Generate (GenerationInfo gen_info) public override void Generate (GenerationInfo gen_info)
{ {
gen_info.CurrentType = Name;
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name); StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
sw.WriteLine ("namespace " + NS + " {"); sw.WriteLine ("namespace " + NS + " {");

View file

@ -155,12 +155,6 @@ namespace GtkSharp.Generation {
} }
} }
public bool NullOk {
get {
return elem.HasAttribute ("null_ok");
}
}
public string PropertyName { public string PropertyName {
get { get {
return elem.GetAttribute("property_name"); return elem.GetAttribute("property_name");
@ -182,6 +176,12 @@ namespace GtkSharp.Generation {
} }
} }
public string Scope {
get {
return elem.GetAttribute ("scope");
}
}
public string CallByName (string call_parm_name) public string CallByName (string call_parm_name)
{ {
string call_parm; string call_parm;
@ -190,9 +190,6 @@ namespace GtkSharp.Generation {
else else
call_parm = SymbolTable.Table.CallByName(CType, call_parm_name); call_parm = SymbolTable.Table.CallByName(CType, call_parm_name);
if (NullOk && !CSType.EndsWith ("IntPtr") && !(Generatable is StructBase))
call_parm = String.Format ("({0} != null) ? {1} : {2}", call_parm_name, call_parm, Generatable is CallbackGen ? "null" : "IntPtr.Zero");
if (IsArray) if (IsArray)
call_parm = call_parm.Replace ("ref ", ""); call_parm = call_parm.Replace ("ref ", "");

View file

@ -31,6 +31,8 @@ namespace GtkSharp.Generation {
public override void Generate (GenerationInfo gen_info) public override void Generate (GenerationInfo gen_info)
{ {
gen_info.CurrentType = Name;
if (!Validate ()) if (!Validate ())
return; return;

View file

@ -30,9 +30,7 @@
<attr path="/api/namespace/class[@cname='GtkBindings_']/method[@name='Activate']" name="name">BindingsActivate</attr> <attr path="/api/namespace/class[@cname='GtkBindings_']/method[@name='Activate']" name="name">BindingsActivate</attr>
<attr path="/api/namespace/class[@cname='GtkCtree_']" name="hidden">1</attr> <attr path="/api/namespace/class[@cname='GtkCtree_']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='GtkDrag_']/method[@name='DestSet']/*/*[@name='targets']" name="array">1</attr> <attr path="/api/namespace/class[@cname='GtkDrag_']/method[@name='DestSet']/*/*[@name='targets']" name="array">1</attr>
<attr path="/api/namespace/class[@cname='GtkDrag_']/method[@name='DestSet']/*/*[@name='targets']" name="null_ok">1</attr>
<attr path="/api/namespace/class[@cname='GtkDrag_']/method[@name='SourceSet']/*/*[@name='targets']" name="array">1</attr> <attr path="/api/namespace/class[@cname='GtkDrag_']/method[@name='SourceSet']/*/*[@name='targets']" name="array">1</attr>
<attr path="/api/namespace/class[@cname='GtkDrag_']/method[@name='SourceSet']/*/*[@name='targets']" name="null_ok">1</attr>
<attr path="/api/namespace/class[@cname='GtkFile_']" name="hidden">1</attr> <attr path="/api/namespace/class[@cname='GtkFile_']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='GtkGlobal']/method[@name='EventsPending']/return-type" name="type">gboolean</attr> <attr path="/api/namespace/class[@cname='GtkGlobal']/method[@name='EventsPending']/return-type" name="type">gboolean</attr>
<attr path="/api/namespace/class[@cname='GtkGlobal']/method[@name='EventsPending']" name="name">GetEventsPending</attr> <attr path="/api/namespace/class[@cname='GtkGlobal']/method[@name='EventsPending']" name="name">GetEventsPending</attr>
@ -247,7 +245,6 @@
<attr path="/api/namespace/object[@cname='GtkMenuItem']/signal[@name='SizeRequest']" name="name">SizeRequested</attr> <attr path="/api/namespace/object[@cname='GtkMenuItem']/signal[@name='SizeRequest']" name="name">SizeRequested</attr>
<attr path="/api/namespace/object[@cname='GtkMenuItem']/signal[@name='ToggleSizeAllocate']" name="name">ToggleSizeAllocated</attr> <attr path="/api/namespace/object[@cname='GtkMenuItem']/signal[@name='ToggleSizeAllocate']" name="name">ToggleSizeAllocated</attr>
<attr path="/api/namespace/object[@cname='GtkMenuItem']/signal[@name='ToggleSizeRequest']" name="name">ToggleSizeRequested</attr> <attr path="/api/namespace/object[@cname='GtkMenuItem']/signal[@name='ToggleSizeRequest']" name="name">ToggleSizeRequested</attr>
<attr path="/api/namespace/object[@cname='GtkMenu']/method[@name='Popup']/*/*[@type='GtkMenuPositionFunc']" name="null_ok">1</attr>
<attr path="/api/namespace/object[@cname='GtkMenu']/method[@name='SetScreen']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='GtkMenu']/method[@name='SetScreen']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GtkMenuShell']/signal[@name='Cancel']" name="name">Canceled</attr> <attr path="/api/namespace/object[@cname='GtkMenuShell']/signal[@name='Cancel']" name="name">Canceled</attr>
<attr path="/api/namespace/object[@cname='GtkMenuShell']/signal[@name='Deactivate']" name="name">Deactivated</attr> <attr path="/api/namespace/object[@cname='GtkMenuShell']/signal[@name='Deactivate']" name="name">Deactivated</attr>

View file

@ -1,5 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<metadata> <metadata>
<attr path="/api/namespace/boxed[@cname='PangoAttrList']/method[@name='Filter']/*/*[@name='func']" name="scope">call</attr>
<attr path="/api/namespace/boxed[@cname='PangoTabArray']/constructor[@cname='pango_tab_array_new_with_positions']" name="hidden">1</attr> <attr path="/api/namespace/boxed[@cname='PangoTabArray']/constructor[@cname='pango_tab_array_new_with_positions']" name="hidden">1</attr>
<attr path="/api/namespace/boxed[@cname='PangoTabArray']/method[@name='GetTabs']" name="hidden">1</attr> <attr path="/api/namespace/boxed[@cname='PangoTabArray']/method[@name='GetTabs']" name="hidden">1</attr>
<attr path="/api/namespace/callback[@cname='PangoFT2SubstituteFunc']" name="hidden">1</attr> <attr path="/api/namespace/callback[@cname='PangoFT2SubstituteFunc']" name="hidden">1</attr>
@ -15,6 +16,7 @@
<attr path="/api/namespace/object[@cname='PangoFont']/method[@name='DescriptionsFree']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='PangoFont']/method[@name='DescriptionsFree']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='PangoFontFamily']/method[@name='ListFaces']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='PangoFontFamily']/method[@name='ListFaces']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='PangoFontMap']/method[@name='ListFamilies']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='PangoFontMap']/method[@name='ListFamilies']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='PangoFontset']/method[@name='Foreach']/*/*[@name='func']" name="scope">call</attr>
<attr path="/api/namespace/object[@cname='PangoFT2FontMap']" name="hidden">1</attr> <attr path="/api/namespace/object[@cname='PangoFT2FontMap']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetCursorPos']/*/*[@type='PangoRectangle*']" name="pass_as">out</attr> <attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetCursorPos']/*/*[@type='PangoRectangle*']" name="pass_as">out</attr>
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetExtents']/*/*[@type='PangoRectangle*']" name="pass_as">out</attr> <attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetExtents']/*/*[@type='PangoRectangle*']" name="pass_as">out</attr>
@ -33,9 +35,7 @@
<attr path="/api/namespace/struct[@cname='PangoGlyphItem']/method[@name='ApplyAttrs']" name="hidden">1</attr> <attr path="/api/namespace/struct[@cname='PangoGlyphItem']/method[@name='ApplyAttrs']" name="hidden">1</attr>
<attr path="/api/namespace/struct[@cname='PangoLayoutLine']" name="opaque">1</attr> <attr path="/api/namespace/struct[@cname='PangoLayoutLine']" name="opaque">1</attr>
<attr path="/api/namespace/struct[@cname='PangoLayoutLine']/method[@name='GetExtents']/*/*[@type='PangoRectangle*']" name="pass_as">ref</attr> <attr path="/api/namespace/struct[@cname='PangoLayoutLine']/method[@name='GetExtents']/*/*[@type='PangoRectangle*']" name="pass_as">ref</attr>
<attr path="/api/namespace/struct[@cname='PangoLayoutLine']/method[@name='GetExtents']/*/*[@type='PangoRectangle*']" name="null_ok">1</attr>
<attr path="/api/namespace/struct[@cname='PangoLayoutLine']/method[@name='GetPixelExtents']/*/*[@type='PangoRectangle*']" name="pass_as">ref</attr> <attr path="/api/namespace/struct[@cname='PangoLayoutLine']/method[@name='GetPixelExtents']/*/*[@type='PangoRectangle*']" name="pass_as">ref</attr>
<attr path="/api/namespace/struct[@cname='PangoLayoutLine']/method[@name='GetPixelExtents']/*/*[@type='PangoRectangle*']" name="null_ok">1</attr>
<attr path="/api/namespace/struct[@cname='PangoLayoutLine']/method[@name='GetXRanges']" name="hidden">1</attr> <attr path="/api/namespace/struct[@cname='PangoLayoutLine']/method[@name='GetXRanges']" name="hidden">1</attr>
<attr path="/api/namespace/struct[@cname='PangoWin32FontCache']" name="hidden">1</attr> <attr path="/api/namespace/struct[@cname='PangoWin32FontCache']" name="hidden">1</attr>
</metadata> </metadata>