Get returns working
This commit is contained in:
32
src/lisp.h
32
src/lisp.h
@ -108,6 +108,7 @@ typedef struct {
|
||||
LISP_OBJECT_HEADER;
|
||||
|
||||
LispVal *name;
|
||||
LispVal *return_tag;
|
||||
LispVal *doc;
|
||||
LispVal *args;
|
||||
bool is_builtin;
|
||||
@ -267,6 +268,8 @@ inline static bool NUMBERP(LispVal *v) {
|
||||
_INTERNAL_DEFUN_EXTENDED(true, c_name, lisp_name, c_args, )
|
||||
#define STATIC_DEFUN(c_name, lisp_name, c_args) \
|
||||
_INTERNAL_DEFUN_EXTENDED(false, c_name, lisp_name, c_args, static)
|
||||
#define STATIC_DEFMACRO(c_name, lisp_name, c_args) \
|
||||
_INTERNAL_DEFUN_EXTENDED(true, c_name, lisp_name, c_args, static)
|
||||
|
||||
// ###############
|
||||
// # Loop macros #
|
||||
@ -318,8 +321,8 @@ LispVal *make_lisp_integer(intmax_t value);
|
||||
LispVal *make_lisp_float(long double value);
|
||||
LispVal *make_lisp_vector(LispVal **data, size_t length);
|
||||
void set_function_args(LispFunction *func, LispVal *args);
|
||||
LispVal *make_lisp_function(LispVal *name, LispVal *args, LispVal *lexenv,
|
||||
LispVal *body, bool is_macro);
|
||||
LispVal *make_lisp_function(LispVal *name, LispVal *return_tag, LispVal *args,
|
||||
LispVal *lexenv, LispVal *body, bool is_macro);
|
||||
LispVal *make_lisp_hashtable(LispVal *eq_fn, LispVal *hash_fn);
|
||||
LispVal *make_user_pointer(void *data, void (*free_func)(void *));
|
||||
#define ALLOC_USERPTR(type, free_func) \
|
||||
@ -422,7 +425,8 @@ struct CleanupHandlerEntry {
|
||||
typedef struct StackFrame {
|
||||
struct StackFrame *next;
|
||||
bool hidden;
|
||||
LispSymbol *name;
|
||||
LispVal *name;
|
||||
LispVal *return_tag;
|
||||
LispVal *detail; // function arguments
|
||||
LispVal *lexenv; // symbol -> value
|
||||
bool enable_handlers;
|
||||
@ -519,14 +523,18 @@ LispVal *predicate_for_type(LispType type);
|
||||
|
||||
extern LispVal *Vobarray;
|
||||
|
||||
#define REGISTER_SYMBOL(sym) \
|
||||
{ \
|
||||
refcount_init_static(Q##sym); \
|
||||
refcount_init_static(((LispSymbol *) Q##sym)->name); \
|
||||
puthash(Vobarray, LISPVAL(((LispSymbol *) Q##sym)->name), Q##sym); \
|
||||
#define REGISTER_SYMBOL_NOINTERN(sym) \
|
||||
{ \
|
||||
refcount_init_static(Q##sym); \
|
||||
refcount_init_static(((LispSymbol *) Q##sym)->name); \
|
||||
}
|
||||
#define REGISTER_STATIC_FUNCTION(obj, args, docstr) \
|
||||
#define REGISTER_SYMBOL(sym) \
|
||||
REGISTER_SYMBOL_NOINTERN(sym) \
|
||||
puthash(Vobarray, LISPVAL(((LispSymbol *) Q##sym)->name), Q##sym);
|
||||
#define REGISTER_STATIC_FUNCTION(name, args, docstr) \
|
||||
REGISTER_SYMBOL_NOINTERN(name); \
|
||||
{ \
|
||||
LispVal *obj = ((LispSymbol *) Q##name)->function; \
|
||||
refcount_init_static(obj); \
|
||||
((LispFunction *) (obj))->doc = STATIC_STRING(docstr); \
|
||||
LispVal *src = STATIC_STRING(args); \
|
||||
@ -535,9 +543,9 @@ extern LispVal *Vobarray;
|
||||
refcount_unref(src); \
|
||||
refcount_unref(a); \
|
||||
}
|
||||
#define REGISTER_FUNCTION(fn, args, docstr) \
|
||||
REGISTER_SYMBOL(fn); \
|
||||
REGISTER_STATIC_FUNCTION(((LispSymbol *) Q##fn)->function, args, docstr);
|
||||
#define REGISTER_FUNCTION(fn, args, docstr) \
|
||||
REGISTER_STATIC_FUNCTION(fn, args, docstr); \
|
||||
puthash(Vobarray, LISPVAL(((LispSymbol *) Q##fn)->name), Q##fn);
|
||||
|
||||
void lisp_init(void);
|
||||
void lisp_shutdown(void);
|
||||
|
Reference in New Issue
Block a user