Hello,
When I run SWIG on my source code, it generates invalid code, because I have hidden a reference type in a struct member:
template <typename TYPE>
struct ReturnType {
typedef const TYPE& ConstValue;
typedef TYPE& Value;
};
Swig generates
tlp::ReturnType< tlp::PointType::RealType >::ConstValue result;
when wrapping a function returning a ReturnType<...>::ConstValue and gcc complains this is a reference type and it's not initialized.
Hope this is not an impossible feature to implement :)
The following code compiles for me using the latest:
%inline %{
template <typename TYPE>
struct ReturnType {
typedef const TYPE& ConstValue;
typedef TYPE& Value;
};
%}
%template(ReturnInt) ReturnType<int>;
%inline %{
ReturnType<int>::ConstValue getit() {
static int abc = 0;
return abc;
}
%}
It generates
int *result = 0 ;
in the wrapper. Checked with Python and Java. Which version are you using and can you post the full code if you are still having problems with the latest.
I am using version 2.0.1.
The ReturnType definition is inside of a namespace, and when I try to %include the file ReturnType.h and use %template on ReturnType, SWIG returns with error code 1.
Wheter I %inline it or not does not seem to change anything.
If you want to take a look at the source, see http://auber.svn.sourceforge.net/viewvc/auber/tulip/library/tulip/.
ReturnType.h lies in include/tulip.
Thanks :)
Woops, scratch that.
I had missed a message telling me the template was not found, due to an #ifdef I had missed.
SWIG seems to work fine, I just don't know how to use it properly.
I'll ask on the forums, thanks a lot :)