diff --git a/src/pytrexio.i b/src/pytrexio.i index a2ba005..52a7be9 100644 --- a/src/pytrexio.i +++ b/src/pytrexio.i @@ -43,7 +43,7 @@ /* Return number of sparse data points stored in the file as part of the output tuple */ %apply int *OUTPUT { int64_t* const size_max}; /* Return number of sparse data points read from the file as part of the output tuple */ -/* %apply int *INOUT { int64_t* const buffer_size_read}; */ +%apply int *INOUT { int64_t* const buffer_size_read}; /* Does not work for arrays (SIGSEGV) */ @@ -88,11 +88,11 @@ import_array(); %apply (int64_t* ARGOUT_ARRAY1, int64_t DIM1) {(int64_t* const dset_out, const int64_t dim_out)}; %apply (int64_t* IN_ARRAY1, int64_t DIM1) {(const int64_t* dset_in, const int64_t dim_in)}; /* Enable write|read_safe functions to convert numpy arrays from/to sparse arrays */ -%apply (double* IN_ARRAY1, int64_t DIM1) {(const double* value_sparse, const int64_t size_value_write)}; -%apply (int32_t* IN_ARRAY1, int64_t DIM1) {(const int32_t* index_sparse, const int64_t size_index_write)}; +%apply (double* IN_ARRAY1, int64_t DIM1) {(const double* value_sparse_write, const int64_t size_value_write)}; +%apply (int32_t* IN_ARRAY1, int64_t DIM1) {(const int32_t* index_sparse_write, const int64_t size_index_write)}; -%apply (int32_t* ARGOUT_ARRAY1, int DIM1) {(int32_t* const index_sparse_read, const int64_t size_index_read)}; -%apply (double* ARGOUT_ARRAY1, int DIM1) {(double* const value_sparse_read, const int64_t size_value_read)}; +%apply (double* ARGOUT_ARRAY1, int64_t DIM1) {(double* const value_sparse_read, const int64_t size_value_read)}; +%apply (int32_t* ARGOUT_ARRAY1, int64_t DIM1) {(int32_t* const index_sparse_read, const int64_t size_index_read)}; /* This tells SWIG to treat char ** dset_in pattern as a special case Enables access to trexio_[...]_write_dset_str set of functions directly, i.e. diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index 874c36a..bb7f661 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -2416,11 +2416,25 @@ trexio_exit_code trexio_has_$group_dset$(trexio_t* const file); trexio_exit_code trexio_read_$group_dset$(trexio_t* const file, const int64_t offset_file, int64_t* const buffer_size, int32_t* const index_sparse, double* const value_sparse); trexio_exit_code trexio_read_$group_dset$_size(trexio_t* const file, int64_t* const size_max); trexio_exit_code trexio_write_$group_dset$(trexio_t* const file, const int64_t offset_file, const int64_t buffer_size, const int32_t* index_sparse, const double* value_sparse); +trexio_exit_code trexio_read_safe_$group_dset$(trexio_t* const file, const int64_t offset_file, int64_t* const buffer_size_read, int32_t* const index_sparse_read, const int64_t size_index_read, double* const value_sparse_read, const int64_t size_value_read); +trexio_exit_code trexio_write_safe_$group_dset$(trexio_t* const file, const int64_t offset_file, const int64_t buffer_size, const int32_t* index_sparse_write, const int64_t size_index_write, const double* value_sparse_write, const int64_t size_value_write); #+end_src **** Source code for default functions #+begin_src c :tangle read_dset_sparse_front.c +trexio_exit_code trexio_read_safe_$group_dset$(trexio_t* const file, + const int64_t offset_file, + int64_t* const buffer_size_read, + int32_t* const index_sparse_read, + const int64_t size_index_read, + double* const value_sparse_read, + const int64_t size_value_read + ) +{ + return trexio_read_$group_dset$(file, offset_file, buffer_size_read, index_sparse_read, value_sparse_read); +} + trexio_exit_code trexio_read_$group_dset$(trexio_t* const file, const int64_t offset_file, @@ -2525,13 +2539,25 @@ trexio_read_$group_dset$_size(trexio_t* const file, int64_t* const size_max) #+begin_src c :tangle write_dset_sparse_front.c +trexio_exit_code trexio_write_safe_$group_dset$(trexio_t* const file, + const int64_t offset_file, + const int64_t buffer_size, + const int32_t* index_sparse_write, + const int64_t size_index_write, + const double* value_sparse_write, + const int64_t size_value_write + ) +{ + return trexio_write_$group_dset$(file, offset_file, buffer_size, index_sparse_write, value_sparse_write); +} + trexio_exit_code trexio_write_$group_dset$(trexio_t* const file, - const int64_t offset_file, - const int64_t buffer_size, - const int32_t* index_sparse, - const double* value_sparse - ) + const int64_t offset_file, + const int64_t buffer_size, + const int32_t* index_sparse, + const double* value_sparse + ) { if (file == NULL) return TREXIO_INVALID_ARG_1; if (offset_file < 0L) return TREXIO_INVALID_ARG_2;