Skip to content

Commit

Permalink
Overhaul python typemaps
Browse files Browse the repository at this point in the history
- check that we don't have a list as input
- refactor code to call static functions to only have minimal
functionality inside the actuall typemap
- re-enable boolean type by default to fix crasher
  • Loading branch information
Soeren Sonnenburg committed Nov 29, 2011
1 parent 6aebf7d commit 4bce5ac
Show file tree
Hide file tree
Showing 3 changed files with 496 additions and 377 deletions.
2 changes: 1 addition & 1 deletion src/configure
Expand Up @@ -117,7 +117,7 @@ _ld_static=""
_static=no
_optimizing=""
_interfaces=""
_datatypes="char,uint8_t,uint16_t,int32_t,int64_t,uint64_t,float32_t,float64_t"
_datatypes="bool,char,uint8_t,uint16_t,int32_t,int64_t,uint64_t,float32_t,float64_t"
_libshogun=yes
_python=auto
_octave=auto
Expand Down
6 changes: 2 additions & 4 deletions src/interfaces/octave_modular/swig_typemaps.i
Expand Up @@ -35,8 +35,7 @@ void* get_copy(void* src, size_t len)

/* One dimensional input arrays */
%define TYPEMAP_IN_SGVECTOR(oct_type_check, oct_type, oct_converter, sg_type, if_type, error_string)
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER)
shogun::SGVector<sg_type>
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) shogun::SGVector<sg_type>
{
const octave_value m=$input;

Expand Down Expand Up @@ -109,8 +108,7 @@ TYPEMAP_OUT_SGVECTOR(uint16NDArray, uint16_t, uint16_t, "Word")

/* Two dimensional input arrays */
%define TYPEMAP_IN_SGMATRIX(oct_type_check, oct_type, oct_converter, sg_type, if_type, error_string)
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER)
shogun::SGMatrix<sg_type>
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) shogun::SGMatrix<sg_type>
{
const octave_value m=$input;
$1 = (m.is_matrix_type() && m.oct_type_check()) ? 1 : 0;
Expand Down

0 comments on commit 4bce5ac

Please sign in to comment.