Commit ee7049e6 authored by Karl Wette's avatar Karl Wette

Merge branch 'swig-dims-array-length-decl-fix' into 'master'

SWIG: declare all size_t dims/strides arrays with a explicit length

See merge request lscsoft/lalsuite!626
parents 24322407 d13904c4
This diff is collapsed.
......@@ -134,7 +134,7 @@ typedef struct {
/// </li><li>
/// Typemap which attempts to view pointers to \c const GSL vector.
%typemap(in, noblock=1) const gsl_vector##NAME* (void *argp = 0, int res = 0, gsl_vector##NAME##_view temp, void *temp_data = 0, size_t dims[] = {0}, int elemalloc = 0) %{
%typemap(in, noblock=1) const gsl_vector##NAME* (void *argp = 0, int res = 0, gsl_vector##NAME##_view temp, void *temp_data = 0, size_t dims[1] = {0}, int elemalloc = 0) %{
res = SWIG_ConvertPtr($input, &argp, $descriptor, 0 /*$disown*/ | %convertptr_flags);
if (!SWIG_IsOK(res)) {
if (!($disown)) {
......@@ -146,7 +146,7 @@ typedef struct {
$disown | %convertptr_flags);
if (!SWIG_IsOK(res)) {
temp_data = data = %swiglal_new_array(dims[0], TYPE);
size_t strides[] = {1};
size_t strides[1] = {1};
res = %swiglal_array_copyin(TYPE*)(swiglal_no_self(), $input, %as_voidptr(data), &elemalloc,
sizeof(TYPE), 1, dims, strides,
$typemap(swiglal_dynarr_isptr, TYPE), $typemap(swiglal_dynarr_tinfo, TYPE),
......@@ -180,7 +180,7 @@ typedef struct {
res = SWIG_ConvertPtr($input, &argp, $descriptor, 0 /*$disown*/ | %convertptr_flags);
if (!SWIG_IsOK(res)) {
if (!($disown)) {
size_t dims[] = {0};
size_t dims[1] = {0};
void *data = NULL;
/* swiglal_array_typeid input type: TYPE* */
res = %swiglal_array_viewin(TYPE*)(swiglal_no_self(), $input, %as_voidptrptr(&data),
......@@ -207,7 +207,7 @@ typedef struct {
/// - If the input argument is a SWIG-wrapped \c NAME*, just unwrap it and return a reference.
/// - If the input argument is a native scripting-language array, make an internal copy of it,
/// use the copy, and return a native scripting-language array copy of the internal copy.
%typemap(in, noblock=1) gsl_vector##NAME* SWIGLAL_COPYINOUT_ARRAY (void *argp = 0, int res = 0, gsl_vector##NAME##_view temp, SWIG_Object input_ref, void *temp_data = 0, size_t dims[] = {0}, int elemalloc = 0) %{
%typemap(in, noblock=1) gsl_vector##NAME* SWIGLAL_COPYINOUT_ARRAY (void *argp = 0, int res = 0, gsl_vector##NAME##_view temp, SWIG_Object input_ref, void *temp_data = 0, size_t dims[1] = {0}, int elemalloc = 0) %{
res = SWIG_ConvertPtr($input, &argp, $descriptor, 0 /*$disown*/ | %convertptr_flags);
if (!SWIG_IsOK(res)) {
if (!($disown)) {
......@@ -218,7 +218,7 @@ typedef struct {
$disown | %convertptr_flags);
if (dims[0] > 0) {
temp_data = %swiglal_new_array(dims[0], TYPE);
size_t strides[] = {1};
size_t strides[1] = {1};
res = %swiglal_array_copyin(TYPE*)(swiglal_no_self(), $input, %as_voidptr(temp_data), &elemalloc,
sizeof(TYPE), 1, dims, strides,
$typemap(swiglal_dynarr_isptr, TYPE), $typemap(swiglal_dynarr_tinfo, TYPE),
......@@ -240,8 +240,8 @@ typedef struct {
%}
%typemap(argout, match="in", noblock=1) gsl_vector##NAME* SWIGLAL_COPYINOUT_ARRAY %{
if (temp_data$argnum) {
const size_t dims[] = {temp$argnum.vector.size};
const size_t strides[] = {1};
const size_t dims[1] = {temp$argnum.vector.size};
const size_t strides[1] = {1};
/* swiglal_array_typeid input type: TYPE* */
%append_output(%swiglal_array_copyout(TYPE*)(swiglal_no_self(), %as_voidptr(temp_data$argnum),
sizeof(TYPE), 1, dims, strides,
......@@ -282,7 +282,7 @@ typedef struct {
/// </li><li>
/// Typemap which attempts to view pointers to \c const GSL matrix.
%typemap(in, noblock=1) const gsl_matrix##NAME* (void *argp = 0, int res = 0, gsl_matrix##NAME##_view temp, void *temp_data = 0, size_t dims[] = {0, 0}, int elemalloc = 0) %{
%typemap(in, noblock=1) const gsl_matrix##NAME* (void *argp = 0, int res = 0, gsl_matrix##NAME##_view temp, void *temp_data = 0, size_t dims[2] = {0, 0}, int elemalloc = 0) %{
res = SWIG_ConvertPtr($input, &argp, $descriptor, 0 /*$disown*/ | %convertptr_flags);
if (!SWIG_IsOK(res)) {
if (!($disown)) {
......@@ -294,7 +294,7 @@ typedef struct {
$disown | %convertptr_flags);
if (!SWIG_IsOK(res)) {
temp_data = data = %swiglal_new_array(dims[0] * dims[1], TYPE);
size_t strides[] = {dims[1], 1};
size_t strides[2] = {dims[1], 1};
res = %swiglal_array_copyin(TYPE*)(swiglal_no_self(), $input, %as_voidptr(data), &elemalloc,
sizeof(TYPE), 2, dims, strides,
$typemap(swiglal_dynarr_isptr, TYPE), $typemap(swiglal_dynarr_tinfo, TYPE),
......@@ -328,7 +328,7 @@ typedef struct {
res = SWIG_ConvertPtr($input, &argp, $descriptor, 0 /*$disown*/ | %convertptr_flags);
if (!SWIG_IsOK(res)) {
if (!($disown)) {
size_t dims[] = {0, 0};
size_t dims[2] = {0, 0};
void *data = NULL;
/* swiglal_array_typeid input type: TYPE* */
res = %swiglal_array_viewin(TYPE*)(swiglal_no_self(), $input, %as_voidptrptr(&data),
......@@ -355,7 +355,7 @@ typedef struct {
/// - If the input argument is a SWIG-wrapped \c NAME*, just unwrap it and return a reference.
/// - If the input argument is a native scripting-language array, make an internal copy of it,
/// use the copy, and return a native scripting-language array copy of the internal copy.
%typemap(in, noblock=1) gsl_matrix##NAME* SWIGLAL_COPYINOUT_ARRAY (void *argp = 0, int res = 0, gsl_matrix##NAME##_view temp, SWIG_Object input_ref, void *temp_data = 0, size_t dims[] = {0, 0}, int elemalloc = 0) %{
%typemap(in, noblock=1) gsl_matrix##NAME* SWIGLAL_COPYINOUT_ARRAY (void *argp = 0, int res = 0, gsl_matrix##NAME##_view temp, SWIG_Object input_ref, void *temp_data = 0, size_t dims[2] = {0, 0}, int elemalloc = 0) %{
res = SWIG_ConvertPtr($input, &argp, $descriptor, 0 /*$disown*/ | %convertptr_flags);
if (!SWIG_IsOK(res)) {
if (!($disown)) {
......@@ -366,7 +366,7 @@ typedef struct {
$disown | %convertptr_flags);
if (dims[0] * dims[1] > 0) {
temp_data = %swiglal_new_array(dims[0] * dims[1], TYPE);
size_t strides[] = {dims[1], 1};
size_t strides[2] = {dims[1], 1};
res = %swiglal_array_copyin(TYPE*)(swiglal_no_self(), $input, %as_voidptr(temp_data), &elemalloc,
sizeof(TYPE), 2, dims, strides,
$typemap(swiglal_dynarr_isptr, TYPE), $typemap(swiglal_dynarr_tinfo, TYPE),
......@@ -388,8 +388,8 @@ typedef struct {
%}
%typemap(argout, match="in", noblock=1) gsl_matrix##NAME* SWIGLAL_COPYINOUT_ARRAY %{
if (temp_data$argnum) {
const size_t dims[] = {temp$argnum.matrix.size1, temp$argnum.matrix.size2};
const size_t strides[] = {dims[1], 1};
const size_t dims[2] = {temp$argnum.matrix.size1, temp$argnum.matrix.size2};
const size_t strides[2] = {dims[1], 1};
/* swiglal_array_typeid input type: TYPE* */
%append_output(%swiglal_array_copyout(TYPE*)(swiglal_no_self(), %as_voidptr(temp_data$argnum),
sizeof(TYPE), 2, dims, strides,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment