swig

Integrating log4j with SWIG/JNI?

房东的猫 提交于 2020-02-06 04:43:34
问题 I'm working on a Java program which has a C++ module. I'd like for my C++'s stdout/stderr to be sent to a slf4j/log4j logger. Some possibilities: Have my C++ module capture stdout/stderr in a string which is returned and sent to a logger. A downside is the C++ module might be expensive and this would be asynchronous. Have my Java software create/manage a temp file to which the C++ module can write. Upon completion, my software would read and then delete the file and send the data to slf4j. is

Initialize a sub-module within a package with SWIG and Python 3

匆匆过客 提交于 2020-02-05 07:03:26
问题 I have a C++ application that I swigged to Python 2.7. I'm currently trying to port my code from Python 2.7 to Python 3.4 using the Python/C API and SWIG. I have a package containing multiple modules. The problem is I cannot find a way to initialize my module ModuleABC as a sub-module of package PackageXYZ . It works well with Python 2.7 but not with Python 3.4 (and I suppose it wouldn't work either with any Python 3.x version). Here is my code. ModuleABC.h extern "C" { #if PY_MAJOR_VERSION >

SWIG get returntype from String as String array in java

一个人想着一个人 提交于 2020-02-04 06:36:26
问题 For a small Java project I needed to interact with existing code written in C, so to make things easy (I'm not a C/C++ programmer unfortunately..) I decided to use swig. The generated wrapper code seems to work; however, when I call a function that is supposed to give me a NULL-delimited list of strings (That's what the C function is supposed to return, if I'm not mistaken) the wrapped code only returns the first String value of the expected list of values. I assume the correct return

SWIG Technique to Wrap Unsigned Binary Data

删除回忆录丶 提交于 2020-02-03 04:50:03
问题 I have a C function that returns a unsigned char* that represents binary data. I noticed in the documentation that SWIG has a nice typemap to handle binary data as input to a C function, but what about when a C function returns binary data and its unsigned? Any ideas? swig.i: %apply (char *STRING, size_t LENGTH) { (const char data[], size_t len) } %inline %{ void binaryChar1(const char data[], size_t len) { printf("len: %d data: ", len); for (size_t i=0; i<len; ++i) printf("%x ", data[i]);

Swig C++: Interfacing vector<Class object *>

家住魔仙堡 提交于 2020-02-01 21:34:19
问题 basically I am trying to have a tuple/list which contains a dictionary of different data types of values(float/int/bool/char/list) in python. I am getting this from the following code: (<f_p.Bunch; proxy of <Swig Object of type 'Bunch *' at 0x7f4954bdde10> >, <f_p.Bunch; proxy of <Swig Object of type 'Bunch *' at 0x7f4954bdde40> >, <f_p.Bunch; proxy of <Swig Object of type 'Bunch *' at 0x7f495668be70> >, <f_p.Bunch; proxy of <Swig Object of type 'Bunch *' at 0x7f4952d09a50> >) I want to get

How to Install M2crypto on Windows

こ雲淡風輕ζ 提交于 2020-01-28 02:07:14
问题 After installing OpenSSL, downloading the pre-built Swig executable, and ensuring the openssl libraries are located in the default c:\pkg , pip install m2crypto results in: ... C:\Program Files (x86)\gfortran\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Pyth on27\include -IC:\Python27\PC -Ic:\pkg\include -Ic:\users\evbo\appdata\local\tem p\pip_build_evbo\m2crypto\SWIG -c SWIG/_m2crypto_wrap.c -o build\temp.win32-2.7\ Release\swig\_m2crypto_wrap.o -DTHREADING gcc: error: unrecognized command

Implementing and inheriting from C++ classes in Lua using SWIG

对着背影说爱祢 提交于 2020-01-24 21:04:46
问题 Would it be possible using Lua and SWIG and say an IInterface class, to implement that interface and instantiate it all within Lua? If so how would it be done? 回答1: In the first place, C++ style interfaces does now make much sense in a language like Lua. For a Lua object to conform to an interface, it just need to contain definitions for all the functions in that interface. There is no need for any specific inheritance. For instance, if you have a C++ interface like this: // Represents a

Implementing and inheriting from C++ classes in Lua using SWIG

非 Y 不嫁゛ 提交于 2020-01-24 21:04:29
问题 Would it be possible using Lua and SWIG and say an IInterface class, to implement that interface and instantiate it all within Lua? If so how would it be done? 回答1: In the first place, C++ style interfaces does now make much sense in a language like Lua. For a Lua object to conform to an interface, it just need to contain definitions for all the functions in that interface. There is no need for any specific inheritance. For instance, if you have a C++ interface like this: // Represents a

swig extending a templated class with variable

可紊 提交于 2020-01-24 11:41:28
问题 I am building a Swig interface to a templated class. In my pyinterface.i file, I declare %template (myclass) MyClass<int>; Now what I want to do, is add a field variable to my new class, which I assume should be done as %extend MyClass<int>{ double x; } However, this complains that there is no myclass_get_x method defined. So if I try to define this by modifying the above to: %extend MyClass<int>{ double x; double MyClass<int>_get_x(MyClass<int> *f){ return (*f)->x; } } Then I get syntax

Simpler way to create a SWIG typemap for a function with multiple arguments?

雨燕双飞 提交于 2020-01-24 01:34:05
问题 Here's the C++ function that I want to wrap using SWIG. static void my_func(t_string name, t_string value) { do_something(name, value); } And here are the SWIG typemaps. %typemap(in) (t_string name) { if (!lua_isstring(L, $input)) { SWIG_exception(SWIG_RuntimeError, "argument mismatch: string expected"); } $1 = lua_tostring(L, $input); } %typemap(in) (t_string value) { if (!lua_isstring(L, $input)) { SWIG_exception(SWIG_RuntimeError, "argument mismatch: string expected"); } $1 = lua_tostring