diff --git a/src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs b/src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs index e5901696..944d8d7d 100644 --- a/src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs +++ b/src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Reflection; using System.Text; using CppSharp.AST; +using Type = CppSharp.AST.Type; namespace CppSharp.Passes { @@ -94,7 +95,8 @@ namespace CppSharp.Passes { string name = GetPropertyName(getter.Name); if (string.Compare(name, afterSet, StringComparison.OrdinalIgnoreCase) == 0 && - getter.OriginalReturnType == setter.Parameters[0].QualifiedType && + GetUnderlyingType(getter.OriginalReturnType).Equals( + GetUnderlyingType(setter.Parameters[0].QualifiedType)) && !type.Methods.Any( m => m != getter && @@ -132,6 +134,17 @@ namespace CppSharp.Passes } } + private static Type GetUnderlyingType(QualifiedType type) + { + TagType tagType = type.Type as TagType; + if (tagType != null) + return type.Type; + if (!type.Qualifiers.IsConst) + return type.Type; + PointerType pointerType = type.Type as PointerType; + return pointerType != null ? pointerType.Pointee : type.Type; + } + private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null) { Class type = (Class) context; @@ -148,7 +161,8 @@ namespace CppSharp.Passes Property baseVirtualProperty = type.GetRootBaseProperty(property); if (baseVirtualProperty.SetMethod == null) setter = null; - foreach (Method method in type.Methods.Where(m => m.Name == property.Name && m.Parameters.Count > 0)) + foreach (Method method in type.Methods.Where(m => m.Name == property.Name && + m.Parameters.Any(p => p.Kind != ParameterKind.IndirectReturnType))) method.Name = "get" + method.Name; } property.GetMethod = getter; @@ -215,7 +229,7 @@ namespace CppSharp.Passes { if (IsGetter(method)) getters.Add(method); - if (method.Parameters.Count == 0) + if (method.Parameters.All(p => p.Kind == ParameterKind.IndirectReturnType)) nonSetters.Add(method); } }