From f13287de2ee0615f1ac9dda92b080e032e2a5fe1 Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 1 Apr 2020 02:17:09 +0200 Subject: [PATCH] swig: add page (#3951) --- pages/common/swig.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 pages/common/swig.md diff --git a/pages/common/swig.md b/pages/common/swig.md new file mode 100644 index 000000000..8b8287c27 --- /dev/null +++ b/pages/common/swig.md @@ -0,0 +1,20 @@ +# swig + +> Generate bindings between C / C++ code and various high level languages such as Javascript, Python, C#, and more. +> It uses special .i or .swg files to generate the bindings (C/C++ with SWIG directives, then outputs a C/C++ file that contains all of the wrapper code needed to build an extension module. + +- Generate a binding between C++ and Python: + +`swig -c++ -python -o {{path/to/output_wrapper.cpp}} {{path/to/swig_file.i}}` + +- Generate a binding between C++ and Go: + +`swig -go -cgo -intgosize 64 -c++ {{path/to/swig_file.i}}` + +- Generate a binding between C and Java: + +`swig -java {{path/to/swig_file.i}}` + +- Generate a binding between C and Ruby and prefix the Ruby module with {{foo::bar::}}: + +`swig -ruby -prefix "{{foo::bar::}}" {{path/to/swig_file.i}}`