1
// SWIG typemaps for std::string
2
// copied from the guile std_string.i and modified
10
%insert(closprefix) %{ (declare (hide <std-string>)) %}
12
%rename("std-string") string;
21
#define std_string_str_get(s) ((char *)((s)->c_str()))
22
#define std_string_str_set(s,v) (s->assign((char *)(v)))
25
%typemap(typecheck) string = char *;
26
%typemap(typecheck) const string & = char *;
28
%typemap(in) string (char* tempptr) {
29
if ($input == C_SCHEME_FALSE) {
32
if (!C_swig_is_string ($input)) {
33
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE,
34
"Argument #$argnum is not a string");
36
tempptr = SWIG_MakeString($input);
37
$1 = std::string(tempptr);
38
if (tempptr) SWIG_free(tempptr);
42
%typemap(in) const string& (std::string temp,
45
if ($input == C_SCHEME_FALSE) {
49
if (!C_swig_is_string ($input)) {
50
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE,
51
"Argument #$argnum is not a string");
53
tempptr = SWIG_MakeString($input);
54
temp = std::string(tempptr);
55
if (tempptr) SWIG_free(tempptr);
60
%typemap(out) string {
62
C_word *space = C_alloc (C_SIZEOF_STRING (size));
63
$result = C_string (&space, size, (char *) $1.c_str());
66
%typemap(out) const string& {
67
int size = $1->size();
68
C_word *space = C_alloc (C_SIZEOF_STRING (size));
69
$result = C_string (&space, size, (char *) $1->c_str());
72
%typemap(varin) string {
73
if ($input == C_SCHEME_FALSE) {
77
if (!C_swig_is_string ($input)) {
78
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE,
79
"Argument #$argnum is not a string");
81
tempptr = SWIG_MakeString($input);
82
$1 = std::string(tempptr);
83
if (tempptr) SWIG_free(tempptr);
87
%typemap(varout) string {
89
C_word *space = C_alloc (C_SIZEOF_STRING (size));
90
$result = C_string (&space, size, (char *) $1.c_str());