mirror of https://github.com/mono/CppSharp.git
11 changed files with 320 additions and 37 deletions
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
using System.Linq; |
||||
using CppSharp.AST; |
||||
using CppSharp.AST.Extensions; |
||||
|
||||
namespace CppSharp.Passes |
||||
{ |
||||
public class TrimSpecializationsPass : TranslationUnitPass |
||||
{ |
||||
public override bool VisitClassTemplateDecl(ClassTemplate template) |
||||
{ |
||||
if (!base.VisitClassTemplateDecl(template) || |
||||
template.Specializations.Count == 0) |
||||
return false; |
||||
|
||||
var lastGroup = (from specialization in template.Specializations |
||||
group specialization by specialization.Arguments.All( |
||||
a => a.Type.Type != null && a.Type.Type.IsAddress()) into @group |
||||
select @group).Last(); |
||||
if (lastGroup.Key) |
||||
{ |
||||
foreach (var specialization in lastGroup.Skip(1)) |
||||
template.Specializations.Remove(specialization); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
#include "CSharpTemplates.h" |
||||
|
||||
TemplateSpecializer::TemplateSpecializer() |
||||
{ |
||||
} |
||||
|
||||
void TemplateSpecializer::completeSpecializationInParameter(DependentValueFields<float> p1, |
||||
DependentValueFields<int*> p2, |
||||
DependentValueFields<float*> p3) |
||||
{ |
||||
} |
||||
|
||||
void TemplateSpecializer::completeSpecializationInParameter(TwoTemplateArgs<int *, int *> p1, |
||||
TwoTemplateArgs<int *, int> p2, |
||||
TwoTemplateArgs<int *, float> p3) |
||||
{ |
||||
} |
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
#include "../Tests.h" |
||||
|
||||
class DLL_API T1 |
||||
{ |
||||
}; |
||||
|
||||
class DLL_API T2 |
||||
{ |
||||
}; |
||||
|
||||
template <typename T> |
||||
class DLL_API IndependentFields |
||||
{ |
||||
private: |
||||
int field; |
||||
}; |
||||
|
||||
template <typename T> |
||||
class DLL_API DependentValueFields |
||||
{ |
||||
private: |
||||
T field; |
||||
}; |
||||
|
||||
template <typename T> |
||||
class DLL_API DependentPointerFields |
||||
{ |
||||
private: |
||||
T* field; |
||||
}; |
||||
|
||||
template <typename K, typename V> |
||||
class TwoTemplateArgs |
||||
{ |
||||
private: |
||||
K key; |
||||
V value; |
||||
}; |
||||
|
||||
template <typename T, typename D = IndependentFields<T>> |
||||
class HasDefaultTemplateArgument |
||||
{ |
||||
T field; |
||||
}; |
||||
|
||||
class DLL_API TemplateSpecializer |
||||
{ |
||||
public: |
||||
TemplateSpecializer(); |
||||
private: |
||||
IndependentFields<int> independentFields; |
||||
DependentValueFields<int> dependentValueFields; |
||||
DependentPointerFields<int> dependentPointerFields; |
||||
HasDefaultTemplateArgument<int> hasDefaultTemplateArgument; |
||||
DependentValueFields<T1> dependentPointerFieldsT1; |
||||
DependentValueFields<T2> dependentPointerFieldsT2; |
||||
void completeSpecializationInParameter(DependentValueFields<float> p1, |
||||
DependentValueFields<int*> p2, |
||||
DependentValueFields<float*> p3); |
||||
void completeSpecializationInParameter(TwoTemplateArgs<int*, int*> p1, |
||||
TwoTemplateArgs<int*, int> p2, |
||||
TwoTemplateArgs<int*, float> p3); |
||||
}; |
Loading…
Reference in new issue