diff --git a/ChangeLog b/ChangeLog index 4d3263747..ddb4cba56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-12-02 Stephane Delcroix + + * generator/Ctor.cs: + * generator/Method.cs: + * generator/MethodBase.cs: refactor the Protection from Method to + MethodBase, generate ctors with the correct proteciton too. + 2008-12-01 Mike Kestner * gtk/Gtk.metadata: automarshal TreeSelection.GetSelectedRows. diff --git a/generator/Ctor.cs b/generator/Ctor.cs index b39a33615..9d5704316 100644 --- a/generator/Ctor.cs +++ b/generator/Ctor.cs @@ -71,7 +71,7 @@ namespace GtkSharp.Generation { void GenerateStatic (GenerationInfo gen_info) { StreamWriter sw = gen_info.Writer; - sw.WriteLine("\t\tpublic static " + Safety + Modifiers + name + " " + StaticName + "(" + Signature + ")"); + sw.WriteLine("\t\t" + Protection + " static " + Safety + Modifiers + name + " " + StaticName + "(" + Signature + ")"); sw.WriteLine("\t\t{"); Body.Initialize(gen_info, false, false, ""); @@ -100,7 +100,7 @@ namespace GtkSharp.Generation { if (IsStatic) GenerateStatic (gen_info); else { - sw.WriteLine("\t\tpublic {0}{1} ({2}) {3}", Safety, name, Signature.ToString(), needs_chaining ? ": base (IntPtr.Zero)" : ""); + sw.WriteLine("\t\t{0} {1}{2} ({3}) {4}", Protection, Safety, name, Signature.ToString(), needs_chaining ? ": base (IntPtr.Zero)" : ""); sw.WriteLine("\t\t{"); if (needs_chaining) { diff --git a/generator/Method.cs b/generator/Method.cs index 0527837b2..76cd72104 100644 --- a/generator/Method.cs +++ b/generator/Method.cs @@ -32,7 +32,6 @@ namespace GtkSharp.Generation { private ReturnValue retval; private string call; - private string protection = "public"; private bool is_get, is_set; private bool deprecated = false; @@ -44,18 +43,6 @@ namespace GtkSharp.Generation { string attr = elem.GetAttribute ("deprecated"); deprecated = attr == "1" || attr == "true"; } - if (elem.HasAttribute ("accessibility")) { - string attr = elem.GetAttribute ("accessibility"); - switch (attr) { - case "public": - case "protected": - case "internal": - case "private": - case "protected internal": - protection = attr; - break; - } - } if (Name == "GetType") Name = "GetGType"; @@ -79,15 +66,6 @@ namespace GtkSharp.Generation { } } - public string Protection { - get { - return protection; - } - set { - protection = value; - } - } - public string ReturnType { get { return retval.CSType; @@ -251,8 +229,8 @@ namespace GtkSharp.Generation { if (IsDeprecated) gen_info.Writer.WriteLine("\t\t[Obsolete]"); gen_info.Writer.Write("\t\t"); - if (protection != "") - gen_info.Writer.Write("{0} ", protection); + if (Protection != "") + gen_info.Writer.Write("{0} ", Protection); GenerateDeclCommon (gen_info.Writer, implementor); if (is_get || is_set) diff --git a/generator/MethodBase.cs b/generator/MethodBase.cs index 8b4a80b34..9a25fa0e7 100644 --- a/generator/MethodBase.cs +++ b/generator/MethodBase.cs @@ -33,6 +33,7 @@ namespace GtkSharp.Generation { bool is_static = false; string mods = String.Empty; string name; + private string protection = "public"; protected MethodBase (XmlElement elem, ClassBase container_type) { @@ -43,6 +44,18 @@ namespace GtkSharp.Generation { IsStatic = elem.GetAttribute ("shared") == "true"; if (elem.HasAttribute ("new_flag")) mods = "new "; + if (elem.HasAttribute ("accessibility")) { + string attr = elem.GetAttribute ("accessibility"); + switch (attr) { + case "public": + case "protected": + case "internal": + case "private": + case "protected internal": + protection = attr; + break; + } + } } protected string BaseName { @@ -135,7 +148,12 @@ namespace GtkSharp.Generation { return parms; } } - + + public string Protection { + get { return protection; } + set { protection = value; } + } + protected string Safety { get { return Body.ThrowsException && !(container_type is InterfaceGen) ? "unsafe " : "";