swig

On the fly font coloring in Tclsh via c++

Hello people! I am an amateur try to hack together a little project. It is a simple note storage and retrieval console app on Windows Vista (and XP - i'm hoping to run the whole thing off a USB Stick). I use Sqlite as the store and Tcl/SQL scripts to add notes (and tags!) and also retrieve them by tag. 3 tables and a "Toxi" schema. ...

Cross-compiling python extensions under Linux using distutils

Hello, everybody! Is there any way to compile both Windows and Linux versions of Python/distutils/SWIG/C++ extensions under Linux? As far as I understand the problem is at least in obtaining windows version of python-dev. Thank you. ...

GCC not recognising standard header files when using swig and distutils

I'm trying to generate a python wrapper for a C++ library that I am putting together. I have just come across SWIG and am trying to use this in conjunction with distutils. I'm modifying someone elses code, so odd errors were to be expected but this one is just confusing. I've managed to generate a c++ wrapper file with SWIG and am now a...

numpy arrays type conversion in C

Hi, I would like to convert the numpy double array to numpy float array in C(Swig). I am trying to use PyObject *object = PyArray_FROM_OT(input,NPY_FLOAT) or PyObject *object = PyArray_FROMANY(input,NPY_FLOAT,0,0,NPY_DEFAULT) or PyObject *object = PyArray_FromObject(input,NPY_FLOAT,0,0) or PyObject *object = PyArray_Contiguou...

Shared pointers and building in SIP4 (was: Dynamic casting in SWIG/python?)

So I'm playing about with Python, C++0x, and SWIG 2.0. I've got a header that looks like this: #include <string> #include <iostream> #include <memory> using namespace std; struct Base { virtual string name(); int foo; shared_ptr<Base> mine; Base(int); virtual ~Base() {} virtual void doit(shared_ptr<Base> b) { cout << ...

SWIG Python bindings to native code not working with OpenCV 2.1

I have an OpenCV project mixing Python and C. After changing to OpenCV 2.1, my calls to C code are not working any more, probably because OpenCV is no more using SWIG bindings. From Python, I was used to call a C function with the following prototype: int fast_support_transform(CvMat * I, CvMat * N,...); Now, I get the following err...

stdout from SWIG-generated PHP extension

I have the following C++ function: void foo() { std::cout << "bar" << std::endl; } I'm porting this to PHP via SWIG. Everything compiles fine and the extension loads properly. I'm able to call foo() from PHP, but I only see the bar output if I run the PHP script from the command line. $ php script.php bar If I load the script i...

Wrapping boost::shared_ptr in PHP using SWIG

If I use SWIG to wrap this C++ function: boost::shared_ptr<Client> Client::create() { return boost::shared_ptr<Client>(new Client()); } And then call it in PHP: $client = Client::create(); echo gettype($client); The type of $client is resource, not object, and so I cannot call Client methods. What are my options for wrapping t...

Does a function type "extern __declspec(dllimport) INT __cdecl" makes sense in C/C++ or SWIG?

I am trying to wrap a DLL, using its header file, through SWIG. I got a syntax error while processing my interface .i file using SWIG. After tracking down what was the offending line (line number of the printed by SWIG error message did not match the true offending line), I found that the minimum non-processable SWIG interface file is: ...

Calling a Python function in C++ with Swig

Here is my c++ code: void callMethod(void (*someMethod)()) { (*someMethod)(); } My Swig .i file is: %module test %{ #define SWIG_FILE_WITH_INIT extern void callMethod(void (*someMethod)()); %} %typemap (in) void* %{ $1 = PyCObject_AsVoidPtr($input); %} extern void callMethod(void (*someMethod)()); Here is my error: In ...

Problem with SWIG generated JNI code on Android

I want to generate JNI wrappers from C/C++ code. Here is my interface file. /* aes_security.i */ %module jni_security_example %{ #include "pbkdf2.h" %} extern int pbkdf2_sha1 (const char *passphrase, size_t passphraseLength, const char *SSID, size_t SSIDlen, unsigned int iterationCount, char *aeskey, size_t ke...

Compiling Quantlib via SWIG for C#

Anyone have any experience using SWIG ? I am currently researching QuantLib and saw that C# code can be generated using SWIG. We are exploring options to create a combined library of financial functions using QuantLib and a proprietary closed source library (which will probably be made available as .Net dlls). The idea is to combine bot...

Integrating plug-ins of different languages in a framework

I am novel software guy so I have little experience with software design. I have a question to ask: suppose I create a extensible software application with a plug in architecture, so that new applications can be integrated in this tool. If a new application is written in a different language and needs to be integrated in this application...

How can I define a typemap for SWIG, that converts a reference argument from C++ to C#

I have a C++ library which provides the following enum and function: typedef enum en{ a, b }myEnum; int myFunction( myEnum &varToSet ) { varToSet = 1; return 0; } The function in the C# Wrapper should look something like this: public static int myFunction( ref myEnum varToSet ) I have tried to get this result by following ...

Multiple C++ .lib projects to .dll projects, Lua crashes!

Hello, Today I've tried to get Edit & Continue to work in my solution, which looks like this: Game Engine .lib <- Game .lib <- Editor .exe <- Server .exe <- Client .exe Which works nicely. But now I wanted to turn the engine and game .libs into .dlls, so I can use the Edit & Continue ...

using SWIG with C++

HI all I am trying to use SWIG to export C++ code to Python. The C sample I read on the web site does work but I have problem with C++ code. Here are the lines I call swig -c++ -python SWIG_TEST.i g++ -c -fPIC SWIG_TEST.cpp SWIG_TEST_wrap.cxx -I/usr/include/python2.4/ gcc --shared SWIG_TEST.o SWIG_TEST_wrap.o -o _SWIG_TEST.so -lstdc+...

Memory leak from SWIG-generated extension

I'm having a memory leak problem wrapping a C++ library in PHP using SWIG. It seems to happen when callbacks from C++ containing complex types are sent to PHP while directors are enabled. Here is a standalone example to reproduce the leak: Client.hpp: #ifndef CLIENT_HPP_ #define CLIENT_HPP_ #include <vector> #include "ProcedureCallbac...

Dynamic linking and Python SWIG (C++) works in C++ fails in python

I have a library for which I have created a python wrapper using SWIG. The library itself accepts user provided functions which are in an .so file that is dynamically linked. At the moment I'm dealing with one that I have created myself and have managed to get the dynamic linking working... in C++. When I attempt to run it in python I ge...

SWIG2 template return type namespace not detected

Hi there. I'm swigging to Java. I'm trying to get a templated member func to use some templated return type, which i have to give a name of course (since otherwise SWIG would not create the needed source). test.i is like: %module Test %{ #include <vector> namespace ns { class C { public: template <class T> void doit(con...

Python: convert swig object...

I am using SWIG to create a Python wrapper around a piece of C++ code which returns an object like this: TH1F*GetHist(); (The class TH1F has not been written by me.) Now under Python this results in an <Swig Object of type 'TH1F *' at 0x12da820> My problem is that I would like to use methods of this object which SWIG does not know ...