dos to unix fileformatting

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12261 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-10-07 06:06:12 +00:00
commit a4a56acd33

View file

@ -1,102 +1,102 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* wchar.i * wchar.i
* *
* Typemaps for the wchar_t type * Typemaps for the wchar_t type
* These are mapped to a C# String and are passed around by value. * 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 * 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_NO_WSTRING_HELPER)
#if !defined(SWIG_CSHARP_WSTRING_HELPER_) #if !defined(SWIG_CSHARP_WSTRING_HELPER_)
#define SWIG_CSHARP_WSTRING_HELPER_ #define SWIG_CSHARP_WSTRING_HELPER_
%insert(runtime) %{ %insert(runtime) %{
/* Callback for returning strings to C# without leaking memory */ /* Callback for returning strings to C# without leaking memory */
typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *); typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *);
static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL; static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL;
%} %}
%pragma(csharp) imclasscode=%{ %pragma(csharp) imclasscode=%{
protected class SWIGWStringHelper { protected class SWIGWStringHelper {
public delegate string SWIGWStringDelegate(IntPtr message); public delegate string SWIGWStringDelegate(IntPtr message);
static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString); static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString);
[DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")] [DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")]
public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate); public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate);
static string CreateWString([MarshalAs(UnmanagedType.LPWStr)]IntPtr cString) { static string CreateWString([MarshalAs(UnmanagedType.LPWStr)]IntPtr cString) {
return System.Runtime.InteropServices.Marshal.PtrToStringUni(cString); return System.Runtime.InteropServices.Marshal.PtrToStringUni(cString);
} }
static SWIGWStringHelper() { static SWIGWStringHelper() {
SWIGRegisterWStringCallback_$module(wstringDelegate); SWIGRegisterWStringCallback_$module(wstringDelegate);
} }
} }
static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper(); static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper();
%} %}
%insert(runtime) %{ %insert(runtime) %{
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback) { SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback) {
SWIG_csharp_wstring_callback = callback; SWIG_csharp_wstring_callback = callback;
} }
%} %}
#endif // SWIG_CSHARP_WSTRING_HELPER_ #endif // SWIG_CSHARP_WSTRING_HELPER_
#endif // SWIG_CSHARP_NO_WSTRING_HELPER #endif // SWIG_CSHARP_NO_WSTRING_HELPER
// wchar_t // wchar_t
%typemap(ctype) wchar_t "wchar_t" %typemap(ctype) wchar_t "wchar_t"
%typemap(imtype) wchar_t "char" %typemap(imtype) wchar_t "char"
%typemap(cstype) wchar_t "char" %typemap(cstype) wchar_t "char"
%typemap(csin) wchar_t "$csinput" %typemap(csin) wchar_t "$csinput"
%typemap(csout, excode=SWIGEXCODE) wchar_t { %typemap(csout, excode=SWIGEXCODE) wchar_t {
char ret = $imcall;$excode char ret = $imcall;$excode
return ret; return ret;
} }
%typemap(csvarin, excode=SWIGEXCODE2) wchar_t %{ %typemap(csvarin, excode=SWIGEXCODE2) wchar_t %{
set { set {
$imcall;$excode $imcall;$excode
} %} } %}
%typemap(csvarout, excode=SWIGEXCODE2) wchar_t %{ %typemap(csvarout, excode=SWIGEXCODE2) wchar_t %{
get { get {
char ret = $imcall;$excode char ret = $imcall;$excode
return ret; return ret;
} %} } %}
%typemap(in) wchar_t %{ $1 = ($1_ltype)$input; %} %typemap(in) wchar_t %{ $1 = ($1_ltype)$input; %}
%typemap(out) wchar_t %{ $result = (wchar_t)$1; %} %typemap(out) wchar_t %{ $result = (wchar_t)$1; %}
%typemap(typecheck) wchar_t = char; %typemap(typecheck) wchar_t = char;
// wchar_t * // wchar_t *
%typemap(ctype) wchar_t * "wchar_t *" %typemap(ctype) wchar_t * "wchar_t *"
%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]", out="IntPtr" ) wchar_t * "string" %typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]", out="IntPtr" ) wchar_t * "string"
%typemap(cstype) wchar_t * "string" %typemap(cstype) wchar_t * "string"
%typemap(csin) wchar_t * "$csinput" %typemap(csin) wchar_t * "$csinput"
%typemap(csout, excode=SWIGEXCODE) wchar_t * { %typemap(csout, excode=SWIGEXCODE) wchar_t * {
string ret = System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode string ret = System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode
return ret; return ret;
} }
%typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{ %typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{
set { set {
$imcall;$excode $imcall;$excode
} %} } %}
%typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{ %typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{
get { get {
string ret = $imcall;$excode string ret = $imcall;$excode
return ret; return ret;
} %} } %}
%typemap(in) wchar_t * %{ $1 = ($1_ltype)$input; %} %typemap(in) wchar_t * %{ $1 = ($1_ltype)$input; %}
%typemap(out) wchar_t * %{ $result = (wchar_t *)$1; %} %typemap(out) wchar_t * %{ $result = (wchar_t *)$1; %}
%typemap(typecheck) wchar_t * = char *; %typemap(typecheck) wchar_t * = char *;