2002-03-25 Mike Kestner <mkestner@speakeasy.net>

* generator/StructBase.cs : Throttle _gtk methods.
	* generator/SymbolTable.cs : tweak dll names.
	* glib/Object.cs : restructure DllImports and prop code.
	* glib/SList.cs : restructure DllImports.
	* glib/Value.cs : restructure DllImports.
	* gtk/Application.cs : overload Init() to get past the string[]
	  marshaling crash on linux.
	* sample/HelloWorld.cs : Use App::Init() since no args are needed.

svn path=/trunk/gtk-sharp/; revision=3341
This commit is contained in:
Mike Kestner 2002-03-26 01:29:43 +00:00
parent 12acb7ff05
commit f3a997ca6f
8 changed files with 96 additions and 121 deletions

View File

@ -1,3 +1,14 @@
2002-03-25 Mike Kestner <mkestner@speakeasy.net>
* generator/StructBase.cs : Throttle _gtk methods.
* generator/SymbolTable.cs : tweak dll names.
* glib/Object.cs : restructure DllImports and prop code.
* glib/SList.cs : restructure DllImports.
* glib/Value.cs : restructure DllImports.
* gtk/Application.cs : overload Init() to get past the string[]
marshaling crash on linux.
* sample/HelloWorld.cs : Use App::Init() since no args are needed.
2002-03-24 Mike Kestner <mkestner@speakeasy.net> 2002-03-24 Mike Kestner <mkestner@speakeasy.net>
* generator/*Gen.cs : Use Path.DirectorySeparatorChar. * generator/*Gen.cs : Use Path.DirectorySeparatorChar.

View File

@ -173,6 +173,11 @@ namespace GtkSharp.Generation {
String cname = method.GetAttribute("cname"); String cname = method.GetAttribute("cname");
String name = method.GetAttribute("name"); String name = method.GetAttribute("name");
if (cname[0] == '_') {
Statistics.ThrottledCount++;
return true;
}
sw.WriteLine("\t\t[DllImport(\"" + table.GetDllName(ns) + sw.WriteLine("\t\t[DllImport(\"" + table.GetDllName(ns) +
"\", CallingConvention=CallingConvention.Cdecl)]"); "\", CallingConvention=CallingConvention.Cdecl)]");
sw.Write("\t\tstatic extern " + m_ret + " " + cname + isig); sw.Write("\t\tstatic extern " + m_ret + " " + cname + isig);

View File

@ -66,10 +66,10 @@ namespace GtkSharp.Generation {
simple_types.Add ("GParamSpec", "IntPtr"); simple_types.Add ("GParamSpec", "IntPtr");
dlls = new Hashtable(); dlls = new Hashtable();
dlls.Add("Pango", "pango.dll"); dlls.Add("Pango", "pango");
dlls.Add("Atk", "atk.dll"); dlls.Add("Atk", "atk");
dlls.Add("Gdk", "gdk-x11-1.3.dll"); dlls.Add("Gdk", "gdk-x11-1.3");
dlls.Add("Gtk", "gtk-x11-1.3.dll"); dlls.Add("Gtk", "gtk-x11-1.3");
} }
public void AddType (IGeneratable gen) public void AddType (IGeneratable gen)

View File

@ -197,18 +197,13 @@ namespace GLib {
/// Accesses a string Property. /// Accesses a string Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, [DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
CallingConvention=CallingConvention.Cdecl)] static extern void g_object_get (IntPtr obj, string name,
static extern void g_object_get (IntPtr obj, IntPtr name, out string val, IntPtr term);
out IntPtr val, IntPtr term);
public void GetProperty (String name, out String val) public void GetProperty (String name, out String val)
{ {
IntPtr propval; g_object_get (Raw, name, out val, new IntPtr (0));
g_object_get (Raw,
Marshal.StringToHGlobalAnsi (name),
out propval, new IntPtr (0));
val = Marshal.PtrToStringAnsi (propval);
} }
/// <summary> /// <summary>
@ -219,16 +214,13 @@ namespace GLib {
/// Accesses a boolean Property. /// Accesses a boolean Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, [DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
CallingConvention=CallingConvention.Cdecl)] static extern void g_object_get (IntPtr obj, string name,
static extern void g_object_get (IntPtr obj, IntPtr name,
out bool val, IntPtr term); out bool val, IntPtr term);
public void GetProperty (String name, out bool val) public void GetProperty (String name, out bool val)
{ {
g_object_get (Raw, g_object_get (Raw, name, out val, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
out val, new IntPtr (0));
} }
/// <summary> /// <summary>
@ -239,16 +231,13 @@ namespace GLib {
/// Accesses a double Property. /// Accesses a double Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, [DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
CallingConvention=CallingConvention.Cdecl)] static extern void g_object_get (IntPtr obj, string name,
static extern void g_object_get (IntPtr obj, IntPtr name,
out double val, IntPtr term); out double val, IntPtr term);
public void GetProperty (String name, out double val) public void GetProperty (String name, out double val)
{ {
g_object_get (Raw, g_object_get (Raw, name, out val, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
out val, new IntPtr (0));
} }
/// <summary> /// <summary>
@ -259,16 +248,13 @@ namespace GLib {
/// Accesses a float Property. /// Accesses a float Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, [DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
CallingConvention=CallingConvention.Cdecl)] static extern void g_object_get (IntPtr obj, string name,
static extern void g_object_get (IntPtr obj, IntPtr name,
out float val, IntPtr term); out float val, IntPtr term);
public void GetProperty (String name, out float val) public void GetProperty (String name, out float val)
{ {
g_object_get (Raw, g_object_get (Raw, name, out val, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
out val, new IntPtr (0));
} }
/// <summary> /// <summary>
@ -279,16 +265,13 @@ namespace GLib {
/// Accesses an integer Property. /// Accesses an integer Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, [DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
CallingConvention=CallingConvention.Cdecl)] static extern void g_object_get (IntPtr obj, string name,
static extern void g_object_get (IntPtr obj, IntPtr name,
out int val, IntPtr term); out int val, IntPtr term);
public void GetProperty (String name, out int val) public void GetProperty (String name, out int val)
{ {
g_object_get (Raw, g_object_get (Raw, name, out val, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
out val, new IntPtr (0));
} }
/// <summary> /// <summary>
@ -299,16 +282,13 @@ namespace GLib {
/// Accesses an unsigned integer Property. /// Accesses an unsigned integer Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, [DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
CallingConvention=CallingConvention.Cdecl)] static extern void g_object_get (IntPtr obj, string name,
static extern void g_object_get (IntPtr obj, IntPtr name,
out uint val, IntPtr term); out uint val, IntPtr term);
public void GetProperty (String name, out uint val) public void GetProperty (String name, out uint val)
{ {
g_object_get (Raw, g_object_get (Raw, name, out val, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
out val, new IntPtr (0));
} }
/// <summary> /// <summary>
@ -319,12 +299,14 @@ namespace GLib {
/// Accesses an Object Property. /// Accesses an Object Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
static extern void g_object_get (IntPtr obj, string name,
out IntPtr val, IntPtr term);
public void GetProperty (String name, out GLib.Object val) public void GetProperty (String name, out GLib.Object val)
{ {
IntPtr obj; IntPtr obj;
g_object_get (Raw, g_object_get (Raw, name, out obj, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
out obj, new IntPtr (0));
val = GLib.Object.GetObject (obj); val = GLib.Object.GetObject (obj);
} }
@ -339,15 +321,10 @@ namespace GLib {
public void GetProperty (String name, out GtkSharp.Boxed val) public void GetProperty (String name, out GtkSharp.Boxed val)
{ {
IntPtr raw; IntPtr raw;
g_object_get (Raw, g_object_get (Raw, name, out raw, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
out raw, new IntPtr (0));
val = GtkSharp.Boxed.GetBoxed (raw); val = GtkSharp.Boxed.GetBoxed (raw);
} }
/// <summary>
/// GetProperty Method
/// </summary>
/// <summary> /// <summary>
/// GetProperty Method /// GetProperty Method
/// </summary> /// </summary>
@ -358,14 +335,9 @@ namespace GLib {
public void GetProperty (String name, out IntPtr val) public void GetProperty (String name, out IntPtr val)
{ {
g_object_get (Raw, g_object_get (Raw, name, out val, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
out val, new IntPtr (0));
} }
/// <summary>
/// SetProperty Method
/// </summary>
/// <summary> /// <summary>
/// SetProperty Method /// SetProperty Method
/// </summary> /// </summary>
@ -374,17 +346,13 @@ namespace GLib {
/// Changes the value of a string Property. /// Changes the value of a string Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, [DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
CallingConvention=CallingConvention.Cdecl)] static extern void g_object_set (IntPtr obj, string name,
static extern void g_object_set (IntPtr obj, IntPtr name, string val, IntPtr term);
IntPtr val, IntPtr term);
public void SetProperty (String name, String val) public void SetProperty (String name, String val)
{ {
g_object_set (Raw, g_object_set (Raw, name, val, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
Marshal.StringToHGlobalAnsi (val),
new IntPtr (0));
} }
/// <summary> /// <summary>
@ -395,16 +363,13 @@ namespace GLib {
/// Changes the value of an integer Property. /// Changes the value of an integer Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, [DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
CallingConvention=CallingConvention.Cdecl)] static extern void g_object_set (IntPtr obj, string name,
static extern void g_object_set (IntPtr obj, IntPtr name,
int val, IntPtr term); int val, IntPtr term);
public void SetProperty (String name, int val) public void SetProperty (String name, int val)
{ {
g_object_set (Raw, g_object_set (Raw, name, val, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
val, new IntPtr (0));
} }
/// <summary> /// <summary>
@ -415,16 +380,13 @@ namespace GLib {
/// Changes the value of an unsigned integer Property. /// Changes the value of an unsigned integer Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, [DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
CallingConvention=CallingConvention.Cdecl)] static extern void g_object_set (IntPtr obj, string name,
static extern void g_object_set (IntPtr obj, IntPtr name,
uint val, IntPtr term); uint val, IntPtr term);
public void SetProperty (String name, uint val) public void SetProperty (String name, uint val)
{ {
g_object_set (Raw, g_object_set (Raw, name, val, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
val, new IntPtr (0));
} }
/// <summary> /// <summary>
@ -435,16 +397,13 @@ namespace GLib {
/// Changes the value of a boolean Property. /// Changes the value of a boolean Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, [DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
CallingConvention=CallingConvention.Cdecl)] static extern void g_object_set (IntPtr obj, string name,
static extern void g_object_set (IntPtr obj, IntPtr name,
bool val, IntPtr term); bool val, IntPtr term);
public void SetProperty (String name, bool val) public void SetProperty (String name, bool val)
{ {
g_object_set (Raw, g_object_set (Raw, name, val, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
val, new IntPtr (0));
} }
/// <summary> /// <summary>
@ -455,16 +414,13 @@ namespace GLib {
/// Changes the value of a double Property. /// Changes the value of a double Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, [DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
CallingConvention=CallingConvention.Cdecl)] static extern void g_object_set (IntPtr obj, string name,
static extern void g_object_set (IntPtr obj, IntPtr name,
double val, IntPtr term); double val, IntPtr term);
public void SetProperty (String name, double val) public void SetProperty (String name, double val)
{ {
g_object_set (Raw, g_object_set (Raw, name, val, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
val, new IntPtr (0));
} }
/// <summary> /// <summary>
@ -475,16 +431,13 @@ namespace GLib {
/// Changes the value of a float Property. /// Changes the value of a float Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", CharSet=CharSet.Ansi, [DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
CallingConvention=CallingConvention.Cdecl)] static extern void g_object_set (IntPtr obj, string name,
static extern void g_object_set (IntPtr obj, IntPtr name,
float val, IntPtr term); float val, IntPtr term);
public void SetProperty (String name, float val) public void SetProperty (String name, float val)
{ {
g_object_set (Raw, g_object_set (Raw, name, val, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
val, new IntPtr (0));
} }
/// <summary> /// <summary>
@ -495,11 +448,13 @@ namespace GLib {
/// Changes the value of an IntPtr Property. /// Changes the value of an IntPtr Property.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3", CallingConvention=CallingConvention.Cdecl)]
static extern void g_object_set (IntPtr obj, string name,
IntPtr val, IntPtr term);
public void SetProperty (String name, IntPtr val) public void SetProperty (String name, IntPtr val)
{ {
g_object_set (Raw, g_object_set (Raw, name, val, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
val, new IntPtr (0));
} }
/// <summary> /// <summary>
@ -512,9 +467,7 @@ namespace GLib {
public void SetProperty (String name, GLib.Object val) public void SetProperty (String name, GLib.Object val)
{ {
g_object_set (Raw, g_object_set (Raw, name, val.Handle, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
val.Handle, new IntPtr (0));
} }
/// <summary> /// <summary>
@ -527,14 +480,12 @@ namespace GLib {
public void SetProperty (String name, GtkSharp.Boxed val) public void SetProperty (String name, GtkSharp.Boxed val)
{ {
g_object_set (Raw, g_object_set (Raw, name, val.Handle, new IntPtr (0));
Marshal.StringToHGlobalAnsi (name),
val.Handle, new IntPtr (0));
} }
/* /*
[DllImport("gtk-1.3.dll")] [DllImport("gtk-1.3")]
static extern void g_object_set_data_full ( static extern void g_object_set_data_full (
IntPtr obj, IntPtr obj,
String key, String key,

View File

@ -65,7 +65,7 @@ namespace GLib {
/// The number of elements in the SList. /// The number of elements in the SList.
/// </remarks> /// </remarks>
[DllImport("glib-1.3.dll", CallingConvention=CallingConvention.Cdecl)] [DllImport("glib-1.3", CallingConvention=CallingConvention.Cdecl)]
static extern int g_slist_length(IntPtr raw); static extern int g_slist_length(IntPtr raw);
public int Count { public int Count {
@ -168,7 +168,7 @@ namespace GLib {
/// Indexer to access members of the SList. /// Indexer to access members of the SList.
/// </remarks> /// </remarks>
[DllImport("glib-1.3.dll", CallingConvention=CallingConvention.Cdecl)] [DllImport("glib-1.3", CallingConvention=CallingConvention.Cdecl)]
static extern IntPtr g_slist_nth_data(IntPtr raw, int index); static extern IntPtr g_slist_nth_data(IntPtr raw, int index);
public object this[int index] { public object this[int index] {

View File

@ -26,7 +26,7 @@ namespace GLib {
// Destructor is required since we are allocating unmananged // Destructor is required since we are allocating unmananged
// heap resources. // heap resources.
[DllImport("glib-1.3.dll")] [DllImport("glib-1.3")]
static extern void g_free (IntPtr mem); static extern void g_free (IntPtr mem);
~Value () ~Value ()
@ -44,7 +44,7 @@ namespace GLib {
/// value to it. /// value to it.
/// </remarks> /// </remarks>
[DllImport("glib-1.3.dll", [DllImport("glib-1.3",
CallingConvention=CallingConvention.Cdecl)] CallingConvention=CallingConvention.Cdecl)]
static extern IntPtr g_malloc0 (long n_bytes); static extern IntPtr g_malloc0 (long n_bytes);
@ -74,7 +74,7 @@ namespace GLib {
/// Constructs a Value from a specified boolean. /// Constructs a Value from a specified boolean.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", [DllImport("gobject-1.3",
CallingConvention=CallingConvention.Cdecl)] CallingConvention=CallingConvention.Cdecl)]
static extern void g_value_set_boolean (IntPtr val, static extern void g_value_set_boolean (IntPtr val,
bool data); bool data);
@ -92,7 +92,7 @@ namespace GLib {
/// Constructs a Value from a specified integer. /// Constructs a Value from a specified integer.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", [DllImport("gobject-1.3",
CallingConvention=CallingConvention.Cdecl)] CallingConvention=CallingConvention.Cdecl)]
static extern void g_value_set_int (IntPtr val, int data); static extern void g_value_set_int (IntPtr val, int data);
@ -110,7 +110,7 @@ namespace GLib {
/// Constructs a Value from a specified string. /// Constructs a Value from a specified string.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", [DllImport("gobject-1.3",
CallingConvention=CallingConvention.Cdecl)] CallingConvention=CallingConvention.Cdecl)]
static extern void g_value_set_string (IntPtr val, static extern void g_value_set_string (IntPtr val,
IntPtr data); IntPtr data);
@ -129,7 +129,7 @@ namespace GLib {
/// Prepares a raw value to hold a specified type. /// Prepares a raw value to hold a specified type.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", [DllImport("gobject-1.3",
CallingConvention=CallingConvention.Cdecl)] CallingConvention=CallingConvention.Cdecl)]
static extern void g_value_init (IntPtr val, static extern void g_value_init (IntPtr val,
TypeFundamentals type); TypeFundamentals type);
@ -149,7 +149,7 @@ namespace GLib {
/// boolean value. /// boolean value.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", [DllImport("gobject-1.3",
CallingConvention=CallingConvention.Cdecl)] CallingConvention=CallingConvention.Cdecl)]
static extern bool g_value_get_boolean (IntPtr val); static extern bool g_value_get_boolean (IntPtr val);
@ -170,7 +170,7 @@ namespace GLib {
/// integer value. /// integer value.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", [DllImport("gobject-1.3",
CallingConvention=CallingConvention.Cdecl)] CallingConvention=CallingConvention.Cdecl)]
static extern int g_value_get_int (IntPtr val); static extern int g_value_get_int (IntPtr val);
@ -191,7 +191,7 @@ namespace GLib {
/// string value. /// string value.
/// </remarks> /// </remarks>
[DllImport("gobject-1.3.dll", [DllImport("gobject-1.3",
CallingConvention=CallingConvention.Cdecl)] CallingConvention=CallingConvention.Cdecl)]
static extern IntPtr g_value_get_string (IntPtr val); static extern IntPtr g_value_get_string (IntPtr val);

View File

@ -23,7 +23,15 @@ namespace Gtk {
public class Application { public class Application {
[DllImport("gtk-1.3.dll")] [DllImport("gtk-x11-1.3")]
static extern void gtk_init (int argc, IntPtr argv);
public static void Init ()
{
gtk_init (0, new IntPtr(0));
}
[DllImport("gtk-x11-1.3")]
static extern void gtk_init (ref int argc, ref String[] argv); static extern void gtk_init (ref int argc, ref String[] argv);
/// <summary> /// <summary>
@ -48,7 +56,7 @@ namespace Gtk {
/// Begins the event loop iteration. /// Begins the event loop iteration.
/// </remarks> /// </remarks>
[DllImport("gtk-1.3.dll")] [DllImport("gtk-x11-1.3")]
static extern void gtk_main (); static extern void gtk_main ();
public static void Run () public static void Run ()
@ -65,7 +73,7 @@ namespace Gtk {
/// Terminates the event loop iteration. /// Terminates the event loop iteration.
/// </remarks> /// </remarks>
[DllImport("gtk-1.3.dll")] [DllImport("gtk-x11-1.3")]
static extern void gtk_main_quit (); static extern void gtk_main_quit ();
public static void Quit () public static void Quit ()

View File

@ -16,7 +16,7 @@ namespace GtkSamples {
public static int Main (string[] args) public static int Main (string[] args)
{ {
Application.Init (ref args); Application.Init ();
Gtk.Window win = new Gtk.Window (Gtk.WindowType.Toplevel); Gtk.Window win = new Gtk.Window (Gtk.WindowType.Toplevel);
win.Title = "Gtk# Hello World"; win.Title = "Gtk# Hello World";
win.DeleteEvent += new EventHandler (Window_Delete); win.DeleteEvent += new EventHandler (Window_Delete);