swig

Read swig python 'double *' object into numpy (maybe through ctypes?)

拈花ヽ惹草 提交于 2020-01-13 19:17:07
问题 I have swig python library that I can't modify. It returns a <Swig object of type 'double *'> which I know is a pointer to an array of doubles. Through a separate function, I get a python int for the length. My question is, how can I read this data into numpy? I've found the numpy.ndarray.ctypes module, and another stackoverflow answer that hints that a conversion from SWIG to ctypes is possible (https://stackoverflow.com/a/41212424/654602) but makes no mention how. Any help is appreciated.

swig no module named _example

喜你入骨 提交于 2020-01-12 07:42:48
问题 I cannot reproduce the basic SWIG example on windows. My error is stated in the SWIG docs and I am sure that I do the 2 fixes they mention. For this error: >>> import example Traceback (most recent call last): File "<stdin>", line 1, in ? File "example.py", line 2, in ? import _example ImportError: No module named _example the SWIG documentation clearly states: forget the leading underscore (_). forget the leading underscore (_).> If you get this message, it means that you either forgot to

swig no matching function for overloaded

╄→гoц情女王★ 提交于 2020-01-11 07:34:10
问题 I have a problem in wrapping my c++ code in PHP with SWIG: I have a class in C++ with method which is declared as below: int hexDump(string &dmpstr,bool space=true)const; also I include std_string.i in my interface file and I can pass string arguments well. but when I call my method in my PHP code as below: $bf->hexDump('12',true); I got this error: Fatal error: No matching function for overloaded 'PKI_Buf_hexDump' PKI_Buf is the name of my class. any idea?? 回答1: The problem here seems to be

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

♀尐吖头ヾ 提交于 2020-01-11 06:05:47
问题 My situation is that i have a C++ class (MyClass) with a method that has the following signature: bool getSerialized(const stdString & name, std::string & serialized); Where name is a in argument and serialized is an out argument. I got it working by making a %extend and %ignore declarations in the 'i' file as follows: %extend MyClass{ std::string getSerialized(const std::string & name){ std::string res; $self->getSerialized(name, res); return res; }; %rename("$ignore", fullname=1) "MyClass:

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

二次信任 提交于 2020-01-11 06:04:59
问题 My situation is that i have a C++ class (MyClass) with a method that has the following signature: bool getSerialized(const stdString & name, std::string & serialized); Where name is a in argument and serialized is an out argument. I got it working by making a %extend and %ignore declarations in the 'i' file as follows: %extend MyClass{ std::string getSerialized(const std::string & name){ std::string res; $self->getSerialized(name, res); return res; }; %rename("$ignore", fullname=1) "MyClass:

Installing pocketsphinx python module: command 'swig.exe' failed

时光怂恿深爱的人放手 提交于 2020-01-11 05:01:09
问题 I'm getting something like this. Can anyone please tell me how to fix this. C:\Users\krush\Documents\ML using Python>pip install pocketsphinx Collecting pocketsphinx Using cached pocketsphinx-0.1.3.zip Building wheels for collected packages: pocketsphinx Running setup.py bdist_wheel for pocketsphinx: started Running setup.py bdist_wheel for pocketsphinx: finished with status 'error' Complete output from command C:\Users\krush\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C

为1900个JNI函数添加日志

浪尽此生 提交于 2020-01-10 14:55:47
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> Android Native库的调试一直是个复杂的事,通常调试方法有输出日志和使用ADT等插件方法,前者较简单, TouchVG 就使用日志输出方式来调试定位: 在CPP文件中 #include "mglog.h" ,在要调试的函数中调用 LOGD("your message %d", someint); 在 Eclipse 中设置 LogCat 过滤串: tag:dalvikvm|AndroidRuntime|vgjni|touchvg|vgstack|libc 最近遇到一些libc崩溃问题,需要在C++代码中定位。首先需要定位JNI入口函数,而SWIG生成 touchvg_java_wrap.cpp 有4万行代码、1900多个JNI函数,不可能一个个去加日志。 当然写脚本自动干这事了,这里是 Python脚本内容 。 <!-- lang: python --> #!/usr/bin/env python # addlog.py: Add logging entry for each JNI function # author: Zhang Yungui <github.com/rhcad> # Usage: # 1. Call `python addlog.py` in jni/build.sh # 2.

How can I read the window title with JNI or JNA?

南楼画角 提交于 2020-01-09 10:46:48
问题 Looking to get back into the development space; primarily using Java to call some native win32 functions (I don't desire to build in .NET).... Can someone point me to a place where I can read the title from a differnt running window using Java (JNI/JNA/SWIG). Assume you would know where in the memory space the application you are attempting to hook into is. 回答1: In JNA: public interface User32 extends StdCallLibrary { User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class); int

swig-php wrapper uses pointer, c code is an array

牧云@^-^@ 提交于 2020-01-07 04:22:06
问题 I am using SWIG to generate a PHP extension that calls into a 'c' shared lib. I am able to get most things to work except the following situation... In my 'c' code I declare a function as (Please note that structure and function names have been changed to protect the innocent): int getAllThePortInfo(EthernetPort *ports); In this case, the parameter ports is actually an array of EthernetPort structures. In another 'c' program, I could have called it like this... EthernetPort ports[4]; int rval

Passing bool by reference using SWIG and Python

孤者浪人 提交于 2020-01-06 04:34:06
问题 I've wrapped a C++ library API using SWIG, which works well, but I'm stumped by a "bool &" parameter. The original API looks like this: void foo(bool & bar); when I call it from Python, the _wrap.cxx drops out of the wrap process at int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_bool, 0); _v = SWIG_CheckState(res); if (_v) { In other words, swig can't convert what I'm passing in to a bool pointer. I'm trying to call it from Python, like so: obj = LibObject() x = 0 obj.foo(x) Is there a