1 /* -----------------------------------------------------------------------------
2 * See the LICENSE file for information on copyright, usage and redistribution
3 * of SWIG, and the README file for authors - http://www.swig.org/release.html.
7 * Support code for exceptions if the SWIG_CSHARP_NO_EXCEPTION_HELPER is not defined
8 * Support code for strings if the SWIG_CSHARP_NO_STRING_HELPER is not defined
9 * ----------------------------------------------------------------------------- */
17 #if !defined(SWIG_CSHARP_NO_EXCEPTION_HELPER)
19 /* Support for throwing C# exceptions from C/C++. There are two types:
20 * Exceptions that take a message and ArgumentExceptions that take a message and a parameter name. */
22 SWIG_CSharpApplicationException,
23 SWIG_CSharpArithmeticException,
24 SWIG_CSharpDivideByZeroException,
25 SWIG_CSharpIndexOutOfRangeException,
26 SWIG_CSharpInvalidCastException,
27 SWIG_CSharpInvalidOperationException,
28 SWIG_CSharpIOException,
29 SWIG_CSharpNullReferenceException,
30 SWIG_CSharpOutOfMemoryException,
31 SWIG_CSharpOverflowException,
32 SWIG_CSharpSystemException
33 } SWIG_CSharpExceptionCodes;
36 SWIG_CSharpArgumentException,
37 SWIG_CSharpArgumentNullException,
38 SWIG_CSharpArgumentOutOfRangeException
39 } SWIG_CSharpExceptionArgumentCodes;
41 typedef void (SWIGSTDCALL* SWIG_CSharpExceptionCallback_t)(const char *);
42 typedef void (SWIGSTDCALL* SWIG_CSharpExceptionArgumentCallback_t)(const char *, const char *);
45 SWIG_CSharpExceptionCodes code;
46 SWIG_CSharpExceptionCallback_t callback;
47 } SWIG_CSharpException_t;
50 SWIG_CSharpExceptionArgumentCodes code;
51 SWIG_CSharpExceptionArgumentCallback_t callback;
52 } SWIG_CSharpExceptionArgument_t;
54 static SWIG_CSharpException_t SWIG_csharp_exceptions[] = {
55 { SWIG_CSharpApplicationException, NULL },
56 { SWIG_CSharpArithmeticException, NULL },
57 { SWIG_CSharpDivideByZeroException, NULL },
58 { SWIG_CSharpIndexOutOfRangeException, NULL },
59 { SWIG_CSharpInvalidCastException, NULL },
60 { SWIG_CSharpInvalidOperationException, NULL },
61 { SWIG_CSharpIOException, NULL },
62 { SWIG_CSharpNullReferenceException, NULL },
63 { SWIG_CSharpOutOfMemoryException, NULL },
64 { SWIG_CSharpOverflowException, NULL },
65 { SWIG_CSharpSystemException, NULL }
68 static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = {
69 { SWIG_CSharpArgumentException, NULL },
70 { SWIG_CSharpArgumentNullException, NULL },
71 { SWIG_CSharpArgumentOutOfRangeException, NULL }
74 static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) {
75 SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback;
76 if ((size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) {
77 callback = SWIG_csharp_exceptions[code].callback;
82 static void SWIGUNUSED SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code, const char *msg, const char *param_name) {
83 SWIG_CSharpExceptionArgumentCallback_t callback = SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback;
84 if ((size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) {
85 callback = SWIG_csharp_exceptions_argument[code].callback;
87 callback(msg, param_name);
95 SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionCallbacks_$module(
96 SWIG_CSharpExceptionCallback_t applicationCallback,
97 SWIG_CSharpExceptionCallback_t arithmeticCallback,
98 SWIG_CSharpExceptionCallback_t divideByZeroCallback,
99 SWIG_CSharpExceptionCallback_t indexOutOfRangeCallback,
100 SWIG_CSharpExceptionCallback_t invalidCastCallback,
101 SWIG_CSharpExceptionCallback_t invalidOperationCallback,
102 SWIG_CSharpExceptionCallback_t ioCallback,
103 SWIG_CSharpExceptionCallback_t nullReferenceCallback,
104 SWIG_CSharpExceptionCallback_t outOfMemoryCallback,
105 SWIG_CSharpExceptionCallback_t overflowCallback,
106 SWIG_CSharpExceptionCallback_t systemCallback) {
107 SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback = applicationCallback;
108 SWIG_csharp_exceptions[SWIG_CSharpArithmeticException].callback = arithmeticCallback;
109 SWIG_csharp_exceptions[SWIG_CSharpDivideByZeroException].callback = divideByZeroCallback;
110 SWIG_csharp_exceptions[SWIG_CSharpIndexOutOfRangeException].callback = indexOutOfRangeCallback;
111 SWIG_csharp_exceptions[SWIG_CSharpInvalidCastException].callback = invalidCastCallback;
112 SWIG_csharp_exceptions[SWIG_CSharpInvalidOperationException].callback = invalidOperationCallback;
113 SWIG_csharp_exceptions[SWIG_CSharpIOException].callback = ioCallback;
114 SWIG_csharp_exceptions[SWIG_CSharpNullReferenceException].callback = nullReferenceCallback;
115 SWIG_csharp_exceptions[SWIG_CSharpOutOfMemoryException].callback = outOfMemoryCallback;
116 SWIG_csharp_exceptions[SWIG_CSharpOverflowException].callback = overflowCallback;
117 SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback = systemCallback;
123 SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
124 SWIG_CSharpExceptionArgumentCallback_t argumentCallback,
125 SWIG_CSharpExceptionArgumentCallback_t argumentNullCallback,
126 SWIG_CSharpExceptionArgumentCallback_t argumentOutOfRangeCallback) {
127 SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback = argumentCallback;
128 SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentNullException].callback = argumentNullCallback;
129 SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentOutOfRangeException].callback = argumentOutOfRangeCallback;
133 %pragma(csharp) imclasscode=%{
134 protected class SWIGExceptionHelper {
136 public delegate void ExceptionDelegate(string message);
137 public delegate void ExceptionArgumentDelegate(string message, string paramName);
139 static ExceptionDelegate applicationDelegate = new ExceptionDelegate(SetPendingApplicationException);
140 static ExceptionDelegate arithmeticDelegate = new ExceptionDelegate(SetPendingArithmeticException);
141 static ExceptionDelegate divideByZeroDelegate = new ExceptionDelegate(SetPendingDivideByZeroException);
142 static ExceptionDelegate indexOutOfRangeDelegate = new ExceptionDelegate(SetPendingIndexOutOfRangeException);
143 static ExceptionDelegate invalidCastDelegate = new ExceptionDelegate(SetPendingInvalidCastException);
144 static ExceptionDelegate invalidOperationDelegate = new ExceptionDelegate(SetPendingInvalidOperationException);
145 static ExceptionDelegate ioDelegate = new ExceptionDelegate(SetPendingIOException);
146 static ExceptionDelegate nullReferenceDelegate = new ExceptionDelegate(SetPendingNullReferenceException);
147 static ExceptionDelegate outOfMemoryDelegate = new ExceptionDelegate(SetPendingOutOfMemoryException);
148 static ExceptionDelegate overflowDelegate = new ExceptionDelegate(SetPendingOverflowException);
149 static ExceptionDelegate systemDelegate = new ExceptionDelegate(SetPendingSystemException);
151 static ExceptionArgumentDelegate argumentDelegate = new ExceptionArgumentDelegate(SetPendingArgumentException);
152 static ExceptionArgumentDelegate argumentNullDelegate = new ExceptionArgumentDelegate(SetPendingArgumentNullException);
153 static ExceptionArgumentDelegate argumentOutOfRangeDelegate = new ExceptionArgumentDelegate(SetPendingArgumentOutOfRangeException);
155 [DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionCallbacks_$module")]
156 public static extern void SWIGRegisterExceptionCallbacks_$module(
157 ExceptionDelegate applicationDelegate,
158 ExceptionDelegate arithmeticDelegate,
159 ExceptionDelegate divideByZeroDelegate,
160 ExceptionDelegate indexOutOfRangeDelegate,
161 ExceptionDelegate invalidCastDelegate,
162 ExceptionDelegate invalidOperationDelegate,
163 ExceptionDelegate ioDelegate,
164 ExceptionDelegate nullReferenceDelegate,
165 ExceptionDelegate outOfMemoryDelegate,
166 ExceptionDelegate overflowDelegate,
167 ExceptionDelegate systemExceptionDelegate);
169 [DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionArgumentCallbacks_$module")]
170 public static extern void SWIGRegisterExceptionCallbacksArgument_$module(
171 ExceptionArgumentDelegate argumentDelegate,
172 ExceptionArgumentDelegate argumentNullDelegate,
173 ExceptionArgumentDelegate argumentOutOfRangeDelegate);
175 static void SetPendingApplicationException(string message) {
176 SWIGPendingException.Set(new System.ApplicationException(message, SWIGPendingException.Retrieve()));
178 static void SetPendingArithmeticException(string message) {
179 SWIGPendingException.Set(new System.ArithmeticException(message, SWIGPendingException.Retrieve()));
181 static void SetPendingDivideByZeroException(string message) {
182 SWIGPendingException.Set(new System.DivideByZeroException(message, SWIGPendingException.Retrieve()));
184 static void SetPendingIndexOutOfRangeException(string message) {
185 SWIGPendingException.Set(new System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve()));
187 static void SetPendingInvalidCastException(string message) {
188 SWIGPendingException.Set(new System.InvalidCastException(message, SWIGPendingException.Retrieve()));
190 static void SetPendingInvalidOperationException(string message) {
191 SWIGPendingException.Set(new System.InvalidOperationException(message, SWIGPendingException.Retrieve()));
193 static void SetPendingIOException(string message) {
194 SWIGPendingException.Set(new System.IO.IOException(message, SWIGPendingException.Retrieve()));
196 static void SetPendingNullReferenceException(string message) {
197 SWIGPendingException.Set(new System.NullReferenceException(message, SWIGPendingException.Retrieve()));
199 static void SetPendingOutOfMemoryException(string message) {
200 SWIGPendingException.Set(new System.OutOfMemoryException(message, SWIGPendingException.Retrieve()));
202 static void SetPendingOverflowException(string message) {
203 SWIGPendingException.Set(new System.OverflowException(message, SWIGPendingException.Retrieve()));
205 static void SetPendingSystemException(string message) {
206 SWIGPendingException.Set(new System.SystemException(message, SWIGPendingException.Retrieve()));
209 static void SetPendingArgumentException(string message, string paramName) {
210 SWIGPendingException.Set(new System.ArgumentException(message, paramName, SWIGPendingException.Retrieve()));
212 static void SetPendingArgumentNullException(string message, string paramName) {
213 Exception e = SWIGPendingException.Retrieve();
214 if (e != null) message = message + " Inner Exception: " + e.Message;
215 SWIGPendingException.Set(new System.ArgumentNullException(paramName, message));
217 static void SetPendingArgumentOutOfRangeException(string message, string paramName) {
218 Exception e = SWIGPendingException.Retrieve();
219 if (e != null) message = message + " Inner Exception: " + e.Message;
220 SWIGPendingException.Set(new System.ArgumentOutOfRangeException(paramName, message));
223 static SWIGExceptionHelper() {
224 SWIGRegisterExceptionCallbacks_$module(
227 divideByZeroDelegate,
228 indexOutOfRangeDelegate,
230 invalidOperationDelegate,
232 nullReferenceDelegate,
237 SWIGRegisterExceptionCallbacksArgument_$module(
239 argumentNullDelegate,
240 argumentOutOfRangeDelegate);
244 protected static SWIGExceptionHelper swigExceptionHelper = new SWIGExceptionHelper();
246 public class SWIGPendingException {
248 private static Exception pendingException = null;
249 private static int numExceptionsPending = 0;
251 public static bool Pending {
253 bool pending = false;
254 if (numExceptionsPending > 0)
255 if (pendingException != null)
261 public static void Set(Exception e) {
262 if (pendingException != null)
263 throw new ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e);
264 pendingException = e;
265 lock(typeof($imclassname)) {
266 numExceptionsPending++;
270 public static Exception Retrieve() {
272 if (numExceptionsPending > 0) {
273 if (pendingException != null) {
274 e = pendingException;
275 pendingException = null;
276 lock(typeof($imclassname)) {
277 numExceptionsPending--;
285 #endif // SWIG_CSHARP_NO_EXCEPTION_HELPER
287 #if !defined(SWIG_CSHARP_NO_STRING_HELPER)
289 /* Callback for returning strings to C# without leaking memory */
290 typedef char * (SWIGSTDCALL* SWIG_CSharpStringHelperCallback)(const char *);
291 static SWIG_CSharpStringHelperCallback SWIG_csharp_string_callback = NULL;
294 %pragma(csharp) imclasscode=%{
295 protected class SWIGStringHelper {
297 public delegate string SWIGStringDelegate(string message);
298 static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString);
300 [DllImport("$dllimport", EntryPoint="SWIGRegisterStringCallback_$module")]
301 public static extern void SWIGRegisterStringCallback_$module(SWIGStringDelegate stringDelegate);
303 static string CreateString(string cString) {
307 static SWIGStringHelper() {
308 SWIGRegisterStringCallback_$module(stringDelegate);
312 static protected SWIGStringHelper swigStringHelper = new SWIGStringHelper();
319 SWIGEXPORT void SWIGSTDCALL SWIGRegisterStringCallback_$module(SWIG_CSharpStringHelperCallback callback) {
320 SWIG_csharp_string_callback = callback;
323 #endif // SWIG_CSHARP_NO_STRING_HELPER
326 /* Contract support */
328 #define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, msg, ""); return nullreturn; } else