2002-06-21 Rachel Hestilow <hestilow@ximian.com>

* generator/ClassBase.cs: New base class for classes and interfaces.

	* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.

	* generator/ObjectGen.cs: Move half of this into ClassBase.

	* generator/Method.cs: Turn all applicable Get/Set functions into .NET
	accessors. Remove redundant == overload and move into Equals, as
	it was confusing "!= null".

	* generator/Parameters.cs: Alter signature creation to accept "is_set"
	option, add support for variable arguments. Add properties "Count",
	"IsVarArgs", "VAType".

	* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
	signature creation).

	* generator/Signal.cs: Support generating declarations.

	* generator/SymbolTable: Change GetObjectGen to GetClassGen.

	* glib/IWrapper.cs: Move "Handle" declaration to here, so
	both classes and interfaces can benefit from it.

	* glib/Object.cs: Inherit from IWrapper.cs

	* parser/Metadata.pm: Support attribute changes on constructors,
	methods, signals, and paramater lists.

	* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
	functions here.

	* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
	be caught in the init funcs.

	* parser/Atk.metadata: Added.

	* parser/Gtk.metadata: Add all needed signal/method collision
	renames. Rename GtkEditable.Editable accessors to IsEditable,
	as .NET does not like accessors with the same name as their
	declaring type. Tag TreeStore constructor as varargs.

	* samples/ButtonApp.cs: s/EmitAdd/Add.

	* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.

svn path=/trunk/gtk-sharp/; revision=5394
This commit is contained in:
Rachel Hestilow 2002-06-21 17:15:19 +00:00
parent f8c7fff45e
commit 6857128f07
24 changed files with 2657 additions and 288 deletions

View file

@ -1,3 +1,51 @@
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
2002-06-21 Mike Kestner <mkestner@speakeasy.net> 2002-06-21 Mike Kestner <mkestner@speakeasy.net>
* */makefile.win32 : add /doc flags * */makefile.win32 : add /doc flags

149
generator/ClassBase.cs Normal file
View file

@ -0,0 +1,149 @@
// GtkSharp.Generation.ClassBase.cs - Common code between object
// and interface wrappers
//
// Authors: Rachel Hestilow <hestilow@ximian.com>
// Mike Kestner <mkestner@speakeasy.net>
//
// (c) 2002 Rachel Hestilow, 2001-2002 Mike Kestner
namespace GtkSharp.Generation {
using System;
using System.Collections;
using System.IO;
using System.Xml;
public class ClassBase : GenBase {
protected Hashtable props = new Hashtable();
protected Hashtable sigs = new Hashtable();
protected Hashtable methods = new Hashtable();
protected ArrayList interfaces = null;
protected ClassBase (string ns, XmlElement elem) : base (ns, elem) {
foreach (XmlNode node in elem.ChildNodes) {
XmlElement member = (XmlElement) node;
switch (node.Name) {
case "method":
methods.Add (member.GetAttribute ("name"), new Method (ns, member, this));
break;
case "property":
props.Add (member.GetAttribute ("name"), new Property (member));
break;
case "signal":
sigs.Add (member.GetAttribute ("name"), new Signal (ns, member));
break;
case "implements":
interfaces = ParseImplements (member);
break;
default:
break;
}
}
}
protected bool IsNodeNameHandled (string name)
{
switch (name) {
case "method":
case "property":
case "signal":
case "implements":
return true;
default:
return false;
}
}
public String MarshalType {
get
{
return "IntPtr";
}
}
public String CallByName (String var_name)
{
return var_name + ".Handle";
}
public String FromNative(String var)
{
return "(" + QualifiedName + ") GLib.Object.GetObject(" + var + ")";
}
protected void GenProperties (StreamWriter sw)
{
if (props == null)
return;
foreach (Property prop in props.Values) {
if (prop.Validate ())
prop.Generate (sw);
else
Console.WriteLine(" in Object " + Name);
}
}
protected void GenSignals (StreamWriter sw)
{
if (sigs == null)
return;
sw.WriteLine("\t\tprivate Hashtable Signals = new Hashtable();");
foreach (Signal sig in sigs.Values) {
if (sig.Validate ())
sig.Generate (sw);
else
Console.WriteLine(" in Object " + Name);
}
}
private ArrayList ParseImplements (XmlElement member)
{
ArrayList ifaces = new ArrayList ();
foreach (XmlNode node in member.ChildNodes) {
if (node.Name != "interface")
continue;
XmlElement element = (XmlElement) node;
ifaces.Add (element.GetAttribute ("cname"));
}
return ifaces;
}
protected bool IgnoreMethod (Method method)
{
string mname = method.Name;
return ((mname.StartsWith("Set") || mname.StartsWith("Get")) &&
(props != null) && props.ContainsKey(mname.Substring(3)));
}
protected void GenMethods (StreamWriter sw)
{
if (methods == null)
return;
foreach (Method method in methods.Values) {
if (IgnoreMethod (method))
continue;
if (method.Validate ())
method.Generate (sw);
else
Console.WriteLine(" in Object " + Name);
}
}
public Method GetMethod (string name)
{
return (Method) methods[name];
}
}
}

View file

@ -27,10 +27,13 @@ namespace GtkSharp.Generation {
public bool Validate () public bool Validate ()
{ {
if ((parms != null) && !parms.Validate ()) { if (parms != null) {
Console.Write("ctor "); if (!parms.Validate ()) {
Statistics.ThrottledCount++; Console.Write("ctor ");
return false; Statistics.ThrottledCount++;
return false;
}
parms.CreateSignature (false);
} }
return true; return true;
@ -79,19 +82,19 @@ namespace GtkSharp.Generation {
sw.WriteLine("\t\tpublic static " + safety + name + " " + mname + sig); sw.WriteLine("\t\tpublic static " + safety + name + " " + mname + sig);
sw.WriteLine("\t\t{"); sw.WriteLine("\t\t{");
if (parms != null) if (parms != null)
parms.Initialize(sw, false); parms.Initialize(sw, false, "");
sw.WriteLine("\t\t\tIntPtr ret = " + cname + call + ";"); sw.WriteLine("\t\t\tIntPtr ret = " + cname + call + ";");
if (parms != null) if (parms != null)
parms.HandleException (sw); parms.HandleException (sw, "");
sw.WriteLine("\t\t\treturn new " + name + "(ret);"); sw.WriteLine("\t\t\treturn new " + name + "(ret);");
} else { } else {
sw.WriteLine("\t\tpublic " + safety + name + sig); sw.WriteLine("\t\tpublic " + safety + name + sig);
sw.WriteLine("\t\t{"); sw.WriteLine("\t\t{");
if (parms != null) if (parms != null)
parms.Initialize(sw, false); parms.Initialize(sw, false, "");
sw.WriteLine("\t\t\tRaw = " + cname + call + ";"); sw.WriteLine("\t\t\tRaw = " + cname + call + ";");
if (parms != null) if (parms != null)
parms.HandleException (sw); parms.HandleException (sw, "");
} }
sw.WriteLine("\t\t}"); sw.WriteLine("\t\t}");

View file

@ -10,27 +10,10 @@ namespace GtkSharp.Generation {
using System.IO; using System.IO;
using System.Xml; using System.Xml;
public class InterfaceGen : GenBase, IGeneratable { public class InterfaceGen : ClassBase, IGeneratable {
public InterfaceGen (string ns, XmlElement elem) : base (ns, elem) {} public InterfaceGen (string ns, XmlElement elem) : base (ns, elem) {}
public String MarshalType {
get
{
return "";
}
}
public String CallByName (String var_name)
{
return "";
}
public String FromNative(String var)
{
return "";
}
public void Generate () public void Generate ()
{ {
StreamWriter sw = CreateWriter (); StreamWriter sw = CreateWriter ();
@ -38,22 +21,26 @@ namespace GtkSharp.Generation {
sw.WriteLine ("\tusing System;"); sw.WriteLine ("\tusing System;");
sw.WriteLine (); sw.WriteLine ();
sw.WriteLine ("\tpublic interface " + Name + " {"); sw.WriteLine ("\tpublic interface " + Name + " : GLib.IWrapper {");
sw.WriteLine (); sw.WriteLine ();
foreach (Signal sig in sigs.Values) {
if (sig.Validate ())
sig.GenerateDecl (sw);
}
foreach (XmlNode node in Elem.ChildNodes) { foreach (Method method in methods.Values) {
if (node.Name != "member") { if (IgnoreMethod (method))
continue; continue;
}
//FIXME: Generate the methods. if (method.Validate ())
XmlElement member = (XmlElement) node; method.GenerateDecl (sw);
} }
sw.WriteLine ("\t}"); sw.WriteLine ("\t}");
CloseWriter (sw); CloseWriter (sw);
Statistics.IFaceCount++; Statistics.IFaceCount++;
} }
} }
} }

View file

@ -16,21 +16,30 @@ namespace GtkSharp.Generation {
private string ns; private string ns;
private XmlElement elem; private XmlElement elem;
private Parameters parms; private Parameters parms;
private ClassBase container_type;
public Method (string ns, XmlElement elem)
private bool initialized = false;
private string sig, isig, call;
private string rettype, m_ret, s_ret;
private string name, cname, safety;
private bool is_get, is_set;
public Method (string ns, XmlElement elem, ClassBase container_type)
{ {
this.ns = ns; this.ns = ns;
this.elem = elem; this.elem = elem;
if (elem["parameters"] != null) if (elem["parameters"] != null)
parms = new Parameters (elem["parameters"]); parms = new Parameters (elem["parameters"]);
this.container_type = container_type;
this.name = elem.GetAttribute("name");
} }
public string Name { public string Name {
get { get {
return elem.GetAttribute("name"); return name;
} }
set { set {
elem.SetAttribute("name", value); name = value;
} }
} }
@ -44,12 +53,17 @@ namespace GtkSharp.Generation {
{ {
if (!(o is Method)) if (!(o is Method))
return false; return false;
/*
return (this == (Method) o); return (this == (Method) o);
} }
public static bool operator == (Method a, Method b) public static bool operator == (Method a, Method b)
{ {
if (a == null)
return (b
*/
Method a = this;
Method b = (Method) o;
if (a.Name != b.Name) if (a.Name != b.Name)
return false; return false;
@ -61,9 +75,10 @@ namespace GtkSharp.Generation {
return (a.Params.SignatureTypes == b.Params.SignatureTypes); return (a.Params.SignatureTypes == b.Params.SignatureTypes);
} }
/*
public static bool operator != (Method a, Method b) public static bool operator != (Method a, Method b)
{ {
return !(
if (a.Name == b.Name) if (a.Name == b.Name)
return false; return false;
@ -75,36 +90,37 @@ namespace GtkSharp.Generation {
return (a.Params.SignatureTypes != b.Params.SignatureTypes); return (a.Params.SignatureTypes != b.Params.SignatureTypes);
} }
*/
public bool Validate () private bool Initialize ()
{ {
if (initialized)
return true;
if (parms != null && !parms.Validate ())
return false;
XmlElement ret_elem = elem["return-type"]; XmlElement ret_elem = elem["return-type"];
if (ret_elem == null) { if (ret_elem == null) {
Console.Write("Missing return type in method "); Console.Write("Missing return type in method ");
Statistics.ThrottledCount++; Statistics.ThrottledCount++;
return false; return false;
} }
rettype = ret_elem.GetAttribute("type");
m_ret = SymbolTable.GetMarshalType(rettype);
s_ret = SymbolTable.GetCSType(rettype);
cname = elem.GetAttribute("cname");
string rettype = ret_elem.GetAttribute("type"); if (parms != null && parms.ThrowsException)
string m_ret = SymbolTable.GetMarshalType(rettype); safety = "unsafe ";
string s_ret = SymbolTable.GetCSType(rettype); else
if (m_ret == "" || s_ret == "") { safety = "";
Console.Write("rettype: " + rettype + " method ");
Statistics.ThrottledCount++;
return false;
}
if (Params == null) is_get = ((parms != null && (parms.IsAccessor || (parms.Count == 0 && s_ret != "void")) || (parms == null && s_ret != "void")) && Name.Substring(0, 3) == "Get");
return true; is_set = ((parms != null && (parms.IsAccessor || (parms.Count == 1 && s_ret == "void"))) && (Name.Substring(0, 3) == "Set"));
return Params.Validate ();
}
public void Generate (StreamWriter sw)
{
string sig, isig, call;
if (parms != null) { if (parms != null) {
parms.CreateSignature (is_set);
sig = "(" + parms.Signature + ")"; sig = "(" + parms.Signature + ")";
isig = "(IntPtr raw, " + parms.ImportSig + ");"; isig = "(IntPtr raw, " + parms.ImportSig + ");";
call = "(Handle, " + parms.CallString + ")"; call = "(Handle, " + parms.CallString + ")";
@ -114,70 +130,188 @@ namespace GtkSharp.Generation {
call = "(Handle)"; call = "(Handle)";
} }
string rettype = elem["return-type"].GetAttribute("type"); initialized = true;
string m_ret = SymbolTable.GetMarshalType(rettype); return true;
string s_ret = SymbolTable.GetCSType(rettype); }
string cname = elem.GetAttribute("cname");
public bool Validate ()
{
if (!Initialize ())
return false;
if (cname[0] == '_') { if (m_ret == "" || s_ret == "") {
Console.Write("rettype: " + rettype + " method ");
Statistics.ThrottledCount++; Statistics.ThrottledCount++;
return; return false;
} }
return true;
string safety; }
if (parms != null && parms.ThrowsException)
safety = "unsafe "; private Method GetComplement ()
{
char complement;
if (is_get)
complement = 'S';
else else
safety = ""; complement = 'G';
return container_type.GetMethod (complement + elem.GetAttribute("name").Substring (1));
}
private void GenerateDeclCommon (StreamWriter sw)
{
sw.Write(safety);
if (is_get || is_set) {
if (s_ret == "void")
s_ret = parms.AccessorReturnType;
sw.Write(s_ret);
sw.Write(" ");
sw.Write(Name.Substring (3));
sw.WriteLine(" { ");
} else {
if (elem.HasAttribute("new_flag"))
sw.Write("new ");
sw.Write(s_ret + " " + Name + sig);
}
}
sw.WriteLine("\t\t/// <summary> " + Name + " Method </summary>"); public void GenerateDecl (StreamWriter sw)
sw.WriteLine("\t\t/// <remarks> To be completed </remarks>"); {
sw.WriteLine(); if (!Initialize ())
return;
if (is_get || is_set)
{
Method comp = GetComplement ();
if (comp != null && comp.Validate () && is_set)
return;
sw.Write("\t\t");
GenerateDeclCommon (sw);
sw.Write("\t\t\t");
sw.Write ((is_get) ? "get;" : "set;");
if (comp != null && comp.is_set)
sw.WriteLine (" set;");
else
sw.WriteLine ();
sw.WriteLine ("\t\t}");
}
else
{
sw.Write("\t\t");
GenerateDeclCommon (sw);
sw.WriteLine (";");
}
Statistics.MethodCount++;
}
protected void GenerateImport (StreamWriter sw)
{
sw.WriteLine("\t\t[DllImport(\"" + SymbolTable.GetDllName(ns) + sw.WriteLine("\t\t[DllImport(\"" + SymbolTable.GetDllName(ns) +
"\", CallingConvention=CallingConvention.Cdecl)]"); "\", CallingConvention=CallingConvention.Cdecl)]");
sw.Write("\t\tstatic extern " + safety + m_ret + " " + cname + isig); sw.Write("\t\tstatic extern " + safety + m_ret + " " + cname + isig);
sw.WriteLine(); sw.WriteLine();
}
sw.Write("\t\tpublic " + safety); public void Generate (StreamWriter sw)
bool is_get = (parms != null && parms.IsAccessor && Name.Substring(0, 3) == "Get"); {
if (is_get) { Method comp = null;
s_ret = parms.AccessorReturnType;
sw.Write(s_ret); if (!Initialize ())
sw.Write(" "); return;
sw.Write(Name.Substring (3));
sw.Write(" { get"); /* we are generated by the get Method, if there is one */
} else { if (is_set || is_get)
if (elem.HasAttribute("new_flag")) {
sw.Write("new "); comp = GetComplement ();
sw.WriteLine(s_ret + " " + Name + sig); if (comp != null && comp.Validate () && is_set && parms.AccessorReturnType == comp.s_ret)
return;
if (comp != null && is_set && parms.AccessorReturnType != comp.s_ret)
{
is_set = false;
parms.CreateSignature (false);
call = "(Handle, " + parms.CallString + ")";
comp = null;
}
/* some setters take more than one arg */
if (comp != null && !comp.is_set)
comp = null;
} }
sw.WriteLine("\t\t{"); else {
if (parms != null) sw.WriteLine("\t\t/// <summary> " + Name + " Method </summary>");
parms.Initialize(sw, is_get); sw.WriteLine("\t\t/// <remarks> To be completed </remarks>");
sw.Write("\t\t\t"); sw.WriteLine();
if (is_get || m_ret == "void") {
sw.WriteLine(cname + call + ";");
} else {
sw.WriteLine(s_ret + " ret = " + SymbolTable.FromNative(rettype, cname + call) + ";");
} }
if (parms != null)
parms.HandleException (sw);
if (is_get) GenerateImport (sw);
sw.WriteLine ("\t\t\treturn " + parms.AccessorName + ";"); if (comp != null && s_ret == comp.parms.AccessorReturnType)
else if (m_ret != "void") comp.GenerateImport (sw);
sw.WriteLine ("\t\t\treturn ret;");
sw.Write("\t\tpublic ");
sw.Write("\t\t}"); GenerateDeclCommon (sw);
if (is_get)
sw.Write(" }"); if (is_get || is_set)
{
sw.Write ("\t\t\t");
sw.Write ((is_get) ? "get" : "set");
GenerateBody (sw, "\t");
}
else
GenerateBody (sw, "");
if (is_get || is_set)
{
if (comp != null && s_ret == comp.parms.AccessorReturnType)
{
sw.WriteLine ();
sw.Write ("\t\t\tset");
comp.GenerateBody (sw, "\t");
}
sw.WriteLine ();
sw.WriteLine ("\t\t}");
}
else
sw.WriteLine();
sw.WriteLine();
sw.WriteLine(); sw.WriteLine();
Statistics.MethodCount++; Statistics.MethodCount++;
} }
protected void GenerateBody (StreamWriter sw, string indent)
{
sw.WriteLine(" {");
if (parms != null)
parms.Initialize(sw, is_get, indent);
sw.Write(indent + "\t\t\t");
if (m_ret == "void") {
sw.WriteLine(cname + call + ";");
} else {
if (SymbolTable.IsObject (rettype))
{
sw.WriteLine(m_ret + " raw_ret = " + cname + call + ";");
sw.WriteLine(indent +"\t\t\t" + s_ret + " ret = " + SymbolTable.FromNative(rettype, "raw_ret") + ";");
sw.WriteLine(indent + "\t\t\tif (ret == null) ret = new " + s_ret + "(raw_ret);");
}
else
sw.WriteLine(s_ret + " ret = " + SymbolTable.FromNative(rettype, cname + call) + ";");
}
if (parms != null)
parms.HandleException (sw, indent);
if (is_get && parms != null)
sw.WriteLine (indent + "\t\t\treturn " + parms.AccessorName + ";");
else if (m_ret != "void")
sw.WriteLine (indent + "\t\t\treturn ret;");
sw.Write(indent + "\t\t}");
}
} }
} }

View file

@ -11,12 +11,9 @@ namespace GtkSharp.Generation {
using System.IO; using System.IO;
using System.Xml; using System.Xml;
public class ObjectGen : GenBase, IGeneratable { public class ObjectGen : ClassBase, IGeneratable {
private ArrayList ctors = new ArrayList(); private ArrayList ctors = new ArrayList();
private Hashtable props = new Hashtable();
private Hashtable sigs = new Hashtable();
private Hashtable methods = new Hashtable();
public ObjectGen (string ns, XmlElement elem) : base (ns, elem) public ObjectGen (string ns, XmlElement elem) : base (ns, elem)
{ {
@ -33,46 +30,19 @@ namespace GtkSharp.Generation {
case "constructor": case "constructor":
ctors.Add (new Ctor (ns, member)); ctors.Add (new Ctor (ns, member));
break; break;
case "method":
methods.Add (member.GetAttribute ("name"), new Method (ns, member));
break;
case "property":
props.Add (member.GetAttribute ("name"), new Property (member));
break;
case "signal":
sigs.Add (member.GetAttribute ("name"), new Signal (ns, member));
break;
default: default:
Console.WriteLine ("Unexpected node " + node.Name + " in " + CName); if (!IsNodeNameHandled (node.Name))
Console.WriteLine ("Unexpected node " + node.Name + " in " + CName);
break; break;
} }
} }
} }
public string MarshalType {
get {
return "IntPtr";
}
}
public string CallByName (string var_name)
{
return var_name + ".Handle";
}
public string FromNative(string var)
{
return "(" + QualifiedName + ") GLib.Object.GetObject(" + var + ")";
}
private ObjectGen Parent { private ObjectGen Parent {
get { get {
string parent = Elem.GetAttribute("parent"); string parent = Elem.GetAttribute("parent");
return SymbolTable.GetObjectGen(parent); return (ObjectGen) SymbolTable.GetClassGen(parent);
} }
} }
@ -89,6 +59,11 @@ namespace GtkSharp.Generation {
string cs_parent = SymbolTable.GetCSType(Elem.GetAttribute("parent")); string cs_parent = SymbolTable.GetCSType(Elem.GetAttribute("parent"));
if (cs_parent != "") if (cs_parent != "")
sw.Write (" : " + cs_parent); sw.Write (" : " + cs_parent);
if (interfaces != null) {
foreach (string iface in interfaces) {
sw.Write (", " + SymbolTable.GetCSType (iface));
}
}
sw.WriteLine (" {"); sw.WriteLine (" {");
sw.WriteLine (); sw.WriteLine ();
@ -96,6 +71,14 @@ namespace GtkSharp.Generation {
GenProperties (sw); GenProperties (sw);
GenSignals (sw); GenSignals (sw);
GenMethods (sw); GenMethods (sw);
if (interfaces != null) {
foreach (string iface in interfaces) {
ClassBase igen = SymbolTable.GetClassGen (iface);
igen.GenMethods (sw);
}
}
AppendCustom(Namespace, Name, sw); AppendCustom(Namespace, Name, sw);
sw.WriteLine ("\t}"); sw.WriteLine ("\t}");
@ -103,7 +86,7 @@ namespace GtkSharp.Generation {
CloseWriter (sw); CloseWriter (sw);
Statistics.ObjectCount++; Statistics.ObjectCount++;
} }
private bool Validate () private bool Validate ()
{ {
string parent = Elem.GetAttribute("parent"); string parent = Elem.GetAttribute("parent");
@ -133,6 +116,13 @@ namespace GtkSharp.Generation {
if (!method.Validate()) if (!method.Validate())
return false; return false;
if (interfaces != null) {
foreach (string iface in interfaces) {
if (SymbolTable.GetCSType(parent) == null)
return false;
}
}
return true; return true;
} }
@ -157,55 +147,6 @@ namespace GtkSharp.Generation {
} }
} }
private void GenProperties (StreamWriter sw)
{
if (props == null)
return;
foreach (Property prop in props.Values) {
if (prop.Validate ())
prop.Generate (sw);
else
Console.WriteLine(" in Object " + Name);
}
}
private void GenSignals (StreamWriter sw)
{
if (sigs == null)
return;
sw.WriteLine("\t\tprivate Hashtable Signals = new Hashtable();");
foreach (Signal sig in sigs.Values) {
if (sig.Validate ())
sig.Generate (sw);
else
Console.WriteLine(" in Object " + Name);
}
}
private void GenMethods (StreamWriter sw)
{
if (methods == null)
return;
foreach (Method method in methods.Values) {
string mname = method.Name;
if ((mname.StartsWith("Set") || mname.StartsWith("Get")) &&
(props != null) && props.ContainsKey(mname.Substring(3))) {
continue;
} else if ((sigs != null) && sigs.ContainsKey(mname)) {
method.Name = "Emit" + mname;
}
if (method.Validate ())
method.Generate (sw);
else
Console.WriteLine(" in Object " + Name);
}
}
} }
} }

View file

@ -49,9 +49,6 @@ namespace GtkSharp.Generation {
public bool Validate () public bool Validate ()
{ {
signature_types = signature = import_sig = call_string = "";
bool need_sep = false;
foreach (XmlNode parm in elem.ChildNodes) { foreach (XmlNode parm in elem.ChildNodes) {
if (parm.Name != "parameter") { if (parm.Name != "parameter") {
continue; continue;
@ -69,16 +66,58 @@ namespace GtkSharp.Generation {
Console.Write("Name: " + name + " Type: " + type + " "); Console.Write("Name: " + name + " Type: " + type + " ");
return false; return false;
} }
}
return true;
}
public void CreateSignature (bool is_set)
{
signature_types = signature = import_sig = call_string = "";
bool need_sep = false;
int len = 0;
XmlElement last_param;
foreach (XmlNode parm in elem.ChildNodes) {
if (parm.Name != "parameter") {
continue;
}
len++;
last_param = (XmlElement) parm;
}
int i = 0;
foreach (XmlNode parm in elem.ChildNodes) {
if (parm.Name != "parameter") {
continue;
}
XmlElement p_elem = (XmlElement) parm;
string type = p_elem.GetAttribute("type");
string cs_type = SymbolTable.GetCSType(type);
string m_type = SymbolTable.GetMarshalType(type);
string name = MangleName(p_elem.GetAttribute("name"));
string call_parm;
if (is_set && i == 0)
call_parm = SymbolTable.CallByName(type, "value");
else
call_parm = SymbolTable.CallByName(type, name);
if (p_elem.HasAttribute("array")) { if (p_elem.HasAttribute("array")) {
cs_type += "[]"; cs_type += "[]";
m_type += "[]"; m_type += "[]";
} }
if (IsVarArgs && i == (len - 1) && VAType == "length_param") {
cs_type = "params " + cs_type + "[]";
m_type += "[]";
}
if (need_sep) { if (need_sep) {
call_string += ", "; call_string += ", ";
import_sig += ", "; import_sig += ", ";
if (type != "GError**") if (type != "GError**" && !(IsVarArgs && i == (len - 1) && VAType == "length_param"))
{ {
signature += ", "; signature += ", ";
signature_types += ":"; signature_types += ":";
@ -88,24 +127,40 @@ namespace GtkSharp.Generation {
} }
if (p_elem.HasAttribute("pass_as")) { if (p_elem.HasAttribute("pass_as")) {
signature += p_elem.GetAttribute("pass_as") + " "; string pass_as = p_elem.GetAttribute("pass_as");
signature += pass_as + " ";
// We only need to do this for value types
if (type != "GError**" && m_type != "IntPtr" && m_type != "System.IntPtr")
{
import_sig += pass_as + " ";
call_string += "out ";
}
} }
else if (type == "GError**")
if (type == "GError**") { {
call_string += "out "; call_string += "out ";
import_sig += "out "; import_sig += "out ";
} else {
signature += (cs_type + " " + name);
signature_types += cs_type;
} }
call_string += call_parm;
if (IsVarArgs && i == (len - 2) && VAType == "length_param")
{
call_string += MangleName(last_param.GetAttribute("name")) + ".Length";
}
else
{
if (type != "GError**") {
signature += (cs_type + " " + name);
signature_types += cs_type;
}
call_string += call_parm;
}
import_sig += (m_type + " " + name); import_sig += (m_type + " " + name);
i++;
} }
return true;
} }
public void Initialize (StreamWriter sw, bool is_get) public void Initialize (StreamWriter sw, bool is_get, string indent)
{ {
string name = ""; string name = "";
foreach (XmlNode parm in elem.ChildNodes) { foreach (XmlNode parm in elem.ChildNodes) {
@ -115,28 +170,64 @@ namespace GtkSharp.Generation {
XmlElement p_elem = (XmlElement) parm; XmlElement p_elem = (XmlElement) parm;
string type = SymbolTable.GetCSType(p_elem.GetAttribute ("type")); string c_type = p_elem.GetAttribute ("type");
string type = SymbolTable.GetCSType(c_type);
name = MangleName(p_elem.GetAttribute("name")); name = MangleName(p_elem.GetAttribute("name"));
if (is_get) { if (is_get) {
sw.WriteLine ("\t\t\t" + type + " " + name + ";"); sw.WriteLine (indent + "\t\t\t" + type + " " + name + ";");
} }
if (is_get || (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out")) { if ((is_get || (p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out")) && (SymbolTable.IsObject (c_type) || SymbolTable.IsBoxed (c_type))) {
sw.WriteLine("\t\t\t" + name + " = new " + type + "();"); sw.WriteLine(indent + "\t\t\t" + name + " = new " + type + "();");
} }
} }
if (ThrowsException) if (ThrowsException)
sw.WriteLine ("\t\t\tIntPtr error;"); sw.WriteLine (indent + "\t\t\tIntPtr error;");
} }
/*
public void Finish (StreamWriter sw)
{
foreach (XmlNode parm in elem.ChildNodes) {
if (parm.Name != "parameter") {
continue;
}
XmlElement p_elem = (XmlElement) parm;
string c_type = p_elem.GetAttribute ("type");
string name = MangleName(p_elem.GetAttribute("name"));
public void HandleException (StreamWriter sw) if ((p_elem.HasAttribute("pass_as") && p_elem.GetAttribute ("pass_as") == "out")) {
string call_parm = SymbolTable.CallByName(c_type, name);
string local_parm = GetPossibleLocal (call_parm);
if (call_parm != local_parm)
sw.WriteLine ("\t\t\t{0} = {1};", call_parm, local_parm);
}
}
}
*/
public void HandleException (StreamWriter sw, string indent)
{ {
if (!ThrowsException) if (!ThrowsException)
return; return;
sw.WriteLine ("\t\t\tif (error != IntPtr.Zero) throw new GLib.GException (error);"); sw.WriteLine (indent + "\t\t\tif (error != IntPtr.Zero) throw new GLib.GException (error);");
} }
public int Count {
get {
int length = 0;
foreach (XmlNode parm in elem.ChildNodes) {
if (parm.Name != "parameter") {
continue;
}
length++;
}
return length;
}
}
public bool IsAccessor { public bool IsAccessor {
get { get {
int length = 0; int length = 0;
@ -169,6 +260,18 @@ namespace GtkSharp.Generation {
} }
} }
public bool IsVarArgs {
get {
return elem.HasAttribute ("va_type");
}
}
public string VAType {
get {
return elem.GetAttribute ("va_type");
}
}
public string AccessorReturnType { public string AccessorReturnType {
get { get {
foreach (XmlNode parm in elem.ChildNodes) { foreach (XmlNode parm in elem.ChildNodes) {

View file

@ -15,17 +15,22 @@ namespace GtkSharp.Generation {
private string ns; private string ns;
private string marsh; private string marsh;
private string name;
private XmlElement elem; private XmlElement elem;
public Signal (string ns, XmlElement elem) public Signal (string ns, XmlElement elem)
{ {
this.ns = ns; this.ns = ns;
this.elem = elem; this.elem = elem;
this.name = elem.GetAttribute ("name");
} }
public string Name { public string Name {
get { get {
return elem.GetAttribute ("name"); return name;
}
set {
name = value;
} }
} }
@ -41,6 +46,13 @@ namespace GtkSharp.Generation {
return true; return true;
} }
public void GenerateDecl (StreamWriter sw)
{
if (elem.HasAttribute("new_flag"))
sw.Write("new ");
sw.WriteLine ("\t\tevent EventHandler " + Name + ";");
}
public void Generate (StreamWriter sw) public void Generate (StreamWriter sw)
{ {
string cname = "\"" + elem.GetAttribute("cname") + "\""; string cname = "\"" + elem.GetAttribute("cname") + "\"";

View file

@ -234,16 +234,16 @@ namespace GtkSharp.Generation {
return false; return false;
} }
public static ObjectGen GetObjectGen(string c_type) public static ClassBase GetClassGen(string c_type)
{ {
c_type = Trim(c_type); c_type = Trim(c_type);
c_type = DeAlias(c_type); c_type = DeAlias(c_type);
if (IsObject(c_type)) { if (IsInterface(c_type) || IsObject (c_type)) {
return (ObjectGen) complex_types[c_type]; return (ClassBase) complex_types[c_type];
} }
return null; return null;
} }
public static bool IsObject(string c_type) public static bool IsObject(string c_type)
{ {
c_type = Trim(c_type); c_type = Trim(c_type);

File diff suppressed because one or more lines are too long

View file

@ -47,6 +47,9 @@ namespace GLib {
get { get {
return raw; return raw;
} }
set {
raw = value;
}
} }
/// <summary> /// <summary>

15
glib/IWrapper.cs Normal file
View file

@ -0,0 +1,15 @@
// IWrapper.cs - Common code for GInterfaces and GObjects
//
// Author: Rachel Hestilow <hesitlow@ximian.com>
//
// (c) 2002 Rachel Hestilow
namespace GLib
{
using System;
public interface IWrapper
{
IntPtr Handle { get; set; }
}
}

View file

@ -20,7 +20,7 @@ namespace GLib {
/// Wrapper class for GObject. /// Wrapper class for GObject.
/// </remarks> /// </remarks>
public class Object { public class Object : IWrapper {
// Private class and instance members // Private class and instance members
IntPtr _obj; IntPtr _obj;
@ -109,6 +109,9 @@ namespace GLib {
get { get {
return _obj; return _obj;
} }
set {
_obj = value;
}
} }
/// <summary> /// <summary>

View file

@ -14,4 +14,10 @@ gtksharp_text_iter_create (void)
return iter; return iter;
} }
void
gtksharp_test_array (int len, int* types)
{
int i;
for (i = 0; i < len; i++)
g_print ("type %i\n", types[i]);
}

28
parser/Atk.metadata Normal file
View file

@ -0,0 +1,28 @@
<?xml version="1.0"?>
<metadata>
<!-- renames -->
<rule>
<class name="AtkDocument">
<method>GetDocument</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>GetTheDocument</value>
</attribute>
</data>
</rule>
<rule>
<class name="AtkDocument">
<method>SetDocument</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>SetTheDocument</value>
</attribute>
</data>
</rule>
</metadata>

View file

@ -24,13 +24,17 @@ sub new {
sub parseClass { sub parseClass {
my ($node, $classes) = @_; my ($node, $classes) = @_;
my %methods = (); my %methods = ();
my %signals = ();
my @attrs = $node->attributes; my @attrs = $node->attributes;
my $class_name = $attrs[0]->value; my $class_name = $attrs[0]->value;
${$classes}{$class_name} = \%methods; ${$classes}{$class_name} = [\%methods, \%signals];
for ($method_node = $node->firstChild; $method_node != undef; $method_node = $method_node->nextSibling ()) { for ($method_node = $node->firstChild; $method_node != undef; $method_node = $method_node->nextSibling ()) {
next if $method_node->nodeName ne "method"; if ($method_node->nodeName eq "method" or $method_node->nodeName eq "constructor") {
$methods{$method_node->firstChild->nodeValue} = 1; $methods{$method_node->firstChild->nodeValue} = 1;
} elsif ($method_node->nodeName eq "signal") {
$signals{$method_node->firstChild->nodeValue} = 1;
}
} }
} }
@ -84,23 +88,35 @@ sub load {
sub fixupParams { sub fixupParams {
my ($method_node, $data_list_ref) = @_; my ($method_node, $data_list_ref) = @_;
my ($params_node, $node); my ($params_node, $node);
for ($node = $method_node->firstChild; $node; $node = $node->nextSibling ()) {
if ($node->nodeName eq "parameters") { foreach $data (@$data_list_ref) {
$params_node = $node; if ($$data[1] eq "method" or $$data[1] eq "signal") {
last; $method_node->setAttribute ($$data[5], $$data[6]);
next;
} }
}
return if not $params_node; for ($node = $method_node->firstChild; $node; $node = $node->nextSibling ()) {
for ($node = $params_node->firstChild; $node; $node = $node->nextSibling ()) { if ($node->nodeName eq "parameters") {
my $param_type; $params_node = $node;
foreach $attr ($node->attributes) {
if ($attr->name eq "type") {
$param_type = $attr->value;
last; last;
} }
} }
next if not $params_node;
if ($$data[1] eq "parameters") {
$params_node->setAttribute ($$data[5], $$data[6]);
next;
}
foreach $data (@$data_list_ref) {
for ($node = $params_node->firstChild; $node; $node = $node->nextSibling ()) {
my $param_type;
foreach $attr ($node->attributes) {
if ($attr->name eq "type") {
$param_type = $attr->value;
last;
}
}
if ($param_type eq $$data[4]) { if ($param_type eq $$data[4]) {
$node->setAttribute ($$data[5], $$data[6]); $node->setAttribute ($$data[5], $$data[6]);
} }
@ -114,7 +130,7 @@ sub fixupNamespace {
foreach $rule (@{$self->{rules}}) { foreach $rule (@{$self->{rules}}) {
my ($classes_ref, $data_list_ref) = @$rule; my ($classes_ref, $data_list_ref) = @$rule;
for ($node = $ns_node->firstChild; $node; $node = $node->nextSibling ()) { for ($node = $ns_node->firstChild; $node; $node = $node->nextSibling ()) {
next if $node->nodeName ne "object"; next if not ($node->nodeName eq "object" or $node->nodeName eq "interface");
my $class, $methods_ref, $attr; my $class, $methods_ref, $attr;
foreach $attr ($node->attributes) { foreach $attr ($node->attributes) {
if ($attr->name eq "cname") { if ($attr->name eq "cname") {
@ -124,21 +140,38 @@ sub fixupNamespace {
} }
my %classes = %$classes_ref; my %classes = %$classes_ref;
$methods_ref = $classes{$class}; $methods_ref = $classes{$class}[0];
next if not $methods_ref; $signals_ref = $classes{$class}[1];
next if not ($methods_ref or $signals_ref);
for ($method_node = $node->firstChild; $method_node; $method_node = $method_node->nextSibling ()) { for ($method_node = $node->firstChild; $method_node; $method_node = $method_node->nextSibling ()) {
next if $method_node->nodeName ne "method"; next if not ($method_node->nodeName eq "method" or $method_node->nodeName eq "constructor");
my $method; my $method;
foreach $attr ($method_node->attributes) { foreach $attr ($method_node->attributes) {
if ($attr->name eq "name") { if (($attr->name eq "name" and $method_node->nodeName eq "method") or ($attr->name eq "cname" and $method_node->nodeName eq "constructor")) {
$method = $attr->value; $method = $attr->value;
last; last;
} }
} }
next if not ${$methods_ref}{$method}; next if not ${%$methods_ref}{$method};
fixupParams ($method_node, $data_list_ref); fixupParams ($method_node, $data_list_ref);
} }
for ($signal_node = $node->firstChild; $signal_node; $signal_node = $signal_node->nextSibling ()) {
next if $signal_node->nodeName ne "signal";
my $signal;
foreach $attr ($signal_node->attributes) {
if ($attr->name eq "name") {
$signal = $attr->value;
last;
}
}
next if not ${$signals_ref}{$signal};
fixupParams ($signal_node, $data_list_ref);
}
} }
} }
} }
@ -152,8 +185,9 @@ sub fixup {
return if not ($api_node and $api_node->nodeName eq "api"); return if not ($api_node and $api_node->nodeName eq "api");
for ($ns_node = $api_node->firstChild; $ns_node; $ns_node = $ns_node->nextSibling ()) { for ($ns_node = $api_node->firstChild; $ns_node; $ns_node = $ns_node->nextSibling ()) {
next if $ns_node->nodeName ne "namespace"; next if $ns_node->nodeName ne "namespace";
next if not ($ns_node->attributes and (scalar (@{$ns_node->attributes})) + 1); next if not $ns_node->attributes;
my @attrs = $ns_node->attributes; my @attrs = $ns_node->attributes;
next if not @attrs;
my $namespace = $attrs[0]->value; my $namespace = $attrs[0]->value;
if (-f "$namespace.metadata") { if (-f "$namespace.metadata") {
if (not ($metadata and $metadata->{namespace} eq $namespace)) { if (not ($metadata and $metadata->{namespace} eq $namespace)) {

View file

@ -1,5 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<metadata> <metadata>
<!-- out parameters -->
<rule> <rule>
<class name="GtkTextBuffer"> <class name="GtkTextBuffer">
<method>GetIterAtLineOffset</method> <method>GetIterAtLineOffset</method>
@ -28,4 +30,892 @@
</attribute> </attribute>
</data> </data>
</rule> </rule>
<rule>
<class name="GtkEditable">
<method>InsertText</method>
</class>
<data>
<attribute target="param">
<filter level="type">gint*</filter>
<name>pass_as</name>
<value>out</value>
</attribute>
</data>
</rule>
<!-- variable arguments -->
<rule>
<class name="GtkTreeStore">
<constructor>gtk_tree_store_newv</constructor>
</class>
<data>
<attribute target="parameters">
<name>va_type</name>
<value>length_param</value>
</attribute>
</data>
</rule>
<!-- renames -->
<rule>
<class name="GtkEditable">
<method>GetEditable</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>GetIsEditable</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkEditable">
<method>SetEditable</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>SetIsEditable</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkContainer">
<signal>Add</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Added</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkContainer">
<signal>Remove</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Removed</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkEditable">
<signal>InsertText</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>TextInserted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkEditable">
<signal>DeleteText</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>TextDeleted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>Show</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Shown</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>Hide</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Hidden</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>Map</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Mapped</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>Unmap</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Unmapped</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>Realize</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Realized</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>Unrealize</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Unrealized</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>GrabFocus</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>FocusGrabbed</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>SizeAllocate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>SizeAllocated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>MnemonicActivate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>MnemonicActivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>SizeRequest</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>SizeRequested</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>ChildNotify</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildNotified</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>InsertPixbuf</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>PixbufInserted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>ApplyTag</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>TagApplied</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>RemoveTag</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>TagRemoved</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>InsertChildAnchor</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildAnchorInserted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>RemoveChildAnchor</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildAnchorRemoved</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkItem">
<signal>Select</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Selected</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkItem">
<signal>Deselect</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Deselected</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkItem">
<signal>Toggle</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Toggled</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkList">
<signal>SelectChild</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildSelected</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkList">
<signal>UnselectChild</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildUnselected</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTree">
<signal>SelectChild</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildSelected</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTree">
<signal>UnselectChild</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildUnselected</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTipsQuery">
<signal>StartQuery</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>QueryStarted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTipsQuery">
<signal>StopQuery</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>QueryStopped</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeItem">
<signal>Collapse</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Collapsed</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeItem">
<signal>Expand</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Expanded</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkContainer">
<signal>SetFocusChild</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>FocusChildSet</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkEntry">
<signal>PasteClipboard</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ClipboardPasted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkEntry">
<signal>CutClipboard</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ClipboardCut</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkEntry">
<signal>CopyClipboard</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ClipboardCopied</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkOldEditable">
<signal>PasteClipboard</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ClipboardPasted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkOldEditable">
<signal>CutClipboard</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ClipboardCut</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkOldEditable">
<signal>CopyClipboard</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ClipboardCopied</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>Activate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Activated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>Deactivate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Deactivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>Deactivate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Deactivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>ToggleSizeRequest</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ToggleSizeRequested</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>ToggleSizeAllocate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ToggleSizeAllocated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>RemoveWidget</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>WidgetRemoved</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>SizeAllocate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>SizeAllocated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>MnemonicActivate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>MnemonicActivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>SizeRequest</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>SizeRequested</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>ChildNotify</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildNotified</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkToggleButton">
<method>Toggled</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Toggle</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkButton">
<method>Pressed</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Press</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkButton">
<method>Clicked</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Click</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkButton">
<method>Released</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Release</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkButton">
<signal>Enter</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Entered</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkButton">
<signal>Leave</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Left</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuShell">
<signal>Deactivate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Deactivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkCellEditable">
<signal>RemoveWidget</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>WidgetRemoved</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkCellEditable">
<method>EditingDone</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>FinishEditing</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWindow">
<signal>ActivateDefault</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>DefaultActivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWindow">
<signal>ActivateFocus</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>FocusActivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkAdjustment">
<method>Changed</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Change</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkAdjustment">
<method>ValueChanged</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>ChangeValue</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkObject">
<signal>Destroy</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Destroyed</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeView">
<method>RowActivated</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>ActivateRow</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeView">
<method>RowExpanded</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>RowExpand</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeModel">
<method>RowDeleted</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>DeleteRow</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeModel">
<method>RowHasChildToggled</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>ToggleRowHasChild</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeModel">
<method>RowInserted</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>InsertRow</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeModel">
<method>RowChanged</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>ChangeRow</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeModel">
<method>RowsReordered</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>ReorderRows</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeSortable">
<method>SortColumnChanged</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>ChangeSortColumn</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkDialog">
<method>Response</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Respond</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>EndUserAction</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>UserActionEnded</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>BeginUserAction</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>UserActionBegun</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkCheckMenuItem">
<method>Toggled</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Toggle</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkContainer">
<signal>CheckResize</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ResizeChecked</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeViewColumn">
<method>Clicked</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Click</value>
</attribute>
</data>
</rule>
</metadata> </metadata>

View file

@ -24,13 +24,17 @@ sub new {
sub parseClass { sub parseClass {
my ($node, $classes) = @_; my ($node, $classes) = @_;
my %methods = (); my %methods = ();
my %signals = ();
my @attrs = $node->attributes; my @attrs = $node->attributes;
my $class_name = $attrs[0]->value; my $class_name = $attrs[0]->value;
${$classes}{$class_name} = \%methods; ${$classes}{$class_name} = [\%methods, \%signals];
for ($method_node = $node->firstChild; $method_node != undef; $method_node = $method_node->nextSibling ()) { for ($method_node = $node->firstChild; $method_node != undef; $method_node = $method_node->nextSibling ()) {
next if $method_node->nodeName ne "method"; if ($method_node->nodeName eq "method" or $method_node->nodeName eq "constructor") {
$methods{$method_node->firstChild->nodeValue} = 1; $methods{$method_node->firstChild->nodeValue} = 1;
} elsif ($method_node->nodeName eq "signal") {
$signals{$method_node->firstChild->nodeValue} = 1;
}
} }
} }
@ -84,23 +88,35 @@ sub load {
sub fixupParams { sub fixupParams {
my ($method_node, $data_list_ref) = @_; my ($method_node, $data_list_ref) = @_;
my ($params_node, $node); my ($params_node, $node);
for ($node = $method_node->firstChild; $node; $node = $node->nextSibling ()) {
if ($node->nodeName eq "parameters") { foreach $data (@$data_list_ref) {
$params_node = $node; if ($$data[1] eq "method" or $$data[1] eq "signal") {
last; $method_node->setAttribute ($$data[5], $$data[6]);
next;
} }
}
return if not $params_node; for ($node = $method_node->firstChild; $node; $node = $node->nextSibling ()) {
for ($node = $params_node->firstChild; $node; $node = $node->nextSibling ()) { if ($node->nodeName eq "parameters") {
my $param_type; $params_node = $node;
foreach $attr ($node->attributes) {
if ($attr->name eq "type") {
$param_type = $attr->value;
last; last;
} }
} }
next if not $params_node;
if ($$data[1] eq "parameters") {
$params_node->setAttribute ($$data[5], $$data[6]);
next;
}
foreach $data (@$data_list_ref) {
for ($node = $params_node->firstChild; $node; $node = $node->nextSibling ()) {
my $param_type;
foreach $attr ($node->attributes) {
if ($attr->name eq "type") {
$param_type = $attr->value;
last;
}
}
if ($param_type eq $$data[4]) { if ($param_type eq $$data[4]) {
$node->setAttribute ($$data[5], $$data[6]); $node->setAttribute ($$data[5], $$data[6]);
} }
@ -114,7 +130,7 @@ sub fixupNamespace {
foreach $rule (@{$self->{rules}}) { foreach $rule (@{$self->{rules}}) {
my ($classes_ref, $data_list_ref) = @$rule; my ($classes_ref, $data_list_ref) = @$rule;
for ($node = $ns_node->firstChild; $node; $node = $node->nextSibling ()) { for ($node = $ns_node->firstChild; $node; $node = $node->nextSibling ()) {
next if $node->nodeName ne "object"; next if not ($node->nodeName eq "object" or $node->nodeName eq "interface");
my $class, $methods_ref, $attr; my $class, $methods_ref, $attr;
foreach $attr ($node->attributes) { foreach $attr ($node->attributes) {
if ($attr->name eq "cname") { if ($attr->name eq "cname") {
@ -124,21 +140,38 @@ sub fixupNamespace {
} }
my %classes = %$classes_ref; my %classes = %$classes_ref;
$methods_ref = $classes{$class}; $methods_ref = $classes{$class}[0];
next if not $methods_ref; $signals_ref = $classes{$class}[1];
next if not ($methods_ref or $signals_ref);
for ($method_node = $node->firstChild; $method_node; $method_node = $method_node->nextSibling ()) { for ($method_node = $node->firstChild; $method_node; $method_node = $method_node->nextSibling ()) {
next if $method_node->nodeName ne "method"; next if not ($method_node->nodeName eq "method" or $method_node->nodeName eq "constructor");
my $method; my $method;
foreach $attr ($method_node->attributes) { foreach $attr ($method_node->attributes) {
if ($attr->name eq "name") { if (($attr->name eq "name" and $method_node->nodeName eq "method") or ($attr->name eq "cname" and $method_node->nodeName eq "constructor")) {
$method = $attr->value; $method = $attr->value;
last; last;
} }
} }
next if not ${$methods_ref}{$method}; next if not ${%$methods_ref}{$method};
fixupParams ($method_node, $data_list_ref); fixupParams ($method_node, $data_list_ref);
} }
for ($signal_node = $node->firstChild; $signal_node; $signal_node = $signal_node->nextSibling ()) {
next if $signal_node->nodeName ne "signal";
my $signal;
foreach $attr ($signal_node->attributes) {
if ($attr->name eq "name") {
$signal = $attr->value;
last;
}
}
next if not ${$signals_ref}{$signal};
fixupParams ($signal_node, $data_list_ref);
}
} }
} }
} }
@ -152,8 +185,9 @@ sub fixup {
return if not ($api_node and $api_node->nodeName eq "api"); return if not ($api_node and $api_node->nodeName eq "api");
for ($ns_node = $api_node->firstChild; $ns_node; $ns_node = $ns_node->nextSibling ()) { for ($ns_node = $api_node->firstChild; $ns_node; $ns_node = $ns_node->nextSibling ()) {
next if $ns_node->nodeName ne "namespace"; next if $ns_node->nodeName ne "namespace";
next if not ($ns_node->attributes and (scalar (@{$ns_node->attributes})) + 1); next if not $ns_node->attributes;
my @attrs = $ns_node->attributes; my @attrs = $ns_node->attributes;
next if not @attrs;
my $namespace = $attrs[0]->value; my $namespace = $attrs[0]->value;
if (-f "$namespace.metadata") { if (-f "$namespace.metadata") {
if (not ($metadata and $metadata->{namespace} eq $namespace)) { if (not ($metadata and $metadata->{namespace} eq $namespace)) {

View file

@ -88,7 +88,7 @@ while ($line = <STDIN>) {
$sdef =~ s!/\*.*?(\*/|\n)!!g; $sdef =~ s!/\*.*?(\*/|\n)!!g;
$sdef =~ s/\n\s*//g; $sdef =~ s/\n\s*//g;
$sdefs{$sname} = $sdef; $sdefs{$sname} = $sdef;
} elsif ($line =~ /^(\w+)_class_init\b/) { } elsif ($line =~ /^(\w+)_(class|base)_init\b/) {
$class = StudlyCaps($1); $class = StudlyCaps($1);
$pedef = $line; $pedef = $line;
while ($line = <STDIN>) { while ($line = <STDIN>) {
@ -96,16 +96,25 @@ while ($line = <STDIN>) {
last if ($line =~ /^}/); last if ($line =~ /^}/);
} }
$pedefs{$class} = $pedef; $pedefs{$class} = $pedef;
} elsif ($line =~ /g_boxed_type_register_static/) { } elsif ($line =~ /^(\w+)_get_type\b/) {
$boxdef = $line; $class = StudlyCaps($1);
while ($line !~ /;/) { $pedef = $line;
$boxdef .= ($line = <STDIN>); while ($line = <STDIN>) {
$pedef .= $line;
if ($line =~ /g_boxed_type_register_static/) {
$boxdef = $line;
while ($line !~ /;/) {
$boxdef .= ($line = <STDIN>);
}
$boxdef =~ s/\n\s*//g;
$boxdef =~ /\(\"(\w+)\"/;
my $boxtype = $1;
$boxtype =~ s/($ns)Type(\w+)/$ns$2/;
$boxdefs{$boxtype} = $boxdef;
}
last if ($line =~ /^}/);
} }
$boxdef =~ s/\n\s*//g; $typefuncs{$class} = $pedef;
$boxdef =~ /\(\"(\w+)\"/;
my $boxtype = $1;
$boxtype =~ s/($ns)Type(\w+)/$ns$2/;
$boxdefs{$boxtype} = $boxdef;
} elsif ($line =~ /^(const|G_CONST_RETURN)?\s*\w+\s*\**\s*(\w+)\s*\(/) { } elsif ($line =~ /^(const|G_CONST_RETURN)?\s*\w+\s*\**\s*(\w+)\s*\(/) {
$fname = $2; $fname = $2;
$fdef = ""; $fdef = "";
@ -216,12 +225,21 @@ foreach $type (sort(keys(%ifaces))) {
$iface = $ifaces{$type}; $iface = $ifaces{$type};
($inst, $dontcare) = split(/:/, delete $objects{$type}); ($inst, $dontcare) = split(/:/, delete $objects{$type});
$initfunc = $pedefs{$inst};
$ifacetype = delete $types{$iface}; $ifacetype = delete $types{$iface};
delete $types{$inst}; delete $types{$inst};
$ifacecnt++; $ifacecnt++;
$iface_el = addNameElem($ns_elem, 'interface', $inst, $ns); $iface_el = addNameElem($ns_elem, 'interface', $inst, $ns);
addFuncElems($iface_el, $inst); addFuncElems($iface_el, $inst);
$classdef = $sdefs{$1} if ($ifacetype =~ /struct\s+(\w+)/);
if ($initfunc) {
print "parsing $inst\n";
parseInitFunc($iface_el, $initfunc);
} else {
warn "Don't have an init func for $inst.\n" if $debug;
}
} }
@ -234,6 +252,7 @@ foreach $type (sort(keys(%objects))) {
($inst, $class) = split(/:/, $objects{$type}); ($inst, $class) = split(/:/, $objects{$type});
$class = $inst . "Class" if (!$class); $class = $inst . "Class" if (!$class);
$initfunc = $pedefs{$inst}; $initfunc = $pedefs{$inst};
$typefunc = $typefuncs{$inst};
$insttype = delete $types{$inst}; $insttype = delete $types{$inst};
$classtype = delete $types{$class}; $classtype = delete $types{$class};
@ -266,6 +285,13 @@ foreach $type (sort(keys(%objects))) {
warn "Don't have an init func for $inst.\n" if $debug; warn "Don't have an init func for $inst.\n" if $debug;
} }
# Get the interfaces from the class_init func.
if ($typefunc) {
parseTypeFunc($obj_el, $typefunc);
} else {
warn "Don't have a GetType func for $inst.\n" if $debug;
}
addFuncElems($obj_el, $inst); addFuncElems($obj_el, $inst);
} }
@ -379,12 +405,12 @@ sub addFuncElems
$fcnt = keys(%fdefs); $fcnt = keys(%fdefs);
foreach $mname (keys(%fdefs)) { foreach $mname (keys(%fdefs)) {
next if ($mname !~ /$prefix/); next if ($mname !~ /^$prefix/);
if ($mname =~ /$prefix(new)/) { if ($mname =~ /$prefix(new)/) {
$el = addNameElem($obj_el, 'constructor', $mname); $el = addNameElem($obj_el, 'constructor', $mname);
$drop_1st = 0; $drop_1st = 0;
} elsif ($fdefs{$mname} =~ /\(\s*$inst\b/) { } elsif ($fdefs{$mname} =~ /\(\s*(const)?\s*$inst\b/) {
$el = addNameElem($obj_el, 'method', $mname, $prefix); $el = addNameElem($obj_el, 'method', $mname, $prefix);
$fdefs{$mname} =~ /(.*?)\w+\s*\(/; $fdefs{$mname} =~ /(.*?)\w+\s*\(/;
addReturnElem($el, $1); addReturnElem($el, $1);
@ -579,6 +605,18 @@ sub addSignalElem
} }
sub addImplementsElem
{
my ($spec, $node) = @_;
$spec =~ s/\n\s*//g;
if ($spec =~ /,\s*(\w+)_TYPE_(\w+),/) {
$impl_elem = $doc->createElement('interface');
$name = StudlyCaps (lc ("$1_$2"));
$impl_elem->setAttribute ("cname", "$name");
$node->appendChild($impl_elem);
}
}
sub parseInitFunc sub parseInitFunc
{ {
@ -612,6 +650,35 @@ sub parseInitFunc
} }
} }
sub parseTypeFunc
{
my ($obj_el, $typefunc) = @_;
my @type_lines = split (/\n/, $typefunc);
my $linenum = 0;
$impl_node = undef;
while ($linenum < @type_lines) {
my $line = $type_lines[$linenum];
if ($line =~ /#define/) {
# FIXME: This ignores the bool helper macro thingie.
} elsif ($line =~ /g_type_add_interface_static/) {
my $prop = $line;
do {
$prop .= $type_lines[++$linenum];
} until ($type_lines[$linenum] =~ /;/);
if (not $impl_node) {
$impl_node = $doc->createElement ("implements");
$obj_el->appendChild ($impl_node);
}
addImplementsElem ($prop, $impl_node);
}
$linenum++;
}
}
############################################################## ##############################################################
# Converts a dash or underscore separated name to StudlyCaps. # Converts a dash or underscore separated name to StudlyCaps.
############################################################## ##############################################################

View file

@ -70,18 +70,12 @@ foreach $fname (`ls $ARGV[0]/*.c`, @privhdrs) {
} }
while ($line = <INFILE>) { while ($line = <INFILE>) {
next if ($line !~ /^(struct|\w+_class_init)|g_boxed_type_register_static/); #next if ($line !~ /^(struct|\w+_class_init)|g_boxed_type_register_static/);
next if ($line !~ /^(struct|\w+_class_init|\w+_base_init|\w+_get_type)/);
if ($line =~ /^struct/) { if ($line =~ /^struct/) {
# need some of these to parse out parent types # need some of these to parse out parent types
print "private"; print "private";
} elsif ($line =~ /g_boxed_type_register_static/) {
while ($line !~ /;/) {
print $line;
$line = <INFILE>;
}
print $line;
next;
} }
do { do {

View file

@ -21,7 +21,7 @@ namespace GtkSamples {
win.DeleteEvent += new EventHandler (Window_Delete); win.DeleteEvent += new EventHandler (Window_Delete);
Button btn = new Button ("Click Me"); Button btn = new Button ("Click Me");
btn.Clicked += new EventHandler (btn_click); btn.Clicked += new EventHandler (btn_click);
win.EmitAdd (btn); win.Add (btn);
win.ShowAll (); win.ShowAll ();
Application.Run (); Application.Run ();
return 0; return 0;

View file

@ -25,17 +25,17 @@ namespace GtkSharp.Samples {
MenuBar mb = new MenuBar (); MenuBar mb = new MenuBar ();
Menu file_menu = new Menu (); Menu file_menu = new Menu ();
MenuItem exit_item = new MenuItem("Exit"); MenuItem exit_item = new MenuItem("Exit");
exit_item.Activate += new EventHandler (exit_cb); exit_item.Activated += new EventHandler (exit_cb);
file_menu.Append (exit_item); file_menu.Append (exit_item);
MenuItem file_item = new MenuItem("File"); MenuItem file_item = new MenuItem("File");
file_item.SetSubmenu (file_menu); file_item.Submenu = file_menu;
mb.Append (file_item); mb.Append (file_item);
box.PackStart(mb, false, false, 0); box.PackStart(mb, false, false, 0);
Button btn = new Button ("Yep, that's a menu"); Button btn = new Button ("Yep, that's a menu");
box.PackStart(btn, true, true, 0); box.PackStart(btn, true, true, 0);
win.EmitAdd (box); win.Add (box);
win.ShowAll (); win.ShowAll ();
Application.Run (); Application.Run ();

28
sources/Atk.metadata Normal file
View file

@ -0,0 +1,28 @@
<?xml version="1.0"?>
<metadata>
<!-- renames -->
<rule>
<class name="AtkDocument">
<method>GetDocument</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>GetTheDocument</value>
</attribute>
</data>
</rule>
<rule>
<class name="AtkDocument">
<method>SetDocument</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>SetTheDocument</value>
</attribute>
</data>
</rule>
</metadata>

View file

@ -1,5 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<metadata> <metadata>
<!-- out parameters -->
<rule> <rule>
<class name="GtkTextBuffer"> <class name="GtkTextBuffer">
<method>GetIterAtLineOffset</method> <method>GetIterAtLineOffset</method>
@ -28,4 +30,892 @@
</attribute> </attribute>
</data> </data>
</rule> </rule>
<rule>
<class name="GtkEditable">
<method>InsertText</method>
</class>
<data>
<attribute target="param">
<filter level="type">gint*</filter>
<name>pass_as</name>
<value>out</value>
</attribute>
</data>
</rule>
<!-- variable arguments -->
<rule>
<class name="GtkTreeStore">
<constructor>gtk_tree_store_newv</constructor>
</class>
<data>
<attribute target="parameters">
<name>va_type</name>
<value>length_param</value>
</attribute>
</data>
</rule>
<!-- renames -->
<rule>
<class name="GtkEditable">
<method>GetEditable</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>GetIsEditable</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkEditable">
<method>SetEditable</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>SetIsEditable</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkContainer">
<signal>Add</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Added</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkContainer">
<signal>Remove</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Removed</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkEditable">
<signal>InsertText</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>TextInserted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkEditable">
<signal>DeleteText</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>TextDeleted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>Show</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Shown</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>Hide</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Hidden</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>Map</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Mapped</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>Unmap</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Unmapped</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>Realize</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Realized</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>Unrealize</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Unrealized</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>GrabFocus</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>FocusGrabbed</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>SizeAllocate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>SizeAllocated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>MnemonicActivate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>MnemonicActivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>SizeRequest</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>SizeRequested</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWidget">
<signal>ChildNotify</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildNotified</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>InsertPixbuf</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>PixbufInserted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>ApplyTag</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>TagApplied</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>RemoveTag</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>TagRemoved</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>InsertChildAnchor</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildAnchorInserted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>RemoveChildAnchor</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildAnchorRemoved</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkItem">
<signal>Select</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Selected</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkItem">
<signal>Deselect</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Deselected</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkItem">
<signal>Toggle</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Toggled</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkList">
<signal>SelectChild</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildSelected</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkList">
<signal>UnselectChild</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildUnselected</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTree">
<signal>SelectChild</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildSelected</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTree">
<signal>UnselectChild</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildUnselected</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTipsQuery">
<signal>StartQuery</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>QueryStarted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTipsQuery">
<signal>StopQuery</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>QueryStopped</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeItem">
<signal>Collapse</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Collapsed</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeItem">
<signal>Expand</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Expanded</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkContainer">
<signal>SetFocusChild</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>FocusChildSet</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkEntry">
<signal>PasteClipboard</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ClipboardPasted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkEntry">
<signal>CutClipboard</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ClipboardCut</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkEntry">
<signal>CopyClipboard</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ClipboardCopied</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkOldEditable">
<signal>PasteClipboard</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ClipboardPasted</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkOldEditable">
<signal>CutClipboard</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ClipboardCut</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkOldEditable">
<signal>CopyClipboard</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ClipboardCopied</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>Activate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Activated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>Deactivate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Deactivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>Deactivate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Deactivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>ToggleSizeRequest</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ToggleSizeRequested</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>ToggleSizeAllocate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ToggleSizeAllocated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>RemoveWidget</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>WidgetRemoved</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>SizeAllocate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>SizeAllocated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>MnemonicActivate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>MnemonicActivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>SizeRequest</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>SizeRequested</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuItem">
<signal>ChildNotify</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ChildNotified</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkToggleButton">
<method>Toggled</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Toggle</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkButton">
<method>Pressed</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Press</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkButton">
<method>Clicked</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Click</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkButton">
<method>Released</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Release</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkButton">
<signal>Enter</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Entered</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkButton">
<signal>Leave</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Left</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkMenuShell">
<signal>Deactivate</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Deactivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkCellEditable">
<signal>RemoveWidget</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>WidgetRemoved</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkCellEditable">
<method>EditingDone</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>FinishEditing</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWindow">
<signal>ActivateDefault</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>DefaultActivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkWindow">
<signal>ActivateFocus</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>FocusActivated</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkAdjustment">
<method>Changed</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Change</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkAdjustment">
<method>ValueChanged</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>ChangeValue</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkObject">
<signal>Destroy</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>Destroyed</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeView">
<method>RowActivated</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>ActivateRow</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeView">
<method>RowExpanded</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>RowExpand</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeModel">
<method>RowDeleted</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>DeleteRow</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeModel">
<method>RowHasChildToggled</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>ToggleRowHasChild</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeModel">
<method>RowInserted</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>InsertRow</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeModel">
<method>RowChanged</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>ChangeRow</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeModel">
<method>RowsReordered</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>ReorderRows</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeSortable">
<method>SortColumnChanged</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>ChangeSortColumn</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkDialog">
<method>Response</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Respond</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>EndUserAction</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>UserActionEnded</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTextBuffer">
<signal>BeginUserAction</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>UserActionBegun</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkCheckMenuItem">
<method>Toggled</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Toggle</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkContainer">
<signal>CheckResize</signal>
</class>
<data>
<attribute target="signal">
<name>name</name>
<value>ResizeChecked</value>
</attribute>
</data>
</rule>
<rule>
<class name="GtkTreeViewColumn">
<method>Clicked</method>
</class>
<data>
<attribute target="method">
<name>name</name>
<value>Click</value>
</attribute>
</data>
</rule>
</metadata> </metadata>