Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / share / swig / 1.3.26 / tcl / std_string.i
CommitLineData
920dae64
AT
1//
2// SWIG typemaps for std::string
3// Luigi Ballabio and Manu ???
4// Apr 26, 2002
5//
6// Tcl implementation
7
8
9// ------------------------------------------------------------------------
10// std::string is typemapped by value
11// This can prevent exporting methods which return a string
12// in order for the user to modify it.
13// However, I think I'll wait until someone asks for it...
14// ------------------------------------------------------------------------
15
16%include exception.i
17
18%{
19#include <string>
20%}
21
22namespace std {
23
24 class string;
25
26 /* Overloading check */
27 %typemap(typecheck) string = char *;
28 %typemap(typecheck) const string & = char *;
29
30 %typemap(in) string {
31 $1 = std::string(Tcl_GetStringFromObj($input,NULL));
32 }
33
34 %typemap(in) const string & (std::string temp) {
35 temp = std::string(Tcl_GetStringFromObj($input,NULL));
36 $1 = &temp;
37 }
38
39 %typemap(out) string {
40 Tcl_SetStringObj($result,(char*)$1.c_str(),$1.length());
41 }
42
43 %typemap(out) const string & {
44 Tcl_SetStringObj($result,(char*)$1->c_str(),$1->length());
45 }
46
47 %typemap(throws) string {
48 Tcl_SetObjResult(interp, Tcl_NewStringObj((char*) $1.c_str(), -1));
49 SWIG_fail;
50 }
51
52 %typemap(throws) const string & {
53 Tcl_SetObjResult(interp, Tcl_NewStringObj((char*) $1.c_str(), -1));
54 SWIG_fail;
55 }
56}