generator: Add a way to force constructors to be names

In some cases (GstEvent) unnamed constructors make no sense
This commit is contained in:
Thibault Saunier 2018-03-13 09:56:11 -03:00 committed by Harry
parent dd8f3f994e
commit 9002cefe44
2 changed files with 12 additions and 1 deletions

View file

@ -46,6 +46,12 @@ namespace GtkSharp.Generation {
private Dictionary<string, Ctor> clash_map; private Dictionary<string, Ctor> clash_map;
private bool deprecated = false; private bool deprecated = false;
private bool isabstract = false; private bool isabstract = false;
public bool nameConstructors {
get {
return Elem.GetAttributeAsBoolean("name_constructors");
}
}
public IDictionary<string, Method> Methods { public IDictionary<string, Method> Methods {
get { get {
@ -563,7 +569,11 @@ namespace GtkSharp.Generation {
clash_map = new Dictionary<string, Ctor>(); clash_map = new Dictionary<string, Ctor>();
foreach (Ctor ctor in ctors) { foreach (Ctor ctor in ctors) {
if (clash_map.ContainsKey (ctor.Signature.Types)) { if (nameConstructors) {
ctor.IsStatic = true;
if (Parent != null && Parent.HasStaticCtor (ctor.StaticName))
ctor.Modifiers = "new ";
} else if (clash_map.ContainsKey (ctor.Signature.Types)) {
Ctor clash = clash_map [ctor.Signature.Types]; Ctor clash = clash_map [ctor.Signature.Types];
Ctor alter = ctor.Preferred ? clash : ctor; Ctor alter = ctor.Preferred ? clash : ctor;
alter.IsStatic = true; alter.IsStatic = true;

View file

@ -38,6 +38,7 @@ namespace GtkSharp.Generation {
preferred = elem.GetAttributeAsBoolean ("preferred"); preferred = elem.GetAttributeAsBoolean ("preferred");
if (implementor is ObjectGen) if (implementor is ObjectGen)
needs_chaining = true; needs_chaining = true;
name = implementor.Name; name = implementor.Name;
} }