swig

using stdint with swig and numpy.i

谁都会走 提交于 2019-12-22 10:57:17
问题 I'm developing a module for using c inline in Python code based on swig . For that I would like to make numpy arrays accessible in C . Until now I used C types like unsigned short but I would like to use types like uint16_t from stdint.h to be save whatever compiler my module encounters. Unfortunately the c++ -functions do not get wrapped correctly when using stdint.h types. The Error given is: _setc() takes exactly 2 arguments (1 given) . That means, the function is not wrapped to accept

Generate a perl module with a separate namespace using SWIG

徘徊边缘 提交于 2019-12-22 08:52:27
问题 I need to generate a perl module Vinod::StatHandler. I have 2 files related to c++ code.(statHandler.h,statHandler.cpp) Currently I am using the following command to generate the module. swig -perl -noproxy -c++ -o StatHandler_wrap.cxx StatHandler.i It generated the module StatHandler.pm I generated the .so file using the following commands. g++ -c statHandler.h statHandler.cpp -fPIC g++ -O2 -shared -o StatHandler.so statHandler.o I got the following error by just including "use StatHandler;"

Accessing an array of pointers within a structure from Java with SWIG

北城以北 提交于 2019-12-22 05:16:27
问题 I've something like this: typedef struct { char * content; } Boo; typedef struct { Boo **data; int size; } Foo; I want to convert Boo ** data to an array with Boo elements ( Boo[] ) in Java with SWIG. And then to read the array (I don't want to edit,delete and create a new array from Java code). In the SWIG documentation is described how to do this with carrays.i and array_functions , but the struct's member data must be of type Boo* . Is there a solution of my problem? EDIT: I've hurried and

Is it possible to split a SWIG module for compilation, but rejoin it when linking?

醉酒当歌 提交于 2019-12-22 04:36:37
问题 I hit this issue about two years ago when I first implemented our SWIG bindings. As soon as we exposed a large amount of code we got to the point where SWIG would output C++ files so large the compiler could not handle them. The only way I could get around the issue was to split up the interfaces into multiple modules and to compile them separately. This has several downsides: • Each module must know about dependencies in other modules. I have a script to generate the interface files which

SWIG: getters/setters for an array of struct don't return/expect an array of proxy class in Java

我的梦境 提交于 2019-12-22 00:25:46
问题 I try to generate an adequate interface for Java of a C++ interface with help of SWIG. In general it works quite nice, but now I have a problem with an (bound) array of structs. I have following two structures: typedef struct { char* street; char* city; } Address; typedef struct { char* firstname; char* lastname; Address addresses[4]; } Person; The getters and setters for addresses field of Person struct is: public Address getAddresses() { /*...*/ } public void setAddresses(Address value) { /

UnsatisfiedLinkError While Calling Native Method from OSGi Bundle

╄→尐↘猪︶ㄣ 提交于 2019-12-21 23:56:42
问题 I have created one OSGi plugin (Bundle) using eclipse File-->New-->Other-->Plug-in Project called plugin 1. I want to use a native .so library in this plugin. I have added libtest_app_wrap1.so at the root of my plugin project. my project structure looks like below And here is the manifest file Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: JniTest Bundle-SymbolicName: JniTest Bundle-Version: 1.0.0.qualifier Bundle-Activator: jnitest.Activator Bundle-RequiredExecutionEnvironment:

Swig c++ w/ Java loses type on polymorphic callback functions [duplicate]

Deadly 提交于 2019-12-21 20:44:24
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: SWIG Java Retaining Class information of the objects bouncing from C++ Question : Why is my C++ swigged object losing its type when passed to a Java callback function? Setup : I've taken the Swig Java example for doing callbacks and added an object to be passed to the callback run(Parent p) . The callback works as expected but when I pass a Child object the Java seems to lose its type and think its of type

(Swig to python) import error:dynamic module does not define init function

[亡魂溺海] 提交于 2019-12-21 17:32:06
问题 I am trying to port my c++ code to python by swig. When I finish building the py, pyd, cxx and lib files, under Python (command line), I key in "module Dnld", it shows-> import error:dynamic module does not define init function . The following is my code, Further: Add my build step to avoid misunderstanding, thank you Mark Tolonen File->New->Project->Windows Console Application-> Select DLL and empty project(no unicode) Add my SerialComm folder to the project(include DownloaderEngine.h Serial

Return vector<pair<int,int>> & from c++ method to python list of tuples using swig typemap

半世苍凉 提交于 2019-12-21 17:02:45
问题 I'm having a lot of troubles trying to wrap a c++ method that returns a constant reference to a vector of pairs to a Python list of tuples using %typemap(out) . I currently have something like this: myclass.h: #inlcude <vector> using std::vector; class MyClass { private: const vector<pair<int,int>> & _myvector; public: MyClass(const vector<pair<int,int>> & myvector ); const vector<pair<int,int>> & GetMyVector() const; } myclass.cpp: #include "myclass.h" MyClass::MyClass(const vector<pair<int

Passing Java Map<String, String> to C++ method using SWIG

天涯浪子 提交于 2019-12-21 13:26:43
问题 I have a method defined in C++: std::map<std::string, std::string> validate( std::map<std::string, std::string> key, std::map<std::string, std::string> value ); I want to consume this method in Java. So, I have to write a wrapper using Swig through which I will be able to pass Java Map as STL map to the c++ method. Please let me know how should I define the .i file for swig to make this work. 回答1: In order to do this you'll need to tell SWIG to use java.util.Map for the input argument, using