Hello everyone,
I am trying to write Python wrap for C code which uses struct.
modules.c:
struct foo
{
int a;
};
struct foo bar;
modulues.i
%module nepal
%{
struct foo
{
int a;
}
%}
extern struct foo bar;
But during compiling I am given error:
In function ‘Swig_var_bar_set’:
error: ‘bar’ undeclared (fi...
I am trying to wrap a c++ class (let's call it "Spam") written by someone else with swig to expose it to Python.
After solving several problems, I am able to import the module in python, but when I try to create an object of such class I obtain the following error:
foo = Spam.Spam('abc',3)
Traceback (most recent call last):
File "<st...
I am trying to wrap some legacy code for use in Java and I was quite happy to see that Swig was able to handle the header file and it generate a great wrapper that almost works. Now I am looking for the deep magic that will make it really work.
In C I have a function that looks like this
DLL_IMPORT int DustyVoodoo(char *buff, int len...
I have a class with a method called GetEnemiesLua. I have bound this class to lua using SWIG, and I can call this method using my lua code.
I am trying to get the method to return a lua table of objects.
Here is my current code:
void CGame::GetEnemiesLua(){
std::vector<Unit*> enemies = callback->GetEnemyUnits();
if( enemies.empty())...
Hello,
I've a problem with SWIG and python. I've a c-class that compiles correctly, but the python script says it can't find the module.
I compile with:
swig -c++ -python codes/codes.i
g++ -c -Wall -O4 -fPIC -pedantic codes/*.cc
g++ -I/usr/include/python2.6 -shared codes/codes_wrap.cxx *.o -o _codes.so
This gives me a _codes.so file...
I have used SWIG to bind a set of classes to lua. I know C++ itself doesn't support monkey patching, and I'm not trying to modify my C++ objects, merely their lua representations. The problem comes if I want to start monkey patching the lua tables and objects exported by SWIG, so that I can modify the API presented on the lua side.
e.g....
I am trying to pass data around the numpy and boost::ublas layers. I
have written an ultra thin wrapper because swig cannot parse ublas'
header correctly. The code is shown below
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/lexical_cast.hpp>
#include <algorithm>
#include <sstream>
#...
Hi everyone. I've been trying to create a SWIG wrapper for this tiny little C++ class for the better part of 3 hours with no success, so I was hoping one of you out there could lend me a small hand. I have the following class:
#include <stdio.h>
class Example {
public:
Example();
~Example();
int test();
};
#include "exam...
Hi!
We're using some C library in our Java project. Several years ago some other developer which has retired few years ago (as always) has created all the wrappers for us. The wrappers were generated by the swig, but the interface file is lost now.
The basic idea of library and the wrappers for it is following:
There only one function...
I want to use swig for generation of read-only wrappers for a complex object. The object which I want to wrap will always be existent while I will read it. And also I will only use my wrappers at the time that object is existent, thus I don't need any memory management from SWIG.
For following swig interface:
%module test
%immutable;
...
Our C++ lib works fine with Python2.4 using Swig, returning a C++ char* back to a python str. But this solution hit problem in Python3.0, error is:
Exception=(, UnicodeDecodeError('utf8', b"\xb6\x9d\xa.....",0, 1, 'unexpected code byte')
Our definition is like(working fine in Python 2.4):
void cGetPubModulus(
void* pSslRsa,
ch...
I am trying to wrap a native C++ library using swig, and I am stuck at trying to convert time_t in C, to long in Java. I have successfully used swig with python, but so far I am unable to get the above typemap to work in Java.
In python it looks like this
%typemap(in) time_t
{
if (PyLong_Check($input))
$1 = (time_t) PyLong_...
Hello,
my task is to create dual program. At the beginning I start C program that calls throught C/C++ API of Python some Python method. The called method after that call a function that is created with SWIG. I show you my sample also with backtrace from gdb after I am given Segmentation fault.
main.c:
#include <Python.h>
#include <s...
I am using swig-lua. I have a function in Lua which I call and it returns me a pointer (userdata). right now I know what this pointer is, but how can I tell Lua from within Lua?
...
I am concreting a question I had earlier.
I have two classes in C++ and I use SWIG to wrap them. A method in one class can return a pointer to the other class. How can I get Lua to see it as more than just a userdata?
More concretely:
I have
class fruit
{
int numberofseeds;
//some other stuff about fruit constructors etc...
...
We've got an interface we've defined in C++ (abstract class, all functions pure virtual) which will be extended in Python. To overcome the cross-language polymorphism issues we're planning on using SWIG directors. I've read how to catch exceptions thrown from C++ code in our Python code here, here, here, and even on SO.
It's fairly st...
I came across this error trying to compile a shared object from 2 sets of objects. The first set contains one .os object compiled from one cpp file generated by SWIG. The second set is contains all of the .so files from the individual files that make up the interface to be wrapped.
$g++ -shared *.os -o Mathlibmodule.so
ld: duplicate...
I'd like to use some existing C++ code, NvTriStrip, in a Python tool.
SWIG easily handles the functions with simple parameters, but the main function, GenerateStrips, is much more complicated.
What do I need to put in the SWIG interface file to indicate that primGroups is really an output parameter and that it must be cleaned up with d...
Here's what I take to be a pretty standard header for a list. Because the struct
points to itself, we need this two-part declaration. Call it listicle.h:
typedef struct _listicle listicle;
struct _listicle{
int i;
listicle *next;
};
I'm trying to get swig to wrap this, so that the Python user can make use of the listicle
...
I am writing a C/C++ extension module for other languages and I am using SWIG to generate the bindings.
I have two questions
Can I include more than 1 header file in the declaration part of the interface file e.g.:
/* Declarations exposed to wrapper: */
> %{
> #define SWIG_FILE_WITH_INIT
> #include "a.h"
> #include "b.h"
> #include ...