Fixes for %apply char *, char[], char[ANY] to other types, like unsigned char

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9462 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2006-10-19 21:35:19 +00:00
commit 1247cd7cc5
3 changed files with 36 additions and 36 deletions

View file

@ -371,11 +371,11 @@
%typemap(out) SWIGTYPE [] %{ $result = $1; %}
/* char arrays - treat as String */
%typemap(in) char[ANY], char[] %{ $1 = $input; %}
%typemap(out) char[ANY], char[] %{ $result = SWIG_csharp_string_callback($1); %}
%typemap(in) char[ANY], char[] %{ $1 = ($1_ltype)$input; %}
%typemap(out) char[ANY], char[] %{ $result = SWIG_csharp_string_callback((const char *)$1); %}
%typemap(directorout) char[ANY], char[] %{ $1 = $input; %}
%typemap(directorin) char[ANY], char[] %{ $input = SWIG_csharp_string_callback($1); %}
%typemap(directorout) char[ANY], char[] %{ $1 = ($1_ltype)$input; %}
%typemap(directorin) char[ANY], char[] %{ $input = SWIG_csharp_string_callback((const char *)$1); %}
%typemap(csdirectorin) char[ANY], char[] "$iminput"
%typemap(csdirectorout) char[ANY], char[] "$cscall"

View file

@ -353,16 +353,16 @@ namespace std {
%typemap(memberin) char * {
if ($1) delete [] $1;
if ($input) {
$1 = ($1_type) (new char[strlen($input)+1]);
strcpy((char *) $1,$input);
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
strcpy((char *)$1, (const char *)$input);
} else {
$1 = 0;
}
}
%typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
if ($input) {
$1 = ($1_type) (new char[strlen($input)+1]);
strcpy((char *) $1,$input);
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
strcpy((char *)$1, (const char *)$input);
} else {
$1 = 0;
}
@ -370,51 +370,51 @@ namespace std {
%typemap(globalin) char * {
if ($1) delete [] $1;
if ($input) {
$1 = ($1_type) (new char[strlen($input)+1]);
strcpy((char *) $1,$input);
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
strcpy((char *)$1, (const char *)$input);
} else {
$1 = 0;
}
}
%typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
if ($input) {
$1 = ($1_type) (new char[strlen($input)+1]);
strcpy((char *) $1,$input);
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
strcpy((char *)$1, (const char *)$input);
} else {
$1 = 0;
}
}
#else
%typemap(memberin) char * {
if ($1) free((char*)$1);
if ($1) free((char *)$1);
if ($input) {
$1 = ($1_type) malloc(strlen($input)+1);
strcpy((char*)$1,$input);
$1 = ($1_type) malloc(strlen((const char *)$input)+1);
strcpy((char *)$1, (const char *)$input);
} else {
$1 = 0;
}
}
%typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
if ($input) {
$1 = ($1_type) malloc(strlen($input)+1);
strcpy((char*)$1,$input);
$1 = ($1_type) malloc(strlen((const char *)$input)+1);
strcpy((char *)$1, (const char *)$input);
} else {
$1 = 0;
}
}
%typemap(globalin) char * {
if ($1) free((char*)$1);
if ($1) free((char *)$1);
if ($input) {
$1 = ($1_type) malloc(strlen($input)+1);
strcpy((char*)$1,$input);
$1 = ($1_type) malloc(strlen((const char *)$input)+1);
strcpy((char *)$1, (const char *)$input);
} else {
$1 = 0;
}
}
%typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
if ($input) {
$1 = ($1_type) malloc(strlen($input)+1);
strcpy((char*)$1,$input);
$1 = ($1_type) malloc(strlen((const char *)$input)+1);
strcpy((char *)$1, (const char *)$input);
} else {
$1 = 0;
}
@ -425,22 +425,22 @@ namespace std {
/* Character array handling */
%typemap(memberin) char [ANY] {
if ($input) strncpy($1,$input,$1_dim0);
if ($input) strncpy((char *)$1, (const char *)$input, $1_dim0);
else $1[0] = 0;
}
%typemap(globalin) char [ANY] {
if ($input) strncpy($1,$input,$1_dim0);
if ($input) strncpy((char *)$1, (const char *)$input, $1_dim0);
else $1[0] = 0;
}
%typemap(memberin) char [] {
if ($input) strcpy($1,$input);
if ($input) strcpy((char *)$1, (const char *)$input);
else $1[0] = 0;
}
%typemap(globalin) char [] {
if ($input) strcpy($1,$input);
if ($input) strcpy((char *)$1, (const char *)$input);
else $1[0] = 0;
}

View file

@ -79,7 +79,7 @@
if (alloc == SWIG_NEWOBJ) {
$1 = cptr;
} else {
$1 = csize ? %new_copy_array(cptr, csize, Char) : 0;
$1 = csize ? ($1_type)%new_copy_array(cptr, csize, Char) : 0;
}
}
@ -92,7 +92,7 @@
if (alloc == SWIG_NEWOBJ) {
$1 = cptr;
} else {
$1 = csize ? %new_copy_array(cptr, csize, Char) : 0;
$1 = csize ? ($1_type)%new_copy_array(cptr, csize, Char) : 0;
}
}
@ -107,8 +107,8 @@
%typemap(memberin,noblock=1) Char * {
if ($1) %delete_array($1);
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
$1 = %new_copy_array($input, size, Char);
size_t size = SWIG_CharPtrLen(%reinterpret_cast($input, const Char *)) + 1;
$1 = ($1_type)%new_copy_array(%reinterpret_cast($input, const Char *), size, Char);
} else {
$1 = 0;
}
@ -116,8 +116,8 @@
%typemap(memberin,noblock=1,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * {
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
$1 = %new_copy_array($input, size, Char);
size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1;
$1 = ($1_type)%new_copy_array($input, size, Char);
} else {
$1 = 0;
}
@ -128,8 +128,8 @@
%typemap(globalin,noblock=1) Char * {
if ($1) %delete_array($1);
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
$1 = %new_copy_array($input, size, Char);
size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1;
$1 = ($1_type)%new_copy_array($input, size, Char);
} else {
$1 = 0;
}
@ -138,7 +138,7 @@
%typemap(globalin,noblock=1,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * {
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
$1 = %new_copy_array($input, size, Char);
$1 = ($1_type)%new_copy_array($input, size, Char);
} else {
$1 = 0;
}
@ -263,7 +263,7 @@
if (!SWIG_IsOK(res)) {
%argument_fail(res,"$type",$symname, $argnum);
}
$1 = temp;
$1 = %reinterpret_cast(temp, $1_ltype);
}
%typemap(freearg) Char [ANY], const Char [ANY] "";