Permalink
Browse files

Fixed the generated C# for a property returning a template with a ren…

…amed type arg.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information...
ddobrev committed Aug 13, 2017
1 parent f818005 commit 94c083833746c55cbb19b8508e02f88a356f933d
@@ -174,14 +174,18 @@ public override bool VisitPointerType(PointerType pointer, TypeQualifiers quals)
var type = Context.ReturnType.Type.Desugar(
resolveTemplateSubstitution: false);
if (Context.Function != null &&
Context.Function.OperatorKind == CXXOperatorKind.Subscript &&
type.IsPrimitiveType(primitive))
Context.Function.OperatorKind == CXXOperatorKind.Subscript)
{
var substitute = type as TemplateParameterSubstitutionType;
if (substitute != null)
Context.Return.Write($@"({
substitute.ReplacedParameter.Parameter.Name}) (object) ");
Context.Return.Write("*");
if (type.IsPrimitiveType(primitive))
{
Context.Return.Write("*");
}
else
{
var templateParameter = type as TemplateParameterType;
if (templateParameter != null)
Context.Return.Write($@"({templateParameter.Parameter.Name}) (object) *");
}
}
Context.Return.Write(Context.ReturnVarName);
@@ -1086,13 +1086,14 @@ private void GenerateFunctionGetter(Class @class, Property property)
@class.Visit(TypePrinter)}."");");
return;
}
property = actualProperty;
if (property.GetMethod.SynthKind == FunctionSynthKind.AbstractImplCall)
GenerateVirtualPropertyCall(property.GetMethod, @class.BaseClass, property);
else if (property.GetMethod.IsVirtual)
GenerateVirtualPropertyCall(property.GetMethod, @class, property);
else GenerateInternalFunctionCall(property.GetMethod,
property.GetMethod.Parameters, property.QualifiedType);
if (actualProperty.GetMethod.SynthKind == FunctionSynthKind.AbstractImplCall)
GenerateVirtualPropertyCall(actualProperty.GetMethod,
@class.BaseClass, actualProperty);
else if (actualProperty.GetMethod.IsVirtual)
GenerateVirtualPropertyCall(actualProperty.GetMethod,
@class, actualProperty);
else GenerateInternalFunctionCall(actualProperty.GetMethod,
actualProperty.GetMethod.Parameters, property.QualifiedType);
}
private static Property GetActualProperty(Property property, Class c)
@@ -831,6 +831,17 @@ public void TestReturnTemplateWithRenamedTypeArg()
}
}
[Test]
public void TestPropertyReturnsTemplateWithRenamedTypeArg()
{
using (var hasDefaultTemplateArgument = new HasDefaultTemplateArgument<int, int>())
{
var returnTemplateWithRenamedTypeArg =
hasDefaultTemplateArgument.PropertyReturnsTemplateWithRenamedTypeArg;
Assert.That(returnTemplateWithRenamedTypeArg.DependentValue, Is.EqualTo(0));
}
}
[Test]
public void TestAbstractImplementatonsInPrimaryAndSecondaryBases()
{
@@ -101,7 +101,7 @@ template <typename T>
class DLL_API DependentValueFieldForArray
{
private:
T field;
T field{};
};
template <typename T>
@@ -124,7 +124,7 @@ class DLL_API DependentValueFields : public Base<T>
T getDependentValue();
void setDependentValue(const T& value);
private:
T field;
T field{};
union {
int unionField;
};
@@ -205,9 +205,10 @@ class HasDefaultTemplateArgument
static T staticProperty();
static void setStaticProperty(const T& t);
bool operator==(const HasDefaultTemplateArgument& other);
DependentValueFields<D> returnTemplateWithRenamedTypeArg(const DependentValueFields<D> &value);
DependentValueFields<D> returnTemplateWithRenamedTypeArg(const DependentValueFields<D>& value);
DependentValueFields<D> propertyReturnsTemplateWithRenamedTypeArg();
private:
T field;
T field{};
static T staticField;
};
@@ -272,6 +273,12 @@ DependentValueFields<D> HasDefaultTemplateArgument<T, D>::returnTemplateWithRena
return value;
}
template <typename T, typename D>
DependentValueFields<D> HasDefaultTemplateArgument<T, D>::propertyReturnsTemplateWithRenamedTypeArg()
{
return DependentValueFields<D>();
}
template <typename T, typename D>
T HasDefaultTemplateArgument<T, D>::staticField;

0 comments on commit 94c0838

Please sign in to comment.