1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-12-23 04:44:03 +01:00
qmckl/python/pyqmckl.i

50 lines
1.4 KiB
OpenEdge ABL
Raw Normal View History

2022-05-02 13:39:22 +02:00
%module pyqmckl
/* Define SWIGWORDSIZE in order to properly align long integers on 64-bit system */
#define SWIGWORDSIZE64
%{
#define SWIG_FILE_WITH_INIT
/* Include the headers in the wrapper code */
#include "qmckl.h"
%}
/* Include stdint to recognize types from stdint.h */
%include <stdint.i>
2022-05-02 16:36:34 +02:00
/* Include typemaps to play with input/output re-casting (e.g. C pointers) */
2022-05-02 13:39:22 +02:00
%include typemaps.i
%apply int *OUTPUT { qmckl_exit_code *exit_code};
2022-05-02 16:36:34 +02:00
/* Avoid passing file_name length as an additiona argument */
%apply (char *STRING, int LENGTH) { (const char* file_name, const int64_t size_max) };
/* For functions that return strings */
2022-05-02 13:39:22 +02:00
%include <cstring.i>
2022-05-02 16:36:34 +02:00
%cstring_bounded_output(char* function_name, 1024);
%cstring_bounded_output(char* message, 1024);
2022-05-02 13:39:22 +02:00
2022-05-02 16:36:34 +02:00
/* This block is needed make SWIG convert NumPy arrays to/from from the C pointer and size_max argument.
NOTE: `numpy.i` interface file is not part of SWIG but it is included in the numpy distribution (under numpy/tools/swig/numpy.i)
2022-05-02 13:39:22 +02:00
*/
%include "numpy.i"
%init %{
import_array();
%}
/* Typemaps below change the type of numpy array dimensions from int to int64_t */
%numpy_typemaps(double, NPY_DOUBLE, int64_t)
%numpy_typemaps(float, NPY_FLOAT, int64_t)
%numpy_typemaps(int32_t, NPY_INT32, int64_t)
%numpy_typemaps(int64_t, NPY_INT64, int64_t)
/* Include typemaps generated by the process.py */
%include pyqmckl_include.i
/* Parse the header files to generate wrappers */
%include "qmckl.h"