Quantcast

Csharp: typemap not applied or typemap search working incorrectly

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Csharp: typemap not applied or typemap search working incorrectly

peter greenwood
typemapIssue.zip
C# typemap searching may have an issue OR of course I am doing something wrong!
I am using Swig version 2.0.9. On windows.
A failing example is include in attached zip.

I am wrapping a number of CPP classes targeting both Java and C# with similar interface files. Java is OK. In the failing example included here I get the following generated:-
  public void addB(string bvalue) {....
  public string getB(int index) { ...
I think I should get:-
  public void addB(byte[] bvalue)) {....
  public byte[] getB(int index) {

You can find this method in the class StringVector.

However, in StringMap I get:-
 public void setB(byte[] bkey, byte[] bvalue) { ...
  public byte[] getB(byte[] bkey) {
which are correct.

Regards

Peter
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Csharp: typemap not applied or typemap search working incorrectly

William S Fulton
On 28/01/13 12:17, peter greenwood wrote:

> typemapIssue.zip
> <http://swig.10945.n7.nabble.com/file/n13030/typemapIssue.zip>
> C# typemap searching may have an issue OR of course I am doing something
> wrong!
> I am using Swig version 2.0.9. On windows.
> A failing example is include in attached zip.
>
> I am wrapping a number of CPP classes targeting both Java and C# with
> similar interface files. Java is OK. In the failing example included here I
> get the following generated:-
>    public void addB(string bvalue) {....
>    public string getB(int index) { ...
> I think I should get:-
>    public void addB(byte[] bvalue)) {....
>    public byte[] getB(int index) {
>
> You can find this method in the class StringVector.
>
> However, in StringMap I get:-
>   public void setB(byte[] bkey, byte[] bvalue) { ...
>    public byte[] getB(byte[] bkey) {
> which are correct.
>


This line:

%template(StringVector) std::vector<std::string>;

instantiates the StringVector wrappers. Note that it occurs before you
apply the typemaps that you want:

%apply std::string& FSD_BSTRING  {
        const std::string& bstring,
        const std::string& bkey,
        const std::string& bvalue
         };

Hence they are not used. Solution is to move the typemaps (%apply)
before the %template.

William

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Loading...