Skip to content

Commit d0c8e15

Browse files
committed
Fixed the generation of internals for template specialisations.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 5e39989 commit d0c8e15

File tree

22 files changed

+5954
-2545
lines changed

22 files changed

+5954
-2545
lines changed

src/AST/ClassExtensions.cs

+27-5
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ public static bool HasRefBase(this Class @class)
137137
if (@class.HasBaseClass)
138138
@base = @class.Bases[0].Class;
139139

140-
var hasRefBase = @base != null && @base.IsRefType && @base.IsGenerated;
141-
142-
return hasRefBase;
140+
return @base?.IsRefType == true && @base.IsGenerated;
143141
}
144142

145143
public static IEnumerable<TranslationUnit> GetGenerated(this IEnumerable<TranslationUnit> units)
@@ -150,8 +148,7 @@ public static IEnumerable<TranslationUnit> GetGenerated(this IEnumerable<Transla
150148
public static List<ClassTemplateSpecialization> GetSpecializationsToGenerate(
151149
this Class classTemplate)
152150
{
153-
if (classTemplate.Fields.Any(
154-
f => f.Type.Desugar() is TemplateParameterType))
151+
if (classTemplate.HasDependentValueFieldInLayout())
155152
return classTemplate.Specializations;
156153

157154
var specializations = new List<ClassTemplateSpecialization>();
@@ -162,5 +159,30 @@ public static List<ClassTemplateSpecialization> GetSpecializationsToGenerate(
162159
specializations.Add(specialization);
163160
return specializations;
164161
}
162+
163+
public static bool HasDependentValueFieldInLayout(this Class @class)
164+
{
165+
if (@class.Fields.Any(f => IsValueDependent(f.Type)))
166+
return true;
167+
168+
return @class.Bases.Where(b => b.IsClass).Select(
169+
b => b.Class).Any(HasDependentValueFieldInLayout);
170+
}
171+
172+
private static bool IsValueDependent(Type type)
173+
{
174+
var desugared = type.Desugar();
175+
if (desugared is TemplateParameterType)
176+
return true;
177+
var tagType = desugared as TagType;
178+
if (tagType?.IsDependent == true)
179+
return true;
180+
var templateType = desugared as TemplateSpecializationType;
181+
if (templateType?.Arguments.Any(
182+
a => a.Type.Type?.Desugar().IsDependent == true) == true)
183+
return true;
184+
var arrayType = desugared as ArrayType;
185+
return arrayType != null && IsValueDependent(arrayType.Type);
186+
}
165187
}
166188
}

src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs

+395-381
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <string>
22

33

4+
template __attribute__((visibility("default"))) std::allocator<char>::allocator() noexcept;
45
template __attribute__((visibility("default"))) std::basic_string<char, std::char_traits<char>, std::allocator<char>>::basic_string(const std::basic_string<char, std::char_traits<char>, std::allocator<char>>::value_type*, const std::basic_string<char, std::char_traits<char>, std::allocator<char>>::allocator_type&);
56
template __attribute__((visibility("default"))) std::basic_string<char, std::char_traits<char>, std::allocator<char>>::~basic_string() noexcept;
67
template __attribute__((visibility("default"))) const std::basic_string<char, std::char_traits<char>, std::allocator<char>>::value_type* std::basic_string<char, std::char_traits<char>, std::allocator<char>>::c_str() const noexcept;
7-
template __attribute__((visibility("default"))) std::allocator<char>::allocator() noexcept;

0 commit comments

Comments
 (0)