Removing uses of sexp_api_params and sexp_api_pass which were ugly and no longer supported anyway.

The definitions are still provided for backwards compatibility.
This commit is contained in:
Alex Shinn 2011-11-07 01:30:55 +09:00
parent e65ed61b26
commit 1b4cc2ad14
25 changed files with 421 additions and 423 deletions

110
eval.c
View file

@ -12,9 +12,9 @@ static sexp analyze (sexp ctx, sexp x);
static void generate (sexp ctx, sexp name, sexp loc, sexp lam, sexp x); static void generate (sexp ctx, sexp name, sexp loc, sexp lam, sexp x);
#if SEXP_USE_MODULES #if SEXP_USE_MODULES
sexp sexp_load_module_file_op (sexp ctx sexp_api_params(self, n), sexp file, sexp env); sexp sexp_load_module_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp file, sexp env);
sexp sexp_find_module_file_op (sexp ctx sexp_api_params(self, n), sexp file); sexp sexp_find_module_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp file);
sexp sexp_current_environment (sexp ctx sexp_api_params(self, n)); sexp sexp_current_environment (sexp ctx, sexp self, sexp_sint_t n);
#endif #endif
sexp sexp_compile_error (sexp ctx, const char *message, sexp o) { sexp sexp_compile_error (sexp ctx, const char *message, sexp o) {
@ -148,7 +148,7 @@ sexp sexp_env_rename (sexp ctx, sexp env, sexp key, sexp value) {
} }
#endif #endif
sexp sexp_env_exports_op (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_env_exports_op (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp ls; sexp ls;
sexp_gc_var1(res); sexp_gc_var1(res);
sexp_gc_preserve1(ctx, res); sexp_gc_preserve1(ctx, res);
@ -289,7 +289,7 @@ static void emit (sexp ctx, unsigned char c) {
sexp_bytecode_data(sexp_context_bc(ctx))[sexp_context_pos(ctx)++] = c; sexp_bytecode_data(sexp_context_bc(ctx))[sexp_context_pos(ctx)++] = c;
} }
sexp sexp_make_procedure_op (sexp ctx sexp_api_params(self, n), sexp flags, sexp sexp_make_procedure_op (sexp ctx, sexp self, sexp_sint_t n, sexp flags,
sexp num_args, sexp bc, sexp vars) { sexp num_args, sexp bc, sexp vars) {
sexp proc = sexp_alloc_type(ctx, procedure, SEXP_PROCEDURE); sexp proc = sexp_alloc_type(ctx, procedure, SEXP_PROCEDURE);
sexp_procedure_flags(proc) = (char) (sexp_uint_t) flags; sexp_procedure_flags(proc) = (char) (sexp_uint_t) flags;
@ -306,7 +306,7 @@ static sexp sexp_make_macro (sexp ctx, sexp p, sexp e) {
return mac; return mac;
} }
sexp sexp_make_synclo_op (sexp ctx sexp_api_params(self, n), sexp env, sexp fv, sexp expr) { sexp sexp_make_synclo_op (sexp ctx, sexp self, sexp_sint_t n, sexp env, sexp fv, sexp expr) {
sexp res; sexp res;
if (! (sexp_symbolp(expr) || sexp_pairp(expr))) if (! (sexp_symbolp(expr) || sexp_pairp(expr)))
return expr; return expr;
@ -464,15 +464,15 @@ sexp sexp_make_child_context (sexp ctx, sexp lambda) {
/**************************** identifiers *****************************/ /**************************** identifiers *****************************/
sexp sexp_identifierp_op (sexp ctx sexp_api_params(self, n), sexp x) { sexp sexp_identifierp_op (sexp ctx, sexp self, sexp_sint_t n, sexp x) {
return sexp_make_boolean(sexp_idp(x)); return sexp_make_boolean(sexp_idp(x));
} }
sexp sexp_syntactic_closure_expr_op (sexp ctx sexp_api_params(self, n), sexp x) { sexp sexp_syntactic_closure_expr_op (sexp ctx, sexp self, sexp_sint_t n, sexp x) {
return (sexp_synclop(x) ? sexp_synclo_expr(x) : x); return (sexp_synclop(x) ? sexp_synclo_expr(x) : x);
} }
sexp sexp_strip_synclos (sexp ctx sexp_api_params(self, n), sexp x) { sexp sexp_strip_synclos (sexp ctx, sexp self, sexp_sint_t n, sexp x) {
sexp_gc_var3(res, kar, kdr); sexp_gc_var3(res, kar, kdr);
sexp_gc_preserve3(ctx, res, kar, kdr); sexp_gc_preserve3(ctx, res, kar, kdr);
loop: loop:
@ -480,8 +480,8 @@ sexp sexp_strip_synclos (sexp ctx sexp_api_params(self, n), sexp x) {
x = sexp_synclo_expr(x); x = sexp_synclo_expr(x);
goto loop; goto loop;
} else if (sexp_pairp(x) && sexp_truep(sexp_length(ctx, x))) { } else if (sexp_pairp(x) && sexp_truep(sexp_length(ctx, x))) {
kar = sexp_strip_synclos(ctx sexp_api_pass(self, n), sexp_car(x)); kar = sexp_strip_synclos(ctx, self, n, sexp_car(x));
kdr = sexp_strip_synclos(ctx sexp_api_pass(self, n), sexp_cdr(x)); kdr = sexp_strip_synclos(ctx, self, n, sexp_cdr(x));
res = sexp_cons(ctx, kar, kdr); res = sexp_cons(ctx, kar, kdr);
sexp_pair_source(res) = sexp_pair_source(x); sexp_pair_source(res) = sexp_pair_source(x);
sexp_immutablep(res) = 1; sexp_immutablep(res) = 1;
@ -492,7 +492,7 @@ sexp sexp_strip_synclos (sexp ctx sexp_api_params(self, n), sexp x) {
return res; return res;
} }
sexp sexp_identifier_eq_op (sexp ctx sexp_api_params(self, n), sexp e1, sexp id1, sexp e2, sexp id2) { sexp sexp_identifier_eq_op (sexp ctx, sexp self, sexp_sint_t n, sexp e1, sexp id1, sexp e2, sexp id2) {
sexp cell1, cell2; sexp cell1, cell2;
cell1 = sexp_env_cell(e1, id1, 0); cell1 = sexp_env_cell(e1, id1, 0);
if (!cell1 && sexp_synclop(id1)) { if (!cell1 && sexp_synclop(id1)) {
@ -857,7 +857,7 @@ static sexp analyze (sexp ctx, sexp object) {
else else
res = sexp_make_lit(ctx, res = sexp_make_lit(ctx,
(sexp_core_code(op) == SEXP_CORE_QUOTE) ? (sexp_core_code(op) == SEXP_CORE_QUOTE) ?
sexp_strip_synclos(ctx sexp_api_pass(NULL, 1), sexp_cadr(x)) : sexp_strip_synclos(ctx , NULL, 1, sexp_cadr(x)) :
sexp_cadr(x)); sexp_cadr(x));
break; break;
case SEXP_CORE_DEFINE_SYNTAX: case SEXP_CORE_DEFINE_SYNTAX:
@ -996,12 +996,12 @@ sexp sexp_free_vars (sexp ctx, sexp x, sexp fv) {
/************************ library procedures **************************/ /************************ library procedures **************************/
sexp sexp_exception_type_op (sexp ctx sexp_api_params(self, n), sexp exn) { sexp sexp_exception_type_op (sexp ctx, sexp self, sexp_sint_t n, sexp exn) {
sexp_assert_type(ctx, sexp_exceptionp, SEXP_EXCEPTION, exn); sexp_assert_type(ctx, sexp_exceptionp, SEXP_EXCEPTION, exn);
return sexp_exception_kind(exn); return sexp_exception_kind(exn);
} }
sexp sexp_open_input_file_op (sexp ctx sexp_api_params(self, n), sexp path) { sexp sexp_open_input_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp path) {
FILE *in; FILE *in;
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, path); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, path);
in = fopen(sexp_string_data(path), "r"); in = fopen(sexp_string_data(path), "r");
@ -1013,7 +1013,7 @@ sexp sexp_open_input_file_op (sexp ctx sexp_api_params(self, n), sexp path) {
return sexp_make_input_port(ctx, in, path); return sexp_make_input_port(ctx, in, path);
} }
sexp sexp_open_output_file_op (sexp ctx sexp_api_params(self, n), sexp path) { sexp sexp_open_output_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp path) {
FILE *out; FILE *out;
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, path); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, path);
out = fopen(sexp_string_data(path), "w"); out = fopen(sexp_string_data(path), "w");
@ -1022,23 +1022,23 @@ sexp sexp_open_output_file_op (sexp ctx sexp_api_params(self, n), sexp path) {
return sexp_make_output_port(ctx, out, path); return sexp_make_output_port(ctx, out, path);
} }
sexp sexp_open_binary_input_file (sexp ctx sexp_api_params(self, n), sexp path) { sexp sexp_open_binary_input_file (sexp ctx, sexp self, sexp_sint_t n, sexp path) {
sexp res = sexp_open_input_file_op(ctx, self, n, path); sexp res = sexp_open_input_file_op(ctx, self, n, path);
if (sexp_portp(res)) sexp_port_binaryp(res) = 1; if (sexp_portp(res)) sexp_port_binaryp(res) = 1;
return res; return res;
} }
sexp sexp_open_binary_output_file (sexp ctx sexp_api_params(self, n), sexp path) { sexp sexp_open_binary_output_file (sexp ctx, sexp self, sexp_sint_t n, sexp path) {
sexp res = sexp_open_output_file_op(ctx, self, n, path); sexp res = sexp_open_output_file_op(ctx, self, n, path);
if (sexp_portp(res)) sexp_port_binaryp(res) = 1; if (sexp_portp(res)) sexp_port_binaryp(res) = 1;
return res; return res;
} }
sexp sexp_close_port_op (sexp ctx sexp_api_params(self, n), sexp port) { sexp sexp_close_port_op (sexp ctx, sexp self, sexp_sint_t n, sexp port) {
sexp_assert_type(ctx, sexp_portp, SEXP_OPORT, port); sexp_assert_type(ctx, sexp_portp, SEXP_OPORT, port);
if (! sexp_port_openp(port)) if (! sexp_port_openp(port))
return sexp_user_exception(ctx, self, "port already closed", port); return sexp_user_exception(ctx, self, "port already closed", port);
return sexp_finalize_port(ctx sexp_api_pass(self, n), port); return sexp_finalize_port(ctx, self, n, port);
} }
#if SEXP_USE_STATIC_LIBS #if SEXP_USE_STATIC_LIBS
@ -1063,7 +1063,7 @@ static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
if (! entry) if (! entry)
return sexp_compile_error(ctx, "couldn't find builtin library", file); return sexp_compile_error(ctx, "couldn't find builtin library", file);
return entry->init(ctx sexp_api_pass(NULL, 1), env); return entry->init(ctx, NULL, 1, env);
} }
#else #else
#define sexp_find_static_library(path) NULL #define sexp_find_static_library(path) NULL
@ -1080,7 +1080,7 @@ static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
FreeLibrary(handle); FreeLibrary(handle);
return sexp_compile_error(ctx, "dynamic library has no sexp_init_library", file); return sexp_compile_error(ctx, "dynamic library has no sexp_init_library", file);
} }
return init(ctx sexp_api_pass(NULL, 1), env); return init(ctx, NULL, 1, env);
} }
#else #else
static sexp sexp_make_dl (sexp ctx, sexp file, void* handle) { static sexp sexp_make_dl (sexp ctx, sexp file, void* handle) {
@ -1103,7 +1103,7 @@ static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
sexp_gc_preserve2(ctx, res, old_dl); sexp_gc_preserve2(ctx, res, old_dl);
old_dl = sexp_context_dl(ctx); old_dl = sexp_context_dl(ctx);
sexp_context_dl(ctx) = sexp_make_dl(ctx, file, handle); sexp_context_dl(ctx) = sexp_make_dl(ctx, file, handle);
res = init(ctx sexp_api_pass(NULL, 1), env); res = init(ctx, NULL, 1, env);
sexp_context_dl(ctx) = old_dl; sexp_context_dl(ctx) = old_dl;
sexp_gc_release2(ctx); sexp_gc_release2(ctx);
return res; return res;
@ -1112,7 +1112,7 @@ static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
#endif #endif
#endif #endif
sexp sexp_load_op (sexp ctx sexp_api_params(self, n), sexp source, sexp env) { sexp sexp_load_op (sexp ctx, sexp self, sexp_sint_t n, sexp source, sexp env) {
#if SEXP_USE_DL || SEXP_USE_STATIC_LIBS #if SEXP_USE_DL || SEXP_USE_STATIC_LIBS
char *suffix; char *suffix;
#endif #endif
@ -1167,7 +1167,7 @@ sexp sexp_load_op (sexp ctx sexp_api_params(self, n), sexp source, sexp env) {
return res; return res;
} }
sexp sexp_register_optimization (sexp ctx sexp_api_params(self, n), sexp f, sexp priority) { sexp sexp_register_optimization (sexp ctx, sexp self, sexp_sint_t n, sexp f, sexp priority) {
sexp_assert_type(ctx, sexp_applicablep, SEXP_PROCEDURE, f); sexp_assert_type(ctx, sexp_applicablep, SEXP_PROCEDURE, f);
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, priority); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, priority);
sexp_push(ctx, sexp_global(ctx, SEXP_G_OPTIMIZATIONS), SEXP_VOID); sexp_push(ctx, sexp_global(ctx, SEXP_G_OPTIMIZATIONS), SEXP_VOID);
@ -1200,7 +1200,7 @@ sexp sexp_register_optimization (sexp ctx sexp_api_params(self, n), sexp f, sexp
#endif #endif
#define define_math_op(name, cname, t, f) \ #define define_math_op(name, cname, t, f) \
sexp name (sexp ctx sexp_api_params(self, n), sexp z) { \ sexp name (sexp ctx, sexp self, sexp_sint_t n, sexp z) { \
double d; \ double d; \
if (sexp_flonump(z)) \ if (sexp_flonump(z)) \
d = sexp_flonum_value(z); \ d = sexp_flonum_value(z); \
@ -1227,7 +1227,7 @@ define_math_op(sexp_trunc, trunc, 0, sexp_complex_dummy)
define_math_op(sexp_floor, floor, 0, sexp_complex_dummy) define_math_op(sexp_floor, floor, 0, sexp_complex_dummy)
define_math_op(sexp_ceiling, ceil, 0, sexp_complex_dummy) define_math_op(sexp_ceiling, ceil, 0, sexp_complex_dummy)
sexp sexp_sqrt (sexp ctx sexp_api_params(self, n), sexp z) { sexp sexp_sqrt (sexp ctx, sexp self, sexp_sint_t n, sexp z) {
#if SEXP_USE_COMPLEX #if SEXP_USE_COMPLEX
int negativep = 0; int negativep = 0;
#endif #endif
@ -1278,7 +1278,7 @@ sexp sexp_generic_expt (sexp ctx, sexp x, sexp_sint_t e) {
} }
#endif #endif
sexp sexp_expt_op (sexp ctx sexp_api_params(self, n), sexp x, sexp e) { sexp sexp_expt_op (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp e) {
long double f, x1, e1; long double f, x1, e1;
sexp res; sexp res;
#if SEXP_USE_COMPLEX #if SEXP_USE_COMPLEX
@ -1353,28 +1353,28 @@ sexp sexp_expt_op (sexp ctx sexp_api_params(self, n), sexp x, sexp e) {
} }
#if SEXP_USE_RATIOS #if SEXP_USE_RATIOS
sexp sexp_ratio_numerator_op (sexp ctx sexp_api_params(self, n), sexp rat) { sexp sexp_ratio_numerator_op (sexp ctx, sexp self, sexp_sint_t n, sexp rat) {
sexp_assert_type(ctx, sexp_ratiop, SEXP_RATIO, rat); sexp_assert_type(ctx, sexp_ratiop, SEXP_RATIO, rat);
return sexp_ratio_numerator(rat); return sexp_ratio_numerator(rat);
} }
sexp sexp_ratio_denominator_op (sexp ctx sexp_api_params(self, n), sexp rat) { sexp sexp_ratio_denominator_op (sexp ctx, sexp self, sexp_sint_t n, sexp rat) {
sexp_assert_type(ctx, sexp_ratiop, SEXP_RATIO, rat); sexp_assert_type(ctx, sexp_ratiop, SEXP_RATIO, rat);
return sexp_ratio_denominator(rat); return sexp_ratio_denominator(rat);
} }
#endif #endif
#if SEXP_USE_COMPLEX #if SEXP_USE_COMPLEX
sexp sexp_complex_real_op (sexp ctx sexp_api_params(self, n), sexp cpx) { sexp sexp_complex_real_op (sexp ctx, sexp self, sexp_sint_t n, sexp cpx) {
sexp_assert_type(ctx, sexp_complexp, SEXP_COMPLEX, cpx); sexp_assert_type(ctx, sexp_complexp, SEXP_COMPLEX, cpx);
return sexp_complex_real(cpx); return sexp_complex_real(cpx);
} }
sexp sexp_complex_imag_op (sexp ctx sexp_api_params(self, n), sexp cpx) { sexp sexp_complex_imag_op (sexp ctx, sexp self, sexp_sint_t n, sexp cpx) {
sexp_assert_type(ctx, sexp_complexp, SEXP_COMPLEX, cpx); sexp_assert_type(ctx, sexp_complexp, SEXP_COMPLEX, cpx);
return sexp_complex_imag(cpx); return sexp_complex_imag(cpx);
} }
#endif #endif
sexp sexp_string_cmp_op (sexp ctx sexp_api_params(self, n), sexp str1, sexp str2, sexp ci) { sexp sexp_string_cmp_op (sexp ctx, sexp self, sexp_sint_t n, sexp str1, sexp str2, sexp ci) {
sexp_sint_t len1, len2, len, diff; sexp_sint_t len1, len2, len, diff;
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str1); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str1);
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str2); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str2);
@ -1433,11 +1433,11 @@ sexp sexp_string_utf8_ref (sexp ctx, sexp str, sexp i) {
return sexp_make_character(((p[0]&0x0F)<<16) + ((p[1]&0x3F)<<6) + ((p[2]&0x3F)<<6) + (p[2]&0x3F)); return sexp_make_character(((p[0]&0x0F)<<16) + ((p[1]&0x3F)<<6) + ((p[2]&0x3F)<<6) + (p[2]&0x3F));
} }
sexp sexp_string_utf8_index_ref (sexp ctx sexp_api_params(self, n), sexp str, sexp i) { sexp sexp_string_utf8_index_ref (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp i) {
sexp off; sexp off;
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str);
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, i); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, i);
off = sexp_string_index_to_offset(ctx sexp_api_pass(self, n), str, i); off = sexp_string_index_to_offset(ctx, self, n, str, i);
if (sexp_exceptionp(off)) return off; if (sexp_exceptionp(off)) return off;
return sexp_string_utf8_ref(ctx, str, off); return sexp_string_utf8_ref(ctx, str, off);
} }
@ -1493,12 +1493,12 @@ void sexp_string_utf8_set (sexp ctx, sexp str, sexp index, sexp ch) {
sexp_utf8_encode_char(p, new_len, c); sexp_utf8_encode_char(p, new_len, c);
} }
sexp sexp_string_utf8_index_set (sexp ctx sexp_api_params(self, n), sexp str, sexp i, sexp ch) { sexp sexp_string_utf8_index_set (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp i, sexp ch) {
sexp off; sexp off;
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str);
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, i); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, i);
sexp_assert_type(ctx, sexp_charp, SEXP_CHAR, ch); sexp_assert_type(ctx, sexp_charp, SEXP_CHAR, ch);
off = sexp_string_index_to_offset(ctx sexp_api_pass(self, n), str, i); off = sexp_string_index_to_offset(ctx, self, n, str, i);
if (sexp_exceptionp(off)) return off; if (sexp_exceptionp(off)) return off;
sexp_string_utf8_set(ctx, str, off, ch); sexp_string_utf8_set(ctx, str, off, ch);
return SEXP_VOID; return SEXP_VOID;
@ -1508,7 +1508,7 @@ sexp sexp_string_utf8_index_set (sexp ctx sexp_api_params(self, n), sexp str, se
#endif #endif
#if SEXP_USE_AUTO_FORCE #if SEXP_USE_AUTO_FORCE
sexp sexp_make_promise (sexp ctx sexp_api_params(self, n), sexp done, sexp val) { sexp sexp_make_promise (sexp ctx, sexp self, sexp_sint_t n, sexp done, sexp val) {
sexp res = sexp_alloc_type(ctx, promise, SEXP_PROMISE); sexp res = sexp_alloc_type(ctx, promise, SEXP_PROMISE);
sexp_promise_donep(res) = sexp_unbox_boolean(done); sexp_promise_donep(res) = sexp_unbox_boolean(done);
sexp_promise_value(res) = val; sexp_promise_value(res) = val;
@ -1532,7 +1532,7 @@ sexp sexp_make_promise (sexp ctx sexp_api_params(self, n), sexp done, sexp val)
#if SEXP_USE_TYPE_DEFS #if SEXP_USE_TYPE_DEFS
sexp sexp_type_slot_offset_op (sexp ctx sexp_api_params(self, n), sexp type, sexp slot) { sexp sexp_type_slot_offset_op (sexp ctx , sexp self, sexp_sint_t n, sexp type, sexp slot) {
sexp cpl, slots, *v; sexp cpl, slots, *v;
int i, offset=0, len; int i, offset=0, len;
sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, type); sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, type);
@ -1552,7 +1552,7 @@ sexp sexp_type_slot_offset_op (sexp ctx sexp_api_params(self, n), sexp type, se
return SEXP_FALSE; return SEXP_FALSE;
} }
sexp sexp_make_type_predicate_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type) { sexp sexp_make_type_predicate_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type) {
if (sexp_typep(type)) type = sexp_make_fixnum(sexp_type_tag(type)); if (sexp_typep(type)) type = sexp_make_fixnum(sexp_type_tag(type));
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, type); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, type);
return sexp_make_opcode(ctx, self, name, sexp_make_fixnum(SEXP_OPC_TYPE_PREDICATE), return sexp_make_opcode(ctx, self, name, sexp_make_fixnum(SEXP_OPC_TYPE_PREDICATE),
@ -1560,7 +1560,7 @@ sexp sexp_make_type_predicate_op (sexp ctx sexp_api_params(self, n), sexp name,
SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, type, NULL, NULL); SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, type, NULL, NULL);
} }
sexp sexp_make_constructor_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type) { sexp sexp_make_constructor_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type) {
sexp_uint_t type_size; sexp_uint_t type_size;
if (sexp_typep(type)) type = sexp_make_fixnum(sexp_type_tag(type)); if (sexp_typep(type)) type = sexp_make_fixnum(sexp_type_tag(type));
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, type); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, type);
@ -1571,7 +1571,7 @@ sexp sexp_make_constructor_op (sexp ctx sexp_api_params(self, n), sexp name, sex
sexp_make_fixnum(type_size), NULL); sexp_make_fixnum(type_size), NULL);
} }
sexp sexp_make_getter_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type, sexp index) { sexp sexp_make_getter_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type, sexp index) {
if (sexp_typep(type)) type = sexp_make_fixnum(sexp_type_tag(type)); if (sexp_typep(type)) type = sexp_make_fixnum(sexp_type_tag(type));
if ((! sexp_fixnump(type)) || (sexp_unbox_fixnum(type) < 0)) if ((! sexp_fixnump(type)) || (sexp_unbox_fixnum(type) < 0))
return sexp_type_exception(ctx, self, SEXP_FIXNUM, type); return sexp_type_exception(ctx, self, SEXP_FIXNUM, type);
@ -1583,7 +1583,7 @@ sexp sexp_make_getter_op (sexp ctx sexp_api_params(self, n), sexp name, sexp typ
type, SEXP_ZERO, SEXP_ZERO, type, index, NULL); type, SEXP_ZERO, SEXP_ZERO, type, index, NULL);
} }
sexp sexp_make_setter_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type, sexp index) { sexp sexp_make_setter_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type, sexp index) {
sexp res; sexp res;
if (sexp_typep(type)) type = sexp_make_fixnum(sexp_type_tag(type)); if (sexp_typep(type)) type = sexp_make_fixnum(sexp_type_tag(type));
if ((! sexp_fixnump(type)) || (sexp_unbox_fixnum(type) < 0)) if ((! sexp_fixnump(type)) || (sexp_unbox_fixnum(type) < 0))
@ -1601,8 +1601,8 @@ sexp sexp_make_setter_op (sexp ctx sexp_api_params(self, n), sexp name, sexp typ
#endif #endif
#if SEXP_USE_PROFILE_VM #if SEXP_USE_PROFILE_VM
static sexp sexp_reset_vm_profile (sexp ctx sexp_api_params(self, n)); static sexp sexp_reset_vm_profile (sexp ctx, sexp self, sexp_sint_t n);
static sexp sexp_print_vm_profile (sexp ctx sexp_api_params(self, n)); static sexp sexp_print_vm_profile (sexp ctx, sexp self, sexp_sint_t n);
#endif #endif
#include "opcodes.c" #include "opcodes.c"
@ -1722,7 +1722,7 @@ static struct sexp_core_form_struct core_forms[] = {
{SEXP_CORE_LETREC_SYNTAX, (sexp)"letrec-syntax"}, {SEXP_CORE_LETREC_SYNTAX, (sexp)"letrec-syntax"},
}; };
sexp sexp_make_env_op (sexp ctx sexp_api_params(self, n)) { sexp sexp_make_env_op (sexp ctx, sexp self, sexp_sint_t n) {
sexp e = sexp_alloc_type(ctx, env, SEXP_ENV); sexp e = sexp_alloc_type(ctx, env, SEXP_ENV);
sexp_env_lambda(e) = NULL; sexp_env_lambda(e) = NULL;
sexp_env_parent(e) = NULL; sexp_env_parent(e) = NULL;
@ -1733,7 +1733,7 @@ sexp sexp_make_env_op (sexp ctx sexp_api_params(self, n)) {
return e; return e;
} }
sexp sexp_make_null_env_op (sexp ctx sexp_api_params(self, n), sexp version) { sexp sexp_make_null_env_op (sexp ctx, sexp self, sexp_sint_t n, sexp version) {
sexp_uint_t i; sexp_uint_t i;
sexp_gc_var2(e, core); sexp_gc_var2(e, core);
sexp_gc_preserve2(ctx, e, core); sexp_gc_preserve2(ctx, e, core);
@ -1824,21 +1824,21 @@ sexp sexp_load_module_file (sexp ctx, const char *file, sexp env) {
} }
#if SEXP_USE_MODULES #if SEXP_USE_MODULES
sexp sexp_find_module_file_op (sexp ctx sexp_api_params(self, n), sexp file) { sexp sexp_find_module_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp file) {
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, file); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, file);
return sexp_find_module_file(ctx, sexp_string_data(file)); return sexp_find_module_file(ctx, sexp_string_data(file));
} }
sexp sexp_load_module_file_op (sexp ctx sexp_api_params(self, n), sexp file, sexp env) { sexp sexp_load_module_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp file, sexp env) {
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, file); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, file);
sexp_assert_type(ctx, sexp_envp, SEXP_ENV, env); sexp_assert_type(ctx, sexp_envp, SEXP_ENV, env);
return sexp_load_module_file(ctx, sexp_string_data(file), env); return sexp_load_module_file(ctx, sexp_string_data(file), env);
} }
sexp sexp_current_environment (sexp ctx sexp_api_params(self, n)) { sexp sexp_current_environment (sexp ctx, sexp self, sexp_sint_t n) {
return sexp_context_env(ctx); return sexp_context_env(ctx);
} }
#endif #endif
sexp sexp_add_module_directory_op (sexp ctx sexp_api_params(self, n), sexp dir, sexp appendp) { sexp sexp_add_module_directory_op (sexp ctx, sexp self, sexp_sint_t n, sexp dir, sexp appendp) {
sexp ls; sexp ls;
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, dir); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, dir);
if (sexp_truep(appendp)) { if (sexp_truep(appendp)) {
@ -1980,7 +1980,7 @@ sexp sexp_load_standard_env (sexp ctx, sexp e, sexp version) {
return sexp_exceptionp(tmp) ? tmp : e; return sexp_exceptionp(tmp) ? tmp : e;
} }
sexp sexp_make_standard_env_op (sexp ctx sexp_api_params(self, n), sexp version) { sexp sexp_make_standard_env_op (sexp ctx, sexp self, sexp_sint_t n, sexp version) {
sexp_gc_var1(env); sexp_gc_var1(env);
sexp_gc_preserve1(ctx, env); sexp_gc_preserve1(ctx, env);
env = sexp_make_primitive_env(ctx, version); env = sexp_make_primitive_env(ctx, version);
@ -1995,7 +1995,7 @@ sexp sexp_make_standard_env_op (sexp ctx sexp_api_params(self, n), sexp version)
#define sexp_same_bindingp(x, y) (sexp_env_value(x) == sexp_env_value(y)) #define sexp_same_bindingp(x, y) (sexp_env_value(x) == sexp_env_value(y))
#endif #endif
sexp sexp_env_import_op (sexp ctx sexp_api_params(self, n), sexp to, sexp from, sexp ls, sexp immutp) { sexp sexp_env_import_op (sexp ctx, sexp self, sexp_sint_t n, sexp to, sexp from, sexp ls, sexp immutp) {
sexp oldname, newname; sexp oldname, newname;
sexp_gc_var2(value, oldcell); sexp_gc_var2(value, oldcell);
sexp_gc_preserve2(ctx, value, oldcell); sexp_gc_preserve2(ctx, value, oldcell);
@ -2048,7 +2048,7 @@ sexp sexp_env_import_op (sexp ctx sexp_api_params(self, n), sexp to, sexp from,
/************************** eval interface ****************************/ /************************** eval interface ****************************/
sexp sexp_compile_op (sexp ctx sexp_api_params(self, n), sexp obj, sexp env) { sexp sexp_compile_op (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp env) {
sexp_gc_var3(ast, vec, res); sexp_gc_var3(ast, vec, res);
sexp ctx2; sexp ctx2;
if (! env) env = sexp_context_env(ctx); if (! env) env = sexp_context_env(ctx);
@ -2075,7 +2075,7 @@ sexp sexp_compile_op (sexp ctx sexp_api_params(self, n), sexp obj, sexp env) {
return res; return res;
} }
sexp sexp_eval_op (sexp ctx sexp_api_params(self, n), sexp obj, sexp env) { sexp sexp_eval_op (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp env) {
sexp_sint_t top; sexp_sint_t top;
sexp ctx2; sexp ctx2;
sexp_gc_var2(res, params); sexp_gc_var2(res, params);

2
gc.c
View file

@ -338,7 +338,7 @@ sexp sexp_sweep (sexp ctx, size_t *sum_freed_ptr) {
if (!sexp_markedp(p)) { if (!sexp_markedp(p)) {
/* free p */ /* free p */
finalizer = sexp_type_finalize(sexp_object_type(ctx, p)); finalizer = sexp_type_finalize(sexp_object_type(ctx, p));
if (finalizer) finalizer(ctx sexp_api_pass(NULL, 1), p); if (finalizer) finalizer(ctx, NULL, 1, p);
sum_freed += size; sum_freed += size;
if (((((char*)q) + q->size) == (char*)p) && (q != h->free_list)) { if (((((char*)q) + q->size) == (char*)p) && (q != h->free_list)) {
/* merge q with p */ /* merge q with p */

View file

@ -56,28 +56,28 @@ SEXP_API sexp sexp_analyze (sexp context, sexp x);
SEXP_API void sexp_stack_trace (sexp ctx, sexp out); SEXP_API void sexp_stack_trace (sexp ctx, sexp out);
SEXP_API sexp sexp_free_vars (sexp context, sexp x, sexp fv); SEXP_API sexp sexp_free_vars (sexp context, sexp x, sexp fv);
SEXP_API int sexp_param_index (sexp lambda, sexp name); SEXP_API int sexp_param_index (sexp lambda, sexp name);
SEXP_API sexp sexp_compile_op (sexp context sexp_api_params(self, n), sexp obj, sexp env); SEXP_API sexp sexp_compile_op (sexp context, sexp self, sexp_sint_t n, sexp obj, sexp env);
SEXP_API sexp sexp_eval_op (sexp context sexp_api_params(self, n), sexp obj, sexp env); SEXP_API sexp sexp_eval_op (sexp context, sexp self, sexp_sint_t n, sexp obj, sexp env);
SEXP_API sexp sexp_eval_string (sexp context, const char *str, sexp_sint_t len, sexp env); SEXP_API sexp sexp_eval_string (sexp context, const char *str, sexp_sint_t len, sexp env);
SEXP_API sexp sexp_load_op (sexp context sexp_api_params(self, n), sexp expr, sexp env); SEXP_API sexp sexp_load_op (sexp context, sexp self, sexp_sint_t n, sexp expr, sexp env);
SEXP_API sexp sexp_make_env_op (sexp context sexp_api_params(self, n)); SEXP_API sexp sexp_make_env_op (sexp context, sexp self, sexp_sint_t n);
SEXP_API sexp sexp_make_null_env_op (sexp context sexp_api_params(self, n), sexp version); SEXP_API sexp sexp_make_null_env_op (sexp context, sexp self, sexp_sint_t n, sexp version);
SEXP_API sexp sexp_make_primitive_env (sexp context, sexp version); SEXP_API sexp sexp_make_primitive_env (sexp context, sexp version);
SEXP_API sexp sexp_make_standard_env_op (sexp context sexp_api_params(self, n), sexp version); SEXP_API sexp sexp_make_standard_env_op (sexp context, sexp self, sexp_sint_t n, sexp version);
SEXP_API void sexp_set_parameter (sexp ctx, sexp env, sexp name, sexp value); SEXP_API void sexp_set_parameter (sexp ctx, sexp env, sexp name, sexp value);
SEXP_API sexp sexp_load_standard_ports (sexp context, sexp env, FILE* in, FILE* out, FILE* err, int no_close); SEXP_API sexp sexp_load_standard_ports (sexp context, sexp env, FILE* in, FILE* out, FILE* err, int no_close);
SEXP_API sexp sexp_load_standard_env (sexp context, sexp env, sexp version); SEXP_API sexp sexp_load_standard_env (sexp context, sexp env, sexp version);
SEXP_API sexp sexp_find_module_file (sexp ctx, const char *file); SEXP_API sexp sexp_find_module_file (sexp ctx, const char *file);
SEXP_API sexp sexp_load_module_file (sexp ctx, const char *file, sexp env); SEXP_API sexp sexp_load_module_file (sexp ctx, const char *file, sexp env);
SEXP_API sexp sexp_add_module_directory_op (sexp ctx sexp_api_params(self, n), sexp dir, sexp appendp); SEXP_API sexp sexp_add_module_directory_op (sexp ctx, sexp self, sexp_sint_t n, sexp dir, sexp appendp);
SEXP_API sexp sexp_extend_env (sexp ctx, sexp env, sexp vars, sexp value); SEXP_API sexp sexp_extend_env (sexp ctx, sexp env, sexp vars, sexp value);
SEXP_API sexp sexp_env_import_op (sexp ctx sexp_api_params(self, n), sexp to, sexp from, sexp ls, sexp immutp); SEXP_API sexp sexp_env_import_op (sexp ctx, sexp self, sexp_sint_t n, sexp to, sexp from, sexp ls, sexp immutp);
SEXP_API sexp sexp_identifier_op(sexp ctx sexp_api_params(self, n), sexp x); SEXP_API sexp sexp_identifier_op(sexp ctx, sexp self, sexp_sint_t n, sexp x);
SEXP_API sexp sexp_syntactic_closure_expr(sexp ctx sexp_api_params(self, n), sexp x); SEXP_API sexp sexp_syntactic_closure_expr(sexp ctx, sexp self, sexp_sint_t n, sexp x);
SEXP_API sexp sexp_identifier_eq_op(sexp ctx sexp_api_params(self, n), sexp a, sexp b, sexp c, sexp d); SEXP_API sexp sexp_identifier_eq_op(sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b, sexp c, sexp d);
SEXP_API sexp sexp_open_input_file_op(sexp ctx sexp_api_params(self, n), sexp x); SEXP_API sexp sexp_open_input_file_op(sexp ctx, sexp self, sexp_sint_t n, sexp x);
SEXP_API sexp sexp_open_output_file_op(sexp ctx sexp_api_params(self, n), sexp x); SEXP_API sexp sexp_open_output_file_op(sexp ctx, sexp self, sexp_sint_t n, sexp x);
SEXP_API sexp sexp_close_port_op(sexp ctx sexp_api_params(self, n), sexp x); SEXP_API sexp sexp_close_port_op(sexp ctx, sexp self, sexp_sint_t n, sexp x);
SEXP_API sexp sexp_env_define (sexp ctx, sexp env, sexp sym, sexp val); SEXP_API sexp sexp_env_define (sexp ctx, sexp env, sexp sym, sexp val);
SEXP_API sexp sexp_env_cell (sexp env, sexp sym, int localp); SEXP_API sexp sexp_env_cell (sexp env, sexp sym, int localp);
SEXP_API sexp sexp_env_ref (sexp env, sexp sym, sexp dflt); SEXP_API sexp sexp_env_ref (sexp env, sexp sym, sexp dflt);
@ -85,18 +85,18 @@ SEXP_API sexp sexp_parameter_ref (sexp ctx, sexp param);
SEXP_API void sexp_warn_undefs (sexp ctx, sexp from, sexp to); SEXP_API void sexp_warn_undefs (sexp ctx, sexp from, sexp to);
SEXP_API sexp sexp_make_lit (sexp ctx, sexp value); SEXP_API sexp sexp_make_lit (sexp ctx, sexp value);
SEXP_API sexp sexp_make_opcode (sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp_proc1); SEXP_API sexp sexp_make_opcode (sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp_proc1);
SEXP_API sexp sexp_make_procedure_op (sexp ctx sexp_api_params(self, n), sexp flags, sexp num_args, sexp bc, sexp vars); SEXP_API sexp sexp_make_procedure_op (sexp ctx, sexp self, sexp_sint_t n, sexp flags, sexp num_args, sexp bc, sexp vars);
SEXP_API sexp sexp_define_foreign_aux (sexp ctx, sexp env, const char *name, int num_args, int flags, sexp_proc1 f, sexp data); SEXP_API sexp sexp_define_foreign_aux (sexp ctx, sexp env, const char *name, int num_args, int flags, sexp_proc1 f, sexp data);
#if SEXP_USE_NATIVE_X86 #if SEXP_USE_NATIVE_X86
SEXP_API sexp sexp_write_char_op(sexp ctx sexp_api_params(self, n), sexp ch, sexp out); SEXP_API sexp sexp_write_char_op(sexp ctx, sexp self, sexp_sint_t n, sexp ch, sexp out);
SEXP_API sexp sexp_newline_op(sexp ctx sexp_api_params(self, n), sexp out); SEXP_API sexp sexp_newline_op(sexp ctx, sexp self, sexp_sint_t n, sexp out);
SEXP_API sexp sexp_read_char_op(sexp ctx sexp_api_params(self, n), sexp in); SEXP_API sexp sexp_read_char_op(sexp ctx, sexp self, sexp_sint_t n, sexp in);
SEXP_API sexp sexp_peek_char_op(sexp ctx sexp_api_params(self, n), sexp in); SEXP_API sexp sexp_peek_char_op(sexp ctx, sexp self, sexp_sint_t n, sexp in);
SEXP_API sexp sexp_exact_to_inexact(sexp ctx sexp_api_params(self, n), sexp i); SEXP_API sexp sexp_exact_to_inexact(sexp ctx, sexp self, sexp_sint_t n, sexp i);
SEXP_API sexp sexp_inexact_to_exact(sexp ctx sexp_api_params(self, n), sexp x); SEXP_API sexp sexp_inexact_to_exact(sexp ctx, sexp self, sexp_sint_t n, sexp x);
SEXP_API sexp sexp_char_upcase(sexp ctx sexp_api_params(self, n), sexp ch); SEXP_API sexp sexp_char_upcase(sexp ctx, sexp self, sexp_sint_t n, sexp ch);
SEXP_API sexp sexp_char_downcase(sexp ctx sexp_api_params(self, n), sexp ch); SEXP_API sexp sexp_char_downcase(sexp ctx, sexp self, sexp_sint_t n, sexp ch);
#endif #endif
#define sexp_define_foreign(c,e,s,n,f) sexp_define_foreign_aux(c,e,s,n,0,(sexp_proc1)f,NULL) #define sexp_define_foreign(c,e,s,n,f) sexp_define_foreign_aux(c,e,s,n,0,(sexp_proc1)f,NULL)
@ -111,32 +111,31 @@ SEXP_API sexp sexp_define_foreign_param (sexp ctx, sexp env, const char *name, i
#define sexp_env_push_rename(ctx, env, tmp, name, value) (tmp=sexp_cons(ctx,name,value), sexp_env_next_cell(tmp)=sexp_env_renames(env), sexp_env_renames(env)=tmp) #define sexp_env_push_rename(ctx, env, tmp, name, value) (tmp=sexp_cons(ctx,name,value), sexp_env_next_cell(tmp)=sexp_env_renames(env), sexp_env_renames(env)=tmp)
#if SEXP_USE_TYPE_DEFS #if SEXP_USE_TYPE_DEFS
SEXP_API sexp sexp_make_type_predicate_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type); SEXP_API sexp sexp_make_type_predicate_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type);
SEXP_API sexp sexp_make_constructor_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type); SEXP_API sexp sexp_make_constructor_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type);
SEXP_API sexp sexp_make_getter_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type, sexp index); SEXP_API sexp sexp_make_getter_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type, sexp index);
SEXP_API sexp sexp_make_setter_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type, sexp index); SEXP_API sexp sexp_make_setter_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type, sexp index);
#endif #endif
/* simplify primitive API interface */ /* simplify primitive API interface */
#define sexp_make_synclo(ctx, a, b, c) sexp_make_synclo_op(ctx sexp_api_pass(NULL, 3), a, b, c) #define sexp_make_synclo(ctx, a, b, c) sexp_make_synclo_op(ctx, NULL, 3, a, b, c)
#define sexp_make_procedure(ctx, f, n, b, v) sexp_make_procedure_op(ctx sexp_api_pass(NULL, 4), f, n, b, v) #define sexp_make_procedure(ctx, f, n, b, v) sexp_make_procedure_op(ctx, NULL, 4, f, n, b, v)
#define sexp_make_env(ctx) sexp_make_env_op(ctx sexp_api_pass(NULL, 0)) #define sexp_make_env(ctx) sexp_make_env_op(ctx, NULL, 0)
#define sexp_make_null_env(ctx, v) sexp_make_null_env_op(ctx sexp_api_pass(NULL, 0), v) #define sexp_make_null_env(ctx, v) sexp_make_null_env_op(ctx, NULL, 0, v)
#define sexp_make_standard_env(ctx) sexp_make_standard_env_op(ctx sexp_api_pass(NULL, 0)) #define sexp_make_standard_env(ctx) sexp_make_standard_env_op(ctx, NULL, 0)
#define sexp_add_module_directory(ctx, d, a) sexp_add_module_directory_op(ctx sexp_api_pass(NULL, 1), d, a) #define sexp_add_module_directory(ctx, d, a) sexp_add_module_directory_op(ctx, NULL, 1, d, a)
#define sexp_eval(ctx, x, e) sexp_eval_op(ctx sexp_api_pass(NULL, 2), x, e) #define sexp_eval(ctx, x, e) sexp_eval_op(ctx, NULL, 2, x, e)
#define sexp_load(ctx, f, e) sexp_load_op(ctx sexp_api_pass(NULL, 2), f, e) #define sexp_load(ctx, f, e) sexp_load_op(ctx, NULL, 2, f, e)
#define sexp_env_import(ctx, a, b, c, d) sexp_env_import_op(ctx sexp_api_pass(NULL, 4), a, b, c, d) #define sexp_env_import(ctx, a, b, c, d) sexp_env_import_op(ctx, NULL, 4, a, b, c, d)
#define sexp_identifierp(ctx, x) sexp_identifierp_op(ctx sexp_api_pass(NULL, 1), x) #define sexp_identifierp(ctx, x) sexp_identifierp_op(ctx, NULL, 1, x)
#define sexp_identifier_to_symbol(ctx, x) sexp_syntactic_closure_expr(ctx sexp_api_pass(NULL, 1), x) #define sexp_identifier_to_symbol(ctx, x) sexp_syntactic_closure_expr(ctx, NULL, 1, x)
#define sexp_identifier_eq(ctx, a, b, c, d) sexp_identifier_eq_op(ctx sexp_api_pass(NULL, 4), a, b, c, d) #define sexp_identifier_eq(ctx, a, b, c, d) sexp_identifier_eq_op(ctx, NULL, 4, a, b, c, d)
#define sexp_open_input_file(ctx, x) sexp_open_input_file_op(ctx sexp_api_pass(NULL, 1), x) #define sexp_open_input_file(ctx, x) sexp_open_input_file_op(ctx, NULL, 1, x)
#define sexp_open_output_file(ctx, x) sexp_open_output_file_op(ctx sexp_api_pass(NULL, 1), x) #define sexp_open_output_file(ctx, x) sexp_open_output_file_op(ctx, NULL, 1, x)
#define sexp_close_port(ctx, x) sexp_close_port_op(ctx sexp_api_pass(NULL, 1), x) #define sexp_close_port(ctx, x) sexp_close_port_op(ctx, NULL, 1, x)
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif
#endif /* ! SEXP_EVAL_H */ #endif /* ! SEXP_EVAL_H */

View file

@ -1,5 +1,5 @@
/* sexp.h -- header for sexp library */ /* sexp.h -- header for sexp library */
/* Copyright (c) 2009-2010 Alex Shinn. All rights reserved. */ /* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */
/* BSD-style license: http://synthcode.com/license.txt */ /* BSD-style license: http://synthcode.com/license.txt */
#ifndef SEXP_H #ifndef SEXP_H
@ -191,7 +191,7 @@ typedef struct sexp_struct *sexp;
#define SEXP_MIN_FIXNUM (-SEXP_MAX_FIXNUM-1) #define SEXP_MIN_FIXNUM (-SEXP_MAX_FIXNUM-1)
#if SEXP_USE_SELF_PARAMETER #if SEXP_USE_SELF_PARAMETER
#define sexp_api_params(self, n) , sexp self, long n #define sexp_api_params(self, n) , sexp self, sexp_sint_t n
#define sexp_api_pass(self, n) , self, n #define sexp_api_pass(self, n) , self, n
#else #else
#define sexp_api_params(self, n) #define sexp_api_params(self, n)
@ -199,13 +199,13 @@ typedef struct sexp_struct *sexp;
#endif #endif
/* procedure types */ /* procedure types */
typedef sexp (*sexp_proc1) (sexp sexp_api_params(self, n)); typedef sexp (*sexp_proc1) (sexp, sexp, sexp_sint_t);
typedef sexp (*sexp_proc2) (sexp sexp_api_params(self, n), sexp); typedef sexp (*sexp_proc2) (sexp, sexp, sexp_sint_t, sexp);
typedef sexp (*sexp_proc3) (sexp sexp_api_params(self, n), sexp, sexp); typedef sexp (*sexp_proc3) (sexp, sexp, sexp_sint_t, sexp, sexp);
typedef sexp (*sexp_proc4) (sexp sexp_api_params(self, n), sexp, sexp, sexp); typedef sexp (*sexp_proc4) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp);
typedef sexp (*sexp_proc5) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc5) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp);
typedef sexp (*sexp_proc6) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc6) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp);
typedef sexp (*sexp_proc7) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc7) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp);
typedef struct sexp_free_list_t *sexp_free_list; typedef struct sexp_free_list_t *sexp_free_list;
struct sexp_free_list_t { struct sexp_free_list_t {
@ -1149,70 +1149,70 @@ SEXP_API sexp sexp_buffered_flush (sexp ctx, sexp p);
SEXP_API sexp sexp_alloc_tagged_aux(sexp ctx, size_t size, sexp_uint_t tag sexp_current_source_param); SEXP_API sexp sexp_alloc_tagged_aux(sexp ctx, size_t size, sexp_uint_t tag sexp_current_source_param);
SEXP_API sexp sexp_make_context(sexp ctx, size_t size, size_t max_size); SEXP_API sexp sexp_make_context(sexp ctx, size_t size, size_t max_size);
SEXP_API sexp sexp_cons_op(sexp ctx sexp_api_params(self, n), sexp head, sexp tail); SEXP_API sexp sexp_cons_op(sexp ctx, sexp self, sexp_sint_t n, sexp head, sexp tail);
SEXP_API sexp sexp_list2(sexp ctx, sexp a, sexp b); SEXP_API sexp sexp_list2(sexp ctx, sexp a, sexp b);
SEXP_API sexp sexp_equalp_bound (sexp ctx sexp_api_params(self, n), sexp a, sexp b, sexp bound); SEXP_API sexp sexp_equalp_bound (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b, sexp bound);
SEXP_API sexp sexp_equalp_op (sexp ctx sexp_api_params(self, n), sexp a, sexp b); SEXP_API sexp sexp_equalp_op (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b);
SEXP_API sexp sexp_listp_op(sexp ctx sexp_api_params(self, n), sexp obj); SEXP_API sexp sexp_listp_op(sexp ctx, sexp self, sexp_sint_t n, sexp obj);
SEXP_API sexp sexp_reverse_op(sexp ctx sexp_api_params(self, n), sexp ls); SEXP_API sexp sexp_reverse_op(sexp ctx, sexp self, sexp_sint_t n, sexp ls);
SEXP_API sexp sexp_nreverse_op(sexp ctx sexp_api_params(self, n), sexp ls); SEXP_API sexp sexp_nreverse_op(sexp ctx, sexp self, sexp_sint_t n, sexp ls);
SEXP_API sexp sexp_copy_list_op(sexp ctx sexp_api_params(self, n), sexp ls); SEXP_API sexp sexp_copy_list_op(sexp ctx, sexp self, sexp_sint_t n, sexp ls);
SEXP_API sexp sexp_append2_op(sexp ctx sexp_api_params(self, n), sexp a, sexp b); SEXP_API sexp sexp_append2_op(sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b);
SEXP_API sexp sexp_memq_op(sexp ctx sexp_api_params(self, n), sexp x, sexp ls); SEXP_API sexp sexp_memq_op(sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp ls);
SEXP_API sexp sexp_assq_op(sexp ctx sexp_api_params(self, n), sexp x, sexp ls); SEXP_API sexp sexp_assq_op(sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp ls);
SEXP_API sexp sexp_length_op(sexp ctx sexp_api_params(self, n), sexp ls); SEXP_API sexp sexp_length_op(sexp ctx, sexp self, sexp_sint_t n, sexp ls);
SEXP_API sexp sexp_c_string(sexp ctx, const char *str, sexp_sint_t slen); SEXP_API sexp sexp_c_string(sexp ctx, const char *str, sexp_sint_t slen);
SEXP_API sexp sexp_make_bytes_op(sexp ctx sexp_api_params(self, n), sexp len, sexp i); SEXP_API sexp sexp_make_bytes_op(sexp ctx, sexp self, sexp_sint_t n, sexp len, sexp i);
SEXP_API sexp sexp_make_string_op(sexp ctx sexp_api_params(self, n), sexp len, sexp ch); SEXP_API sexp sexp_make_string_op(sexp ctx, sexp self, sexp_sint_t n, sexp len, sexp ch);
SEXP_API sexp sexp_substring_op (sexp ctx sexp_api_params(self, n), sexp str, sexp start, sexp end); SEXP_API sexp sexp_substring_op (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp start, sexp end);
SEXP_API sexp sexp_string_concatenate_op (sexp ctx sexp_api_params(self, n), sexp str_ls, sexp sep); SEXP_API sexp sexp_string_concatenate_op (sexp ctx, sexp self, sexp_sint_t n, sexp str_ls, sexp sep);
SEXP_API sexp sexp_intern (sexp ctx, const char *str, sexp_sint_t len); SEXP_API sexp sexp_intern (sexp ctx, const char *str, sexp_sint_t len);
SEXP_API sexp sexp_string_to_symbol_op (sexp ctx sexp_api_params(self, n), sexp str); SEXP_API sexp sexp_string_to_symbol_op (sexp ctx, sexp self, sexp_sint_t n, sexp str);
SEXP_API sexp sexp_string_to_number_op (sexp ctx sexp_api_params(self, n), sexp str, sexp b); SEXP_API sexp sexp_string_to_number_op (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp b);
SEXP_API sexp sexp_flonump_op (sexp ctx sexp_api_params(self, n), sexp x); SEXP_API sexp sexp_flonump_op (sexp ctx, sexp self, sexp_sint_t n, sexp x);
SEXP_API sexp sexp_make_vector_op (sexp ctx sexp_api_params(self, n), sexp len, sexp dflt); SEXP_API sexp sexp_make_vector_op (sexp ctx, sexp self, sexp_sint_t n, sexp len, sexp dflt);
SEXP_API sexp sexp_list_to_vector_op (sexp ctx sexp_api_params(self, n), sexp ls); SEXP_API sexp sexp_list_to_vector_op (sexp ctx, sexp self, sexp_sint_t n, sexp ls);
SEXP_API sexp sexp_make_cpointer (sexp ctx, sexp_uint_t type_id, void* value, sexp parent, int freep); SEXP_API sexp sexp_make_cpointer (sexp ctx, sexp_uint_t type_id, void* value, sexp parent, int freep);
SEXP_API sexp sexp_write_op (sexp ctx sexp_api_params(self, n), sexp obj, sexp out); SEXP_API sexp sexp_write_op (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp out);
SEXP_API sexp sexp_display_op (sexp ctx sexp_api_params(self, n), sexp obj, sexp out); SEXP_API sexp sexp_display_op (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp out);
SEXP_API sexp sexp_flush_output_op (sexp ctx sexp_api_params(self, n), sexp out); SEXP_API sexp sexp_flush_output_op (sexp ctx, sexp self, sexp_sint_t n, sexp out);
SEXP_API sexp sexp_read_string (sexp ctx, sexp in, int sentinel); SEXP_API sexp sexp_read_string (sexp ctx, sexp in, int sentinel);
SEXP_API sexp sexp_read_symbol (sexp ctx, sexp in, int init, int internp); SEXP_API sexp sexp_read_symbol (sexp ctx, sexp in, int init, int internp);
SEXP_API sexp sexp_read_number (sexp ctx, sexp in, int base); SEXP_API sexp sexp_read_number (sexp ctx, sexp in, int base);
SEXP_API sexp sexp_read_raw (sexp ctx, sexp in); SEXP_API sexp sexp_read_raw (sexp ctx, sexp in);
SEXP_API sexp sexp_read_op (sexp ctx sexp_api_params(self, n), sexp in); SEXP_API sexp sexp_read_op (sexp ctx, sexp self, sexp_sint_t n, sexp in);
SEXP_API sexp sexp_read_from_string (sexp ctx, const char *str, sexp_sint_t len); SEXP_API sexp sexp_read_from_string (sexp ctx, const char *str, sexp_sint_t len);
SEXP_API sexp sexp_write_to_string (sexp ctx, sexp obj); SEXP_API sexp sexp_write_to_string (sexp ctx, sexp obj);
SEXP_API sexp sexp_write_simple_object (sexp ctx sexp_api_params(self, n), sexp obj, sexp writer, sexp out); SEXP_API sexp sexp_write_simple_object (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp writer, sexp out);
SEXP_API sexp sexp_finalize_port (sexp ctx sexp_api_params(self, n), sexp port); SEXP_API sexp sexp_finalize_port (sexp ctx, sexp self, sexp_sint_t n, sexp port);
SEXP_API sexp sexp_make_input_port (sexp ctx, FILE* in, sexp name); SEXP_API sexp sexp_make_input_port (sexp ctx, FILE* in, sexp name);
SEXP_API sexp sexp_make_output_port (sexp ctx, FILE* out, sexp name); SEXP_API sexp sexp_make_output_port (sexp ctx, FILE* out, sexp name);
SEXP_API sexp sexp_port_binaryp_op (sexp ctx sexp_api_params(self, n), sexp port); SEXP_API sexp sexp_port_binaryp_op (sexp ctx, sexp self, sexp_sint_t n, sexp port);
SEXP_API sexp sexp_port_openp_op (sexp ctx sexp_api_params(self, n), sexp port); SEXP_API sexp sexp_port_openp_op (sexp ctx, sexp self, sexp_sint_t n, sexp port);
#if SEXP_USE_FOLD_CASE_SYMS #if SEXP_USE_FOLD_CASE_SYMS
SEXP_API sexp sexp_get_port_fold_case (sexp ctx sexp_api_params(self, n), sexp in); SEXP_API sexp sexp_get_port_fold_case (sexp ctx, sexp self, sexp_sint_t n, sexp in);
SEXP_API sexp sexp_set_port_fold_case (sexp ctx sexp_api_params(self, n), sexp in, sexp x); SEXP_API sexp sexp_set_port_fold_case (sexp ctx, sexp self, sexp_sint_t n, sexp in, sexp x);
#endif #endif
#if SEXP_USE_OBJECT_BRACE_LITERALS #if SEXP_USE_OBJECT_BRACE_LITERALS
SEXP_API sexp sexp_lookup_type_op (sexp ctx sexp_api_params(self, n), sexp name, sexp id); SEXP_API sexp sexp_lookup_type_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp id);
#endif #endif
SEXP_API sexp sexp_make_input_string_port_op (sexp ctx sexp_api_params(self, n), sexp str); SEXP_API sexp sexp_make_input_string_port_op (sexp ctx, sexp self, sexp_sint_t n, sexp str);
SEXP_API sexp sexp_make_output_string_port_op (sexp ctx sexp_api_params(self, n)); SEXP_API sexp sexp_make_output_string_port_op (sexp ctx, sexp self, sexp_sint_t n);
SEXP_API sexp sexp_get_output_string_op (sexp ctx sexp_api_params(self, n), sexp port); SEXP_API sexp sexp_get_output_string_op (sexp ctx, sexp self, sexp_sint_t n, sexp port);
SEXP_API sexp sexp_make_exception (sexp ctx, sexp kind, sexp message, sexp irritants, sexp procedure, sexp source); SEXP_API sexp sexp_make_exception (sexp ctx, sexp kind, sexp message, sexp irritants, sexp procedure, sexp source);
SEXP_API sexp sexp_user_exception (sexp ctx, sexp self, const char *msg, sexp x); SEXP_API sexp sexp_user_exception (sexp ctx, sexp self, const char *msg, sexp x);
SEXP_API sexp sexp_type_exception (sexp ctx, sexp self, sexp_uint_t type_id, sexp x); SEXP_API sexp sexp_type_exception (sexp ctx, sexp self, sexp_uint_t type_id, sexp x);
SEXP_API sexp sexp_xtype_exception (sexp ctx, sexp self, const char *msg, sexp x); SEXP_API sexp sexp_xtype_exception (sexp ctx, sexp self, const char *msg, sexp x);
SEXP_API sexp sexp_range_exception (sexp ctx, sexp obj, sexp start, sexp end); SEXP_API sexp sexp_range_exception (sexp ctx, sexp obj, sexp start, sexp end);
SEXP_API sexp sexp_print_exception_op (sexp ctx sexp_api_params(self, n), sexp exn, sexp out); SEXP_API sexp sexp_print_exception_op (sexp ctx, sexp self, sexp_sint_t n, sexp exn, sexp out);
SEXP_API sexp sexp_apply (sexp context, sexp proc, sexp args); SEXP_API sexp sexp_apply (sexp context, sexp proc, sexp args);
SEXP_API sexp sexp_apply1 (sexp ctx, sexp f, sexp x); SEXP_API sexp sexp_apply1 (sexp ctx, sexp f, sexp x);
SEXP_API sexp sexp_make_foreign (sexp ctx, const char *name, int num_args, int flags, sexp_proc1 f, sexp data); SEXP_API sexp sexp_make_foreign (sexp ctx, const char *name, int num_args, int flags, sexp_proc1 f, sexp data);
SEXP_API void sexp_init(void); SEXP_API void sexp_init(void);
#if SEXP_USE_UTF8_STRINGS #if SEXP_USE_UTF8_STRINGS
SEXP_API sexp sexp_string_index_to_offset (sexp ctx sexp_api_params(self, n), sexp str, sexp index); SEXP_API sexp sexp_string_index_to_offset (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp index);
SEXP_API sexp sexp_utf8_substring_op (sexp ctx sexp_api_params(self, n), sexp str, sexp start, sexp end); SEXP_API sexp sexp_utf8_substring_op (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp start, sexp end);
SEXP_API void sexp_utf8_encode_char (unsigned char* p, int len, int c); SEXP_API void sexp_utf8_encode_char (unsigned char* p, int len, int c);
#endif #endif
@ -1258,9 +1258,9 @@ SEXP_API int sexp_valid_object_p(sexp ctx, sexp x);
#endif #endif
#if SEXP_USE_TYPE_DEFS #if SEXP_USE_TYPE_DEFS
SEXP_API sexp sexp_register_type_op (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp_proc2); SEXP_API sexp sexp_register_type_op (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp_proc2);
SEXP_API sexp sexp_register_simple_type_op (sexp ctx sexp_api_params(self, n), sexp name, sexp parent, sexp slots); SEXP_API sexp sexp_register_simple_type_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp parent, sexp slots);
SEXP_API sexp sexp_finalize_c_type (sexp ctx sexp_api_params(self, n), sexp obj); SEXP_API sexp sexp_finalize_c_type (sexp ctx, sexp self, sexp_sint_t n, sexp obj);
#define sexp_register_c_type(ctx, name, finalizer) \ #define sexp_register_c_type(ctx, name, finalizer) \
sexp_register_type(ctx, name, SEXP_FALSE, SEXP_FALSE, SEXP_ZERO, SEXP_ZERO, \ sexp_register_type(ctx, name, SEXP_FALSE, SEXP_FALSE, SEXP_ZERO, SEXP_ZERO, \
SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, \ SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, \
@ -1275,42 +1275,42 @@ SEXP_API sexp sexp_finalize_c_type (sexp ctx sexp_api_params(self, n), sexp obj)
/* simplify primitive API interface */ /* simplify primitive API interface */
#define sexp_read(ctx, in) sexp_read_op(ctx sexp_api_pass(NULL, 1), in) #define sexp_read(ctx, in) sexp_read_op(ctx, NULL, 1, in)
#define sexp_write(ctx, obj, out) sexp_write_op(ctx sexp_api_pass(NULL, 2), obj, out) #define sexp_write(ctx, obj, out) sexp_write_op(ctx, NULL, 2, obj, out)
#define sexp_display(ctx, obj, out) sexp_display_op(ctx sexp_api_pass(NULL, 2), obj, out) #define sexp_display(ctx, obj, out) sexp_display_op(ctx, NULL, 2, obj, out)
#define sexp_print_exception(ctx, e, out) sexp_print_exception_op(ctx sexp_api_pass(NULL, 2), e, out) #define sexp_print_exception(ctx, e, out) sexp_print_exception_op(ctx, NULL, 2, e, out)
#define sexp_flush_output(ctx, obj, out) sexp_flush_output_op(ctx sexp_api_pass(NULL, 1), out) #define sexp_flush_output(ctx, obj, out) sexp_flush_output_op(ctx, NULL, 1, out)
#define sexp_equalp(ctx, a, b) sexp_equalp_op(ctx sexp_api_pass(NULL, 2), a, b) #define sexp_equalp(ctx, a, b) sexp_equalp_op(ctx, NULL, 2, a, b)
#define sexp_listp(ctx, x) sexp_listp_op(ctx sexp_api_pass(NULL, 1), x) #define sexp_listp(ctx, x) sexp_listp_op(ctx, NULL, 1, x)
#define sexp_length(ctx, x) sexp_length_op(ctx sexp_api_pass(NULL, 1), x) #define sexp_length(ctx, x) sexp_length_op(ctx, NULL, 1, x)
#define sexp_reverse(ctx, x) sexp_reverse_op(ctx sexp_api_pass(NULL, 1), x) #define sexp_reverse(ctx, x) sexp_reverse_op(ctx, NULL, 1, x)
#define sexp_nreverse(ctx, x) sexp_nreverse_op(ctx sexp_api_pass(NULL, 1), x) #define sexp_nreverse(ctx, x) sexp_nreverse_op(ctx, NULL, 1, x)
#define sexp_copy_list(ctx, x) sexp_copy_list_op(ctx sexp_api_pass(NULL, 1), x) #define sexp_copy_list(ctx, x) sexp_copy_list_op(ctx, NULL, 1, x)
#define sexp_cons(ctx, a, b) sexp_cons_op(ctx sexp_api_pass(NULL, 2), a, b) #define sexp_cons(ctx, a, b) sexp_cons_op(ctx, NULL, 2, a, b)
#define sexp_append2(ctx, a, b) sexp_append2_op(ctx sexp_api_pass(NULL, 2), a, b) #define sexp_append2(ctx, a, b) sexp_append2_op(ctx, NULL, 2, a, b)
#define sexp_make_vector(ctx, a, b) sexp_make_vector_op(ctx sexp_api_pass(NULL, 2), a, b); #define sexp_make_vector(ctx, a, b) sexp_make_vector_op(ctx, NULL, 2, a, b);
#define sexp_list_to_vector(ctx, x) sexp_list_to_vector_op(ctx sexp_api_pass(NULL, 1), x) #define sexp_list_to_vector(ctx, x) sexp_list_to_vector_op(ctx, NULL, 1, x)
#define sexp_exception_type(ctx, x) sexp_exception_type_op(ctx sexp_api_pass(NULL, 1), x) #define sexp_exception_type(ctx, x) sexp_exception_type_op(ctx, NULL, 1, x)
#define sexp_string_to_symbol(ctx, s) sexp_string_to_symbol_op(ctx sexp_api_pass(NULL, 1), s) #define sexp_string_to_symbol(ctx, s) sexp_string_to_symbol_op(ctx, NULL, 1, s)
#define sexp_string_to_number(ctx, s, b) sexp_string_to_number_op(ctx sexp_api_pass(NULL, 2), s, b) #define sexp_string_to_number(ctx, s, b) sexp_string_to_number_op(ctx, NULL, 2, s, b)
#define sexp_make_bytes(ctx, l, i) sexp_make_bytes_op(ctx sexp_api_pass(NULL, 2), l, i) #define sexp_make_bytes(ctx, l, i) sexp_make_bytes_op(ctx, NULL, 2, l, i)
#define sexp_make_string(ctx, l, c) sexp_make_string_op(ctx sexp_api_pass(NULL, 2), l, c) #define sexp_make_string(ctx, l, c) sexp_make_string_op(ctx, NULL, 2, l, c)
#define sexp_string_cmp(ctx, a, b, c) sexp_string_cmp_op(ctx sexp_api_pass(NULL, 3), a, b, c) #define sexp_string_cmp(ctx, a, b, c) sexp_string_cmp_op(ctx, NULL, 3, a, b, c)
#define sexp_substring(ctx, a, b, c) sexp_substring_op(ctx sexp_api_pass(NULL, 3), a, b, c) #define sexp_substring(ctx, a, b, c) sexp_substring_op(ctx, NULL, 3, a, b, c)
#define sexp_string_concatenate(ctx, ls, s) sexp_string_concatenate_op(ctx sexp_api_pass(NULL, 2), ls, s) #define sexp_string_concatenate(ctx, ls, s) sexp_string_concatenate_op(ctx, NULL, 2, ls, s)
#define sexp_memq(ctx, a, b) sexp_memq_op(ctx sexp_api_pass(NULL, 2), a, b) #define sexp_memq(ctx, a, b) sexp_memq_op(ctx, NULL, 2, a, b)
#define sexp_assq(ctx, a, b) sexp_assq_op(ctx sexp_api_pass(NULL, 2), a, b) #define sexp_assq(ctx, a, b) sexp_assq_op(ctx, NULL, 2, a, b)
#define sexp_make_output_string_port(ctx) sexp_make_output_string_port_op(ctx sexp_api_pass(NULL, 0)) #define sexp_make_output_string_port(ctx) sexp_make_output_string_port_op(ctx, NULL, 0)
#define sexp_make_input_string_port(ctx, s) sexp_make_input_string_port_op(ctx sexp_api_pass(NULL, 1), s) #define sexp_make_input_string_port(ctx, s) sexp_make_input_string_port_op(ctx, NULL, 1, s)
#define sexp_get_output_string(ctx, out) sexp_get_output_string_op(ctx sexp_api_pass(NULL, 1), out) #define sexp_get_output_string(ctx, out) sexp_get_output_string_op(ctx, NULL, 1, out)
#define sexp_expt(ctx, a, b) sexp_expt_op(ctx sexp_api_pass(NULL, 2), a, b) #define sexp_expt(ctx, a, b) sexp_expt_op(ctx, NULL, 2, a, b)
#define sexp_register_simple_type(ctx, a, b, c) sexp_register_simple_type_op(ctx sexp_api_pass(NULL, 3), a, b, c) #define sexp_register_simple_type(ctx, a, b, c) sexp_register_simple_type_op(ctx, NULL, 3, a, b, c)
#define sexp_register_type(ctx, a, b, c, d, e, f, g, h, i, j, k, l, m, o, p, q, r, s) sexp_register_type_op(ctx sexp_api_pass(NULL, 18), a, b, c, d, e, f, g, h, i, j, k, l, m, o, p, q, r, s) #define sexp_register_type(ctx, a, b, c, d, e, f, g, h, i, j, k, l, m, o, p, q, r, s) sexp_register_type_op(ctx, NULL, 18, a, b, c, d, e, f, g, h, i, j, k, l, m, o, p, q, r, s)
#define sexp_make_type_predicate(ctx, a, b) sexp_make_type_predicate_op(ctx sexp_api_pass(NULL, 2), a, b) #define sexp_make_type_predicate(ctx, a, b) sexp_make_type_predicate_op(ctx, NULL, 2, a, b)
#define sexp_make_constructor(ctx, a, b) sexp_make_constructor_op(ctx sexp_api_pass(NULL, 2), a, b) #define sexp_make_constructor(ctx, a, b) sexp_make_constructor_op(ctx, NULL, 2, a, b)
#define sexp_make_getter(ctx, a, b, c) sexp_make_getter_op(ctx sexp_api_pass(NULL, 3), a, b, c) #define sexp_make_getter(ctx, a, b, c) sexp_make_getter_op(ctx, NULL, 3, a, b, c)
#define sexp_make_setter(ctx, a, b, c) sexp_make_setter_op(ctx sexp_api_pass(NULL, 3), a, b, c) #define sexp_make_setter(ctx, a, b, c) sexp_make_setter_op(ctx, NULL, 3, a, b, c)
#define sexp_lookup_type(ctx, name, id) sexp_lookup_type_op(ctx sexp_api_pass(NULL, 2), name, id) #define sexp_lookup_type(ctx, name, id) sexp_lookup_type_op(ctx, NULL, 2, name, id)
enum sexp_opcode_names { enum sexp_opcode_names {
SEXP_OP_NOOP, SEXP_OP_NOOP,
@ -1404,4 +1404,3 @@ enum sexp_opcode_names {
#endif #endif
#endif /* ! SEXP_H */ #endif /* ! SEXP_H */

View file

@ -36,7 +36,7 @@ static void sexp_define_accessors (sexp ctx, sexp env, sexp_uint_t ctype,
sexp_gc_release2(ctx); sexp_gc_release2(ctx);
} }
static sexp sexp_get_env_cell (sexp ctx sexp_api_params(self, n), sexp env, sexp id) { static sexp sexp_get_env_cell (sexp ctx, sexp self, sexp_sint_t n, sexp env, sexp id) {
sexp cell; sexp cell;
sexp_assert_type(ctx, sexp_envp, SEXP_ENV, env); sexp_assert_type(ctx, sexp_envp, SEXP_ENV, env);
cell = sexp_env_cell(env, id, 0); cell = sexp_env_cell(env, id, 0);
@ -47,7 +47,7 @@ static sexp sexp_get_env_cell (sexp ctx sexp_api_params(self, n), sexp env, sexp
return cell ? cell : SEXP_FALSE; return cell ? cell : SEXP_FALSE;
} }
static sexp sexp_get_opcode_name (sexp ctx sexp_api_params(self, n), sexp op) { static sexp sexp_get_opcode_name (sexp ctx, sexp self, sexp_sint_t n, sexp op) {
if (! sexp_opcodep(op)) if (! sexp_opcodep(op))
return sexp_type_exception(ctx, self, SEXP_OPCODE, op); return sexp_type_exception(ctx, self, SEXP_OPCODE, op);
else if (! sexp_opcode_name(op)) else if (! sexp_opcode_name(op))
@ -74,7 +74,7 @@ static sexp sexp_translate_opcode_type (sexp ctx, sexp type) {
return res; return res;
} }
static sexp sexp_get_opcode_ret_type (sexp ctx sexp_api_params(self, n), sexp op) { static sexp sexp_get_opcode_ret_type (sexp ctx, sexp self, sexp_sint_t n, sexp op) {
sexp res; sexp res;
if (! sexp_opcodep(op)) if (! sexp_opcodep(op))
return sexp_type_exception(ctx, self, SEXP_OPCODE, op); return sexp_type_exception(ctx, self, SEXP_OPCODE, op);
@ -86,7 +86,7 @@ static sexp sexp_get_opcode_ret_type (sexp ctx sexp_api_params(self, n), sexp op
return sexp_translate_opcode_type(ctx, res); return sexp_translate_opcode_type(ctx, res);
} }
static sexp sexp_get_opcode_param_type (sexp ctx sexp_api_params(self, n), sexp op, sexp k) { static sexp sexp_get_opcode_param_type (sexp ctx, sexp self, sexp_sint_t n, sexp op, sexp k) {
sexp res; sexp res;
int p = sexp_unbox_fixnum(k); int p = sexp_unbox_fixnum(k);
if (! sexp_opcodep(op)) if (! sexp_opcodep(op))
@ -115,31 +115,31 @@ static sexp sexp_get_opcode_param_type (sexp ctx sexp_api_params(self, n), sexp
return sexp_translate_opcode_type(ctx, res); return sexp_translate_opcode_type(ctx, res);
} }
static sexp sexp_get_opcode_num_params (sexp ctx sexp_api_params(self, n), sexp op) { static sexp sexp_get_opcode_num_params (sexp ctx, sexp self, sexp_sint_t n, sexp op) {
if (! sexp_opcodep(op)) if (! sexp_opcodep(op))
return sexp_type_exception(ctx, self, SEXP_OPCODE, op); return sexp_type_exception(ctx, self, SEXP_OPCODE, op);
return sexp_make_fixnum(sexp_opcode_num_args(op)); return sexp_make_fixnum(sexp_opcode_num_args(op));
} }
static sexp sexp_get_opcode_variadic_p (sexp ctx sexp_api_params(self, n), sexp op) { static sexp sexp_get_opcode_variadic_p (sexp ctx, sexp self, sexp_sint_t n, sexp op) {
if (! sexp_opcodep(op)) if (! sexp_opcodep(op))
return sexp_type_exception(ctx, self, SEXP_OPCODE, op); return sexp_type_exception(ctx, self, SEXP_OPCODE, op);
return sexp_make_boolean(sexp_opcode_variadic_p(op)); return sexp_make_boolean(sexp_opcode_variadic_p(op));
} }
static sexp sexp_get_port_line (sexp ctx sexp_api_params(self, n), sexp p) { static sexp sexp_get_port_line (sexp ctx, sexp self, sexp_sint_t n, sexp p) {
sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, p); sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, p);
return sexp_make_fixnum(sexp_port_line(p)); return sexp_make_fixnum(sexp_port_line(p));
} }
static sexp sexp_set_port_line (sexp ctx sexp_api_params(self, n), sexp p, sexp i) { static sexp sexp_set_port_line (sexp ctx, sexp self, sexp_sint_t n, sexp p, sexp i) {
sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, p); sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, p);
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, i); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, i);
sexp_port_line(p) = sexp_unbox_fixnum(i); sexp_port_line(p) = sexp_unbox_fixnum(i);
return SEXP_VOID; return SEXP_VOID;
} }
static sexp sexp_type_of (sexp ctx sexp_api_params(self, n), sexp x) { static sexp sexp_type_of (sexp ctx, sexp self, sexp_sint_t n, sexp x) {
if (sexp_pointerp(x)) if (sexp_pointerp(x))
return sexp_object_type(ctx, x); return sexp_object_type(ctx, x);
else if (sexp_fixnump(x)) else if (sexp_fixnump(x))
@ -160,33 +160,33 @@ static sexp sexp_type_of (sexp ctx sexp_api_params(self, n), sexp x) {
return sexp_type_by_index(ctx, SEXP_OBJECT); return sexp_type_by_index(ctx, SEXP_OBJECT);
} }
static sexp sexp_type_name_op (sexp ctx sexp_api_params(self, n), sexp t) { static sexp sexp_type_name_op (sexp ctx, sexp self, sexp_sint_t n, sexp t) {
sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t); sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t);
return sexp_type_name(t); return sexp_type_name(t);
} }
static sexp sexp_type_cpl_op (sexp ctx sexp_api_params(self, n), sexp t) { static sexp sexp_type_cpl_op (sexp ctx, sexp self, sexp_sint_t n, sexp t) {
sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t); sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t);
return sexp_type_cpl(t); return sexp_type_cpl(t);
} }
static sexp sexp_type_slots_op (sexp ctx sexp_api_params(self, n), sexp t) { static sexp sexp_type_slots_op (sexp ctx, sexp self, sexp_sint_t n, sexp t) {
sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t); sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t);
return sexp_type_slots(t); return sexp_type_slots(t);
} }
static sexp sexp_type_num_slots_op (sexp ctx sexp_api_params(self, n), sexp t) { static sexp sexp_type_num_slots_op (sexp ctx, sexp self, sexp_sint_t n, sexp t) {
sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t); sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t);
return sexp_truep(sexp_type_slots(t)) ? sexp_length(ctx, sexp_type_slots(t)) return sexp_truep(sexp_type_slots(t)) ? sexp_length(ctx, sexp_type_slots(t))
: sexp_make_fixnum(sexp_type_field_eq_len_base(t)); : sexp_make_fixnum(sexp_type_field_eq_len_base(t));
} }
static sexp sexp_type_printer_op (sexp ctx sexp_api_params(self, n), sexp t) { static sexp sexp_type_printer_op (sexp ctx, sexp self, sexp_sint_t n, sexp t) {
sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t); sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t);
return sexp_type_print(t) ? sexp_type_print(t) : SEXP_FALSE; return sexp_type_print(t) ? sexp_type_print(t) : SEXP_FALSE;
} }
static sexp sexp_object_size (sexp ctx sexp_api_params(self, n), sexp x) { static sexp sexp_object_size (sexp ctx, sexp self, sexp_sint_t n, sexp x) {
sexp t; sexp t;
if ((! sexp_pointerp(x)) || (sexp_pointer_tag(x) >= sexp_context_num_types(ctx))) if ((! sexp_pointerp(x)) || (sexp_pointer_tag(x) >= sexp_context_num_types(ctx)))
return SEXP_ZERO; return SEXP_ZERO;
@ -194,7 +194,7 @@ static sexp sexp_object_size (sexp ctx sexp_api_params(self, n), sexp x) {
return sexp_make_fixnum(sexp_type_size_of_object(t, x)); return sexp_make_fixnum(sexp_type_size_of_object(t, x));
} }
static sexp sexp_integer_to_immediate (sexp ctx sexp_api_params(self, n), sexp i, sexp dflt) { static sexp sexp_integer_to_immediate (sexp ctx, sexp self, sexp_sint_t n, sexp i, sexp dflt) {
sexp x = (sexp)sexp_unbox_fixnum(i); sexp x = (sexp)sexp_unbox_fixnum(i);
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, i); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, i);
if (sexp_pointerp(x)) if (sexp_pointerp(x))
@ -202,7 +202,7 @@ static sexp sexp_integer_to_immediate (sexp ctx sexp_api_params(self, n), sexp i
return x; return x;
} }
static sexp sexp_make_lambda_op (sexp ctx sexp_api_params(self, n), sexp name, sexp params, sexp body, sexp locals) { static sexp sexp_make_lambda_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp params, sexp body, sexp locals) {
sexp res = sexp_alloc_type(ctx, lambda, SEXP_LAMBDA); sexp res = sexp_alloc_type(ctx, lambda, SEXP_LAMBDA);
sexp_lambda_name(res) = name; sexp_lambda_name(res) = name;
sexp_lambda_params(res) = params; sexp_lambda_params(res) = params;
@ -216,7 +216,7 @@ static sexp sexp_make_lambda_op (sexp ctx sexp_api_params(self, n), sexp name, s
return res; return res;
} }
static sexp sexp_copy_lambda (sexp ctx sexp_api_params(self, n), sexp lambda) { static sexp sexp_copy_lambda (sexp ctx, sexp self, sexp_sint_t n, sexp lambda) {
sexp res = sexp_alloc_type(ctx, lambda, SEXP_LAMBDA); sexp res = sexp_alloc_type(ctx, lambda, SEXP_LAMBDA);
sexp_lambda_name(res) = sexp_lambda_name(lambda); sexp_lambda_name(res) = sexp_lambda_name(lambda);
sexp_lambda_params(res) = sexp_lambda_params(lambda); sexp_lambda_params(res) = sexp_lambda_params(lambda);
@ -230,21 +230,21 @@ static sexp sexp_copy_lambda (sexp ctx sexp_api_params(self, n), sexp lambda) {
return res; return res;
} }
static sexp sexp_make_set_op (sexp ctx sexp_api_params(self, n), sexp var, sexp value) { static sexp sexp_make_set_op (sexp ctx, sexp self, sexp_sint_t n, sexp var, sexp value) {
sexp res = sexp_alloc_type(ctx, set, SEXP_SET); sexp res = sexp_alloc_type(ctx, set, SEXP_SET);
sexp_set_var(res) = var; sexp_set_var(res) = var;
sexp_set_value(res) = value; sexp_set_value(res) = value;
return res; return res;
} }
static sexp sexp_make_ref_op (sexp ctx sexp_api_params(self, n), sexp name, sexp cell) { static sexp sexp_make_ref_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp cell) {
sexp res = sexp_alloc_type(ctx, ref, SEXP_REF); sexp res = sexp_alloc_type(ctx, ref, SEXP_REF);
sexp_ref_name(res) = name; sexp_ref_name(res) = name;
sexp_ref_cell(res) = cell; sexp_ref_cell(res) = cell;
return res; return res;
} }
static sexp sexp_make_cnd_op (sexp ctx sexp_api_params(self, n), sexp test, sexp pass, sexp fail) { static sexp sexp_make_cnd_op (sexp ctx, sexp self, sexp_sint_t n, sexp test, sexp pass, sexp fail) {
sexp res = sexp_alloc_type(ctx, cnd, SEXP_CND); sexp res = sexp_alloc_type(ctx, cnd, SEXP_CND);
sexp_cnd_test(res) = test; sexp_cnd_test(res) = test;
sexp_cnd_pass(res) = pass; sexp_cnd_pass(res) = pass;
@ -252,19 +252,19 @@ static sexp sexp_make_cnd_op (sexp ctx sexp_api_params(self, n), sexp test, sexp
return res; return res;
} }
static sexp sexp_make_seq (sexp ctx sexp_api_params(self, n), sexp ls) { static sexp sexp_make_seq (sexp ctx, sexp self, sexp_sint_t n, sexp ls) {
sexp res = sexp_alloc_type(ctx, seq, SEXP_SEQ); sexp res = sexp_alloc_type(ctx, seq, SEXP_SEQ);
sexp_seq_ls(res) = ls; sexp_seq_ls(res) = ls;
return res; return res;
} }
static sexp sexp_make_lit_op (sexp ctx sexp_api_params(self, n), sexp value) { static sexp sexp_make_lit_op (sexp ctx, sexp self, sexp_sint_t n, sexp value) {
sexp res = sexp_alloc_type(ctx, lit, SEXP_LIT); sexp res = sexp_alloc_type(ctx, lit, SEXP_LIT);
sexp_lit_value(res) = value; sexp_lit_value(res) = value;
return res; return res;
} }
static sexp sexp_analyze_op (sexp ctx sexp_api_params(self, n), sexp x, sexp e) { static sexp sexp_analyze_op (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp e) {
sexp ctx2 = ctx; sexp ctx2 = ctx;
if (sexp_envp(e)) { if (sexp_envp(e)) {
ctx2 = sexp_make_child_context(ctx, NULL); ctx2 = sexp_make_child_context(ctx, NULL);
@ -273,7 +273,7 @@ static sexp sexp_analyze_op (sexp ctx sexp_api_params(self, n), sexp x, sexp e)
return sexp_analyze(ctx2, x); return sexp_analyze(ctx2, x);
} }
static sexp sexp_optimize (sexp ctx sexp_api_params(self, n), sexp x) { static sexp sexp_optimize (sexp ctx, sexp self, sexp_sint_t n, sexp x) {
sexp_gc_var2(ls, res); sexp_gc_var2(ls, res);
sexp_gc_preserve2(ctx, ls, res); sexp_gc_preserve2(ctx, ls, res);
res = x; res = x;
@ -285,7 +285,7 @@ static sexp sexp_optimize (sexp ctx sexp_api_params(self, n), sexp x) {
return res; return res;
} }
static sexp sexp_gc_op (sexp ctx sexp_api_params(self, n)) { static sexp sexp_gc_op (sexp ctx, sexp self, sexp_sint_t n) {
size_t sum_freed=0; size_t sum_freed=0;
#if SEXP_USE_BOEHM #if SEXP_USE_BOEHM
GC_gcollect(); GC_gcollect();
@ -295,7 +295,7 @@ static sexp sexp_gc_op (sexp ctx sexp_api_params(self, n)) {
return sexp_make_unsigned_integer(ctx, sum_freed); return sexp_make_unsigned_integer(ctx, sum_freed);
} }
static sexp sexp_string_contains (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { static sexp sexp_string_contains (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp y) {
const char *res; const char *res;
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, x); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, x);
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, y); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, y);
@ -303,7 +303,7 @@ static sexp sexp_string_contains (sexp ctx sexp_api_params(self, n), sexp x, sex
return res ? sexp_make_fixnum(res-sexp_string_data(x)) : SEXP_FALSE; return res ? sexp_make_fixnum(res-sexp_string_data(x)) : SEXP_FALSE;
} }
static sexp sexp_error_string (sexp ctx sexp_api_params(self, n), sexp x) { static sexp sexp_error_string (sexp ctx, sexp self, sexp_sint_t n, sexp x) {
int err; int err;
if (x == SEXP_FALSE) { if (x == SEXP_FALSE) {
err = errno; err = errno;
@ -314,14 +314,14 @@ static sexp sexp_error_string (sexp ctx sexp_api_params(self, n), sexp x) {
return sexp_c_string(ctx, strerror(err), -1); return sexp_c_string(ctx, strerror(err), -1);
} }
static sexp sexp_update_free_vars (sexp ctx sexp_api_params(self, n), sexp x) { static sexp sexp_update_free_vars (sexp ctx, sexp self, sexp_sint_t n, sexp x) {
return sexp_free_vars(ctx, x, SEXP_NULL); return sexp_free_vars(ctx, x, SEXP_NULL);
} }
#define sexp_define_type(ctx, name, tag) \ #define sexp_define_type(ctx, name, tag) \
sexp_env_define(ctx, env, sexp_intern(ctx, name, -1), sexp_type_by_index(ctx, tag)); sexp_env_define(ctx, env, sexp_intern(ctx, name, -1), sexp_type_by_index(ctx, tag));
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp_define_type(ctx, "Object", SEXP_OBJECT); sexp_define_type(ctx, "Object", SEXP_OBJECT);
sexp_define_type(ctx, "Number", SEXP_NUMBER); sexp_define_type(ctx, "Number", SEXP_NUMBER);
sexp_define_type(ctx, "Bignum", SEXP_BIGNUM); sexp_define_type(ctx, "Bignum", SEXP_BIGNUM);

View file

@ -185,11 +185,11 @@ static sexp disasm (sexp ctx, sexp self, sexp bc, sexp out, int depth) {
return SEXP_VOID; return SEXP_VOID;
} }
static sexp sexp_disasm (sexp ctx sexp_api_params(self, n), sexp bc, sexp out) { static sexp sexp_disasm (sexp ctx, sexp self, sexp_sint_t n, sexp bc, sexp out) {
return disasm(ctx, self, bc, out, 0); return disasm(ctx, self, bc, out, 0);
} }
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp_define_foreign_param(ctx, env, "disasm", 2, (sexp_proc1)sexp_disasm, "current-output-port"); sexp_define_foreign_param(ctx, env, "disasm", 2, (sexp_proc1)sexp_disasm, "current-output-port");
return SEXP_VOID; return SEXP_VOID;
} }

View file

@ -105,11 +105,11 @@ static sexp sexp_heap_walk (sexp ctx, int depth, int printp) {
return res; return res;
} }
static sexp sexp_heap_stats (sexp ctx sexp_api_params(self, n)) { static sexp sexp_heap_stats (sexp ctx, sexp self, sexp_sint_t n) {
return sexp_heap_walk(ctx, 0, 0); return sexp_heap_walk(ctx, 0, 0);
} }
static sexp sexp_heap_dump (sexp ctx sexp_api_params(self, n), sexp depth) { static sexp sexp_heap_dump (sexp ctx, sexp self, sexp_sint_t n, sexp depth) {
if (! sexp_fixnump(depth) || (sexp_unbox_fixnum(depth) < 0)) if (! sexp_fixnump(depth) || (sexp_unbox_fixnum(depth) < 0))
return sexp_xtype_exception(ctx, self, "bad heap-dump depth", depth); return sexp_xtype_exception(ctx, self, "bad heap-dump depth", depth);
return sexp_heap_walk(ctx, sexp_unbox_fixnum(depth), 1); return sexp_heap_walk(ctx, sexp_unbox_fixnum(depth), 1);
@ -117,17 +117,17 @@ static sexp sexp_heap_dump (sexp ctx sexp_api_params(self, n), sexp depth) {
#else #else
static sexp sexp_heap_stats (sexp ctx sexp_api_params(self, n)) { static sexp sexp_heap_stats (sexp ctx, sexp self, sexp_sint_t n) {
return SEXP_NULL; return SEXP_NULL;
} }
static sexp sexp_heap_dump (sexp ctx sexp_api_params(self, n), sexp depth) { static sexp sexp_heap_dump (sexp ctx, sexp self, sexp_sint_t n, sexp depth) {
return SEXP_NULL; return SEXP_NULL;
} }
#endif #endif
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp_define_foreign(ctx, env, "heap-stats", 0, sexp_heap_stats); sexp_define_foreign(ctx, env, "heap-stats", 0, sexp_heap_stats);
sexp_define_foreign_opt(ctx, env, "heap-dump", 1, sexp_heap_dump, SEXP_ONE); sexp_define_foreign_opt(ctx, env, "heap-dump", 1, sexp_heap_dump, SEXP_ONE);
return SEXP_VOID; return SEXP_VOID;

View file

@ -4,13 +4,13 @@
#include <chibi/eval.h> #include <chibi/eval.h>
static sexp sexp_increment_cdr (sexp ctx sexp_api_params(self, n), sexp pair) { static sexp sexp_increment_cdr (sexp ctx, sexp self, sexp_sint_t n, sexp pair) {
sexp_assert_type(ctx, sexp_pairp, SEXP_PAIR, pair); sexp_assert_type(ctx, sexp_pairp, SEXP_PAIR, pair);
sexp_cdr(pair) = sexp_make_fixnum(1 + sexp_unbox_fixnum(sexp_cdr(pair))); sexp_cdr(pair) = sexp_make_fixnum(1 + sexp_unbox_fixnum(sexp_cdr(pair)));
return SEXP_VOID; return SEXP_VOID;
} }
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp_define_foreign(ctx, env, "increment-cdr!", 1, sexp_increment_cdr); sexp_define_foreign(ctx, env, "increment-cdr!", 1, sexp_increment_cdr);
return SEXP_VOID; return SEXP_VOID;
} }

View file

@ -4,7 +4,7 @@
#include <chibi/eval.h> #include <chibi/eval.h>
static sexp sexp_num_parameters (sexp ctx sexp_api_params(self, n)) { static sexp sexp_num_parameters (sexp ctx, sexp self, sexp_sint_t n) {
return sexp_stack_data(sexp_context_stack(ctx))[sexp_context_last_fp(ctx)]; return sexp_stack_data(sexp_context_stack(ctx))[sexp_context_last_fp(ctx)];
} }
@ -19,7 +19,7 @@ static sexp copy_opcode (sexp ctx, struct sexp_opcode_struct *op) {
return res; return res;
} }
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp_gc_var2(name, op); sexp_gc_var2(name, op);
sexp_gc_preserve2(ctx, name, op); sexp_gc_preserve2(ctx, name, op);
sexp_define_foreign(ctx, env, "num-parameters", 0, sexp_num_parameters); sexp_define_foreign(ctx, env, "num-parameters", 0, sexp_num_parameters);

View file

@ -1,6 +1,6 @@
/* weak.c -- weak pointers and ephemerons */ /* weak.c -- weak pointers and ephemerons */
/* Copyright (c) 2010 Alex Shinn. All rights reserved. */ /* Copyright (c) 2010-2011 Alex Shinn. All rights reserved. */
/* BSD-style license: http://synthcode.com/license.txt */ /* BSD-style license: http://synthcode.com/license.txt */
#include <chibi/eval.h> #include <chibi/eval.h>
@ -12,7 +12,7 @@ static int sexp_ephemeron_id, sexp_weak_vector_id;
#define sexp_weak_vector_p(x) sexp_check_tag(x, sexp_weak_vector_id) #define sexp_weak_vector_p(x) sexp_check_tag(x, sexp_weak_vector_id)
sexp sexp_make_ephemeron (sexp ctx sexp_api_params(self, n), sexp key, sexp value) { sexp sexp_make_ephemeron (sexp ctx, sexp self, sexp_sint_t n, sexp key, sexp value) {
sexp res = sexp_alloc_type(ctx, pair, sexp_ephemeron_id); sexp res = sexp_alloc_type(ctx, pair, sexp_ephemeron_id);
if (! sexp_exceptionp(res)) { if (! sexp_exceptionp(res)) {
sexp_ephemeron_key(res) = key; sexp_ephemeron_key(res) = key;
@ -21,11 +21,11 @@ sexp sexp_make_ephemeron (sexp ctx sexp_api_params(self, n), sexp key, sexp valu
return res; return res;
} }
sexp sexp_ephemeron_brokenp_op (sexp ctx sexp_api_params(self, n), sexp eph) { sexp sexp_ephemeron_brokenp_op (sexp ctx, sexp self, sexp_sint_t n, sexp eph) {
return sexp_make_boolean(sexp_brokenp(eph)); return sexp_make_boolean(sexp_brokenp(eph));
} }
sexp sexp_make_weak_vector (sexp ctx sexp_api_params(self, n), sexp len) { sexp sexp_make_weak_vector (sexp ctx, sexp self, sexp_sint_t n, sexp len) {
sexp vec, *x; sexp vec, *x;
int i, clen = sexp_unbox_fixnum(len); int i, clen = sexp_unbox_fixnum(len);
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, len); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, len);
@ -39,25 +39,25 @@ sexp sexp_make_weak_vector (sexp ctx sexp_api_params(self, n), sexp len) {
return vec; return vec;
} }
sexp sexp_weak_vector_length (sexp ctx sexp_api_params(self, n), sexp v) { sexp sexp_weak_vector_length (sexp ctx, sexp self, sexp_sint_t n, sexp v) {
sexp_assert_type(ctx, sexp_weak_vector_p, sexp_weak_vector_id, v); sexp_assert_type(ctx, sexp_weak_vector_p, sexp_weak_vector_id, v);
return sexp_make_fixnum(sexp_vector_length(v)); return sexp_make_fixnum(sexp_vector_length(v));
} }
sexp sexp_weak_vector_ref (sexp ctx sexp_api_params(self, n), sexp v, sexp k) { sexp sexp_weak_vector_ref (sexp ctx, sexp self, sexp_sint_t n, sexp v, sexp k) {
sexp_assert_type(ctx, sexp_weak_vector_p, sexp_weak_vector_id, v); sexp_assert_type(ctx, sexp_weak_vector_p, sexp_weak_vector_id, v);
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, k); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, k);
return sexp_vector_ref(v, k); return sexp_vector_ref(v, k);
} }
sexp sexp_weak_vector_set (sexp ctx sexp_api_params(self, n), sexp v, sexp k, sexp x) { sexp sexp_weak_vector_set (sexp ctx, sexp self, sexp_sint_t n, sexp v, sexp k, sexp x) {
sexp_assert_type(ctx, sexp_weak_vector_p, sexp_weak_vector_id, v); sexp_assert_type(ctx, sexp_weak_vector_p, sexp_weak_vector_id, v);
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, k); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, k);
sexp_vector_set(v, k, x); sexp_vector_set(v, k, x);
return SEXP_VOID; return SEXP_VOID;
} }
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp v; sexp v;
sexp_gc_var3(name, t, op); sexp_gc_var3(name, t, op);
sexp_gc_preserve3(ctx, name, t, op); sexp_gc_preserve3(ctx, name, t, op);

View file

@ -8,12 +8,12 @@
/* TODO: Check a leap second table file at appropriate intervals. */ /* TODO: Check a leap second table file at appropriate intervals. */
static time_t leap_seconds_since_epoch = 34; static time_t leap_seconds_since_epoch = 34;
static sexp sexp_current_second (sexp ctx sexp_api_params(self, n)) { static sexp sexp_current_second (sexp ctx, sexp self, sexp_sint_t n) {
time_t res = time(NULL); time_t res = time(NULL);
return sexp_make_flonum(ctx, res + leap_seconds_since_epoch); return sexp_make_flonum(ctx, res + leap_seconds_since_epoch);
} }
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp_define_foreign(ctx, env, "current-second", 0, sexp_current_second); sexp_define_foreign(ctx, env, "current-second", 0, sexp_current_second);
return SEXP_VOID; return SEXP_VOID;
} }

View file

@ -46,31 +46,31 @@ static void sexp_define_type_predicate_by_tag (sexp ctx, sexp env, char *cname,
sexp_gc_release2(ctx); sexp_gc_release2(ctx);
} }
sexp sexp_thread_timeoutp (sexp ctx sexp_api_params(self, n)) { sexp sexp_thread_timeoutp (sexp ctx, sexp self, sexp_sint_t n) {
return sexp_make_boolean(sexp_context_timeoutp(ctx)); return sexp_make_boolean(sexp_context_timeoutp(ctx));
} }
sexp sexp_thread_name (sexp ctx sexp_api_params(self, n), sexp thread) { sexp sexp_thread_name (sexp ctx, sexp self, sexp_sint_t n, sexp thread) {
sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread); sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread);
return sexp_context_name(thread); return sexp_context_name(thread);
} }
sexp sexp_thread_specific (sexp ctx sexp_api_params(self, n), sexp thread) { sexp sexp_thread_specific (sexp ctx, sexp self, sexp_sint_t n, sexp thread) {
sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread); sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread);
return sexp_context_specific(thread); return sexp_context_specific(thread);
} }
sexp sexp_thread_specific_set (sexp ctx sexp_api_params(self, n), sexp thread, sexp val) { sexp sexp_thread_specific_set (sexp ctx, sexp self, sexp_sint_t n, sexp thread, sexp val) {
sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread); sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread);
sexp_context_specific(thread) = val; sexp_context_specific(thread) = val;
return SEXP_VOID; return SEXP_VOID;
} }
sexp sexp_current_thread (sexp ctx sexp_api_params(self, n)) { sexp sexp_current_thread (sexp ctx, sexp self, sexp_sint_t n) {
return ctx; return ctx;
} }
sexp sexp_make_thread (sexp ctx sexp_api_params(self, n), sexp thunk, sexp name) { sexp sexp_make_thread (sexp ctx, sexp self, sexp_sint_t n, sexp thunk, sexp name) {
sexp res, *stack; sexp res, *stack;
sexp_assert_type(ctx, sexp_procedurep, SEXP_PROCEDURE, thunk); sexp_assert_type(ctx, sexp_procedurep, SEXP_PROCEDURE, thunk);
res = sexp_make_eval_context(ctx, SEXP_FALSE, sexp_context_env(ctx), 0, 0); res = sexp_make_eval_context(ctx, SEXP_FALSE, sexp_context_env(ctx), 0, 0);
@ -85,7 +85,7 @@ sexp sexp_make_thread (sexp ctx sexp_api_params(self, n), sexp thunk, sexp name)
return res; return res;
} }
sexp sexp_thread_start (sexp ctx sexp_api_params(self, n), sexp thread) { sexp sexp_thread_start (sexp ctx, sexp self, sexp_sint_t n, sexp thread) {
sexp cell; sexp cell;
sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread); sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread);
cell = sexp_cons(ctx, thread, SEXP_NULL); cell = sexp_cons(ctx, thread, SEXP_NULL);
@ -98,7 +98,7 @@ sexp sexp_thread_start (sexp ctx sexp_api_params(self, n), sexp thread) {
return thread; return thread;
} }
sexp sexp_thread_terminate (sexp ctx sexp_api_params(self, n), sexp thread) { sexp sexp_thread_terminate (sexp ctx, sexp self, sexp_sint_t n, sexp thread) {
sexp res = sexp_make_boolean(ctx == thread); sexp res = sexp_make_boolean(ctx == thread);
for ( ; thread && sexp_contextp(thread); thread=sexp_context_child(thread)) for ( ; thread && sexp_contextp(thread); thread=sexp_context_child(thread))
sexp_context_refuel(thread) = 0; sexp_context_refuel(thread) = 0;
@ -160,7 +160,7 @@ static void sexp_insert_timed (sexp ctx, sexp thread, sexp timeout) {
sexp_cdr(ls1) = sexp_cons(ctx, thread, ls2); sexp_cdr(ls1) = sexp_cons(ctx, thread, ls2);
} }
sexp sexp_thread_join (sexp ctx sexp_api_params(self, n), sexp thread, sexp timeout) { sexp sexp_thread_join (sexp ctx, sexp self, sexp_sint_t n, sexp thread, sexp timeout) {
sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread); sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread);
if (sexp_context_refuel(thread) <= 0) /* return true if already terminated */ { if (sexp_context_refuel(thread) <= 0) /* return true if already terminated */ {
return SEXP_TRUE; return SEXP_TRUE;
@ -172,7 +172,7 @@ sexp sexp_thread_join (sexp ctx sexp_api_params(self, n), sexp thread, sexp time
return SEXP_FALSE; return SEXP_FALSE;
} }
sexp sexp_thread_sleep (sexp ctx sexp_api_params(self, n), sexp timeout) { sexp sexp_thread_sleep (sexp ctx, sexp self, sexp_sint_t n, sexp timeout) {
sexp_context_waitp(ctx) = 1; sexp_context_waitp(ctx) = 1;
if (timeout != SEXP_TRUE) { if (timeout != SEXP_TRUE) {
sexp_assert_type(ctx, sexp_numberp, SEXP_NUMBER, timeout); sexp_assert_type(ctx, sexp_numberp, SEXP_NUMBER, timeout);
@ -184,7 +184,7 @@ sexp sexp_thread_sleep (sexp ctx sexp_api_params(self, n), sexp timeout) {
/**************************** mutexes *************************************/ /**************************** mutexes *************************************/
sexp sexp_mutex_state (sexp ctx sexp_api_params(self, n), sexp mutex) { sexp sexp_mutex_state (sexp ctx, sexp self, sexp_sint_t n, sexp mutex) {
if (!sexp_mutexp(ctx, mutex)) if (!sexp_mutexp(ctx, mutex))
return sexp_type_exception(ctx, self, sexp_unbox_fixnum(sexp_global(ctx, SEXP_G_THREADS_POLLFDS_ID)), mutex); return sexp_type_exception(ctx, self, sexp_unbox_fixnum(sexp_global(ctx, SEXP_G_THREADS_POLLFDS_ID)), mutex);
if (sexp_truep(sexp_mutex_lockp(mutex))) { if (sexp_truep(sexp_mutex_lockp(mutex))) {
@ -197,7 +197,7 @@ sexp sexp_mutex_state (sexp ctx sexp_api_params(self, n), sexp mutex) {
} }
} }
sexp sexp_mutex_lock (sexp ctx sexp_api_params(self, n), sexp mutex, sexp timeout, sexp thread) { sexp sexp_mutex_lock (sexp ctx, sexp self, sexp_sint_t n, sexp mutex, sexp timeout, sexp thread) {
if (thread == SEXP_TRUE) if (thread == SEXP_TRUE)
thread = ctx; thread = ctx;
if (sexp_not(sexp_mutex_lockp(mutex))) { if (sexp_not(sexp_mutex_lockp(mutex))) {
@ -212,7 +212,7 @@ sexp sexp_mutex_lock (sexp ctx sexp_api_params(self, n), sexp mutex, sexp timeou
} }
} }
sexp sexp_mutex_unlock (sexp ctx sexp_api_params(self, n), sexp mutex, sexp condvar, sexp timeout) { sexp sexp_mutex_unlock (sexp ctx, sexp self, sexp_sint_t n, sexp mutex, sexp condvar, sexp timeout) {
sexp ls1, ls2; sexp ls1, ls2;
if (sexp_not(condvar)) { if (sexp_not(condvar)) {
/* normal unlock - always succeeds, just need to unblock threads */ /* normal unlock - always succeeds, just need to unblock threads */
@ -248,7 +248,7 @@ sexp sexp_mutex_unlock (sexp ctx sexp_api_params(self, n), sexp mutex, sexp cond
/**************************** condition variables *************************/ /**************************** condition variables *************************/
sexp sexp_condition_variable_signal (sexp ctx sexp_api_params(self, n), sexp condvar) { sexp sexp_condition_variable_signal (sexp ctx, sexp self, sexp_sint_t n, sexp condvar) {
sexp ls1=SEXP_NULL, ls2=sexp_global(ctx, SEXP_G_THREADS_PAUSED); sexp ls1=SEXP_NULL, ls2=sexp_global(ctx, SEXP_G_THREADS_PAUSED);
for ( ; sexp_pairp(ls2); ls1=ls2, ls2=sexp_cdr(ls2)) for ( ; sexp_pairp(ls2); ls1=ls2, ls2=sexp_cdr(ls2))
if (sexp_context_event(sexp_car(ls2)) == condvar) { if (sexp_context_event(sexp_car(ls2)) == condvar) {
@ -266,7 +266,7 @@ sexp sexp_condition_variable_signal (sexp ctx sexp_api_params(self, n), sexp con
return SEXP_FALSE; return SEXP_FALSE;
} }
sexp sexp_condition_variable_broadcast (sexp ctx sexp_api_params(self, n), sexp condvar) { sexp sexp_condition_variable_broadcast (sexp ctx, sexp self, sexp_sint_t n, sexp condvar) {
sexp res = SEXP_FALSE; sexp res = SEXP_FALSE;
while (sexp_truep(sexp_condition_variable_signal(ctx, self, n, condvar))) while (sexp_truep(sexp_condition_variable_signal(ctx, self, n, condvar)))
res = SEXP_TRUE; res = SEXP_TRUE;
@ -285,7 +285,7 @@ static sexp_uint_t sexp_log2_of_pow2 (sexp_uint_t n) {
return sexp_log2_lookup[((unsigned)n * 0x077CB531U) >> 27]; return sexp_log2_lookup[((unsigned)n * 0x077CB531U) >> 27];
} }
static sexp sexp_pop_signal (sexp ctx sexp_api_params(self, n)) { static sexp sexp_pop_signal (sexp ctx, sexp self, sexp_sint_t n) {
int allsigs, restsigs, signum; int allsigs, restsigs, signum;
if (sexp_global(ctx, SEXP_G_THREADS_SIGNALS) == SEXP_ZERO) { if (sexp_global(ctx, SEXP_G_THREADS_SIGNALS) == SEXP_ZERO) {
return SEXP_FALSE; return SEXP_FALSE;
@ -298,7 +298,7 @@ static sexp sexp_pop_signal (sexp ctx sexp_api_params(self, n)) {
} }
} }
static sexp sexp_get_signal_handler (sexp ctx sexp_api_params(self, n), sexp signum) { static sexp sexp_get_signal_handler (sexp ctx, sexp self, sexp_sint_t n, sexp signum) {
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, signum); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, signum);
return sexp_vector_ref(sexp_global(ctx, SEXP_G_SIGNAL_HANDLERS), signum); return sexp_vector_ref(sexp_global(ctx, SEXP_G_SIGNAL_HANDLERS), signum);
} }
@ -311,7 +311,7 @@ static sexp sexp_make_pollfds (sexp ctx) {
return res; return res;
} }
static sexp sexp_free_pollfds (sexp ctx sexp_api_params(self, n), sexp pollfds) { static sexp sexp_free_pollfds (sexp ctx, sexp self, sexp_sint_t n, sexp pollfds) {
if (sexp_pollfds_fds(pollfds)) { if (sexp_pollfds_fds(pollfds)) {
free(sexp_pollfds_fds(pollfds)); free(sexp_pollfds_fds(pollfds));
sexp_pollfds_fds(pollfds) = NULL; sexp_pollfds_fds(pollfds) = NULL;
@ -350,7 +350,7 @@ static sexp sexp_insert_pollfd (sexp ctx, int fd, int events) {
} }
/* block the current thread on the specified port */ /* block the current thread on the specified port */
static sexp sexp_blocker (sexp ctx sexp_api_params(self, n), sexp port) { static sexp sexp_blocker (sexp ctx, sexp self, sexp_sint_t n, sexp port) {
int fd; int fd;
sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, port); sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, port);
/* register the fd */ /* register the fd */
@ -364,7 +364,7 @@ static sexp sexp_blocker (sexp ctx sexp_api_params(self, n), sexp port) {
return SEXP_VOID; return SEXP_VOID;
} }
sexp sexp_scheduler (sexp ctx sexp_api_params(self, n), sexp root_thread) { sexp sexp_scheduler (sexp ctx, sexp self, sexp_sint_t n, sexp root_thread) {
int i, k; int i, k;
struct timeval tval; struct timeval tval;
struct pollfd *pfds; struct pollfd *pfds;
@ -555,7 +555,7 @@ sexp sexp_lookup_named_type (sexp ctx, sexp env, const char *name) {
return sexp_make_fixnum((sexp_typep(t)) ? sexp_type_tag(t) : -1); return sexp_make_fixnum((sexp_typep(t)) ? sexp_type_tag(t) : -1);
} }
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp t; sexp t;
sexp_gc_var1(name); sexp_gc_var1(name);
sexp_gc_preserve1(ctx, name); sexp_gc_preserve1(ctx, name);
@ -566,8 +566,8 @@ sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) {
SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO,
SEXP_ZERO, sexp_make_fixnum(sexp_sizeof_pollfds), SEXP_ZERO, sexp_make_fixnum(sexp_sizeof_pollfds),
SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO,
SEXP_ZERO, SEXP_ZERO, (sexp_proc2)sexp_free_pollfds, SEXP_ZERO, SEXP_ZERO, NULL,
NULL); (sexp_proc2)sexp_free_pollfds);
if (sexp_typep(t)) { if (sexp_typep(t)) {
sexp_global(ctx, SEXP_G_THREADS_POLLFDS_ID) = sexp_make_fixnum(sexp_type_tag(t)); sexp_global(ctx, SEXP_G_THREADS_POLLFDS_ID) = sexp_make_fixnum(sexp_type_tag(t));
} }

View file

@ -1,5 +1,5 @@
/* rand.c -- rand_r/random_r interface */ /* rand.c -- rand_r/random_r interface */
/* Copyright (c) 2009-2010 Alex Shinn. All rights reserved. */ /* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */
/* BSD-style license: http://synthcode.com/license.txt */ /* BSD-style license: http://synthcode.com/license.txt */
#include <time.h> #include <time.h>
@ -37,7 +37,7 @@ typedef struct random_data sexp_random_t;
static sexp_uint_t rs_type_id = 0; static sexp_uint_t rs_type_id = 0;
static sexp default_random_source; static sexp default_random_source;
static sexp sexp_rs_random_integer (sexp ctx sexp_api_params(self, n), sexp rs, sexp bound) { static sexp sexp_rs_random_integer (sexp ctx, sexp self, sexp_sint_t n, sexp rs, sexp bound) {
sexp res; sexp res;
int32_t m; int32_t m;
#if SEXP_USE_BIGNUMS #if SEXP_USE_BIGNUMS
@ -69,11 +69,11 @@ static sexp sexp_rs_random_integer (sexp ctx sexp_api_params(self, n), sexp rs,
return res; return res;
} }
static sexp sexp_random_integer (sexp ctx sexp_api_params(self, n), sexp bound) { static sexp sexp_random_integer (sexp ctx, sexp self, sexp_sint_t n, sexp bound) {
return sexp_rs_random_integer(ctx sexp_api_pass(self, n), default_random_source, bound); return sexp_rs_random_integer(ctx, self, n, default_random_source, bound);
} }
static sexp sexp_rs_random_real (sexp ctx sexp_api_params(self, n), sexp rs) { static sexp sexp_rs_random_real (sexp ctx, sexp self, sexp_sint_t n, sexp rs) {
int32_t res; int32_t res;
if (! sexp_random_source_p(rs)) if (! sexp_random_source_p(rs))
return sexp_type_exception(ctx, self, rs_type_id, rs); return sexp_type_exception(ctx, self, rs_type_id, rs);
@ -81,27 +81,27 @@ static sexp sexp_rs_random_real (sexp ctx sexp_api_params(self, n), sexp rs) {
return sexp_make_flonum(ctx, (double)res / (double)RAND_MAX); return sexp_make_flonum(ctx, (double)res / (double)RAND_MAX);
} }
static sexp sexp_random_real (sexp ctx sexp_api_params(self, n)) { static sexp sexp_random_real (sexp ctx, sexp self, sexp_sint_t n) {
return sexp_rs_random_real(ctx sexp_api_pass(self, n), default_random_source); return sexp_rs_random_real(ctx, self, n, default_random_source);
} }
#if SEXP_BSD || defined(__CYGWIN__) #if SEXP_BSD || defined(__CYGWIN__)
static sexp sexp_make_random_source (sexp ctx sexp_api_params(self, n)) { static sexp sexp_make_random_source (sexp ctx, sexp self, sexp_sint_t n) {
sexp res; sexp res;
res = sexp_alloc_tagged(ctx, sexp_sizeof_random, rs_type_id); res = sexp_alloc_tagged(ctx, sexp_sizeof_random, rs_type_id);
*sexp_random_data(res) = 1; *sexp_random_data(res) = 1;
return res; return res;
} }
static sexp sexp_random_source_state_ref (sexp ctx sexp_api_params(self, n), sexp rs) { static sexp sexp_random_source_state_ref (sexp ctx, sexp self, sexp_sint_t n, sexp rs) {
if (! sexp_random_source_p(rs)) if (! sexp_random_source_p(rs))
return sexp_type_exception(ctx, self, rs_type_id, rs); return sexp_type_exception(ctx, self, rs_type_id, rs);
else else
return sexp_make_integer(ctx, *sexp_random_data(rs)); return sexp_make_integer(ctx, *sexp_random_data(rs));
} }
static sexp sexp_random_source_state_set (sexp ctx sexp_api_params(self, n), sexp rs, sexp state) { static sexp sexp_random_source_state_set (sexp ctx, sexp self, sexp_sint_t n, sexp rs, sexp state) {
if (! sexp_random_source_p(rs)) if (! sexp_random_source_p(rs))
return sexp_type_exception(ctx, self, rs_type_id, rs); return sexp_type_exception(ctx, self, rs_type_id, rs);
else if (sexp_fixnump(state)) else if (sexp_fixnump(state))
@ -118,7 +118,7 @@ static sexp sexp_random_source_state_set (sexp ctx sexp_api_params(self, n), sex
#else #else
static sexp sexp_make_random_source (sexp ctx sexp_api_params(self, n)) { static sexp sexp_make_random_source (sexp ctx, sexp self, sexp_sint_t n) {
sexp res; sexp res;
sexp_gc_var1(state); sexp_gc_var1(state);
sexp_gc_preserve1(ctx, state); sexp_gc_preserve1(ctx, state);
@ -131,14 +131,14 @@ static sexp sexp_make_random_source (sexp ctx sexp_api_params(self, n)) {
return res; return res;
} }
static sexp sexp_random_source_state_ref (sexp ctx sexp_api_params(self, n), sexp rs) { static sexp sexp_random_source_state_ref (sexp ctx, sexp self, sexp_sint_t n, sexp rs) {
if (! sexp_random_source_p(rs)) if (! sexp_random_source_p(rs))
return sexp_type_exception(ctx, self, rs_type_id, rs); return sexp_type_exception(ctx, self, rs_type_id, rs);
else else
return sexp_substring(ctx, sexp_random_state(rs), ZERO, STATE_SIZE); return sexp_substring(ctx, sexp_random_state(rs), ZERO, STATE_SIZE);
} }
static sexp sexp_random_source_state_set (sexp ctx sexp_api_params(self, n), sexp rs, sexp state) { static sexp sexp_random_source_state_set (sexp ctx, sexp self, sexp_sint_t n, sexp rs, sexp state) {
if (! sexp_random_source_p(rs)) if (! sexp_random_source_p(rs))
return sexp_type_exception(ctx, self, rs_type_id, rs); return sexp_type_exception(ctx, self, rs_type_id, rs);
else if (! (sexp_stringp(state) else if (! (sexp_stringp(state)
@ -151,14 +151,14 @@ static sexp sexp_random_source_state_set (sexp ctx sexp_api_params(self, n), sex
#endif #endif
static sexp sexp_random_source_randomize (sexp ctx sexp_api_params(self, n), sexp rs) { static sexp sexp_random_source_randomize (sexp ctx, sexp self, sexp_sint_t n, sexp rs) {
if (! sexp_random_source_p(rs)) if (! sexp_random_source_p(rs))
return sexp_type_exception(ctx, self, rs_type_id, rs); return sexp_type_exception(ctx, self, rs_type_id, rs);
sexp_seed_random(time(NULL), rs); sexp_seed_random(time(NULL), rs);
return SEXP_VOID; return SEXP_VOID;
} }
static sexp sexp_random_source_pseudo_randomize (sexp ctx sexp_api_params(self, n), sexp rs, sexp seed) { static sexp sexp_random_source_pseudo_randomize (sexp ctx, sexp self, sexp_sint_t n, sexp rs, sexp seed) {
if (! sexp_random_source_p(rs)) if (! sexp_random_source_p(rs))
return sexp_type_exception(ctx, self, rs_type_id, rs); return sexp_type_exception(ctx, self, rs_type_id, rs);
if (! sexp_fixnump(seed)) if (! sexp_fixnump(seed))
@ -167,7 +167,7 @@ static sexp sexp_random_source_pseudo_randomize (sexp ctx sexp_api_params(self,
return SEXP_VOID; return SEXP_VOID;
} }
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp_gc_var2(name, op); sexp_gc_var2(name, op);
sexp_gc_preserve2(ctx, name, op); sexp_gc_preserve2(ctx, name, op);
@ -196,10 +196,10 @@ sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) {
sexp_define_foreign(ctx, env, "random-source-randomize!", 1, sexp_random_source_randomize); sexp_define_foreign(ctx, env, "random-source-randomize!", 1, sexp_random_source_randomize);
sexp_define_foreign(ctx, env, "random-source-pseudo-randomize!", 2, sexp_random_source_pseudo_randomize); sexp_define_foreign(ctx, env, "random-source-pseudo-randomize!", 2, sexp_random_source_pseudo_randomize);
default_random_source = op = sexp_make_random_source(ctx sexp_api_pass(NULL, 0)); default_random_source = op = sexp_make_random_source(ctx, NULL, 0);
name = sexp_intern(ctx, "default-random-source", -1); name = sexp_intern(ctx, "default-random-source", -1);
sexp_env_define(ctx, env, name, default_random_source); sexp_env_define(ctx, env, name, default_random_source);
sexp_random_source_randomize(ctx sexp_api_pass(NULL, 0), default_random_source); sexp_random_source_randomize(ctx, NULL, 0, default_random_source);
sexp_gc_release2(ctx); sexp_gc_release2(ctx);
return SEXP_VOID; return SEXP_VOID;

View file

@ -1,5 +1,5 @@
/* bit.c -- bitwise operators */ /* bit.c -- bitwise operators */
/* Copyright (c) 2009-2010 Alex Shinn. All rights reserved. */ /* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */
/* BSD-style license: http://synthcode.com/license.txt */ /* BSD-style license: http://synthcode.com/license.txt */
#include <chibi/eval.h> #include <chibi/eval.h>
@ -11,7 +11,7 @@
#define sexp_bignum_normalize(x) x #define sexp_bignum_normalize(x) x
#endif #endif
static sexp sexp_bit_and (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { static sexp sexp_bit_and (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp y) {
sexp res; sexp res;
#if SEXP_USE_BIGNUMS #if SEXP_USE_BIGNUMS
sexp_sint_t len, i; sexp_sint_t len, i;
@ -21,7 +21,7 @@ static sexp sexp_bit_and (sexp ctx sexp_api_params(self, n), sexp x, sexp y) {
res = (sexp) ((sexp_uint_t)x & (sexp_uint_t)y); res = (sexp) ((sexp_uint_t)x & (sexp_uint_t)y);
#if SEXP_USE_BIGNUMS #if SEXP_USE_BIGNUMS
else if (sexp_bignump(y)) else if (sexp_bignump(y))
res = sexp_bit_and(ctx sexp_api_pass(self, n), y, x); res = sexp_bit_and(ctx, self, n, y, x);
#endif #endif
else else
res = sexp_type_exception(ctx, self, SEXP_FIXNUM, y); res = sexp_type_exception(ctx, self, SEXP_FIXNUM, y);
@ -47,7 +47,7 @@ static sexp sexp_bit_and (sexp ctx sexp_api_params(self, n), sexp x, sexp y) {
return sexp_bignum_normalize(res); return sexp_bignum_normalize(res);
} }
static sexp sexp_bit_ior (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { static sexp sexp_bit_ior (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp y) {
sexp res; sexp res;
#if SEXP_USE_BIGNUMS #if SEXP_USE_BIGNUMS
sexp_sint_t len, i; sexp_sint_t len, i;
@ -57,7 +57,7 @@ static sexp sexp_bit_ior (sexp ctx sexp_api_params(self, n), sexp x, sexp y) {
res = (sexp) ((sexp_uint_t)x | (sexp_uint_t)y); res = (sexp) ((sexp_uint_t)x | (sexp_uint_t)y);
#if SEXP_USE_BIGNUMS #if SEXP_USE_BIGNUMS
else if (sexp_bignump(y)) else if (sexp_bignump(y))
res = sexp_bit_ior(ctx sexp_api_pass(self, n), y, x); res = sexp_bit_ior(ctx, self, n, y, x);
#endif #endif
else else
res = sexp_type_exception(ctx, self, SEXP_FIXNUM, y); res = sexp_type_exception(ctx, self, SEXP_FIXNUM, y);
@ -87,7 +87,7 @@ static sexp sexp_bit_ior (sexp ctx sexp_api_params(self, n), sexp x, sexp y) {
return sexp_bignum_normalize(res); return sexp_bignum_normalize(res);
} }
static sexp sexp_bit_xor (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { static sexp sexp_bit_xor (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp y) {
sexp res; sexp res;
#if SEXP_USE_BIGNUMS #if SEXP_USE_BIGNUMS
sexp_sint_t len, i; sexp_sint_t len, i;
@ -97,7 +97,7 @@ static sexp sexp_bit_xor (sexp ctx sexp_api_params(self, n), sexp x, sexp y) {
res = sexp_make_fixnum(sexp_unbox_fixnum(x) ^ sexp_unbox_fixnum(y)); res = sexp_make_fixnum(sexp_unbox_fixnum(x) ^ sexp_unbox_fixnum(y));
#if SEXP_USE_BIGNUMS #if SEXP_USE_BIGNUMS
else if (sexp_bignump(y)) else if (sexp_bignump(y))
res = sexp_bit_xor(ctx sexp_api_pass(self, n), y, x); res = sexp_bit_xor(ctx, self, n, y, x);
#endif #endif
else else
res = sexp_type_exception(ctx, self, SEXP_FIXNUM, y); res = sexp_type_exception(ctx, self, SEXP_FIXNUM, y);
@ -129,7 +129,7 @@ static sexp sexp_bit_xor (sexp ctx sexp_api_params(self, n), sexp x, sexp y) {
/* should probably split into left and right shifts, that's a better */ /* should probably split into left and right shifts, that's a better */
/* interface anyway */ /* interface anyway */
static sexp sexp_arithmetic_shift (sexp ctx sexp_api_params(self, n), sexp i, sexp count) { static sexp sexp_arithmetic_shift (sexp ctx, sexp self, sexp_sint_t n, sexp i, sexp count) {
sexp_uint_t tmp; sexp_uint_t tmp;
sexp_sint_t c; sexp_sint_t c;
#if SEXP_USE_BIGNUMS #if SEXP_USE_BIGNUMS
@ -156,7 +156,7 @@ static sexp sexp_arithmetic_shift (sexp ctx sexp_api_params(self, n), sexp i, se
} else { } else {
sexp_gc_preserve1(ctx, res); sexp_gc_preserve1(ctx, res);
res = sexp_fixnum_to_bignum(ctx, i); res = sexp_fixnum_to_bignum(ctx, i);
res = sexp_arithmetic_shift(ctx sexp_api_pass(self, n), res, count); res = sexp_arithmetic_shift(ctx, self, n, res, count);
sexp_gc_release1(ctx); sexp_gc_release1(ctx);
} }
#endif #endif
@ -208,7 +208,7 @@ static sexp_uint_t bit_count (sexp_uint_t i) {
>> (sizeof(i) - 1) * CHAR_BIT); >> (sizeof(i) - 1) * CHAR_BIT);
} }
static sexp sexp_bit_count (sexp ctx sexp_api_params(self, n), sexp x) { static sexp sexp_bit_count (sexp ctx, sexp self, sexp_sint_t n, sexp x) {
sexp res; sexp res;
sexp_sint_t i; sexp_sint_t i;
#if SEXP_USE_BIGNUMS #if SEXP_USE_BIGNUMS
@ -250,7 +250,7 @@ static sexp_uint_t integer_log2 (sexp_uint_t x) {
return (t = x >> 8) ? 8 + log_table_256[t] : log_table_256[x]; return (t = x >> 8) ? 8 + log_table_256[t] : log_table_256[x];
} }
static sexp sexp_integer_length (sexp ctx sexp_api_params(self, n), sexp x) { static sexp sexp_integer_length (sexp ctx, sexp self, sexp_sint_t n, sexp x) {
sexp_sint_t tmp; sexp_sint_t tmp;
#if SEXP_USE_BIGNUMS #if SEXP_USE_BIGNUMS
sexp_sint_t hi; sexp_sint_t hi;
@ -269,7 +269,7 @@ static sexp sexp_integer_length (sexp ctx sexp_api_params(self, n), sexp x) {
} }
} }
static sexp sexp_bit_set_p (sexp ctx sexp_api_params(self, n), sexp i, sexp x) { static sexp sexp_bit_set_p (sexp ctx, sexp self, sexp_sint_t n, sexp i, sexp x) {
#if SEXP_USE_BIGNUMS #if SEXP_USE_BIGNUMS
sexp_uint_t pos; sexp_uint_t pos;
#endif #endif
@ -290,7 +290,7 @@ static sexp sexp_bit_set_p (sexp ctx sexp_api_params(self, n), sexp i, sexp x) {
} }
} }
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp_define_foreign(ctx, env, "bit-and", 2, sexp_bit_and); sexp_define_foreign(ctx, env, "bit-and", 2, sexp_bit_and);
sexp_define_foreign(ctx, env, "bit-ior", 2, sexp_bit_ior); sexp_define_foreign(ctx, env, "bit-ior", 2, sexp_bit_ior);
sexp_define_foreign(ctx, env, "bit-xor", 2, sexp_bit_xor); sexp_define_foreign(ctx, env, "bit-xor", 2, sexp_bit_xor);

View file

@ -1,12 +1,12 @@
/* param.c -- low-level parameter utilities */ /* param.c -- low-level parameter utilities */
/* Copyright (c) 2010 Alex Shinn. All rights reserved. */ /* Copyright (c) 2010-2011 Alex Shinn. All rights reserved. */
/* BSD-style license: http://synthcode.com/license.txt */ /* BSD-style license: http://synthcode.com/license.txt */
#include <chibi/eval.h> #include <chibi/eval.h>
#define _I(x) sexp_make_fixnum(x) #define _I(x) sexp_make_fixnum(x)
static sexp sexp_make_parameter (sexp ctx sexp_api_params(self, n), sexp init, sexp conv) { static sexp sexp_make_parameter (sexp ctx, sexp self, sexp_sint_t n, sexp init, sexp conv) {
sexp res; sexp res;
sexp_gc_var1(cell); sexp_gc_var1(cell);
sexp_gc_preserve1(ctx, cell); sexp_gc_preserve1(ctx, cell);
@ -19,24 +19,24 @@ static sexp sexp_make_parameter (sexp ctx sexp_api_params(self, n), sexp init, s
return res; return res;
} }
static sexp sexp_parameter_converter (sexp ctx sexp_api_params(self, n), sexp param) { static sexp sexp_parameter_converter (sexp ctx, sexp self, sexp_sint_t n, sexp param) {
sexp res; sexp res;
sexp_assert_type(ctx, sexp_opcodep, SEXP_OPCODE, param); sexp_assert_type(ctx, sexp_opcodep, SEXP_OPCODE, param);
res = sexp_opcode_data2(param); res = sexp_opcode_data2(param);
return res ? res : SEXP_FALSE; return res ? res : SEXP_FALSE;
} }
static sexp sexp_thread_parameters (sexp ctx sexp_api_params(self, n)) { static sexp sexp_thread_parameters (sexp ctx, sexp self, sexp_sint_t n) {
sexp res = sexp_context_params(ctx); sexp res = sexp_context_params(ctx);
return res ? res : SEXP_NULL; return res ? res : SEXP_NULL;
} }
static sexp sexp_thread_parameters_set (sexp ctx sexp_api_params(self, n), sexp new) { static sexp sexp_thread_parameters_set (sexp ctx, sexp self, sexp_sint_t n, sexp new) {
sexp_context_params(ctx) = new; sexp_context_params(ctx) = new;
return SEXP_VOID; return SEXP_VOID;
} }
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp_define_foreign(ctx, env, "%make-parameter", 2, sexp_make_parameter); sexp_define_foreign(ctx, env, "%make-parameter", 2, sexp_make_parameter);
sexp_define_foreign(ctx, env, "parameter-converter", 1, sexp_parameter_converter); sexp_define_foreign(ctx, env, "parameter-converter", 1, sexp_parameter_converter);

View file

@ -23,7 +23,7 @@ static sexp_uint_t string_hash (char *str, sexp_uint_t bound) {
return acc % bound; return acc % bound;
} }
static sexp sexp_string_hash (sexp ctx sexp_api_params(self, n), sexp str, sexp bound) { static sexp sexp_string_hash (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp bound) {
if (! sexp_stringp(str)) if (! sexp_stringp(str))
return sexp_type_exception(ctx, self, SEXP_STRING, str); return sexp_type_exception(ctx, self, SEXP_STRING, str);
else if (! sexp_fixnump(bound)) else if (! sexp_fixnump(bound))
@ -38,7 +38,7 @@ static sexp_uint_t string_ci_hash (char *str, sexp_uint_t bound) {
return acc % bound; return acc % bound;
} }
static sexp sexp_string_ci_hash (sexp ctx sexp_api_params(self, n), sexp str, sexp bound) { static sexp sexp_string_ci_hash (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp bound) {
if (! sexp_stringp(str)) if (! sexp_stringp(str))
return sexp_type_exception(ctx, self, SEXP_STRING, str); return sexp_type_exception(ctx, self, SEXP_STRING, str);
else if (! sexp_fixnump(bound)) else if (! sexp_fixnump(bound))
@ -91,13 +91,13 @@ static sexp_uint_t hash_one (sexp ctx, sexp obj, sexp_uint_t bound, sexp_sint_t
return (bound ? acc % bound : acc); return (bound ? acc % bound : acc);
} }
static sexp sexp_hash (sexp ctx sexp_api_params(self, n), sexp obj, sexp bound) { static sexp sexp_hash (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp bound) {
if (! sexp_exact_integerp(bound)) if (! sexp_exact_integerp(bound))
return sexp_type_exception(ctx, self, SEXP_FIXNUM, bound); return sexp_type_exception(ctx, self, SEXP_FIXNUM, bound);
return sexp_make_fixnum(hash_one(ctx, obj, sexp_unbox_fixnum(bound), HASH_DEPTH)); return sexp_make_fixnum(hash_one(ctx, obj, sexp_unbox_fixnum(bound), HASH_DEPTH));
} }
static sexp sexp_hash_by_identity (sexp ctx sexp_api_params(self, n), sexp obj, sexp bound) { static sexp sexp_hash_by_identity (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp bound) {
if (! sexp_exact_integerp(bound)) if (! sexp_exact_integerp(bound))
return sexp_type_exception(ctx, self, SEXP_FIXNUM, bound); return sexp_type_exception(ctx, self, SEXP_FIXNUM, bound);
return sexp_make_fixnum((sexp_uint_t)obj % sexp_unbox_fixnum(bound)); return sexp_make_fixnum((sexp_uint_t)obj % sexp_unbox_fixnum(bound));
@ -108,9 +108,9 @@ static sexp sexp_get_bucket (sexp ctx, sexp buckets, sexp hash_fn, sexp obj) {
sexp res; sexp res;
sexp_uint_t len = sexp_vector_length(buckets); sexp_uint_t len = sexp_vector_length(buckets);
if (hash_fn == SEXP_ONE) if (hash_fn == SEXP_ONE)
res = sexp_hash_by_identity(ctx sexp_api_pass(NULL, 2), obj, sexp_make_fixnum(len)); res = sexp_hash_by_identity(ctx, NULL, 2, obj, sexp_make_fixnum(len));
else if (hash_fn == SEXP_TWO) else if (hash_fn == SEXP_TWO)
res = sexp_hash(ctx sexp_api_pass(NULL, 2), obj, sexp_make_fixnum(len)); res = sexp_hash(ctx, NULL, 2, obj, sexp_make_fixnum(len));
else { else {
sexp_gc_preserve1(ctx, args); sexp_gc_preserve1(ctx, args);
args = sexp_list2(ctx, obj, sexp_make_fixnum(len)); args = sexp_list2(ctx, obj, sexp_make_fixnum(len));
@ -184,7 +184,7 @@ static void sexp_regrow_hash_table (sexp ctx, sexp ht, sexp oldbuckets, sexp has
sexp_gc_release1(ctx); sexp_gc_release1(ctx);
} }
static sexp sexp_hash_table_cell (sexp ctx sexp_api_params(self, n), sexp ht, sexp obj, sexp createp) { static sexp sexp_hash_table_cell (sexp ctx, sexp self, sexp_sint_t n, sexp ht, sexp obj, sexp createp) {
sexp buckets, eq_fn, hash_fn, i; sexp buckets, eq_fn, hash_fn, i;
sexp_uint_t size; sexp_uint_t size;
sexp_gc_var1(res); sexp_gc_var1(res);
@ -214,7 +214,7 @@ static sexp sexp_hash_table_cell (sexp ctx sexp_api_params(self, n), sexp ht, se
return res; return res;
} }
static sexp sexp_hash_table_delete (sexp ctx sexp_api_params(self, n), sexp ht, sexp obj) { static sexp sexp_hash_table_delete (sexp ctx, sexp self, sexp_sint_t n, sexp ht, sexp obj) {
sexp buckets=sexp_hash_table_buckets(ht), eq_fn=sexp_hash_table_eq_fn(ht), sexp buckets=sexp_hash_table_buckets(ht), eq_fn=sexp_hash_table_eq_fn(ht),
hash_fn=sexp_hash_table_hash_fn(ht), i, p, res; hash_fn=sexp_hash_table_hash_fn(ht), i, p, res;
i = sexp_get_bucket(ctx, buckets, hash_fn, obj); i = sexp_get_bucket(ctx, buckets, hash_fn, obj);
@ -232,7 +232,7 @@ static sexp sexp_hash_table_delete (sexp ctx sexp_api_params(self, n), sexp ht,
return SEXP_VOID; return SEXP_VOID;
} }
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp_define_foreign_opt(ctx, env, "string-hash", 2, sexp_string_hash, HASH_BOUND); sexp_define_foreign_opt(ctx, env, "string-hash", 2, sexp_string_hash, HASH_BOUND);
sexp_define_foreign_opt(ctx, env, "string-ci-hash", 2, sexp_string_ci_hash, HASH_BOUND); sexp_define_foreign_opt(ctx, env, "string-ci-hash", 2, sexp_string_ci_hash, HASH_BOUND);

View file

@ -116,7 +116,7 @@ static int sexp_object_compare (sexp ctx, sexp a, sexp b) {
return res; return res;
} }
static sexp sexp_object_compare_op (sexp ctx sexp_api_params(self, n), sexp a, sexp b) { static sexp sexp_object_compare_op (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b) {
return sexp_make_fixnum(sexp_object_compare(ctx, a, b)); return sexp_make_fixnum(sexp_object_compare(ctx, a, b));
} }
@ -190,7 +190,7 @@ static sexp sexp_qsort_less (sexp ctx, sexp *vec,
return res; return res;
} }
static sexp sexp_sort_x (sexp ctx sexp_api_params(self, n), sexp seq, static sexp sexp_sort_x (sexp ctx, sexp self, sexp_sint_t n, sexp seq,
sexp less, sexp key) { sexp less, sexp key) {
sexp_sint_t len; sexp_sint_t len;
sexp res, *data; sexp res, *data;
@ -228,7 +228,7 @@ static sexp sexp_sort_x (sexp ctx sexp_api_params(self, n), sexp seq,
return res; return res;
} }
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp_define_foreign(ctx, env, "object-cmp", 2, sexp_object_compare_op); sexp_define_foreign(ctx, env, "object-cmp", 2, sexp_object_compare_op);
sexp_define_foreign_opt(ctx, env, "sort!", 3, sexp_sort_x, SEXP_FALSE); sexp_define_foreign_opt(ctx, env, "sort!", 3, sexp_sort_x, SEXP_FALSE);
return SEXP_VOID; return SEXP_VOID;

View file

@ -1,5 +1,5 @@
/* env.c -- SRFI-98 environment interface */ /* env.c -- SRFI-98 environment interface */
/* Copyright (c) 2009-2010 Alex Shinn. All rights reserved. */ /* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */
/* BSD-style license: http://synthcode.com/license.txt */ /* BSD-style license: http://synthcode.com/license.txt */
#ifdef __APPLE__ #ifdef __APPLE__
@ -11,7 +11,7 @@ extern char **environ;
#include <chibi/eval.h> #include <chibi/eval.h>
sexp sexp_get_environment_variable (sexp ctx sexp_api_params(self, n), sexp str) { sexp sexp_get_environment_variable (sexp ctx, sexp self, sexp_sint_t n, sexp str) {
char *cstr; char *cstr;
if (! sexp_stringp(str)) if (! sexp_stringp(str))
return sexp_type_exception(ctx, self, SEXP_STRING, str); return sexp_type_exception(ctx, self, SEXP_STRING, str);
@ -19,7 +19,7 @@ sexp sexp_get_environment_variable (sexp ctx sexp_api_params(self, n), sexp str)
return cstr ? sexp_c_string(ctx, cstr, -1) : SEXP_FALSE; return cstr ? sexp_c_string(ctx, cstr, -1) : SEXP_FALSE;
} }
sexp sexp_get_environment_variables (sexp ctx sexp_api_params(self, n)) { sexp sexp_get_environment_variables (sexp ctx, sexp self, sexp_sint_t n) {
int i; int i;
char **env, *cname, *cval; char **env, *cname, *cval;
sexp_gc_var3(res, name, val); sexp_gc_var3(res, name, val);
@ -40,7 +40,7 @@ sexp sexp_get_environment_variables (sexp ctx sexp_api_params(self, n)) {
return res; return res;
} }
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {
sexp_define_foreign(ctx, env, "get-environment-variable", 1, sexp_get_environment_variable); sexp_define_foreign(ctx, env, "get-environment-variable", 1, sexp_get_environment_variable);
sexp_define_foreign(ctx, env, "get-environment-variables", 0, sexp_get_environment_variables); sexp_define_foreign(ctx, env, "get-environment-variables", 0, sexp_get_environment_variables);
return SEXP_VOID; return SEXP_VOID;

View file

@ -1,16 +1,16 @@
typedef sexp (*sexp_proc8) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc8) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp);
typedef sexp (*sexp_proc9) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc9) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp);
typedef sexp (*sexp_proc10) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc10) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp);
typedef sexp (*sexp_proc11) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc11) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp);
typedef sexp (*sexp_proc12) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc12) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp);
typedef sexp (*sexp_proc13) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc13) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp);
typedef sexp (*sexp_proc14) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc14) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp);
typedef sexp (*sexp_proc15) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc15) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp);
typedef sexp (*sexp_proc16) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc16) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp);
typedef sexp (*sexp_proc17) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc17) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp);
typedef sexp (*sexp_proc18) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc18) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp);
typedef sexp (*sexp_proc19) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); typedef sexp (*sexp_proc19) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp);
#define _A(i) stack[top-i] #define _A(i) stack[top-i]

View file

@ -2,16 +2,16 @@
/* Copyright (c) 2009-2010 Alex Shinn. All rights reserved. */ /* Copyright (c) 2009-2010 Alex Shinn. All rights reserved. */
/* BSD-style license: http://synthcode.com/license.txt */ /* BSD-style license: http://synthcode.com/license.txt */
sexp sexp_rand (sexp ctx sexp_api_params(self, n)) { sexp sexp_rand (sexp ctx, sexp self, sexp_sint_t n) {
return sexp_make_fixnum(rand()); return sexp_make_fixnum(rand());
} }
sexp sexp_srand (sexp ctx sexp_api_params(self, n), sexp seed) { sexp sexp_srand (sexp ctx, sexp self, sexp_sint_t n, sexp seed) {
srand(sexp_unbox_fixnum(seed)); srand(sexp_unbox_fixnum(seed));
return SEXP_VOID; return SEXP_VOID;
} }
sexp sexp_file_exists_p (sexp ctx sexp_api_params(self, n), sexp path) { sexp sexp_file_exists_p (sexp ctx, sexp self, sexp_sint_t n, sexp path) {
int res; int res;
uchar statbuf[STATMAX]; uchar statbuf[STATMAX];
if (! sexp_stringp(path)) if (! sexp_stringp(path))
@ -20,7 +20,7 @@ sexp sexp_file_exists_p (sexp ctx sexp_api_params(self, n), sexp path) {
return (res < 0) ? SEXP_FALSE : SEXP_TRUE; return (res < 0) ? SEXP_FALSE : SEXP_TRUE;
} }
sexp sexp_fdopen (sexp ctx sexp_api_params(self, n), sexp fd, sexp mode) { sexp sexp_fdopen (sexp ctx, sexp self, sexp_sint_t n, sexp fd, sexp mode) {
FILE *f; FILE *f;
if (! sexp_integerp(fd)) if (! sexp_integerp(fd))
return sexp_type_exception(ctx, self, SEXP_FIXNUM, fd); return sexp_type_exception(ctx, self, SEXP_FIXNUM, fd);
@ -36,17 +36,17 @@ sexp sexp_fdopen (sexp ctx sexp_api_params(self, n), sexp fd, sexp mode) {
return sexp_make_input_port(ctx, f, SEXP_FALSE); return sexp_make_input_port(ctx, f, SEXP_FALSE);
} }
sexp sexp_fileno (sexp ctx sexp_api_params(self, n), sexp port) { sexp sexp_fileno (sexp ctx, sexp self, sexp_sint_t n, sexp port) {
if (! sexp_portp(port)) if (! sexp_portp(port))
return sexp_type_exception(ctx, self, SEXP_IPORT, port); return sexp_type_exception(ctx, self, SEXP_IPORT, port);
return sexp_make_fixnum(fileno(sexp_port_stream(port))); return sexp_make_fixnum(fileno(sexp_port_stream(port)));
} }
sexp sexp_fork (sexp ctx sexp_api_params(self, n)) { sexp sexp_fork (sexp ctx, sexp self, sexp_sint_t n) {
return sexp_make_fixnum(fork()); return sexp_make_fixnum(fork());
} }
sexp sexp_exec (sexp ctx sexp_api_params(self, n), sexp name, sexp args) { sexp sexp_exec (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp args) {
int i, len = sexp_unbox_fixnum(sexp_length(ctx, args)); int i, len = sexp_unbox_fixnum(sexp_length(ctx, args));
char **argv = malloc((len+1)*sizeof(char*)); char **argv = malloc((len+1)*sizeof(char*));
for (i=0; i<len; i++, args=sexp_cdr(args)) for (i=0; i<len; i++, args=sexp_cdr(args))
@ -56,30 +56,30 @@ sexp sexp_exec (sexp ctx sexp_api_params(self, n), sexp name, sexp args) {
return SEXP_VOID; /* won't really return */ return SEXP_VOID; /* won't really return */
} }
void sexp_exits (sexp ctx sexp_api_params(self, n), sexp msg) { void sexp_exits (sexp ctx, sexp self, sexp_sint_t n, sexp msg) {
exits(sexp_string_data(sexp_stringp(msg) exits(sexp_string_data(sexp_stringp(msg)
? msg : sexp_write_to_string(ctx, msg))); ? msg : sexp_write_to_string(ctx, msg)));
} }
sexp sexp_dup (sexp ctx sexp_api_params(self, n), sexp oldfd, sexp newfd) { sexp sexp_dup (sexp ctx, sexp self, sexp_sint_t n, sexp oldfd, sexp newfd) {
return sexp_make_fixnum(dup(sexp_unbox_fixnum(oldfd), return sexp_make_fixnum(dup(sexp_unbox_fixnum(oldfd),
sexp_unbox_fixnum(newfd))); sexp_unbox_fixnum(newfd)));
} }
sexp sexp_pipe (sexp ctx sexp_api_params(self, n)) { sexp sexp_pipe (sexp ctx, sexp self, sexp_sint_t n) {
int fds[2]; int fds[2];
pipe(fds); pipe(fds);
return sexp_list2(ctx, sexp_make_fixnum(fds[0]), sexp_make_fixnum(fds[1])); return sexp_list2(ctx, sexp_make_fixnum(fds[0]), sexp_make_fixnum(fds[1]));
} }
sexp sexp_sleep (sexp ctx sexp_api_params(self, n), sexp msecs) { sexp sexp_sleep (sexp ctx, sexp self, sexp_sint_t n, sexp msecs) {
if (! sexp_integerp(msecs)) if (! sexp_integerp(msecs))
return sexp_type_exception(ctx, self, SEXP_FIXNUM, msecs); return sexp_type_exception(ctx, self, SEXP_FIXNUM, msecs);
sleep(sexp_unbox_fixnum(msecs)); sleep(sexp_unbox_fixnum(msecs));
return SEXP_VOID; return SEXP_VOID;
} }
sexp sexp_getenv (sexp ctx sexp_api_params(self, n), sexp name) { sexp sexp_getenv (sexp ctx, sexp self, sexp_sint_t n, sexp name) {
char *value; char *value;
if (! sexp_stringp(name)) if (! sexp_stringp(name))
return sexp_type_exception(ctx, self, SEXP_STRING, name); return sexp_type_exception(ctx, self, SEXP_STRING, name);
@ -87,28 +87,28 @@ sexp sexp_getenv (sexp ctx sexp_api_params(self, n), sexp name) {
return ((! value) ? SEXP_FALSE : sexp_c_string(ctx, value, -1)); return ((! value) ? SEXP_FALSE : sexp_c_string(ctx, value, -1));
} }
sexp sexp_getwd (sexp ctx sexp_api_params(self, n)) { sexp sexp_getwd (sexp ctx, sexp self, sexp_sint_t n) {
char buf[512]; char buf[512];
getwd(buf, 512); getwd(buf, 512);
return sexp_c_string(ctx, buf, -1); return sexp_c_string(ctx, buf, -1);
} }
sexp sexp_chdir (sexp ctx sexp_api_params(self, n), sexp path) { sexp sexp_chdir (sexp ctx, sexp self, sexp_sint_t n, sexp path) {
if (! sexp_stringp(path)) if (! sexp_stringp(path))
return sexp_type_exception(ctx, self, SEXP_STRING, path); return sexp_type_exception(ctx, self, SEXP_STRING, path);
chdir(sexp_string_data(path)); chdir(sexp_string_data(path));
return SEXP_VOID; return SEXP_VOID;
} }
sexp sexp_getuser (sexp ctx sexp_api_params(self, n)) { sexp sexp_getuser (sexp ctx, sexp self, sexp_sint_t n) {
return sexp_c_string(ctx, getuser(), -1); return sexp_c_string(ctx, getuser(), -1);
} }
sexp sexp_sysname (sexp ctx sexp_api_params(self, n)) { sexp sexp_sysname (sexp ctx, sexp self, sexp_sint_t n) {
return sexp_c_string(ctx, sysname(), -1); return sexp_c_string(ctx, sysname(), -1);
} }
sexp sexp_wait (sexp ctx sexp_api_params(self, n)) { /* just return (pid msg) */ sexp sexp_wait (sexp ctx, sexp self, sexp_sint_t n) { /* just return (pid msg) */
Waitmsg *wmsg; Waitmsg *wmsg;
sexp res; sexp res;
sexp_gc_var(ctx, msg, s_msg); sexp_gc_var(ctx, msg, s_msg);
@ -120,7 +120,7 @@ sexp sexp_wait (sexp ctx sexp_api_params(self, n)) { /* just return (pid msg) */
return res; return res;
} }
sexp sexp_postnote (sexp ctx sexp_api_params(self, n), sexp pid, sexp note) { sexp sexp_postnote (sexp ctx, sexp self, sexp_sint_t n, sexp pid, sexp note) {
if (! sexp_integerp(pid)) if (! sexp_integerp(pid))
return sexp_type_exception(ctx, self, SEXP_FIXNUM, pid); return sexp_type_exception(ctx, self, SEXP_FIXNUM, pid);
if (! sexp_stringp(note)) if (! sexp_stringp(note))
@ -282,7 +282,7 @@ void sexp_9p_end (Srv *srv) {
sexp_gc_release(ctx, ptr, s_ptr); sexp_gc_release(ctx, ptr, s_ptr);
} }
sexp sexp_postmountsrv (sexp ctx sexp_api_params(self, n), sexp ls, sexp name, sexp mtpt, sexp flags) { sexp sexp_postmountsrv (sexp ctx, sexp self, sexp_sint_t n, sexp ls, sexp name, sexp mtpt, sexp flags) {
Srv s; Srv s;
struct sexp_plan9_srv p9s; struct sexp_plan9_srv p9s;
if (! sexp_listp(ctx, ls)) if (! sexp_listp(ctx, ls))
@ -316,35 +316,35 @@ sexp sexp_postmountsrv (sexp ctx sexp_api_params(self, n), sexp ls, sexp name, s
return SEXP_UNDEF; return SEXP_UNDEF;
} }
sexp sexp_9p_req_offset (sexp ctx sexp_api_params(self, n), sexp req) { sexp sexp_9p_req_offset (sexp ctx, sexp self, sexp_sint_t n, sexp req) {
return sexp_make_integer(ctx, ((Req*)sexp_cpointer_value(req))->ifcall.offset); return sexp_make_integer(ctx, ((Req*)sexp_cpointer_value(req))->ifcall.offset);
} }
sexp sexp_9p_req_count (sexp ctx sexp_api_params(self, n), sexp req) { sexp sexp_9p_req_count (sexp ctx, sexp self, sexp_sint_t n, sexp req) {
return sexp_make_integer(ctx, ((Req*)sexp_cpointer_value(req))->ifcall.count); return sexp_make_integer(ctx, ((Req*)sexp_cpointer_value(req))->ifcall.count);
} }
#if 0 #if 0
sexp sexp_9p_req_path (sexp ctx sexp_api_params(self, n), sexp req) { sexp sexp_9p_req_path (sexp ctx, sexp self, sexp_sint_t n, sexp req) {
return sexp_c_string(ctx, ((Req*)sexp_cpointer_value(req))->fid->qid.path, -1); return sexp_c_string(ctx, ((Req*)sexp_cpointer_value(req))->fid->qid.path, -1);
} }
#endif #endif
sexp sexp_9p_req_fid (sexp ctx sexp_api_params(self, n), sexp req) { sexp sexp_9p_req_fid (sexp ctx, sexp self, sexp_sint_t n, sexp req) {
return sexp_make_cpointer(ctx, SEXP_CPOINTER, ((Req*)sexp_cpointer_value(req))->fid, SEXP_FALSE, 0); return sexp_make_cpointer(ctx, SEXP_CPOINTER, ((Req*)sexp_cpointer_value(req))->fid, SEXP_FALSE, 0);
} }
sexp sexp_9p_req_newfid (sexp ctx sexp_api_params(self, n), sexp req) { sexp sexp_9p_req_newfid (sexp ctx, sexp self, sexp_sint_t n, sexp req) {
return sexp_make_cpointer(ctx, SEXP_CPOINTER, ((Req*)sexp_cpointer_value(req))->newfid, SEXP_FALSE, 0); return sexp_make_cpointer(ctx, SEXP_CPOINTER, ((Req*)sexp_cpointer_value(req))->newfid, SEXP_FALSE, 0);
} }
sexp sexp_9p_respond (sexp ctx sexp_api_params(self, n), sexp req, sexp err) { sexp sexp_9p_respond (sexp ctx, sexp self, sexp_sint_t n, sexp req, sexp err) {
char *cerr = sexp_stringp(err) ? sexp_string_data(err) : nil; char *cerr = sexp_stringp(err) ? sexp_string_data(err) : nil;
respond(sexp_cpointer_value(req), cerr); respond(sexp_cpointer_value(req), cerr);
return SEXP_VOID; return SEXP_VOID;
} }
sexp sexp_9p_responderror (sexp ctx sexp_api_params(self, n), sexp req) { sexp sexp_9p_responderror (sexp ctx, sexp self, sexp_sint_t n, sexp req) {
responderror(sexp_cpointer_value(req)); responderror(sexp_cpointer_value(req));
return SEXP_VOID; return SEXP_VOID;
} }

View file

@ -139,7 +139,7 @@ static sexp simplify (sexp ctx, sexp ast, sexp init_substs, sexp lambda) {
return res; return res;
} }
sexp sexp_simplify (sexp ctx sexp_api_params(self, n), sexp ast) { sexp sexp_simplify (sexp ctx, sexp self, sexp_sint_t n, sexp ast) {
return simplify(ctx, ast, SEXP_NULL, NULL); return simplify(ctx, ast, SEXP_NULL, NULL);
} }

110
sexp.c
View file

@ -64,7 +64,7 @@ sexp sexp_alloc_tagged_aux(sexp ctx, size_t size, sexp_uint_t tag sexp_current_s
} }
#if SEXP_USE_OBJECT_BRACE_LITERALS #if SEXP_USE_OBJECT_BRACE_LITERALS
sexp sexp_write_simple_object (sexp ctx sexp_api_params(self, n), sexp obj, sexp writer, sexp out) { sexp sexp_write_simple_object (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp writer, sexp out) {
sexp t, x, *elts; sexp t, x, *elts;
sexp_gc_var1(args); sexp_gc_var1(args);
sexp_sint_t i, len, nulls=0; sexp_sint_t i, len, nulls=0;
@ -112,7 +112,7 @@ sexp sexp_write_simple_object (sexp ctx sexp_api_params(self, n), sexp obj, sexp
#define sexp_write_simple_object NULL #define sexp_write_simple_object NULL
#endif #endif
sexp sexp_finalize_port (sexp ctx sexp_api_params(self, n), sexp port) { sexp sexp_finalize_port (sexp ctx, sexp self, sexp_sint_t n, sexp port) {
if (sexp_port_openp(port)) { if (sexp_port_openp(port)) {
sexp_port_openp(port) = 0; sexp_port_openp(port) = 0;
if (sexp_port_stream(port) && ! sexp_port_no_closep(port)) { if (sexp_port_stream(port) && ! sexp_port_no_closep(port)) {
@ -131,7 +131,7 @@ sexp sexp_finalize_port (sexp ctx sexp_api_params(self, n), sexp port) {
#endif #endif
#if SEXP_USE_DL #if SEXP_USE_DL
sexp sexp_finalize_dl (sexp ctx sexp_api_params(self, n), sexp dl) { sexp sexp_finalize_dl (sexp ctx, sexp self, sexp_sint_t n, sexp dl) {
dlclose(sexp_dl_handle(dl)); dlclose(sexp_dl_handle(dl));
return SEXP_VOID; return SEXP_VOID;
} }
@ -195,7 +195,7 @@ static struct sexp_type_struct _sexp_type_specs[] = {
#if SEXP_USE_TYPE_DEFS #if SEXP_USE_TYPE_DEFS
sexp sexp_register_type_op (sexp ctx sexp_api_params(self, n), sexp name, sexp sexp_register_type_op (sexp ctx, sexp self, sexp_sint_t n, sexp name,
sexp parent, sexp slots, sexp parent, sexp slots,
sexp fb, sexp felb, sexp flb, sexp flo, sexp fls, sexp fb, sexp felb, sexp flb, sexp flo, sexp fls,
sexp sb, sexp so, sexp sc, sexp w, sexp wb, sexp wo, sexp sb, sexp so, sexp sc, sexp w, sexp wb, sexp wo,
@ -273,7 +273,7 @@ sexp sexp_register_type_op (sexp ctx sexp_api_params(self, n), sexp name,
return res; return res;
} }
sexp sexp_register_simple_type_op (sexp ctx sexp_api_params(self, n), sexp name, sexp parent, sexp slots) { sexp sexp_register_simple_type_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp parent, sexp slots) {
short i, num_slots = sexp_unbox_fixnum(sexp_length(ctx, slots)); short i, num_slots = sexp_unbox_fixnum(sexp_length(ctx, slots));
sexp type_size, num_slots_obj, cpl, tmp; sexp type_size, num_slots_obj, cpl, tmp;
if (parent && sexp_typep(parent)) { if (parent && sexp_typep(parent)) {
@ -297,7 +297,7 @@ sexp sexp_register_simple_type_op (sexp ctx sexp_api_params(self, n), sexp name,
} }
#if SEXP_USE_OBJECT_BRACE_LITERALS #if SEXP_USE_OBJECT_BRACE_LITERALS
sexp sexp_lookup_type_op(sexp ctx sexp_api_params(self, n), sexp name, sexp id) { sexp sexp_lookup_type_op(sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp id) {
int i; int i;
sexp res; sexp res;
const char* str = sexp_string_data(name); const char* str = sexp_string_data(name);
@ -322,7 +322,7 @@ sexp sexp_lookup_type_op(sexp ctx sexp_api_params(self, n), sexp name, sexp id)
} }
#endif #endif
sexp sexp_finalize_c_type (sexp ctx sexp_api_params(self, n), sexp obj) { sexp sexp_finalize_c_type (sexp ctx, sexp self, sexp_sint_t n, sexp obj) {
if (sexp_cpointer_freep(obj)) if (sexp_cpointer_freep(obj))
free(sexp_cpointer_value(obj)); free(sexp_cpointer_value(obj));
return SEXP_VOID; return SEXP_VOID;
@ -544,7 +544,7 @@ sexp sexp_range_exception (sexp ctx, sexp obj, sexp start, sexp end) {
return res; return res;
} }
sexp sexp_print_exception_op (sexp ctx sexp_api_params(self, n), sexp exn, sexp out) { sexp sexp_print_exception_op (sexp ctx, sexp self, sexp_sint_t n, sexp exn, sexp out) {
sexp ls; sexp ls;
if (! sexp_oportp(out)) if (! sexp_oportp(out))
out = sexp_make_output_port(ctx, stderr, SEXP_FALSE); out = sexp_make_output_port(ctx, stderr, SEXP_FALSE);
@ -628,7 +628,7 @@ static sexp sexp_read_error (sexp ctx, const char *msg, sexp ir, sexp port) {
/*************************** list utilities ***************************/ /*************************** list utilities ***************************/
sexp sexp_cons_op (sexp ctx sexp_api_params(self, n), sexp head, sexp tail) { sexp sexp_cons_op (sexp ctx, sexp self, sexp_sint_t n, sexp head, sexp tail) {
sexp pair = sexp_alloc_type(ctx, pair, SEXP_PAIR); sexp pair = sexp_alloc_type(ctx, pair, SEXP_PAIR);
if (sexp_exceptionp(pair)) return pair; if (sexp_exceptionp(pair)) return pair;
sexp_car(pair) = head; sexp_car(pair) = head;
@ -646,7 +646,7 @@ sexp sexp_list2 (sexp ctx, sexp a, sexp b) {
return res; return res;
} }
sexp sexp_listp_op (sexp ctx sexp_api_params(self, n), sexp hare) { sexp sexp_listp_op (sexp ctx, sexp self, sexp_sint_t n, sexp hare) {
sexp turtle; sexp turtle;
if (! sexp_pairp(hare)) if (! sexp_pairp(hare))
return sexp_make_boolean(sexp_nullp(hare)); return sexp_make_boolean(sexp_nullp(hare));
@ -660,7 +660,7 @@ sexp sexp_listp_op (sexp ctx sexp_api_params(self, n), sexp hare) {
return sexp_make_boolean(sexp_nullp(hare)); return sexp_make_boolean(sexp_nullp(hare));
} }
sexp sexp_memq_op (sexp ctx sexp_api_params(self, n), sexp x, sexp ls) { sexp sexp_memq_op (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp ls) {
while (sexp_pairp(ls)) while (sexp_pairp(ls))
if (x == sexp_car(ls)) if (x == sexp_car(ls))
return ls; return ls;
@ -669,7 +669,7 @@ sexp sexp_memq_op (sexp ctx sexp_api_params(self, n), sexp x, sexp ls) {
return SEXP_FALSE; return SEXP_FALSE;
} }
sexp sexp_assq_op (sexp ctx sexp_api_params(self, n), sexp x, sexp ls) { sexp sexp_assq_op (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp ls) {
while (sexp_pairp(ls)) while (sexp_pairp(ls))
if (sexp_pairp(sexp_car(ls)) && (x == sexp_caar(ls))) if (sexp_pairp(sexp_car(ls)) && (x == sexp_caar(ls)))
return sexp_car(ls); return sexp_car(ls);
@ -678,7 +678,7 @@ sexp sexp_assq_op (sexp ctx sexp_api_params(self, n), sexp x, sexp ls) {
return SEXP_FALSE; return SEXP_FALSE;
} }
sexp sexp_reverse_op (sexp ctx sexp_api_params(self, n), sexp ls) { sexp sexp_reverse_op (sexp ctx, sexp self, sexp_sint_t n, sexp ls) {
sexp_gc_var1(res); sexp_gc_var1(res);
sexp_gc_preserve1(ctx, res); sexp_gc_preserve1(ctx, res);
for (res=SEXP_NULL; sexp_pairp(ls); ls=sexp_cdr(ls)) for (res=SEXP_NULL; sexp_pairp(ls); ls=sexp_cdr(ls))
@ -687,7 +687,7 @@ sexp sexp_reverse_op (sexp ctx sexp_api_params(self, n), sexp ls) {
return res; return res;
} }
sexp sexp_nreverse_op (sexp ctx sexp_api_params(self, n), sexp ls) { sexp sexp_nreverse_op (sexp ctx, sexp self, sexp_sint_t n, sexp ls) {
sexp a, b, tmp; sexp a, b, tmp;
if (ls == SEXP_NULL) return ls; if (ls == SEXP_NULL) return ls;
sexp_assert_type(ctx, sexp_pairp, SEXP_PAIR, ls); sexp_assert_type(ctx, sexp_pairp, SEXP_PAIR, ls);
@ -701,7 +701,7 @@ sexp sexp_nreverse_op (sexp ctx sexp_api_params(self, n), sexp ls) {
return b; return b;
} }
sexp sexp_copy_list_op (sexp ctx sexp_api_params(self, n), sexp ls) { sexp sexp_copy_list_op (sexp ctx, sexp self, sexp_sint_t n, sexp ls) {
sexp tmp; sexp tmp;
sexp_gc_var1(res); sexp_gc_var1(res);
if (! sexp_pairp(ls)) return ls; if (! sexp_pairp(ls)) return ls;
@ -713,7 +713,7 @@ sexp sexp_copy_list_op (sexp ctx sexp_api_params(self, n), sexp ls) {
return res; return res;
} }
sexp sexp_append2_op (sexp ctx sexp_api_params(self, n), sexp a, sexp b) { sexp sexp_append2_op (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b) {
sexp_gc_var2(a1, b1); sexp_gc_var2(a1, b1);
sexp_gc_preserve2(ctx, a1, b1); sexp_gc_preserve2(ctx, a1, b1);
b1 = b; b1 = b;
@ -723,7 +723,7 @@ sexp sexp_append2_op (sexp ctx sexp_api_params(self, n), sexp a, sexp b) {
return b1; return b1;
} }
sexp sexp_length_op (sexp ctx sexp_api_params(self, n), sexp ls1) { sexp sexp_length_op (sexp ctx, sexp self, sexp_sint_t n, sexp ls1) {
sexp ls2; sexp ls2;
sexp_uint_t res = 1; sexp_uint_t res = 1;
if (!sexp_pairp(ls1)) if (!sexp_pairp(ls1))
@ -735,7 +735,7 @@ sexp sexp_length_op (sexp ctx sexp_api_params(self, n), sexp ls1) {
return sexp_make_fixnum(res + (sexp_pairp(ls2) ? 1 : 0)); return sexp_make_fixnum(res + (sexp_pairp(ls2) ? 1 : 0));
} }
sexp sexp_equalp_bound (sexp ctx sexp_api_params(self, n), sexp a, sexp b, sexp bound) { sexp sexp_equalp_bound (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b, sexp bound) {
sexp_uint_t size; sexp_uint_t size;
sexp_sint_t i, len; sexp_sint_t i, len;
sexp t, *p, *q; sexp t, *p, *q;
@ -783,7 +783,7 @@ sexp sexp_equalp_bound (sexp ctx sexp_api_params(self, n), sexp a, sexp b, sexp
len = sexp_type_num_eq_slots_of_object(t, a); len = sexp_type_num_eq_slots_of_object(t, a);
if (len > 0) { if (len > 0) {
for (i=0; i<len-1; i++) { for (i=0; i<len-1; i++) {
bound = sexp_equalp_bound(ctx sexp_api_pass(self, n), p[i], q[i], bound); bound = sexp_equalp_bound(ctx, self, n, p[i], q[i], bound);
if (sexp_not(bound)) return SEXP_FALSE; if (sexp_not(bound)) return SEXP_FALSE;
} }
/* tail-recurse on the last value */ /* tail-recurse on the last value */
@ -792,15 +792,15 @@ sexp sexp_equalp_bound (sexp ctx sexp_api_params(self, n), sexp a, sexp b, sexp
return bound; return bound;
} }
sexp sexp_equalp_op (sexp ctx sexp_api_params(self, n), sexp a, sexp b) { sexp sexp_equalp_op (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b) {
return sexp_make_boolean( return sexp_make_boolean(
sexp_truep(sexp_equalp_bound(ctx sexp_api_pass(self, n), a, b, sexp_truep(sexp_equalp_bound(ctx, self, n, a, b,
sexp_make_fixnum(SEXP_MAX_FIXNUM)))); sexp_make_fixnum(SEXP_MAX_FIXNUM))));
} }
/********************* strings, symbols, vectors **********************/ /********************* strings, symbols, vectors **********************/
sexp sexp_flonump_op (sexp ctx sexp_api_params(self, n), sexp x) { sexp sexp_flonump_op (sexp ctx, sexp self, sexp_sint_t n, sexp x) {
return sexp_make_boolean(sexp_flonump(x)); return sexp_make_boolean(sexp_flonump(x));
} }
@ -826,7 +826,7 @@ sexp sexp_make_flonum (sexp ctx, float f) {
#endif #endif
#endif #endif
sexp sexp_make_bytes_op (sexp ctx sexp_api_params(self, n), sexp len, sexp i) { sexp sexp_make_bytes_op (sexp ctx, sexp self, sexp_sint_t n, sexp len, sexp i) {
sexp_sint_t clen = sexp_unbox_fixnum(len); sexp_sint_t clen = sexp_unbox_fixnum(len);
sexp s; sexp s;
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, len); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, len);
@ -870,7 +870,7 @@ void sexp_utf8_encode_char (unsigned char* p, int len, int c) {
} }
} }
sexp sexp_string_index_to_offset (sexp ctx sexp_api_params(self, n), sexp str, sexp index) { sexp sexp_string_index_to_offset (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp index) {
sexp_sint_t i, j, limit; sexp_sint_t i, j, limit;
unsigned char *p; unsigned char *p;
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str);
@ -886,7 +886,7 @@ sexp sexp_string_index_to_offset (sexp ctx sexp_api_params(self, n), sexp str, s
#endif #endif
sexp sexp_make_string_op (sexp ctx sexp_api_params(self, n), sexp len, sexp ch) sexp sexp_make_string_op (sexp ctx, sexp self, sexp_sint_t n, sexp len, sexp ch)
{ {
sexp i = (sexp_charp(ch) ? sexp_make_fixnum(sexp_unbox_character(ch)) : ch); sexp i = (sexp_charp(ch) ? sexp_make_fixnum(sexp_unbox_character(ch)) : ch);
#if SEXP_USE_PACKED_STRINGS #if SEXP_USE_PACKED_STRINGS
@ -899,7 +899,7 @@ sexp sexp_make_string_op (sexp ctx sexp_api_params(self, n), sexp len, sexp ch)
if (sexp_charp(ch) && (sexp_unbox_character(ch) >= 0x80)) { if (sexp_charp(ch) && (sexp_unbox_character(ch) >= 0x80)) {
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, len); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, len);
clen = sexp_utf8_char_byte_count(sexp_unbox_character(ch)); clen = sexp_utf8_char_byte_count(sexp_unbox_character(ch));
b = sexp_make_bytes_op(ctx sexp_api_pass(self, n), b = sexp_make_bytes_op(ctx, self, n,
sexp_fx_mul(len, sexp_make_fixnum(clen)), SEXP_VOID); sexp_fx_mul(len, sexp_make_fixnum(clen)), SEXP_VOID);
if (sexp_exceptionp(b)) return b; if (sexp_exceptionp(b)) return b;
for (j=0; j<sexp_unbox_fixnum(len); j++) for (j=0; j<sexp_unbox_fixnum(len); j++)
@ -907,7 +907,7 @@ sexp sexp_make_string_op (sexp ctx sexp_api_params(self, n), sexp len, sexp ch)
sexp_unbox_character(ch)); sexp_unbox_character(ch));
} else } else
#endif #endif
b = sexp_make_bytes_op(ctx sexp_api_pass(self, n), len, i); b = sexp_make_bytes_op(ctx, self, n, len, i);
if (sexp_exceptionp(b)) return b; if (sexp_exceptionp(b)) return b;
#if SEXP_USE_PACKED_STRINGS #if SEXP_USE_PACKED_STRINGS
sexp_pointer_tag(b) = SEXP_STRING; sexp_pointer_tag(b) = SEXP_STRING;
@ -932,7 +932,7 @@ sexp sexp_c_string (sexp ctx, const char *str, sexp_sint_t slen) {
return s; return s;
} }
sexp sexp_substring_op (sexp ctx sexp_api_params(self, n), sexp str, sexp start, sexp end) { sexp sexp_substring_op (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp start, sexp end) {
sexp res; sexp res;
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str);
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, start); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, start);
@ -954,17 +954,17 @@ sexp sexp_substring_op (sexp ctx sexp_api_params(self, n), sexp str, sexp start,
} }
#if SEXP_USE_UTF8_STRINGS #if SEXP_USE_UTF8_STRINGS
sexp sexp_utf8_substring_op (sexp ctx sexp_api_params(self, n), sexp str, sexp start, sexp end) { sexp sexp_utf8_substring_op (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp start, sexp end) {
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str);
sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, start); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, start);
start = sexp_string_index_to_offset(ctx sexp_api_pass(self, n), str, start); start = sexp_string_index_to_offset(ctx, self, n, str, start);
if (sexp_fixnump(end)) if (sexp_fixnump(end))
end = sexp_string_index_to_offset(ctx sexp_api_pass(self, n), str, end); end = sexp_string_index_to_offset(ctx, self, n, str, end);
return sexp_substring_op(ctx sexp_api_pass(self, n), str, start, end); return sexp_substring_op(ctx, self, n, str, start, end);
} }
#endif #endif
sexp sexp_string_concatenate_op (sexp ctx sexp_api_params(self, n), sexp str_ls, sexp sep) { sexp sexp_string_concatenate_op (sexp ctx, sexp self, sexp_sint_t n, sexp str_ls, sexp sep) {
sexp res, ls; sexp res, ls;
sexp_uint_t len=0, i=0, sep_len=0; sexp_uint_t len=0, i=0, sep_len=0;
char *p, *csep=NULL; char *p, *csep=NULL;
@ -1061,12 +1061,12 @@ sexp sexp_intern(sexp ctx, const char *str, sexp_sint_t len) {
return sym; return sym;
} }
sexp sexp_string_to_symbol_op (sexp ctx sexp_api_params(self, n), sexp str) { sexp sexp_string_to_symbol_op (sexp ctx, sexp self, sexp_sint_t n, sexp str) {
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str);
return sexp_intern(ctx, sexp_string_data(str), sexp_string_length(str)); return sexp_intern(ctx, sexp_string_data(str), sexp_string_length(str));
} }
sexp sexp_make_vector_op (sexp ctx sexp_api_params(self, n), sexp len, sexp dflt) { sexp sexp_make_vector_op (sexp ctx, sexp self, sexp_sint_t n, sexp len, sexp dflt) {
sexp vec, *x; sexp vec, *x;
int i, clen = sexp_unbox_fixnum(len); int i, clen = sexp_unbox_fixnum(len);
if (! clen) return sexp_global(ctx, SEXP_G_EMPTY_VECTOR); if (! clen) return sexp_global(ctx, SEXP_G_EMPTY_VECTOR);
@ -1080,7 +1080,7 @@ sexp sexp_make_vector_op (sexp ctx sexp_api_params(self, n), sexp len, sexp dflt
return vec; return vec;
} }
sexp sexp_list_to_vector_op (sexp ctx sexp_api_params(self, n), sexp ls) { sexp sexp_list_to_vector_op (sexp ctx, sexp self, sexp_sint_t n, sexp ls) {
int i; int i;
sexp x, *elts, vec = sexp_make_vector(ctx, sexp_length(ctx, ls), SEXP_VOID); sexp x, *elts, vec = sexp_make_vector(ctx, sexp_length(ctx, ls), SEXP_VOID);
if (sexp_exceptionp(vec)) return vec; if (sexp_exceptionp(vec)) return vec;
@ -1169,7 +1169,7 @@ off_t sstream_seek (void *vec, off_t offset, int whence) {
return pos; return pos;
} }
sexp sexp_make_input_string_port_op (sexp ctx sexp_api_params(self, n), sexp str) { sexp sexp_make_input_string_port_op (sexp ctx, sexp self, sexp_sint_t n, sexp str) {
FILE *in; FILE *in;
sexp res; sexp res;
sexp_gc_var1(cookie); sexp_gc_var1(cookie);
@ -1188,7 +1188,7 @@ sexp sexp_make_input_string_port_op (sexp ctx sexp_api_params(self, n), sexp str
return res; return res;
} }
sexp sexp_make_output_string_port_op (sexp ctx sexp_api_params(self, n)) { sexp sexp_make_output_string_port_op (sexp ctx, sexp self, sexp_sint_t n) {
FILE *out; FILE *out;
sexp res, size; sexp res, size;
sexp_gc_var1(cookie); sexp_gc_var1(cookie);
@ -1207,7 +1207,7 @@ sexp sexp_make_output_string_port_op (sexp ctx sexp_api_params(self, n)) {
return res; return res;
} }
sexp sexp_get_output_string_op (sexp ctx sexp_api_params(self, n), sexp port) { sexp sexp_get_output_string_op (sexp ctx, sexp self, sexp_sint_t n, sexp port) {
sexp cookie = sexp_port_cookie(port); sexp cookie = sexp_port_cookie(port);
fflush(sexp_port_stream(port)); fflush(sexp_port_stream(port));
return sexp_substring(ctx, return sexp_substring(ctx,
@ -1218,7 +1218,7 @@ sexp sexp_get_output_string_op (sexp ctx sexp_api_params(self, n), sexp port) {
#else /* SEXP_USE_STRING_STREAMS && ! SEXP_BSD */ #else /* SEXP_USE_STRING_STREAMS && ! SEXP_BSD */
sexp sexp_make_input_string_port_op (sexp ctx sexp_api_params(self, n), sexp str) { sexp sexp_make_input_string_port_op (sexp ctx, sexp self, sexp_sint_t n, sexp str) {
FILE *in; FILE *in;
sexp res; sexp res;
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str);
@ -1238,7 +1238,7 @@ sexp sexp_make_input_string_port_op (sexp ctx sexp_api_params(self, n), sexp str
return res; return res;
} }
sexp sexp_make_output_string_port_op (sexp ctx sexp_api_params(self, n)) { sexp sexp_make_output_string_port_op (sexp ctx, sexp self, sexp_sint_t n) {
sexp res = sexp_make_output_port(ctx, NULL, SEXP_FALSE); sexp res = sexp_make_output_port(ctx, NULL, SEXP_FALSE);
sexp_port_stream(res) sexp_port_stream(res)
= open_memstream(&sexp_port_buf(res), &sexp_port_size(res)); = open_memstream(&sexp_port_buf(res), &sexp_port_size(res));
@ -1246,7 +1246,7 @@ sexp sexp_make_output_string_port_op (sexp ctx sexp_api_params(self, n)) {
return res; return res;
} }
sexp sexp_get_output_string_op (sexp ctx sexp_api_params(self, n), sexp port) { sexp sexp_get_output_string_op (sexp ctx, sexp self, sexp_sint_t n, sexp port) {
sexp_assert_type(ctx, sexp_oportp, SEXP_OPORT, port); sexp_assert_type(ctx, sexp_oportp, SEXP_OPORT, port);
fflush(sexp_port_stream(port)); fflush(sexp_port_stream(port));
return sexp_c_string(ctx, sexp_port_buf(port), sexp_port_size(port)); return sexp_c_string(ctx, sexp_port_buf(port), sexp_port_size(port));
@ -1319,7 +1319,7 @@ sexp sexp_buffered_flush (sexp ctx, sexp p) {
} }
} }
sexp sexp_make_input_string_port_op (sexp ctx sexp_api_params(self, n), sexp str) { sexp sexp_make_input_string_port_op (sexp ctx, sexp self, sexp_sint_t n, sexp str) {
sexp res; sexp res;
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str);
res = sexp_make_input_port(ctx, NULL, SEXP_FALSE); res = sexp_make_input_port(ctx, NULL, SEXP_FALSE);
@ -1332,7 +1332,7 @@ sexp sexp_make_input_string_port_op (sexp ctx sexp_api_params(self, n), sexp str
return res; return res;
} }
sexp sexp_make_output_string_port_op (sexp ctx sexp_api_params(self, n)) { sexp sexp_make_output_string_port_op (sexp ctx, sexp self, sexp_sint_t n) {
sexp res = sexp_make_output_port(ctx, NULL, SEXP_FALSE); sexp res = sexp_make_output_port(ctx, NULL, SEXP_FALSE);
if (sexp_exceptionp(res)) return res; if (sexp_exceptionp(res)) return res;
sexp_port_buf(res) = (char*) sexp_malloc(SEXP_PORT_BUFFER_SIZE); sexp_port_buf(res) = (char*) sexp_malloc(SEXP_PORT_BUFFER_SIZE);
@ -1347,7 +1347,7 @@ sexp sexp_make_output_string_port_op (sexp ctx sexp_api_params(self, n)) {
return res; return res;
} }
sexp sexp_get_output_string_op (sexp ctx sexp_api_params(self, n), sexp out) { sexp sexp_get_output_string_op (sexp ctx, sexp self, sexp_sint_t n, sexp out) {
sexp res; sexp res;
sexp_gc_var2(ls, tmp); sexp_gc_var2(ls, tmp);
sexp_assert_type(ctx, sexp_oportp, SEXP_OPORT, out); sexp_assert_type(ctx, sexp_oportp, SEXP_OPORT, out);
@ -1392,22 +1392,22 @@ sexp sexp_make_output_port (sexp ctx, FILE* out, sexp name) {
return p; return p;
} }
sexp sexp_port_binaryp_op (sexp ctx sexp_api_params(self, n), sexp port) { sexp sexp_port_binaryp_op (sexp ctx, sexp self, sexp_sint_t n, sexp port) {
sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, port); sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, port);
return sexp_make_boolean(sexp_port_binaryp(port)); return sexp_make_boolean(sexp_port_binaryp(port));
} }
sexp sexp_port_openp_op (sexp ctx sexp_api_params(self, n), sexp port) { sexp sexp_port_openp_op (sexp ctx, sexp self, sexp_sint_t n, sexp port) {
sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, port); sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, port);
return sexp_make_boolean(sexp_port_openp(port)); return sexp_make_boolean(sexp_port_openp(port));
} }
#if SEXP_USE_FOLD_CASE_SYMS #if SEXP_USE_FOLD_CASE_SYMS
sexp sexp_get_port_fold_case (sexp ctx sexp_api_params(self, n), sexp in) { sexp sexp_get_port_fold_case (sexp ctx, sexp self, sexp_sint_t n, sexp in) {
sexp_assert_type(ctx, sexp_iportp, SEXP_IPORT, in); sexp_assert_type(ctx, sexp_iportp, SEXP_IPORT, in);
return sexp_make_boolean(sexp_port_fold_casep(in)); return sexp_make_boolean(sexp_port_fold_casep(in));
} }
sexp sexp_set_port_fold_case (sexp ctx sexp_api_params(self, n), sexp in, sexp x) { sexp sexp_set_port_fold_case (sexp ctx, sexp self, sexp_sint_t n, sexp in, sexp x) {
sexp_assert_type(ctx, sexp_iportp, SEXP_IPORT, in); sexp_assert_type(ctx, sexp_iportp, SEXP_IPORT, in);
sexp_assert_type(ctx, sexp_booleanp, SEXP_BOOLEAN, x); sexp_assert_type(ctx, sexp_booleanp, SEXP_BOOLEAN, x);
sexp_port_fold_casep(in) = sexp_truep(x); sexp_port_fold_casep(in) = sexp_truep(x);
@ -1679,12 +1679,12 @@ sexp sexp_write_one (sexp ctx, sexp obj, sexp out) {
return SEXP_VOID; return SEXP_VOID;
} }
sexp sexp_write_op (sexp ctx sexp_api_params(self, n), sexp obj, sexp out) { sexp sexp_write_op (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp out) {
sexp_assert_type(ctx, sexp_oportp, SEXP_OPORT, out); sexp_assert_type(ctx, sexp_oportp, SEXP_OPORT, out);
return sexp_write_one(ctx, obj, out); return sexp_write_one(ctx, obj, out);
} }
sexp sexp_display_op (sexp ctx sexp_api_params(self, n), sexp obj, sexp out) { sexp sexp_display_op (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp out) {
sexp res=SEXP_VOID; sexp res=SEXP_VOID;
sexp_assert_type(ctx, sexp_oportp, SEXP_OPORT, out); sexp_assert_type(ctx, sexp_oportp, SEXP_OPORT, out);
if (sexp_stringp(obj)) if (sexp_stringp(obj))
@ -1696,7 +1696,7 @@ sexp sexp_display_op (sexp ctx sexp_api_params(self, n), sexp obj, sexp out) {
return res; return res;
} }
sexp sexp_flush_output_op (sexp ctx sexp_api_params(self, n), sexp out) { sexp sexp_flush_output_op (sexp ctx, sexp self, sexp_sint_t n, sexp out) {
sexp_flush(ctx, out); sexp_flush(ctx, out);
return SEXP_VOID; return SEXP_VOID;
} }
@ -2067,7 +2067,7 @@ int sexp_maybe_block_port (sexp ctx, sexp in, int forcep) {
&& (((c = sexp_read_char(ctx, in)) == EOF) && (((c = sexp_read_char(ctx, in)) == EOF)
&& (errno == EAGAIN) && (errno == EAGAIN)
&& sexp_opcodep((f=sexp_global(ctx, SEXP_G_THREADS_BLOCKER))))) { && sexp_opcodep((f=sexp_global(ctx, SEXP_G_THREADS_BLOCKER))))) {
((sexp_proc2)sexp_opcode_func(f))(ctx sexp_api_pass(f, 1), in); ((sexp_proc2)sexp_opcode_func(f))(ctx, f, 1, in);
return 1; return 1;
} else { } else {
if (!forcep) sexp_push_char(ctx, c, in); if (!forcep) sexp_push_char(ctx, c, in);
@ -2515,7 +2515,7 @@ sexp sexp_read_raw (sexp ctx, sexp in) {
return res; return res;
} }
sexp sexp_read_op (sexp ctx sexp_api_params(self, n), sexp in) { sexp sexp_read_op (sexp ctx, sexp self, sexp_sint_t n, sexp in) {
sexp res; sexp res;
sexp_assert_type(ctx, sexp_iportp, SEXP_IPORT, in); sexp_assert_type(ctx, sexp_iportp, SEXP_IPORT, in);
res = sexp_read_raw(ctx, in); res = sexp_read_raw(ctx, in);
@ -2541,7 +2541,7 @@ sexp sexp_read_from_string (sexp ctx, const char *str, sexp_sint_t len) {
return res; return res;
} }
sexp sexp_string_to_number_op (sexp ctx sexp_api_params(self, n), sexp str, sexp b) { sexp sexp_string_to_number_op (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp b) {
int base; int base;
sexp_gc_var1(in); sexp_gc_var1(in);
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str);

View file

@ -938,7 +938,7 @@
(define (write-func func) (define (write-func func)
(cat "static sexp " (func-stub-name func) (cat "static sexp " (func-stub-name func)
" (sexp ctx sexp_api_params(self, n)" " (sexp ctx, sexp self, sexp_sint_t n"
(write-parameters (func-scheme-args func)) ") {\n") (write-parameters (func-scheme-args func)) ") {\n")
(write-locals func) (write-locals func)
(write-temporaries func) (write-temporaries func)
@ -1010,7 +1010,7 @@
(define (write-type-getter type name field) (define (write-type-getter type name field)
(cat "static sexp " (type-getter-name type name field) (cat "static sexp " (type-getter-name type name field)
" (sexp ctx sexp_api_params(self, n), sexp x) {\n" " (sexp ctx, sexp self, sexp_sint_t n, sexp x) {\n"
(lambda () (write-validator "x" name)) (lambda () (write-validator "x" name))
" return " " return "
(lambda () (lambda ()
@ -1056,7 +1056,7 @@
(define (write-type-setter type name field) (define (write-type-setter type name field)
(cat "static sexp " (type-setter-name type name field) (cat "static sexp " (type-setter-name type name field)
" (sexp ctx sexp_api_params(self, n), sexp x, sexp v) {\n" " (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp v) {\n"
(lambda () (write-validator "x" name)) (lambda () (write-validator "x" name))
(lambda () (write-validator "v" (car field))) (lambda () (write-validator "v" (car field)))
(write-type-setter-assignment (write-type-setter-assignment
@ -1076,7 +1076,7 @@
((memq 'finalizer: type) ((memq 'finalizer: type)
=> (lambda (x) => (lambda (x)
(cat "static sexp " (generate-stub-name (cadr x)) (cat "static sexp " (generate-stub-name (cadr x))
" (sexp ctx sexp_api_params(self, n), sexp x) {\n" " (sexp ctx, sexp self, sexp_sint_t n, sexp x) {\n"
" if (sexp_cpointer_freep(x))\n" " if (sexp_cpointer_freep(x))\n"
" " (cadr x) "(sexp_cpointer_value(x));\n" " " (cadr x) "(sexp_cpointer_value(x));\n"
" return SEXP_VOID;\n" " return SEXP_VOID;\n"
@ -1088,7 +1088,7 @@
(let ((make (caadr x)) (let ((make (caadr x))
(args (cdadr x))) (args (cdadr x)))
(cat "static sexp " (generate-stub-name make) (cat "static sexp " (generate-stub-name make)
" (sexp ctx sexp_api_params(self, n)" " (sexp ctx, sexp self, sexp_sint_t n"
(lambda () (lambda ()
(let lp ((ls args) (i 0)) (let lp ((ls args) (i 0))
(cond ((pair? ls) (cond ((pair? ls)
@ -1194,7 +1194,7 @@
(write-utilities) (write-utilities)
(for-each write-func *funcs*) (for-each write-func *funcs*)
(for-each write-type-funcs *types*) (for-each write-type-funcs *types*)
(cat "sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) {\n" (cat "sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {\n"
" sexp_gc_var2(name, tmp);\n" " sexp_gc_var2(name, tmp);\n"
" sexp_gc_preserve2(ctx, name, tmp);\n") " sexp_gc_preserve2(ctx, name, tmp);\n")
(for-each write-const *consts*) (for-each write-const *consts*)

View file

@ -131,7 +131,7 @@
(newline) (newline)
(display "typedef struct {\n") (display "typedef struct {\n")
(display " const char *name;\n") (display " const char *name;\n")
(display " sexp (*init)(sexp ctx sexp_api_params(self, n), sexp env);\n") (display " sexp (*init)(sexp ctx, sexp self, sexp_sint_t n, sexp env);\n")
(display "} sexp_library_entry_t;\n") (display "} sexp_library_entry_t;\n")
(newline) (newline)
(display "static sexp_library_entry_t sexp_static_libraries[] = {\n") (display "static sexp_library_entry_t sexp_static_libraries[] = {\n")

16
vm.c
View file

@ -791,7 +791,7 @@ static int sexp_check_type(sexp ctx, sexp a, sexp b) {
sexp_uint_t profile1[SEXP_OP_NUM_OPCODES]; sexp_uint_t profile1[SEXP_OP_NUM_OPCODES];
sexp_uint_t profile2[SEXP_OP_NUM_OPCODES][SEXP_OP_NUM_OPCODES]; sexp_uint_t profile2[SEXP_OP_NUM_OPCODES][SEXP_OP_NUM_OPCODES];
static sexp sexp_reset_vm_profile (sexp ctx sexp_api_params(self, n)) { static sexp sexp_reset_vm_profile (sexp ctx, sexp self, sexp_sint_t n) {
int i, j; int i, j;
for (i=0; i<SEXP_OP_NUM_OPCODES; i++) { for (i=0; i<SEXP_OP_NUM_OPCODES; i++) {
profile1[i] = 0; profile1[i] = 0;
@ -800,7 +800,7 @@ static sexp sexp_reset_vm_profile (sexp ctx sexp_api_params(self, n)) {
return SEXP_VOID; return SEXP_VOID;
} }
static sexp sexp_print_vm_profile (sexp ctx sexp_api_params(self, n)) { static sexp sexp_print_vm_profile (sexp ctx, sexp self, sexp_sint_t n) {
int i, j; int i, j;
for (i=0; i<SEXP_OP_NUM_OPCODES; i++) for (i=0; i<SEXP_OP_NUM_OPCODES; i++)
fprintf(stderr, "%s %lu\n", reverse_opcode_names[i], profile1[i]); fprintf(stderr, "%s %lu\n", reverse_opcode_names[i], profile1[i]);
@ -1030,31 +1030,31 @@ sexp sexp_apply (sexp ctx, sexp proc, sexp args) {
_ALIGN_IP(); _ALIGN_IP();
sexp_context_top(ctx) = top; sexp_context_top(ctx) = top;
sexp_context_last_fp(ctx) = fp; sexp_context_last_fp(ctx) = fp;
tmp1 = ((sexp_proc1)sexp_opcode_func(_WORD0))(ctx sexp_api_pass(_WORD0, 0)); tmp1 = ((sexp_proc1)sexp_opcode_func(_WORD0))(ctx, _WORD0, 0);
sexp_fcall_return(tmp1, -1) sexp_fcall_return(tmp1, -1)
break; break;
case SEXP_OP_FCALL1: case SEXP_OP_FCALL1:
_ALIGN_IP(); _ALIGN_IP();
sexp_context_top(ctx) = top; sexp_context_top(ctx) = top;
tmp1 = ((sexp_proc2)sexp_opcode_func(_WORD0))(ctx sexp_api_pass(_WORD0, 1), _ARG1); tmp1 = ((sexp_proc2)sexp_opcode_func(_WORD0))(ctx, _WORD0, 1, _ARG1);
sexp_fcall_return(tmp1, 0) sexp_fcall_return(tmp1, 0)
break; break;
case SEXP_OP_FCALL2: case SEXP_OP_FCALL2:
_ALIGN_IP(); _ALIGN_IP();
sexp_context_top(ctx) = top; sexp_context_top(ctx) = top;
tmp1 = ((sexp_proc3)sexp_opcode_func(_WORD0))(ctx sexp_api_pass(_WORD0, 2), _ARG1, _ARG2); tmp1 = ((sexp_proc3)sexp_opcode_func(_WORD0))(ctx, _WORD0, 2, _ARG1, _ARG2);
sexp_fcall_return(tmp1, 1) sexp_fcall_return(tmp1, 1)
break; break;
case SEXP_OP_FCALL3: case SEXP_OP_FCALL3:
_ALIGN_IP(); _ALIGN_IP();
sexp_context_top(ctx) = top; sexp_context_top(ctx) = top;
tmp1 = ((sexp_proc4)sexp_opcode_func(_WORD0))(ctx sexp_api_pass(_WORD0, 3), _ARG1, _ARG2, _ARG3); tmp1 = ((sexp_proc4)sexp_opcode_func(_WORD0))(ctx, _WORD0, 3, _ARG1, _ARG2, _ARG3);
sexp_fcall_return(tmp1, 2) sexp_fcall_return(tmp1, 2)
break; break;
case SEXP_OP_FCALL4: case SEXP_OP_FCALL4:
_ALIGN_IP(); _ALIGN_IP();
sexp_context_top(ctx) = top; sexp_context_top(ctx) = top;
tmp1 = ((sexp_proc5)sexp_opcode_func(_WORD0))(ctx sexp_api_pass(_WORD0, 4), _ARG1, _ARG2, _ARG3, _ARG4); tmp1 = ((sexp_proc5)sexp_opcode_func(_WORD0))(ctx, _WORD0, 4, _ARG1, _ARG2, _ARG3, _ARG4);
sexp_fcall_return(tmp1, 3) sexp_fcall_return(tmp1, 3)
break; break;
#if SEXP_USE_EXTENDED_FCALL #if SEXP_USE_EXTENDED_FCALL
@ -1839,7 +1839,7 @@ sexp sexp_apply1 (sexp ctx, sexp f, sexp x) {
sexp res; sexp res;
sexp_gc_var1(args); sexp_gc_var1(args);
if (sexp_opcodep(f) && sexp_opcode_func(f)) { if (sexp_opcodep(f) && sexp_opcode_func(f)) {
res = ((sexp_proc2)sexp_opcode_func(f))(ctx sexp_api_pass(f, 1), x); res = ((sexp_proc2)sexp_opcode_func(f))(ctx, f, 1, x);
} else { } else {
sexp_gc_preserve1(ctx, args); sexp_gc_preserve1(ctx, args);
res = sexp_apply(ctx, f, args=sexp_list1(ctx, x)); res = sexp_apply(ctx, f, args=sexp_list1(ctx, x));