more typemaps unification and fixes for valgrind

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7684 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-10-19 10:52:50 +00:00
commit aadff06f45
26 changed files with 484 additions and 74 deletions

View file

@ -80,10 +80,6 @@ typedef TYPE NAME;
typedef struct NAME {
/* Put language specific enhancements here */
#if defined(SWIGPYTHON) || defined(SWIGRUBY)
%rename(__getitem__) getitem;
%rename(__setitem__) setitem;
#endif
} NAME;
%extend NAME {

View file

@ -65,7 +65,7 @@ SWIG_AsArgcArgv(PyObject* input,
}
}
%typemap(freearg) (int ARGC, char **ARGV) {
%typemap(freearg,noblock=1) (int ARGC, char **ARGV) {
if (owner$argnum) {
size_t i = argc$argnum;
while (i) {

2
Lib/python/carrays.i Normal file
View file

@ -0,0 +1,2 @@
%include <typemaps/carrays.swg>

1
Lib/python/cmalloc.i Normal file
View file

@ -0,0 +1 @@
%include <typemaps/cmalloc.swg>

1
Lib/python/cpointer.i Normal file
View file

@ -0,0 +1 @@
%include <typemaps/cpointer.swg>

View file

@ -338,10 +338,10 @@ namespace swig
snprintf(msg, sizeof(msg), "in sequence element %d of type %s", i, swig::type_name<value_type>());
SWIG_set_errmsg(SWIG_TypeError, msg);
}
return 0;
return false;
}
}
return 1;
return true;
}
private:
@ -488,7 +488,7 @@ namespace swig
if (SWIG_ConvertPtr(obj,(void**)&p,
swig::type_info<sequence>(),0) == SWIG_OK) {
if (seq) *seq = p;
return 1;
return SWIG_OLDOBJ;
}
}
if (seq) {

View file

@ -67,7 +67,7 @@ namespace swig {
template <class Type>
struct traits_asval {
static bool asval(PyObject *obj, Type *val) {
static int asval(PyObject *obj, Type *val) {
if (val) {
Type *p = 0;
int res = traits_asptr<Type>::asptr(obj, &p);
@ -75,12 +75,12 @@ namespace swig {
typedef typename noconst_traits<Type>::noconst_type noconst_type;
*(const_cast<noconst_type*>(val)) = *p;
if (res == SWIG_NEWOBJ) SWIG_delete(p);
return true;
return SWIG_OK;
} else {
return false;
return SWIG_ERROR;
}
} else {
return traits_asptr<Type>::asptr(obj, (Type **)(0)) ? true : false;
return traits_asptr<Type>::asptr(obj, (Type **)(0)) ? SWIG_OK : SWIG_ERROR;
}
}
};
@ -93,26 +93,26 @@ namespace swig {
int res = traits_asptr<noconst_type>::asptr(obj, &p);
if (res) {
*(const_cast<noconst_type**>(val)) = p;
return true;
return SWIG_OK;
} else {
return false;
return SWIG_ERROR;
}
} else {
return traits_asptr<Type>::asptr(obj, (Type **)(0)) ? true : false;
return traits_asptr<Type>::asptr(obj, (Type **)(0)) ? SWIG_OK : SWIG_ERROR;
}
}
};
template <class Type>
inline bool asval(PyObject *obj, Type *val) {
return traits_asval<Type>::asval(obj, val) ? true : false;
inline int asval(PyObject *obj, Type *val) {
return traits_asval<Type>::asval(obj, val);
}
template <class Type>
struct traits_as<Type, value_category> {
static Type as(PyObject *obj, bool throw_error) {
Type v;
if (!obj || !asval(obj, &v)) {
if (!obj || (asval(obj, &v) != SWIG_OK)) {
if (!PyErr_Occurred()) {
SWIG_Python_SetErrorMsg(SWIG_Python_ErrorType(SWIG_TypeError), swig::type_name<Type>());
}
@ -173,7 +173,7 @@ namespace swig {
template <class Type>
struct traits_check<Type, value_category> {
static bool check(PyObject *obj) {
return obj && asval(obj, (Type *)(0));
return obj && (asval(obj, (Type *)(0)) == SWIG_OK);
}
};
@ -229,9 +229,9 @@ namespace swig {
static int asval(PyObject *obj, value_type *val) {
if (Check(obj)) {
*val = As(obj);
return 1;
return SWIG_OK;
}
return 0;
return SWIG_ERROR;
}
};
template <> struct traits_from<Type > {

View file

@ -20,12 +20,30 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
PyString_AsStringAndSize(obj, &cstr, &len);
if (cptr) {
if (alloc) {
if (*alloc == SWIG_NEWOBJ) {
*cptr = SWIG_new_copy_array(cstr, len + 1, char);
} else {
/*
In python the user should not be able to modify the inner
string representation, so, by default we return a copy of
the buffer, as in the wstring case.
But, if you use the -DSWIG_PYTHON_UNSAFE_CSTR at
compilation time, you will get, at your own risk, the
inner string pointer instead, when possible.
*/
#ifndef SWIG_PYTHON_UNSAFE_CSTR
if (*alloc != SWIG_OLDOBJ)
#else
if (*alloc == SWIG_NEWOBJ)
#endif
{
*cptr = SWIG_new_copy_array(cstr, len + 1, char);
*alloc = SWIG_NEWOBJ;
}
else {
*cptr = cstr;
*alloc = SWIG_OLDOBJ;
}
} else {
*cptr = cstr;
}
}
if (psize) *psize = len + 1;

View file

@ -26,6 +26,7 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
int len = PyUnicode_GetSize(obj);
if (cptr) {
*cptr = SWIG_new_array(len + 1, wchar_t);
memset(*cptr, 0, (len + 1)*sizeof(wchar_t));
PyUnicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
(*cptr)[len] = 0;
}

View file

@ -20,7 +20,7 @@
pfirst = &((*val)->first);
psecond = &((*val)->second);
}
if (swig::asval(first,pfirst) && swig::asval(second,psecond)) {
if ((swig::asval(first,pfirst) == SWIG_OK) && (swig::asval(second,psecond) == SWIG_OK)) {
return SWIG_NEWOBJ;
} else {
SWIG_delete(*val);

2
Lib/ruby/carrays.i Normal file
View file

@ -0,0 +1,2 @@
%include <typemaps/carrays.swg>

1
Lib/ruby/cmalloc.i Normal file
View file

@ -0,0 +1 @@
%include <typemaps/cmalloc.swg>

1
Lib/ruby/cpointer.i Normal file
View file

@ -0,0 +1 @@
%include <typemaps/cpointer.swg>

View file

@ -42,7 +42,7 @@
/* Error manipulation */
#define SWIG_ERROR -1
#define SWIG_fail return Qnil
#define SWIG_fail goto fail
#define SWIG_var_fail return Qnil
#define SWIG_error(code, msg) SWIG_Ruby_SetErrorMsg(SWIG_Ruby_ErrorType(code), msg)

View file

@ -142,7 +142,7 @@ namespace swig {
template <> struct traits_asval<Type > {
typedef Type value_type;
static int asval(PyObject *obj, value_type *val) {
return SWIG_AsVal(Type)(obj, val) == SWIG_OK;
return SWIG_AsVal(Type)(obj, val);
}
};
template <> struct traits_from<Type > {

2
Lib/tcl/carrays.i Normal file
View file

@ -0,0 +1,2 @@
%include <typemaps/carrays.swg>

1
Lib/tcl/cmalloc.i Normal file
View file

@ -0,0 +1 @@
%include <typemaps/cmalloc.swg>

1
Lib/tcl/cpointer.i Normal file
View file

@ -0,0 +1 @@
%include <typemaps/cpointer.swg>

111
Lib/typemaps/carrays.swg Normal file
View file

@ -0,0 +1,111 @@
/* -----------------------------------------------------------------------------
* carrays.i
*
* Author(s): David Beazley (beazley@cs.uchicago.edu)
*
* This library file contains macros that can be used to manipulate simple
* pointers as arrays.
*
* $Header$
* ----------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
* %array_functions(TYPE,NAME)
*
* Generates functions for creating and accessing elements of a C array
* (as pointers). Creates the following functions:
*
* TYPE *new_NAME(int nelements)
* void delete_NAME(TYPE *);
* TYPE NAME_getitem(TYPE *, int index);
* void NAME_setitem(TYPE *, int index, TYPE value);
*
* ----------------------------------------------------------------------------- */
%define %array_functions(TYPE,NAME)
%{
static TYPE *new_##NAME(size_t nelements) {
return SWIG_new_array(nelements, TYPE);
}
static void delete_##NAME(TYPE *ary) {
SWIG_delete_array(ary);
}
static TYPE NAME##_getitem(TYPE *ary, size_t index) {
return ary[index];
}
static void NAME##_setitem(TYPE *ary, size_t index, TYPE value) {
ary[index] = value;
}
%}
TYPE *new_##NAME(size_t nelements);
void delete_##NAME(TYPE *ary);
TYPE NAME##_getitem(TYPE *ary, size_t index);
void NAME##_setitem(TYPE *ary, size_t index, TYPE value);
%enddef
/* -----------------------------------------------------------------------------
* %array_class(TYPE,NAME)
*
* Generates a class wrapper around a C array. The class has the following
* interface:
*
* struct NAME {
* NAME(int nelements);
* ~NAME();
* TYPE getitem(int index);
* void setitem(int index, TYPE value);
* TYPE * cast();
* static NAME *frompointer(TYPE *t);
* }
*
* ----------------------------------------------------------------------------- */
%define %array_class(TYPE,NAME)
%{
typedef TYPE NAME;
%}
typedef struct NAME {
/* Put language specific enhancements here */
#if defined(SWIGPYTHON) || defined(SWIGRUBY)
%rename(__getitem__) getitem;
%rename(__setitem__) setitem;
#endif
} NAME;
%extend NAME {
NAME(size_t nelements) {
return SWIG_new_array(nelements, TYPE);
}
~NAME() {
SWIG_delete_array(self);
}
TYPE getitem(size_t index) {
return self[index];
}
void setitem(size_t index, TYPE value) {
self[index] = value;
}
TYPE * cast() {
return self;
}
static NAME *frompointer(TYPE *t) {
return SWIG_static_cast(t, NAME *);
}
};
%types(NAME = TYPE);
%enddef

114
Lib/typemaps/cmalloc.swg Normal file
View file

@ -0,0 +1,114 @@
/* -----------------------------------------------------------------------------
* cmalloc.i
*
* Author(s): David Beazley (beazley@cs.uchicago.edu)
*
* This library file contains macros that can be used to create objects using
* the C malloc function.
*
* $Header$
* ----------------------------------------------------------------------------- */
%{
#include <stdlib.h>
%}
/* %malloc(TYPE [, NAME = TYPE])
%calloc(TYPE [, NAME = TYPE])
%realloc(TYPE [, NAME = TYPE])
%free(TYPE [, NAME = TYPE])
%allocators(TYPE [,NAME = TYPE])
Creates functions for allocating/reallocating memory.
TYPE *malloc_NAME(size_t nbytes = sizeof(TYPE);
TYPE *calloc_NAME(size_t nobj=1, size_t size=sizeof(TYPE));
TYPE *realloc_NAME(TYPE *ptr, size_t nbytes);
void free_NAME(TYPE *ptr);
*/
%define %malloc(TYPE,NAME...)
#if #NAME != ""
%rename(malloc_##NAME) ::malloc(size_t nbytes);
#else
%rename(malloc_##TYPE) ::malloc(size_t nbytes);
#endif
#if #TYPE != "void"
%typemap(default) size_t nbytes "$1 = (size_t) sizeof(TYPE);"
#endif
TYPE *malloc(size_t nbytes);
%typemap(default) size_t nbytes;
%enddef
%define %calloc(TYPE,NAME...)
#if #NAME != ""
%rename(calloc_##NAME) ::calloc(size_t nobj, size_t sz);
#else
%rename(calloc_##TYPE) ::calloc(size_t nobj, size_t sz);
#endif
#if #TYPE != "void"
%typemap(default) size_t sz "$1 = (size_t) sizeof(TYPE);"
#else
%typemap(default) size_t sz "$1 = 1;"
#endif
%typemap(default) size_t nobj "$1 = 1;"
TYPE *calloc(size_t nobj, size_t sz);
%typemap(default) size_t sz;
%typemap(default) size_t nobj;
%enddef
%define %realloc(TYPE,NAME...)
%insert("header") {
#if #NAME != ""
TYPE *realloc_##NAME(TYPE *ptr, size_t nitems)
#else
TYPE *realloc_##TYPE(TYPE *ptr, size_t nitems)
#endif
{
#if #TYPE != "void"
return (TYPE *) realloc(ptr, nitems*sizeof(TYPE));
#else
return (TYPE *) realloc(ptr, nitems);
#endif
}
}
#if #NAME != ""
TYPE *realloc_##NAME(TYPE *ptr, size_t nitems);
#else
TYPE *realloc_##TYPE(TYPE *ptr, size_t nitems);
#endif
%enddef
%define %free(TYPE,NAME...)
#if #NAME != ""
%rename(free_##NAME) ::free(TYPE *ptr);
#else
%rename(free_##TYPE) ::free(TYPE *ptr);
#endif
void free(TYPE *ptr);
%enddef
%define %sizeof(TYPE,NAME...)
#if #NAME != ""
%constant size_t sizeof_##NAME = sizeof(TYPE);
#else
%constant size_t sizeof_##TYPE = sizeof(TYPE);
#endif
%enddef
%define %allocators(TYPE,NAME...)
%malloc(TYPE,NAME)
%calloc(TYPE,NAME)
%realloc(TYPE,NAME)
%free(TYPE,NAME)
#if #TYPE != "void"
%sizeof(TYPE,NAME)
#endif
%enddef

160
Lib/typemaps/cpointer.swg Normal file
View file

@ -0,0 +1,160 @@
/* -----------------------------------------------------------------------------
* cpointer.i
*
* Author(s): David Beazley (beazley@cs.uchicago.edu)
*
* This library file contains macros that can be used to manipulate simple
* pointer objects.
*
* $Header$
* ----------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
* %pointer_class(type,name)
*
* Places a simple proxy around a simple type like 'int', 'float', or whatever.
* The proxy provides this interface:
*
* class type {
* public:
* type();
* ~type();
* type value();
* void assign(type value);
* };
*
* Example:
*
* %pointer_class(int, intp);
*
* int add(int *x, int *y) { return *x + *y; }
*
* In python (with proxies)
*
* >>> a = intp()
* >>> a.assign(10)
* >>> a.value()
* 10
* >>> b = intp()
* >>> b.assign(20)
* >>> print add(a,b)
* 30
*
* As a general rule, this macro should not be used on class/structures that
* are already defined in the interface.
* ----------------------------------------------------------------------------- */
%define %pointer_class(TYPE, NAME)
%{
typedef TYPE NAME;
%}
typedef struct {
} NAME;
%extend NAME {
NAME() {
return SWIG_new(TYPE);
}
~NAME() {
if (self) SWIG_delete(self);
}
}
%extend NAME {
void assign(TYPE value) {
*self = value;
}
TYPE value() {
return *self;
}
TYPE * cast() {
return self;
}
static NAME * frompointer(TYPE *t) {
return (NAME *) t;
}
}
%types(NAME = TYPE);
%enddef
/* -----------------------------------------------------------------------------
* %pointer_functions(type,name)
*
* Create functions for allocating/deallocating pointers. This can be used
* if you don't want to create a proxy class or if the pointer is complex.
*
* %pointer_functions(int, intp)
*
* int add(int *x, int *y) { return *x + *y; }
*
* In python (with proxies)
*
* >>> a = copy_intp(10)
* >>> intp_value(a)
* 10
* >>> b = new_intp()
* >>> intp_assign(b,20)
* >>> print add(a,b)
* 30
* >>> delete_intp(a)
* >>> delete_intp(b)
*
* ----------------------------------------------------------------------------- */
%define %pointer_functions(TYPE,NAME)
%{
static TYPE *new_##NAME() {
return SWIG_new(TYPE);
}
static TYPE *copy_##NAME(TYPE value) {
return SWIG_new_copy(value, TYPE);
}
static void delete_##NAME(TYPE *self) {
if (self) SWIG_delete(self);
}
static void NAME ##_assign(TYPE *self, TYPE value) {
*self = value;
}
static TYPE NAME ##_value(TYPE *self) {
return *self;
}
%}
TYPE *new_##NAME();
TYPE *copy_##NAME(TYPE value);
void delete_##NAME(TYPE *self);
void NAME##_assign(TYPE *self, TYPE value);
TYPE NAME##_value(TYPE *self);
%enddef
/* -----------------------------------------------------------------------------
* %pointer_cast(type1,type2,name)
*
* Generates a pointer casting function.
* ----------------------------------------------------------------------------- */
%define %pointer_cast(TYPE1,TYPE2,NAME)
%inline %{
TYPE2 NAME(TYPE1 x) {
return SWIG_static_cast(x, TYPE2);
}
%}
%enddef

View file

@ -29,14 +29,14 @@
%define Name ## _input_binary(TYPEMAP, SIZE)
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (TYPEMAP, SIZE)
(Char *buf, size_t size, int alloc) {
(Char *buf = 0, size_t size = 0, int alloc = 0) {
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
}
$1 = ($1_ltype) buf;
$2 = ($2_ltype) size - 1;
}
%typemap(freearg) (TYPEMAP, SIZE) {
%typemap(freearg,noblock=1) (TYPEMAP, SIZE) {
if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
}
%enddef
@ -59,7 +59,7 @@
%typemap(in,noblock=1,numinputs=0) TYPEMAP (Char temp[MAX+1]) {
$1 = ($1_ltype) temp;
}
%typemap(freearg) TYPEMAP "";
%typemap(freearg,noblock=1) TYPEMAP "";
%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtr ) TYPEMAP {
$1[MAX] = 0;
SWIG_append_result(SWIG_FromCharPtr($1));
@ -84,7 +84,7 @@
%typemap(in,noblock=1,numinputs=0) TYPEMAP(Char temp[SIZE]) {
$1 = ($1_ltype) temp;
}
%typemap(freearg) TYPEMAP "";
%typemap(freearg,noblock=1) TYPEMAP "";
%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtrAndSize) TYPEMAP {
SWIG_append_result(SWIG_FromCharPtrAndSize($1,SIZE));
}
@ -108,7 +108,8 @@
%define Name ## _bounded_mutable(TYPEMAP,MAX)
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP (Char temp[MAX+1], Char *t, size_t n, int alloc) {
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP
(Char temp[MAX+1], Char *t = 0, size_t n = 0, int alloc = 0) {
if (SWIG_AsCharPtrAndSize($input, &t, &n, &alloc) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "TYPEMAP", $argnum);
}
@ -118,7 +119,7 @@
temp[n - 1] = 0;
$1 = ($1_ltype) temp;
}
%typemap(freearg) TYPEMAP "";
%typemap(freearg,noblock=1) TYPEMAP "";
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
$1[MAX] = 0;
SWIG_append_result(SWIG_FromCharPtr($1));
@ -143,7 +144,8 @@
*/
%define Name ## _mutable(TYPEMAP,EXP...)
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP (Char* t, size_t n, int alloc, size_t expansion = 0) {
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP
(Char* t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) {
#if #EXP != ""
expansion += EXP;
#endif
@ -155,7 +157,7 @@
if (alloc == SWIG_NEWOBJ) SWIG_delete_array(t);
$1[n-1] = 0;
}
%typemap(freearg) TYPEMAP "";
%typemap(freearg,noblock=1) TYPEMAP "";
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
SWIG_append_result(SWIG_FromCharPtr($1));
SWIG_delete_array($1);

View file

@ -46,7 +46,7 @@
%define %implicit_frag(Type...) ,fragment=SWIG_Traits_frag(Type) %enddef
%define %implicit_code(Type...)
if (swig::asval<Type >(obj, 0)) {
if (swig::asval<Type >(obj, 0) == SWIG_OK) {
Type _v;
swig::asval<Type >(obj, &_v);
if (val) *val = new value_type(_v);

View file

@ -41,47 +41,44 @@
/* directorout */
%define SWIG_PTR_DIRECTOROUT_TYPEMAP(asptr_meth,frag,Type...)
%typemap(directorargout,fragment=frag) Type *DIRECTOROUT ($*1_ltype temp) {
Type *ptr = 0;
int res = $input ? asptr_meth($input, &ptr) : 0;
if (!res || !ptr) {
%typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT ($*ltype temp) {
Type *optr = 0;
int ores = $input ? asptr_meth($input, &optr) : 0;
if (!ores || !optr) {
SWIG_dout_fail(SWIG_TypeError,"$type");
} else {
temp = *ptr;
$result = &temp;
if (res == SWIG_NEWOBJ) SWIG_delete(ptr);
}
temp = *optr;
$result = &temp;
if (ores == SWIG_NEWOBJ) SWIG_delete(optr);
}
%typemap(directorout,fragment=frag) Type {
Type *ptr = 0;
int res = asptr_meth($input, &ptr);
if (!res || !ptr) {
%typemap(directorout,noblock=1,fragment=frag) Type {
Type *optr = 0;
int ores = asptr_meth($input, &optr);
if (!ores || !optr) {
SWIG_dout_fail(SWIG_TypeError,"$type");
} else {
$result = *ptr;
if (res == SWIG_NEWOBJ) SWIG_delete(ptr);
}
$result = *optr;
if (ores == SWIG_NEWOBJ) SWIG_delete(optr);
}
%typemap(directorout,fragment=frag,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const Type& {
Type *ptr = 0;
int res = asptr_meth($input, &ptr);
if (!res) {
%typemap(directorout,noblock=1,fragment=frag,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const Type& {
Type *optr = 0;
int ores = asptr_meth($input, &optr);
if (!ores) {
SWIG_dout_fail(SWIG_TypeError,"$type");
} else {
if (!ptr) {
if (!optr) {
SWIG_dout_nullref("$type");
} else {
if (res == SWIG_NEWOBJ) {
/* Possible thread/reentrant problem here! */
static $*ltype temp = *ptr;
$result = &temp;
SWIG_delete(ptr);
} else {
$result = ptr;
}
}
}
}
if (ores == SWIG_NEWOBJ) {
/* Possible thread/reentrant problem here! */
static $*ltype temp = *optr;
$result = &temp;
SWIG_delete(optr);
} else {
$result = optr;
}
}
@ -115,12 +112,12 @@
{
Type *v = (Type *)0;
int res = SWIG_AsPtr(Type)(obj, &v);
if (!res || !v) return 0;
if (!res || !v) return SWIG_ERROR;
if (val) {
*val = *v;
if (res == SWIG_NEWOBJ) SWIG_delete(v);
}
return 1;
return SWIG_OK;
}
%}
%fragment(SWIG_As_frag(Type),"header",

View file

@ -39,8 +39,7 @@
if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
}
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char const*& (Char *buf, int alloc)
{
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char const*& (Char *buf = 0, int alloc = 0) {
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
}
@ -149,7 +148,7 @@
/* directorin */
%typemap(directorin,fragment=#SWIG_FromCharPtr,noblock=1)
%typemap(directorin,noblock=1,fragment=#SWIG_FromCharPtr)
Char *, Char const*, Char *const, Char const *const,
Char const *&, Char *const &, Char const *const & {
$input = SWIG_FromCharPtr($1_name);
@ -158,14 +157,14 @@
/* directorout */
%typemap(directorout,fragment=#SWIG_AsCharPtr,noblock=1) Char * (Char* buf, int alloc) {
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr) Char * (Char* buf = 0, int alloc = 0) {
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
SWIG_dout_fail(SWIG_TypeError, "$type");
}
$result = buf;
}
%typemap(directorout,fragment=#SWIG_AsCharPtr) Char * const& (Char* buf, int alloc) {
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr) Char * const& (Char* buf = 0, int alloc = 0) {
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
SWIG_dout_fail(SWIG_TypeError, "$type");
}

View file

@ -4,7 +4,7 @@
/* Pointers and arrays */
%typemap(in, noblock=1) SWIGTYPE *, SWIGTYPE [] {
if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&$1), $descriptor, $disown) != SWIG_OK) {
if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&$1),$descriptor, $disown) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "$type", $argnum);
}
}