Browse Source

Fixed handling of the argument for indexers.

pull/395/head
ebifrier 11 years ago committed by Joao Matos
parent
commit
604bbf9626
  1. 13
      src/Generator/Generators/CLI/CLISourcesTemplate.cs
  2. 3
      tests/Basic/Basic.h

13
src/Generator/Generators/CLI/CLISourcesTemplate.cs

@ -409,7 +409,18 @@ namespace CppSharp.Generators.CLI @@ -409,7 +409,18 @@ namespace CppSharp.Generators.CLI
param.Visit(marshal);
if (isIndexer)
variable += string.Format("({0})", indexParameter.Name);
{
var ctx2 = new MarshalContext(Driver)
{
Parameter = indexParameter,
ArgName = indexParameter.Name
};
var marshal2 = new CLIMarshalManagedToNativePrinter(ctx2);
indexParameter.Visit(marshal2);
variable += string.Format("({0})", marshal2.Context.Return);
}
if (!string.IsNullOrWhiteSpace(marshal.Context.SupportBefore))
Write(marshal.Context.SupportBefore);

3
tests/Basic/Basic.h

@ -486,6 +486,8 @@ public: @@ -486,6 +486,8 @@ public:
TestProperties* operator[](unsigned char b);
// Should lead to a read-only indexer with return type TestProperties
const TestProperties& operator[](short b);
// Should lead to a read-only indexer with argument type TestProperties
foo_t operator[](TestProperties b);
};
TestIndexedProperties::TestIndexedProperties() : p(1), f() {}
@ -495,6 +497,7 @@ foo_t* TestIndexedProperties::operator[](float f) { return &p; } @@ -495,6 +497,7 @@ foo_t* TestIndexedProperties::operator[](float f) { return &p; }
const foo_t& TestIndexedProperties::operator[](double f) { return p; }
TestProperties* TestIndexedProperties::operator[](unsigned char b) { return &f; }
const TestProperties& TestIndexedProperties::operator[](short b) { return f; }
foo_t TestIndexedProperties::operator[](TestProperties b) { return p; }
struct DLL_API TestIndexedPropertiesInValueType
{

Loading…
Cancel
Save