Questions tagged [swig]

SWIG is an interface compiler that connects programs written in C and C++ with scripting languages such as Perl, Python, Ruby, and Tcl.

SWIG is typically used to parse C/C++ interfaces and generate the 'glue code' required for the target language to call into the C/C++ code. SWIG can also export its parse tree in the form of XML and Lisp s-expressions. SWIG is free software and the code that SWIG generates is compatible with both commercial and non-commercial projects.

For information about the features of SWIG and the supported languages see: http://www.swig.org/compare.html

One of many projects using SWIG to generate libraries for the above languages is Subversion. Other projects listed here.

Documentation:

3063 questions
1
vote
1 answer

Having trouble with calling Endpoint.utilAddPendingJob(job)

I'm trying to call the PJSUA2 library from Python, it works fine but I hit a snag trying to call void utilAddPendingJob(PendingJob *job) which results in the following error TypeError: in method 'Endpoint_utilAddPendingJob', argument 2 of type…
Rob
  • 21
  • 3
1
vote
2 answers

Android, SWIG and bidirectional communication

I have a C++ api I can't change which: exposes object (easy) exposes interfaces that have to be derived by caller (classical trigger-listener design pattern). I managed to wrap this API to python using SWIG and the director feature, which allows…
Bruce
  • 7,094
  • 1
  • 25
  • 42
1
vote
1 answer

swig, pass carrays with no dimension especified

This is part of the code I wanna wrap: typedef unsigned char UINT8; ... void fn(UINT8 data[]); In a .i file, I included: From 8.2.2 carrays.i: %array_class(UINT8, UINT8Array) To support array write operation: %typemap(in) UINT8[ANY] ($1_basetype…
pablomtz
  • 129
  • 7
1
vote
0 answers

SWIG-Python: How to garbage collect int pointer

I have a big C project and I want to expose it's API to python by using SWIG. For that, I have a script for generating automatically the interface file for swig (.i file). For each type defined in the project, the script adds to the interface file…
guy szweigman
  • 514
  • 5
  • 8
1
vote
1 answer

Cannot include when generating SWIG bindings

Here's my preprocessor section in my C++ code which I want to generate SWIG bindings. #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__) \ || defined(__OpenBSD__) #include #endif #if…
Zack Lee
  • 2,784
  • 6
  • 35
  • 77
1
vote
1 answer

How to create SWIG typemap for a function that takes 2 tables?

I'm trying to create a SWIG typemap for the following function: void mix(int size, float *in1, float *in2, float *out1) { for (int i = 0; i < size; ++i) out1[i] = in1[i] + in2[i]; } In lua, I want this function to take 2 table arguments…
Zack Lee
  • 2,784
  • 6
  • 35
  • 77
1
vote
0 answers

How to solve the math operation of templates' arguments in SWIG?

I want to convert some C++ code to Java code in SWIG. In some C++ templates, there are some math operation about templates' parameters. Such as: template value<1 + 2 * (nbits - es)> fma(const posit& a, const…
MK.Bin
  • 73
  • 6
1
vote
0 answers

Java+SWIG How to access the elements of an array within a struct?

Trying to pass a C struct in and out of Java. Everything works except I cannot figure out how to read and write the elements of the array inside the structure. I read about memberin typemap but I am sure I am still not using it right. My module file…
Coconha
  • 11
  • 2
1
vote
1 answer

Python ctypes and void const pointers

I have an numpy array of uint8, that I would like to pass as a void const pointer to a C++ library through SWIG. I use this python…
pserra
  • 206
  • 1
  • 11
1
vote
0 answers

How to wrap UserDefinedType* getObject() and populate Java container from a member of type const uint16_t* of the returned object

I have the following struct which contains a data member pixeldata_ which is a pointer to an array of short ints. Size of this array is width * height. struct Frame { public: const uint16_t* getPixelData() { return this->pixeldata_; …
getchar
  • 75
  • 9
1
vote
1 answer

SWIG: How to get value of wrapped std::shared_ptr from SwigPyobject

I'm trying to create a SWIG Python interface for a C++ library, to add Python wrappers for some functions, and I would greatly appreciate some help from someone experienced with SWIG. For now I have such sources: test.h namespace Test { class…
1
vote
1 answer

How to pass a std::vector with data to Java via Swig?

I have the following C++ library, which I want to use in Java using Swig to generate the necessary glue code. However, I am finding it difficult to send a vector of user-defined objects to C++ which have some data. I tried using std_vector.i but…
getchar
  • 75
  • 9
1
vote
1 answer

How can I build RDKits C# Wrappers — Visual Studio 2019 x64

I have followed the steps described here: https://github.com/bp-kelley/rdkit-csharp to try and create RDKits C# Wrappers. git clone https://github.com/bp-kelley/rdkit-csharp.git git clone https://github.com/rdkit/rdkit.git cd…
OrderAndChaos
  • 3,547
  • 2
  • 30
  • 57
1
vote
0 answers

How to convert python tf.Tensor into C++ Tensor using pybind11

I am developing a Python library in C++ using pybind11. This library is meant to be used with deep learning packages like TensorFlow, so some of the functions it exposes take TensorFlow objects as argument, and in particular tf.Tensor instances. At…
sunmat
  • 6,976
  • 3
  • 28
  • 44
1
vote
1 answer

SWIG: std/multimap.i seems broken for Tcl wrapping

I am trying to wrap a class ContainerMap which exposes a single multimap data member: namespace MYCLASSES { class ContainedAttributes { std::string _value; }; class NameList { public: std::vector _names; …
LMNCA
  • 21
  • 6