mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-24 16:45:35 +00:00
02c9fb725c
* configure.in, makefile, makefile.win32: add gnome. * doc/index.html, netdoc.xsl: Add gnome. * gdk/Event.cs: New manual wrap for GdkEvent. * generator/ClassBase.cs: Add methods GetProperty, GetPropertyRecursively, GetMethodRecursively. Move Parent property here from ObjectGen.cs. Pass this pointer into Property. * generator/Ctor.cs: Generate docs. * generator/Method.cs, Property.cs: Tag method as "new" if a Method/Property with the same name is found in the class hierarchy. * generator/SignalHandler.cs: Correctly wrap complex signal argument types. Add gnome directory. * generator/SymbolTable.cs: Add manually wrapped types hash (contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped. * glib/SList.cs: Add constructor from IntPtr. * glue/slist.c, glue/event.c: Added (field accessor glue). * glue/Makefile.am: Update. * parser/Gtk.metadata: Add new signal renames for new signals exposed by GdkEvent changes. * parser/README, parser/build.pl: Add libgnome, libgnomecanvas, libgnomeui. * parser/gapi2xml.pl: Handle literal-length array parameters, and NULL property doc strings. * sample/: Add new test GnomeHelloWorld.cs. * gnome/: Added. * parser/Gnome.metadata: Added. svn path=/trunk/gtk-sharp/; revision=5461
212 lines
4.4 KiB
C#
212 lines
4.4 KiB
C#
// 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;
|
|
|
|
public Hashtable Methods {
|
|
get {
|
|
return methods;
|
|
}
|
|
}
|
|
|
|
public Hashtable Signals {
|
|
get {
|
|
return sigs;
|
|
}
|
|
}
|
|
|
|
public ClassBase Parent {
|
|
get {
|
|
string parent = Elem.GetAttribute("parent");
|
|
return SymbolTable.GetClassGen(parent);
|
|
}
|
|
}
|
|
|
|
protected ClassBase (XmlElement 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 (LibraryName, member, this));
|
|
break;
|
|
|
|
case "property":
|
|
props.Add (member.GetAttribute ("name"), new Property (member, this));
|
|
break;
|
|
|
|
case "signal":
|
|
sigs.Add (member.GetAttribute ("name"), new Signal (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);
|
|
}
|
|
}
|
|
|
|
public void GenSignals (StreamWriter sw, bool gen_docs)
|
|
{
|
|
if (sigs == null)
|
|
return;
|
|
|
|
foreach (Signal sig in sigs.Values) {
|
|
if (sig.Validate ())
|
|
sig.Generate (sw, gen_docs);
|
|
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)));
|
|
}
|
|
|
|
public void GenMethods (StreamWriter sw, Hashtable collisions, bool gen_docs)
|
|
{
|
|
if (methods == null)
|
|
return;
|
|
|
|
foreach (Method method in methods.Values) {
|
|
if (IgnoreMethod (method))
|
|
continue;
|
|
|
|
if (method.Validate ())
|
|
{
|
|
String oname = null, oprotection = null;
|
|
if (collisions != null && collisions.Contains (method.Name))
|
|
{
|
|
oname = method.Name;
|
|
oprotection = method.Protection;
|
|
method.Name = Name + "." + method.Name;
|
|
method.Protection = "";
|
|
}
|
|
method.Generate (sw, gen_docs);
|
|
if (oname != null)
|
|
{
|
|
method.Name = oname;
|
|
method.Protection = oprotection;
|
|
}
|
|
}
|
|
else
|
|
Console.WriteLine(" in Object " + Name);
|
|
}
|
|
}
|
|
|
|
public Method GetMethod (string name)
|
|
{
|
|
return (Method) methods[name];
|
|
}
|
|
|
|
public Property GetProperty (string name)
|
|
{
|
|
return (Property) props[name];
|
|
}
|
|
|
|
public virtual Method GetMethodRecursively (string name)
|
|
{
|
|
ClassBase klass = this;
|
|
Method m = null;
|
|
while (klass != null && m == null) {
|
|
m = (Method) klass.GetMethod (name);
|
|
klass = klass.Parent;
|
|
}
|
|
|
|
return m;
|
|
}
|
|
|
|
public virtual Property GetPropertyRecursively (string name)
|
|
{
|
|
ClassBase klass = this;
|
|
Property p = null;
|
|
while (klass != null && p == null) {
|
|
p = (Property) klass.GetProperty (name);
|
|
klass = klass.Parent;
|
|
}
|
|
|
|
return p;
|
|
}
|
|
|
|
}
|
|
}
|