Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / share / swig / 1.3.26 / mzscheme / std_string.i
CommitLineData
920dae64
AT
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