diff options
-rw-r--r-- | Examples/test-suite/csharp/director_wstring_runme.cs | 21 | ||||
-rw-r--r-- | Examples/test-suite/director_wstring.i | 13 | ||||
-rw-r--r-- | Lib/csharp/std_wstring.i | 6 |
3 files changed, 29 insertions, 11 deletions
diff --git a/Examples/test-suite/csharp/director_wstring_runme.cs b/Examples/test-suite/csharp/director_wstring_runme.cs index 6f97dcb50..fcb6e7afa 100644 --- a/Examples/test-suite/csharp/director_wstring_runme.cs +++ b/Examples/test-suite/csharp/director_wstring_runme.cs @@ -17,10 +17,19 @@ public class runme if (b.get_first() != "hello world!") throw new ApplicationException("Incorrect get_first:" + b.get_first()); + /* b.call_process_func(); - if (b.smem != "hello") throw new ApplicationException("Incorrect smem:" + b.smem); + */ + + b.call_process_wstring_func(); + if (b.smem != "hello (wstring)") + throw new ApplicationException("Incorrect smem:" + b.smem); + + b.call_process_wstring_ref_func(); + if (b.smem != "hello (wstring ref)") + throw new ApplicationException("Incorrect smem:" + b.smem); } } @@ -38,4 +47,12 @@ class director_wstring_B : A { this.smem = s; } -}
\ No newline at end of file + public override void process_wstring_text(String s) + { + this.smem = s + " (wstring)"; + } + public override void process_wstring_ref_text(String s) + { + this.smem = s + " (wstring ref)"; + } +} diff --git a/Examples/test-suite/director_wstring.i b/Examples/test-suite/director_wstring.i index 73900ccf6..10dd032d0 100644 --- a/Examples/test-suite/director_wstring.i +++ b/Examples/test-suite/director_wstring.i @@ -41,13 +41,12 @@ struct A #if !defined(SWIGCSHARP) - virtual void process_text(const wchar_t *text) - { - } + virtual void process_text(const wchar_t *text) {} #else - virtual void process_text(const std::wstring& text) - { - } +// temp until wchar_t* fixed + virtual void process_text(std::wstring text) {} + virtual void process_wstring_text(std::wstring text) {} + virtual void process_wstring_ref_text(const std::wstring& text) {} #endif virtual std::wstring multiple_params_val(const std::wstring& p1, const std::wstring& p2, std::wstring p3, std::wstring p4) const @@ -57,6 +56,8 @@ struct A { return get_first(); } void call_process_func() { process_text(L"hello"); } + void call_process_wstring_func() { process_wstring_text(L"hello"); } + void call_process_wstring_ref_func() { process_wstring_ref_text(L"hello"); } }; %} diff --git a/Lib/csharp/std_wstring.i b/Lib/csharp/std_wstring.i index d45471014..1d10ca808 100644 --- a/Lib/csharp/std_wstring.i +++ b/Lib/csharp/std_wstring.i @@ -70,7 +70,7 @@ class wstring; SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); return $null; } - $result.assign($input); %} + $result = Swig_csharp_UTF16ToWString($input); %} %typemap(directorin) wstring %{ $input = SWIG_csharp_wstring_with_length_callback($1.c_str(), (int)$1.size()); %} @@ -121,10 +121,10 @@ class wstring; } /* possible thread/reentrant code problem */ static std::wstring $1_str; - $1_str = $input; + $1_str = Swig_csharp_UTF16ToWString($input); $result = &$1_str; %} -%typemap(directorin) const wstring & %{ $input = SWIG_csharp_wstring_with_length_callback($1.c_str(), (int)$1->size()); %} +%typemap(directorin) const wstring & %{ $input = SWIG_csharp_wstring_with_length_callback($1.c_str(), (int)$1.size()); %} %typemap(csvarin, excode=SWIGEXCODE2) const wstring & %{ set { |