Skip to content

Commit e8ef99d

Browse files
committed
Merge commit 'refs/pullreqs/155'
2 parents cca3036 + 19fcd16 commit e8ef99d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

lib/c.tcl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ namespace eval c {
5151
#include <setjmp.h>
5252

5353
jmp_buf __onError;
54+
Tcl_Interp* __interp;
5455

5556
#define __ENSURE(EXPR) if (!(EXPR)) { Tcl_SetResult(interp, "failed to convert argument from Tcl to C in: " #EXPR, NULL); longjmp(__onError, 0); }
5657
#define __ENSURE_OK(EXPR) if ((EXPR) != TCL_OK) { longjmp(__onError, 0); }
58+
59+
#define FOLK_ERROR(MSG) do { Tcl_SetResult(__interp, MSG, NULL); longjmp(__onError, 0); } while (0)
60+
#define FOLK_ENSURE(EXPR) if (!(EXPR)) { Tcl_SetResult(__interp, "assertion failed: " #EXPR, NULL); longjmp(__onError, 0); }
61+
#define FOLK_CHECK(EXPR, MSG) if (!(EXPR)) { FOLK_ERROR(MSG); }
5762
}
5863
variable code [list]
5964
variable objtypes [list]
@@ -438,6 +443,7 @@ namespace eval c {
438443
Tcl_SetResult(interp, "Wrong number of arguments to $name", NULL);
439444
return TCL_ERROR;
440445
}
446+
__interp = interp;
441447
int r = setjmp(__onError);
442448
if (r != 0) { return TCL_ERROR; }
443449

0 commit comments

Comments
 (0)