Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / share / swig / 1.3.26 / python / std_string.i
CommitLineData
920dae64
AT
1//
2// std::string
3//
4
5#ifndef SWIG_STD_BASIC_STRING
6#define SWIG_STD_STRING
7
8%{
9#include <string>
10%}
11
12%include <pystrings.swg>
13
14namespace std
15{
16 class string;
17}
18
19
20/* defining the std::string asptr/from methods */
21
22
23%fragment(SWIG_AsPtr_frag(std::string),"header",
24 fragment="SWIG_AsCharPtrAndSize") {
25 SWIGINTERN int
26 SWIG_AsPtr(std::string)(PyObject* obj, std::string **val)
27 {
28 static swig_type_info* string_info = SWIG_TypeQuery("std::string *");
29 std::string *vptr;
30 if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) != -1) {
31 if (val) *val = vptr;
32 return SWIG_OLDOBJ;
33 } else {
34 PyErr_Clear();
35 char* buf = 0 ; size_t size = 0;
36 if (SWIG_AsCharPtrAndSize(obj, &buf, &size)) {
37 if (buf) {
38 if (val) *val = new std::string(buf, size - 1);
39 return SWIG_NEWOBJ;
40 }
41 } else {
42 PyErr_Clear();
43 }
44 if (val) {
45 PyErr_SetString(PyExc_TypeError,"a string is expected");
46 }
47 return 0;
48 }
49 }
50}
51
52%fragment(SWIG_From_frag(std::string),"header",
53 fragment="SWIG_FromCharArray") {
54SWIGINTERNINLINE PyObject*
55 SWIG_From(std::string)(const std::string& s)
56 {
57 return SWIG_FromCharArray(s.data(), s.size());
58 }
59}
60
61%fragment(SWIG_AsVal_frag(std::string),"header",
62 fragment=SWIG_AsPtr_frag(std::string)) {
63SWIGINTERN int
64 SWIG_AsVal(std::string)(PyObject* obj, std::string *val)
65 {
66 std::string* s;
67 int res = SWIG_AsPtr(std::string)(obj, &s);
68 if ((res != 0) && s) {
69 if (val) *val = *s;
70 if (res == SWIG_NEWOBJ) delete s;
71 return res;
72 }
73 if (val) {
74 PyErr_SetString(PyExc_TypeError,"a string is expected");
75 }
76 return 0;
77 }
78}
79
80%typemap_asptrfromn(SWIG_CCode(STRING), std::string);
81
82#else
83
84%include <std/std_string.i>
85
86#endif