Skip to content

Commit

Permalink
start to simplify typemaps - extracting all code into functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed Sep 15, 2011
1 parent c834d2b commit 4f9566f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/interfaces/python_modular/swig_typemaps.i
Expand Up @@ -144,17 +144,23 @@ PyObject* make_contiguous(PyObject* ary, int* is_new_object,
}

/* End John Hunter translation (with modifications by Bill Spotz) */

int is_pyvector(PyObject* obj, int typecode)
{
return (
(obj && PyList_Check(obj) && PyList_Size(obj)>0) ||
(is_array(obj) && array_dimensions(obj)==1 && array_type(obj) == typecode)
) ? 1 : 0;
}

%}


/* One dimensional input arrays */
%define TYPEMAP_IN_SGVECTOR(type,typecode)
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) shogun::SGVector<type>
{
$1 = (
($input && PyList_Check($input) && PyList_Size($input)>0) ||
(is_array($input) && array_dimensions($input)==1 && array_type($input) == typecode)
) ? 1 : 0;
$1 = is_pyvector($input, typecode);
}

%typemap(in) shogun::SGVector<type>
Expand Down

0 comments on commit 4f9566f

Please sign in to comment.