Browse Source

Simplified the comparisons used in the advanced pass for properties.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/116/head
Dimitar Dobrev 12 years ago
parent
commit
ee1c53b5b0
  1. 12
      src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs

12
src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs

@ -94,13 +94,10 @@ namespace CppSharp.Passes
foreach (var getter in nonSetters.Where(m => m.Namespace == type)) foreach (var getter in nonSetters.Where(m => m.Namespace == type))
{ {
string name = GetPropertyName(getter.Name); string name = GetPropertyName(getter.Name);
if (string.Compare(name, afterSet, StringComparison.OrdinalIgnoreCase) == 0 && if (name == afterSet &&
GetUnderlyingType(getter.OriginalReturnType).Equals( GetUnderlyingType(getter.OriginalReturnType).Equals(
GetUnderlyingType(setter.Parameters[0].QualifiedType)) && GetUnderlyingType(setter.Parameters[0].QualifiedType)) &&
!type.Methods.Any( !type.Methods.Any(m => m != getter && name == m.Name))
m =>
m != getter &&
string.Compare(name, m.Name, StringComparison.OrdinalIgnoreCase) == 0))
{ {
GenerateProperty(getter.Namespace, getter, readOnly ? null : setter); GenerateProperty(getter.Namespace, getter, readOnly ? null : setter);
goto next; goto next;
@ -149,9 +146,8 @@ namespace CppSharp.Passes
private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null) private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null)
{ {
Class type = (Class) context; Class type = (Class) context;
if (type.Properties.All( if (type.Properties.All(p => getter.Name != p.Name ||
p => string.Compare(getter.Name, p.Name, StringComparison.OrdinalIgnoreCase) != 0 || p.ExplicitInterfaceImpl != getter.ExplicitInterfaceImpl))
p.ExplicitInterfaceImpl != getter.ExplicitInterfaceImpl))
{ {
Property property = new Property(); Property property = new Property();
property.Name = GetPropertyName(getter.Name); property.Name = GetPropertyName(getter.Name);

Loading…
Cancel
Save