|
From: William S F. <ws...@fu...> - 2006-10-13 23:52:29
|
Marc Lepage wrote:
> Hi, new mailing list reader (and new SWIG user) here.
>
>
>
> I’m involving in bringing a fairly large C++ codebase to SWIG, primarily
> for C# wrapping, and possibly for other languages in the future (maybe
> Lua, Ruby, Python, Perl, etc.).
>
>
>
> Our C++ code is organized into namespaces about 2 levels deep, something
> like this:
>
>
>
> company::util
>
> company::moduleA
>
> company::moduleB
>
> and so on.
>
>
>
> I’d like that to map to appropriate namespaces on the C# side, so
> company::moduleA::classX in C++ maps to company.moduleA.classX proxy in
> C# (and the same for the other modules). Is this possible? Is this
> advisable?
>
>
>
> I’m relatively new to SWIG so apologies if I seem slow or on the wrong
> track. I started with an interface file defining two %modules, one for
> util, one for moduleA. But they aren’t in a module named company. And by
> default, the generated wrapping to C# places everything in the global
> namespace.
>
>
>
> I tried the –namespace option, and I can place all of the generated C#
> code into a company namespace. But the sub-namespaces (util, moduleA) do
> not appear. Is there a way to nest namespaces in the generated C# proxy
> code?
>
>
>
> Must I move to some sort of solution which puts a %module in each SWIG
> invocation (with a different –namespace command line option), then put
> them all together somehow at the end?
>
>
>
> If anyone can provide links to examples of this nature, I’m pretty sure
> I can follow along. I just haven’t seen anything comparable in the
> documentation or online searches.
>
>
>
C# supports nested namespaces that are not lexically nested, so you just
take advantage of that and for example, specify -namespace company.util,
to generate:
namespace company.util {
...
}
which is semantically the same as
namespace company {
namespace util {
...
}
}
William
|