2002-06-24 Rachel Hestilow <hestilow@ximian.com>
* glib/EnumWrapper.cs: New class which holds an enum int. * glib/Value.cs: Add support for glib enum types. We needed to use EnumWrapper for this because otherwise the int operator wouldn't know which glib function to use. * generator/BoxedGen.cs, ClassBase.cs, Ctor.cs, EnumGen.cs, InterfaceGen.cs, Method.cs, ObjectGen.cs, Signal.cs, StructGen.cs: Create more doc stubs. * generator/Property.cs: Generate enum values correctly. * generator/Ctor.cs: Refactor generation to honor metadata-specified collision preference. * parser/Gtk.metadata: Added constructor collision preferences to all known clashes. * parse/Gdk.metadata: Added (for Pixbuf clashes). svn path=/trunk/gtk-sharp/; revision=5437
This commit is contained in:
parent
b10fe35ac0
commit
1f4ff5bb86
18 changed files with 320 additions and 39 deletions
22
ChangeLog
22
ChangeLog
|
@ -1,3 +1,25 @@
|
||||||
|
2002-06-24 Rachel Hestilow <hestilow@ximian.com>
|
||||||
|
|
||||||
|
* glib/EnumWrapper.cs: New class which holds an enum int.
|
||||||
|
|
||||||
|
* glib/Value.cs: Add support for glib enum types. We needed
|
||||||
|
to use EnumWrapper for this because otherwise the int operator
|
||||||
|
wouldn't know which glib function to use.
|
||||||
|
|
||||||
|
* generator/BoxedGen.cs, ClassBase.cs, Ctor.cs, EnumGen.cs,
|
||||||
|
InterfaceGen.cs, Method.cs, ObjectGen.cs, Signal.cs, StructGen.cs:
|
||||||
|
Create more doc stubs.
|
||||||
|
|
||||||
|
* generator/Property.cs: Generate enum values correctly.
|
||||||
|
|
||||||
|
* generator/Ctor.cs: Refactor generation to honor metadata-specified
|
||||||
|
collision preference.
|
||||||
|
|
||||||
|
* parser/Gtk.metadata: Added constructor collision preferences to
|
||||||
|
all known clashes.
|
||||||
|
|
||||||
|
* parse/Gdk.metadata: Added (for Pixbuf clashes).
|
||||||
|
|
||||||
2002-06-24 Duncan Mak <duncan@ximian.com>
|
2002-06-24 Duncan Mak <duncan@ximian.com>
|
||||||
|
|
||||||
* glue/fileselection.c: New file, defines accessor functions to
|
* glue/fileselection.c: New file, defines accessor functions to
|
||||||
|
|
|
@ -34,6 +34,10 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
|
sw.WriteLine("\t\t/// <summary> " + Name + " Boxed Struct</summary>");
|
||||||
|
sw.WriteLine("\t\t/// <remarks>");
|
||||||
|
sw.WriteLine("\t\t/// </remarks>");
|
||||||
|
|
||||||
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
|
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
|
||||||
sw.WriteLine ("\tpublic class " + Name + " : GLib.Boxed {");
|
sw.WriteLine ("\tpublic class " + Name + " : GLib.Boxed {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
|
@ -101,14 +101,14 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenSignals (StreamWriter sw)
|
public void GenSignals (StreamWriter sw, bool gen_docs)
|
||||||
{
|
{
|
||||||
if (sigs == null)
|
if (sigs == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (Signal sig in sigs.Values) {
|
foreach (Signal sig in sigs.Values) {
|
||||||
if (sig.Validate ())
|
if (sig.Validate ())
|
||||||
sig.Generate (sw);
|
sig.Generate (sw, gen_docs);
|
||||||
else
|
else
|
||||||
Console.WriteLine(" in Object " + Name);
|
Console.WriteLine(" in Object " + Name);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ namespace GtkSharp.Generation {
|
||||||
(props != null) && props.ContainsKey(mname.Substring(3)));
|
(props != null) && props.ContainsKey(mname.Substring(3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenMethods (StreamWriter sw, Hashtable collisions)
|
public void GenMethods (StreamWriter sw, Hashtable collisions, bool gen_docs)
|
||||||
{
|
{
|
||||||
if (methods == null)
|
if (methods == null)
|
||||||
return;
|
return;
|
||||||
|
@ -154,7 +154,7 @@ namespace GtkSharp.Generation {
|
||||||
method.Name = Name + "." + method.Name;
|
method.Name = Name + "." + method.Name;
|
||||||
method.Protection = "";
|
method.Protection = "";
|
||||||
}
|
}
|
||||||
method.Generate (sw);
|
method.Generate (sw, gen_docs);
|
||||||
if (oname != null)
|
if (oname != null)
|
||||||
{
|
{
|
||||||
method.Name = oname;
|
method.Name = oname;
|
||||||
|
|
|
@ -16,13 +16,21 @@ namespace GtkSharp.Generation {
|
||||||
private string libname;
|
private string libname;
|
||||||
private XmlElement elem;
|
private XmlElement elem;
|
||||||
private Parameters parms;
|
private Parameters parms;
|
||||||
|
private bool preferred;
|
||||||
|
|
||||||
|
public bool Preferred {
|
||||||
|
get { return preferred; }
|
||||||
|
set { preferred = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public Ctor (string libname, XmlElement elem) {
|
public Ctor (string libname, XmlElement elem) {
|
||||||
this.libname = libname;
|
this.libname = libname;
|
||||||
this.elem = elem;
|
this.elem = elem;
|
||||||
XmlElement parms_elem = elem ["parameters"];
|
XmlElement parms_elem = elem ["parameters"];
|
||||||
if (parms_elem != null)
|
if (parms_elem != null)
|
||||||
parms = new Parameters (parms_elem);
|
parms = new Parameters (parms_elem);
|
||||||
|
if (elem.HasAttribute ("preferred"))
|
||||||
|
preferred = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Validate ()
|
public bool Validate ()
|
||||||
|
@ -39,6 +47,18 @@ namespace GtkSharp.Generation {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void InitClashMap (Hashtable clash_map)
|
||||||
|
{
|
||||||
|
string sigtypes = (parms != null) ? parms.SignatureTypes : "";
|
||||||
|
if (clash_map.ContainsKey (sigtypes)) {
|
||||||
|
int num = (int) clash_map[sigtypes];
|
||||||
|
clash_map[sigtypes] = ++num;
|
||||||
|
Console.WriteLine ("CLASH: {0} {1}", elem.GetAttribute ("cname"), num);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
clash_map[sigtypes] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public void Generate (StreamWriter sw, Hashtable clash_map)
|
public void Generate (StreamWriter sw, Hashtable clash_map)
|
||||||
{
|
{
|
||||||
string sigtypes = "";
|
string sigtypes = "";
|
||||||
|
@ -52,12 +72,7 @@ namespace GtkSharp.Generation {
|
||||||
sigtypes = parms.SignatureTypes;
|
sigtypes = parms.SignatureTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool clash = false;
|
int clashes = (int) clash_map[sigtypes];
|
||||||
if (clash_map.ContainsKey(sigtypes)) {
|
|
||||||
clash = true;
|
|
||||||
} else {
|
|
||||||
clash_map[sigtypes] = elem;
|
|
||||||
}
|
|
||||||
|
|
||||||
string cname = elem.GetAttribute("cname");
|
string cname = elem.GetAttribute("cname");
|
||||||
string name = ((XmlElement)elem.ParentNode).GetAttribute("name");
|
string name = ((XmlElement)elem.ParentNode).GetAttribute("name");
|
||||||
|
@ -71,7 +86,7 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine("\t\tstatic extern " + safety + "IntPtr " + cname + isig);
|
sw.WriteLine("\t\tstatic extern " + safety + "IntPtr " + cname + isig);
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
|
||||||
if (clash) {
|
if (clashes > 0 && !Preferred) {
|
||||||
String mname = cname.Substring(cname.IndexOf("new"));
|
String mname = cname.Substring(cname.IndexOf("new"));
|
||||||
mname = mname.Substring(0,1).ToUpper() + mname.Substring(1);
|
mname = mname.Substring(0,1).ToUpper() + mname.Substring(1);
|
||||||
int idx;
|
int idx;
|
||||||
|
|
|
@ -38,9 +38,15 @@ namespace GtkSharp.Generation {
|
||||||
if (Elem.GetAttribute("type") == "flags") {
|
if (Elem.GetAttribute("type") == "flags") {
|
||||||
sw.WriteLine ("\tusing System;");
|
sw.WriteLine ("\tusing System;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t[Flags]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sw.WriteLine("\t\t/// <summary> " + Name + " enumeration </summary>");
|
||||||
|
sw.WriteLine("\t\t/// <remarks>");
|
||||||
|
sw.WriteLine("\t\t/// </remarks>");
|
||||||
|
|
||||||
|
if (Elem.GetAttribute("type") == "flags")
|
||||||
|
sw.WriteLine ("\t[Flags]");
|
||||||
|
|
||||||
sw.WriteLine ("\tpublic enum " + Name + " {");
|
sw.WriteLine ("\tpublic enum " + Name + " {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
|
@ -50,6 +56,11 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlElement member = (XmlElement) node;
|
XmlElement member = (XmlElement) node;
|
||||||
|
|
||||||
|
sw.WriteLine("\t\t/// <summary />");
|
||||||
|
sw.WriteLine("\t\t/// <remarks>");
|
||||||
|
sw.WriteLine("\t\t/// </remarks>");
|
||||||
|
|
||||||
sw.Write ("\t\t" + member.GetAttribute("name"));
|
sw.Write ("\t\t" + member.GetAttribute("name"));
|
||||||
if (member.HasAttribute("value")) {
|
if (member.HasAttribute("value")) {
|
||||||
sw.WriteLine (" = " + member.GetAttribute("value") + ",");
|
sw.WriteLine (" = " + member.GetAttribute("value") + ",");
|
||||||
|
|
|
@ -21,6 +21,10 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ("\tusing System;");
|
sw.WriteLine ("\tusing System;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
|
sw.WriteLine("\t\t/// <summary> " + Name + " Interface</summary>");
|
||||||
|
sw.WriteLine("\t\t/// <remarks>");
|
||||||
|
sw.WriteLine("\t\t/// </remarks>");
|
||||||
|
|
||||||
sw.WriteLine ("\tpublic interface " + Name + " : GLib.IWrapper {");
|
sw.WriteLine ("\tpublic interface " + Name + " : GLib.IWrapper {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,8 @@ namespace GtkSharp.Generation {
|
||||||
if (!Initialize ())
|
if (!Initialize ())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
GenerateComments (sw);
|
||||||
|
|
||||||
if (is_get || is_set)
|
if (is_get || is_set)
|
||||||
{
|
{
|
||||||
Method comp = GetComplement ();
|
Method comp = GetComplement ();
|
||||||
|
@ -219,6 +221,21 @@ namespace GtkSharp.Generation {
|
||||||
Statistics.MethodCount++;
|
Statistics.MethodCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GenerateComments (StreamWriter sw)
|
||||||
|
{
|
||||||
|
string summary, sname;
|
||||||
|
sw.WriteLine();
|
||||||
|
if (is_get || is_set) {
|
||||||
|
summary = "Property";
|
||||||
|
sname = Name.Substring (3);
|
||||||
|
} else {
|
||||||
|
summary = "Method";
|
||||||
|
sname = Name;
|
||||||
|
}
|
||||||
|
sw.WriteLine("\t\t/// <summary> " + sname + " " + summary + " </summary>");
|
||||||
|
sw.WriteLine("\t\t/// <remarks> To be completed </remarks>");
|
||||||
|
}
|
||||||
|
|
||||||
protected void GenerateImport (StreamWriter sw)
|
protected void GenerateImport (StreamWriter sw)
|
||||||
{
|
{
|
||||||
sw.WriteLine("\t\t[DllImport(\"" + libname + "\")]");
|
sw.WriteLine("\t\t[DllImport(\"" + libname + "\")]");
|
||||||
|
@ -227,6 +244,11 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Generate (StreamWriter sw)
|
public void Generate (StreamWriter sw)
|
||||||
|
{
|
||||||
|
Generate (sw, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Generate (StreamWriter sw, bool gen_docs)
|
||||||
{
|
{
|
||||||
Method comp = null;
|
Method comp = null;
|
||||||
|
|
||||||
|
@ -255,12 +277,8 @@ namespace GtkSharp.Generation {
|
||||||
if (comp != null && s_ret == comp.parms.AccessorReturnType)
|
if (comp != null && s_ret == comp.parms.AccessorReturnType)
|
||||||
comp.GenerateImport (sw);
|
comp.GenerateImport (sw);
|
||||||
|
|
||||||
if (!(is_set || is_get))
|
if (gen_docs)
|
||||||
{
|
GenerateComments (sw);
|
||||||
sw.WriteLine("\t\t/// <summary> " + Name + " Method </summary>");
|
|
||||||
sw.WriteLine("\t\t/// <remarks> To be completed </remarks>");
|
|
||||||
sw.WriteLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
sw.Write("\t\t");
|
sw.Write("\t\t");
|
||||||
if (protection != "")
|
if (protection != "")
|
||||||
|
|
|
@ -55,6 +55,9 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
|
sw.WriteLine("\t\t/// <summary> " + Name + " Class</summary>");
|
||||||
|
sw.WriteLine("\t\t/// <remarks>");
|
||||||
|
sw.WriteLine("\t\t/// </remarks>");
|
||||||
sw.Write ("\tpublic class " + Name);
|
sw.Write ("\tpublic class " + Name);
|
||||||
string cs_parent = SymbolTable.GetCSType(Elem.GetAttribute("parent"));
|
string cs_parent = SymbolTable.GetCSType(Elem.GetAttribute("parent"));
|
||||||
if (cs_parent != "")
|
if (cs_parent != "")
|
||||||
|
@ -84,10 +87,10 @@ namespace GtkSharp.Generation {
|
||||||
if (has_sigs)
|
if (has_sigs)
|
||||||
{
|
{
|
||||||
sw.WriteLine("\t\tprivate Hashtable Signals = new Hashtable();");
|
sw.WriteLine("\t\tprivate Hashtable Signals = new Hashtable();");
|
||||||
GenSignals (sw);
|
GenSignals (sw, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
GenMethods (sw, null);
|
GenMethods (sw, null, true);
|
||||||
|
|
||||||
if (interfaces != null) {
|
if (interfaces != null) {
|
||||||
Hashtable all_methods = new Hashtable ();
|
Hashtable all_methods = new Hashtable ();
|
||||||
|
@ -104,8 +107,8 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
foreach (string iface in interfaces) {
|
foreach (string iface in interfaces) {
|
||||||
ClassBase igen = SymbolTable.GetClassGen (iface);
|
ClassBase igen = SymbolTable.GetClassGen (iface);
|
||||||
igen.GenMethods (sw, collisions);
|
igen.GenMethods (sw, collisions, false);
|
||||||
igen.GenSignals (sw);
|
igen.GenSignals (sw, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,13 +162,26 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
Hashtable clash_map = new Hashtable();
|
Hashtable clash_map = new Hashtable();
|
||||||
|
|
||||||
if (ctors != null)
|
if (ctors != null) {
|
||||||
|
bool has_preferred = false;
|
||||||
foreach (Ctor ctor in ctors) {
|
foreach (Ctor ctor in ctors) {
|
||||||
if (ctor.Validate ())
|
if (ctor.Validate ()) {
|
||||||
ctor.Generate (sw, clash_map);
|
ctor.InitClashMap (clash_map);
|
||||||
|
if (ctor.Preferred)
|
||||||
|
has_preferred = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Console.WriteLine(" in Object " + Name);
|
Console.WriteLine(" in Object " + Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!has_preferred && ctors.Count > 0)
|
||||||
|
((Ctor) ctors[0]).Preferred = true;
|
||||||
|
|
||||||
|
foreach (Ctor ctor in ctors) {
|
||||||
|
if (ctor.Validate ())
|
||||||
|
ctor.Generate (sw, clash_map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!clash_map.ContainsKey("")) {
|
if (!clash_map.ContainsKey("")) {
|
||||||
sw.WriteLine("\t\tprotected " + Name + "() : base(){}");
|
sw.WriteLine("\t\tprotected " + Name + "() : base(){}");
|
||||||
|
|
|
@ -55,22 +55,27 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
string v_type = "";
|
string v_type = "";
|
||||||
if (SymbolTable.IsEnum(c_type)) {
|
if (SymbolTable.IsEnum(c_type)) {
|
||||||
v_type = "int";
|
v_type = "(int) (GLib.EnumWrapper)";
|
||||||
} else if (SymbolTable.IsInterface(c_type)) {
|
} else if (SymbolTable.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;
|
return;
|
||||||
} else if (SymbolTable.IsObject(c_type)) {
|
} else if (SymbolTable.IsObject(c_type)) {
|
||||||
v_type = "GLib.Object";
|
v_type = "(GLib.Object)";
|
||||||
} else if (SymbolTable.IsBoxed (c_type)) {
|
} else if (SymbolTable.IsBoxed (c_type)) {
|
||||||
v_type = "GLib.Boxed";
|
v_type = "(GLib.Boxed)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem.HasAttribute("construct-only") && !elem.HasAttribute("readable")) {
|
if (elem.HasAttribute("construct-only") && !elem.HasAttribute("readable")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sw.WriteLine();
|
||||||
|
sw.WriteLine("\t\t/// <summary> " + name + " Property </summary>");
|
||||||
|
sw.WriteLine("\t\t/// <remarks>");
|
||||||
|
sw.WriteLine("\t\t/// </remarks>");
|
||||||
|
|
||||||
sw.WriteLine("\t\tpublic " + cs_type + " " + name + " {");
|
sw.WriteLine("\t\tpublic " + cs_type + " " + name + " {");
|
||||||
if (elem.HasAttribute("readable")) {
|
if (elem.HasAttribute("readable")) {
|
||||||
sw.WriteLine("\t\t\tget {");
|
sw.WriteLine("\t\t\tget {");
|
||||||
|
@ -78,7 +83,7 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine("\t\t\t\tGetProperty(" + cname + ", val);");
|
sw.WriteLine("\t\t\t\tGetProperty(" + cname + ", val);");
|
||||||
sw.Write("\t\t\t\treturn (" + cs_type + ") ");
|
sw.Write("\t\t\t\treturn (" + cs_type + ") ");
|
||||||
if (v_type != "") {
|
if (v_type != "") {
|
||||||
sw.Write("(" + v_type + ") ");
|
sw.Write(v_type + " ");
|
||||||
}
|
}
|
||||||
sw.WriteLine("val;");
|
sw.WriteLine("val;");
|
||||||
sw.WriteLine("\t\t\t}");
|
sw.WriteLine("\t\t\t}");
|
||||||
|
@ -87,10 +92,14 @@ namespace GtkSharp.Generation {
|
||||||
if (elem.HasAttribute("writeable") && !elem.HasAttribute("construct-only")) {
|
if (elem.HasAttribute("writeable") && !elem.HasAttribute("construct-only")) {
|
||||||
sw.WriteLine("\t\t\tset {");
|
sw.WriteLine("\t\t\tset {");
|
||||||
sw.Write("\t\t\t\tSetProperty(" + cname + ", new GLib.Value(");
|
sw.Write("\t\t\t\tSetProperty(" + cname + ", new GLib.Value(");
|
||||||
if (v_type != "") {
|
if (SymbolTable.IsEnum(c_type)) {
|
||||||
sw.Write("(" + v_type + ") ");
|
sw.WriteLine("Handle, " + cname + ", new GLib.EnumWrapper ((int) value)));");
|
||||||
|
} else {
|
||||||
|
if (v_type != "") {
|
||||||
|
sw.Write(v_type + " ");
|
||||||
|
}
|
||||||
|
sw.WriteLine("value));");
|
||||||
}
|
}
|
||||||
sw.WriteLine("value));");
|
|
||||||
sw.WriteLine("\t\t\t}");
|
sw.WriteLine("\t\t\t}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,21 +46,28 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public void GenerateDecl (StreamWriter sw)
|
public void GenerateDecl (StreamWriter sw)
|
||||||
{
|
{
|
||||||
|
GenComments (sw);
|
||||||
if (elem.HasAttribute("new_flag"))
|
if (elem.HasAttribute("new_flag"))
|
||||||
sw.Write("new ");
|
sw.Write("new ");
|
||||||
sw.WriteLine ("\t\tevent EventHandler " + Name + ";");
|
sw.WriteLine ("\t\tevent EventHandler " + Name + ";");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Generate (StreamWriter sw)
|
public void GenComments (StreamWriter sw)
|
||||||
{
|
{
|
||||||
string cname = "\"" + elem.GetAttribute("cname") + "\"";
|
sw.WriteLine();
|
||||||
marsh = "GtkSharp." + marsh;
|
|
||||||
|
|
||||||
sw.WriteLine("\t\t/// <summary> " + Name + " 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();
|
}
|
||||||
|
|
||||||
|
public void Generate (StreamWriter sw, bool gen_docs)
|
||||||
|
{
|
||||||
|
string cname = "\"" + elem.GetAttribute("cname") + "\"";
|
||||||
|
marsh = "GtkSharp." + marsh;
|
||||||
|
|
||||||
|
if (gen_docs)
|
||||||
|
GenComments (sw);
|
||||||
sw.Write("\t\tpublic ");
|
sw.Write("\t\tpublic ");
|
||||||
if (elem.HasAttribute("new_flag"))
|
if (elem.HasAttribute("new_flag"))
|
||||||
sw.Write("new ");
|
sw.Write("new ");
|
||||||
|
|
|
@ -40,6 +40,10 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
|
sw.WriteLine("\t\t/// <summary> " + Name + " Struct </summary>");
|
||||||
|
sw.WriteLine("\t\t/// <remarks>");
|
||||||
|
sw.WriteLine("\t\t/// </remarks>");
|
||||||
|
|
||||||
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
|
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
|
||||||
sw.WriteLine ("\tpublic class " + Name + " {");
|
sw.WriteLine ("\tpublic class " + Name + " {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
File diff suppressed because one or more lines are too long
26
glib/EnumWrapper.cs
Normal file
26
glib/EnumWrapper.cs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// EnumWrapper.cs - Class to hold arbitrary glib enums
|
||||||
|
//
|
||||||
|
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||||
|
//
|
||||||
|
// (c) 2002 Rachel Hestilow
|
||||||
|
|
||||||
|
namespace GLib {
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// <summary> Enum wrapping class </summary>
|
||||||
|
// <remarks> </remarks>
|
||||||
|
public class EnumWrapper {
|
||||||
|
int val;
|
||||||
|
|
||||||
|
public EnumWrapper (int val) {
|
||||||
|
this.val = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static explicit operator int (EnumWrapper wrap) {
|
||||||
|
return wrap.val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -219,6 +219,23 @@ namespace GLib {
|
||||||
g_value_set_uint (_val, val);
|
g_value_set_uint (_val, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DllImport("gobject-2.0")]
|
||||||
|
static extern void g_value_set_enum (IntPtr val, int data);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Value Constructor
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// Constructs a Value from a specified enum wrapper.
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
|
public Value (IntPtr obj, string prop_name, EnumWrapper wrap)
|
||||||
|
{
|
||||||
|
_val = gtksharp_value_create_from_property (obj, prop_name);
|
||||||
|
g_value_set_enum (_val, (int) wrap);
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport("gobject-2.0")]
|
[DllImport("gobject-2.0")]
|
||||||
static extern bool g_value_get_boolean (IntPtr val);
|
static extern bool g_value_get_boolean (IntPtr val);
|
||||||
|
|
||||||
|
@ -400,6 +417,26 @@ namespace GLib {
|
||||||
return g_value_get_uint (val._val);
|
return g_value_get_uint (val._val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DllImport("gobject-2.0")]
|
||||||
|
static extern int g_value_get_enum (IntPtr val);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Value to Enum Conversion
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// Extracts an enum from a Value. Note, this method
|
||||||
|
/// will produce an exception if the Value does not hold an
|
||||||
|
/// enum value.
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
|
public static explicit operator EnumWrapper (Value val)
|
||||||
|
{
|
||||||
|
// FIXME: Insert an appropriate exception here if
|
||||||
|
// _val.type indicates an error.
|
||||||
|
return new EnumWrapper (g_value_get_enum (val._val));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle Property
|
/// Handle Property
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
17
parser/Gdk.metadata
Normal file
17
parser/Gdk.metadata
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<metadata>
|
||||||
|
|
||||||
|
<!-- constructor collision hints -->
|
||||||
|
<rule>
|
||||||
|
<class name="GdkPixbuf">
|
||||||
|
<constructor>gdk_pixbuf_new_from_file</constructor>
|
||||||
|
</class>
|
||||||
|
<data>
|
||||||
|
<attribute target="method">
|
||||||
|
<name>preferred</name>
|
||||||
|
<value>1</value>
|
||||||
|
</attribute>
|
||||||
|
</data>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
</metadata>
|
|
@ -56,6 +56,43 @@
|
||||||
</data>
|
</data>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
|
<!-- constructor collision hints -->
|
||||||
|
<rule>
|
||||||
|
<class name="GtkButton">
|
||||||
|
<constructor>gtk_button_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkCheckButton">
|
||||||
|
<constructor>gtk_check_button_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkRadioButton">
|
||||||
|
<constructor>gtk_radio_button_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkToggleButton">
|
||||||
|
<constructor>gtk_toggle_button_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkLabel">
|
||||||
|
<constructor>gtk_label_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkMenuItem">
|
||||||
|
<constructor>gtk_menu_item_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkCheckMenuItem">
|
||||||
|
<constructor>gtk_check_menu_item_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkRadioMenuItem">
|
||||||
|
<constructor>gtk_radio_menu_item_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkImageMenuItem">
|
||||||
|
<constructor>gtk_image_menu_item_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<data>
|
||||||
|
<attribute target="method">
|
||||||
|
<name>preferred</name>
|
||||||
|
<value>1</value>
|
||||||
|
</attribute>
|
||||||
|
</data>
|
||||||
|
</rule>
|
||||||
|
|
||||||
<!-- renames -->
|
<!-- renames -->
|
||||||
<rule>
|
<rule>
|
||||||
<class name="GtkEditable">
|
<class name="GtkEditable">
|
||||||
|
|
17
sources/Gdk.metadata
Normal file
17
sources/Gdk.metadata
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<metadata>
|
||||||
|
|
||||||
|
<!-- constructor collision hints -->
|
||||||
|
<rule>
|
||||||
|
<class name="GdkPixbuf">
|
||||||
|
<constructor>gdk_pixbuf_new_from_file</constructor>
|
||||||
|
</class>
|
||||||
|
<data>
|
||||||
|
<attribute target="method">
|
||||||
|
<name>preferred</name>
|
||||||
|
<value>1</value>
|
||||||
|
</attribute>
|
||||||
|
</data>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
</metadata>
|
|
@ -56,6 +56,43 @@
|
||||||
</data>
|
</data>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
|
<!-- constructor collision hints -->
|
||||||
|
<rule>
|
||||||
|
<class name="GtkButton">
|
||||||
|
<constructor>gtk_button_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkCheckButton">
|
||||||
|
<constructor>gtk_check_button_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkRadioButton">
|
||||||
|
<constructor>gtk_radio_button_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkToggleButton">
|
||||||
|
<constructor>gtk_toggle_button_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkLabel">
|
||||||
|
<constructor>gtk_label_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkMenuItem">
|
||||||
|
<constructor>gtk_menu_item_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkCheckMenuItem">
|
||||||
|
<constructor>gtk_check_menu_item_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkRadioMenuItem">
|
||||||
|
<constructor>gtk_radio_menu_item_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<class name="GtkImageMenuItem">
|
||||||
|
<constructor>gtk_image_menu_item_new_with_mnemonic</constructor>
|
||||||
|
</class>
|
||||||
|
<data>
|
||||||
|
<attribute target="method">
|
||||||
|
<name>preferred</name>
|
||||||
|
<value>1</value>
|
||||||
|
</attribute>
|
||||||
|
</data>
|
||||||
|
</rule>
|
||||||
|
|
||||||
<!-- renames -->
|
<!-- renames -->
|
||||||
<rule>
|
<rule>
|
||||||
<class name="GtkEditable">
|
<class name="GtkEditable">
|
||||||
|
|
Loading…
Add table
Reference in a new issue