mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-24 12:45:45 +00:00
6d30cf0c3e
2002-05-23 Mike Kestner <mkestner@speakeasy.net> * generator/BoxedGen.cs : Update for Static SymbolTable * generator/CallbackGen.cs : Use GenBase and Parameters classes * generator/CodeGenerator.cs : Update for Static SymbolTable * generator/Ctor.cs : code from StructBase using Parameters class * generator/EnumGen.cs : Use GenBase * generator/GenBase.cs : Abstract Stream Writer creation, stream boilerplate, and common *Name properties * generator/IGeneratable.cs : Update for Static SymbolTable * generator/InterfaceGen.cs : Use GenBase * generator/Method.cs : code from StructBase using Parameters class * generator/ObjectGen.cs : Major refactoring. Use GenBase. Build tables of Member generatables at construct time to facilitate future name collision resolution logic. * generator/Parameters.cs : new generatable to abstract duplicated parameter parsing logic. * generator/Parser.cs : Update for Static SymbolTable * generator/Property.cs : code from ObjectGen * generator/Signal.cs : code from ObjectGen * generator/SignalHandler.cs : Update for Static SymbolTable * generator/StructBase.cs : Update for Static SymbolTable * generator/StructGen.cs : Update for Static SymbolTable * generator/SymbolTable.cs : Make all methods and private members static. There is no reason to ever have multiple tables. svn path=/trunk/gtk-sharp/; revision=4895
102 lines
2.5 KiB
C#
102 lines
2.5 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 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";
|
|
}
|
|
|
|
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;");
|
|
sw.WriteLine("\t\t\t\tGetProperty(\"" + elem.GetAttribute("cname") + "\", out 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(\"" + elem.GetAttribute("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++;
|
|
}
|
|
}
|
|
}
|
|
|