diff options
author | Vince Harron <vharron@google.com> | 2015-06-02 18:58:48 -0700 |
---|---|---|
committer | Vince Harron <vharron@google.com> | 2015-06-02 18:58:48 -0700 |
commit | b46a6ee1ee38582dd3af57ebe1b6d5e4158c34e0 (patch) | |
tree | b342a62eea47f607a7c0846c731bf151c1503359 /share/swig/2.0.11/csharp/wchar.i | |
parent | 6c85ed3bdac5c6dd65ad8cef83fc4fc7ef99a6c9 (diff) | |
download | linux-x86-b46a6ee1ee38582dd3af57ebe1b6d5e4158c34e0.tar.gz |
Adding binaries for 2.0.11HEADstudio-master-dev_before_27917934studio-master-dev_before_26911779studio-3.1.2studio-2.3studio-2.0-rc1studio-2.0studio-1.5studio-1.4gradle_3.1.2gradle_2.3.0gradle_2.0.0studio-master-releasestudio-1.4-releasestudio-1.4-devstudio-1.3-releasestudio-1.3-devmastermain
Diffstat (limited to 'share/swig/2.0.11/csharp/wchar.i')
-rw-r--r-- | share/swig/2.0.11/csharp/wchar.i | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/share/swig/2.0.11/csharp/wchar.i b/share/swig/2.0.11/csharp/wchar.i new file mode 100644 index 0000000..1d95edd --- /dev/null +++ b/share/swig/2.0.11/csharp/wchar.i @@ -0,0 +1,102 @@ +/* ----------------------------------------------------------------------------- + * wchar.i + * + * Typemaps for the wchar_t type + * These are mapped to a C# String and are passed around by value. + * + * Support code for wide strings can be turned off by defining SWIG_CSHARP_NO_WSTRING_HELPER + * + * ----------------------------------------------------------------------------- */ + +#if !defined(SWIG_CSHARP_NO_WSTRING_HELPER) +#if !defined(SWIG_CSHARP_WSTRING_HELPER_) +#define SWIG_CSHARP_WSTRING_HELPER_ +%insert(runtime) %{ +/* Callback for returning strings to C# without leaking memory */ +typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *); +static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL; +%} + +%pragma(csharp) imclasscode=%{ + protected class SWIGWStringHelper { + + public delegate string SWIGWStringDelegate(IntPtr message); + static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString); + + [DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")] + public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate); + + static string CreateWString([MarshalAs(UnmanagedType.LPWStr)]IntPtr cString) { + return System.Runtime.InteropServices.Marshal.PtrToStringUni(cString); + } + + static SWIGWStringHelper() { + SWIGRegisterWStringCallback_$module(wstringDelegate); + } + } + + static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper(); +%} + +%insert(runtime) %{ +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback) { + SWIG_csharp_wstring_callback = callback; +} +%} +#endif // SWIG_CSHARP_WSTRING_HELPER_ +#endif // SWIG_CSHARP_NO_WSTRING_HELPER + + +// wchar_t +%typemap(ctype) wchar_t "wchar_t" +%typemap(imtype) wchar_t "char" +%typemap(cstype) wchar_t "char" + +%typemap(csin) wchar_t "$csinput" +%typemap(csout, excode=SWIGEXCODE) wchar_t { + char ret = $imcall;$excode + return ret; + } +%typemap(csvarin, excode=SWIGEXCODE2) wchar_t %{ + set { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) wchar_t %{ + get { + char ret = $imcall;$excode + return ret; + } %} + +%typemap(in) wchar_t %{ $1 = ($1_ltype)$input; %} +%typemap(out) wchar_t %{ $result = (wchar_t)$1; %} + +%typemap(typecheck) wchar_t = char; + +// wchar_t * +%typemap(ctype) wchar_t * "wchar_t *" +%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]", out="IntPtr" ) wchar_t * "string" +%typemap(cstype) wchar_t * "string" + +%typemap(csin) wchar_t * "$csinput" +%typemap(csout, excode=SWIGEXCODE) wchar_t * { + string ret = System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode + return ret; + } +%typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{ + set { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{ + get { + string ret = $imcall;$excode + return ret; + } %} + +%typemap(in) wchar_t * %{ $1 = ($1_ltype)$input; %} +%typemap(out) wchar_t * %{ $result = (wchar_t *)$1; %} + +%typemap(typecheck) wchar_t * = char *; + |