jonrue | 20 Jul 2012 20:19
Picon

How to apply the %nspace feature to template instantiations?

The %nspace feature is very helpful and works great with CSharp and
Java. However, I could not figure out how to convince SWIG to generate
template instantiations in a namespace. Is there any way to achieve
this?

I really hope this is somehow possible. Thanks to %nspace my CSharp
wrapper assembly reflects nicely the namespaces of the wrapped C++
code, except for all the instantiated template classes which end up
outside any namespace.

Thanks in advance for your feedback, much appreciated.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
jonrue | 25 Jul 2012 10:56
Picon

Re: How to apply the %nspace feature to template instantiations?

Hi All,

In the meantime I found, the %nspace feature is working for templates
(in most cases) as follows. The %nspace directive must appear before
the declaration of the addressed data type. Hence, the sequence of
statement is:

%nspace ...
%include ...
%template ...

In some cases, I couldn't get this to work though.

The following example illustrates this.

Source Test.h:

namespace test{
  template<typename T>
  class Test{};
  class A{};
}

SWIG file example.i:

 %module example
 %{
 #include <vector>
 #include "Test.h"
 %}
(Continue reading)

William S Fulton | 27 Jul 2012 22:27
Picon
Favicon
Gravatar

Re: How to apply the %nspace feature to template instantiations?

On 25/07/12 09:56, jonrue <at> gmx.net wrote:
> Hi All,
>
> In the meantime I found, the %nspace feature is working for templates
> (in most cases) as follows. The %nspace directive must appear before
> the declaration of the addressed data type. Hence, the sequence of
> statement is:
>
> %nspace ...
> %include ...
> %template ...
>
%nspace is a %feature, so that is correct.

> In some cases, I couldn't get this to work though.
>
> The following example illustrates this.
>
> Source Test.h:
>
> namespace test{
>    template<typename T>
>    class Test{};
>    class A{};
> }
>
> SWIG file example.i:
>
>   %module example
>   %{
(Continue reading)


Gmane