swig

How to get python slicing to work with my c++ array class using SWIG

六眼飞鱼酱① 提交于 2019-12-11 12:13:43
问题 I have an an array class, Array1D, defined in c++ which essentially wraps the STL vector class. I extended this class so that I can display individual elements of the array vector. Here is the relevant code in my SWIG interface file: namespace std{ %template(dblVector) vector<double>; } %extend Array1D{ double __getitem__(int index) { return (*self)[index]; } } This allows me to access individual elements of the array in python: >>> a = Array1D(10) # creates a c++ vector of length 10 with

How to SWIG my entire c++ code base to Java

给你一囗甜甜゛ 提交于 2019-12-11 11:06:14
问题 I have used swig to do generate java bindings for independent classes. However when I tried to do it for my existing codebase which is quite complex, having calls for STL , OSG and OpenGL. When I am trying to swig it am getting issues. Here is my .i file /* File : Line.i */ %module Line %{ #include "Elements/LineFeatureObject.h" %} /* Let's just grab the original header file here */ %include "Elements/LineFeatureObject.h This headers includes several other headers files. Some of them are read

SWIG CYGWIN DLL linking

左心房为你撑大大i 提交于 2019-12-11 10:39:30
问题 I'm trying to follow the SWIG Java example located here. This example uses cygwin for compilation. I would like to pass the compiler an alredy compiled dll, test.dll, instead of a C source file. The SWIG.org example uses C source. I attempted to pass the test.dll(compiled C source) and then example.dll to the 3rd command but I get an error "test.dll: no such file or directory". The SWIG.org example's 3rd command creates the example.dll based on example.c. How can I create example.dll so that

Use SWIG to bind C unsigned char Pointer to Java ArrayList or Collection Structure

隐身守侯 提交于 2019-12-11 10:28:53
问题 If I have a C function (see below) that returns a unsigned char pointer to an array. How would you instruct SWIG to bind to the Java ArrayList data type for getFoo(). I'm not sure an ArrayList is possible, maybe an array (String[] in this case). I want to keep the Java return type of getFoo as generic as possible since the C getFoo may return an array of int, double, char..etc. unsigned char * getFoo(int32_t *length){ static unsigned char foo[44]; foo[0]='a'; foo[1]='b'; foo[2]='c'; foo[3]='d

[swig-JavaScript]is it support std::vector<std::string>* as a OUTPUT?

自古美人都是妖i 提交于 2019-12-11 09:59:38
问题 I use swig to write NodeJS's addon and encountered an error. is it support std::vector* as a OUTPUT? my *.i: %apply std::vector<std::string> *OUTPUT {std::vector<std::string>* result}; when I run swig: swig -javascript -node -c++ -DV8_VERSION=0x040599 export.i has error: export.i:19: Warning 453: Can't apply (std::vector< std::string > *OUTPUT). No typemaps are defined. I encountered an error at swig-javascript, but it works fine at swig-python. Anyone can help? thanks 回答1: Adding: %include

How to pass userdata from one Lua chunk to another in C++

∥☆過路亽.° 提交于 2019-12-11 08:02:58
问题 I'm trying to get userdata from a Lua script( chunk A ) in C++(through a returned variable from function in my example) and then, later pass this userdata back to Lua script( chunk B ) from C++(through a function argument in my example) so the userdata can be used in chunk B as it was in the chunk A . MyBindings.h class Vec2 { public: Vec2():x(0), y(0){}; Vec2(float x, float y):x(x), y(y){}; float x, y; }; MyBindings.i %module my %{ #include "MyBindings.h" %} %include "MyBindings.h" main.cpp

Wrapping C structs with SWIG

﹥>﹥吖頭↗ 提交于 2019-12-11 07:17:42
问题 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 header file into my interface file so that the latter looks like %module example %inline %{ typedef struct Vertex { int color; } Vertex; %} I can access the struct

SWIG function with pointer struct

◇◆丶佛笑我妖孽 提交于 2019-12-11 06:46:51
问题 Im new using SWIG to wrapped C shared library. I have problem to call a C function with Struct pointer in python. My files: ST_Param.h: typedef struct { unsigned int* device_Address; .... .... unsigned int lock; }ST_param_ST; unsigned char ST_Param_Initialize(ST_param_ST * ST_param, unsigned int device_Address); ST_Param.c ......... Rest of file............. unsigned char ST_Param_Initialize(ST_param_ST * ST_param, unsigned int device_Address){ if(ST_param == NULL){ .......... rest of funtion

Swig: convert return type std::string to java byte[]

99封情书 提交于 2019-12-11 06:45:16
问题 I have a C++ method that returns a std::string. I am using SWIG and I want to add logic to SWIG to make the std::string that is returned, be received in Java as a byte[]. If this is possible, how can I do this? Thanks 回答1: SWIG comes with pre-written interface files for many C++ constructs. The are found in SWIG's Lib directory for many languages, including Java. Add %include <std_string.i> in your SWIG interface file. Check SWIG's Lib/Java directory for support for other constructs as well.

problems installing M2Crypto on Mint

谁说我不能喝 提交于 2019-12-11 04:19:28
问题 I am trying to install M2Crypto for python on Mint 12. I have executed `python setup.py build, but the build fails, stating error: command 'gcc' failed with exit status 1 the preceding 2 lines show that there may be a problem with Python.h: SWIG/_m2crypto_wrap.c:126:20: fatal error: Python.h: No such file or directory compilation terminated If anyone knows what needs to be done to fix this, please let me know. EDIT I have attempted to install python-dev , but I get the following error: The