swig

How to Rename SWIG Generated Proxy Java classes created from C Structures

人走茶凉 提交于 2019-12-13 17:43:11
问题 I have a few C structures like below that are generated by SWIG into sample_struct_t.java since the C function declares it as sample_struct_t. What would I need to add to the SWIG interface file to generate the sample_struct_t structure as Sample.java? typedef struct sample_struct_t_ { char *sample; uint8_t example; ios_boolean remove; } sample_struct_t; 回答1: You need to use %rename with the non- typedef 'd (i.e. original) name, before this is first seen: %module test %rename (Sample) sample

How to use a ByteBuffer return from C++ to Java

不羁岁月 提交于 2019-12-13 16:43:14
问题 This is almost a repeat of question in How can I make Swig correctly wrap a char* buffer that is modified in C as a Java Something-or-other? ... Instead of Stringbuffer if I were to use a bytebuffer, what would be the change in the typemap ? 回答1: I've put together an example of how you might do this using the following header file/function as a test: #include <stdio.h> static void foo(char *buf, int len) { while(len--) putchar(*buf++); } My solution was to modify this answer such that the

SWIG with python and C: arguments

旧巷老猫 提交于 2019-12-13 16:26:34
问题 I have this function: void func(int* a, int b); Which I want to make available in python like so: func(list, int) ie, the user passes a list and an integer (telling the functions how many entries should be stored in the list). To do this, I need to know the value of "b" in the initialization for "a" (because I need a raw C int array temporarily). %typemap(in) ( int* a) { //need to allocate sizeof(int) * b bytes temporarily } But I don't know the value of "b" because it is only parsed later!

SWIG unsigned char and byte[]

China☆狼群 提交于 2019-12-13 15:10:58
问题 I've looked all over the place. I have tried some of the techniques on this site. To no avail. I have a c++ global function char* squid( char* buff, int len ); I create a .i file %module Crabby %include "arrays_java.i" %{ /* headers here are included in the wrapper code */ #include "sponge.h" %} %typemap(jtype) (const signed char *arr, size_t sz) "byte[]" %typemap(jstype) (const signed char *arr, size_t sz) "byte[]" %typemap(jni) (const signed char *arr, size_t sz) "jbyteArray" %typemap

python swig : ImportError wrong ELF class: ELFCLASS64

。_饼干妹妹 提交于 2019-12-13 09:00:35
问题 I am trying to interface from python to c++ code via swig. I get the following error , while trying to execute my script. File "./driver.py", line 4, in <module> from fixMessageSim import * File "/var/user/pradyotd/testframework/fixMessageSim.py", line 12, in <module> import MessageFactory File "/var/user/pradyotd/testframework/MessageFactory.py", line 25, in <module> _MessageFactory = swig_import_helper() File "/var/user/pradyotd/testframework/MessageFactory.py", line 21, in swig_import

SWIG - Java - Pass by reference int

余生长醉 提交于 2019-12-13 06:08:23
问题 I have a simple function intReference int intReference(int *intArray) Where I am passing intArray by reference. How do I set the interface file for SWIG such that it can do that? Thanks, 回答1: This is the pattern I think you want: intReference.i %module intReference %{ extern int intReference(int intArray[]); %} %typemap(jtype) int intArray[] "int[]" %typemap(jstype) int intArray[] "int[]" %typemap(javain) int intArray[] "$javainput" %typemap(jni) int intArray[] "jintArray" %typemap(in) int

A couple more SWIG warnings

落花浮王杯 提交于 2019-12-13 05:13:14
问题 I am trying to create some ruby wrappers around a c++ library. I have most of it working, but I have a few Warnings that I would like to fix. The issues are with 2 header files, here are the snips of code typedef std::set<WParm,std::less<WParm> > WParmlistType; typedef WParmlistType::iterator WParmlistIter; class WParmlist : public WParmlistType { and the warning I get ... Warning 401: Nothing known about base class 'WParmlistType'. Ignored. and the second header is similar : typedef std:

Referencing specific classes in an external library with SWIG

和自甴很熟 提交于 2019-12-13 04:56:21
问题 Currently, I'm trying to wrap my custom C++ library for use in Java (and ultimately Android). My library uses the OpenCV Mat and Size classes as input. Below, is an example SWIG interface of what I have so far: %module customLib %include <std_vector.i> %include <std_string.i> %{ #include "opencv2/core/core.hpp" #include "../include/myinc/CustomLib.h" %} namespace cv { class Mat {}; class Size {}; } namespace myinc { CustomType preprocessMatrix(const cv::Mat& src, cv::Mat& dst, const cv::Size&

Fatal error in extension: PyThreadState_Get: no current thread when using SWIG with Anaconda3 on a Mac

烈酒焚心 提交于 2019-12-13 02:50:38
问题 I only get this error with anaconda3 and swig on a Mac. Does anyone have any suggestions on how to resolve this? This is the test.i file. # test.i %module test %{ int hello(); %} This is the test.c file. //test.c #include <stdio.h> int hello() { printf("Hello\n"); return 0; } This is the compilation steps for creating the extension. $ swig -python test.i $ cc -c $(python3-config --cflags) test.c test_wrap.c $ cc -bundle -L/Users/$USER/miniconda3/lib/python3.6/config-3.6m-darwin -lpython3.6m

is all the available swig+python+mingw compile information outdated?

一曲冷凌霜 提交于 2019-12-13 01:54:27
问题 I'm trying to build a C++ extension for python using swig. I've followed the instructions below and the others to a T and can't seem to get my extension to load. I ran across this article on the MinGW site under "How do I create Python extensions?" http://www.mingw.org/wiki/FAQ I also found these tutorials: http://boodebr.org/main/python/build-windows-extensions http://www.mail-archive.com/modwsgi@googlegroups.com/msg04655.html http://oldwiki.mingw.org/index.php/Python%20extensions I'm using