From 9002cefe44d135058be9946beb66848ad88082d1 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 13 Mar 2018 09:56:11 -0300 Subject: [PATCH] generator: Add a way to force constructors to be names In some cases (GstEvent) unnamed constructors make no sense --- Source/Tools/GapiCodegen/ClassBase.cs | 12 +++++++++++- Source/Tools/GapiCodegen/Ctor.cs | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Tools/GapiCodegen/ClassBase.cs b/Source/Tools/GapiCodegen/ClassBase.cs index 375a79a74..0ff0bb58d 100644 --- a/Source/Tools/GapiCodegen/ClassBase.cs +++ b/Source/Tools/GapiCodegen/ClassBase.cs @@ -46,6 +46,12 @@ namespace GtkSharp.Generation { private Dictionary clash_map; private bool deprecated = false; private bool isabstract = false; + public bool nameConstructors { + get { + return Elem.GetAttributeAsBoolean("name_constructors"); + } + } + public IDictionary Methods { get { @@ -563,7 +569,11 @@ namespace GtkSharp.Generation { clash_map = new Dictionary(); 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 alter = ctor.Preferred ? clash : ctor; alter.IsStatic = true; diff --git a/Source/Tools/GapiCodegen/Ctor.cs b/Source/Tools/GapiCodegen/Ctor.cs index 8acde2a42..d2c04963f 100644 --- a/Source/Tools/GapiCodegen/Ctor.cs +++ b/Source/Tools/GapiCodegen/Ctor.cs @@ -38,6 +38,7 @@ namespace GtkSharp.Generation { preferred = elem.GetAttributeAsBoolean ("preferred"); if (implementor is ObjectGen) needs_chaining = true; + name = implementor.Name; }