Browse Source

Merge pull request #272 from ddobrev/master

Fixed wrong code generated for indexers in value types
pull/273/head
João Matos 11 years ago
parent
commit
4291cb7fa3
  1. 5
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  2. 2
      tests/Basic/Basic.cpp
  3. 8
      tests/Basic/Basic.h

5
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -2283,7 +2283,10 @@ namespace CppSharp.Generators.CSharp
if (needsFixedThis) if (needsFixedThis)
{ {
WriteLine("var {0} = {1};", Generator.GeneratedIdentifier("fixedInstance"), WriteLine("var {0} = {1};", Generator.GeneratedIdentifier("fixedInstance"),
method.IsOperator ? "__arg0" : "ToInternal()"); (method.IsOperator && method.OperatorKind != CXXOperatorKind.Subscript ?
method.Parameters.First(
p => p.Kind == ParameterKind.OperatorParameter).Name + "." :
string.Empty) + "ToInternal()");
} }
if (needsReturn && !originalFunction.HasIndirectReturnTypeParameter) if (needsReturn && !originalFunction.HasIndirectReturnTypeParameter)

2
tests/Basic/Basic.cpp

@ -251,5 +251,5 @@ int test(basic& s)
Bar::Item operator |(Bar::Item left, Bar::Item right) Bar::Item operator |(Bar::Item left, Bar::Item right)
{ {
return left; return left | right;
} }

8
tests/Basic/Basic.h

@ -433,6 +433,14 @@ const foo_t& TestIndexedProperties::operator[](double f) { return p; }
TestProperties* TestIndexedProperties::operator[](unsigned char b) { return &f; } TestProperties* TestIndexedProperties::operator[](unsigned char b) { return &f; }
const TestProperties& TestIndexedProperties::operator[](short b) { return f; } const TestProperties& TestIndexedProperties::operator[](short b) { return f; }
struct DLL_API TestIndexedPropertiesInValueType
{
public:
int operator[](int i);
};
int TestIndexedPropertiesInValueType::operator[](int i) { return i; }
enum struct MyEnum { A, B, C }; enum struct MyEnum { A, B, C };
class DLL_API TestArraysPointers class DLL_API TestArraysPointers

Loading…
Cancel
Save