From 87d4d29dfd18b22f58a582da33d6fa5052dab469 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 24 Aug 2017 10:20:05 -0300 Subject: [PATCH] Some fixes to support updated gstreamer-sharp (#29) * parameters: Ignore UserData arguments to compute if has_optional Those are never present in the prototypes and thus should not be taken into account to see if prototype alternative has to be implemented. * Fix generation of interface properties * generator: Enhance the way we check if a field is padding First check that fields are private to see if a field is padding, in GstVideo we have public field staring with padding (VideoAlignment.padding_top/bottomg/left/right) and thus need to be taken into account to compare structures. Also add a way for user to specify that the field is padding with the new `is-padding` attribute. In GStreamer padding fields usually look like __gst_reservedX, meaning that they go unnoticed by previous code. --- generator/Parameters.cs | 2 +- generator/Property.cs | 4 ++++ generator/StructField.cs | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/generator/Parameters.cs b/generator/Parameters.cs index 9ebecea17..1b0544d5f 100644 --- a/generator/Parameters.cs +++ b/generator/Parameters.cs @@ -206,7 +206,7 @@ namespace GtkSharp.Generation { return false; } - if (p.IsOptional && p.PassAs == String.Empty) + if (p.IsOptional && p.PassAs == String.Empty && p.IsUserData == false) has_optional = true; IGeneratable gen = p.Generatable; diff --git a/generator/Property.cs b/generator/Property.cs index 7e0e09549..5dd7cc74a 100644 --- a/generator/Property.cs +++ b/generator/Property.cs @@ -68,10 +68,14 @@ namespace GtkSharp.Generation { } protected virtual string RawGetter (string qpname) { + if (container_type is InterfaceGen) + return "implementor.GetProperty (" + qpname + ")"; return "GetProperty (" + qpname + ")"; } protected virtual string RawSetter (string qpname) { + if (container_type is InterfaceGen) + return "implementor.SetProperty(" + qpname + ", val)"; return "SetProperty(" + qpname + ", val)"; } diff --git a/generator/StructField.cs b/generator/StructField.cs index 292d99814..78a15fb36 100644 --- a/generator/StructField.cs +++ b/generator/StructField.cs @@ -102,7 +102,11 @@ namespace GtkSharp.Generation { public bool IsPadding { get { - return (CName.StartsWith ("dummy") || CName.StartsWith ("padding")); + if (elem.GetAttributeAsBoolean ("is-padding")) + return elem.GetAttributeAsBoolean ("is-padding"); + + return (elem.GetAttribute ("access") == "private" && ( + CName.StartsWith ("dummy") || CName.StartsWith ("padding"))); } }