/tags/ttn-post-libtool-1-4-3-upgrade/SWIG/Lib/mzscheme/std_string.i
Swig | 56 lines | 41 code | 14 blank | 1 comment | 0 complexity | 51ee64101643b0ad79c70147558aef78 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
1//
2// SWIG typemaps for std::string types
3// Luigi Ballabio
4// Apr 8, 2002
5//
6// MzScheme implementation
7
8// ------------------------------------------------------------------------
9// std::string is typemapped by value
10// This can prevent exporting methods which return a string
11// in order for the user to modify it.
12// However, I think I'll wait until someone asks for it...
13// ------------------------------------------------------------------------
14
15%include exception.i
16
17%{
18#include <string>
19%}
20
21namespace std {
22
23 class string;
24
25 /* Overloading check */
26
27 %typemap(typecheck) string = char *;
28 %typemap(typecheck) const string & = char *;
29
30 %typemap(in) string {
31 if (SCHEME_STRINGP($input))
32 $1 = std::string(SCHEME_STR_VAL($input));
33 else
34 SWIG_exception(SWIG_TypeError, "string expected");
35 }
36
37 %typemap(in) const string & (std::string temp) {
38 if (SCHEME_STRINGP($input)) {
39 temp = std::string(SCHEME_STR_VAL($input));
40 $1 = &temp;
41 } else {
42 SWIG_exception(SWIG_TypeError, "string expected");
43 }
44 }
45
46 %typemap(out) string {
47 $result = scheme_make_string($1.c_str());
48 }
49
50 %typemap(out) const string & {
51 $result = scheme_make_string($1->c_str());
52 }
53
54}
55
56