Created
September 8, 2016 17:05
-
-
Save nschloe/2905bbd136605aa91eeb5d22cbe6ec05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MYFOO_HPP | |
#define MYFOO_HPP | |
#include <vector> | |
double sum(const std::vector<double> & a) { | |
double sum = 0.0; | |
for (const auto & elem: a) { | |
sum += elem; | |
} | |
return sum; | |
} | |
#endif // MYFOO_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%module myfoo | |
%{ | |
#define SWIG_FILE_WITH_INIT | |
#include "myfoo.hpp" | |
%} | |
%include <std_vector.i> | |
namespace std { | |
%template(Line) vector<double>; | |
} | |
%include "myfoo.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from distutils.core import setup, Extension | |
setup( | |
name='myfoo', | |
ext_modules=[ | |
Extension( | |
'_myfoo', | |
['myfoo.i'], | |
swig_opts=['-keyword', '-c++'], | |
extra_compile_args=['-std=c++11'] | |
) | |
], | |
py_modules=['myfoo'], | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment