2002-08-03 Mike Kestner <mkestner@speakeasy.net>

* generator/Method.cs : Added IsGetter, IsSetter, ReturnType. Made
	  GenerateImport, GenerateBody public.
	* generator/Parameters.cs : Added Parameter::MarshalType
	* generator/Property.cs : Added logic to use methods instead of text
	  properties wherever possible.

svn path=/trunk/gtk-sharp/; revision=6391
This commit is contained in:
Mike Kestner 2002-08-04 04:23:13 +00:00
parent 54838fec29
commit 71b46ecd41
5 changed files with 71 additions and 7 deletions

View file

@ -1,3 +1,11 @@
2002-08-03 Mike Kestner <mkestner@speakeasy.net>
* generator/Method.cs : Added IsGetter, IsSetter, ReturnType. Made
GenerateImport, GenerateBody public.
* generator/Parameters.cs : Added Parameter::MarshalType
* generator/Property.cs : Added logic to use methods instead of text
properties wherever possible.
2002-08-03 Rachel Hestilow <hestilow@ximian.com>
* generator/Method.cs: Support libname overrides. Call parms.Finish.

View file

@ -39,6 +39,18 @@ namespace GtkSharp.Generation {
this.libname = libname;
}
public bool IsGetter {
get {
return is_get;
}
}
public bool IsSetter {
get {
return is_set;
}
}
public string Name {
get {
return name;
@ -63,6 +75,12 @@ namespace GtkSharp.Generation {
}
}
public string ReturnType {
get {
return s_ret;
}
}
public override bool Equals (object o)
{
if (!(o is Method))
@ -258,7 +276,7 @@ namespace GtkSharp.Generation {
sw.WriteLine("\t\t/// <remarks> To be completed </remarks>");
}
protected void GenerateImport (StreamWriter sw)
public void GenerateImport (StreamWriter sw)
{
sw.WriteLine("\t\t[DllImport(\"" + libname + "\")]");
sw.Write("\t\tstatic extern " + safety + m_ret + " " + cname + isig);
@ -337,7 +355,12 @@ namespace GtkSharp.Generation {
Statistics.MethodCount++;
}
protected void GenerateBody (StreamWriter sw, string indent)
public void GenerateBody (StreamWriter sw, string indent)
{
GenerateBody(sw, indent, "");
}
public void GenerateBody (StreamWriter sw, string indent, string cast_type)
{
sw.WriteLine(" {");
if (parms != null)

View file

@ -25,6 +25,12 @@ namespace GtkSharp.Generation {
}
}
public string MarshalType {
get {
return SymbolTable.GetMarshalType( elem.GetAttribute("type"));
}
}
public string Name {
get {
string name = elem.GetAttribute("name");

View file

@ -59,8 +59,8 @@ namespace GtkSharp.Generation {
modifiers = "new ";
XmlElement parent = (XmlElement) elem.ParentNode;
string name = elem.GetAttribute("name");
if (name == parent.GetAttribute("name")) {
string name = Name;
if (name == container_type.Name) {
name += "Prop";
}
string cname = "\"" + elem.GetAttribute("cname") + "\"";
@ -85,13 +85,36 @@ namespace GtkSharp.Generation {
return;
}
bool has_getter = false;
bool has_setter = false;
Method getter = container_type.GetMethod("Get" + Name);
Method setter = container_type.GetMethod("Set" + Name);
if (getter != null && getter.Validate() && getter.IsGetter) {
has_getter = true;
getter.GenerateImport(sw);
}
if (setter != null && setter.Validate() && setter.IsSetter) {
has_setter = true;
setter.GenerateImport(sw);
}
if (has_setter && setter.Params[0].CSType != cs_type)
cs_type = setter.Params[0].CSType;
else if (has_getter && getter.ReturnType != cs_type)
cs_type = getter.ReturnType;
sw.WriteLine();
sw.WriteLine("\t\t/// <summary> " + name + " Property </summary>");
sw.WriteLine("\t\t/// <remarks>");
sw.WriteLine("\t\t/// </remarks>");
sw.WriteLine("\t\tpublic " + modifiers + cs_type + " " + name + " {");
if (elem.HasAttribute("readable")) {
if (has_getter) {
sw.Write("\t\t\tget ");
getter.GenerateBody(sw, "\t", c_type);
sw.WriteLine();
} else 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);");
@ -113,7 +136,11 @@ namespace GtkSharp.Generation {
sw.WriteLine("\t\t\t}");
}
if (elem.HasAttribute("writeable") && !elem.HasAttribute("construct-only")) {
if (has_setter) {
sw.Write("\t\t\tset ");
setter.GenerateBody(sw, "\t", c_type);
sw.WriteLine();
} else if (elem.HasAttribute("writeable") && !elem.HasAttribute("construct-only")) {
sw.WriteLine("\t\t\tset {");
sw.Write("\t\t\t\tSetProperty(" + cname + ", new GLib.Value(");
if (SymbolTable.IsEnum(c_type)) {

View file

@ -29,7 +29,7 @@ namespace GtkSamples {
darea.ConfigureEvent += new ConfigureEventHandler (ConfigureEvent);
darea.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotifyEvent);
darea.ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEvent);
darea.Events = EventMask.ExposureMask |
darea.Events = (int)EventMask.ExposureMask |
EventMask.LeaveNotifyMask |
EventMask.ButtonPressMask |
EventMask.PointerMotionMask |