swig

No iterator for Java when using SWIG with C++'s std::map

感情迁移 提交于 2019-12-05 21:40:35
问题 I have implemented a class with std::map in C++ and created interface using SWIG to be call from Java. However there is no iterator object that allows me to iterate through the entries in the SWIG wrapped std::map . Does anyone know how to create an iterator? 回答1: In order to be able to iterate over an Object in Java it needs to implement Iterable . This in turn requires a member function called iterator() which returns a suitable implementation of an Iterator . From your question it's not

Swig: pass byte array in Java to C

大城市里の小女人 提交于 2019-12-05 20:26:14
I am trying to create Java implementation for passing byte [] to C using Swig. Swig: %include "typemaps.i" %apply(char *STRING, int LENGTH) { (char *buff, int len) }; %inline { typedef struct { char* buff; int len; } workit_t; } In my generated java class (workit_t.java), the parameter buff is a String, instead of a byte []. Java: public void setBuff(String value){ ... } What am I doing wrong in my swig definition? When I write a simple swig definition with no struct, I get the desired type of parameter. Swig: %include "typemaps.i" %apply(char *STRING, int LENGTH) { (char *buff1, int *len1) };

brew install geos

江枫思渺然 提交于 2019-12-05 19:18:09
geo3.8 导致py2中 geodjango不可用 django 报错,不能解析版本 File "/Users/huoyinghui/gitlab/ange/venv/lib/python2.7/site-packages/django/contrib/gis/geos/__init__.py", line 18, in <module> HAS_GEOS = geos_version_info()['version'] >= '3.3.0' File "/Users/huoyinghui/gitlab/ange/venv/lib/python2.7/site-packages/django/contrib/gis/geos/libgeos.py", line 191, in geos_version_info raise GEOSException('Could not parse version info string "%s"' % ver) django.contrib.gis.geos.error.GEOSException: Could not parse version info string "3.8.0-CAPI-1.13.1 " 参考 安装geos ➜ ~ brew unlink geos Unlinking /usr/local/Cellar/geos/3

using stdint with swig and numpy.i

删除回忆录丶 提交于 2019-12-05 19:05:57
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 numpy arrays. The error does not occur, when I use e.g. unsigned short . Do you have any ideas, how I can

__str__() not called when printing C++ class wrapped for Python with SWIG

给你一囗甜甜゛ 提交于 2019-12-05 18:02:18
I'm trying to print C++ classes that I wrapped for Python using SWIG. I have followed the documentation and this question: How to stringfy a swig matrix object in python The extended __str__ function is there, but it isn't called when I print the object from Python. Let me give a minimal example: TestClass.h #include <iostream> class TestClass{ private: int my_int; public: TestClass(): my_int(0) {} friend std::ostream& operator<< (std::ostream& o, TestClass const& t){ o<< "TestClass: " << t.my_int; return o; } }; TestClass.cpp #include "TestClass.h" int main(){ using namespace std; TestClass t

Convert a member of structure of type signed char * to byte array in Java (byte[]) using SWIG

假装没事ソ 提交于 2019-12-05 17:01:40
I'm trying to convert a member of structure of type signed char * to byte array in Java. I've the following structure: typedef struct { signed char * content; int contentLength; } Foo; I've tried this: %typemap(jni) signed char *content [ANY] "jbyteArray" %typemap(jtype) signed char *content [ANY] "byte[]" %typemap(jstype) signed char *content [ANY] "byte[]" %typemap(javaout) signed char *content [ANY] { return $jnicall; } %typemap(memberin) int contentLength [ANY] { int length=0; $1 = &length; } %typemap(out) signed char * content [ANY] { $result = JCALL1(NewByteArray, jenv, length); JCALL4

SWIG: difference between %import and %include

送分小仙女□ 提交于 2019-12-05 16:30:16
问题 The SWIG docs explain these two directives as follows: %include : "To include another file into a SWIG interface, use the %include directive ... Unlike, #include , %include includes each file once (and will not reload the file on subsequent %include declarations). Therefore, it is not necessary to use include-guards in SWIG interfaces." %import : "SWIG provides another file inclusion directive with the %import directive ... The purpose of %import is to collect certain information from another

How to embed lua in c++ via SWIG

自古美人都是妖i 提交于 2019-12-05 16:05:00
Currently I have a set of SWIG wrappers for my classes and it all builds. I can create a lua virtual machine and load my wrappers, but at that point I'm flummoxed. Googling tells me how to shove put c++ in lua in swig, but not how to put lua in c++. Really all I want to do is manage to instantiate a lua object and pass it my main game engine object pointer, from there I can manage Take a look at the Programming in Lua book, it has a section on the Lua C API . For calling Lua functions use lua_pcall , which is equivalent to lua_call (that has a short example) except it will catch Lua runtime

SWIG Python undefined symbol error

帅比萌擦擦* 提交于 2019-12-05 15:05:49
I'm trying to create a *.so file for further use in Python using SWIG, but something isn't working. I have two files: DataGatherer.h #include <iostream> #include <stdlib.h> #include <time.h> #include "gnublin.h" #include <pthread.h> class dataGatherer { private: int threshold; int timeThreshold; int data[4096]; bool running; gnublin_spi* spiDevice; pthread_t spiThread; void *params; public: dataGatherer(void); dataGatherer(int, int); void initData(); int getThreshold(void); int* getData(void); int getPeak(void); void initSPI(void); void gatherData(); void * run(void * arg); void stop(void); //

Swig python - c++ how to use type int8_t

邮差的信 提交于 2019-12-05 13:51:26
问题 I have a C function that takes as paramenter an 8 bit integer int8_t foo( int8_t x ); I would like to call this function from my python code using a swig interface but int8_t type do not exists in python. In order to have this kind of types exists a python module called numpy. Even using this yet I do not manage to make the 2 comunicating. Do you know if there is any way of defining such a type in the SWIG interfacve in order to be able to use it from python?? int8_t is just an example... i