Possible bug in C#??

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible bug in C#??

Xutuan Zhang
I'm new to SWIG, and I am trying to wrap the following structure in C#.

*********************************
/*mytest.i*/

%module mytest

typedef struct {
   int a;
   int b;
   double arr[100];
} test_struct;
*********************************

But supprisingly when I run it with SWIG (swig.exe -csharp mytest.i),
in the generated test_struct.cs, I have:
***************************
  public int a {
    set {
      mytestPINVOKE.set_test_struct_a(swigCPtr, value);
    }
    get {
      int ret = mytestPINVOKE.get_test_struct_a(swigCPtr);
      return ret;
    }
  }
**********************************

Note the set/get. This is not right. do I miss anything or is this a
bug? (I tested with 1.3.25 and 1.3.27, and they are the same). If not,
how can I wrap this structure properly??

Thank you very much.

Xutuan


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug in C#??

William S Fulton
Xutuan Zhang wrote:

> I'm new to SWIG, and I am trying to wrap the following structure in C#.
>
> *********************************
> /*mytest.i*/
>
> %module mytest
>
> typedef struct {
>    int a;
>    int b;
>    double arr[100];
> } test_struct;
> *********************************
>
> But supprisingly when I run it with SWIG (swig.exe -csharp mytest.i),
> in the generated test_struct.cs, I have:
> ***************************
>   public int a {
>     set {
>       mytestPINVOKE.set_test_struct_a(swigCPtr, value);
>     }
>     get {
>       int ret = mytestPINVOKE.get_test_struct_a(swigCPtr);
>       return ret;
>     }
>   }
> **********************************
>
> Note the set/get. This is not right. do I miss anything or is this a
> bug? (I tested with 1.3.25 and 1.3.27, and they are the same). If not,
> how can I wrap this structure properly??
>

There are other ways to wrap this structure, but there is nothing wrong
with the above approach. This C# code should work beautifully using the
SWIG generated wrappers:

test_struct ts = new test_struct();
ts.a = 10;
int a = ts.a;



William


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug in C#??

Xutuan Zhang
Thanks very much, William. I admit I am new to C# too and I didn't
know C# can handle set/get like this. I am now doing some readings on
http://www.c-sharpcorner.com/Language/PropertiesInCSRVS.asp

Thanks again.

Xutuan

On 11/10/05, William S Fulton <[hidden email]> wrote:

> Xutuan Zhang wrote:
> > I'm new to SWIG, and I am trying to wrap the following structure in C#.
> >
> > *********************************
> > /*mytest.i*/
> >
> > %module mytest
> >
> > typedef struct {
> >    int a;
> >    int b;
> >    double arr[100];
> > } test_struct;
> > *********************************
> >
> > But supprisingly when I run it with SWIG (swig.exe -csharp mytest.i),
> > in the generated test_struct.cs, I have:
> > ***************************
> >   public int a {
> >     set {
> >       mytestPINVOKE.set_test_struct_a(swigCPtr, value);
> >     }
> >     get {
> >       int ret = mytestPINVOKE.get_test_struct_a(swigCPtr);
> >       return ret;
> >     }
> >   }
> > **********************************
> >
> > Note the set/get. This is not right. do I miss anything or is this a
> > bug? (I tested with 1.3.25 and 1.3.27, and they are the same). If not,
> > how can I wrap this structure properly??
> >
>
> There are other ways to wrap this structure, but there is nothing wrong
> with the above approach. This C# code should work beautifully using the
> SWIG generated wrappers:
>
> test_struct ts = new test_struct();
> ts.a = 10;
> int a = ts.a;
>
>
>
> William
>


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user