1 %module li_std_wstring 2 3 // The languages below are yet to provide std_wstring.i 4 #if !(defined(SWIGD) || defined(SWIGGO) || defined(SWIGGUILE) || defined(SWIGJAVASCRIPT) || defined(SWIGLUA) || defined(SWIGMZSCHEME) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL) || defined(SWIGPHP) || defined(SWIGR) || defined(SWIGSCILAB)) 5 6 %include <std_wstring.i> 7 8 // throw is invalid in C++17 and later, only SWIG to use it 9 #define TESTCASE_THROW1(T1) throw(T1) 10 %{ 11 #define TESTCASE_THROW1(T1) 12 %} 13 14 %inline %{ 15 #include <string> 16 test_wcvalue(wchar_t x)17wchar_t test_wcvalue(wchar_t x) { 18 return x; 19 } 20 test_ccvalue(const wchar_t * x)21const wchar_t* test_ccvalue(const wchar_t* x) { 22 return x; 23 } 24 test_cvalue(wchar_t * x)25wchar_t* test_cvalue(wchar_t* x) { 26 return x; 27 } 28 29 test_wchar_overload()30wchar_t* test_wchar_overload() { 31 return 0; 32 } 33 test_wchar_overload(wchar_t * x)34wchar_t* test_wchar_overload(wchar_t *x) { 35 return x; 36 } 37 test_value(std::wstring x)38std::wstring test_value(std::wstring x) { 39 return x; 40 } 41 test_const_reference(const std::wstring & x)42const std::wstring& test_const_reference(const std::wstring &x) { 43 return x; 44 } 45 test_pointer(std::wstring * x)46void test_pointer(std::wstring *x) { 47 } 48 test_const_pointer(const std::wstring * x)49void test_const_pointer(const std::wstring *x) { 50 } 51 test_reference(std::wstring & x)52void test_reference(std::wstring &x) { 53 } 54 test_equal_abc(const std::wstring & s)55bool test_equal_abc(const std::wstring &s) { 56 return L"abc" == s; 57 } 58 test_throw()59void test_throw() TESTCASE_THROW1(std::wstring){ 60 static std::wstring x = L"throwing test_throw"; 61 62 throw x; 63 } 64 non_utf8_c_str()65const char * non_utf8_c_str() { 66 return "h\xe9llo"; 67 } 68 size_wstring(const std::wstring & s)69size_t size_wstring(const std::wstring& s) { 70 return s.size(); 71 } 72 73 %} 74 75 #endif 76 77