theKernel 10.0
Loading...
Searching...
No Matches
MkExceptionC_rb.c
Go to the documentation of this file.
1
9/* LABEL-NO */
10
11#define META_FILE_NAME "MkExceptionC_rb.c"
12
13/* LABEL-END */
14
16
17static VALUE MK(MkExceptionC);
18static ID MK(id_Catch);
19
20// BEGIN-DOC
21// END-DOC
22
23// ---------------------------------------------------------------------------------------
24
28
29/*****************************************************************************/
30/* */
31/* O B J E C T */
32/* */
33/*****************************************************************************/
34
35/*
36static void MK(MkExceptionC_Delete) (MK_PTR data) {
37 MkRefDecr_M(data);
38}
39*/
40
43void MK(MkExceptionC_Raise) (
45 MK_MNGN const expobj,
46 MK_STRN const doc,
47 MK_STRN const callfunc,
48 MK_I32 callline
49) {
50 MK_ERR err = MkErrorFORMAT_1M(expobj);
51 MkErrorStackFormat(err,doc,callfunc,callline);
52 MK(Get_Call_Stack)(MK_RT_CALL err, 0);
53 MK_ERR newerr = MkErrCheck(expobj) && expobj != err ? (MK_ERR)expobj : MkErrorDup(err);
54 //VALUE errO = Data_Wrap_Struct(MK(MkExceptionC), NULL, MK(MkExceptionC_Delete), newerr);
55 VALUE args[2];
56 args[0] = OT_TMP_ERR_OBJ(newerr);
57 args[1] = STRN2VAL(MkErrorGetTextI(newerr));
58 VALUE errO = rb_class_new_instance(2,args,MK(MkExceptionC));
59 MkErrorReset_1(err);
60 rb_exc_raise(errO);
62}
63
66MK_ERR MK(MkExceptionC_Catch) (
68 MK_MNG const expobj,
69 MK_EXP exception,
70 MK_STRN const callfunc,
71 MK_STRN const stop
72) {
73 if (exception == NULL) exception = (MK_EXP) rb_errinfo();
74 VALUE ex = (VALUE) exception;
75 MK_ERR err = MkErrorFORMAT_1M(expobj);
76 if (rb_obj_is_kind_of(ex, MK(MkExceptionC)) == Qtrue) {
77 static ID id_mkerr = 0;
78 if (!id_mkerr) id_mkerr = rb_intern("mkerr");
79 MK_ERR newerr = VAL2ERR(rb_funcallv(ex,id_mkerr,0,NULL));
80 MkErrorSetE (err, newerr);
81 rb_set_errinfo(Qnil);
82 } else if (rb_obj_is_kind_of(ex, rb_eStandardError) == Qtrue) {
83
84 VALUE argv[4];
85 argv[0] = OT_TMP_ERR_OBJ(err);
86 argv[1] = ex;
87 argv[2] = STRN2VAL(callfunc);
88 argv[3] = stop == NULL ? Qnil : STRN2VAL(stop);
89
90 rb_funcallv(MK(MkExceptionC), MK(id_Catch), 4, argv);
91 rb_set_errinfo(Qnil);
92 } else if (rb_obj_is_kind_of(ex, rb_eSystemExit) == Qtrue) {
93 // exit in an callback
94 MkErrorSetEXIT(err,callfunc);
95 } else {
96 MkLogV_2X(err,"WARNING: re-raise exception (long-jump in code) → %s\n",
97 VAL2STRN(rb_inspect(ex))
98 );
99 rb_exc_raise(ex);
100 }
101 return err;
102}
103
105
106/*
107static OT_ProcRet MK(MkExceptionC_new) (CONSTR_ARGS) {
108 return Qundef;
109}
110*/
111
112static const char MkExceptionC_code[] =
113 // script2code.tcl MkExceptionC.rb > MkExceptionC.tpl
114 #include "MkExceptionC.tpl"
115;
116
117void MK(MkExceptionC_Init) (MK_RT_ARGS_ONLY) {
118
119 MK(id_Catch) = rb_intern("Catch");
120 MK(MkExceptionC) = rb_eval_string(MkExceptionC_code);
121}
122
tag: nhi1-release-250425
#define MK(n)
#define VAL2ERR(val)
#define VAL2STRN(val)
#define OT_TMP_ERR_OBJ(val)
#define OT_Prefix_ARGS
#define STRN2VAL(nat)
static const char MkExceptionC_code[]
struct MkErrorS * MK_ERR
class-shortcut for struct MkErrorS *, all shortcut using the XX_YYY syntax (only for public API) …
static bool MkErrCheck(MK_MNGN mng)
check MkErrorS -> MkObjectS::signature …
#define MkErrorGetTextI(e)
get the MkErrorS::text …
#define MkErrorReset_1(err)
#define MkErrorStackFormat(...)
#define MkErrorSetE(...)
#define MkErrorSetEXIT(...)
#define MkErrorFORMAT_1M(m)
#define MkErrorDup(...)
#define MK_UNREACHABLE
const MK_PTRB * MK_MNGN
const - a managed object pointer, datatype will be checked at runtime
const MK_STRB * MK_STRN
constant string pointer data-type
MK_PTRB * MK_MNG
managed object pointer, datatype will be checked at runtime
MK_PTRB const * MK_EXP
exception object pointer
signed int MK_I32
4 byte integer data-type
#define MkLogV_2X(x, printfmt,...)
#define MK_RT_CALL
#define MK_RT_ARGS_ONLY
The data-type to store and handle the error-condition …