mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 00:13:20 +02:00
![Rachel Hestilow](/assets/img/avatar_default.png)
* generator/GenBase.cs: new method AppendCustom, moved from ObjectGen. * generator/BoxedGen.cs, ObjectGen.cs, StructGen.cs: Call AppendCustom in Generate (); * generator/Method.cs, Parameters.cs: Add support for "out" parameters. Additionally, output an accessor instead of a regular method if it is an accessor-style function (ie GetStartIter). * generator/Property.cs: Add additional cast to Boxed, if necessary. * glue/textiter.c: New constructor for GtkTextIter. * glue/Makefile.am: Add textiter.c, build with Gtk+ cflags. * configure.in: Check for Gtk+ cflags. * parser/Metadata.pm, Gtk.metadata: Added. * parser/gapi2xml.pl: Call Metadata::fixup on the document. Also work around gtk's screwy boxed type name registration (GtkFoo -> GtkTypeFoo). * gtk/TextIter.custom: Added. svn path=/trunk/gtk-sharp/; revision=5205
105 lines
2.7 KiB
C#
105 lines
2.7 KiB
C#
// GtkSharp.Generation.Property.cs - The Property Generatable.
|
|
//
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
//
|
|
// (c) 2001-2002 Mike Kestner
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
using System;
|
|
using System.Collections;
|
|
using System.IO;
|
|
using System.Xml;
|
|
|
|
public class Property {
|
|
|
|
private XmlElement elem;
|
|
|
|
public Property (XmlElement elem)
|
|
{
|
|
this.elem = elem;
|
|
}
|
|
|
|
public bool Validate ()
|
|
{
|
|
string c_type = elem.GetAttribute("type");
|
|
string cs_type = SymbolTable.GetCSType(c_type);
|
|
|
|
if (cs_type == "") {
|
|
Console.Write("Property has unknown Type {0} ", c_type);
|
|
Statistics.ThrottledCount++;
|
|
return false;
|
|
}
|
|
|
|
if (SymbolTable.IsInterface(c_type)) {
|
|
// FIXME: Handle interface props properly.
|
|
Console.Write("Interface property detected ");
|
|
Statistics.ThrottledCount++;
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public void Generate (StreamWriter sw)
|
|
{
|
|
string c_type = elem.GetAttribute("type");
|
|
string cs_type = SymbolTable.GetCSType(c_type);
|
|
|
|
XmlElement parent = (XmlElement) elem.ParentNode;
|
|
string name = elem.GetAttribute("name");
|
|
if (name == parent.GetAttribute("name")) {
|
|
name += "Prop";
|
|
}
|
|
string cname = "\"" + elem.GetAttribute("cname") + "\"";
|
|
|
|
string v_type = "";
|
|
if (SymbolTable.IsEnum(c_type)) {
|
|
v_type = "int";
|
|
} else if (SymbolTable.IsInterface(c_type)) {
|
|
// FIXME: Handle interface props properly.
|
|
Console.Write("Interface property detected ");
|
|
Statistics.ThrottledCount++;
|
|
return;
|
|
} else if (SymbolTable.IsObject(c_type)) {
|
|
v_type = "GLib.Object";
|
|
} else if (SymbolTable.IsBoxed (c_type)) {
|
|
v_type = "GLib.Boxed";
|
|
}
|
|
|
|
if (elem.HasAttribute("construct-only") && !elem.HasAttribute("readable")) {
|
|
return;
|
|
}
|
|
|
|
sw.WriteLine("\t\tpublic " + cs_type + " " + name + " {");
|
|
if (elem.HasAttribute("readable")) {
|
|
sw.WriteLine("\t\t\tget {");
|
|
sw.WriteLine("\t\t\t\tGLib.Value val = new GLib.Value (Handle, " + cname + ");");
|
|
sw.WriteLine("\t\t\t\tGetProperty(" + cname + ", val);");
|
|
sw.Write("\t\t\t\treturn (" + cs_type + ") ");
|
|
if (v_type != "") {
|
|
sw.Write("(" + v_type + ") ");
|
|
}
|
|
sw.WriteLine("val;");
|
|
sw.WriteLine("\t\t\t}");
|
|
}
|
|
|
|
if (elem.HasAttribute("writeable") && !elem.HasAttribute("construct-only")) {
|
|
sw.WriteLine("\t\t\tset {");
|
|
sw.Write("\t\t\t\tSetProperty(" + cname + ", new GLib.Value(");
|
|
if (v_type != "") {
|
|
sw.Write("(" + v_type + ") ");
|
|
}
|
|
sw.WriteLine("value));");
|
|
sw.WriteLine("\t\t\t}");
|
|
}
|
|
|
|
sw.WriteLine("\t\t}");
|
|
sw.WriteLine();
|
|
|
|
Statistics.PropCount++;
|
|
}
|
|
}
|
|
}
|
|
|