[Swig-user] Class/Namespace/C# problem

69 views
Skip to first unread message

Anders Backman

unread,
Mar 14, 2012, 4:04:49 AM3/14/12
to swig...@lists.sourceforge.net
Hi all, Im new to SWIG. Right now I'm deciding whether to use SWIG or CLI/C++ for wrapping a rather large C++ API into .NET (C#)
Im using SWIG 2.0.4 and Visual Studio 2010.

I stumbled on some quite irritating hurdles immediately.
I have tried to illustrate the problem in the attached code, it should build if you have swig.exe in the path.



I have basically two namespace's A and B (in reality I have a lot more, these are just very reduced examples to show two of my problems). 
One thing that sticks out is that there are two classes with the same name that exist both in namespace A and B.

My problems so far:

#1 the init function should be called as: A.init(); NOT A.A.init();
#2 A.Material does not exist in the generated binding code. Only B.Material

Command to generate binding:

swig -outdir generated -c++ -v -csharp -namespace A -Wall a.i
swig -outdir generated -c++ -v -csharp  -namespace B  -Wall b.i


runme.cs is using the generated code.

/A


--
__________________________________________
Anders Backman, HPC2N
90187 Umeå University, Sweden
and...@cs.umu.se http://www.hpc2n.umu.se
Cell: +46-70-392 64 67
csharp-example.rar

Anders Backman

unread,
Mar 14, 2012, 6:13:13 AM3/14/12
to swig...@lists.sourceforge.net
Second attempt, seems that the SWIG list does not like html formatted
messages...


Hi all, Im new to SWIG. Right now I'm deciding whether to use SWIG or
CLI/C++ for wrapping a rather large C++ API into .NET (C#)
Im using SWIG 2.0.4 and Visual Studio 2010.

I stumbled on some quite irritating hurdles immediately.
I have tried to illustrate the problem in the attached code, it should
build if you have swig.exe in the path.

I have basically two namespace's A and B (in reality I have a lot
more, these are just very reduced examples to show two of my
problems).
One thing that sticks out is that there are two classes with the same
name that exist both in namespace A and B.

My problems so far:

#1 the init function should be called as: A.init(); NOT A.A.init();
#2 A.Material does not exist in the generated binding code. Only B.Material

Command to generate binding:

swig -outdir generated -c++ -v -csharp -namespace A -Wall a.i
swig -outdir generated -c++ -v -csharp -namespace B -Wall b.i


runme.cs is using the generated code.

--

csharp-example.rar

William S Fulton

unread,
Mar 15, 2012, 5:15:14 PM3/15/12
to Anders Backman, swig...@lists.sourceforge.net
On 14/03/12 10:13, Anders Backman wrote:
> Second attempt, seems that the SWIG list does not like html formatted
> messages...
>
>
> Hi all, Im new to SWIG. Right now I'm deciding whether to use SWIG or
> CLI/C++ for wrapping a rather large C++ API into .NET (C#)
> Im using SWIG 2.0.4 and Visual Studio 2010.
>
> I stumbled on some quite irritating hurdles immediately.
> I have tried to illustrate the problem in the attached code, it should
> build if you have swig.exe in the path.
>
>
>
> I have basically two namespace's A and B (in reality I have a lot
> more, these are just very reduced examples to show two of my
> problems).
> One thing that sticks out is that there are two classes with the same
> name that exist both in namespace A and B.
>
>
Have you looked at the nspace feature? Read the namespace section which
I'd guess you havn't yet come across:

http://www.swig.org/Doc2.0/SWIGPlus.html#SWIGPlus_namespaces

William

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Swig-user mailing list
Swig...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user

Reply all
Reply to author
Forward
0 new messages