kapplicative.h (777B)
1 /* 2 ** kapplicative.h 3 ** Kernel Applicatives 4 ** See Copyright Notice in klisp.h 5 */ 6 7 #ifndef kapplicative_h 8 #define kapplicative_h 9 10 #include "kobject.h" 11 #include "kstate.h" 12 #include "koperative.h" 13 14 /* GC: Assumes underlying is rooted */ 15 TValue kwrap(klisp_State *K, TValue underlying); 16 17 /* GC: Assumes all argps are rooted */ 18 #define kmake_applicative(K_, ...) \ 19 ({ klisp_State *K__ = (K_); \ 20 TValue op = kmake_operative(K__, __VA_ARGS__); \ 21 krooted_tvs_push(K__, op); \ 22 TValue app = kwrap(K__, op); \ 23 krooted_tvs_pop(K__); \ 24 (app); }) 25 26 static inline TValue kunwrap(TValue app) { return (tv2app(app)->underlying); } 27 28 #endif