summaryrefslogtreecommitdiff
path: root/share/swig/2.0.11/csharp/wchar.i
diff options
context:
space:
mode:
authorVince Harron <vharron@google.com>2015-06-02 18:58:48 -0700
committerVince Harron <vharron@google.com>2015-06-02 18:58:48 -0700
commitb46a6ee1ee38582dd3af57ebe1b6d5e4158c34e0 (patch)
treeb342a62eea47f607a7c0846c731bf151c1503359 /share/swig/2.0.11/csharp/wchar.i
parent6c85ed3bdac5c6dd65ad8cef83fc4fc7ef99a6c9 (diff)
downloadlinux-x86-b46a6ee1ee38582dd3af57ebe1b6d5e4158c34e0.tar.gz
Diffstat (limited to 'share/swig/2.0.11/csharp/wchar.i')
-rw-r--r--share/swig/2.0.11/csharp/wchar.i102
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 *;
+