Browse Source

Fixed the generated C# when a template specialization with extensions is used for a secondary base.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1033/head
Dimitar Dobrev 8 years ago
parent
commit
cb6d2aee23
  1. 14
      src/Generator/Generators/CSharp/CSharpSources.cs
  2. 9
      tests/CSharp/CSharpTemplates.h

14
src/Generator/Generators/CSharp/CSharpSources.cs

@ -463,14 +463,15 @@ namespace CppSharp.Generators.CSharp @@ -463,14 +463,15 @@ namespace CppSharp.Generators.CSharp
WriteStartBraceIndent();
foreach (var method in @class.Methods.Where(m =>
!ASTUtils.CheckIgnoreMethod(m) && m.Access == AccessSpecifier.Public))
!ASTUtils.CheckIgnoreFunction(m.OriginalFunction) &&
m.Access == AccessSpecifier.Public))
{
PushBlock(BlockKind.Method);
GenerateDeclarationCommon(method);
var functionName = GetMethodIdentifier(method);
Write("{0} {1}(", method.OriginalReturnType, functionName);
Write($"{method.OriginalReturnType} {functionName}(");
Write(FormatMethodParameters(method.Parameters));
@ -478,14 +479,19 @@ namespace CppSharp.Generators.CSharp @@ -478,14 +479,19 @@ namespace CppSharp.Generators.CSharp
PopBlock(NewLineKind.BeforeNextBlock);
}
foreach (var prop in @class.Properties.Where(p => p.IsGenerated && p.Access == AccessSpecifier.Public))
foreach (var prop in @class.Properties.Where(p => p.IsGenerated &&
(p.GetMethod == null || p.GetMethod.OriginalFunction == null ||
!p.GetMethod.OriginalFunction.Ignore) &&
(p.SetMethod == null || p.SetMethod.OriginalFunction == null ||
!p.SetMethod.OriginalFunction.Ignore) &&
p.Access == AccessSpecifier.Public))
{
PushBlock(BlockKind.Property);
var type = prop.Type;
if (prop.Parameters.Count > 0 && prop.Type.IsPointerToPrimitiveType())
type = ((PointerType) prop.Type).Pointee;
GenerateDeclarationCommon(prop);
Write("{0} {1} {{ ", type, GetPropertyName(prop));
Write($"{type} {GetPropertyName(prop)} {{ ");
if (prop.HasGetter)
Write("get; ");
if (prop.HasSetter)

9
tests/CSharp/CSharpTemplates.h

@ -36,6 +36,7 @@ public: @@ -36,6 +36,7 @@ public:
int getIndependent();
const T* returnTakeDependentPointer(const T* p);
T getDependent(const T& t);
const T* propertyReturnDependentPointer();
static T staticDependent(const T& t);
template <typename AdditionalDependentType>
void usesAdditionalDependentType(AdditionalDependentType additionalDependentType);
@ -91,6 +92,12 @@ T IndependentFields<T>::getDependent(const T& t) @@ -91,6 +92,12 @@ T IndependentFields<T>::getDependent(const T& t)
return t;
}
template <typename T>
const T* IndependentFields<T>::propertyReturnDependentPointer()
{
return 0;
}
template <typename T>
T IndependentFields<T>::staticDependent(const T& t)
{
@ -425,7 +432,7 @@ private: @@ -425,7 +432,7 @@ private:
HasDefaultTemplateArgument<bool, bool> explicitSpecialization;
};
class DLL_API HasSpecializationForSecondaryBase : T1, DependentValueFields<int>
class DLL_API HasSpecializationForSecondaryBase : T1, DependentValueFields<int>, IndependentFields<int>
{
public:
HasSpecializationForSecondaryBase();

Loading…
Cancel
Save