mirror of https://github.com/swig/swig
Add C# wchar_t * director typemaps
More Python std::wstring directors Python testing
This commit is contained in:
parent
751d443046
commit
bb39235c9c
|
@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.1.0 (in progress)
|
||||
===========================
|
||||
|
||||
2022-05-04: wsfulton
|
||||
[C#] Add C# wchar_t * director typemaps
|
||||
|
||||
2022-04-20: cminyard
|
||||
Fix an issue where newlines were not properly generated
|
||||
for godirectorin typemaps. If you have a virtual function
|
||||
|
|
|
@ -17,11 +17,9 @@ 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)")
|
||||
|
|
|
@ -39,15 +39,11 @@ struct A
|
|||
|
||||
std::vector<std::wstring> m_strings;
|
||||
|
||||
virtual const wchar_t * wchar_out() { return L"ciao"; }
|
||||
|
||||
#if !defined(SWIGCSHARP)
|
||||
virtual void process_text(const wchar_t *text) {}
|
||||
#else
|
||||
// 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
|
||||
{ return get_first(); }
|
||||
|
|
|
@ -12,6 +12,12 @@ class B(A):
|
|||
def process_text(self, s):
|
||||
self.smem = s
|
||||
|
||||
def process_wstring_text(self, s):
|
||||
self.smem = s + " (wstring)"
|
||||
|
||||
def process_wstring_ref_text(self, s):
|
||||
self.smem = s + " (wstring ref)"
|
||||
|
||||
|
||||
b = B("hello")
|
||||
|
||||
|
@ -24,3 +30,13 @@ b.call_process_func()
|
|||
|
||||
if b.smem != "hello":
|
||||
raise RuntimeError("smem: {}".format(smem))
|
||||
|
||||
b.call_process_wstring_func()
|
||||
|
||||
if b.smem != "hello (wstring)":
|
||||
raise RuntimeError("smem: {}".format(smem))
|
||||
|
||||
b.call_process_wstring_ref_func()
|
||||
|
||||
if b.smem != "hello (wstring ref)":
|
||||
raise RuntimeError("smem: {}".format(smem))
|
||||
|
|
|
@ -211,9 +211,13 @@ static void Swig_csharp_UTF16ToWCharPtrFree(wchar_t *str) {
|
|||
%typemap(ctype, out="void *") wchar_t * "unsigned short *"
|
||||
%typemap(imtype,
|
||||
inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
|
||||
outattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]"
|
||||
outattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
|
||||
directorinattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
|
||||
directoroutattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]"
|
||||
) wchar_t * "string"
|
||||
%typemap(cstype) wchar_t * "string"
|
||||
%typemap(csdirectorin) wchar_t * "$iminput"
|
||||
%typemap(csdirectorout) wchar_t * "$cscall"
|
||||
|
||||
%typemap(csin) wchar_t * "$csinput"
|
||||
%typemap(csout, excode=SWIGEXCODE) wchar_t * {
|
||||
|
@ -238,6 +242,11 @@ static void Swig_csharp_UTF16ToWCharPtrFree(wchar_t *str) {
|
|||
%typemap(freearg, fragment="Swig_csharp_UTF16ToWCharPtrFree") wchar_t *
|
||||
%{ Swig_csharp_UTF16ToWCharPtrFree($1); %}
|
||||
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) wchar_t *
|
||||
%{ $result = Swig_csharp_UTF16ToWCharPtr($input); %}
|
||||
|
||||
%typemap(directorin) wchar_t * %{ $input = SWIG_csharp_wstring_with_length_callback($1, (int)wcslen($1)); %}
|
||||
|
||||
%typemap(typecheck) wchar_t * = char *;
|
||||
|
||||
%typemap(throws, canthrow=1, fragment="<wchar.h>") wchar_t *
|
||||
|
|
Loading…
Reference in New Issue