added methods for size_t and more freearg typemaps around, just in case
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7743 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
05c529eedc
commit
a8fe5247e2
8 changed files with 56 additions and 19 deletions
|
|
@ -181,16 +181,19 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
%define Name ## _output_maxsize(TYPEMAP, SIZE)
|
%define Name ## _output_maxsize(TYPEMAP, SIZE)
|
||||||
%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(unsigned long)) (TYPEMAP, SIZE) (unsigned long size) {
|
%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (TYPEMAP, SIZE) (size_t size, Char *buff = 0) {
|
||||||
if (SWIG_AsVal(unsigned long)($input, &size) != SWIG_OK) {
|
if (SWIG_AsVal(size_t)($input, &size) != SWIG_OK) {
|
||||||
%argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
|
%argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
|
||||||
}
|
}
|
||||||
|
buff= %new_array(size+1, Char);
|
||||||
$2 = %numeric_cast(size, $2_ltype);
|
$2 = %numeric_cast(size, $2_ltype);
|
||||||
$1 = %new_array(size+1, $*1_ltype);
|
$1 = %static_cast(buff,$1_ltype);
|
||||||
|
}
|
||||||
|
%typemap(freearg,noblock=1) (TYPEMAP,SIZE) {
|
||||||
|
if (buff$argnum) %delete_array(buff$argnum);
|
||||||
}
|
}
|
||||||
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) (TYPEMAP,SIZE) {
|
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) (TYPEMAP,SIZE) {
|
||||||
%append_output(SWIG_FromCharPtr($1));
|
%append_output(SWIG_FromCharPtr($1));
|
||||||
%delete_array($1);
|
|
||||||
}
|
}
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
|
|
@ -208,18 +211,20 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
%define Name ## _output_withsize(TYPEMAP, SIZE)
|
%define Name ## _output_withsize(TYPEMAP, SIZE)
|
||||||
%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(unsigned long)) (TYPEMAP, SIZE) (unsigned long n) {
|
%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (TYPEMAP, SIZE) (size_t n, Char *buff = 0, $*2_ltype size) {
|
||||||
if (SWIG_AsVal(unsigned long)($input, &n) != SWIG_OK) {
|
if (SWIG_AsVal(size_t)($input, &n) != SWIG_OK) {
|
||||||
%argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
|
%argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
|
||||||
}
|
}
|
||||||
$1 = %new_array(n+1, $*1_ltype);
|
buff= %new_array(n+1, Char);
|
||||||
$2 = %new_instance($*2_ltype);
|
$1 = %static_cast(buff, $1_ltype);
|
||||||
*$2 = %numeric_cast(n, $*2_ltype);
|
size = %numeric_cast(n,$*2_ltype);
|
||||||
|
$2 = &size;
|
||||||
|
}
|
||||||
|
%typemap(freearg,noblock=1)(TYPEMAP,SIZE) {
|
||||||
|
if (buff$argnum) %delete_array(buff$argnum);
|
||||||
}
|
}
|
||||||
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) (TYPEMAP,SIZE) {
|
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) (TYPEMAP,SIZE) {
|
||||||
%append_output(SWIG_FromCharPtrAndSize($1,*$2));
|
%append_output(SWIG_FromCharPtrAndSize($1,*$2));
|
||||||
%delete_array($1);
|
|
||||||
%delete($2);
|
|
||||||
}
|
}
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
|
|
@ -241,6 +246,7 @@
|
||||||
%typemap(in,noblock=1,numinputs=0) TYPEMAP($*1_ltype temp = 0) {
|
%typemap(in,noblock=1,numinputs=0) TYPEMAP($*1_ltype temp = 0) {
|
||||||
$1 = &temp;
|
$1 = &temp;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) TYPEMAP "";
|
||||||
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
|
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
|
||||||
if (*$1) {
|
if (*$1) {
|
||||||
%append_output(SWIG_FromCharPtr(*$1));
|
%append_output(SWIG_FromCharPtr(*$1));
|
||||||
|
|
@ -268,6 +274,7 @@
|
||||||
%typemap(in,noblock=1,numinputs=0) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) {
|
%typemap(in,noblock=1,numinputs=0) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) {
|
||||||
$1 = &temp; $2 = &tempn;
|
$1 = &temp; $2 = &tempn;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) (TYPEMAP,SIZE) "";
|
||||||
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)(TYPEMAP,SIZE) {
|
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)(TYPEMAP,SIZE) {
|
||||||
if (*$1) {
|
if (*$1) {
|
||||||
%append_output(SWIG_FromCharPtrAndSize(*$1,*$2));
|
%append_output(SWIG_FromCharPtrAndSize(*$1,*$2));
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
$1 = &temp;
|
$1 = &temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) const enum SWIGTYPE& "";
|
||||||
|
|
||||||
%typemap(varin,fragment=SWIG_AsVal_frag(int),noblock=1) enum SWIGTYPE {
|
%typemap(varin,fragment=SWIG_AsVal_frag(int),noblock=1) enum SWIGTYPE {
|
||||||
if (sizeof(int) != sizeof($1)) {
|
if (sizeof(int) != sizeof($1)) {
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,24 @@ SWIG_AsVal_dec(bool)(SWIG_Object obj, bool *val)
|
||||||
|
|
||||||
%ensure_type_fragments(double)
|
%ensure_type_fragments(double)
|
||||||
|
|
||||||
|
/* size_t */
|
||||||
|
|
||||||
|
%fragment(SWIG_From_frag(size_t),"header",fragment=SWIG_From_frag(unsigned long)) {
|
||||||
|
SWIGINTERNINLINE SWIG_Object
|
||||||
|
SWIG_From_dec(size_t)(size_t value)
|
||||||
|
{
|
||||||
|
return SWIG_From(unsigned long)(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%fragment(SWIG_AsVal_frag(size_t),"header",fragment=SWIG_AsVal_frag(unsigned long)) {
|
||||||
|
SWIGINTERNINLINE int
|
||||||
|
SWIG_AsVal_dec(size_t)(SWIG_Object obj, size_t *val)
|
||||||
|
{
|
||||||
|
return SWIG_AsVal(unsigned long)(obj, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
* Generate the typemaps for primitive type
|
* Generate the typemaps for primitive type
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
$1 = *ptr;
|
$1 = *ptr;
|
||||||
if (res == SWIG_NEWOBJ) %delete(ptr);
|
if (res == SWIG_NEWOBJ) %delete(ptr);
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) Type "";
|
||||||
%typemap(in,fragment=frag) const Type & (int res = 0) {
|
%typemap(in,fragment=frag) const Type & (int res = 0) {
|
||||||
Type *ptr = (Type *)0;
|
Type *ptr = (Type *)0;
|
||||||
res = asptr_meth($input, &ptr);
|
res = asptr_meth($input, &ptr);
|
||||||
|
|
|
||||||
|
|
@ -233,6 +233,7 @@
|
||||||
}
|
}
|
||||||
$1 = temp;
|
$1 = temp;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) Char [ANY], const Char [ANY] "";
|
||||||
|
|
||||||
%typemap(in,noblock=1,fragment=#SWIG_AsCharArray) const Char (&)[ANY] (Char temp[$1_dim0])
|
%typemap(in,noblock=1,fragment=#SWIG_AsCharArray) const Char (&)[ANY] (Char temp[$1_dim0])
|
||||||
{
|
{
|
||||||
|
|
@ -241,6 +242,7 @@
|
||||||
}
|
}
|
||||||
$1 = &temp;
|
$1 = &temp;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) const Char (&)[ANY] "";
|
||||||
|
|
||||||
%typemap(out,fragment=#SWIG_FromCharPtrAndSize)
|
%typemap(out,fragment=#SWIG_FromCharPtrAndSize)
|
||||||
Char [ANY], const Char[ANY]
|
Char [ANY], const Char[ANY]
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
}
|
}
|
||||||
$1 = %reinterpret_cast(argp, $ltype);
|
$1 = %reinterpret_cast(argp, $ltype);
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(freearg) SWIGTYPE *, SWIGTYPE [] "";
|
%typemap(freearg) SWIGTYPE *, SWIGTYPE [] "";
|
||||||
|
|
||||||
%typemap(in, noblock=1) SWIGTYPE* const& (void *argp, $*ltype temp) {
|
%typemap(in, noblock=1) SWIGTYPE* const& (void *argp, $*ltype temp) {
|
||||||
|
|
@ -19,6 +18,7 @@
|
||||||
temp = %reinterpret_cast(argp, $*ltype);
|
temp = %reinterpret_cast(argp, $*ltype);
|
||||||
$1 = &temp;
|
$1 = &temp;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) SWIGTYPE* const& "";
|
||||||
|
|
||||||
/* Reference */
|
/* Reference */
|
||||||
%typemap(in, noblock=1) SWIGTYPE & (void *argp) {
|
%typemap(in, noblock=1) SWIGTYPE & (void *argp) {
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
if (!argp) { %argument_nullref("$type", $argnum); }
|
if (!argp) { %argument_nullref("$type", $argnum); }
|
||||||
$1 = %reinterpret_cast(argp, $ltype);
|
$1 = %reinterpret_cast(argp, $ltype);
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) SWIGTYPE& "";
|
||||||
|
|
||||||
/* By value */
|
/* By value */
|
||||||
%typemap(in,noblock=1) SWIGTYPE (void *argp) {
|
%typemap(in,noblock=1) SWIGTYPE (void *argp) {
|
||||||
|
|
@ -37,6 +38,7 @@
|
||||||
if (!argp) { %argument_nullref("$type", $argnum); }
|
if (!argp) { %argument_nullref("$type", $argnum); }
|
||||||
$1 = *(%reinterpret_cast(argp, $<ype));
|
$1 = *(%reinterpret_cast(argp, $<ype));
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) SWIGTYPE "";
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* --- Output arguments ---
|
* --- Output arguments ---
|
||||||
|
|
@ -327,6 +329,7 @@
|
||||||
%argument_fail(SWIG_TypeError,"$type",$argnum);
|
%argument_fail(SWIG_TypeError,"$type",$argnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) SWIGTYPE (CLASS::*) "";
|
||||||
|
|
||||||
%typemap(out,noblock=1) SWIGTYPE (CLASS::*) {
|
%typemap(out,noblock=1) SWIGTYPE (CLASS::*) {
|
||||||
%set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor));
|
%set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor));
|
||||||
|
|
@ -361,6 +364,7 @@
|
||||||
%argument_fail(SWIG_TypeError,"$type",$argnum);
|
%argument_fail(SWIG_TypeError,"$type",$argnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) SWIGTYPE ((*)(ANY)) "";
|
||||||
|
|
||||||
%typemap(out, noblock=1) SWIGTYPE ((*)(ANY)) {
|
%typemap(out, noblock=1) SWIGTYPE ((*)(ANY)) {
|
||||||
%set_output(SWIG_NewFunctionPtrObj((void *)($1), $descriptor));
|
%set_output(SWIG_NewFunctionPtrObj((void *)($1), $descriptor));
|
||||||
|
|
@ -378,6 +382,7 @@
|
||||||
/* VARARGS_SENTINEL typemap. Used by the %varargs directive. */
|
/* VARARGS_SENTINEL typemap. Used by the %varargs directive. */
|
||||||
|
|
||||||
%typemap(in,numinputs=0) SWIGTYPE *VARARGS_SENTINEL, SWIGTYPE VARARGS_SENTINEL "";
|
%typemap(in,numinputs=0) SWIGTYPE *VARARGS_SENTINEL, SWIGTYPE VARARGS_SENTINEL "";
|
||||||
|
%typemap(freearg) SWIGTYPE *VARARGS_SENTINEL, SWIGTYPE VARARGS_SENTINEL "";
|
||||||
|
|
||||||
|
|
||||||
/* DISOWN typemap */
|
/* DISOWN typemap */
|
||||||
|
|
@ -387,6 +392,7 @@
|
||||||
%argument_fail(SWIG_TypeError,"$type", $argnum);
|
%argument_fail(SWIG_TypeError,"$type", $argnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) SWIGTYPE *DISOWN "";
|
||||||
|
|
||||||
%typemap(varin,noblock=1) SWIGTYPE *DISOWN {
|
%typemap(varin,noblock=1) SWIGTYPE *DISOWN {
|
||||||
void *temp = 0;
|
void *temp = 0;
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@
|
||||||
}
|
}
|
||||||
$1 = %static_cast(val,$ltype);
|
$1 = %static_cast(val,$ltype);
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) Type "";
|
||||||
%typemap(in,noblock=1,fragment=frag) const Type & ($*ltype temp, Type val, int ecode = 0) {
|
%typemap(in,noblock=1,fragment=frag) const Type & ($*ltype temp, Type val, int ecode = 0) {
|
||||||
ecode = asval_meth($input, &val);
|
ecode = asval_meth($input, &val);
|
||||||
if (ecode != SWIG_OK) {
|
if (ecode != SWIG_OK) {
|
||||||
|
|
@ -46,6 +47,7 @@
|
||||||
temp = %static_cast(val, $*ltype);
|
temp = %static_cast(val, $*ltype);
|
||||||
$1 = &temp;
|
$1 = &temp;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) const Type& "";
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
/* out */
|
/* out */
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
%argument_fail(SWIG_TypeError, "$type", $argnum);
|
%argument_fail(SWIG_TypeError, "$type", $argnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(freearg) void * "";
|
%typemap(freearg) void * "";
|
||||||
|
|
||||||
%typemap(in,noblock=1) void * const& ($*ltype temp) {
|
%typemap(in,noblock=1) void * const& ($*ltype temp) {
|
||||||
|
|
@ -18,6 +17,7 @@
|
||||||
}
|
}
|
||||||
$1 = &temp;
|
$1 = &temp;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) void * const& "";
|
||||||
|
|
||||||
|
|
||||||
/* out */
|
/* out */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue