What you can is the following.
zerocool.i
%module zerocool
%{
#define SWIG_FILE_WITH_INIT
#include "zerocool.h"
%}
#ifdef SWIGPYTHON
%include "numpy.i"
%init {
import_array();
}
#endif
%apply (int* IN_ARRAY1, int DIM1) \
{(int* arr1, int len1)}
%apply (int* IN_ARRAY1, int DIM1) \
{(int* arr2, int len2)}
%apply (int* IN_ARRAY1, int DIM1) \
{(int* arr2, int len2)}
%inline %{
float my_func(int *arr1, int len1,
int *arr2, int len2,
int *arr3, int len3) {
return my_func(arr1, arr2, arr3, len3);
}
%}
You original header, say zerocool.h
#pragma once
float my_func(int *arr1, int *arr2, int *arr3, int length);
Your source, say zerocool.cpp
#include "zerocool.h"
#include "stdio.h"
float my_func(int *arr1, int *arr2, int *arr3, int length) {
printf("Function is called\n");
// Do some work on your input data
return 0.0f;
}
Sample CMakeLists.txt file
cmake_minimum_required(VERSION 3.0)
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
set(Python_ADDITIONAL_VERSIONS 3.5 3.6 3.7)
find_package(PythonInterp 3 REQUIRED)
find_package(PythonLibs)
include_directories(${PYTHON_INCLUDE_PATH})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set_property(SOURCE zerocool.i PROPERTY SWIG_FLAGS "-D_SWIG_WIN32")
set_source_files_properties(zerocool.i PROPERTIES CPLUSPLUS ON)
swig_add_library(zerocool LANGUAGE python SOURCES zerocool.i zerocool.cpp)
swig_link_libraries(zerocool ${PYTHON_LIBRARIES})
int *arr1, int len1for each of the one-dimensional inputs, if you use thenumpy.ifilelibraryName.ia C-wrapper function with a signature(int* arr1, int len1, int* arr2, int len2, int* arr3, int len3), which calls your function. Afterwards, you can use the%renamefunctionality of swig to make the wrapped functions name equal the original name