From: William F. <wsf...@us...> - 2005-02-22 22:56:28
|
Update of /cvsroot/swig/SWIG/Lib/csharp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15682/Lib/csharp Modified Files: csharphead.swg csharp.swg enumsimple.swg enums.swg enumtypesafe.swg std_string.i Log Message: Wider range of C# exceptions to throw. More applicable exceptions in are thrown. Index: enums.swg =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/csharp/enums.swg,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** enums.swg 15 Feb 2005 22:02:22 -0000 1.9 --- enums.swg 22 Feb 2005 22:56:18 -0000 1.10 *************** *** 18,22 **** %typemap(throws, canthrow=1) const enum SWIGTYPE & %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpSystemException, "C++ $1_type exception thrown"); return $null; %} --- 18,22 ---- %typemap(throws, canthrow=1) const enum SWIGTYPE & %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} *************** *** 47,51 **** %typemap(throws, canthrow=1) enum SWIGTYPE %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpSystemException, "C++ $1_type exception thrown"); return $null; %} --- 47,51 ---- %typemap(throws, canthrow=1) enum SWIGTYPE %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} Index: enumsimple.swg =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/csharp/enumsimple.swg,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** enumsimple.swg 15 Feb 2005 22:02:22 -0000 1.9 --- enumsimple.swg 22 Feb 2005 22:56:18 -0000 1.10 *************** *** 20,24 **** %typemap(throws, canthrow=1) const enum SWIGTYPE & %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpSystemException, "C++ $1_type exception thrown"); return $null; %} --- 20,24 ---- %typemap(throws, canthrow=1) const enum SWIGTYPE & %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} *************** *** 49,53 **** %typemap(throws, canthrow=1) enum SWIGTYPE %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpSystemException, "C++ $1_type exception thrown"); return $null; %} --- 49,53 ---- %typemap(throws, canthrow=1) enum SWIGTYPE %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} Index: csharphead.swg =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/csharp/csharphead.swg,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** csharphead.swg 15 Feb 2005 21:59:46 -0000 1.14 --- csharphead.swg 22 Feb 2005 22:56:17 -0000 1.15 *************** *** 19,54 **** %insert(runtime) %{ ! /* Support for throwing C# exceptions from C/C++ */ typedef enum { ! SWIG_CSharpSystemException, ! SWIG_CSharpOutOfMemoryException, ! SWIG_CSharpIndexOutOfRangeException, SWIG_CSharpDivideByZeroException, ! SWIG_CSharpArgumentOutOfRangeException, ! SWIG_CSharpNullReferenceException } SWIG_CSharpExceptionCodes; typedef void (SWIGSTDCALL* SWIG_CSharpExceptionCallback_t)(const char *); typedef struct { SWIG_CSharpExceptionCodes code; SWIG_CSharpExceptionCallback_t callback; ! } SWIG_CSharpExceptions_t; ! static SWIG_CSharpExceptions_t SWIG_csharp_exceptions[] = { ! { SWIG_CSharpSystemException, NULL }, ! { SWIG_CSharpOutOfMemoryException, NULL }, ! { SWIG_CSharpIndexOutOfRangeException, NULL }, { SWIG_CSharpDivideByZeroException, NULL }, { SWIG_CSharpArgumentOutOfRangeException, NULL }, ! { SWIG_CSharpNullReferenceException, NULL } }; static void SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) { ! SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback; ! if (code >=0 && (size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpExceptions_t)) { callback = SWIG_csharp_exceptions[code].callback; } callback(msg); } %} --- 19,90 ---- %insert(runtime) %{ ! /* Support for throwing C# exceptions from C/C++. There are two types: ! * Exceptions that take a message and ArgumentExceptions that take a message and a parameter name. */ typedef enum { ! SWIG_CSharpApplicationException, ! SWIG_CSharpArithmeticException, SWIG_CSharpDivideByZeroException, ! SWIG_CSharpIndexOutOfRangeException, ! SWIG_CSharpInvalidOperationException, ! SWIG_CSharpIOException, ! SWIG_CSharpNullReferenceException, ! SWIG_CSharpOutOfMemoryException, ! SWIG_CSharpOverflowException, ! SWIG_CSharpSystemException } SWIG_CSharpExceptionCodes; + typedef enum { + SWIG_CSharpArgumentException, + SWIG_CSharpArgumentNullException, + SWIG_CSharpArgumentOutOfRangeException, + } SWIG_CSharpExceptionArgumentCodes; + typedef void (SWIGSTDCALL* SWIG_CSharpExceptionCallback_t)(const char *); + typedef void (SWIGSTDCALL* SWIG_CSharpExceptionArgumentCallback_t)(const char *, const char *); typedef struct { SWIG_CSharpExceptionCodes code; SWIG_CSharpExceptionCallback_t callback; ! } SWIG_CSharpException_t; ! typedef struct { ! SWIG_CSharpExceptionArgumentCodes code; ! SWIG_CSharpExceptionArgumentCallback_t callback; ! } SWIG_CSharpExceptionArgument_t; ! ! static SWIG_CSharpException_t SWIG_csharp_exceptions[] = { ! { SWIG_CSharpApplicationException, NULL }, ! { SWIG_CSharpArithmeticException, NULL }, { SWIG_CSharpDivideByZeroException, NULL }, + { SWIG_CSharpIndexOutOfRangeException, NULL }, + { SWIG_CSharpInvalidOperationException, NULL }, + { SWIG_CSharpIOException, NULL }, + { SWIG_CSharpNullReferenceException, NULL }, + { SWIG_CSharpOutOfMemoryException, NULL }, + { SWIG_CSharpOverflowException, NULL }, + { SWIG_CSharpSystemException, NULL } + }; + + static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = { + { SWIG_CSharpArgumentException, NULL }, + { SWIG_CSharpArgumentNullException, NULL }, { SWIG_CSharpArgumentOutOfRangeException, NULL }, ! }; static void SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) { ! SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback; ! if (code >=0 && (size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) { callback = SWIG_csharp_exceptions[code].callback; } callback(msg); } + + static void SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code, const char *msg, const char *param_name) { + SWIG_CSharpExceptionArgumentCallback_t callback = SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback; + if (code >=0 && (size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) { + callback = SWIG_csharp_exceptions_argument[code].callback; + } + callback(msg, param_name); + } %} *************** *** 57,72 **** extern "C" #endif ! DllExport void SWIGSTDCALL SWIGRegisterExceptionCallbacks_$module(SWIG_CSharpExceptionCallback_t systemException, ! SWIG_CSharpExceptionCallback_t outOfMemory, ! SWIG_CSharpExceptionCallback_t indexOutOfRange, ! SWIG_CSharpExceptionCallback_t divideByZero, ! SWIG_CSharpExceptionCallback_t argumentOutOfRange, ! SWIG_CSharpExceptionCallback_t nullReference) { ! SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback = systemException; ! SWIG_csharp_exceptions[SWIG_CSharpOutOfMemoryException].callback = outOfMemory; ! SWIG_csharp_exceptions[SWIG_CSharpIndexOutOfRangeException].callback = indexOutOfRange; SWIG_csharp_exceptions[SWIG_CSharpDivideByZeroException].callback = divideByZero; ! SWIG_csharp_exceptions[SWIG_CSharpArgumentOutOfRangeException].callback = argumentOutOfRange; SWIG_csharp_exceptions[SWIG_CSharpNullReferenceException].callback = nullReference; } %} --- 93,129 ---- extern "C" #endif ! DllExport void SWIGSTDCALL SWIGRegisterExceptionCallbacks_$module( ! SWIG_CSharpExceptionCallback_t application, ! SWIG_CSharpExceptionCallback_t arithmetic, ! SWIG_CSharpExceptionCallback_t divideByZero, ! SWIG_CSharpExceptionCallback_t indexOutOfRange, ! SWIG_CSharpExceptionCallback_t invalidOperation, ! SWIG_CSharpExceptionCallback_t io, ! SWIG_CSharpExceptionCallback_t nullReference, ! SWIG_CSharpExceptionCallback_t outOfMemory, ! SWIG_CSharpExceptionCallback_t overflow, ! SWIG_CSharpExceptionCallback_t system) { ! SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback = application; ! SWIG_csharp_exceptions[SWIG_CSharpArithmeticException].callback = arithmetic; SWIG_csharp_exceptions[SWIG_CSharpDivideByZeroException].callback = divideByZero; ! SWIG_csharp_exceptions[SWIG_CSharpIndexOutOfRangeException].callback = indexOutOfRange; ! SWIG_csharp_exceptions[SWIG_CSharpInvalidOperationException].callback = invalidOperation; ! SWIG_csharp_exceptions[SWIG_CSharpIOException].callback = io; SWIG_csharp_exceptions[SWIG_CSharpNullReferenceException].callback = nullReference; + SWIG_csharp_exceptions[SWIG_CSharpOutOfMemoryException].callback = outOfMemory; + SWIG_csharp_exceptions[SWIG_CSharpOverflowException].callback = overflow; + SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback = system; + } + + #ifdef __cplusplus + extern "C" + #endif + DllExport void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module( + SWIG_CSharpExceptionArgumentCallback_t argument, + SWIG_CSharpExceptionArgumentCallback_t argumentNull, + SWIG_CSharpExceptionArgumentCallback_t argumentOutOfRange) { + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback = argument; + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentNullException].callback = argumentNull; + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentOutOfRangeException].callback = argumentOutOfRange; } %} *************** *** 76,122 **** public delegate void ExceptionDelegate(string message); ! static ExceptionDelegate systemDelegate = new ExceptionDelegate(ThrowSystemException); ! static ExceptionDelegate outOfMemoryDelegate = new ExceptionDelegate(ThrowOutOfMemoryException); ! static ExceptionDelegate indexOutOfRangeDelegate = new ExceptionDelegate(ThrowIndexOutOfRangeException); static ExceptionDelegate divideByZeroDelegate = new ExceptionDelegate(ThrowDivideByZeroException); ! static ExceptionDelegate argumentOutOfRangeDelegate = new ExceptionDelegate(ThrowArgumentOutOfRangeException); static ExceptionDelegate nullReferenceDelegate = new ExceptionDelegate(ThrowNullReferenceException); [DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionCallbacks_$module")] public static extern void SWIGRegisterExceptionCallbacks_$module( ! ExceptionDelegate systemExceptionDelegate, ! ExceptionDelegate outOfMemoryDelegate, ! ExceptionDelegate indexOutOfRangeDelegate, ! ExceptionDelegate divideByZeroDelegate, ! ExceptionDelegate argumentOutOfRangeDelegate, ! ExceptionDelegate nullReferenceDelegate); ! static void ThrowSystemException(string message) { ! SWIGPendingException.Set(new System.SystemException(message)); ! } ! static void ThrowOutOfMemoryException(string message) { ! SWIGPendingException.Set(new System.OutOfMemoryException(message)); } ! ! static void ThrowIndexOutOfRangeException(string message) { ! SWIGPendingException.Set(new System.IndexOutOfRangeException(message)); } - static void ThrowDivideByZeroException(string message) { SWIGPendingException.Set(new System.DivideByZeroException(message)); } ! ! static void ThrowArgumentOutOfRangeException(string message) { ! SWIGPendingException.Set(new System.ArgumentOutOfRangeException(message)); } - static void ThrowNullReferenceException(string message) { SWIGPendingException.Set(new System.NullReferenceException(message)); } static SWIGExceptionHelper() { ! SWIGRegisterExceptionCallbacks_$module(systemDelegate, outOfMemoryDelegate, indexOutOfRangeDelegate, divideByZeroDelegate, argumentOutOfRangeDelegate, nullReferenceDelegate); } } --- 133,230 ---- public delegate void ExceptionDelegate(string message); + public delegate void ExceptionArgumentDelegate(string message, string paramName); ! static ExceptionDelegate applicationDelegate = new ExceptionDelegate(ThrowApplicationException); ! static ExceptionDelegate arithmeticDelegate = new ExceptionDelegate(ThrowArithmeticException); static ExceptionDelegate divideByZeroDelegate = new ExceptionDelegate(ThrowDivideByZeroException); ! static ExceptionDelegate indexOutOfRangeDelegate = new ExceptionDelegate(ThrowIndexOutOfRangeException); ! static ExceptionDelegate invalidOperationDelegate = new ExceptionDelegate(ThrowInvalidOperationException); ! static ExceptionDelegate ioDelegate = new ExceptionDelegate(ThrowIOException); static ExceptionDelegate nullReferenceDelegate = new ExceptionDelegate(ThrowNullReferenceException); + static ExceptionDelegate outOfMemoryDelegate = new ExceptionDelegate(ThrowOutOfMemoryException); + static ExceptionDelegate overflowDelegate = new ExceptionDelegate(ThrowOverflowException); + static ExceptionDelegate systemDelegate = new ExceptionDelegate(ThrowSystemException); + + static ExceptionArgumentDelegate argumentDelegate = new ExceptionArgumentDelegate(ThrowArgumentException); + static ExceptionArgumentDelegate argumentNullDelegate = new ExceptionArgumentDelegate(ThrowArgumentNullException); + static ExceptionArgumentDelegate argumentOutOfRangeDelegate = new ExceptionArgumentDelegate(ThrowArgumentOutOfRangeException); [DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionCallbacks_$module")] public static extern void SWIGRegisterExceptionCallbacks_$module( ! ExceptionDelegate applicationDelegate, ! ExceptionDelegate arithmeticDelegate, ! ExceptionDelegate divideByZeroDelegate, ! ExceptionDelegate indexOutOfRangeDelegate, ! ExceptionDelegate invalidOperationDelegate, ! ExceptionDelegate ioDelegate, ! ExceptionDelegate nullReferenceDelegate, ! ExceptionDelegate outOfMemoryDelegate, ! ExceptionDelegate overflowDelegate, ! ExceptionDelegate systemExceptionDelegate); ! [DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionArgumentCallbacks_$module")] ! public static extern void SWIGRegisterExceptionCallbacksArgument_$module( ! ExceptionArgumentDelegate argumentDelegate, ! ExceptionArgumentDelegate argumentNullDelegate, ! ExceptionArgumentDelegate argumentOutOfRangeDelegate); ! static void ThrowApplicationException(string message) { ! SWIGPendingException.Set(new System.ApplicationException(message)); } ! static void ThrowArithmeticException(string message) { ! SWIGPendingException.Set(new System.ArithmeticException(message)); } static void ThrowDivideByZeroException(string message) { SWIGPendingException.Set(new System.DivideByZeroException(message)); } ! static void ThrowIndexOutOfRangeException(string message) { ! SWIGPendingException.Set(new System.IndexOutOfRangeException(message)); ! } ! static void ThrowInvalidOperationException(string message) { ! SWIGPendingException.Set(new System.InvalidOperationException(message)); ! } ! static void ThrowIOException(string message) { ! SWIGPendingException.Set(new System.IO.IOException(message)); } static void ThrowNullReferenceException(string message) { SWIGPendingException.Set(new System.NullReferenceException(message)); } + static void ThrowOutOfMemoryException(string message) { + SWIGPendingException.Set(new System.OutOfMemoryException(message)); + } + static void ThrowOverflowException(string message) { + SWIGPendingException.Set(new System.OverflowException(message)); + } + static void ThrowSystemException(string message) { + SWIGPendingException.Set(new System.SystemException(message)); + } + + static void ThrowArgumentException(string message, string paramName) { + SWIGPendingException.Set(new System.ArgumentException(message, paramName)); + } + static void ThrowArgumentNullException(string message, string paramName) { + SWIGPendingException.Set(new System.ArgumentNullException(paramName, message)); + } + static void ThrowArgumentOutOfRangeException(string message, string paramName) { + SWIGPendingException.Set(new System.ArgumentOutOfRangeException(paramName, message)); + } static SWIGExceptionHelper() { ! SWIGRegisterExceptionCallbacks_$module( ! applicationDelegate, ! arithmeticDelegate, ! divideByZeroDelegate, ! indexOutOfRangeDelegate, ! invalidOperationDelegate, ! ioDelegate, ! nullReferenceDelegate, ! outOfMemoryDelegate, ! overflowDelegate, ! systemDelegate); ! ! SWIGRegisterExceptionCallbacksArgument_$module( ! argumentDelegate, ! argumentNullDelegate, ! argumentOutOfRangeDelegate); } } *************** *** 140,145 **** public static void Set(Exception e) { ! if (pendingException != null) // Checks for missing pending exception code ! throw new Exception("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e); // unmanaged code destructors may not be called pendingException = e; lock(typeof($modulePINVOKE)) { --- 248,253 ---- public static void Set(Exception e) { ! if (pendingException != null) ! throw new ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e); pendingException = e; lock(typeof($modulePINVOKE)) { *************** *** 201,204 **** /* Contract support */ ! #define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_CSharpSetPendingException(SWIG_CSharpArgumentOutOfRangeException, msg); return nullreturn; } else %} --- 309,312 ---- /* Contract support */ ! #define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, msg, ""); return nullreturn; } else %} Index: std_string.i =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/csharp/std_string.i,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** std_string.i 15 Feb 2005 22:02:22 -0000 1.9 --- std_string.i 22 Feb 2005 22:56:18 -0000 1.10 *************** *** 54,58 **** %typemap(throws, canthrow=1) string %{ ! SWIG_CSharpSetPendingException(SWIG_CSharpSystemException, $1.c_str()); return $null; %} --- 54,58 ---- %typemap(throws, canthrow=1) string %{ ! SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); return $null; %} *************** *** 91,95 **** %typemap(throws, canthrow=1) const string & %{ ! SWIG_CSharpSetPendingException(SWIG_CSharpSystemException, $1.c_str()); return $null; %} --- 91,95 ---- %typemap(throws, canthrow=1) const string & %{ ! SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); return $null; %} Index: enumtypesafe.swg =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/csharp/enumtypesafe.swg,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** enumtypesafe.swg 15 Feb 2005 22:02:22 -0000 1.9 --- enumtypesafe.swg 22 Feb 2005 22:56:18 -0000 1.10 *************** *** 19,23 **** %typemap(throws, canthrow=1) const enum SWIGTYPE & %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpSystemException, "C++ $1_type exception thrown"); return $null; %} --- 19,23 ---- %typemap(throws, canthrow=1) const enum SWIGTYPE & %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} *************** *** 48,52 **** %typemap(throws, canthrow=1) enum SWIGTYPE %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpSystemException, "C++ $1_type exception thrown"); return $null; %} --- 48,52 ---- %typemap(throws, canthrow=1) enum SWIGTYPE %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} Index: csharp.swg =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/csharp/csharp.swg,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** csharp.swg 15 Feb 2005 22:02:18 -0000 1.36 --- csharp.swg 22 Feb 2005 22:56:18 -0000 1.37 *************** *** 296,300 **** char error_msg[256]; sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); ! SWIG_CSharpSetPendingException(SWIG_CSharpSystemException, error_msg); return $null; } --- 296,300 ---- char error_msg[256]; sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); ! SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, error_msg); return $null; } *************** *** 302,311 **** %typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY] %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpSystemException, "C++ $1_type exception thrown"); return $null; %} %typemap(throws, canthrow=1) char * %{ ! SWIG_CSharpSetPendingException(SWIG_CSharpSystemException, $1); return $null; %} --- 302,311 ---- %typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY] %{ (void)$1; ! SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); return $null; %} %typemap(throws, canthrow=1) char * %{ ! SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1); return $null; %} |