/[eiffelstudio]/vendor/gobosoft.com/gobo/4.0d/tool/gec/runtime/c/ge_exception.h
ViewVC logotype

Contents of /vendor/gobosoft.com/gobo/4.0d/tool/gec/runtime/c/ge_exception.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 98698 - (show annotations)
Mon May 9 13:53:54 2016 UTC (3 years, 5 months ago) by manus
File MIME type: text/plain
File size: 7179 byte(s)
Update 4.0d version with changes in Gobo from 2016/05/09

1 /*
2 description:
3
4 "C functions used to implement class EXCEPTION"
5
6 system: "Gobo Eiffel Compiler"
7 copyright: "Copyright (c) 2007-2016, Eric Bezault and others"
8 license: "MIT License"
9 date: "$Date$"
10 revision: "$Revision$"
11 */
12
13 #ifndef GE_EXCEPTION_H
14 #define GE_EXCEPTION_H
15 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
16 #pragma once
17 #endif
18
19 #ifndef GE_EIFFEL_H
20 #include "ge_eiffel.h"
21 #endif
22 #include <setjmp.h>
23
24 /*
25 * On Linux glibc systems, we need to use sig* versions of jmp_buf,
26 * setjmp and longjmp to preserve the signal handling context.
27 * One way to detect this is if _SIGSET_H_types has
28 * been defined in /usr/include/setjmp.h.
29 * NOTE: ANSI only recognizes the non-sig versions.
30 */
31 #if (defined(_SIGSET_H_types) && !defined(__STRICT_ANSI__))
32 #define GE_jmp_buf sigjmp_buf
33 #define GE_setjmp(x) sigsetjmp((x),1)
34 #define GE_longjmp(x,y) siglongjmp((x),(y))
35 #else
36 #define GE_jmp_buf jmp_buf
37 #define GE_setjmp(x) setjmp((x))
38 #define GE_longjmp(x,y) longjmp((x),(y))
39 #endif
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 /*
46 * Predefined exception codes.
47 */
48 #define GE_EX_VOID 1 /* Feature applied to void reference */
49 #define GE_EX_MEM 2 /* No more memory */
50 #define GE_EX_PRE 3 /* Pre-condition violated */
51 #define GE_EX_POST 4 /* Post-condition violated */
52 #define GE_EX_FLOAT 5 /* Floating point exception (signal SIGFPE) */
53 #define GE_EX_CINV 6 /* Class invariant violated */
54 #define GE_EX_CHECK 7 /* Check instruction violated */
55 #define GE_EX_FAIL 8 /* Routine failure */
56 #define GE_EX_WHEN 9 /* Unmatched inspect value */
57 #define GE_EX_VAR 10 /* Non-decreasing loop variant */
58 #define GE_EX_LINV 11 /* Loop invariant violated */
59 #define GE_EX_SIG 12 /* Operating system signal */
60 #define GE_EX_BYE 13 /* Eiffel run-time panic */
61 #define GE_EX_RESC 14 /* Exception in rescue clause */
62 #define GE_EX_OMEM 15 /* Out of memory (cannot be ignored) */
63 #define GE_EX_RES 16 /* Resumption failed (retry did not succeed) */
64 #define GE_EX_CDEF 17 /* Create on deferred */
65 #define GE_EX_EXT 18 /* External event */
66 #define GE_EX_VEXP 19 /* Void assigned to expanded */
67 #define GE_EX_HDLR 20 /* Exception in signal handler */
68 #define GE_EX_IO 21 /* I/O error */
69 #define GE_EX_SYS 22 /* Operating system error */
70 #define GE_EX_RETR 23 /* Retrieval error */
71 #define GE_EX_PROG 24 /* Developer exception */
72 #define GE_EX_FATAL 25 /* Eiffel run-time fatal error */
73 #define GE_EX_DOL 26 /* $ applied to melted feature */
74 #define GE_EX_ISE_IO 27 /* I/O error raised by the ISE Eiffel runtime */
75 #define GE_EX_COM 28 /* COM error raised by EiffelCOM runtime */
76 #define GE_EX_RT_CHECK 29 /* Runtime check error such as out-of-bound array access */
77 #define GE_EX_OLD 30 /* Old violation */
78 #define GE_EX_SEL 31 /* Serialization failure */
79 #define GE_EX_DIRTY 32 /* SCOOP processor dirty exception. */
80 #define GE_EX_NEX 32 /* Number of internal exceptions */
81
82 /*
83 * String buffer used to build the exception trace.
84 */
85 typedef struct GE_exception_trace_buffer_struct GE_exception_trace_buffer;
86 struct GE_exception_trace_buffer_struct {
87 char* area;
88 uint32_t count;
89 uint32_t capacity;
90 };
91
92 /*
93 * Information about the feature being executed.
94 */
95 typedef struct GE_call_struct GE_call;
96 struct GE_call_struct {
97 #ifdef EIF_CURRENT_IN_EXCEPTION_TRACE
98 void* object; /* Current object */
99 #endif
100 const char* class_name;
101 const char* feature_name;
102 GE_call* caller; /* previous feature in the call chain */
103 };
104
105 /*
106 * Context of features containing a rescue clause.
107 */
108 typedef struct GE_rescue_struct GE_rescue;
109 struct GE_rescue_struct {
110 GE_jmp_buf jb;
111 GE_rescue* previous; /* previous context in the call chain */
112 };
113
114 /*
115 * Information about the execution context.
116 * One such struct per thread.
117 */
118 typedef struct GE_thread_context_struct GE_thread_context;
119 typedef struct GE_context_struct GE_context;
120 struct GE_context_struct {
121 GE_call* call; /* Call stack */
122 GE_rescue* last_rescue; /* Context of last feature entered containing a rescue clause */
123 uint32_t in_rescue; /* Number of rescue clauses currently being executed */
124 EIF_REFERENCE exception_manager; /* Exception manager */
125 char raising_exception; /* Is an exception currently being raised? */
126 char exception_trace_enabled; /* Should exception trace be displayed? */
127 long exception_code; /* Code of the exception currently being raised, 0 otherwise */
128 const char* exception_tag; /* Tag of the exception currently being raised, NULL otherwise */
129 GE_exception_trace_buffer exception_trace_buffer; /* String buffer used to build the exception trace */
130 GE_exception_trace_buffer last_exception_trace; /* Last non-routine-failure exception trace */
131 #ifdef EIF_THREADS
132 GE_thread_context* thread; /* Thread context */
133 #endif
134 };
135
136 /*
137 * Default initialization for `GE_context'.
138 */
139 extern GE_context GE_default_context;
140
141 /*
142 * Execution context of main thread.
143 */
144 extern GE_context* GE_main_context;
145
146 /*
147 * Execution context of current thread.
148 */
149 extern GE_context* GE_current_context();
150
151 /*
152 * Initialization of exception handling.
153 */
154 extern void GE_init_exception(GE_context* context);
155
156 /*
157 * Pointer to function to create a new exception manager object.
158 */
159 extern EIF_REFERENCE (*GE_new_exception_manager)(EIF_BOOLEAN);
160
161 /*
162 * Pointer to Eiffel routine EXCEPTION_MANAGER.init_exception_manager.
163 */
164 extern void (*GE_init_exception_manager)(GE_context*, EIF_REFERENCE);
165
166 /*
167 * Pointer to Eiffel routine EXCEPTION_MANAGER.set_exception_data.
168 */
169 extern void (*GE_set_exception_data)(GE_context*, EIF_REFERENCE, EIF_INTEGER_32, EIF_BOOLEAN, EIF_INTEGER_32, EIF_INTEGER_32, EIF_REFERENCE, EIF_REFERENCE, EIF_REFERENCE, EIF_REFERENCE, EIF_REFERENCE, EIF_REFERENCE, EIF_INTEGER_32, EIF_BOOLEAN);
170
171 /*
172 * Exception tag associated with `code'.
173 */
174 extern char* GE_exception_tag(long code);
175
176 /*
177 * Raise an exception with code `code'.
178 */
179 extern void GE_raise(long code);
180
181 /*
182 * Raise an exception with code `code' and message `msg'.
183 */
184 extern void GE_raise_with_message(long code, const char* msg);
185
186 /*
187 * Raise an exception from EXCEPTION_MANAGER.
188 */
189 extern void GE_developer_raise(long code, char* meaning, char* message);
190
191 /*
192 * Check whether the type id of `obj' is not in `type_ids'.
193 * If it is, then raise a CAT-call exception. Don't do anything if `obj' is Void.
194 * `nb' is the number of ids in `type_ids' and is expected to be >0.
195 * `type_ids' is sorted in increasing order.
196 * Return `obj'.
197 */
198 #define GE_catcall(obj,type_ids,nb) GE_check_catcall((obj),(type_ids),(nb))
199 EIF_REFERENCE GE_check_catcall(EIF_REFERENCE obj, int type_ids[], int nb);
200
201 /*
202 * Check whether `obj' is Void.
203 * If it is, then raise a call-on-void-target exception.
204 * Return `obj'.
205 */
206 #define GE_void(obj) (!(obj)?GE_check_void(obj):(obj))
207 extern EIF_REFERENCE GE_check_void(EIF_REFERENCE obj);
208
209 /*
210 * Check whether `ptr' is a null pointer.
211 * If it is, then raise a no-more-memory exception.
212 * Return `ptr'.
213 */
214 #define GE_null(ptr) GE_check_null(ptr)
215 extern void* GE_check_null(void* ptr);
216
217 #ifdef EIF_WINDOWS
218 /*
219 * Set default exception handler.
220 */
221 extern void GE_set_windows_exception_filter();
222 #endif
223
224 #ifdef __cplusplus
225 }
226 #endif
227
228 #endif

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23