Typedef in a C# module

View: New views
5 Messages — Rating Filter:   Alert me  

Typedef in a C# module

by Eyal Raab-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi,

 

I'm using SWIG 1.3.40 with C#.

 

I have the following problem – I can't seem to get SWIG to convert UINT8 to a C# string automatically.

 

Here is a description of the problem:

I have the following simple module:

 

/* File : example.i */

%module example

%include "windows.i"

 

%inline %{

typedef struct {

UINT8 userName[32];

} multiInitParams;

%}

 

 

On the C# side, A SWIGTYPE_p_unsigned_char class is being created and the generated C# class looks like this:

 

public SWIGTYPE_p_unsigned_char userName { … }

….

 

Changing the UINT8 to a char works as expected and generates the following C# signature:

 

            …

public string userName { …  }

 

I've tried adding typedefs, adding windows.i file and several additional module files. Nothing seems to work.

 

Is this possible? Am I missing something?

 

Thanks in advance,

Eyal.



This mail was sent via Mail-SeCure System.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: Typedef in a C# module

by Juan Manuel Alvarez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Have you tried using %apply?

%apply char { UINT8 };
%apply const char& { const UINT8 & };

For more information about apply, refer to
http://www.swig.org/Doc1.3/SWIGDocumentation.html#Arguments_nn2
Please tell me if that worked for you.

Cheers!
Juan M.

On Thu, Sep 24, 2009 at 4:54 AM, Eyal Raab <Eyal.Raab@...> wrote:

> Hi,
>
>
>
> I'm using SWIG 1.3.40 with C#.
>
>
>
> I have the following problem – I can't seem to get SWIG to convert UINT8 to
> a C# string automatically.
>
>
>
> Here is a description of the problem:
>
> I have the following simple module:
>
>
>
> /* File : example.i */
>
> %module example
>
> %include "windows.i"
>
>
>
> %inline %{
>
> typedef struct {
>
> UINT8 userName[32];
>
> } multiInitParams;
>
> %}
>
>
>
>
>
> On the C# side, A SWIGTYPE_p_unsigned_char class is being created and the
> generated C# class looks like this:
>
>
>
> …
>
> public SWIGTYPE_p_unsigned_char userName { … }
>
> ….
>
>
>
> Changing the UINT8 to a char works as expected and generates the following
> C# signature:
>
>
>
>             …
>
> public string userName { …  }
>
> …
>
>
>
> I've tried adding typedefs, adding windows.i file and several additional
> module files. Nothing seems to work.
>
>
>
> Is this possible? Am I missing something?
>
>
>
> Thanks in advance,
>
> Eyal.
>
> This mail was sent via Mail-SeCure System.
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Swig-user mailing list
> Swig-user@...
> https://lists.sourceforge.net/lists/listinfo/swig-user
>
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: Typedef in a C# module

by Eyal Raab-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I did, and it didn’t work.

Eyal.


-----Original Message-----
From: naicigam [mailto:naicigam@...]
Sent: Thursday, September 24, 2009 17:56 PM
To: Eyal Raab
Cc: swig-user@...
Subject: Re: [Swig-user] Typedef in a C# module

Have you tried using %apply?

%apply char { UINT8 };
%apply const char& { const UINT8 & };

For more information about apply, refer to
http://www.swig.org/Doc1.3/SWIGDocumentation.html#Arguments_nn2
Please tell me if that worked for you.

Cheers!
Juan M.

On Thu, Sep 24, 2009 at 4:54 AM, Eyal Raab <Eyal.Raab@...> wrote:

> Hi,
>
>
>
> I'm using SWIG 1.3.40 with C#.
>
>
>
> I have the following problem – I can't seem to get SWIG to convert UINT8 to
> a C# string automatically.
>
>
>
> Here is a description of the problem:
>
> I have the following simple module:
>
>
>
> /* File : example.i */
>
> %module example
>
> %include "windows.i"
>
>
>
> %inline %{
>
> typedef struct {
>
> UINT8 userName[32];
>
> } multiInitParams;
>
> %}
>
>
>
>
>
> On the C# side, A SWIGTYPE_p_unsigned_char class is being created and the
> generated C# class looks like this:
>
>
>
> …
>
> public SWIGTYPE_p_unsigned_char userName { … }
>
> ….
>
>
>
> Changing the UINT8 to a char works as expected and generates the following
> C# signature:
>
>
>
>             …
>
> public string userName { …  }
>
> …
>
>
>
> I've tried adding typedefs, adding windows.i file and several additional
> module files. Nothing seems to work.
>
>
>
> Is this possible? Am I missing something?
>
>
>
> Thanks in advance,
>
> Eyal.
>
> This mail was sent via Mail-SeCure System.
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Swig-user mailing list
> Swig-user@...
> https://lists.sourceforge.net/lists/listinfo/swig-user
>
>

This mail was received via Mail-SeCure System.



This mail was sent via Mail-SeCure System.



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: Typedef in a C# module

by wsfulton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Use:

%apply char [ANY] { UINT8 [ANY] };

or more specifically:

%apply char [ANY] { UINT8 userName[ANY] };

This works because you are wrapping an array, so you need to apply the
array typemaps as per syntax above.

William

Eyal Raab wrote:

> I did, and it didn’t work.
>
> Eyal.
>
>
> -----Original Message-----
> From: naicigam [mailto:naicigam@...]
> Sent: Thursday, September 24, 2009 17:56 PM
> To: Eyal Raab
> Cc: swig-user@...
> Subject: Re: [Swig-user] Typedef in a C# module
>
> Have you tried using %apply?
>
> %apply char { UINT8 };
> %apply const char& { const UINT8 & };
>
> For more information about apply, refer to
> http://www.swig.org/Doc1.3/SWIGDocumentation.html#Arguments_nn2
> Please tell me if that worked for you.
>
> Cheers!
> Juan M.
>
> On Thu, Sep 24, 2009 at 4:54 AM, Eyal Raab <Eyal.Raab@...> wrote:
>> Hi,
>>
>>
>>
>> I'm using SWIG 1.3.40 with C#.
>>
>>
>>
>> I have the following problem – I can't seem to get SWIG to convert UINT8 to
>> a C# string automatically.
>>
>>
>>
>> Here is a description of the problem:
>>
>> I have the following simple module:
>>
>>
>>
>> /* File : example.i */
>>
>> %module example
>>
>> %include "windows.i"
>>
>>
>>
>> %inline %{
>>
>> typedef struct {
>>
>> UINT8 userName[32];
>>
>> } multiInitParams;
>>
>> %}
>>
>>
>>
>>
>>
>> On the C# side, A SWIGTYPE_p_unsigned_char class is being created and the
>> generated C# class looks like this:
>>
>>
>>
>> …
>>
>> public SWIGTYPE_p_unsigned_char userName { … }
>>
>> ….
>>
>>
>>
>> Changing the UINT8 to a char works as expected and generates the following
>> C# signature:
>>
>>
>>
>>             …
>>
>> public string userName { …  }
>>
>> …
>>
>>
>>
>> I've tried adding typedefs, adding windows.i file and several additional
>> module files. Nothing seems to work.
>>
>>
>>
>> Is this possible? Am I missing something?
>>
>>
>>
>> Thanks in advance,
>>
>> Eyal.
>>
>> This mail was sent via Mail-SeCure System.
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry® Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9-12, 2009. Register now!
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> Swig-user mailing list
>> Swig-user@...
>> https://lists.sourceforge.net/lists/listinfo/swig-user
>>
>>
>
> This mail was received via Mail-SeCure System.
>
>
>
> This mail was sent via Mail-SeCure System.
>
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Swig-user mailing list
> Swig-user@...
> https://lists.sourceforge.net/lists/listinfo/swig-user


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: Typedef in a C# module

by Eyal Raab-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

RE: [Swig-user] Typedef in a C# module

Thanks! Worked like a charm.

-----Original Message-----
From: William Fulton on behalf of William S Fulton
Sent: Thu 9/24/2009 11:23 PM
To: Eyal Raab
Cc: naicigam; swig-user@...
Subject: Re: [Swig-user] Typedef in a C# module

Use:

%apply char [ANY] { UINT8 [ANY] };

or more specifically:

%apply char [ANY] { UINT8 userName[ANY] };

This works because you are wrapping an array, so you need to apply the
array typemaps as per syntax above.

William

Eyal Raab wrote:
> I did, and it didn't work.
>
> Eyal.
>
>
> -----Original Message-----
> From: naicigam [naicigam@...]
> Sent: Thursday, September 24, 2009 17:56 PM
> To: Eyal Raab
> Cc: swig-user@...
> Subject: Re: [Swig-user] Typedef in a C# module
>
> Have you tried using %apply?
>
> %apply char { UINT8 };
> %apply const char& { const UINT8 & };
>
> For more information about apply, refer to
> http://www.swig.org/Doc1.3/SWIGDocumentation.html#Arguments_nn2
> Please tell me if that worked for you.
>
> Cheers!
> Juan M.
>
> On Thu, Sep 24, 2009 at 4:54 AM, Eyal Raab <Eyal.Raab@...> wrote:
>> Hi,
>>
>>
>>
>> I'm using SWIG 1.3.40 with C#.
>>
>>
>>
>> I have the following problem - I can't seem to get SWIG to convert UINT8 to
>> a C# string automatically.
>>
>>
>>
>> Here is a description of the problem:
>>
>> I have the following simple module:
>>
>>
>>
>> /* File : example.i */
>>
>> %module example
>>
>> %include "windows.i"
>>
>>
>>
>> %inline %{
>>
>> typedef struct {
>>
>> UINT8 userName[32];
>>
>> } multiInitParams;
>>
>> %}
>>
>>
>>
>>
>>
>> On the C# side, A SWIGTYPE_p_unsigned_char class is being created and the
>> generated C# class looks like this:
>>
>>
>>
>> .
>>
>> public SWIGTYPE_p_unsigned_char userName { . }
>>
>> ..
>>
>>
>>
>> Changing the UINT8 to a char works as expected and generates the following
>> C# signature:
>>
>>
>>
>>             .
>>
>> public string userName { .  }
>>
>> .
>>
>>
>>
>> I've tried adding typedefs, adding windows.i file and several additional
>> module files. Nothing seems to work.
>>
>>
>>
>> Is this possible? Am I missing something?
>>
>>
>>
>> Thanks in advance,
>>
>> Eyal.
>>
>> This mail was sent via Mail-SeCure System.
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9-12, 2009. Register now!
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> Swig-user mailing list
>> Swig-user@...
>> https://lists.sourceforge.net/lists/listinfo/swig-user
>>
>>
>
> This mail was received via Mail-SeCure System.
>
>
>
> This mail was sent via Mail-SeCure System.
>
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Swig-user mailing list
> Swig-user@...
> https://lists.sourceforge.net/lists/listinfo/swig-user


This mail was received via Mail-SeCure System.





This mail was sent via Mail-SeCure System.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user