diff --git a/src/Generation/Generator3/Generation/Record/PublicClass/PublicClassModel.cs b/src/Generation/Generator3/Generation/Record/PublicClass/PublicClassModel.cs index a077ef680..a1115e37d 100644 --- a/src/Generation/Generator3/Generation/Record/PublicClass/PublicClassModel.cs +++ b/src/Generation/Generator3/Generation/Record/PublicClass/PublicClassModel.cs @@ -8,6 +8,8 @@ public class PublicClassModel public string Name => _record.GetPublicClassName(); public string InternalHandleName => _record.GetInternalHandleName(); + public string InternalOwnedHandleName => _record.GetInternalOwnedHandleName(); + public string InternalUnownedHandleName => _record.GetInternalUnownedHandleName(); public string NamespaceName => _record.Namespace.Name; public PublicClassModel(GirModel.Record record) diff --git a/src/Generation/Generator3/Generation/Record/PublicClass/PublicClassTemplate.cs b/src/Generation/Generator3/Generation/Record/PublicClass/PublicClassTemplate.cs index f39606ab1..f0ef6ea6f 100644 --- a/src/Generation/Generator3/Generation/Record/PublicClass/PublicClassTemplate.cs +++ b/src/Generation/Generator3/Generation/Record/PublicClass/PublicClassTemplate.cs @@ -31,6 +31,12 @@ public partial class {model.Name} : GLib.IHandle Initialize(); }} + //TODO: This is a workaround constructor as long as we are + //not having https://github.com/gircore/gir.core/issues/397 + private {model.Name}(IntPtr ptr, bool ownsHandle) : this(ownsHandle + ? new Internal.{model.InternalOwnedHandleName}(ptr) + : new Internal.{model.InternalUnownedHandleName}(ptr)){{ }} + // TODO: Default Constructor (allocate in managed memory and free on Dispose?) // We need to be able to create instances of records with full access to // fields, e.g. Gdk.Rectangle, Gtk.TreeIter, etc.