diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-10-17 20:17:22 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-10-17 20:17:22 -0700 |
commit | 9b18f519decaf0cd7f52571c3c44012e3fc23a3a (patch) | |
tree | 5848a0bfd530e51183dbbf1e201a56ccf437fbd1 /match.c | |
parent | 9f158a44b7e88c1dcfb8d56f4f85d642fc423b59 (diff) | |
download | txr-9b18f519decaf0cd7f52571c3c44012e3fc23a3a.tar.gz txr-9b18f519decaf0cd7f52571c3c44012e3fc23a3a.tar.bz2 txr-9b18f519decaf0cd7f52571c3c44012e3fc23a3a.zip |
Converting cast expressions to macros that are retargetted
to C++ style casts when compiling as C++.
* lib.h (strip_qual, convert, coerce): New casting macros.
(TAG_MASK, tag, type, wli_noex, auto_str, static_str,
litptr, num_fast, chr, lit_noex, nil, nao): Use cast macros.
* arith.c (mul, isqrt_fixnum, bit): Use cast macros.
* configure (INT_PTR_MAX): Define using cast macro.
* debug.c (debug_init): Use cast macro.
* eval.c (do_eval, expand_macro, reg_op, reg_mac, eval_init):
Use cast macros.
* filter.c (filter_init): Use cast macro.
* gc.c (more, mark_obj, in_heap, mark, sweep_one, unmark): Use
cast macros.
* hash.c (hash_double, equal_hash, eql_hash, hash_equal_op,
hash_hash_op, hash_print_op, hash_mark, make_hash, make_similar_hash,
copy_hash, gethash_c, gethash, gethash_f, gethash_n, remhash,
hash_count, get_hash_userdata, set_hash_userdata, hash_iter_destroy,
hash_iter_mark, hash_begin, hash_uni, hash_diff, hash_isec): Use
cast macros.
* lib.c (code2type, chk_malloc, chk_malloc_gc_more, chk_calloc,
chk_realloc, chk_strdup, num, c_num, string, mkstring, mkustring,
upcase_str, downcase_str, string_extend, sub_str, cat_str, trim_str,
c_chr, vector, vec_set_length, copy_vec, sub_vec, cat_vec,
cobj_print_op, obj_init): Likewise.
* match.c (do_match_line, hv_trampoline, match_files, dir_tables_init):
Likewise.
* parser.l (grammar): Likewise.
* parser.y (parse): Likewise.
* rand.c (make_state, make_random_state, random_fixnum, random):
Likewise.
* regex.c (CHAR_SET_L2_LO, CHAR_SET_L2_HI, CHAR_SET_L1_LO,
CHAR_SET_L1_HI, CHAR_SET_L0_LO, CHAR_SET_L0_HI, L0_full, L0_fill_range,
L1_full, L1_fill_range, L1_contains, L1_free, L2_full, L2_fill_range,
L2_contains, L2_free, L3_fill_range, L3_contains, L3_free,
char_set_create, char_set_cobj_destroy, nfa_state_accept,
nfa_state_empty, nfa_state_single, nfa_state_wild, nfa_state_set,
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 142 |
1 files changed, 71 insertions, 71 deletions
@@ -1214,7 +1214,7 @@ static val do_match_line(match_line_ctx *c) } else { val entry = gethash(h_directive_table, directive); if (entry) { - h_match_func hmf = (h_match_func) cptr_get(entry); + h_match_func hmf = coerce(h_match_func, cptr_get(entry)); val result = hmf(c); if (result == next_spec_k) { @@ -3064,7 +3064,7 @@ static val hv_trampoline(match_line_ctx *c) internal_error("hv_trampoline: missing dispatch table entry"); { - v_match_func vmf = (v_match_func) cptr_get(entry); + v_match_func vmf = coerce(v_match_func, cptr_get(entry)); ret = vmf(&mf); if (ret == next_spec_k) c->bindings = mf.bindings; @@ -3899,7 +3899,7 @@ repeat_spec_same_data: val entry = gethash(v_directive_table, sym); if (entry) { - v_match_func vmf = (v_match_func) cptr_get(entry); + v_match_func vmf = coerce(v_match_func, cptr_get(entry)); val result; result = vmf(&c); @@ -4090,74 +4090,74 @@ static void dir_tables_init(void) non_matching_directive_table = make_hash(nil, nil, nil); protect(&h_directive_table, &v_directive_table, - &non_matching_directive_table, (val *) 0); - - sethash(v_directive_table, skip_s, cptr((mem_t *) v_skip)); - sethash(v_directive_table, fuzz_s, cptr((mem_t *) v_fuzz)); - sethash(v_directive_table, trailer_s, cptr((mem_t *) v_trailer)); - sethash(v_directive_table, freeform_s, cptr((mem_t *) v_freeform)); - sethash(v_directive_table, block_s, cptr((mem_t *) v_block)); - sethash(v_directive_table, accept_s, cptr((mem_t *) v_accept_fail)); - sethash(v_directive_table, fail_s, cptr((mem_t *) v_accept_fail)); - sethash(v_directive_table, next_s, cptr((mem_t *) v_next)); - sethash(v_directive_table, some_s, cptr((mem_t *) v_parallel)); - sethash(v_directive_table, all_s, cptr((mem_t *) v_parallel)); - sethash(v_directive_table, none_s, cptr((mem_t *) v_parallel)); - sethash(v_directive_table, maybe_s, cptr((mem_t *) v_parallel)); - sethash(v_directive_table, cases_s, cptr((mem_t *) v_parallel)); - sethash(v_directive_table, choose_s, cptr((mem_t *) v_parallel)); - sethash(v_directive_table, gather_s, cptr((mem_t *) v_gather)); - sethash(v_directive_table, collect_s, cptr((mem_t *) v_collect)); - sethash(v_directive_table, repeat_s, cptr((mem_t *) v_collect)); - sethash(v_directive_table, flatten_s, cptr((mem_t *) v_flatten)); - sethash(v_directive_table, forget_s, cptr((mem_t *) v_forget_local)); - sethash(v_directive_table, local_s, cptr((mem_t *) v_forget_local)); - sethash(v_directive_table, merge_s, cptr((mem_t *) v_merge)); - sethash(v_directive_table, bind_s, cptr((mem_t *) v_bind)); - sethash(v_directive_table, rebind_s, cptr((mem_t *) v_rebind)); - sethash(v_directive_table, set_s, cptr((mem_t *) v_set)); - sethash(v_directive_table, cat_s, cptr((mem_t *) v_cat)); - sethash(v_directive_table, output_s, cptr((mem_t *) v_output)); - sethash(v_directive_table, define_s, cptr((mem_t *) v_define)); - sethash(v_directive_table, try_s, cptr((mem_t *) v_try)); - sethash(v_directive_table, defex_s, cptr((mem_t *) v_defex)); - sethash(v_directive_table, throw_s, cptr((mem_t *) v_throw)); - sethash(v_directive_table, deffilter_s, cptr((mem_t *) v_deffilter)); - sethash(v_directive_table, filter_s, cptr((mem_t *) v_filter)); - sethash(v_directive_table, eof_s, cptr((mem_t *) v_eof)); - sethash(v_directive_table, do_s, cptr((mem_t *) v_do)); - sethash(v_directive_table, require_s, cptr((mem_t *) v_require)); - sethash(v_directive_table, assert_s, cptr((mem_t *) v_assert)); - sethash(v_directive_table, load_s, cptr((mem_t *) v_load)); - sethash(v_directive_table, close_s, cptr((mem_t *) v_close)); - sethash(v_directive_table, line_s, cptr((mem_t *) v_line)); - - sethash(h_directive_table, text_s, cptr((mem_t *) h_text)); - sethash(h_directive_table, var_s, cptr((mem_t *) h_var)); - sethash(h_directive_table, skip_s, cptr((mem_t *) h_skip)); - sethash(h_directive_table, coll_s, cptr((mem_t *) h_coll)); - sethash(h_directive_table, flatten_s, cptr((mem_t *) hv_trampoline)); - sethash(h_directive_table, forget_s, cptr((mem_t *) hv_trampoline)); - sethash(h_directive_table, local_s, cptr((mem_t *) hv_trampoline)); - sethash(h_directive_table, merge_s, cptr((mem_t *) hv_trampoline)); - sethash(h_directive_table, bind_s, cptr((mem_t *) hv_trampoline)); - sethash(h_directive_table, rebind_s, cptr((mem_t *) hv_trampoline)); - sethash(h_directive_table, set_s, cptr((mem_t *) hv_trampoline)); - sethash(h_directive_table, cat_s, cptr((mem_t *) hv_trampoline)); - sethash(h_directive_table, filter_s, cptr((mem_t *) hv_trampoline)); - sethash(h_directive_table, some_s, cptr((mem_t *) h_parallel)); - sethash(h_directive_table, all_s, cptr((mem_t *) h_parallel)); - sethash(h_directive_table, none_s, cptr((mem_t *) h_parallel)); - sethash(h_directive_table, maybe_s, cptr((mem_t *) h_parallel)); - sethash(h_directive_table, cases_s, cptr((mem_t *) h_parallel)); - sethash(h_directive_table, choose_s, cptr((mem_t *) h_parallel)); - sethash(h_directive_table, trailer_s, cptr((mem_t *) h_trailer)); - sethash(h_directive_table, define_s, cptr((mem_t *) h_define)); - sethash(h_directive_table, eol_s, cptr((mem_t *) h_eol)); - sethash(h_directive_table, chr_s, cptr((mem_t *) h_chr)); - sethash(h_directive_table, do_s, cptr((mem_t *) h_do)); - sethash(h_directive_table, require_s, cptr((mem_t *) hv_trampoline)); - sethash(h_directive_table, assert_s, cptr((mem_t *) h_assert)); + &non_matching_directive_table, convert(val *, 0)); + + sethash(v_directive_table, skip_s, cptr(coerce(mem_t *, v_skip))); + sethash(v_directive_table, fuzz_s, cptr(coerce(mem_t *, v_fuzz))); + sethash(v_directive_table, trailer_s, cptr(coerce(mem_t *, v_trailer))); + sethash(v_directive_table, freeform_s, cptr(coerce(mem_t *, v_freeform))); + sethash(v_directive_table, block_s, cptr(coerce(mem_t *, v_block))); + sethash(v_directive_table, accept_s, cptr(coerce(mem_t *, v_accept_fail))); + sethash(v_directive_table, fail_s, cptr(coerce(mem_t *, v_accept_fail))); + sethash(v_directive_table, next_s, cptr(coerce(mem_t *, v_next))); + sethash(v_directive_table, some_s, cptr(coerce(mem_t *, v_parallel))); + sethash(v_directive_table, all_s, cptr(coerce(mem_t *, v_parallel))); + sethash(v_directive_table, none_s, cptr(coerce(mem_t *, v_parallel))); + sethash(v_directive_table, maybe_s, cptr(coerce(mem_t *, v_parallel))); + sethash(v_directive_table, cases_s, cptr(coerce(mem_t *, v_parallel))); + sethash(v_directive_table, choose_s, cptr(coerce(mem_t *, v_parallel))); + sethash(v_directive_table, gather_s, cptr(coerce(mem_t *, v_gather))); + sethash(v_directive_table, collect_s, cptr(coerce(mem_t *, v_collect))); + sethash(v_directive_table, repeat_s, cptr(coerce(mem_t *, v_collect))); + sethash(v_directive_table, flatten_s, cptr(coerce(mem_t *, v_flatten))); + sethash(v_directive_table, forget_s, cptr(coerce(mem_t *, v_forget_local))); + sethash(v_directive_table, local_s, cptr(coerce(mem_t *, v_forget_local))); + sethash(v_directive_table, merge_s, cptr(coerce(mem_t *, v_merge))); + sethash(v_directive_table, bind_s, cptr(coerce(mem_t *, v_bind))); + sethash(v_directive_table, rebind_s, cptr(coerce(mem_t *, v_rebind))); + sethash(v_directive_table, set_s, cptr(coerce(mem_t *, v_set))); + sethash(v_directive_table, cat_s, cptr(coerce(mem_t *, v_cat))); + sethash(v_directive_table, output_s, cptr(coerce(mem_t *, v_output))); + sethash(v_directive_table, define_s, cptr(coerce(mem_t *, v_define))); + sethash(v_directive_table, try_s, cptr(coerce(mem_t *, v_try))); + sethash(v_directive_table, defex_s, cptr(coerce(mem_t *, v_defex))); + sethash(v_directive_table, throw_s, cptr(coerce(mem_t *, v_throw))); + sethash(v_directive_table, deffilter_s, cptr(coerce(mem_t *, v_deffilter))); + sethash(v_directive_table, filter_s, cptr(coerce(mem_t *, v_filter))); + sethash(v_directive_table, eof_s, cptr(coerce(mem_t *, v_eof))); + sethash(v_directive_table, do_s, cptr(coerce(mem_t *, v_do))); + sethash(v_directive_table, require_s, cptr(coerce(mem_t *, v_require))); + sethash(v_directive_table, assert_s, cptr(coerce(mem_t *, v_assert))); + sethash(v_directive_table, load_s, cptr(coerce(mem_t *, v_load))); + sethash(v_directive_table, close_s, cptr(coerce(mem_t *, v_close))); + sethash(v_directive_table, line_s, cptr(coerce(mem_t *, v_line))); + + sethash(h_directive_table, text_s, cptr(coerce(mem_t *, h_text))); + sethash(h_directive_table, var_s, cptr(coerce(mem_t *, h_var))); + sethash(h_directive_table, skip_s, cptr(coerce(mem_t *, h_skip))); + sethash(h_directive_table, coll_s, cptr(coerce(mem_t *, h_coll))); + sethash(h_directive_table, flatten_s, cptr(coerce(mem_t *, hv_trampoline))); + sethash(h_directive_table, forget_s, cptr(coerce(mem_t *, hv_trampoline))); + sethash(h_directive_table, local_s, cptr(coerce(mem_t *, hv_trampoline))); + sethash(h_directive_table, merge_s, cptr(coerce(mem_t *, hv_trampoline))); + sethash(h_directive_table, bind_s, cptr(coerce(mem_t *, hv_trampoline))); + sethash(h_directive_table, rebind_s, cptr(coerce(mem_t *, hv_trampoline))); + sethash(h_directive_table, set_s, cptr(coerce(mem_t *, hv_trampoline))); + sethash(h_directive_table, cat_s, cptr(coerce(mem_t *, hv_trampoline))); + sethash(h_directive_table, filter_s, cptr(coerce(mem_t *, hv_trampoline))); + sethash(h_directive_table, some_s, cptr(coerce(mem_t *, h_parallel))); + sethash(h_directive_table, all_s, cptr(coerce(mem_t *, h_parallel))); + sethash(h_directive_table, none_s, cptr(coerce(mem_t *, h_parallel))); + sethash(h_directive_table, maybe_s, cptr(coerce(mem_t *, h_parallel))); + sethash(h_directive_table, cases_s, cptr(coerce(mem_t *, h_parallel))); + sethash(h_directive_table, choose_s, cptr(coerce(mem_t *, h_parallel))); + sethash(h_directive_table, trailer_s, cptr(coerce(mem_t *, h_trailer))); + sethash(h_directive_table, define_s, cptr(coerce(mem_t *, h_define))); + sethash(h_directive_table, eol_s, cptr(coerce(mem_t *, h_eol))); + sethash(h_directive_table, chr_s, cptr(coerce(mem_t *, h_chr))); + sethash(h_directive_table, do_s, cptr(coerce(mem_t *, h_do))); + sethash(h_directive_table, require_s, cptr(coerce(mem_t *, hv_trampoline))); + sethash(h_directive_table, assert_s, cptr(coerce(mem_t *, h_assert))); sethash(non_matching_directive_table, block_s, t); sethash(non_matching_directive_table, accept_s, t); |