swig

Swig error with Nested enums in C++

会有一股神秘感。 提交于 2019-12-23 03:37:13
问题 I have a class similar to the following. It has a nested enum OptionTag. class MediaPacket { public: struct RtcpAppName { char mName[RTCP_APPNAME_LENGTH]; }; enum OptionTag { RESERVED = 0, PROFILE = 1, LATENCY = 2, PKTLOSS = 3, JITTER = 4, LEGACYMIX = 5, LASTTAG = 255 }; .... .... list<OptionTag> GetOptions(unsigned int ssrc) const; }; For this I created a swig interface as follows %module mediaopts_packet %include "stdint.i" //Redefining nested structure in swig struct RtcpAppName { char

SWIG %ignore doesn't match template with typedef

。_饼干妹妹 提交于 2019-12-23 02:07:07
问题 I have a templated Vector (as in a mathematical vector, not a std::vector) class which can be instantiated with a size between 2 and 4. The definition is something like: template <uint32_t Size, typename StorageType> class Vector { public: Vector(StorageType x, StorageType y); Vector(StorageType x, StorageType y, StorageType z); Vector(StorageType x, StorageType y, StorageType z, StorageType w); ... }; In my SWIG file, I want to wrap a version which has a Size of 3 and a StorageType of int8_t

SWIG typedef recognition

℡╲_俬逩灬. 提交于 2019-12-23 02:01:43
问题 I am trying too use my C++ class in PHP. in my C++ code I have declared the typedef as: typedef unsigned char byte; so I intended to let SWIG consider my typedef in wrapper class, my interface file is something like this: %module xxx typedef unsigned char byte; %include "xxx.h" .... %{ typedef unsigned char byte; #include "xxx.h" %} and in my test code I refer to type as: byte *data; but I've got the following error: Fatal error: Class 'unsigned_char' not found in xxx.php P.S: I also include

Wrap std::vector of std::vectors, C++ SWIG Python

99封情书 提交于 2019-12-22 18:47:24
问题 I want to wrap a C++ vector of vectors to Python code by using SWIG. Is it possible to wrap this type of vector of vectors? std::vector<std::vector<MyClass*>>; In the interface file MyApplication.i I added these lines: %include "std_vector.i" %{ #include <vector> %} namespace std { %template(VectorOfStructVector) vector<vector<MyClass*>>; } But, I'm getting an Error when SWIG is executed. I'm able to wrap this type (using reference to the vector): std::vector<std::vector<MyClass*>*>; But, it

Extending Numpy with C function

依然范特西╮ 提交于 2019-12-22 17:54:51
问题 I am trying to speed up my Numpy code and decided that I wanted to implement one particular function where my code spent most of the time in C. I'm actually a rookie in C, but I managed to write the function which normalizes every row in a matrix to sum to 1. I can compile it and I tested it with some data (in C) and it does what I want. At that point I was very proud of myself. Now I'm trying to call my glorious function from Python where it should accept a 2d-Numpy array. The various things

nested structure array access in python using SWIG

本小妞迷上赌 提交于 2019-12-22 17:54:46
问题 I haven't been able to figure out how to access the array elements SubStatus in the following nested structure. I do seem to be able to see the first element, but don't understand how to force indexing, e.g., as a list. Any help is much appreciated. status.h: // Data Types typedef char CHAR; // 8 bits signed typedef short SHORT; // 16 bits signed typedef long LONG; // 32 bits signed typedef unsigned char UCHAR; // 8 bits unsigned typedef unsigned short USHORT; // 16 bits usigned #define FUNC

Extending Numpy with C function

别说谁变了你拦得住时间么 提交于 2019-12-22 17:53:31
问题 I am trying to speed up my Numpy code and decided that I wanted to implement one particular function where my code spent most of the time in C. I'm actually a rookie in C, but I managed to write the function which normalizes every row in a matrix to sum to 1. I can compile it and I tested it with some data (in C) and it does what I want. At that point I was very proud of myself. Now I'm trying to call my glorious function from Python where it should accept a 2d-Numpy array. The various things

SWIGTYPE_p_p_ : a Pointer on a Pointer on a Structure ( From C/C++ to Java )

折月煮酒 提交于 2019-12-22 17:48:09
问题 I'm using Swig to generate Java classes. I need to deal with a pointer on a pointer on a structure . I have this structure : struct Model { uint32_t serial; } And I have a function in the C/C++ that needs to be wrapped : void getModel( Model ** model ){ // instructions... } I get as a result this Java class : public class SWIGTYPE_p_p_Model { private long swigCPtr; protected SWIGTYPE_p_p_Model(long cPtr, boolean futureUse) { swigCPtr = cPtr; } protected SWIGTYPE_p_p_Model() { swigCPtr = 0; }

SWIG: How to pass list of complex from c++ to python

早过忘川 提交于 2019-12-22 12:09:33
问题 I have a function in c++ who returns a list of complex: #include <complex> std::list< std::complex<double> > func(...); what should i do in the '*.i' file ? Thank you every body. ================= Following are details: the function i would like to use in python in x.h: std::list<std::complex<double> > roots1(const double& d, const double& e); I have tried some ways: (1) x.i: %include <std_list.i> %include <std_complex.i> than I try in IPython: tmp = x.roots1(1.0, 2.0) len(tmp) and I got: ---

how to investigate python2 segfault on imp.load_module

廉价感情. 提交于 2019-12-22 12:08:11
问题 I am trying to install and use dolfin on Arch Linux, with Python 2.7.3. What is the best way to find out what is causing segmentation faults such as these? $ python2 -c "import dolfin; print dolfin.__version__" [3] 6491 segmentation fault (core dumped) python2 -c "import dolfin; print dolfin.__version__" I have tried inspecting the core file through gdb: $ sudo systemd-coredumpctl gdb 6491 but they are always truncated: Reading symbols from /usr/bin/python2.7...(no debugging symbols found)..