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

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

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: 2412 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 EXCEPTIONS"
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 EIF_EXCEPT_C
14 #define EIF_EXCEPT_C
15 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
16 #pragma once
17 #endif
18
19 #ifndef EIF_EXCEPT_H
20 #include "eif_except.h"
21 #endif
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 /*
28 * Raise an Eiffel exception.
29 */
30 void eraise(const char* name, long code)
31 {
32 GE_raise_with_message(code, name);
33 }
34
35 /*
36 * Raise an Eiffel exception of the given code with no associated tag.
37 */
38 void xraise(int code)
39 {
40 GE_raise((long)code);
41 }
42
43 /*
44 * Raise an "Operating system error" exception.
45 */
46 void esys(void)
47 {
48 if (errno == 0) {
49 /* External event */
50 GE_raise(GE_EX_EXT);
51 } else {
52 /* Operating system error */
53 GE_raise(GE_EX_SYS);
54 }
55 }
56
57 /*
58 * As a special case, an I/O error is raised when a system call which is I/O bound fails.
59 */
60 void eise_io(const char* tag)
61 {
62 GE_raise_with_message(GE_EX_ISE_IO, tag);
63 }
64
65 /*
66 * Raise a "No more memory" exception.
67 */
68 void enomem(void) {
69 GE_raise(GE_EX_OMEM);
70 }
71
72 /*
73 * Raise EiffelCOM exception.
74 */
75 void com_eraise(const char* tag, long num)
76 {
77 GE_raise_with_message(num, tag);
78 }
79
80 /*
81 * Terminate execution with exit status `code',
82 * without triggering an exception.
83 */
84 void esdie(int code)
85 {
86 /* TODO: check that the Boehm GC triggers the 'dispose' routines. */
87 exit(code);
88 }
89
90 /*
91 * Exception tag associated with `code'.
92 * This is a duplication from Eiffel classes, but still used for trace printing and in EiffelCom.
93 */
94 EIF_REFERENCE eename(long code)
95 {
96 return GE_str8(GE_exception_tag(code));
97 }
98
99 /*
100 * Is exception `ex' defined?
101 * Used in EiffelCOM.
102 */
103 char eedefined(long ex)
104 {
105 return (char) ((ex > 0 && ex <= GE_EX_NEX)? 1 : 0);
106 }
107
108 /*
109 * Enable/diable printing of the exception trace.
110 * Per thead information.
111 */
112 void eetrace(char b) {
113 GE_context* context;
114
115 context = GE_current_context();
116 context->exception_trace_enabled = b;
117 }
118
119 /*
120 * Is current execution during rescue?
121 */
122 EIF_BOOLEAN eif_is_in_rescue(void)
123 {
124 GE_context* context;
125
126 context = GE_current_context();
127 return (EIF_TEST(context->in_rescue > 0));
128 }
129
130 #ifdef EIF_WINDOWS
131 /*
132 * Set default exception handler.
133 */
134 void set_windows_exception_filter()
135 {
136 GE_set_windows_exception_filter();
137 }
138 #endif
139
140 #ifdef __cplusplus
141 }
142 #endif
143
144 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23