mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 00:13:20 +02:00
2002-02-14 Mike Kestner <mkestner@speakeasy.net>
* generator/ObjectGen.cs : suppress generation of get/set methods when properties exist. Mangle method names on signal name clashes. Gen the signals. * generator/SymbolTable.cs : Add GetName. Add some more calls to Trim. * generator/gtkapi.xml : adding binary file as an experiment. If the diff's show this file, I'll be removing it with apologies and going back to the separate package idea. * parser/gapi2xml.pl : some signal related fixes. * sample/HelloWorld.cs : uncomment the event hook. svn path=/trunk/gtk-sharp/; revision=2419
This commit is contained in:
parent
123557fb68
commit
61b1d1de13
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2002-02-14 Mike Kestner <mkestner@speakeasy.net>
|
||||||
|
|
||||||
|
* generator/ObjectGen.cs : suppress generation of get/set methods when
|
||||||
|
properties exist. Mangle method names on signal name clashes. Gen
|
||||||
|
the signals.
|
||||||
|
* generator/SymbolTable.cs : Add GetName. Add some more calls to Trim.
|
||||||
|
* generator/gtkapi.xml : adding binary file as an experiment. If the
|
||||||
|
diff's show this file, I'll be removing it with apologies and going
|
||||||
|
back to the separate package idea.
|
||||||
|
* parser/gapi2xml.pl : some signal related fixes.
|
||||||
|
* sample/HelloWorld.cs : uncomment the event hook.
|
||||||
|
|
||||||
2002-02-10 Mike Kestner <mkestner@speakeasy.net>
|
2002-02-10 Mike Kestner <mkestner@speakeasy.net>
|
||||||
|
|
||||||
* generator/BoxedGen.cs (FromNative): Add explicit cast.
|
* generator/BoxedGen.cs (FromNative): Add explicit cast.
|
||||||
|
@ -43,7 +43,7 @@ namespace GtkSharp.Generation {
|
|||||||
StreamWriter sw = new StreamWriter (stream);
|
StreamWriter sw = new StreamWriter (stream);
|
||||||
|
|
||||||
sw.WriteLine ("// Generated File. Do not modify.");
|
sw.WriteLine ("// Generated File. Do not modify.");
|
||||||
sw.WriteLine ("// <c> 2001 Mike Kestner");
|
sw.WriteLine ("// <c> 2001-2002 Mike Kestner");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
sw.WriteLine ("namespace " + ns + " {");
|
sw.WriteLine ("namespace " + ns + " {");
|
||||||
@ -69,6 +69,10 @@ namespace GtkSharp.Generation {
|
|||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
|
||||||
Hashtable clash_map = new Hashtable();
|
Hashtable clash_map = new Hashtable();
|
||||||
|
Hashtable props = new Hashtable();
|
||||||
|
Hashtable sigs = new Hashtable();
|
||||||
|
ArrayList methods = new ArrayList();
|
||||||
|
bool first_sig = true;
|
||||||
|
|
||||||
foreach (XmlNode node in elem.ChildNodes) {
|
foreach (XmlNode node in elem.ChildNodes) {
|
||||||
|
|
||||||
@ -91,18 +95,27 @@ namespace GtkSharp.Generation {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "method":
|
case "method":
|
||||||
if (!GenMethod(member, table, sw)) {
|
methods.Add(member);
|
||||||
Console.WriteLine("in object " + CName);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "property":
|
case "property":
|
||||||
if (!GenProperty(member, table, sw)) {
|
String pname;
|
||||||
|
if (!GenProperty(member, table, sw, out pname)) {
|
||||||
Console.WriteLine("in object " + CName);
|
Console.WriteLine("in object " + CName);
|
||||||
}
|
}
|
||||||
|
props.Add(pname, pname);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "signal":
|
case "signal":
|
||||||
|
if (first_sig) {
|
||||||
|
first_sig = false;
|
||||||
|
sw.WriteLine("\t\tprivate Hashtable Signals = new Hashtable();");
|
||||||
|
}
|
||||||
|
String sname;
|
||||||
|
if (!GenSignal(member, table, sw, out sname)) {
|
||||||
|
Console.WriteLine("in object " + CName);
|
||||||
|
}
|
||||||
|
sigs.Add(sname, sname);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -116,7 +129,21 @@ namespace GtkSharp.Generation {
|
|||||||
sw.WriteLine("\t\tpublic " + Name + "() : base(){}");
|
sw.WriteLine("\t\tpublic " + Name + "() : base(){}");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (XmlElement member in methods) {
|
||||||
|
String mname = member.GetAttribute("name");
|
||||||
|
if ((mname.StartsWith("Set") || mname.StartsWith("Get")) &&
|
||||||
|
props.ContainsKey(mname.Substring(3))) {
|
||||||
|
continue;
|
||||||
|
} else if (sigs.ContainsKey(mname)) {
|
||||||
|
member.SetAttribute("name", "Emit" + mname);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GenMethod(member, table, sw)) {
|
||||||
|
Console.WriteLine("in object " + CName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("}");
|
sw.WriteLine ("}");
|
||||||
@ -125,7 +152,7 @@ namespace GtkSharp.Generation {
|
|||||||
sw.Close();
|
sw.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GenProperty (XmlElement prop, SymbolTable table, StreamWriter sw)
|
public bool GenProperty (XmlElement prop, SymbolTable table, StreamWriter sw, out String name)
|
||||||
{
|
{
|
||||||
String c_type = prop.GetAttribute("type");
|
String c_type = prop.GetAttribute("type");
|
||||||
|
|
||||||
@ -134,6 +161,12 @@ namespace GtkSharp.Generation {
|
|||||||
String cs_type = table.GetCSType(c_type);
|
String cs_type = table.GetCSType(c_type);
|
||||||
String m_type;
|
String m_type;
|
||||||
|
|
||||||
|
XmlElement parent = (XmlElement) prop.ParentNode;
|
||||||
|
name = prop.GetAttribute("name");
|
||||||
|
if (name == parent.GetAttribute("name")) {
|
||||||
|
name += "Prop";
|
||||||
|
}
|
||||||
|
|
||||||
if (table.IsObject(c_type)) {
|
if (table.IsObject(c_type)) {
|
||||||
m_type = "GLib.Object";
|
m_type = "GLib.Object";
|
||||||
} else if (table.IsBoxed(c_type)) {
|
} else if (table.IsBoxed(c_type)) {
|
||||||
@ -155,12 +188,6 @@ namespace GtkSharp.Generation {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlElement parent = (XmlElement) prop.ParentNode;
|
|
||||||
String name = prop.GetAttribute("name");
|
|
||||||
if (name == parent.GetAttribute("name")) {
|
|
||||||
name += "Prop";
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {");
|
||||||
@ -186,30 +213,33 @@ namespace GtkSharp.Generation {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GenSignal (XmlElement sig, SymbolTable table, StreamWriter sw)
|
public bool GenSignal (XmlElement sig, SymbolTable table, StreamWriter sw, out String name)
|
||||||
{
|
{
|
||||||
String cname = "\"" + sig.GetAttribute("cname") + "\"";
|
String cname = "\"" + sig.GetAttribute("cname") + "\"";
|
||||||
|
name = sig.GetAttribute("name");
|
||||||
|
|
||||||
String marsh = "blah"; // SignalHandler.GetName(sig);
|
String marsh = SignalHandler.GetName(sig, table);
|
||||||
if (marsh == "") {
|
if (marsh == "") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
marsh = "GtkSharp." + marsh;
|
||||||
|
|
||||||
sw.WriteLine("\t\t/// <summary> " + cname + " Event </summary>");
|
sw.WriteLine("\t\t/// <summary> " + name + " Event </summary>");
|
||||||
sw.WriteLine("\t\t/// <remarks>");
|
sw.WriteLine("\t\t/// <remarks>");
|
||||||
// FIXME: Generate some signal docs
|
// FIXME: Generate some signal docs
|
||||||
sw.WriteLine("\t\t/// </remarks>");
|
sw.WriteLine("\t\t/// </remarks>");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
sw.WriteLine("\t\tpublic event EventHandler " + cname + " {");
|
sw.WriteLine("\t\tpublic event EventHandler " + name + " {");
|
||||||
sw.WriteLine("\t\t\tadd {");
|
sw.WriteLine("\t\t\tadd {");
|
||||||
sw.WriteLine("\t\t\t\tif (Events [" + cname + "] == null)");
|
sw.WriteLine("\t\t\t\tif (EventList[" + cname + "] == null)");
|
||||||
sw.Write("\t\t\t\t\tSignals[" + cname + "] = new " + marsh);
|
sw.Write("\t\t\t\t\tSignals[" + cname + "] = new " + marsh);
|
||||||
sw.WriteLine("(this, Handle, " + cname + ", value);");
|
sw.WriteLine("(this, Handle, " + cname + ", value);");
|
||||||
sw.WriteLine("\t\t\t\tEvents.AddHandler(" + cname + ", value);");
|
sw.WriteLine("\t\t\t\tEventList.AddHandler(" + cname + ", value);");
|
||||||
sw.WriteLine("\t\t\t}");
|
sw.WriteLine("\t\t\t}");
|
||||||
sw.WriteLine("\t\t\tremove {");
|
sw.WriteLine("\t\t\tremove {");
|
||||||
sw.WriteLine("\t\t\t\tEvents.RemoveHandler(" + cname + ", value);");
|
sw.WriteLine("\t\t\t\tEventList.RemoveHandler(" + cname + ", value);");
|
||||||
sw.WriteLine("\t\t\t\tif (Events[" + cname + "] == null)");
|
sw.WriteLine("\t\t\t\tif (EventList[" + cname + "] == null)");
|
||||||
sw.WriteLine("\t\t\t\t\tSignals.Remove(" + cname + ");");
|
sw.WriteLine("\t\t\t\t\tSignals.Remove(" + cname + ");");
|
||||||
sw.WriteLine("\t\t\t}");
|
sw.WriteLine("\t\t\t}");
|
||||||
sw.WriteLine("\t\t}");
|
sw.WriteLine("\t\t}");
|
||||||
|
@ -122,6 +122,25 @@ namespace GtkSharp.Generation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String GetName(String c_type)
|
||||||
|
{
|
||||||
|
c_type = Trim(c_type);
|
||||||
|
if (simple_types.ContainsKey(c_type)) {
|
||||||
|
String stype = (String) simple_types[c_type];
|
||||||
|
int dotidx = stype.IndexOf(".");
|
||||||
|
if (dotidx == -1) {
|
||||||
|
return stype;
|
||||||
|
} else {
|
||||||
|
return stype.Substring(dotidx+1);
|
||||||
|
}
|
||||||
|
} else if (complex_types.ContainsKey(c_type)) {
|
||||||
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
||||||
|
return gen.Name;
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String GetDllName(String ns)
|
public String GetDllName(String ns)
|
||||||
{
|
{
|
||||||
return (String) dlls[ns];
|
return (String) dlls[ns];
|
||||||
@ -155,6 +174,7 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
public bool IsBoxed(String c_type)
|
public bool IsBoxed(String c_type)
|
||||||
{
|
{
|
||||||
|
c_type = Trim(c_type);
|
||||||
if (complex_types.ContainsKey(c_type)) {
|
if (complex_types.ContainsKey(c_type)) {
|
||||||
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
||||||
if (gen is BoxedGen) {
|
if (gen is BoxedGen) {
|
||||||
@ -166,6 +186,7 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
public bool IsInterface(String c_type)
|
public bool IsInterface(String c_type)
|
||||||
{
|
{
|
||||||
|
c_type = Trim(c_type);
|
||||||
if (complex_types.ContainsKey(c_type)) {
|
if (complex_types.ContainsKey(c_type)) {
|
||||||
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
||||||
if (gen is InterfaceGen) {
|
if (gen is InterfaceGen) {
|
||||||
@ -177,6 +198,7 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
public bool IsObject(String c_type)
|
public bool IsObject(String c_type)
|
||||||
{
|
{
|
||||||
|
c_type = Trim(c_type);
|
||||||
if (complex_types.ContainsKey(c_type)) {
|
if (complex_types.ContainsKey(c_type)) {
|
||||||
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
||||||
if (gen is ObjectGen) {
|
if (gen is ObjectGen) {
|
||||||
|
2
generator/gtkapi.xml
Normal file
2
generator/gtkapi.xml
Normal file
File diff suppressed because one or more lines are too long
@ -496,7 +496,10 @@ sub addSignalElem
|
|||||||
$sig_elem = $doc->createElement('signal');
|
$sig_elem = $doc->createElement('signal');
|
||||||
$node->appendChild($sig_elem);
|
$node->appendChild($sig_elem);
|
||||||
|
|
||||||
$sig_elem->setAttribute('name', $1) if ($spec =~ /\(\"(\w+)\"/);
|
if ($spec =~ /\(\"([\w\-]+)\"/) {
|
||||||
|
$sig_elem->setAttribute('name', StudlyCaps($1));
|
||||||
|
$sig_elem->setAttribute('cname', $1);
|
||||||
|
}
|
||||||
$sig_elem->setAttribute('when', $1) if ($spec =~ /_RUN_(\w+)/);
|
$sig_elem->setAttribute('when', $1) if ($spec =~ /_RUN_(\w+)/);
|
||||||
|
|
||||||
my $method = "";
|
my $method = "";
|
||||||
@ -523,7 +526,7 @@ sub addSignalElem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($class =~ /;\s*(\S+\s*\**)\s*\(\*\s*$method\)\s*\((.*)\);/) {
|
if ($class =~ /;\s*(\S+\s*\**)\s*\(\*\s*$method\)\s*\((.*?)\);/) {
|
||||||
$ret = $1; $parms = $2;
|
$ret = $1; $parms = $2;
|
||||||
addReturnElem($sig_elem, $ret);
|
addReturnElem($sig_elem, $ret);
|
||||||
if ($parms && ($parms ne "void")) {
|
if ($parms && ($parms ne "void")) {
|
||||||
|
@ -21,8 +21,8 @@ namespace GtkSamples {
|
|||||||
Gtk.Window win = new Gtk.Window (Gtk.WindowType.Toplevel);
|
Gtk.Window win = new Gtk.Window (Gtk.WindowType.Toplevel);
|
||||||
Console.WriteLine("Setting Title");
|
Console.WriteLine("Setting Title");
|
||||||
win.Title = "Gtk# Hello World";
|
win.Title = "Gtk# Hello World";
|
||||||
// win.Deleted += new EventHandler (Window_Delete);
|
win.DeleteEvent += new EventHandler (Window_Delete);
|
||||||
win.Show ();
|
win.ShowAll ();
|
||||||
Console.WriteLine("Entering event loop");
|
Console.WriteLine("Entering event loop");
|
||||||
Application.Run ();
|
Application.Run ();
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user