2002-05-02 Mike Kestner <mkestner@speakeasy.net>

* README : Describe the new make procedure.
	* configure.in : Add the new Makefile generation.
	* makefile : add the glue dir, make linux the default build,
	  add an install target
	* */makefile.win32 : temp build files for win32
	* */Makefile.in : new configurable make system
	* */makefile : killed
	* generator/BoxedGen.cs : Now uses GLib.Boxed
	* generator/ObjectGen.cs : Use Values for Props.
	* generator/SymbolTable.cs : Add IsEnum method.
	* glib/Boxed.cs : Major overhaul.
	* glib/Object.cs : Remove type specific (Get|Set)Property. Now
	  use GValue based property accessors.
	* glib/TypeFundamentals.cs : Update to current values.
	* glib/Value.cs : Refactor to use glue.

svn path=/trunk/gtk-sharp/; revision=4236
This commit is contained in:
Mike Kestner 2002-05-02 21:57:41 +00:00
parent fa98aa165a
commit cd73a17587
33 changed files with 513 additions and 524 deletions

View file

@ -1,3 +1,21 @@
2002-05-02 Mike Kestner <mkestner@speakeasy.net>
* README : Describe the new make procedure.
* configure.in : Add the new Makefile generation.
* makefile : add the glue dir, make linux the default build,
add an install target
* */makefile.win32 : temp build files for win32
* */Makefile.in : new configurable make system
* */makefile : killed
* generator/BoxedGen.cs : Now uses GLib.Boxed
* generator/ObjectGen.cs : Use Values for Props.
* generator/SymbolTable.cs : Add IsEnum method.
* glib/Boxed.cs : Major overhaul.
* glib/Object.cs : Remove type specific (Get|Set)Property. Now
use GValue based property accessors.
* glib/TypeFundamentals.cs : Update to current values.
* glib/Value.cs : Refactor to use glue.
2002-04-25 Mike Kestner <mkestner@speakeasy.net> 2002-04-25 Mike Kestner <mkestner@speakeasy.net>
* autogen.sh : simple config for the glue build * autogen.sh : simple config for the glue build

18
README
View file

@ -10,14 +10,24 @@ there and adjust accordingly.
Building Gtk#: Building Gtk#:
-------------- --------------
Currently, it is only possible to compile Gtk# on Win32 using the .Net Currently, it is only possible to compile Gtk# on Win32 using the .Net
framework compiler and libraries. Miguel and company will be changing that framework compiler and libraries. The build system is in a transitional
shortly. The win32 compilation utilizes the cygwin environment for a GNU state at the moment. Windows compilation utilizes the cygwin environment
build environment. To compile the package type: for a GNU build environment. To compile the package type:
make windows make -f makefile.win32
in the top level directory. in the top level directory.
The linux build fails due to unresolved issues in mcs. If you would like
to help work these issues, the build procedure on linux is the typical:
configure
make
make install
If you are compiling from CVS, you will need libtool and the auto* tools
and will need to replace the configure above with autogen.sh.
Discussion: Discussion:
----------- -----------
A mailing list for Gtk# discussion (gtk-sharp-list@ximian.com) is available. A mailing list for Gtk# discussion (gtk-sharp-list@ximian.com) is available.

View file

@ -1,4 +1,5 @@
*.dll *.dll
*.exe *.exe
generated generated
Makefile

View file

@ -1,15 +1,19 @@
MCS=mcs MCS=mcs
all: all: linux
@echo "You must use 'make windows' or 'make unix'."
@echo "'make unix' is broken for now."
windows: windows:
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /out:atk-sharp.dll /recurse:*.cs $(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /out:atk-sharp.dll /recurse:*.cs
linux: linux: atk-sharp.dll
atk-sharp.dll: generated/*.cs
$(MCS) --unsafe --target library -r ../glib/glib-sharp.dll -r ../pango/pango-sharp.dll -o atk-sharp.dll --recurse *.cs $(MCS) --unsafe --target library -r ../glib/glib-sharp.dll -r ../pango/pango-sharp.dll -o atk-sharp.dll --recurse *.cs
unix: unix:
@echo "'make unix' is broken for now." @echo "'make unix' is broken for now."
$(CSC) --unsafe --target=library --r=../glib/glib-sharp.dll --r=../pango/pango-sharp.dll --out=atk-sharp.dll --recurse=*.cs $(CSC) --unsafe --target=library --r=../glib/glib-sharp.dll --r=../pango/pango-sharp.dll --out=atk-sharp.dll --recurse=*.cs
install: all
cp atk-sharp.dll @prefix@/lib

5
atk/makefile.win32 Normal file
View file

@ -0,0 +1,5 @@
all: windows
windows:
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /out:atk-sharp.dll /recurse:*.cs

View file

@ -76,6 +76,12 @@ AC_SUBST(CFLAGS)
AC_OUTPUT([ AC_OUTPUT([
glue/Makefile glue/Makefile
glib/Makefile
pango/Makefile
atk/Makefile
gdk/Makefile
gtk/Makefile
sample/Makefile
]) ])
echo " echo "

View file

@ -1,4 +1,5 @@
*.dll *.dll
*.exe *.exe
generated generated
Makefile

View file

@ -1,14 +1,18 @@
MCS=mcs MCS=mcs
all: all: linux
@echo "You must use 'make windows' or 'make unix'."
@echo "'make unix' is broken for now."
windows: windows:
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /out:gdk-sharp.dll /recurse:*.cs $(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /out:gdk-sharp.dll /recurse:*.cs
linux: linux: gdk-sharp.dll
gdk-sharp.dll: generated/*.cs
$(MCS) --unsafe --target library -r ../glib/glib-sharp.dll -r ../pango/pango-sharp.dll -r ../atk/atk-sharp.dll -o gdk-sharp.dll --recurse *.cs $(MCS) --unsafe --target library -r ../glib/glib-sharp.dll -r ../pango/pango-sharp.dll -r ../atk/atk-sharp.dll -o gdk-sharp.dll --recurse *.cs
unix: unix:
@echo "'make unix' is broken for now." @echo "'make unix' is broken for now."
install: all
cp gdk-sharp.dll @prefix@/lib

5
gdk/makefile.win32 Normal file
View file

@ -0,0 +1,5 @@
all: windows
windows:
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /out:gdk-sharp.dll /recurse:*.cs

View file

@ -1,3 +1,5 @@
*.dll *.dll
*.exe *.exe
generated-stamp
Makefile

View file

@ -29,7 +29,7 @@ namespace GtkSharp.Generation {
public String FromNative(String var) public String FromNative(String var)
{ {
return "(" + QualifiedName + ") GtkSharp.Boxed.GetBoxed(" + var + ")"; return "(" + QualifiedName + ") GLib.Boxed.FromNative(" + var + ")";
} }
public void Generate (SymbolTable table) public void Generate (SymbolTable table)
@ -57,7 +57,7 @@ namespace GtkSharp.Generation {
sw.WriteLine (); sw.WriteLine ();
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]"); sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
sw.WriteLine ("\tpublic class " + Name + " : GtkSharp.Boxed {"); sw.WriteLine ("\tpublic class " + Name + " : GLib.Boxed {");
sw.WriteLine (); sw.WriteLine ();
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}"); sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");

View file

@ -160,8 +160,7 @@ namespace GtkSharp.Generation {
char[] ast = {'*'}; char[] ast = {'*'};
c_type = c_type.TrimEnd(ast); c_type = c_type.TrimEnd(ast);
String cs_type = table.GetCSType(c_type); string cs_type = table.GetCSType(c_type);
String m_type;
XmlElement parent = (XmlElement) prop.ParentNode; XmlElement parent = (XmlElement) prop.ParentNode;
name = prop.GetAttribute("name"); name = prop.GetAttribute("name");
@ -169,20 +168,17 @@ namespace GtkSharp.Generation {
name += "Prop"; name += "Prop";
} }
if (table.IsObject(c_type)) { string v_type = "";
m_type = "GLib.Object"; if (table.IsEnum(c_type)) {
} else if (table.IsBoxed(c_type)) { v_type = "int";
m_type = "GtkSharp.Boxed";
} else if (table.IsInterface(c_type)) { } else if (table.IsInterface(c_type)) {
// FIXME: Handle interface props properly. // FIXME: Handle interface props properly.
Console.Write("Interface property detected "); Console.Write("Interface property detected ");
Statistics.ThrottledCount++; Statistics.ThrottledCount++;
return true; return true;
} else {
m_type = table.GetMarshalType(c_type);
} }
if ((cs_type == "") || (m_type == "")) { if (cs_type == "") {
Console.Write("Property has unknown Type {0} ", c_type); Console.Write("Property has unknown Type {0} ", c_type);
Statistics.ThrottledCount++; Statistics.ThrottledCount++;
return false; return false;
@ -195,11 +191,11 @@ namespace GtkSharp.Generation {
sw.WriteLine("\t\tpublic " + cs_type + " " + name + " {"); sw.WriteLine("\t\tpublic " + cs_type + " " + name + " {");
if (prop.HasAttribute("readable")) { if (prop.HasAttribute("readable")) {
sw.WriteLine("\t\t\tget {"); sw.WriteLine("\t\t\tget {");
sw.WriteLine("\t\t\t\t" + m_type + " val;"); sw.WriteLine("\t\t\t\tGLib.Value val;");
sw.WriteLine("\t\t\t\tGetProperty(\"" + prop.GetAttribute("cname") + "\", out val);"); sw.WriteLine("\t\t\t\tGetProperty(\"" + prop.GetAttribute("cname") + "\", out val);");
sw.Write("\t\t\t\treturn "); sw.Write("\t\t\t\treturn (" + cs_type + ") ");
if (cs_type != m_type) { if (v_type != "") {
sw.Write("(" + cs_type + ") "); sw.Write("(" + v_type + ") ");
} }
sw.WriteLine("val;"); sw.WriteLine("val;");
sw.WriteLine("\t\t\t}"); sw.WriteLine("\t\t\t}");
@ -207,7 +203,11 @@ namespace GtkSharp.Generation {
if (prop.HasAttribute("writeable") && !prop.HasAttribute("construct-only")) { if (prop.HasAttribute("writeable") && !prop.HasAttribute("construct-only")) {
sw.WriteLine("\t\t\tset {"); sw.WriteLine("\t\t\tset {");
sw.WriteLine("\t\t\t\tSetProperty(\"" + prop.GetAttribute("cname") + "\", (" + m_type + ") value);"); sw.Write("\t\t\t\tSetProperty(\"" + prop.GetAttribute("cname") + "\", new GLib.Value(");
if (v_type != "") {
sw.Write("(" + v_type + ") ");
}
sw.WriteLine("value));");
sw.WriteLine("\t\t\t}"); sw.WriteLine("\t\t\t}");
} }

View file

@ -185,6 +185,18 @@ namespace GtkSharp.Generation {
return false; return false;
} }
public bool IsEnum(string c_type)
{
c_type = Trim(c_type);
if (complex_types.ContainsKey(c_type)) {
IGeneratable gen = (IGeneratable) complex_types[c_type];
if (gen is EnumGen) {
return true;
}
}
return false;
}
public bool IsInterface(string c_type) public bool IsInterface(string c_type)
{ {
c_type = Trim(c_type); c_type = Trim(c_type);

View file

@ -1,16 +1,34 @@
MCS=mcs MCS=mcs
SOURCES=BoxedGen.cs \
CallbackGen.cs \
CodeGenerator.cs \
EnumGen.cs \
IGeneratable.cs \
InterfaceGen.cs \
ObjectGen.cs \
Parser.cs \
SignalHandler.cs \
Statistics.cs \
StructBase.cs \
StructGen.cs \
SymbolTable.cs
all: all: linux
@echo "You must use 'make windows' or 'make linux'."
@echo "'make unix' is broken for now."
windows: windows: *.cs
$(CSC) /unsafe /out:codegen.exe *.cs $(CSC) /unsafe /out:codegen.exe *.cs
./codegen gtkapi.xml ./codegen gtkapi.xml
linux: linux: generated-stamp
$(MCS) --unsafe -o codegen.exe -r System.Xml.dll *.cs
mono ./codegen.exe gtkapi.xml generated-stamp: codegen.exe gtkapi.xml
mono ./codegen.exe gtkapi.xml && touch generated-stamp
unix: unix:
@echo "'make unix' is broken for now." @echo "'make unix' is broken for now."
install: all
@echo "Nothing to install in generator."
codegen.exe: *.cs
$(MCS) --unsafe -o codegen.exe -r System.Xml.dll *.cs

6
generator/makefile.win32 Normal file
View file

@ -0,0 +1,6 @@
all: windows
windows: *.cs
$(CSC) /unsafe /out:codegen.exe *.cs
./codegen gtkapi.xml

View file

@ -1,4 +1,5 @@
*.dll *.dll
*.exe *.exe
generated generated
Makefile

View file

@ -4,10 +4,9 @@
// //
// (c) 2001-2002 Mike Kestner // (c) 2001-2002 Mike Kestner
namespace GtkSharp { namespace GLib {
using System; using System;
using System.Runtime.InteropServices;
/// <summary> /// <summary>
/// Boxed Class /// Boxed Class
@ -19,61 +18,21 @@ namespace GtkSharp {
public abstract class Boxed { public abstract class Boxed {
IntPtr _raw; private IntPtr raw;
// Destructor is required since we are allocating unmanaged public Boxed () : this (IntPtr.Zero) {}
// heap resources.
~Boxed ()
{
Marshal.FreeHGlobal (_raw);
}
/// <summary> /// <summary>
/// Boxed Constructor /// Boxed Constructor
/// </summary> /// </summary>
/// ///
/// <remarks> /// <remarks>
/// Dummy constructor needed for subclasses. /// Constructs a Boxed type from a raw ref.
/// </remarks> /// </remarks>
public Boxed() public Boxed (IntPtr raw)
{ {
} this.raw = raw;
/// <summary>
/// Boxed Constructor
/// </summary>
///
/// <remarks>
/// Wraps a raw boxed type reference.
/// </remarks>
public Boxed(IntPtr raw)
{
Raw = raw;
}
/// <summary>
/// Raw Property
/// </summary>
///
/// <remarks>
/// Gets a marshallable IntPtr.
/// </remarks>
protected IntPtr Raw {
get {
if (_raw == IntPtr.Zero) {
// FIXME: Ugly hack.
_raw = Marshal.AllocHGlobal (128);
Marshal.StructureToPtr (this, _raw, true);
}
return _raw;
}
set {
_raw = value;
}
} }
/// <summary> /// <summary>
@ -84,25 +43,41 @@ namespace GtkSharp {
/// Gets a marshallable IntPtr. /// Gets a marshallable IntPtr.
/// </remarks> /// </remarks>
public IntPtr Handle { public virtual IntPtr Handle {
get { get {
return _raw; return raw;
} }
} }
/// <summary> /// <summary>
/// GetBoxed Shared Method /// Raw Property
/// </summary> /// </summary>
/// ///
/// <remarks> /// <remarks>
/// Gets a managed class representing a raw ref. /// Gets or sets a marshallable IntPtr.
/// </remarks> /// </remarks>
public static Boxed GetBoxed (IntPtr raw) protected IntPtr Raw {
{ get {
// FIXME: Use the type manager to box the raw ref. return raw;
return null; }
set {
raw = value;
}
} }
/// <summary>
/// FromNative Method
/// </summary>
///
/// <remarks>
/// Gets a Boxed type from a raw IntPtr.
/// </remarks>
public static GLib.Boxed FromNative (IntPtr raw)
{
// FIXME:
return null;
}
} }
} }

View file

@ -1,14 +1,18 @@
MCS=mcs MCS=mcs
all: all: linux
@echo "You must use 'make windows' or 'make unix'."
@echo "'make unix' is broken for now."
windows: windows:
$(CSC) /unsafe /target:library /out:glib-sharp.dll /recurse:*.cs $(CSC) /unsafe /target:library /out:glib-sharp.dll /recurse:*.cs
linux: linux: glib-sharp.dll
glib-sharp.dll: *.cs generated/*.cs
$(MCS) --unsafe --target library -o glib-sharp.dll --recurse *.cs $(MCS) --unsafe --target library -o glib-sharp.dll --recurse *.cs
unix: unix:
@echo "'make unix' is broken for now." @echo "'make unix' is broken for now."
install: all
cp glib-sharp.dll @prefix@/lib || exit 1

View file

@ -194,148 +194,18 @@ namespace GLib {
/// </summary> /// </summary>
/// ///
/// <remarks> /// <remarks>
/// Accesses a string Property. /// Accesses a Value Property.
/// </remarks> /// </remarks>
[DllImport("gobject-2.0", CallingConvention=CallingConvention.Cdecl)] [DllImport("gobject-2.0")]
static extern void g_object_get (IntPtr obj, string name, static extern void g_object_get_property (
out string val, IntPtr term); IntPtr obj, string name, out IntPtr val);
public void GetProperty (String name, out String val) public void GetProperty (String name, out GLib.Value val)
{ {
g_object_get (Raw, name, out val, new IntPtr (0)); IntPtr v;
} g_object_get_property (Raw, name, out v);
val = new GLib.Value (v, v);
/// <summary>
/// GetProperty Method
/// </summary>
///
/// <remarks>
/// Accesses a boolean Property.
/// </remarks>
[DllImport("gobject-2.0", 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, name, out val, new IntPtr (0));
}
/// <summary>
/// GetProperty Method
/// </summary>
///
/// <remarks>
/// Accesses a double Property.
/// </remarks>
[DllImport("gobject-2.0", 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, name, out val, new IntPtr (0));
}
/// <summary>
/// GetProperty Method
/// </summary>
///
/// <remarks>
/// Accesses a float Property.
/// </remarks>
[DllImport("gobject-2.0", 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, name, out val, new IntPtr (0));
}
/// <summary>
/// GetProperty Method
/// </summary>
///
/// <remarks>
/// Accesses an integer Property.
/// </remarks>
[DllImport("gobject-2.0", 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, name, out val, new IntPtr (0));
}
/// <summary>
/// GetProperty Method
/// </summary>
///
/// <remarks>
/// Accesses an unsigned integer Property.
/// </remarks>
[DllImport("gobject-2.0", 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, name, out val, new IntPtr (0));
}
/// <summary>
/// GetProperty Method
/// </summary>
///
/// <remarks>
/// Accesses an Object Property.
/// </remarks>
[DllImport("gobject-2.0", 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, name, out obj, new IntPtr (0));
val = GLib.Object.GetObject (obj);
}
/// <summary>
/// GetProperty Method
/// </summary>
///
/// <remarks>
/// Accesses a Boxed Property.
/// </remarks>
public void GetProperty (String name, out GtkSharp.Boxed val)
{
IntPtr raw;
g_object_get (Raw, name, out raw, new IntPtr (0));
val = GtkSharp.Boxed.GetBoxed (raw);
}
/// <summary>
/// GetProperty Method
/// </summary>
///
/// <remarks>
/// Accesses an IntPtr Property.
/// </remarks>
public void GetProperty (String name, out IntPtr val)
{
g_object_get (Raw, name, out val, new IntPtr (0));
} }
/// <summary> /// <summary>
@ -343,209 +213,17 @@ namespace GLib {
/// </summary> /// </summary>
/// ///
/// <remarks> /// <remarks>
/// Changes the value of a string Property. /// Accesses a Value Property.
/// </remarks> /// </remarks>
[DllImport("gobject-2.0", CallingConvention=CallingConvention.Cdecl)] [DllImport("gobject-2.0")]
static extern void g_object_set (IntPtr obj, string name, static extern void g_object_set_property (
string val, IntPtr term); IntPtr obj, string name, IntPtr val);
public void SetProperty (String name, String val) public void SetProperty (String name, GLib.Value val)
{ {
g_object_set (Raw, name, val, new IntPtr (0)); g_object_set_property (Raw, name, val.Handle);
} }
/// <summary>
/// SetProperty Method
/// </summary>
///
/// <remarks>
/// Changes the value of an integer Property.
/// </remarks>
[DllImport("gobject-2.0", 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, name, val, new IntPtr (0));
}
/// <summary>
/// SetProperty Method
/// </summary>
///
/// <remarks>
/// Changes the value of an unsigned integer Property.
/// </remarks>
[DllImport("gobject-2.0", 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, name, val, new IntPtr (0));
}
/// <summary>
/// SetProperty Method
/// </summary>
///
/// <remarks>
/// Changes the value of a boolean Property.
/// </remarks>
[DllImport("gobject-2.0", 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, name, val, new IntPtr (0));
}
/// <summary>
/// SetProperty Method
/// </summary>
///
/// <remarks>
/// Changes the value of a double Property.
/// </remarks>
[DllImport("gobject-2.0", 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, name, val, new IntPtr (0));
}
/// <summary>
/// SetProperty Method
/// </summary>
///
/// <remarks>
/// Changes the value of a float Property.
/// </remarks>
[DllImport("gobject-2.0", 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, name, val, new IntPtr (0));
}
/// <summary>
/// SetProperty Method
/// </summary>
///
/// <remarks>
/// Changes the value of an IntPtr Property.
/// </remarks>
[DllImport("gobject-2.0", 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, name, val, new IntPtr (0));
}
/// <summary>
/// SetProperty Method
/// </summary>
///
/// <remarks>
/// Changes the value of an Object Property.
/// </remarks>
public void SetProperty (String name, GLib.Object val)
{
g_object_set (Raw, name, val.Handle, new IntPtr (0));
}
/// <summary>
/// SetProperty Method
/// </summary>
///
/// <remarks>
/// Changes the value of a Boxed Property.
/// </remarks>
public void SetProperty (String name, GtkSharp.Boxed val)
{
g_object_set (Raw, name, val.Handle, new IntPtr (0));
}
/*
[DllImport("gtk-2.0")]
static extern void g_object_set_data_full (
IntPtr obj,
String key,
IntPtr data,
DestroyNotify destroy );
GParamSpec* g_object_class_find_property (GObjectClass *oclass,
const gchar *property_name);
GParamSpec** g_object_class_list_properties (GObjectClass *oclass,
guint *n_properties);
gpointer g_object_ref (gpointer object);
void g_object_unref (gpointer object);
void g_object_weak_ref (GObject *object,
GWeakNotify notify,
gpointer data);
void g_object_weak_unref (GObject *object,
GWeakNotify notify,
gpointer data);
void g_object_add_weak_pointer (GObject *object,
gpointer *weak_pointer_location);
void g_object_remove_weak_pointer (GObject *object,
gpointer *weak_pointer_location);
gpointer g_object_connect (gpointer object,
const gchar *signal_spec,
...);
void g_object_disconnect (gpointer object,
const gchar *signal_spec,
...);
void g_object_set (gpointer object,
const gchar *first_property_name,
...);
void g_object_get (gpointer object,
const gchar *first_property_name,
...);
void g_object_notify (GObject *object,
const gchar *property_name);
void g_object_freeze_notify (GObject *object);
void g_object_thaw_notify (GObject *object);
void g_object_set_data_full (GObject *object,
const gchar *key,
gpointer data,
GDestroyNotify destroy);
gpointer g_object_steal_data (GObject *object,
const gchar *key);
gpointer g_object_get_qdata (GObject *object,
GQuark quark);
void g_object_set_qdata (GObject *object,
GQuark quark,
gpointer data);
void g_object_set_qdata_full (GObject *object,
GQuark quark,
gpointer data,
GDestroyNotify destroy);
gpointer g_object_steal_qdata (GObject *object,
GQuark quark);
void g_object_watch_closure (GObject *object,
GClosure *closure);
void g_object_run_dispose (GObject *object);
*/
} }
} }

View file

@ -15,24 +15,26 @@ namespace GLib {
/// </remarks> /// </remarks>
public enum TypeFundamentals { public enum TypeFundamentals {
TypeInvalid, TypeInvalid = 0 << 2,
TypeNone, TypeNone = 1 << 2,
TypeInterface, TypeInterface = 2 << 2,
TypeChar, TypeChar = 3 << 2,
TypeUChar, TypeUChar = 4 << 2,
TypeBoolean, TypeBoolean = 5 << 2,
TypeInt, TypeInt = 6 << 2,
TypeUInt, TypeUInt = 7 << 2,
TypeLong, TypeLong = 8 << 2,
TypeULong, TypeULong = 9 << 2,
TypeEnum, TypeInt64 = 10 << 2,
TypeFlags, TypeUInt64 = 11 << 2,
TypeFloat, TypeEnum = 12 << 2,
TypeDouble, TypeFlags = 13 << 2,
TypeString, TypeFloat = 14 << 2,
TypePointer, TypeDouble = 15 << 2,
TypeBoxed, TypeString = 16 << 2,
TypeParam, TypePointer = 17 << 2,
TypeObject, TypeBoxed = 18 << 2,
TypeParam = 19 << 2,
TypeObject = 20 << 2,
} }
} }

View file

@ -23,7 +23,7 @@ namespace GLib {
IntPtr _val; IntPtr _val;
// Destructor is required since we are allocating unmananged // Destructor is required since we are allocating unmanaged
// heap resources. // heap resources.
[DllImport("glib-2.0")] [DllImport("glib-2.0")]
@ -34,36 +34,18 @@ namespace GLib {
g_free (_val); g_free (_val);
} }
/// <summary>
/// Value Constructor
/// </summary>
///
/// <remarks>
/// Creates an uninitialized Value on the unmanaged heap.
/// Use the Init method prior to attempting to assign a
/// value to it.
/// </remarks>
[DllImport("glib-2.0", // import the glue function to allocate values on heap
CallingConvention=CallingConvention.Cdecl)]
static extern IntPtr g_malloc0 (long n_bytes);
public Value () [DllImport("gtksharpglue")]
static extern IntPtr gtksharp_value_create(TypeFundamentals type);
// Constructor to wrap a raw GValue ref. We need the dummy param
// to distinguish this ctor from the TypePointer ctor.
public Value (IntPtr val, IntPtr dummy)
{ {
_val = g_malloc0 (5 * IntPtr.Size); _val = val;
}
/// <summary>
/// Value Constructor
/// </summary>
///
/// <remarks>
/// Creates an initialized Value of the specified type.
/// </remarks>
public Value (TypeFundamentals type) : this ()
{
Init (type);
} }
/// <summary> /// <summary>
@ -74,16 +56,65 @@ namespace GLib {
/// Constructs a Value from a specified boolean. /// Constructs a Value from a specified boolean.
/// </remarks> /// </remarks>
[DllImport("gobject-2.0", [DllImport("gobject-2.0")]
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);
public Value (bool val) : this () public Value (bool val)
{ {
g_value_init (_val, TypeFundamentals.TypeBoolean); _val = gtksharp_value_create(TypeFundamentals.TypeBoolean);
g_value_set_boolean (_val, val); g_value_set_boolean (_val, val);
} }
/// <summary>
/// Value Constructor
/// </summary>
///
/// <remarks>
/// Constructs a Value from a specified boxed type.
/// </remarks>
[DllImport("gobject-2.0")]
static extern void g_value_set_boxed (IntPtr val, IntPtr data);
public Value (GLib.Boxed val)
{
_val = gtksharp_value_create(TypeFundamentals.TypeBoxed);
g_value_set_boxed (_val, val.Handle);
}
/// <summary>
/// Value Constructor
/// </summary>
///
/// <remarks>
/// Constructs a Value from a specified double.
/// </remarks>
[DllImport("gobject-2.0")]
static extern void g_value_set_double (IntPtr val, double data);
public Value (double val)
{
_val = gtksharp_value_create (TypeFundamentals.TypeDouble);
g_value_set_double (_val, val);
}
/// <summary>
/// Value Constructor
/// </summary>
///
/// <remarks>
/// Constructs a Value from a specified float.
/// </remarks>
[DllImport("gobject-2.0")]
static extern void g_value_set_float (IntPtr val, float data);
public Value (float val)
{
_val = gtksharp_value_create (TypeFundamentals.TypeFloat);
g_value_set_float (_val, val);
}
/// <summary> /// <summary>
/// Value Constructor /// Value Constructor
/// </summary> /// </summary>
@ -92,16 +123,49 @@ namespace GLib {
/// Constructs a Value from a specified integer. /// Constructs a Value from a specified integer.
/// </remarks> /// </remarks>
[DllImport("gobject-2.0", [DllImport("gobject-2.0")]
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);
public Value (int val) : this () public Value (int val)
{ {
g_value_init (_val, TypeFundamentals.TypeInt); _val = gtksharp_value_create (TypeFundamentals.TypeInt);
g_value_set_int (_val, val); g_value_set_int (_val, val);
} }
/// <summary>
/// Value Constructor
/// </summary>
///
/// <remarks>
/// Constructs a Value from a specified object.
/// </remarks>
[DllImport("gobject-2.0")]
static extern void g_value_set_object (IntPtr val, IntPtr data);
public Value (GLib.Object val)
{
_val = gtksharp_value_create (TypeFundamentals.TypeObject);
g_value_set_object (_val, val.Handle);
}
/// <summary>
/// Value Constructor
/// </summary>
///
/// <remarks>
/// Constructs a Value from a specified pointer.
/// </remarks>
[DllImport("gobject-2.0")]
static extern void g_value_set_pointer (IntPtr val, IntPtr data);
public Value (IntPtr val)
{
_val = gtksharp_value_create (TypeFundamentals.TypePointer);
g_value_set_pointer (_val, val);
}
/// <summary> /// <summary>
/// Value Constructor /// Value Constructor
/// </summary> /// </summary>
@ -110,32 +174,30 @@ namespace GLib {
/// Constructs a Value from a specified string. /// Constructs a Value from a specified string.
/// </remarks> /// </remarks>
[DllImport("gobject-2.0", [DllImport("gobject-2.0")]
CallingConvention=CallingConvention.Cdecl)] static extern void g_value_set_string (IntPtr val, string data);
static extern void g_value_set_string (IntPtr val,
string data); public Value (string val)
public Value (string val) : this ()
{ {
g_value_init (_val, TypeFundamentals.TypeString); _val = gtksharp_value_create (TypeFundamentals.TypeString);
g_value_set_string (_val, val); g_value_set_string (_val, val);
} }
/// <summary> /// <summary>
/// Init Method /// Value Constructor
/// </summary> /// </summary>
/// ///
/// <remarks> /// <remarks>
/// Prepares a raw value to hold a specified type. /// Constructs a Value from a specified uint.
/// </remarks> /// </remarks>
[DllImport("gobject-2.0", [DllImport("gobject-2.0")]
CallingConvention=CallingConvention.Cdecl)] static extern void g_value_set_uint (IntPtr val, uint data);
static extern void g_value_init (IntPtr val,
TypeFundamentals type);
public void Init (TypeFundamentals type) public Value (uint val)
{ {
g_value_init (_val, type); _val = gtksharp_value_create (TypeFundamentals.TypeUInt);
g_value_set_uint (_val, val);
} }
/// <summary> /// <summary>
@ -148,8 +210,7 @@ namespace GLib {
/// boolean value. /// boolean value.
/// </remarks> /// </remarks>
[DllImport("gobject-2.0", [DllImport("gobject-2.0")]
CallingConvention=CallingConvention.Cdecl)]
static extern bool g_value_get_boolean (IntPtr val); static extern bool g_value_get_boolean (IntPtr val);
public static explicit operator bool (Value val) public static explicit operator bool (Value val)
@ -159,6 +220,67 @@ namespace GLib {
return g_value_get_boolean (val._val); return g_value_get_boolean (val._val);
} }
/// <summary>
/// Value to Boxed Conversion
/// </summary>
///
/// <remarks>
/// Extracts a boxed type from a Value. Note, this method
/// will produce an exception if the Value does not hold a
/// boxed type value.
/// </remarks>
[DllImport("gobject-2.0")]
static extern IntPtr g_value_get_boxed (IntPtr val);
public static explicit operator GLib.Boxed (Value val)
{
// FIXME: Insert an appropriate exception here if
// _val.type indicates an error.
// FIXME: Figure out how to wrap this boxed type
return null;
}
/// <summary>
/// Value to Double Conversion
/// </summary>
///
/// <remarks>
/// Extracts a double from a Value. Note, this method
/// will produce an exception if the Value does not hold a
/// double value.
/// </remarks>
[DllImport("gobject-2.0")]
static extern double g_value_get_double (IntPtr val);
public static explicit operator double (Value val)
{
// FIXME: Insert an appropriate exception here if
// _val.type indicates an error.
return g_value_get_double (val._val);
}
/// <summary>
/// Value to Float Conversion
/// </summary>
///
/// <remarks>
/// Extracts a float from a Value. Note, this method
/// will produce an exception if the Value does not hold a
/// float value.
/// </remarks>
[DllImport("gobject-2.0")]
static extern float g_value_get_float (IntPtr val);
public static explicit operator float (Value val)
{
// FIXME: Insert an appropriate exception here if
// _val.type indicates an error.
return g_value_get_float (val._val);
}
/// <summary> /// <summary>
/// Value to Integer Conversion /// Value to Integer Conversion
/// </summary> /// </summary>
@ -169,8 +291,7 @@ namespace GLib {
/// integer value. /// integer value.
/// </remarks> /// </remarks>
[DllImport("gobject-2.0", [DllImport("gobject-2.0")]
CallingConvention=CallingConvention.Cdecl)]
static extern int g_value_get_int (IntPtr val); static extern int g_value_get_int (IntPtr val);
public static explicit operator int (Value val) public static explicit operator int (Value val)
@ -180,6 +301,46 @@ namespace GLib {
return g_value_get_int (val._val); return g_value_get_int (val._val);
} }
/// <summary>
/// Value to Object Conversion
/// </summary>
///
/// <remarks>
/// Extracts an object from a Value. Note, this method
/// will produce an exception if the Value does not hold a
/// object value.
/// </remarks>
[DllImport("gobject-2.0")]
static extern IntPtr g_value_get_object (IntPtr val);
public static explicit operator GLib.Object (Value val)
{
// FIXME: Insert an appropriate exception here if
// _val.type indicates an error.
return GLib.Object.GetObject(g_value_get_object (val._val));
}
/// <summary>
/// Value to Pointer Conversion
/// </summary>
///
/// <remarks>
/// Extracts a pointer from a Value. Note, this method
/// will produce an exception if the Value does not hold a
/// pointer value.
/// </remarks>
[DllImport("gobject-2.0")]
static extern IntPtr g_value_get_pointer (IntPtr val);
public static explicit operator IntPtr (Value val)
{
// FIXME: Insert an appropriate exception here if
// _val.type indicates an error.
return g_value_get_pointer (val._val);
}
/// <summary> /// <summary>
/// Value to String Conversion /// Value to String Conversion
/// </summary> /// </summary>
@ -190,8 +351,7 @@ namespace GLib {
/// string value. /// string value.
/// </remarks> /// </remarks>
[DllImport("gobject-2.0", [DllImport("gobject-2.0")]
CallingConvention=CallingConvention.Cdecl)]
static extern string g_value_get_string (IntPtr val); static extern string g_value_get_string (IntPtr val);
public static explicit operator String (Value val) public static explicit operator String (Value val)
@ -202,14 +362,34 @@ namespace GLib {
} }
/// <summary> /// <summary>
/// MarshalAs Property /// Value to Unsigned Integer Conversion
/// </summary>
///
/// <remarks>
/// Extracts an uint from a Value. Note, this method
/// will produce an exception if the Value does not hold a
/// unsigned integer value.
/// </remarks>
[DllImport("gobject-2.0")]
static extern uint g_value_get_uint (IntPtr val);
public static explicit operator uint (Value val)
{
// FIXME: Insert an appropriate exception here if
// _val.type indicates an error.
return g_value_get_uint (val._val);
}
/// <summary>
/// Handle Property
/// </summary> /// </summary>
/// ///
/// <remarks> /// <remarks>
/// Read only. Accesses a pointer to the raw GValue. /// Read only. Accesses a pointer to the raw GValue.
/// </remarks> /// </remarks>
public IntPtr MarshalAs { public IntPtr Handle {
get { get {
return _val; return _val;
} }

5
glib/makefile.win32 Normal file
View file

@ -0,0 +1,5 @@
all: windows
windows:
$(CSC) /unsafe /target:library /out:glib-sharp.dll /recurse:*.cs

View file

@ -1,4 +1,5 @@
*.dll *.dll
*.exe *.exe
generated generated
Makefile

View file

@ -1,15 +1,20 @@
MCS=mcs MCS=mcs
all: all: linux
@echo "You must use 'make windows' or 'make unix'." @echo "You must use 'make windows' or 'make unix'."
@echo "'make unix' is broken for now." @echo "'make unix' is broken for now."
windows: windows:
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /r:../gdk/gdk-sharp.dll /out:gtk-sharp.dll /recurse:*.cs $(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /r:../gdk/gdk-sharp.dll /out:gtk-sharp.dll /recurse:*.cs
linux: linux: gtk-sharp.dll
gtk-sharp.dll: *.cs generated/*.cs
$(MCS) --unsafe --target library -r ../glib/glib-sharp.dll -r ../pango/pango-sharp.dll -r ../atk/atk-sharp.dll -r ../gdk/gdk-sharp.dll -o gtk-sharp.dll --recurse *.cs $(MCS) --unsafe --target library -r ../glib/glib-sharp.dll -r ../pango/pango-sharp.dll -r ../atk/atk-sharp.dll -r ../gdk/gdk-sharp.dll -o gtk-sharp.dll --recurse *.cs
unix: unix:
@echo "'make unix' is broken for now." @echo "'make unix' is broken for now."
install: all
cp gtk-sharp.dll @prefix@/lib

5
gtk/makefile.win32 Normal file
View file

@ -0,0 +1,5 @@
all: windows
windows:
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /r:../gdk/gdk-sharp.dll /out:gtk-sharp.dll /recurse:*.cs

View file

@ -1,11 +1,9 @@
DIRS=generator glib pango atk gdk gtk sample DIRS=glue generator glib pango atk gdk gtk sample
ROOT=/cygdrive/$(subst \,/,$(subst :\,/,$(SYSTEMROOT))) ROOT=/cygdrive/$(subst \,/,$(subst :\,/,$(SYSTEMROOT)))
CSC=$(ROOT)/microsoft.net/framework/v1.0.3705/csc.exe CSC=$(ROOT)/microsoft.net/framework/v1.0.3705/csc.exe
MCS=mcs MCS=mcs
all: all: linux
@echo "You must use 'make windows' or 'make linux'."
@echo "'make unix' is broken for now."
windows: windows:
for i in $(DIRS); do \ for i in $(DIRS); do \
@ -16,8 +14,12 @@ unix:
@echo "'make unix' is broken for now." @echo "'make unix' is broken for now."
linux: linux:
(cd glue;make) || exit 1
for i in $(DIRS); do \ for i in $(DIRS); do \
(cd $$i; MCS="$(MCS)" make linux) || exit 1;\ (cd $$i; MCS="$(MCS)" make) || exit 1;\
done;
install:
for i in $(DIRS); do \
(cd $$i; make install) || exit 1; \
done; done;

11
makefile.win32 Executable file
View file

@ -0,0 +1,11 @@
DIRS=generator glib pango atk gdk gtk sample
ROOT=/cygdrive/$(subst \,/,$(subst :\,/,$(SYSTEMROOT)))
CSC=$(ROOT)/microsoft.net/framework/v1.0.3705/csc.exe
all: windows
windows:
for i in $(DIRS); do \
(cd $$i; CSC=$(CSC) make -f makefile.win32) || exit 1;\
done;

View file

@ -1,4 +1,5 @@
*.dll *.dll
*.exe *.exe
generated generated
Makefile

View file

@ -1,14 +1,18 @@
MCS=mcs MCS=mcs
all: all: linux
@echo "You must use 'make windows' or 'make unix'."
@echo "'make unix' is broken for now."
windows: windows:
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /out:pango-sharp.dll /recurse:*.cs $(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /out:pango-sharp.dll /recurse:*.cs
linux: linux: pango-sharp.dll
pango-sharp.dll: generated/*.cs
$(MCS) --unsafe --target library -r ../glib/glib-sharp.dll -o pango-sharp.dll --recurse *.cs $(MCS) --unsafe --target library -r ../glib/glib-sharp.dll -o pango-sharp.dll --recurse *.cs
unix: unix:
@echo "'make unix' is broken for now." @echo "'make unix' is broken for now."
install: all
cp pango-sharp.dll @prefix@/lib

5
pango/makefile.win32 Normal file
View file

@ -0,0 +1,5 @@
all: windows
windows:
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /out:pango-sharp.dll /recurse:*.cs

View file

@ -1,4 +1,5 @@
*.dll *.dll
*.exe *.exe
generated generated
Makefile

21
sample/Makefile.in Executable file
View file

@ -0,0 +1,21 @@
MCS=mcs
all: linux
windows:
$(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll /r:../gdk/gdk-sharp.dll HelloWorld.cs
$(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll ButtonApp.cs
linux: gtk-hello-world.exe button.exe
gtk-hello-world.exe: HelloWorld.cs
$(MCS) --unsafe -o gtk-hello-world.exe -r ../glib/glib-sharp.dll -r ../gtk/gtk-sharp.dll -r ../gdk/gdk-sharp.dll HelloWorld.cs
button.exe: ButtonApp.cs
$(MCS) --unsafe -o button.exe -r ../glib/glib-sharp.dll -r ../gtk/gtk-sharp.dll ButtonApp.cs
unix:
@echo "'make unix' is broken for now."
install:

6
sample/makefile → sample/makefile.win32 Executable file → Normal file
View file

@ -1,10 +1,6 @@
all: all: windows
@echo "You must use 'make windows' or 'make unix'."
@echo "'make unix' is broken for now."
windows: windows:
$(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll /r:../gdk/gdk-sharp.dll HelloWorld.cs $(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll /r:../gdk/gdk-sharp.dll HelloWorld.cs
$(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll ButtonApp.cs $(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll ButtonApp.cs
unix:
@echo "'make unix' is broken for now."