swig/Lib/chicken/std_string.i
John Lenz 897e5ad40d Lots more bug fixes for the chicken module: almost the entire test-sutie now runs
The only tests that are failing are ones that depend on std_vector.i and similar


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7079 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-03-17 07:28:19 +00:00

58 lines
1.4 KiB
OpenEdge ABL

// SWIG typemaps for std::string
// copied from the guile std_string.i and modified
%{
#include <string>
%}
namespace std {
class string;
%typemap(typecheck) string = char *;
%typemap(typecheck) const string & = char *;
%typemap(in) string (char* tempptr) {
if ($input == C_SCHEME_FALSE) {
$1 = std::string();
} else {
if (!C_swig_is_string ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE,
"Argument #$argnum is not a string");
}
tempptr = SWIG_MakeString($input);
$1 = std::string(tempptr);
if (tempptr) SWIG_free(tempptr);
}
}
%typemap(in) const string& (std::string temp,
char* tempptr) {
if ($input == C_SCHEME_FALSE) {
temp = std::string();
$1 = &temp;
} else {
if (!C_swig_is_string ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE,
"Argument #$argnum is not a string");
}
tempptr = SWIG_MakeString($input);
temp = std::string(tempptr);
if (tempptr) SWIG_free(tempptr);
$1 = &temp;
}
}
%typemap(out) string {
int size = $1.size();
C_word *space = C_alloc (C_SIZEOF_STRING (size));
$result = C_string (&space, size, (char *) $1.c_str());
}
%typemap(out) const string& {
int size = $1->size();
C_word *space = C_alloc (C_SIZEOF_STRING (size));
$result = C_string (&space, size, (char *) $1->c_str());
}
}