Apply the parts of the generator reorganization from #69514 that
don't actually affect the generated output * generator/PropertyBase.cs: new base class for fields and properties (mostly containing code formerly in Property.cs). * generator/Property.cs: derive from PropertyBase * generator/FieldBase.cs: base class for fields (containing some code formerly in Field.cs) * generator/StructField.cs: class for struct fields (the rest of what used to be Field.cs) * generator/StructBase.cs: s/Field/StructField/ * gnome/Gnome.metadata: hide a few funky _get_ methods that the generator is just now noticing, to preserve the old output. svn path=/trunk/gtk-sharp/; revision=43896
This commit is contained in:
commit
5825f7f4fe
8 changed files with 320 additions and 165 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
2005-05-02 Dan Winship <danw@novell.com>
|
||||
|
||||
Apply the parts of the generator reorganization from #69514 that
|
||||
don't actually affect the generated output
|
||||
|
||||
* generator/PropertyBase.cs: new base class for fields and
|
||||
properties (mostly containing code formerly in Property.cs).
|
||||
|
||||
* generator/Property.cs: derive from PropertyBase
|
||||
|
||||
* generator/FieldBase.cs: base class for fields (containing some
|
||||
code formerly in Field.cs)
|
||||
|
||||
* generator/StructField.cs: class for struct fields (the rest of
|
||||
what used to be Field.cs)
|
||||
|
||||
* generator/StructBase.cs: s/Field/StructField/
|
||||
|
||||
* gnome/Gnome.metadata: hide a few _get_ methods that the
|
||||
generator is just now noticing, to preserve the old output.
|
||||
|
||||
2005-05-02 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* generator/Property.cs : fix interface setter generation.
|
||||
|
|
70
generator/FieldBase.cs
Normal file
70
generator/FieldBase.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
// GtkSharp.Generation.FieldBase.cs - base class for struct and object
|
||||
// fields
|
||||
//
|
||||
// Copyright (c) 2004 Novell, Inc.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
namespace GtkSharp.Generation {
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
public abstract class FieldBase : PropertyBase {
|
||||
public FieldBase (XmlElement elem, ClassBase container_type) : base (elem, container_type) {}
|
||||
|
||||
protected virtual bool Readable {
|
||||
get {
|
||||
return elem.GetAttribute ("readable") != "false";
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool Writable {
|
||||
get {
|
||||
return elem.GetAttribute ("writeable") != "false";
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract string DefaultAccess { get; }
|
||||
|
||||
protected string Access {
|
||||
get {
|
||||
return elem.HasAttribute ("access") ? elem.GetAttribute ("access") : DefaultAccess;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsArray {
|
||||
get {
|
||||
return elem.HasAttribute("array_len") || elem.HasAttribute("array");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsBitfield {
|
||||
get {
|
||||
return elem.HasAttribute("bits");
|
||||
}
|
||||
}
|
||||
|
||||
public bool Ignored {
|
||||
get {
|
||||
return IsArray || Access == "private";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ sources = \
|
|||
ConstStringGen.cs \
|
||||
Ctor.cs \
|
||||
EnumGen.cs \
|
||||
Field.cs \
|
||||
FieldBase.cs \
|
||||
GenBase.cs \
|
||||
GenerationInfo.cs \
|
||||
IGeneratable.cs \
|
||||
|
@ -38,6 +38,7 @@ sources = \
|
|||
Parameters.cs \
|
||||
Parser.cs \
|
||||
Property.cs \
|
||||
PropertyBase.cs \
|
||||
ReturnValue.cs \
|
||||
Signal.cs \
|
||||
Signature.cs \
|
||||
|
@ -45,6 +46,7 @@ sources = \
|
|||
SimpleGen.cs \
|
||||
Statistics.cs \
|
||||
StructBase.cs \
|
||||
StructField.cs \
|
||||
StructGen.cs \
|
||||
SymbolTable.cs \
|
||||
VirtualMethod.cs \
|
||||
|
|
|
@ -27,31 +27,14 @@ namespace GtkSharp.Generation {
|
|||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
public class Property {
|
||||
public class Property : PropertyBase {
|
||||
|
||||
protected XmlElement elem;
|
||||
protected ClassBase container_type;
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
return elem.GetAttribute ("name");
|
||||
}
|
||||
}
|
||||
|
||||
public Property (XmlElement elem, ClassBase container_type)
|
||||
{
|
||||
this.elem = elem;
|
||||
this.container_type = container_type;
|
||||
}
|
||||
public Property (XmlElement elem, ClassBase container_type) : base (elem, container_type) {}
|
||||
|
||||
public bool Validate ()
|
||||
{
|
||||
string c_type = elem.GetAttribute("type");
|
||||
SymbolTable table = SymbolTable.Table;
|
||||
string cs_type = table.GetCSType(c_type);
|
||||
|
||||
if (cs_type == "") {
|
||||
Console.Write("Property has unknown Type {0} ", c_type);
|
||||
if (CSType == "" && !Hidden) {
|
||||
Console.Write("Property has unknown Type {0} ", CType);
|
||||
Statistics.ThrottledCount++;
|
||||
return false;
|
||||
}
|
||||
|
@ -59,6 +42,19 @@ namespace GtkSharp.Generation {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Readable {
|
||||
get {
|
||||
return elem.GetAttribute ("readable") == "true";
|
||||
}
|
||||
}
|
||||
|
||||
bool Writable {
|
||||
get {
|
||||
return elem.GetAttribute ("writeable") == "true" &&
|
||||
!elem.HasAttribute ("construct-only");
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual string PropertyAttribute (string qpname) {
|
||||
return "[GLib.Property (" + qpname + ")]";
|
||||
}
|
||||
|
@ -71,92 +67,57 @@ namespace GtkSharp.Generation {
|
|||
return "SetProperty(" + qpname + ", val)";
|
||||
}
|
||||
|
||||
public void Generate (GenerationInfo gen_info, string indent)
|
||||
public override void Generate (GenerationInfo gen_info, string indent)
|
||||
{
|
||||
SymbolTable table = SymbolTable.Table;
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
|
||||
string c_type = elem.GetAttribute("type");
|
||||
string cs_type = table.GetCSType(c_type);
|
||||
if (Hidden || (!Readable && !Writable))
|
||||
return;
|
||||
|
||||
string modifiers = "";
|
||||
|
||||
if (elem.HasAttribute("new_flag") || (container_type.Parent != null && container_type.Parent.GetPropertyRecursively (Name) != null))
|
||||
if (IsNew || (container_type.Parent != null && container_type.Parent.GetPropertyRecursively (Name) != null))
|
||||
modifiers = "new ";
|
||||
|
||||
string name = Name;
|
||||
if (name == container_type.Name) {
|
||||
name += "Prop";
|
||||
}
|
||||
string qpname = "\"" + elem.GetAttribute("cname") + "\"";
|
||||
string qpname = "\"" + CName + "\"";
|
||||
|
||||
string v_type = "";
|
||||
if (table.IsEnum(c_type)) {
|
||||
if (table.IsEnum(CType)) {
|
||||
v_type = "(int) (GLib.EnumWrapper)";
|
||||
} else if (table.IsObject(c_type) || table.IsInterface (c_type)) {
|
||||
} else if (table.IsObject(CType) || table.IsInterface (CType)) {
|
||||
v_type = "(GLib.UnwrappedObject)";
|
||||
} else if (table.IsBoxed (c_type)) {
|
||||
} else if (table.IsBoxed (CType)) {
|
||||
v_type = "(GLib.Boxed)";
|
||||
} else if (table.IsOpaque (c_type)) {
|
||||
} else if (table.IsOpaque (CType)) {
|
||||
v_type = "(GLib.Opaque)";
|
||||
}
|
||||
|
||||
if (elem.HasAttribute("construct-only") && !elem.HasAttribute("readable")) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool has_getter = false;
|
||||
bool has_setter = false;
|
||||
string getter_type = String.Empty;
|
||||
string setter_type = String.Empty;
|
||||
|
||||
Method getter = container_type.GetMethod("Get" + Name);
|
||||
if (getter != null && getter.Validate () && getter.IsGetter)
|
||||
getter_type = getter.ReturnType;
|
||||
|
||||
Method setter = container_type.GetMethod("Set" + Name);
|
||||
if (setter != null && setter.Validate () && setter.IsSetter)
|
||||
setter_type = setter.Signature.Types;
|
||||
|
||||
if (getter_type != String.Empty && getter_type == setter_type) {
|
||||
has_getter = has_setter = true;
|
||||
getter.GenerateImport (sw);
|
||||
setter.GenerateImport (sw);
|
||||
cs_type = getter_type;
|
||||
} else {
|
||||
if (getter_type == cs_type) {
|
||||
has_getter = true;
|
||||
getter.GenerateImport(sw);
|
||||
}
|
||||
if (setter_type != String.Empty) {
|
||||
has_setter = true;
|
||||
setter.GenerateImport(sw);
|
||||
}
|
||||
|
||||
if (has_setter && setter_type != cs_type)
|
||||
cs_type = setter_type;
|
||||
else if (has_getter && getter_type != cs_type)
|
||||
cs_type = getter_type;
|
||||
}
|
||||
GenerateImports (gen_info, indent);
|
||||
|
||||
sw.WriteLine (indent + PropertyAttribute (qpname));
|
||||
sw.WriteLine (indent + "public " + modifiers + cs_type + " " + name + " {");
|
||||
sw.WriteLine (indent + "public " + modifiers + CSType + " " + name + " {");
|
||||
indent += "\t";
|
||||
|
||||
if (has_getter) {
|
||||
if (Getter != null) {
|
||||
sw.Write(indent + "get ");
|
||||
getter.GenerateBody(gen_info, "\t");
|
||||
Getter.GenerateBody(gen_info, "\t");
|
||||
sw.WriteLine();
|
||||
} else if (elem.HasAttribute("readable")) {
|
||||
} else if (Readable) {
|
||||
sw.WriteLine(indent + "get {");
|
||||
sw.WriteLine(indent + "\tGLib.Value val = " + RawGetter (qpname) + ";");
|
||||
if (table.IsObject (c_type) || table.IsInterface (c_type)) {
|
||||
if (table.IsObject (CType) || table.IsInterface (CType)) {
|
||||
sw.WriteLine(indent + "\tSystem.IntPtr raw_ret = (System.IntPtr) {0} val;", v_type);
|
||||
sw.WriteLine(indent + "\t" + cs_type + " ret = " + table.FromNativeReturn(c_type, "raw_ret") + ";");
|
||||
} else if (table.IsOpaque (c_type) || table.IsBoxed (c_type)) {
|
||||
sw.WriteLine(indent + "\t" + cs_type + " ret = (" + cs_type + ") val;");
|
||||
sw.WriteLine(indent + "\t" + CSType + " ret = " + table.FromNativeReturn(CType, "raw_ret") + ";");
|
||||
} else if (table.IsOpaque (CType) || table.IsBoxed (CType)) {
|
||||
sw.WriteLine(indent + "\t" + CSType + " ret = (" + CSType + ") val;");
|
||||
} else {
|
||||
sw.Write(indent + "\t" + cs_type + " ret = ");
|
||||
sw.Write ("(" + cs_type + ") ");
|
||||
sw.Write(indent + "\t" + CSType + " ret = ");
|
||||
sw.Write ("(" + CSType + ") ");
|
||||
if (v_type != "") {
|
||||
sw.Write(v_type + " ");
|
||||
}
|
||||
|
@ -168,22 +129,22 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine(indent + "}");
|
||||
}
|
||||
|
||||
if (has_setter) {
|
||||
if (Setter != null) {
|
||||
sw.Write(indent + "set ");
|
||||
setter.GenerateBody(gen_info, "\t");
|
||||
Setter.GenerateBody(gen_info, "\t");
|
||||
sw.WriteLine();
|
||||
} else if (elem.HasAttribute("writeable") && !elem.HasAttribute("construct-only")) {
|
||||
} else if (Writable) {
|
||||
sw.WriteLine(indent + "set {");
|
||||
sw.Write(indent + "\tGLib.Value val = ");
|
||||
if (table.IsEnum(c_type)) {
|
||||
sw.WriteLine("new GLib.Value(new GLib.EnumWrapper ((int) value, {0}), \"{1}\");", table.IsEnumFlags (c_type) ? "true" : "false", c_type);
|
||||
} else if (table.IsBoxed (c_type)) {
|
||||
if (table.IsEnum(CType)) {
|
||||
sw.WriteLine("new GLib.Value(new GLib.EnumWrapper ((int) value, {0}), \"{1}\");", table.IsEnumFlags (CType) ? "true" : "false", CType);
|
||||
} else if (table.IsBoxed (CType)) {
|
||||
sw.WriteLine("(GLib.Value) value;");
|
||||
} else if (table.IsOpaque (c_type)) {
|
||||
sw.WriteLine("new GLib.Value(value, \"{0}\");", c_type);
|
||||
} else if (table.IsOpaque (CType)) {
|
||||
sw.WriteLine("new GLib.Value(value, \"{0}\");", CType);
|
||||
} else {
|
||||
sw.Write("new GLib.Value(");
|
||||
if (v_type != "" && !(table.IsObject (c_type) || table.IsInterface (c_type) || table.IsOpaque (c_type))) {
|
||||
if (v_type != "" && !(table.IsObject (CType) || table.IsInterface (CType) || table.IsOpaque (CType))) {
|
||||
sw.Write(v_type + " ");
|
||||
}
|
||||
sw.WriteLine("value);");
|
||||
|
|
120
generator/PropertyBase.cs
Normal file
120
generator/PropertyBase.cs
Normal file
|
@ -0,0 +1,120 @@
|
|||
// GtkSharp.Generation.PropertyBase.cs - base class for properties and
|
||||
// fields
|
||||
//
|
||||
// Copyright (c) 2005 Novell, Inc.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
namespace GtkSharp.Generation {
|
||||
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
public abstract class PropertyBase {
|
||||
|
||||
protected XmlElement elem;
|
||||
protected ClassBase container_type;
|
||||
|
||||
public PropertyBase (XmlElement elem, ClassBase container_type)
|
||||
{
|
||||
this.elem = elem;
|
||||
this.container_type = container_type;
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
return elem.GetAttribute ("name");
|
||||
}
|
||||
}
|
||||
|
||||
public string CName {
|
||||
get {
|
||||
return elem.GetAttribute ("cname");
|
||||
}
|
||||
}
|
||||
|
||||
protected string ctype;
|
||||
public string CType {
|
||||
get {
|
||||
if (ctype == null)
|
||||
ctype = elem.GetAttribute ("type");
|
||||
return ctype;
|
||||
}
|
||||
}
|
||||
|
||||
protected string cstype;
|
||||
public string CSType {
|
||||
get {
|
||||
if (cstype == null)
|
||||
cstype = SymbolTable.Table.GetCSType (CType);
|
||||
return cstype;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Hidden {
|
||||
get {
|
||||
return elem.HasAttribute("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
protected bool IsNew {
|
||||
get {
|
||||
return elem.HasAttribute("new_flag");
|
||||
}
|
||||
}
|
||||
|
||||
Method getter;
|
||||
protected Method Getter {
|
||||
get {
|
||||
if (getter == null) {
|
||||
getter = container_type.GetMethod ("Get" + Name);
|
||||
if (getter != null && getter.Name == "Get" + Name &&
|
||||
getter.Validate () && getter.IsGetter)
|
||||
cstype = getter.ReturnType;
|
||||
else
|
||||
getter = null;
|
||||
}
|
||||
return getter;
|
||||
}
|
||||
}
|
||||
|
||||
Method setter;
|
||||
protected Method Setter {
|
||||
get {
|
||||
if (setter == null) {
|
||||
setter = container_type.GetMethod ("Set" + Name);
|
||||
if (setter != null && setter.Name == "Set" + Name &&
|
||||
setter.Validate () && setter.IsSetter)
|
||||
cstype = setter.Signature.Types;
|
||||
else
|
||||
setter = null;
|
||||
}
|
||||
return setter;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void GenerateImports (GenerationInfo gen_info, string indent)
|
||||
{
|
||||
if (Getter != null)
|
||||
Getter.GenerateImport (gen_info.Writer);
|
||||
if (Setter != null)
|
||||
Setter.GenerateImport (gen_info.Writer);
|
||||
}
|
||||
|
||||
public abstract void Generate (GenerationInfo gen_info, string indent);
|
||||
}
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ namespace GtkSharp.Generation {
|
|||
|
||||
switch (node.Name) {
|
||||
case "field":
|
||||
fields.Add (new Field (member));
|
||||
fields.Add (new StructField (member, this));
|
||||
break;
|
||||
|
||||
case "callback":
|
||||
|
@ -112,11 +112,11 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
protected void GenFields (StreamWriter sw)
|
||||
protected void GenFields (GenerationInfo gen_info)
|
||||
{
|
||||
Field.bitfields = 0;
|
||||
StructField.bitfields = 0;
|
||||
bool need_field = true;
|
||||
foreach (Field field in fields) {
|
||||
foreach (StructField field in fields) {
|
||||
if (field.IsBit) {
|
||||
if (need_field)
|
||||
need_field = false;
|
||||
|
@ -124,13 +124,13 @@ namespace GtkSharp.Generation {
|
|||
continue;
|
||||
} else
|
||||
need_field = true;
|
||||
field.Generate (sw);
|
||||
field.Generate (gen_info, "\t\t");
|
||||
}
|
||||
}
|
||||
|
||||
public bool Validate ()
|
||||
{
|
||||
foreach (Field field in fields) {
|
||||
foreach (StructField field in fields) {
|
||||
if (!field.Validate ()) {
|
||||
Console.WriteLine ("in Struct " + QualifiedName);
|
||||
return false;
|
||||
|
@ -162,7 +162,7 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("\tpublic struct " + Name + " {");
|
||||
sw.WriteLine ();
|
||||
|
||||
GenFields (sw);
|
||||
GenFields (gen_info);
|
||||
sw.WriteLine ();
|
||||
GenCtors (gen_info);
|
||||
GenMethods (gen_info, null, null);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// GtkSharp.Generation.Field.cs - The Field generation Class.
|
||||
// GtkSharp.Generation.StructField.cs - The Structure Field generation
|
||||
// Class.
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@ximian.com>
|
||||
//
|
||||
|
@ -25,20 +26,15 @@ namespace GtkSharp.Generation {
|
|||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
public class Field {
|
||||
public class StructField : FieldBase {
|
||||
|
||||
public static int bitfields;
|
||||
|
||||
XmlElement elem;
|
||||
public StructField (XmlElement elem, ClassBase container_type) : base (elem, container_type) {}
|
||||
|
||||
public Field (XmlElement elem)
|
||||
{
|
||||
this.elem = elem;
|
||||
}
|
||||
|
||||
public string Access {
|
||||
protected override string DefaultAccess {
|
||||
get {
|
||||
return elem.HasAttribute ("access") ? elem.GetAttribute ("access") : "public";
|
||||
return "public";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,9 +55,9 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public string CSType {
|
||||
public new string CSType {
|
||||
get {
|
||||
string type = SymbolTable.Table.GetCSType (CType);
|
||||
string type = base.CSType;
|
||||
if (IsArray)
|
||||
type += "[]";
|
||||
else if (IsBit)
|
||||
|
@ -75,34 +71,15 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public string CType {
|
||||
get {
|
||||
return elem.GetAttribute ("type");
|
||||
}
|
||||
}
|
||||
|
||||
public bool Hidden {
|
||||
get {
|
||||
return elem.HasAttribute("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsArray {
|
||||
get {
|
||||
return elem.HasAttribute("array_len");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsBit {
|
||||
get {
|
||||
return (elem.HasAttribute("bits") && (elem.GetAttribute("bits") == "1"));
|
||||
return elem.GetAttribute("bits") == "1";
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPadding {
|
||||
get {
|
||||
string c_name = elem.GetAttribute ("cname");
|
||||
return (c_name.StartsWith ("dummy") || c_name.StartsWith ("padding"));
|
||||
return (CName.StartsWith ("dummy") || CName.StartsWith ("padding"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +89,7 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public string Name {
|
||||
public new string Name {
|
||||
get {
|
||||
string result = "";
|
||||
if ((IsPointer || SymbolTable.Table.IsOpaque (CType)) && CSType != "string")
|
||||
|
@ -121,7 +98,7 @@ namespace GtkSharp.Generation {
|
|||
if (IsBit)
|
||||
result = String.Format ("_bitfield{0}", bitfields++);
|
||||
else
|
||||
result += SymbolTable.Table.MangleName (elem.GetAttribute ("cname"));
|
||||
result += SymbolTable.Table.MangleName (CName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -129,14 +106,14 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public string StudlyName {
|
||||
get {
|
||||
string studly = elem.GetAttribute ("name");
|
||||
string studly = base.Name;
|
||||
if (studly != "")
|
||||
return studly;
|
||||
|
||||
// FIXME: this is backward compatibility for API files
|
||||
// output by older versions of the parser. It can go
|
||||
// away at some point.
|
||||
string name = elem.GetAttribute ("cname");
|
||||
string name = CName;
|
||||
string[] segs = name.Split('_');
|
||||
foreach (string s in segs) {
|
||||
if (s.Trim () == "")
|
||||
|
@ -150,74 +127,75 @@ namespace GtkSharp.Generation {
|
|||
public bool Validate ()
|
||||
{
|
||||
if (CSType == "" && !Hidden) {
|
||||
Console.Write ("Field has unknown Type {0} ", CType);
|
||||
Console.Write ("Field {0} has unknown Type {1} ", Name, CType);
|
||||
Statistics.ThrottledCount++;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Generate (StreamWriter sw)
|
||||
public override void Generate (GenerationInfo gen_info, string indent)
|
||||
{
|
||||
if (Hidden)
|
||||
return;
|
||||
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
SymbolTable table = SymbolTable.Table;
|
||||
|
||||
if (IsArray)
|
||||
sw.WriteLine ("\t\t[MarshalAs (UnmanagedType.ByValArray, SizeConst=" + ArrayLength + ")]");
|
||||
sw.WriteLine (indent + "[MarshalAs (UnmanagedType.ByValArray, SizeConst=" + ArrayLength + ")]");
|
||||
|
||||
string wrapped = table.GetCSType (CType);
|
||||
string wrapped_name = SymbolTable.Table.MangleName (elem.GetAttribute ("cname"));
|
||||
string wrapped_name = SymbolTable.Table.MangleName (CName);
|
||||
IGeneratable gen = table [CType];
|
||||
|
||||
if (IsArray) {
|
||||
sw.WriteLine ("\t\t{0} {1} {2};", Access, CSType, StudlyName);
|
||||
sw.WriteLine (indent + "{0} {1} {2};", Access, CSType, StudlyName);
|
||||
} else if (IsPadding) {
|
||||
sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name);
|
||||
sw.WriteLine (indent + "private {0} {1};", CSType, Name);
|
||||
} else if (IsBit) {
|
||||
// FIXME
|
||||
sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name);
|
||||
sw.WriteLine (indent + "private {0} {1};", CSType, Name);
|
||||
} else if (table.IsCallback (CType)) {
|
||||
// FIXME
|
||||
sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name);
|
||||
sw.WriteLine (indent + "private {0} {1};", CSType, Name);
|
||||
} else if (gen is LPGen || gen is LPUGen) {
|
||||
sw.WriteLine ("\t\tprivate " + gen.MarshalType + " " + Name + ";");
|
||||
sw.WriteLine ("\t\tpublic " + CSType + " " + StudlyName + " {");
|
||||
sw.WriteLine ("\t\t\tget {");
|
||||
sw.WriteLine ("\t\t\t\treturn " + gen.FromNative (Name) + ";");
|
||||
sw.WriteLine ("\t\t\t}");
|
||||
sw.WriteLine ("\t\t\tset {");
|
||||
sw.WriteLine ("\t\t\t\t" + Name + " = " + gen.CallByName ("value") + ";");
|
||||
sw.WriteLine ("\t\t\t}");
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine (indent + "private " + gen.MarshalType + " " + Name + ";");
|
||||
sw.WriteLine (indent + "public " + CSType + " " + StudlyName + " {");
|
||||
sw.WriteLine (indent + "\tget {");
|
||||
sw.WriteLine (indent + "\t\treturn " + gen.FromNative (Name) + ";");
|
||||
sw.WriteLine (indent + "\t}");
|
||||
sw.WriteLine (indent + "\tset {");
|
||||
sw.WriteLine (indent + "\t\t" + Name + " = " + gen.CallByName ("value") + ";");
|
||||
sw.WriteLine (indent + "\t}");
|
||||
sw.WriteLine (indent + "}");
|
||||
} else if (table.IsObject (CType) || table.IsOpaque (CType)) {
|
||||
sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name);
|
||||
sw.WriteLine (indent + "private {0} {1};", CSType, Name);
|
||||
|
||||
if (Access != "private") {
|
||||
sw.WriteLine ("\t\t" + Access + " " + wrapped + " " + wrapped_name + " {");
|
||||
sw.WriteLine ("\t\t\tget { ");
|
||||
sw.WriteLine ("\t\t\t\treturn " + table.FromNativeReturn(CType, Name) + ";");
|
||||
sw.WriteLine ("\t\t\t}");
|
||||
sw.WriteLine (indent + "" + Access + " " + wrapped + " " + wrapped_name + " {");
|
||||
sw.WriteLine (indent + "\tget { ");
|
||||
sw.WriteLine (indent + "\t\treturn " + table.FromNativeReturn(CType, Name) + ";");
|
||||
sw.WriteLine (indent + "\t}");
|
||||
|
||||
sw.WriteLine ("\t\t\tset { " + Name + " = " + table.CallByName (CType, "value") + "; }");
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine (indent + "\tset { " + Name + " = " + table.CallByName (CType, "value") + "; }");
|
||||
sw.WriteLine (indent + "}");
|
||||
}
|
||||
} else if (IsPointer && (table.IsStruct (CType) || table.IsBoxed (CType))) {
|
||||
sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name);
|
||||
sw.WriteLine (indent + "private {0} {1};", CSType, Name);
|
||||
sw.WriteLine ();
|
||||
if (Access != "private") {
|
||||
sw.WriteLine ("\t\t" + Access + " " + wrapped + " " + wrapped_name + " {");
|
||||
sw.WriteLine ("\t\t\tget { return " + table.FromNativeReturn (CType, Name) + "; }");
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine (indent + "" + Access + " " + wrapped + " " + wrapped_name + " {");
|
||||
sw.WriteLine (indent + "\tget { return " + table.FromNativeReturn (CType, Name) + "; }");
|
||||
sw.WriteLine (indent + "}");
|
||||
}
|
||||
} else if (IsPointer && CSType != "string") {
|
||||
// FIXME: probably some fields here which should be visible.
|
||||
sw.WriteLine ("\t\tprivate {0} {1};", CSType, Name);
|
||||
sw.WriteLine (indent + "private {0} {1};", CSType, Name);
|
||||
} else if (Access != "public") {
|
||||
sw.WriteLine ("\t\t{0} {1} {2};", Access, CSType, Name);
|
||||
sw.WriteLine (indent + "{0} {1} {2};", Access, CSType, Name);
|
||||
} else {
|
||||
sw.WriteLine ("\t\tpublic {0} {1};", CSType, StudlyName);
|
||||
sw.WriteLine (indent + "public {0} {1};", CSType, StudlyName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -55,6 +55,7 @@
|
|||
<attr path="/api/namespace/object[@cname='GnomeCanvasShape']/property[@name='Dash']" name="type">ArtVpathDash</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeClient']/signal[@name='Connect']" name="name">Connected</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeClient']/signal[@name='Disconnect']" name="name">Disconnected</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeDateEdit']/method[@name='GetInitialTime']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeDialog']/method[@name='Close']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeDialog']/method[@name='SetClose']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeDialog']/method[@name='SetDefault']" name="new_flag">1</attr>
|
||||
|
@ -68,7 +69,7 @@
|
|||
<attr path="/api/namespace/object[@cname='GnomeDruidPageEdge']/constructor[@cname='gnome_druid_page_edge_new']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeDruidPageEdge']/constructor[@cname='gnome_druid_page_edge_new_with_vals']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeDruidPageEdge']/constructor[@cname='gnome_druid_page_edge_new_aa']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeEntry']/method[@name='GtkEntry']" name="name">GetGtkEntry</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeEntry']/method[@name='GtkEntry']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeEntry']/signal[@name='Activate']" name="name">Activated</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFileEntry']/method[@name='GnomeEntry']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFileEntry']/method[@name='GtkEntry']" name="hidden">1</attr>
|
||||
|
@ -78,14 +79,16 @@
|
|||
<attr path="/api/namespace/object[@cname='GnomeFont']/method[@name='StyleList']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFont']/method[@name='StyleListFree']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFont']/method/*/*[@type='const-guchar*']" name="type">const-gchar*</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFont']/method/*/*[@type='const-guchar*']" name="type">const-gchar*</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFontPreview']/method/*/*[@type='const-guchar*']" name="type">const-gchar*</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFont']/method[@name='GetFamilyName']/return-type" name="type">const-gchar*</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFont']/method[@name='GetFullName']/return-type" name="type">gchar*</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFontFace']/method/return-type[@type='const-guchar*']" name="type">const-gchar*</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFontFace']/method/*/*[@type='const-guchar*']" name="type">const-gchar*</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFontFamily']/method[@name='List']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFontFamily']/method[@name='ListFree']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFontFamily']/method[@name='StyleList']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFontFamily']/method[@name='StyleListFree']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFontPicker']/method[@name='GetFont']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeFontPreview']/method/*/*[@type='const-guchar*']" name="type">const-gchar*</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeIconEntry']/method[@name='PickDialog']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeIconList']/constructor[@cname='gnome_icon_list_new']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GnomeIconList']/method[@name='GetSelection']" name="hidden">1</attr>
|
||||
|
|
Loading…
Reference in a new issue