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
WriteStartBraceIndent(); WriteStartBraceIndent();
foreach (var method in @class.Methods.Where(m => 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); PushBlock(BlockKind.Method);
GenerateDeclarationCommon(method); GenerateDeclarationCommon(method);
var functionName = GetMethodIdentifier(method); var functionName = GetMethodIdentifier(method);
Write("{0} {1}(", method.OriginalReturnType, functionName); Write($"{method.OriginalReturnType} {functionName}(");
Write(FormatMethodParameters(method.Parameters)); Write(FormatMethodParameters(method.Parameters));
@ -478,14 +479,19 @@ namespace CppSharp.Generators.CSharp
PopBlock(NewLineKind.BeforeNextBlock); 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); PushBlock(BlockKind.Property);
var type = prop.Type; var type = prop.Type;
if (prop.Parameters.Count > 0 && prop.Type.IsPointerToPrimitiveType()) if (prop.Parameters.Count > 0 && prop.Type.IsPointerToPrimitiveType())
type = ((PointerType) prop.Type).Pointee; type = ((PointerType) prop.Type).Pointee;
GenerateDeclarationCommon(prop); GenerateDeclarationCommon(prop);
Write("{0} {1} {{ ", type, GetPropertyName(prop)); Write($"{type} {GetPropertyName(prop)} {{ ");
if (prop.HasGetter) if (prop.HasGetter)
Write("get; "); Write("get; ");
if (prop.HasSetter) if (prop.HasSetter)

9
tests/CSharp/CSharpTemplates.h

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

Loading…
Cancel
Save