2002-10-26 Mike Kestner <mkestner@speakeasy.net>
Much of this patch from Vlad, with substantial rework by mk. * */makefile.win32 : introduce mapdllnames.pl, api, and glue * generator/CallbackGen.cs : rework namespacing for csc compilation * generator/Parameters.cs : ditto * generator/Signal.cs : ditto * generator/SignalHandler.cs : ditto * glue/win32dll.c : new dll construction source * glib/Value.cs : new ushort ctor/cast operator * gtk/Table.custom : comment this out until we add a default ctor tag * gtk/ThreadNotify.cs : make ReadyEvent public * sources/Gdk.metadata : mark a Parse() param as ref svn path=/trunk/gtk-sharp/; revision=8590
This commit is contained in:
parent
cf139575c2
commit
b2f04c1d80
20 changed files with 191 additions and 31 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2002-10-26 Mike Kestner <mkestner@speakeasy.net>
|
||||
|
||||
Much of this patch from Vlad, with substantial rework by mk.
|
||||
* */makefile.win32 : introduce mapdllnames.pl, api, and glue
|
||||
* generator/CallbackGen.cs : rework namespacing for csc compilation
|
||||
* generator/Parameters.cs : ditto
|
||||
* generator/Signal.cs : ditto
|
||||
* generator/SignalHandler.cs : ditto
|
||||
* glue/win32dll.c : new dll construction source
|
||||
* glib/Value.cs : new ushort ctor/cast operator
|
||||
* gtk/Table.custom : comment this out until we add a default ctor tag
|
||||
* gtk/ThreadNotify.cs : make ReadyEvent public
|
||||
* sources/Gdk.metadata : mark a Parse() param as ref
|
||||
|
||||
2002-10-26 Ettore Perazzoli <ettore@ximian.com>
|
||||
|
||||
* glib/Object.cs: Changed so that Objects is a hash of
|
||||
|
|
6
api/makefile.win32
Executable file
6
api/makefile.win32
Executable file
|
@ -0,0 +1,6 @@
|
|||
all: generated-stamp
|
||||
|
||||
generated-stamp: atk-api.xml gdk-api.xml gdk-symbols.xml gtk-api.xml gtk-symbols.xml pango-api.xml ../generator/codegen.exe
|
||||
../generator/codegen --generate atk-api.xml gdk-api.xml gdk-symbols.xml gtk-api.xml gtk-symbols.xml pango-api.xml
|
||||
touch generated-stamp
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
all: windows
|
||||
|
||||
windows:
|
||||
../mapdllnames.pl generated/*.cs
|
||||
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /out:atk-sharp.dll /recurse:*.cs
|
||||
|
||||
docs:
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
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
|
||||
cat *.cs generated/*.cs > allthesource.cs
|
||||
../mapdllnames.pl allthesource.cs
|
||||
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /out:gdk-sharp.dll allthesource.cs
|
||||
rm allthesource.cs
|
||||
|
||||
docs:
|
||||
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /doc:gdk-sharp-docs.xml /out:gdk-sharp.dll /recurse:*.cs
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace GtkSharp.Generation {
|
|||
public String MarshalType {
|
||||
get
|
||||
{
|
||||
return "GtkSharp." + NS + Name + "Native";
|
||||
return NS + "Sharp." + Name + "Native";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,9 @@ namespace GtkSharp.Generation {
|
|||
if (!Directory.Exists (dir))
|
||||
Directory.CreateDirectory (dir);
|
||||
|
||||
string wrapper = NS + Name + "Native";
|
||||
string wrapper = Name + "Native";
|
||||
|
||||
string filename = dir + sep + "GtkSharp." + wrapper + ".cs";
|
||||
string filename = dir + sep + NS + "Sharp." + wrapper + ".cs";
|
||||
|
||||
FileStream stream = new FileStream (filename, FileMode.Create, FileAccess.Write);
|
||||
StreamWriter sw = new StreamWriter (stream);
|
||||
|
@ -67,10 +67,10 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("// Generated File. Do not modify.");
|
||||
sw.WriteLine ("// <c> 2001-2002 Mike Kestner");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("namespace GtkSharp {");
|
||||
sw.WriteLine ("namespace " + NS + "Sharp {");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\tusing System;");
|
||||
sw.WriteLine ("\tusing System.Collections;");
|
||||
sw.WriteLine ();
|
||||
|
||||
string import_sig;
|
||||
if (parms != null)
|
||||
|
@ -87,7 +87,7 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("\tpublic delegate " + m_ret + " " + wrapper + "(" + import_sig + ");");
|
||||
sw.WriteLine ();
|
||||
|
||||
sw.WriteLine ("\tpublic class " + NS + Name + "Wrapper : GLib.DelegateWrapper {");
|
||||
sw.WriteLine ("\tpublic class " + Name + "Wrapper : GLib.DelegateWrapper {");
|
||||
sw.WriteLine ();
|
||||
|
||||
sw.WriteLine ("\t\tpublic " + m_ret + " NativeCallback (" + import_sig + ")");
|
||||
|
@ -147,7 +147,7 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("\t\tprotected {0} _managed;", NS + "." + Name);
|
||||
sw.WriteLine ();
|
||||
|
||||
sw.WriteLine ("\t\tpublic {0} ({1} managed) : base ()", NS + Name + "Wrapper", NS + "." + Name);
|
||||
sw.WriteLine ("\t\tpublic {0} ({1} managed) : base ()", Name + "Wrapper", NS + "." + Name);
|
||||
sw.WriteLine ("\t\t{");
|
||||
|
||||
sw.WriteLine ("\t\t\tNativeDelegate = new {0} (NativeCallback);", wrapper);
|
||||
|
|
|
@ -215,8 +215,7 @@ namespace GtkSharp.Generation {
|
|||
|
||||
if (SymbolTable.IsCallback (type)) {
|
||||
call_parm = SymbolTable.CallByName (type, call_parm_name + "_wrapper");
|
||||
callback_type = type.Replace (".", "");
|
||||
callback_type = "GtkSharp." + callback_type + "Wrapper";
|
||||
callback_type = type.Replace(".", "Sharp.") + "Wrapper";
|
||||
} else
|
||||
call_parm = SymbolTable.CallByName(type, call_parm_name);
|
||||
|
||||
|
@ -344,8 +343,7 @@ namespace GtkSharp.Generation {
|
|||
name = MangleName(p_elem.GetAttribute("name"));
|
||||
|
||||
if (SymbolTable.IsCallback (c_type)) {
|
||||
type = type.Replace (".", "");
|
||||
type = "GtkSharp." + type + "Wrapper";
|
||||
type = type.Replace(".", "Sharp.") + "Wrapper";
|
||||
|
||||
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = null;", type, name);
|
||||
sw.Write (indent + "\t\t\t");
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace GtkSharp.Generation {
|
|||
string argsname;
|
||||
string handler = GetHandlerName (out argsname);
|
||||
if (handler != "EventHandler")
|
||||
handler = "GtkSharp." + handler;
|
||||
handler = container_type.NS + "Sharp." + handler;
|
||||
|
||||
GenComments (sw);
|
||||
if (elem.HasAttribute("new_flag") || (container_type != null && container_type.GetSignalRecursively (Name) != null))
|
||||
|
@ -98,7 +98,7 @@ namespace GtkSharp.Generation {
|
|||
if (!Directory.Exists (dir))
|
||||
Directory.CreateDirectory (dir);
|
||||
|
||||
string filename = dir + sep + "GtkSharp." + handler + ".cs";
|
||||
string filename = dir + sep + container_type.NS + "Sharp." + handler + ".cs";
|
||||
|
||||
FileStream stream = new FileStream (filename, FileMode.Create, FileAccess.Write);
|
||||
StreamWriter sw = new StreamWriter (stream);
|
||||
|
@ -106,7 +106,7 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("// Generated File. Do not modify.");
|
||||
sw.WriteLine ("// <c> 2001-2002 Mike Kestner");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("namespace GtkSharp {");
|
||||
sw.WriteLine ("namespace " + container_type.NS + "Sharp {");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\tusing System;");
|
||||
|
||||
|
@ -138,13 +138,13 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("}");
|
||||
sw.Close ();
|
||||
argsname = "GtkSharp." + argsname;
|
||||
return "GtkSharp." + handler;
|
||||
return container_type.NS + "Sharp." + handler;
|
||||
}
|
||||
|
||||
public void Generate (StreamWriter sw, ClassBase implementor, bool gen_docs)
|
||||
{
|
||||
string cname = "\"" + elem.GetAttribute("cname") + "\"";
|
||||
string qual_marsh = "GtkSharp." + marsh;
|
||||
string qual_marsh = marsh;
|
||||
|
||||
if (gen_docs)
|
||||
GenComments (sw);
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace GtkSharp.Generation {
|
|||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
|
||||
String filename = dir + sep + sname + ".cs";
|
||||
String filename = dir + sep + ns + "Sharp." + sname + ".cs";
|
||||
|
||||
FileStream stream = new FileStream (filename, FileMode.Create, FileAccess.Write);
|
||||
StreamWriter sw = new StreamWriter (stream);
|
||||
|
@ -96,12 +96,11 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("// Generated File. Do not modify.");
|
||||
sw.WriteLine ("// <c> 2001-2002 Mike Kestner");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine("namespace GtkSharp {");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine("namespace " + ns + " {");
|
||||
sw.WriteLine("namespace " + ns + "Sharp {");
|
||||
sw.WriteLine();
|
||||
sw.WriteLine("\tusing System;");
|
||||
sw.WriteLine("\tusing System.Runtime.InteropServices;");
|
||||
sw.WriteLine("\tusing GtkSharp;");
|
||||
sw.WriteLine();
|
||||
sw.Write("\tpublic delegate " + p_ret + " ");
|
||||
sw.WriteLine(dname + "(" + pinv + ", int key);");
|
||||
|
@ -189,10 +188,9 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine("\t\t}");
|
||||
sw.WriteLine("\t}");
|
||||
sw.WriteLine("}");
|
||||
sw.WriteLine("}");
|
||||
sw.Close();
|
||||
|
||||
return ns + "." + sname;
|
||||
return ns + "Sharp." + sname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ all: windows
|
|||
|
||||
windows: *.cs
|
||||
$(CSC) /unsafe /out:codegen.exe *.cs
|
||||
./codegen gtkapi.xml
|
||||
|
||||
docs: windows
|
||||
|
||||
|
|
|
@ -244,6 +244,20 @@ namespace GLib {
|
|||
g_value_set_uint (_val, val);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Value Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Constructs a Value from a specified ushort.
|
||||
/// </remarks>
|
||||
|
||||
public Value (ushort val)
|
||||
{
|
||||
_val = gtksharp_value_create (TypeFundamentals.TypeUInt);
|
||||
g_value_set_uint (_val, val);
|
||||
}
|
||||
|
||||
[DllImport("gobject-2.0")]
|
||||
static extern void g_value_set_enum (IntPtr val, int data);
|
||||
[DllImport("gobject-2.0")]
|
||||
|
@ -467,6 +481,23 @@ namespace GLib {
|
|||
return g_value_get_uint (val._val);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Value to Unsigned Short Conversion
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Extracts a ushort from a Value. Note, this method
|
||||
/// will produce an exception if the Value does not hold a
|
||||
/// unsigned integer value.
|
||||
/// </remarks>
|
||||
|
||||
public static explicit operator ushort (Value val)
|
||||
{
|
||||
// FIXME: Insert an appropriate exception here if
|
||||
// _val.type indicates an error.
|
||||
return (ushort) g_value_get_uint (val._val);
|
||||
}
|
||||
|
||||
[DllImport("gobject-2.0")]
|
||||
static extern int g_value_get_enum (IntPtr val);
|
||||
[DllImport("gobject-2.0")]
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
all: windows
|
||||
|
||||
windows:
|
||||
$(CSC) /unsafe /target:library /out:glib-sharp.dll /recurse:*.cs
|
||||
cat *.cs > allthesource.cs
|
||||
../mapdllnames.pl allthesource.cs
|
||||
$(CSC) /unsafe /target:library /out:glib-sharp.dll allthesource.cs
|
||||
rm allthesource.cs
|
||||
|
||||
docs:
|
||||
$(CSC) /unsafe /target:library /doc:glib-sharp-docs.xml /out:glib-sharp.dll /recurse:*.cs
|
||||
|
|
34
glue/makefile.win32
Executable file
34
glue/makefile.win32
Executable file
|
@ -0,0 +1,34 @@
|
|||
GTK_CFLAGS=`pkg-config --cflags gtk+-win32-2.0`
|
||||
GTK_LIBS=`pkg-config --libs gtk+-win32-2.0`
|
||||
CC=gcc -b i686-pc-mingw32
|
||||
DLLWRAP=dllwrap --mno-cygwin --target i386-mingw32 --export-all-symbols
|
||||
|
||||
GLUE_OBJS = \
|
||||
adjustment.o \
|
||||
dialog.o \
|
||||
error.o \
|
||||
event.o \
|
||||
fileselection.o \
|
||||
list.o \
|
||||
object.o \
|
||||
paned.o \
|
||||
slist.o \
|
||||
style.o \
|
||||
type.o \
|
||||
value.o \
|
||||
widget.o \
|
||||
win32dll.o
|
||||
|
||||
all: gtksharpglue.dll
|
||||
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) $(GTK_CFLAGS) -o $@ $^
|
||||
|
||||
|
||||
gtksharpglue.dll: $(GLUE_OBJS)
|
||||
$(DLLWRAP) --output-lib=libgtksharpglue.a --dllname=gtksharpglue.dll --driver-name=gcc --output-def=gtksharpglue.def $(GLUE_OBJS) $(GTK_LIBS)
|
||||
|
||||
|
||||
clean:
|
||||
rm -f gtksharpglue.dll *.o libgtksharpglue.a
|
16
glue/win32dll.c
Executable file
16
glue/win32dll.c
Executable file
|
@ -0,0 +1,16 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#include <stdio.h>
|
||||
|
||||
BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL APIENTRY DllMainCRTStartup (HINSTANCE hInst, DWORD reason, LPVOID reserved)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/* FIXME: Uncomment this when the default ctor flag is added to the XML
|
||||
public Table()
|
||||
{
|
||||
Raw = gtk_table_new (0, 0, false);
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Gtk {
|
|||
// <summary>
|
||||
// This delegate will be invoked on the main Gtk thread.
|
||||
// </summary>
|
||||
delegate void ReadyEvent ();
|
||||
public delegate void ReadyEvent ();
|
||||
|
||||
/// <summary>
|
||||
/// Utility class to help writting multi-threaded Gtk applications
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
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
|
||||
cat *.cs generated/*.cs > allthesource.cs
|
||||
../mapdllnames.pl allthesource.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 allthesource.cs
|
||||
rm allthesource.cs
|
||||
|
||||
docs:
|
||||
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /r:../gdk/gdk-sharp.dll /doc:gtk-sharp-docs.xml /out:gtk-sharp.dll /recurse:*.cs
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
DIRS=generator glib pango atk gdk gtk gnome sample
|
||||
DIRS=glue generator api glib pango atk gdk gtk sample
|
||||
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 /d:WIN32
|
||||
|
||||
all: windows
|
||||
|
||||
windows:
|
||||
for i in $(DIRS); do \
|
||||
(cd $$i; CSC=$(CSC) make -f makefile.win32) || exit 1;\
|
||||
(cd $$i; CSC="$(CSC)" make -f makefile.win32) || exit 1;\
|
||||
done;
|
||||
|
||||
docs:
|
||||
for i in $(DIRS); do \
|
||||
(cd $$i; CSC=$(CSC) make -f makefile.win32 docs) || exit 1;\
|
||||
(cd $$i; CSC="$(CSC)" make -f makefile.win32 docs) || exit 1;\
|
||||
done;
|
||||
|
||||
|
|
37
mapdllnames.pl
Executable file
37
mapdllnames.pl
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# mapdllnames.pl : remaps the DllImport libnames for a specified source dir.
|
||||
#
|
||||
# Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
#
|
||||
# <c> 2002 Mike Kestner
|
||||
#############################################################################
|
||||
|
||||
%map = (
|
||||
'glib-2.0', "libglib-2.0-0.dll",
|
||||
'gobject-2.0', "libgobject-2.0-0.dll",
|
||||
'pango-1.0', "libpango-1.0-0.dll",
|
||||
'atk-1.0', "libatk-1.0-0.dll",
|
||||
'gdk-x11-2.0', "libgdk-win32-2.0-0.dll",
|
||||
'gdk-pixbuf-2.0', "libgdk_pixbuf-2.0-0.dll",
|
||||
'gtk-x11-2.0', "libgtk-win32-2.0-0.dll"
|
||||
);
|
||||
|
||||
foreach $filename (@ARGV) {
|
||||
|
||||
chomp($filename);
|
||||
open(INFILE, $filename) || die "Couldn't open $filename\n";
|
||||
open(OUTFILE, ">$filename.tmp") || die "Couldn't open $filename.tmp\n";
|
||||
|
||||
while ($line = <INFILE>) {
|
||||
if ($line =~ /DllImport\(\"(.*)\"/ && exists($map{$1})) {
|
||||
$line =~ s/\"(.*)\"/\"$map{$1}\"/;
|
||||
}
|
||||
|
||||
print OUTFILE $line;
|
||||
}
|
||||
close(INFILE);
|
||||
close(OUTFILE);
|
||||
`mv $filename.tmp $filename`;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
all: windows
|
||||
|
||||
windows:
|
||||
../mapdllnames.pl generated/*.cs
|
||||
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /out:pango-sharp.dll /recurse:*.cs
|
||||
|
||||
docs:
|
||||
|
|
|
@ -81,6 +81,20 @@
|
|||
</data>
|
||||
</rule>
|
||||
|
||||
<!-- ref parameters -->
|
||||
<rule>
|
||||
<class name="GdkColor">
|
||||
<method>Parse</method>
|
||||
</class>
|
||||
<data>
|
||||
<attribute target="param">
|
||||
<filter level="type">GdkColor*</filter>
|
||||
<name>pass_as</name>
|
||||
<value>ref</value>
|
||||
</attribute>
|
||||
</data>
|
||||
</rule>
|
||||
|
||||
<!-- out parameters -->
|
||||
<rule>
|
||||
<class name="GdkWindow">
|
||||
|
|
Loading…
Reference in a new issue