|
|
@ -2199,7 +2199,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
|
|
|
|
|
|
|
|
if (method.OperatorKind == CXXOperatorKind.EqualEqual) |
|
|
|
if (method.OperatorKind == CXXOperatorKind.EqualEqual) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GenerateEquals(method, @class); |
|
|
|
GenerateEqualsAndGetHashCode(method, @class); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
@ -2246,7 +2246,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
(p.Usage == ParameterUsage.InOut ? "ref " : string.Empty) + p.Name))); |
|
|
|
(p.Usage == ParameterUsage.InOut ? "ref " : string.Empty) + p.Name))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GenerateEquals(Function method, Class @class) |
|
|
|
private void GenerateEqualsAndGetHashCode(Function method, Class @class) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Class leftHandSide; |
|
|
|
Class leftHandSide; |
|
|
|
Class rightHandSide; |
|
|
|
Class rightHandSide; |
|
|
@ -2268,6 +2268,22 @@ namespace CppSharp.Generators.CSharp |
|
|
|
WriteLine("return this == ({0}) obj;", @class.Name); |
|
|
|
WriteLine("return this == ({0}) obj;", @class.Name); |
|
|
|
} |
|
|
|
} |
|
|
|
WriteCloseBraceIndent(); |
|
|
|
WriteCloseBraceIndent(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NewLine(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WriteLine("public override int GetHashCode()"); |
|
|
|
|
|
|
|
WriteStartBraceIndent(); |
|
|
|
|
|
|
|
if (@class.IsRefType) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
WriteLine("if ({0} == global::System.IntPtr.Zero)", Helpers.InstanceIdentifier); |
|
|
|
|
|
|
|
WriteLineIndent("return global::System.IntPtr.Zero.GetHashCode();"); |
|
|
|
|
|
|
|
WriteLine("return (*(Internal*) {0}).GetHashCode();", Helpers.InstanceIdentifier); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
WriteLine("return {0}.GetHashCode();", Helpers.InstanceIdentifier); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
WriteCloseBraceIndent(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|