-
-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the python binds with output params is difficulty to use #991
Labels
enhancement
New feature or request
Comments
Yes, marking OUTPUT args as such would be good. fp is optional and can be NULL |
I add this at the first for /*****************************************************************************/
/* LibreDWG - free implementation of the DWG file format */
/* */
/* Copyright (C) 2010-2019 Free Software Foundation, Inc. */
/* */
/* This library is free software, licensed under the terms of the GNU */
/* General Public License as published by the Free Software Foundation, */
/* either version 3 of the License, or (at your option) any later version. */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/*****************************************************************************/
/*
* dwg.i: SWIG interface file
* written by Rodrigo Rodrigues da Silva
* ideas contributed by James Michael DuPont
* rewritten and largely auto-generated by Reini Urban
*/
%module LibreDWG
%include "typemaps.i" // 包含常用的类型映射
%typemap(in,numinputs=0) int *isnew (int tmp) %{
$1 = &tmp;
%}
%typemap(argout) int *isnew (PyObject* obj){
obj = PyInt_FromLong(*$1);
$result = SWIG_Python_AppendOutput($result,obj);
}
// This input typemap declares that char** requires no input parameter.
// Instead, the address of a local char* is used to call the function.
%typemap(in,numinputs=0) char** (char* tmp) %{
$1 = &tmp;
%}
// After the function is called, the char** parameter contains a malloc'ed char* pointer.
// Construct a Python Unicode object (I'm using Python 3) and append it to
// any existing return value for the wrapper.
%typemap(argout) char** (PyObject* obj) %{
obj = PyUnicode_FromString(*$1);
$result = SWIG_Python_AppendOutput($result,obj);
%}
// The malloc'ed pointer is no longer needed, so make sure it is freed.
%typemap(freearg) char** %{
free(*$1);
%} It works for me to call it like |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in
dwg.i
,etc:
the output params is
textp
,isnew
,fp
, inLibreDWG.py
I cannot call this function success, always get error
I found this https://stackoverflow.com/questions/15185010/how-to-receive-reference-and-pointer-arguments-in-python-swig , it seem need some modify in
dwg.i
.But I am not familiar with SWIG
The text was updated successfully, but these errors were encountered: