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>
* generator/*Gen.cs : Use Path.DirectorySeparatorChar.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,7 +23,15 @@ namespace Gtk {
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);
/// <summary>
@ -48,7 +56,7 @@ namespace Gtk {
/// Begins the event loop iteration.
/// </remarks>
[DllImport("gtk-1.3.dll")]
[DllImport("gtk-x11-1.3")]
static extern void gtk_main ();
public static void Run ()
@ -65,7 +73,7 @@ namespace Gtk {
/// Terminates the event loop iteration.
/// </remarks>
[DllImport("gtk-1.3.dll")]
[DllImport("gtk-x11-1.3")]
static extern void gtk_main_quit ();
public static void Quit ()

View File

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