SWIG questions

What is the status of the C++ namespace support for the the
Ruby engine of SWIG?

More specifically: is it possible to tell SWIG to wrap all
classes in a header file, even if it contains namespaces?

I was surprised to notice that SWIG generates
singleton setter and getter methods for a namespace.
Is there a reason for that?

Thanks in advance, Christian

What is the status of the C++ namespace support for the the
Ruby engine of SWIG?

More specifically: is it possible to tell SWIG to wrap all
classes in a header file, even if it contains namespaces?

Yes, this is the default behavior for SWIG 1.3.12. This section from the
SWIG documentation:

 http://www.swig.org/Doc1.3/SWIGPlus.html#n24

describes how SWIG’s namespace support works. As noted, the default
behavior is also to “flatten” namespaces in the target language.

I was surprised to notice that SWIG generates
singleton setter and getter methods for a namespace.
Is there a reason for that?

I don’t know what you’re talking about here. Could you be more specific?

I was surprised to notice that SWIG generates
singleton setter and getter methods for a namespace.
Is there a reason for that?

I don’t know what you’re talking about here. Could you be more specific?

I changed the example provided with SWIG in Examples/class, so that the
class is enclosed in a namespace ABC.

I left the exmample.i file unchanged.

SWIG generated the wrapper code in the attached file.
(I deleted everything up to the init function.)

I used SWIG-1.3.12.

Best regards, Christian

wrap.cpp (446 Bytes)

I don’t know what you’re talking about here. Could you be more specific?

I changed the example provided with SWIG in Examples/class, so that the
class is enclosed in a namespace ABC.

I left the exmample.i file unchanged.

SWIG generated the wrapper code in the attached file.
(I deleted everything up to the init function.)

I used SWIG-1.3.12.

Sorry, but I just downloaded the SWIG 1.3.12 sources, built and
installed it, and I can’t reproduce this at all. Can you verify that
you’re indeed running SWIG 1.3.12 by typing:

 swig -version

at the command line? If that checks out (“SWIG Version 1.3.12…”) then
please send me your modified “example.h” file from the
Examples/ruby/class directory. To enclose all of that stuff in an “ABC”
namespace you would have added two lines: at the top,

 namespace ABC {

and at the bottom,

 }

Thanks,

Lyle