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:
parent
54838fec29
commit
71b46ecd41
5 changed files with 71 additions and 7 deletions
|
@ -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>
|
2002-08-03 Rachel Hestilow <hestilow@ximian.com>
|
||||||
|
|
||||||
* generator/Method.cs: Support libname overrides. Call parms.Finish.
|
* generator/Method.cs: Support libname overrides. Call parms.Finish.
|
||||||
|
|
|
@ -39,6 +39,18 @@ namespace GtkSharp.Generation {
|
||||||
this.libname = libname;
|
this.libname = libname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsGetter {
|
||||||
|
get {
|
||||||
|
return is_get;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsSetter {
|
||||||
|
get {
|
||||||
|
return is_set;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string Name {
|
public string Name {
|
||||||
get {
|
get {
|
||||||
return name;
|
return name;
|
||||||
|
@ -63,6 +75,12 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string ReturnType {
|
||||||
|
get {
|
||||||
|
return s_ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override bool Equals (object o)
|
public override bool Equals (object o)
|
||||||
{
|
{
|
||||||
if (!(o is Method))
|
if (!(o is Method))
|
||||||
|
@ -258,7 +276,7 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine("\t\t/// <remarks> To be completed </remarks>");
|
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.WriteLine("\t\t[DllImport(\"" + libname + "\")]");
|
||||||
sw.Write("\t\tstatic extern " + safety + m_ret + " " + cname + isig);
|
sw.Write("\t\tstatic extern " + safety + m_ret + " " + cname + isig);
|
||||||
|
@ -337,7 +355,12 @@ namespace GtkSharp.Generation {
|
||||||
Statistics.MethodCount++;
|
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(" {");
|
sw.WriteLine(" {");
|
||||||
if (parms != null)
|
if (parms != null)
|
||||||
|
|
|
@ -25,6 +25,12 @@ namespace GtkSharp.Generation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string MarshalType {
|
||||||
|
get {
|
||||||
|
return SymbolTable.GetMarshalType( elem.GetAttribute("type"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string Name {
|
public string Name {
|
||||||
get {
|
get {
|
||||||
string name = elem.GetAttribute("name");
|
string name = elem.GetAttribute("name");
|
||||||
|
|
|
@ -59,8 +59,8 @@ namespace GtkSharp.Generation {
|
||||||
modifiers = "new ";
|
modifiers = "new ";
|
||||||
|
|
||||||
XmlElement parent = (XmlElement) elem.ParentNode;
|
XmlElement parent = (XmlElement) elem.ParentNode;
|
||||||
string name = elem.GetAttribute("name");
|
string name = Name;
|
||||||
if (name == parent.GetAttribute("name")) {
|
if (name == container_type.Name) {
|
||||||
name += "Prop";
|
name += "Prop";
|
||||||
}
|
}
|
||||||
string cname = "\"" + elem.GetAttribute("cname") + "\"";
|
string cname = "\"" + elem.GetAttribute("cname") + "\"";
|
||||||
|
@ -85,13 +85,36 @@ namespace GtkSharp.Generation {
|
||||||
return;
|
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();
|
||||||
sw.WriteLine("\t\t/// <summary> " + name + " Property </summary>");
|
sw.WriteLine("\t\t/// <summary> " + name + " Property </summary>");
|
||||||
sw.WriteLine("\t\t/// <remarks>");
|
sw.WriteLine("\t\t/// <remarks>");
|
||||||
sw.WriteLine("\t\t/// </remarks>");
|
sw.WriteLine("\t\t/// </remarks>");
|
||||||
|
|
||||||
sw.WriteLine("\t\tpublic " + modifiers + cs_type + " " + name + " {");
|
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\tget {");
|
||||||
sw.WriteLine("\t\t\t\tGLib.Value val = new GLib.Value (Handle, " + cname + ");");
|
sw.WriteLine("\t\t\t\tGLib.Value val = new GLib.Value (Handle, " + cname + ");");
|
||||||
sw.WriteLine("\t\t\t\tGetProperty(" + cname + ", val);");
|
sw.WriteLine("\t\t\t\tGetProperty(" + cname + ", val);");
|
||||||
|
@ -113,7 +136,11 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine("\t\t\t}");
|
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.WriteLine("\t\t\tset {");
|
||||||
sw.Write("\t\t\t\tSetProperty(" + cname + ", new GLib.Value(");
|
sw.Write("\t\t\t\tSetProperty(" + cname + ", new GLib.Value(");
|
||||||
if (SymbolTable.IsEnum(c_type)) {
|
if (SymbolTable.IsEnum(c_type)) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace GtkSamples {
|
||||||
darea.ConfigureEvent += new ConfigureEventHandler (ConfigureEvent);
|
darea.ConfigureEvent += new ConfigureEventHandler (ConfigureEvent);
|
||||||
darea.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotifyEvent);
|
darea.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotifyEvent);
|
||||||
darea.ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEvent);
|
darea.ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEvent);
|
||||||
darea.Events = EventMask.ExposureMask |
|
darea.Events = (int)EventMask.ExposureMask |
|
||||||
EventMask.LeaveNotifyMask |
|
EventMask.LeaveNotifyMask |
|
||||||
EventMask.ButtonPressMask |
|
EventMask.ButtonPressMask |
|
||||||
EventMask.PointerMotionMask |
|
EventMask.PointerMotionMask |
|
||||||
|
|
Loading…
Reference in a new issue