Browse Source

Fixed the parsing of functions with integral template args.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1146/head
Dimitar Dobrev 7 years ago
parent
commit
88f118ec4e
  1. 16
      src/Generator/Passes/SymbolsCodeGenerator.cs
  2. 6
      tests/CSharp/CSharpTemplates.h

16
src/Generator/Passes/SymbolsCodeGenerator.cs

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using CppSharp.AST; using CppSharp.AST;
@ -241,7 +242,20 @@ namespace CppSharp.Passes
string.Empty : (@namespace + "::"))}{function.OriginalName}{ string.Empty : (@namespace + "::"))}{function.OriginalName}{
(function.SpecializationInfo == null ? string.Empty : $@"<{ (function.SpecializationInfo == null ? string.Empty : $@"<{
string.Join(", ", function.SpecializationInfo.Arguments.Select( string.Join(", ", function.SpecializationInfo.Arguments.Select(
a => a.Type.Visit(cppTypePrinter)))}>")}"; a =>
{
switch (a.Kind)
{
case TemplateArgument.ArgumentKind.Type:
return a.Type.Visit(cppTypePrinter);
case TemplateArgument.ArgumentKind.Declaration:
return a.Declaration.Visit(cppTypePrinter);
case TemplateArgument.ArgumentKind.Integral:
return a.Integral.ToString(CultureInfo.InvariantCulture);
}
throw new System.ArgumentOutOfRangeException(
nameof(a.Kind), a.Kind, "Unsupported kind of template argument.");
}))}>")}";
} }
private void WriteRedeclaration(Function function, string returnType, private void WriteRedeclaration(Function function, string returnType,

6
tests/CSharp/CSharpTemplates.h

@ -691,6 +691,12 @@ std::map<int, int> usesValidSpecialisationOfIgnoredTemplate();
DLL_API DependentValueFields<double> specialiseReturnOnly(); DLL_API DependentValueFields<double> specialiseReturnOnly();
template <int Size> void* qbswap(const void *source, size_t count, void *dest) noexcept;
template<> inline void* qbswap<1>(const void *source, size_t count, void *dest) noexcept
{
return 0;
}
// force the symbols for the template instantiations because we do not have the auto-compilation for the generated C++ source // force the symbols for the template instantiations because we do not have the auto-compilation for the generated C++ source
template class DLL_API IndependentFields<int>; template class DLL_API IndependentFields<int>;
template class DLL_API IndependentFields<bool>; template class DLL_API IndependentFields<bool>;

Loading…
Cancel
Save