Hi,
So I'm almost done. Now I have working code which calls python callback function.
Only thing I need now is how to pass argument to the python callback function.
My callback.c is:
#include <stdio.h>
typedef void (*CALLBACK)(void);
CALLBACK my_callback = 0;
void set_callback(CALLBACK c);
void test(void);
void set_callback(CALLBA...
I have digging through the C# code generated by SWIG for Quantlib and came across the following code that gave me a humbling moment.
Each of the generated classes implement IDisposable, and each of the generated classes have this convention pointed out below.
public class MultiPath : IDisposable { // MultiPath is interchangable
priv...
I'm trying to build a C++ extension for python using swig. I've followed the instructions below and the others to a T and can't seem to get my extension to load.
I ran across this article on the MinGW site under "How do I create Python extensions?"
http://www.mingw.org/wiki/FAQ
I also found these tutorials:
http://boodebr.org/main/p...
Hi,
I'm trying to wrap a C++ library which uses auto_ptr. I'm using swig
and want to generate python bindings. I'v seen the section of the swig docu on how to use swig with smart pointers here[0]. But I can't get it to work.
swig generates code that wants to initialize the auto_ptr using a const
reference, but auto_ptr defines the cop...
I use swig 2.0.1 + mono 2.6/2.8 on Mac OS X 10.6.4.
The overall build is OK, and the build of the C# examples is also OK. The problem is that when I run the example (mono runme.exe), I always get the following errors.
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for example...
I asked about an error for running Swig examples on mono 2.8 here.
Adding "-arch i386" solved the issue with simple example, but when I tried to run the other examples, I got the following error, for example, with Examples/csharp/variables :
Unhandled Exception: System.EntryPointNotFoundException: CSharp_ivar_set
at (wrapper manage...
Hey gang, so I've written a swig wrapper for some C code. I'm trying to bridge the gap between scipy arrays and C arrays, which I know is messy. After a clean compilation (well...not including some warnings...) I'm getting this issue when I load the python-swig-c module:
undefined symbol: PyArray_TYPE
I've added my swig interface file...
The problem: I've wrapped some c++ code in python using SWIG. On the python side, I want to take a wrapped c++ pointer and down-cast it to be a pointer to a subclass. I've added a new c++ function to the SWIG .i file that does this down-casting, but when I call it from python, I get a TypeError.
Here are the details:
I have two c++ cl...
hello, i am able to get xapian working as expected with python on my development server but i am having issues with my web server.
i keep running into this error:
import xapian
Traceback (most recent call last):
File "", line 1, in
File "/home/x/lib/python2.6/xapian/init.py", line 28, in
...
Hi, I have a sinatra web application and a C++ library that I can 'require' in sinatra (ruby) using bindings created by swig.
I also have a second -very similar- library, in which the function names are partially the same as in the first one. When I require them both, the one that is loaded first 'wins', i.e. calls to the ambiguous fun...
Hi,
I'm wrapping C++ code into Python and .NET code by using SWIG 2.0.0.
I'm able to wrap a (myClass*, std::string) by introducing the following sentence in the "interface.i" file:
%template(Dictionary_myClass_String) std::map<myClass*, std::string>;
But I'm getting several errors if i try this:
%template(Dictionary_myClass_myClass)...
Environment : C++, Python, SWIG
Problem :
C++ : I have different shared library(.so) files which share common base class.
SWIG: I can have a wrapper for each .so file & can use corresponding .py in python module. But, this makes lot of interface files & also lot of import statements in python.
Expected: I would like to have best poss...
This is about embedded python using swig.
I have an std::map exposed to python (embedded python). When the script is executed, swig spits out the below "warning" at the end (when the map goes out of scope - I guess):
swig/python detected a memory leak of type 'std::map< MyEnum, std::string> ... no destructor found
The .i file is:
en...
What is the best way to avoid name clashes in SWIG generated functions?
I have two different C++ classes with partially identical function names. When I call such a function on an object, given both classes are loaded in the target language, it seems related to which library was loaded first, which function gets actually executed. It ha...
My application is using SWIG to communicate between c++ and python on windows.
suppose if my interface is "example.h"
swig is generating example.py, example_wrap.cxx
/* File : example.i */
%module example
%{
#include "example.h"
%}
%include "std_string.i"
%include "std_wstring.i"
%include "example.h"
I am porting my application ...
I've got class A wrapped with method foo implemented using %extend:
class A {
...
%extend {
void foo()
{
self->foo_impl();
}
}
Now I want to increase ref count to an A inside foo_impl, but I only got A* (as self).
Question: how can I write/wrap function foo, so that I have an access both to A* and underlying PyObject*...
I'm trying to compile Box2D for use in C# with SWIG.
I've created this Box2D.i file,
%module Box2D
%{
#include "Box2D/Box2D.h"
%}
%include "Box2D/Box2D.h"
Which I placed one level up from the Box2D.h file file, and "compiled" it with,
swig.exe -csharp -c++ -includeall -ignoremissing -outdir SWIG Box2d.i
This gives me all the .cs ...
I am receiving the following error when trying to price a 20x10 swap from a bootstrapped curve. The error get thrown on the last line of the ImpliedRate function
SwapRatesServiceTests.ImpliedRate_ForTwenty_x_TenYearSwap_ReturnsRate:
System.ApplicationException : 2nd leg: empty Handle cannot be dereferenced
I don't have the faint...
Is there any reason for a class declaration to inherit object?
I just found some code that does this and I can't find a good reason why.
class MyClass(object):
# class code follows...
The code is using swig for binding some C code to Python, if that's relevant.
...
I have wrapped some C code using SWIG to use it as a python library.
Within this framework, some python code I have written calls a C function, which returns a string. However, for creating the string, the C function requires a ranking, the generation of which I have implemented in Python. How would I go about implementing this using ca...