move pic_try/pic_catch macros to error.h
This commit is contained in:
parent
42a491ad6e
commit
4a2cb90095
|
@ -134,15 +134,6 @@ void pic_define(pic_state *, const char *, pic_value); /* automatic export */
|
||||||
pic_value pic_ref(pic_state *, const char *);
|
pic_value pic_ref(pic_state *, const char *);
|
||||||
void pic_set(pic_state *, const char *, pic_value);
|
void pic_set(pic_state *, const char *, pic_value);
|
||||||
|
|
||||||
#define pic_try \
|
|
||||||
pic_try_helper__(GENSYM(i), GENSYM(here), GENSYM(prev_jmp))
|
|
||||||
#define pic_try_helper__(i, here, prev_jmp) \
|
|
||||||
for (int i = 0; ! i; ) \
|
|
||||||
for (jmp_buf here, *prev_jmp = pic->jmp; ! i; ) \
|
|
||||||
for (pic->jmp = &here; ! i++; pic->jmp = prev_jmp) \
|
|
||||||
if (setjmp(here) == 0)
|
|
||||||
#define pic_catch else
|
|
||||||
|
|
||||||
struct pic_proc *pic_get_proc(pic_state *);
|
struct pic_proc *pic_get_proc(pic_state *);
|
||||||
int pic_get_args(pic_state *, const char *, ...);
|
int pic_get_args(pic_state *, const char *, ...);
|
||||||
void pic_defun(pic_state *, const char *, pic_func_t);
|
void pic_defun(pic_state *, const char *, pic_func_t);
|
||||||
|
|
|
@ -24,6 +24,15 @@ struct pic_error {
|
||||||
#define pic_error_p(v) (pic_type(v) == PIC_TT_ERROR)
|
#define pic_error_p(v) (pic_type(v) == PIC_TT_ERROR)
|
||||||
#define pic_error_ptr(v) ((struct pic_error *)pic_ptr(v))
|
#define pic_error_ptr(v) ((struct pic_error *)pic_ptr(v))
|
||||||
|
|
||||||
|
#define pic_try \
|
||||||
|
pic_try_helper__(GENSYM(i), GENSYM(here), GENSYM(prev_jmp))
|
||||||
|
#define pic_try_helper__(i, here, prev_jmp) \
|
||||||
|
for (int i = 0; ! i; ) \
|
||||||
|
for (jmp_buf here, *prev_jmp = pic->jmp; ! i; ) \
|
||||||
|
for (pic->jmp = &here; ! i++; pic->jmp = prev_jmp) \
|
||||||
|
if (setjmp(here) == 0)
|
||||||
|
#define pic_catch else
|
||||||
|
|
||||||
pic_value pic_raise_continuable(pic_state *, pic_value);
|
pic_value pic_raise_continuable(pic_state *, pic_value);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "picrin/pair.h"
|
#include "picrin/pair.h"
|
||||||
#include "picrin/lib.h"
|
#include "picrin/lib.h"
|
||||||
#include "picrin/macro.h"
|
#include "picrin/macro.h"
|
||||||
|
#include "picrin/error.h"
|
||||||
|
|
||||||
void pic_init_bool(pic_state *);
|
void pic_init_bool(pic_state *);
|
||||||
void pic_init_pair(pic_state *);
|
void pic_init_pair(pic_state *);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "picrin.h"
|
#include "picrin.h"
|
||||||
#include "picrin/pair.h"
|
#include "picrin/pair.h"
|
||||||
|
#include "picrin/error.h"
|
||||||
|
|
||||||
#if PIC_ENABLE_READLINE
|
#if PIC_ENABLE_READLINE
|
||||||
# include <readline/readline.h>
|
# include <readline/readline.h>
|
||||||
|
|
Loading…
Reference in New Issue