The SWIG documentation explains how a variety of input types in C, like this:
void spam1(Foo *x); // Pass by pointer
void spam2(Foo &x); // Pass by reference
void spam3(Foo x); // Pass by value
void spam4(Foo x[]); // Array of objects
... would all take a single type of argument in Java, like this:
Foo f = new Foo...
I'm trying to add a python callback to a C++ library as illustrated:
template<typename T> void doCallback(shared_ptr<T> data) {
PyObject* pyfunc; //I have this already
PyObject* args = Py_BuildValue("(O)", data);
PyEval_CallObject(pyfunc,args);
}
This fails because data hasn't gone through swig, and isn't a PyObject.
I tried...
I've successfully created Ruby-C++ bindings in the past using SWIG where the C++ code was compiled as a dynamic library with the Ruby script connecting to it.
However, I'd like to do it the other way around. Create an executable using C++ and enable it to load and execute Ruby code. Ruby should be able to call functions defined on the C...
Hi,
I've got a library written in C++ which I wrap using SWIG and use in python. Generally there is one class with few methods. The problem is that calling these methods may be time consuming - they may hang my application (GIL is not released when calling these methods). So my question is:
what is the simplest way to release GIL for t...
I'm trying to write a SWIG wrapper for a C library that uses pointers to functions in its structs. I can't figure out how to handle structs that contain function pointers. A simplified example follows.
test.i:
/* test.i */
%module test
%{
typedef struct {
int (*my_func)(int);
} test_struct;
int add1(int n) { return n+1; }
tes...
I have multiple source files in C++ using which i want to create a Dynamic link library.
I see this happening in linux with gcc -shared and ln
however for Windows i suppose i would have to modify source files to generate a DLL.
Is there a way to generate DLL (a file similar to *.so in linux) with provided source files. Please correc...
I need to access LabWindows API and/or fucntions written in labwindows from Python.
My approach so far
I have been able to do so in Visual studio using SWIG to some extent, but my dll creation fails when i try to generate it in Labwindows using the source file and the SWIG generated wrapper file.
...
I have DLL, interface on C++ for work with he. In bcb, msvc it works fine. I want to use Python-scripts to access function in this library.
Generate python-package using Swig.
File setup.py
import distutils
from distutils.core import setup, Extension
setup(name = "DCM",
version = "1.3.2",
ext_modules = [Extension("_dcm", ...
Hi,
I made a class using wxwdigets
//wrapper over wxIPV4address
class IPV4addressLua : public wxIPV4address
{
public:
IPV4addressLua();
~IPV4addressLua();
bool SetService (const wxString &service);
bool SetService (unsigned short service);
unsigned short GetSer...
I have C header file containing the following type definition:
// example.h
typedef struct Vertex {
int color;
} Vertex;
I try to wrap this struct with SWIG, but apparently I am doing something wrong. My SWIG interface file looks like
// example.i
%module example
%inline %{
#include "example.h"
}
But if I copy the contents of my ...
I am using SWIG to wrap a C interface in Ruby. Given two structs
typedef struct Vertex {
int color, discoverd, finished;
struct Vertex *next;
} Vertex;
typedef struct Graph {
struct Vertex *vertex;
} Graph;
how can I create a #each method which yields the current vertex, so that I can process it in Ruby. Currently my SWIG inte...
SWIG compiles and install easily on AIX. Unfortunately, a simple SWIG hello world (which also compiles - but not so easily) crashes with Segmentation Fault or Illegal Instruction (depending on some details of the compilation/linker process). This happens with both gcc and xlc (IBM c compiler). I tried only the native AIX linker ld, becau...
Hello,
I made some bindings from my C++ app for python.
The problem is that I use pointers to members (It's for computing shortest path and giving the property to minimize as parameter).
This is the C++ signature:
std::vector<Path> martins(int start, int dest, MultimodalGraph & g, float Edge::*)
This is what I did (from what I unde...
I have a C function that takes FILE* as an argument and I'd like to use this function in Lua, passing Lua file. I guess I need a %typemap for this. How to write it?
(I just started learning Lua).
...
I have some C++ I have exposed to Python through SWIG. In there is a base class with a single pure virtual function.
In Python, I import my module and define a class that uses the abstract class as base.
import mymodule
class Foo(mymodule.mybase):
...
In that module is also a manager class, I want to add my new defined class to t...
Would it be possible using Lua and SWIG and say an IInterface class, to implement that interface and instantiate it all within Lua? If so how would it be done?
...
I'm sketching on some fluid dynamics in Python. After a while, I'm looking for a bit more speed, so I rewrote the actual logic in C and put up some Python bindings (using SWIG).
My problem now is that I don't how to render it in a good way. The logic is run pixel by pixel so pixels are what I want to track and render.
Python gives my a...
Currently I know how to have C++ objects instantiated and passed around in Lua using SWIG bindings, what I need is the reverse.
I am using Lua & C++ & SWIG.
I have interfaces in C++ and objects in lua, that implement methods which do the same job and have the same structure. I would like to be able to instantiate these objects in lua y...
Anything I link to gtkglext using SWIG crashes Python on exit. Why does this crash?
test.i:
%module test
%{
void test() { printf("Test.\n"); }
%}
void test();
Session:
$ swig -python test.i
$ g++ -I/usr/include/python2.6 -shared -fPIC -o _test.so test_wrap.c -lpython2.6
$ python -c 'import test; test.test()'
Test.
$ g++ -I/usr/i...
I have for example, a Lua table/object:
bannana
And this Lua table has a function inside it called chew, that takes a parameter
bannana.chew(5)
I have also used SWIG, and have for example a class CPerson:
class CPerson {
public:
// ....
void Eat();
// ....
};
I can obtain an instance of this object fr...