diff --git a/src/Generator/Passes/MultipleInheritancePass.cs b/src/Generator/Passes/MultipleInheritancePass.cs index 59199062..e25004ee 100644 --- a/src/Generator/Passes/MultipleInheritancePass.cs +++ b/src/Generator/Passes/MultipleInheritancePass.cs @@ -68,7 +68,7 @@ namespace CppSharp.Passes @interface.Methods.AddRange( from m in @base.Methods - where !m.IsConstructor && !m.IsDestructor && !m.IsStatic && !m.Ignore + where !m.IsConstructor && !m.IsDestructor && !m.IsStatic && !m.Ignore && !m.IsOperator select new Method(m) { Namespace = @interface }); @interface.Properties.AddRange( diff --git a/src/Generator/Passes/ParamTypeToInterfacePass.cs b/src/Generator/Passes/ParamTypeToInterfacePass.cs index 5e0e12d0..350221c0 100644 --- a/src/Generator/Passes/ParamTypeToInterfacePass.cs +++ b/src/Generator/Passes/ParamTypeToInterfacePass.cs @@ -1,4 +1,5 @@ -using CppSharp.AST; +using System.Linq; +using CppSharp.AST; namespace CppSharp.Passes { @@ -6,24 +7,26 @@ namespace CppSharp.Passes { public override bool VisitFunctionDecl(Function function) { - if (function.HasIndirectReturnTypeParameter) + if (!function.IsOperator) { - var parameter = function.Parameters.Find(p => p.Kind == ParameterKind.IndirectReturnType); - parameter.QualifiedType = GetInterfaceType(parameter.QualifiedType); - } - else - { - function.ReturnType = GetInterfaceType(function.ReturnType); + if (function.HasIndirectReturnTypeParameter) + { + var parameter = function.Parameters.Find(p => p.Kind == ParameterKind.IndirectReturnType); + parameter.QualifiedType = GetInterfaceType(parameter.QualifiedType); + } + else + { + function.ReturnType = GetInterfaceType(function.ReturnType); + } + foreach (Parameter parameter in function.Parameters.Where( + p => p.Kind != ParameterKind.IndirectReturnType)) + { + parameter.QualifiedType = GetInterfaceType(parameter.QualifiedType); + } } return base.VisitFunctionDecl(function); } - public override bool VisitParameterDecl(Parameter parameter) - { - parameter.QualifiedType = GetInterfaceType(parameter.QualifiedType); - return base.VisitParameterDecl(parameter); - } - private static QualifiedType GetInterfaceType(QualifiedType type) { var tagType = type.Type as TagType; diff --git a/tests/CSharpTemp/CSharpTemp.Tests.cs b/tests/CSharpTemp/CSharpTemp.Tests.cs index f047f68f..bb7bdfdf 100644 --- a/tests/CSharpTemp/CSharpTemp.Tests.cs +++ b/tests/CSharpTemp/CSharpTemp.Tests.cs @@ -1,5 +1,4 @@ -using System; -using System.Reflection; +using System.Reflection; using CSharpTemp; using NUnit.Framework; using Foo = CSharpTemp.Foo; @@ -8,7 +7,7 @@ using Foo = CSharpTemp.Foo; public class CSharpTempTests { [Test] - public unsafe void TestIndexer() + public void TestIndexer() { var foo = new Foo(); diff --git a/tests/CSharpTemp/CSharpTemp.cpp b/tests/CSharpTemp/CSharpTemp.cpp index bae46189..5a8a6295 100644 --- a/tests/CSharpTemp/CSharpTemp.cpp +++ b/tests/CSharpTemp/CSharpTemp.cpp @@ -46,6 +46,30 @@ Foo& Bar::operator[](int i) return m_foo; } +Bar Bar::operator *() +{ + return *this; +} + +const Bar& Bar::operator *(int m) +{ + index *= m; + return *this; +} + +const Bar& Bar::operator ++() +{ + ++index; + return *this; +} + +Bar Bar::operator ++(int i) +{ + Bar bar = *this; + index++; + return bar; +} + Baz::Nested::operator int() const { return 300; diff --git a/tests/CSharpTemp/CSharpTemp.h b/tests/CSharpTemp/CSharpTemp.h index a034138d..9d254119 100644 --- a/tests/CSharpTemp/CSharpTemp.h +++ b/tests/CSharpTemp/CSharpTemp.h @@ -31,8 +31,13 @@ public: int method(); const Foo& operator[](int i) const; Foo& operator[](int i); + Bar operator*(); + const Bar& operator*(int m); + const Bar& operator++(); + Bar operator++(int i); private: + int index; Foo m_foo; };