Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / share / swig / 1.3.26 / java / std_string.i
CommitLineData
920dae64
AT
1//
2// SWIG typemaps for std::string
3// Luigi Ballabio, Tal Shalif and William Fulton
4// May 7, 2002
5//
6// Java implementation
7//
8/* ------------------------------------------------------------------------
9 Typemaps for std::string and const std::string&
10 These are mapped to a Java String and are passed around by value.
11
12 To use non-const std::string references use the following %apply. Note
13 that they are passed by value.
14 %apply const std::string & {std::string &};
15 ------------------------------------------------------------------------ */
16
17%{
18#include <string>
19%}
20
21namespace std {
22
23class string;
24
25// string
26%typemap(jni) string "jstring"
27%typemap(jtype) string "String"
28%typemap(jstype) string "String"
29%typemap(javadirectorin) string "$jniinput"
30%typemap(javadirectorout) string "$javacall"
31
32%typemap(in) string
33%{if(!$input) {
34 SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string");
35 return $null;
36 }
37 const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
38 if (!$1_pstr) return $null;
39 $1 = std::string($1_pstr);
40 jenv->ReleaseStringUTFChars($input, $1_pstr); %}
41
42%typemap(directorout) string
43%{if(!$input) {
44 SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string");
45 return $null;
46 }
47 const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
48 if (!$1_pstr) return $null;
49 $1 = std::string($1_pstr);
50 jenv->ReleaseStringUTFChars($input, $1_pstr); %}
51
52%typemap(directorin,descriptor="Ljava/lang/String;") string
53%{ $input = jenv->NewStringUTF($1.c_str()); %}
54
55%typemap(out) string
56%{ $result = jenv->NewStringUTF($1.c_str()); %}
57
58%typemap(javain) string "$javainput"
59
60%typemap(javaout) string {
61 return $jnicall;
62 }
63
64%typemap(typecheck) string = char *;
65
66%typemap(throws) string %{
67 SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.c_str());
68 return $null;
69%}
70
71// const string &
72%typemap(jni) const string & "jstring"
73%typemap(jtype) const string & "String"
74%typemap(jstype) const string & "String"
75%typemap(javadirectorin) const string & "$jniinput"
76%typemap(javadirectorout) const string & "$javacall"
77
78%typemap(in) const string &
79%{if(!$input) {
80 SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string");
81 return $null;
82 }
83 const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
84 if (!$1_pstr) return $null;
85 std::string $1_str($1_pstr);
86 $1 = &$1_str;
87 jenv->ReleaseStringUTFChars($input, $1_pstr); %}
88
89%typemap(directorout,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const string &
90%{if(!$input) {
91 SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string");
92 return $null;
93 }
94 const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
95 if (!$1_pstr) return $null;
96 /* possible thread/reentrant code problem */
97 static std::string $1_str($1_pstr);
98 $1 = &$1_str;
99 jenv->ReleaseStringUTFChars($input, $1_pstr); %}
100
101%typemap(directorin,descriptor="Ljava/lang/String;") const string &
102%{ $input = jenv->NewStringUTF($1.c_str()); %}
103
104%typemap(out) const string &
105%{ $result = jenv->NewStringUTF($1->c_str()); %}
106
107%typemap(javain) const string & "$javainput"
108
109%typemap(javaout) const string & {
110 return $jnicall;
111 }
112
113%typemap(typecheck) const string & = char *;
114
115%typemap(throws) const string & %{
116 SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.c_str());
117 return $null;
118%}
119
120}
121