Files
glisp/src/function.h
2026-01-16 03:20:38 -08:00

34 lines
841 B
C

#ifndef INCLUDED_FUNCTION_H
#define INCLUDED_FUNCTION_H
#include "base.h"
struct LambdaList {
size_t n_req;
size_t n_opt;
size_t n_kw;
LispVal *req; // list of symbols
LispVal *opt; // list of lists of (name default has-p-name)
LispVal *kw; // ditto opt
LispVal *rest; // symbom (non-nil if we have a rest arg)
};
union native_function {
LispVal *(*zero)(void);
LispVal *(*one)(LispVal *);
LispVal *(*two)(LispVal *, LispVal *);
LispVal *(*three)(LispVal *, LispVal *, LispVal *);
LispVal *(*four)(LispVal *, LispVal *, LispVal *, LispVal *);
LispVal *(*five)(LispVal *, LispVal *, LispVal *, LispVal *, LispVal *);
};
DEFOBJTYPE(Function, FUNCTION, FUNCTIONP, {
bool is_native;
struct LambdaList args;
union {
union native_function native;
} impl;
});
#endif