mirror of
https://github.com/eclipse/upm.git
synced 2025-03-14 20:47:30 +03:00
swig: ensure that all uint*_t passed in have the correct type.
Otherwise, we generate an exception. This should fix Issue #172: https://github.com/intel-iot-devkit/upm/issues/172 Signed-off-by: Zion Orent <zorent@ics.com> Signed-off-by: Jon Trulson <jtrulson@ics.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
e003a11723
commit
387b2b86b0
@ -6,3 +6,30 @@
|
||||
%include "stdint.i"
|
||||
%include "carrays.i"
|
||||
%array_class(uint16_t, uint16Array);
|
||||
|
||||
// Adding these typemaps because SWIG is converting uint8, uint16, and uint32 into a short by default
|
||||
// This forces SWIG to convert it correctly
|
||||
|
||||
#if (SWIG_JAVASCRIPT_V8)
|
||||
%typemap(in) uint16_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint16Array, 0 | 0 );
|
||||
if (!SWIG_IsOK(res)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res), "failed to convert input to uint16");
|
||||
}
|
||||
$1 = (uint16_t *)(argp);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (SWIGPYTHON)
|
||||
%typemap(in) uint16_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint16Array, 0 | 0 );
|
||||
if (!SWIG_IsOK(res)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res), "failed to convert input to uint16");
|
||||
}
|
||||
$1 = reinterpret_cast< uint16_t * >(argp);
|
||||
}
|
||||
#endif
|
||||
|
||||
//#elsif (SWIGJAVA)
|
||||
|
@ -6,3 +6,51 @@
|
||||
%include "stdint.i"
|
||||
%include "carrays.i"
|
||||
%array_class(uint32_t, uint32Array);
|
||||
|
||||
// Adding these typemaps because SWIG is converting uint8, uint16, and uint32 into a short by default
|
||||
// This forces SWIG to convert it correctly
|
||||
|
||||
#if (SWIG_JAVASCRIPT_V8)
|
||||
%typemap(in) uint32_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_uint32Array, 0 | 0 );
|
||||
if (!SWIG_IsOK(res)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res), "failed to convert input to uint32 *");
|
||||
}
|
||||
$1 = (uint32_t *)(argp);
|
||||
}
|
||||
|
||||
/*$input (non-pointer) is a v8::object, which inherits from v8::value */
|
||||
%typemap(in) uint32_t {
|
||||
int ecode2 = 0 ;
|
||||
if (($input)->IsInt32())
|
||||
$1 = ($input)->Uint32Value();
|
||||
else
|
||||
SWIG_exception_fail(SWIG_ArgError(ecode2), "failed to convert uint32");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (SWIGPYTHON)
|
||||
%typemap(in) uint32_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_uint32Array, 0 | 0 );
|
||||
if (!SWIG_IsOK(res)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res), "failed to convert input to uint32 *");
|
||||
}
|
||||
$1 = reinterpret_cast< uint32_t * >(argp);
|
||||
}
|
||||
|
||||
/*$input (non-pointer) */
|
||||
%typemap(in) uint32_t {
|
||||
long v;
|
||||
int res = SWIG_AsVal_long ($input, &v);
|
||||
if (SWIG_IsOK(res)) {
|
||||
$1 = PyInt_AsLong($input);
|
||||
}
|
||||
else {
|
||||
SWIG_exception_fail(SWIG_ArgError(res), "failed to convert uint32");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//#elsif (SWIGJAVA)
|
||||
|
@ -6,3 +6,30 @@
|
||||
%include "stdint.i"
|
||||
%include "carrays.i"
|
||||
%array_class(uint8_t, uint8Array);
|
||||
|
||||
// Adding these typemaps because SWIG is converting uint8, uint16, and uint32 into a short by default
|
||||
// This forces SWIG to convert it correctly
|
||||
|
||||
#if (SWIG_JAVASCRIPT_V8)
|
||||
%typemap(in) uint8_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint8Array, 0 | 0 );
|
||||
if (!SWIG_IsOK(res)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res), "failed to convert input to uint8");
|
||||
}
|
||||
$1 = (uint8_t *)(argp);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (SWIGPYTHON)
|
||||
%typemap(in) uint8_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint8Array, 0 | 0 );
|
||||
if (!SWIG_IsOK(res)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res), "failed to convert input to uint8");
|
||||
}
|
||||
$1 = reinterpret_cast< uint8_t * >(argp);
|
||||
}
|
||||
#endif
|
||||
|
||||
//#elsif (SWIGJAVA)
|
||||
|
@ -2,12 +2,6 @@
|
||||
%include "../upm.i"
|
||||
%include "../carrays_uint16_t.i"
|
||||
|
||||
%typemap(in) uint16_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint16Array, 0 | 0 );
|
||||
$1 = (uint16_t *)(argp);
|
||||
}
|
||||
|
||||
%include "gas.h"
|
||||
%{
|
||||
#include "gas.h"
|
||||
|
@ -4,12 +4,6 @@
|
||||
%include "../upm.i"
|
||||
%include "../carrays_uint16_t.i"
|
||||
|
||||
%typemap(in) uint16_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint16Array, 0 | 0 );
|
||||
$1 = reinterpret_cast< uint16_t * >(argp);
|
||||
}
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
%include "gas.h"
|
||||
|
@ -4,26 +4,6 @@
|
||||
%include "../carrays_uint16_t.i"
|
||||
%include "../carrays_uint32_t.i"
|
||||
|
||||
// Adding this typemap because SWIG is converting uint8, uint16, and uint32 into a short by default
|
||||
// This forces SWIG to convert it correctly
|
||||
%typemap(in) uint8_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_uint8Array, 0 | 0 );
|
||||
$1 = (uint8_t *)(argp);
|
||||
}
|
||||
|
||||
%typemap(in) uint16_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_uint16Array, 0 | 0 );
|
||||
$1 = (uint16_t *)(argp);
|
||||
}
|
||||
|
||||
%typemap(in) uint32_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_uint32Array, 0 | 0 );
|
||||
$1 = (uint32_t *)(argp);
|
||||
}
|
||||
|
||||
%{
|
||||
#include "hmtrp.h"
|
||||
speed_t int_B9600 = B9600;
|
||||
|
@ -6,26 +6,6 @@
|
||||
%include "../carrays_uint16_t.i"
|
||||
%include "../carrays_uint32_t.i"
|
||||
|
||||
// Adding this typemap because SWIG is converting uint8, uint16, and uint32 into a short by default
|
||||
// This forces SWIG to convert it correctly
|
||||
%typemap(in) uint8_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_uint8Array, 0 | 0 );
|
||||
$1 = reinterpret_cast< uint8_t * >(argp);
|
||||
}
|
||||
|
||||
%typemap(in) uint16_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_uint16Array, 0 | 0 );
|
||||
$1 = reinterpret_cast< uint16_t * >(argp);
|
||||
}
|
||||
|
||||
%typemap(in) uint32_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_uint32Array, 0 | 0 );
|
||||
$1 = reinterpret_cast< uint32_t * >(argp);
|
||||
}
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
%include "hmtrp.h"
|
||||
|
@ -2,12 +2,6 @@
|
||||
%include "../upm.i"
|
||||
%include "../carrays_uint8_t.i"
|
||||
|
||||
%typemap(in) uint8_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint8Array, 0 | 0 );
|
||||
$1 = (uint8_t *)(argp);
|
||||
}
|
||||
|
||||
%include "ssd.h"
|
||||
%include "lcd.h"
|
||||
%{
|
||||
|
@ -4,13 +4,6 @@
|
||||
%include "../upm.i"
|
||||
%include "../carrays_uint8_t.i"
|
||||
|
||||
%typemap(in) uint8_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint8Array, 0 | 0 );
|
||||
$1 = reinterpret_cast< uint8_t * >(argp);
|
||||
}
|
||||
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
%include "ssd.h"
|
||||
|
@ -2,12 +2,6 @@
|
||||
%include "../upm.i"
|
||||
%include "../carrays_uint16_t.i"
|
||||
|
||||
%typemap(in) uint16_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint16Array, 0 | 0 );
|
||||
$1 = (uint16_t *)(argp);
|
||||
}
|
||||
|
||||
%{
|
||||
#include "mic.h"
|
||||
%}
|
||||
|
@ -4,12 +4,6 @@
|
||||
%include "../upm.i"
|
||||
%include "../carrays_uint16_t.i"
|
||||
|
||||
%typemap(in) uint16_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint16Array, 0 | 0 );
|
||||
$1 = reinterpret_cast< uint16_t * >(argp);
|
||||
}
|
||||
|
||||
%{
|
||||
#include "mic.h"
|
||||
%}
|
||||
|
@ -2,14 +2,6 @@
|
||||
%include "../upm.i"
|
||||
%include "../carrays_uint8_t.i"
|
||||
|
||||
// Adding this typemap because SWIG is converting uint8 into a short by default
|
||||
// This forces SWIG to convert it correctly
|
||||
%typemap(in) uint8_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_uint8Array, 0 | 0 );
|
||||
$1 = (uint8_t *)(argp);
|
||||
}
|
||||
|
||||
%{
|
||||
#include "pn532.h"
|
||||
%}
|
||||
|
@ -4,14 +4,6 @@
|
||||
%include "../upm.i"
|
||||
%include "../carrays_uint8_t.i"
|
||||
|
||||
// Adding this typemap because SWIG is converting uint8, uint16, and uint32 into a short by default
|
||||
// This forces SWIG to convert it correctly
|
||||
%typemap(in) uint8_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_uint8Array, 0 | 0 );
|
||||
$1 = reinterpret_cast< uint8_t * >(argp);
|
||||
}
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
#ifdef DOXYGEN
|
||||
|
@ -7,12 +7,6 @@
|
||||
%rename("writeArray") write(uint8_t *digits);
|
||||
%rename("writeString") write(std::string digits);
|
||||
|
||||
%typemap(in) uint8_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_uint8Array, 0 | 0);
|
||||
$1 = (uint8_t *)(argp);
|
||||
}
|
||||
|
||||
%{
|
||||
#include "tm1637.h"
|
||||
%}
|
||||
|
@ -6,12 +6,6 @@
|
||||
|
||||
%varargs(4, int digit = 0) write;
|
||||
|
||||
%typemap(in) uint8_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint8Array, 0 | 0 );
|
||||
$1 = reinterpret_cast< uint8_t * >(argp);
|
||||
}
|
||||
|
||||
%{
|
||||
#include "tm1637.h"
|
||||
%}
|
||||
|
@ -3,19 +3,6 @@
|
||||
%include "../carrays_uint8_t.i"
|
||||
%include "../carrays_uint16_t.i"
|
||||
|
||||
%typemap(in) uint8_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint8Array, 0 | 0 );
|
||||
$1 = (uint8_t *)(argp);
|
||||
}
|
||||
|
||||
%typemap(in) uint16_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint16Array, 0 | 0 );
|
||||
$1 = (uint16_t *)(argp);
|
||||
}
|
||||
|
||||
|
||||
%{
|
||||
#include "wt5001.h"
|
||||
speed_t int_B9600 = B9600;
|
||||
|
@ -5,18 +5,6 @@
|
||||
%include "../carrays_uint8_t.i"
|
||||
%include "../carrays_uint16_t.i"
|
||||
|
||||
%typemap(in) uint8_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint8Array, 0 | 0 );
|
||||
$1 = reinterpret_cast< uint8_t * >(argp);
|
||||
}
|
||||
|
||||
%typemap(in) uint16_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint16Array, 0 | 0 );
|
||||
$1 = reinterpret_cast< uint16_t * >(argp);
|
||||
}
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
%{
|
||||
|
@ -4,17 +4,6 @@
|
||||
%include "../carrays_uint32_t.i"
|
||||
%include "cpointer.i"
|
||||
|
||||
%typemap(in) uint16_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint16Array, 0 | 0 );
|
||||
$1 = (uint16_t *)(argp);
|
||||
}
|
||||
|
||||
/*$input is a v8::object, which inherits from v8::value */
|
||||
%typemap(in) uint32_t {
|
||||
$1 = ($input)->Uint32Value();
|
||||
}
|
||||
|
||||
/* Send "int *" to JavaScript as intp */
|
||||
%pointer_functions(int, intp);
|
||||
%{
|
||||
|
@ -8,16 +8,6 @@
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
%typemap(in) uint16_t * {
|
||||
void *argp = 0 ;
|
||||
int res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_uint16Array, 0 | 0 );
|
||||
$1 = reinterpret_cast< uint16_t * >(argp);
|
||||
}
|
||||
|
||||
%typemap(in) uint32_t {
|
||||
$1 = PyInt_AsLong($input);
|
||||
}
|
||||
|
||||
/* Send "int *" to python as intp */
|
||||
%pointer_functions(int, intp);
|
||||
%{
|
||||
|
Loading…
x
Reference in New Issue
Block a user