Browse Source

Fixed a regression causing incorrect sizes of types derived from template instantiations.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/560/head
Dimitar Dobrev 10 years ago
parent
commit
c183200815
  1. 3
      src/Generator/Passes/CheckAbiParameters.cs
  2. 6
      tests/CSharp/CSharp.Tests.cs
  3. 9
      tests/CSharp/CSharp.cpp
  4. 14
      tests/CSharp/CSharp.h
  5. 3
      tests/Common/Common.h

3
src/Generator/Passes/CheckAbiParameters.cs

@ -87,7 +87,8 @@ namespace CppSharp.Passes
{ {
if (@class.Fields.Count > 0 || @class.IsDynamic) if (@class.Fields.Count > 0 || @class.IsDynamic)
return true; return true;
return @class.HasBaseClass && @class.Bases.Any(@base => @base.IsClass && HasFieldsOrVirtuals(@base.Class)); return @class.Bases.Any(@base => @base.IsClass && @base.Class != @class &&
HasFieldsOrVirtuals(@base.Class));
} }
} }
} }

6
tests/CSharp/CSharp.Tests.cs

@ -437,4 +437,10 @@ public class CSharpTests : GeneratorTestFixture
Assert.That(foo.A, Is.EqualTo(15)); Assert.That(foo.A, Is.EqualTo(15));
} }
} }
[Test]
public unsafe void TestSizeOfDerivesFromTemplateInstantiation()
{
Assert.That(sizeof(DerivesFromTemplateInstantiation.Internal), Is.EqualTo(sizeof(int)));
}
} }

9
tests/CSharp/CSharp.cpp

@ -789,3 +789,12 @@ void TestOutTypeInterfaces::funcTryInterfaceTypePtrOut(CS_OUT TestParamToInterfa
void TestOutTypeInterfaces::funcTryInterfaceTypeOut(CS_OUT TestParamToInterfacePassBaseTwo classTry) void TestOutTypeInterfaces::funcTryInterfaceTypeOut(CS_OUT TestParamToInterfacePassBaseTwo classTry)
{ {
} }
template <typename T>
TemplateWithDependentField<T>::TemplateWithDependentField()
{
}
DerivesFromTemplateInstantiation::DerivesFromTemplateInstantiation()
{
}

14
tests/CSharp/CSharp.h

@ -717,3 +717,17 @@ public:
void funcTryInterfaceTypePtrOut(CS_OUT TestParamToInterfacePassBaseTwo* classTry); void funcTryInterfaceTypePtrOut(CS_OUT TestParamToInterfacePassBaseTwo* classTry);
void funcTryInterfaceTypeOut(CS_OUT TestParamToInterfacePassBaseTwo classTry); void funcTryInterfaceTypeOut(CS_OUT TestParamToInterfacePassBaseTwo classTry);
}; };
template <typename T>
class TemplateWithDependentField
{
public:
TemplateWithDependentField();
T t;
};
class DerivesFromTemplateInstantiation : public TemplateWithDependentField<int>
{
public:
DerivesFromTemplateInstantiation();
};

3
tests/Common/Common.h

@ -843,3 +843,6 @@ namespace boost
template <class T> struct is_member_pointer_cv { static const bool value = false; }; template <class T> struct is_member_pointer_cv { static const bool value = false; };
template <class T, class U>struct is_member_pointer_cv<T U::*> { static const bool value = true; }; template <class T, class U>struct is_member_pointer_cv<T U::*> { static const bool value = true; };
} }
template <std::size_t N, std::size_t... I>
struct build_index_impl : build_index_impl<N - 1, N - 1, I...> {};

Loading…
Cancel
Save