mix custom typemap(in) and standard typemap(in)

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

mix custom typemap(in) and standard typemap(in)

Arnaud RICHARD

I need to convert a buffer from TCL to C using swig.

 

The C prototype is:

void Send(const uint8_t* FrameTx, const uint32_t NbBitTx);

 

If I rely on standard typemaps and pass in TCL:

TCL> Send 0x26 7

I get the following error:

TypeError in method 'Send, argument 1 of type 'uint8_t const *'

Which I don’t know hox to handle from TCL.

 

Searching the mailing-list, I found the following typemap:

%typemap(in)  (const uint8_t* FrameTx, const uint32_t NbBitTx) %{

    $1 = Tcl_GetByteArrayFromObj($input, (int*)&$2);

%}

 

Which may generates code to convert correctly the first argument from TCL to FrameTx, but doesn’t generate anymore the code to convert the second argument from TCL to NbBitTx.

 

How can I modify the conversion for first argument using value of the second argument while still having default handling of the second argument ?

 

Thx

Arnaud

 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|

Re: mix custom typemap(in) and standard typemap(in)

William S Fulton


On 12 May 2017 at 11:37, Arnaud RICHARD <[hidden email]> wrote:

I need to convert a buffer from TCL to C using swig.

 

The C prototype is:

void Send(const uint8_t* FrameTx, const uint32_t NbBitTx);

 

If I rely on standard typemaps and pass in TCL:

TCL> Send 0x26 7

I get the following error:

TypeError in method 'Send, argument 1 of type 'uint8_t const *'

Which I don’t know hox to handle from TCL.

 

Searching the mailing-list, I found the following typemap:

%typemap(in)  (const uint8_t* FrameTx, const uint32_t NbBitTx) %{

    $1 = Tcl_GetByteArrayFromObj($input, (int*)&$2);

%}

 

Which may generates code to convert correctly the first argument from TCL to FrameTx, but doesn’t generate anymore the code to convert the second argument from TCL to NbBitTx.

 

How can I modify the conversion for first argument using value of the second argument while still having default handling of the second argument ?

 


%include <stdint.i> // This library file provides the appropriate typedefs to handle uint32_t

William

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user