CppSharp and template class

236 views
Skip to first unread message

michel.de...@gmail.com

unread,
May 12, 2016, 11:06:12 AM5/12/16
to CppSharp
Hello,
I'm trying to use CppSharp to wrap Assimp (https://github.com/assimp/assimp) library in C#

Assimp define it's 3D vectors as a templated class which is later specialized with a typedef. Due to the fact that the class is templated, CppSharp ignored it, and the typedef too.

I'have made the following test to exibit the problem

#ifndef CUSTOM_TEST_H_INCLUDED
#define CUSTOM_TEST_H_INCLUDED

template<typename T>
class aiVector3t
{
public:
T x;
T y;
T z;
void Set(T x, T y, T z);
};

typedef aiVector3t<float> aiVector3D;

void testFunc(aiVector3D toto){};
#endif

which give me the following result

Parsing code...
ignoring nonexistent directory "lib\clang\3.8.0\include"
#include "..." search starts here:
#include <...> search starts here:
D:\temp\CPPSharp\AssimpWrapper\Assimp\include
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
C:\Program Files (x86)\Windows Kits\8.0\include\shared
C:\Program Files (x86)\Windows Kits\8.0\include\um
C:\Program Files (x86)\Windows Kits\8.0\include\winrt
End of search list.
Parsed 'assimp/Custom_test.h'
ignoring nonexistent directory "lib\clang\3.8.0\include"
#include "..." search starts here:
#include <...> search starts here:
D:\temp\CPPSharp\AssimpWrapper\Assimp\include
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
C:\Program Files (x86)\Windows Kits\8.0\include\shared
C:\Program Files (x86)\Windows Kits\8.0\include\um
C:\Program Files (x86)\Windows Kits\8.0\include\winrt
End of search list.
Processing code...
Pass 'CppSharp.Passes.CleanUnitPass'
Pass 'CppSharp.Passes.SortDeclarationsPass'
Pass 'CppSharp.Passes.ResolveIncompleteDeclsPass'
Pass 'CppSharp.Passes.CheckIgnoredDeclsPass'
Decl 'aiVector3t' was ignored due to dependent context
Decl 'x' was ignored due to dependent context
Decl 'y' was ignored due to dependent context
Decl 'z' was ignored due to dependent context
Function 'Set' was ignored due to ignored param
Function 'testFunc' was ignored due to ignored param
Typedef 'aiVector3D' was ignored due to ignored type
Pass 'CppSharp.Passes.RegexRenamePass'
Pass 'CppSharp.Passes.FindSymbolsPass'
Pass 'CppSharp.Passes.CheckStaticClass'
Pass 'CppSharp.Passes.MoveOperatorToClassPass'
Pass 'CppSharp.Passes.MoveFunctionToClassPass'
Pass 'CppSharp.Passes.GenerateAnonymousDelegatesPass'
Pass 'CppSharp.Passes.MarshalPrimitivePointersAsRefTypePass'
Pass 'CppSharp.Passes.CheckAmbiguousFunctions'
Pass 'CppSharp.Passes.CheckOperatorsOverloadsPass'
Pass 'CppSharp.Passes.CheckVirtualOverrideReturnCovariance'
Pass 'CppSharp.Passes.CheckAbiParameters'
Pass 'CppSharp.Passes.FieldToPropertyPass'
Property created from field: aiVector3t::__x
Property created from field: aiVector3t::__y
Property created from field: aiVector3t::__z
Pass 'CppSharp.Passes.CleanInvalidDeclNamesPass'
Pass 'CppSharp.Passes.CheckIgnoredDeclsPass'
Decl '__x' was ignored due to dependent context
Decl '__y' was ignored due to dependent context
Decl '__z' was ignored due to dependent context
Property 'x' was ignored due to ignored decl
Property 'y' was ignored due to ignored decl
Property 'z' was ignored due to ignored decl
Function 'Set' was ignored due to ignored param
Function 'testFunc' was ignored due to ignored param
Typedef 'aiVector3D' was ignored due to ignored type
Pass 'CppSharp.Passes.CheckFlagEnumsPass'
Pass 'CppSharp.Passes.CheckDuplicatedNamesPass'
Pass 'CppSharp.Passes.RenameRootNamespacesPass'
Pass 'CppSharp.Passes.GenerateAbstractImplementationsPass'
Pass 'CppSharp.Passes.CheckVTableComponentsPass'
Generating code...
Generated 'Custom_test.cs'


and the generated file

//----------------------------------------------------------------------------
// This is autogenerated code by CppSharp.
// Do not edit this file or all your changes will be lost after re-generation.
//----------------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
using System.Security;

namespace Assimp
{
public unsafe partial struct aiVector3t
{
[StructLayout(LayoutKind.Explicit, Size = 0)]
public partial struct Internal
{
}
}
}

Is it a limitation due to template usage or do I misuse CppSharp ?

João Matos

unread,
May 13, 2016, 9:17:19 AM5/13/16
to michel.de...@gmail.com, CppSharp
Hi Michel,

You are correct. We do not properly support template specializations yet.

We've been working hard on adding proper support for templates lately and you can find our work in progress support in the master branch of the repository.

Feel free to try it but the complete solution will only be ready in the up coming weeks.

And next time feel free to create an issue in Github, it has more visibility than the mailing list and the rest of the contributors will also be able to help you.


--
You received this message because you are subscribed to the Google Groups "CppSharp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cppsharp-lis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
João Matos
Reply all
Reply to author
Forward
0 new messages