/tags/rel-1-3-27/SWIG/Lib/csharp/csharphead.swg
Unknown | 305 lines | 268 code | 37 blank | 0 comment | 0 complexity | 3c70559cb921aa8f35ee20e14b460e52 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
- /* -----------------------------------------------------------------------------
- * csharphead.swg
- *
- * CSharp support code
- * ----------------------------------------------------------------------------- */
- %insert(runtime) %{
- #include <stdlib.h>
- #include <string.h>
- #include <stdio.h>
- %}
- %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);
- }
- %}
- %insert(runtime) %{
- #ifdef __cplusplus
- extern "C"
- #endif
- SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionCallbacks_$module(
- SWIG_CSharpExceptionCallback_t applicationCallback,
- SWIG_CSharpExceptionCallback_t arithmeticCallback,
- SWIG_CSharpExceptionCallback_t divideByZeroCallback,
- SWIG_CSharpExceptionCallback_t indexOutOfRangeCallback,
- SWIG_CSharpExceptionCallback_t invalidOperationCallback,
- SWIG_CSharpExceptionCallback_t ioCallback,
- SWIG_CSharpExceptionCallback_t nullReferenceCallback,
- SWIG_CSharpExceptionCallback_t outOfMemoryCallback,
- SWIG_CSharpExceptionCallback_t overflowCallback,
- SWIG_CSharpExceptionCallback_t systemCallback) {
- SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback = applicationCallback;
- SWIG_csharp_exceptions[SWIG_CSharpArithmeticException].callback = arithmeticCallback;
- SWIG_csharp_exceptions[SWIG_CSharpDivideByZeroException].callback = divideByZeroCallback;
- SWIG_csharp_exceptions[SWIG_CSharpIndexOutOfRangeException].callback = indexOutOfRangeCallback;
- SWIG_csharp_exceptions[SWIG_CSharpInvalidOperationException].callback = invalidOperationCallback;
- SWIG_csharp_exceptions[SWIG_CSharpIOException].callback = ioCallback;
- SWIG_csharp_exceptions[SWIG_CSharpNullReferenceException].callback = nullReferenceCallback;
- SWIG_csharp_exceptions[SWIG_CSharpOutOfMemoryException].callback = outOfMemoryCallback;
- SWIG_csharp_exceptions[SWIG_CSharpOverflowException].callback = overflowCallback;
- SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback = systemCallback;
- }
- #ifdef __cplusplus
- extern "C"
- #endif
- SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
- SWIG_CSharpExceptionArgumentCallback_t argumentCallback,
- SWIG_CSharpExceptionArgumentCallback_t argumentNullCallback,
- SWIG_CSharpExceptionArgumentCallback_t argumentOutOfRangeCallback) {
- SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback = argumentCallback;
- SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentNullException].callback = argumentNullCallback;
- SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentOutOfRangeException].callback = argumentOutOfRangeCallback;
- }
- %}
- %pragma(csharp) imclasscode=%{
- protected class SWIGExceptionHelper {
- public delegate void ExceptionDelegate(string message);
- public delegate void ExceptionArgumentDelegate(string message, string paramName);
- static ExceptionDelegate applicationDelegate = new ExceptionDelegate(SetPendingApplicationException);
- static ExceptionDelegate arithmeticDelegate = new ExceptionDelegate(SetPendingArithmeticException);
- static ExceptionDelegate divideByZeroDelegate = new ExceptionDelegate(SetPendingDivideByZeroException);
- static ExceptionDelegate indexOutOfRangeDelegate = new ExceptionDelegate(SetPendingIndexOutOfRangeException);
- static ExceptionDelegate invalidOperationDelegate = new ExceptionDelegate(SetPendingInvalidOperationException);
- static ExceptionDelegate ioDelegate = new ExceptionDelegate(SetPendingIOException);
- static ExceptionDelegate nullReferenceDelegate = new ExceptionDelegate(SetPendingNullReferenceException);
- static ExceptionDelegate outOfMemoryDelegate = new ExceptionDelegate(SetPendingOutOfMemoryException);
- static ExceptionDelegate overflowDelegate = new ExceptionDelegate(SetPendingOverflowException);
- static ExceptionDelegate systemDelegate = new ExceptionDelegate(SetPendingSystemException);
- static ExceptionArgumentDelegate argumentDelegate = new ExceptionArgumentDelegate(SetPendingArgumentException);
- static ExceptionArgumentDelegate argumentNullDelegate = new ExceptionArgumentDelegate(SetPendingArgumentNullException);
- static ExceptionArgumentDelegate argumentOutOfRangeDelegate = new ExceptionArgumentDelegate(SetPendingArgumentOutOfRangeException);
- [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 SetPendingApplicationException(string message) {
- SWIGPendingException.Set(new System.ApplicationException(message));
- }
- static void SetPendingArithmeticException(string message) {
- SWIGPendingException.Set(new System.ArithmeticException(message));
- }
- static void SetPendingDivideByZeroException(string message) {
- SWIGPendingException.Set(new System.DivideByZeroException(message));
- }
- static void SetPendingIndexOutOfRangeException(string message) {
- SWIGPendingException.Set(new System.IndexOutOfRangeException(message));
- }
- static void SetPendingInvalidOperationException(string message) {
- SWIGPendingException.Set(new System.InvalidOperationException(message));
- }
- static void SetPendingIOException(string message) {
- SWIGPendingException.Set(new System.IO.IOException(message));
- }
- static void SetPendingNullReferenceException(string message) {
- SWIGPendingException.Set(new System.NullReferenceException(message));
- }
- static void SetPendingOutOfMemoryException(string message) {
- SWIGPendingException.Set(new System.OutOfMemoryException(message));
- }
- static void SetPendingOverflowException(string message) {
- SWIGPendingException.Set(new System.OverflowException(message));
- }
- static void SetPendingSystemException(string message) {
- SWIGPendingException.Set(new System.SystemException(message));
- }
- static void SetPendingArgumentException(string message, string paramName) {
- SWIGPendingException.Set(new System.ArgumentException(message, paramName));
- }
- static void SetPendingArgumentNullException(string message, string paramName) {
- SWIGPendingException.Set(new System.ArgumentNullException(paramName, message));
- }
- static void SetPendingArgumentOutOfRangeException(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);
- }
- }
- protected static SWIGExceptionHelper swigExceptionHelper = new SWIGExceptionHelper();
- public class SWIGPendingException {
- [ThreadStatic]
- private static Exception pendingException = null;
- private static int numExceptionsPending = 0;
- public static bool Pending {
- get {
- bool pending = false;
- if (numExceptionsPending > 0)
- if (pendingException != null)
- pending = true;
- return pending;
- }
- }
- 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)) {
- numExceptionsPending++;
-