diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-06-23 06:24:54 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-06-23 06:24:54 -0700 |
commit | ad4e4e79ac6b9fcb182f3cd834120ec79512ac9a (patch) | |
tree | 44aae8e017bc51f526fded0d85bf3a63ba00ad8f /ffi.c | |
parent | eed035b792cb3b1b2723fa2b1ca0dd7fb5e5fe31 (diff) | |
download | txr-ad4e4e79ac6b9fcb182f3cd834120ec79512ac9a.tar.gz txr-ad4e4e79ac6b9fcb182f3cd834120ec79512ac9a.tar.bz2 txr-ad4e4e79ac6b9fcb182f3cd834120ec79512ac9a.zip |
c_str now takes a self argument.
Adding a self parameter to c_str so that when a non-string
occurs, the error is reported against a function.
Legend:
A - Pass existing self to c_str.
B - Define self and pass to c_str and possibly other
functions.
C - Take new self parameter and pass to c_str and possibly
other functions.
D - Pass existing self to c_str and/or other functions.
E - Define self and pass to other functions, not c_str.
X - Pass nil to c_str.
* buf.c (buf_strm_put_string, buf_str): B.
* chksum.c (sha256_str, md5_str): C.
(sha256_hash, md5_hash): D.
* eval.c (load): D.
* ffi.c (ffi_varray_dynsize, ffi_str_put, ffi_wstr_put, ffi_bstr_put): A.
(ffi_char_array_put, ffi_wchar_array_put): C.
(ffi_bchar_array_put): A.
(ffi_array_put, ffi_array_out, ffi_varray_put): D.
* ftw.c (ftw_wrap): A.
* glob.c (glob_wrap): A.
* lib.c (copy_str, length_str, coded_length,split_str_set,
list_str, cmp_str, num_str, out_json_str, out_json_rec,
display_width): B.
(upcase_str, downcase_str, string_extend, search_str,
do_match_str, do_rmatch_str, sub_str, replace_str,
cat_str_append, split_str_keep, trim_str, int_str, chr_str,
span_str, compl_span_str, break_str, length_str_gt,
length_str_ge, length_str_lt, length_str_le, find, rfind, pos,
rpos, mismatch, rmismatch): A.
(c_str): Add self parameter and use in type mismatch diagnostic.
If the parameter is nil, use "internal error".
(flo_str): B, and correction to "flot-str" typo.
(out_lazy_str, out_quasi_str, obj_print_impl): D.
* lib.h (c_str): Declaration updated.
* match.c (dump_var): X.
(v_load): D.
* parser.c (open_txr_file): C.
(load_rcfile): E.
(find_matching_syms, provide_atom): X.
(hist_save, repl): B.
* parser.h (open_txr_file): Declaration updated.
* parser.y (chrlit): X.
* regex.c (search_regex): A.
* socket.c (getaddrinfo_wrap, sockaddr_pack): A.
(dgram_put_string): B.
(open_sockfd): D.
(sock_connect): E.
* stream.c (stdio_put_string, tail_strategy, vformat_str,
open_directory, open_file, open_tail, remove_path,
rename_path, tmpfile_wrap, mkdtemp_wrap, mkstemp_wrap): B.
(do_parse_mode, parse_mode, make_string_byte_input_stream): B.
(normalize_mode, normalize_mode_no_bin): E.
(string_out_put_string, formatv, put_string, open_fileno,
open_subprocess, open_command, base_name,
dir_name, short_suffix, long_suffix): A.
(run): D.
(win_escape_cmd, win_escape_arg): X.
* stream.h (parse_mode, normalize_mode,
normalize_mode_no_bin): Declarations updated.
* sysif.c (mkdir_wrap, do_utimes, dlopen_wrap, dlsym_wrap,
dlvsym_wrap): A.
(do_stat, do_lstat): C.
(mkdir_nothrow_exists, ensure_dir): E.
(chdir_wrap, rmdir_wrap, mkfifo_wrap, chmod_wrap,
symlink_wrap, link_wrap, readlink_wrap, exec_wrap,
getenv_wrap, setenv_wrap, unsetenv_wrap, getpwnam_wrap,
getgrnam_wrap, crypt_wrap, fnmatch_wrap, realpath_wrap,
opendir_wrap): B.
(stat_impl): statfn pointer-to-function argument now takes
self parameter. When calling it, we pass name.
* syslog.c (openlog_wrap, syslog_wrapv): A.
* time.c (time_string_local, time_string_utc,
time_string_meth, time_parse_meth): A.
(strptime_wrap): B.
* txr.c (txr_main): D.
* y.tab.c.shipped: Updated.
Diffstat (limited to 'ffi.c')
-rw-r--r-- | ffi.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -429,7 +429,7 @@ static cnum ffi_varray_dynsize(struct txr_ffi_type *tft, val obj, val self) switch (tft->ch_conv) { case conv_char: case conv_zchar: - return utf8_to_buf(0, c_str(obj), tft->null_term); + return utf8_to_buf(0, c_str(obj, self), tft->null_term); case conv_wchar: case conv_bchar: case conv_none: @@ -1952,7 +1952,7 @@ static void ffi_str_put(struct txr_ffi_type *tft, val s, mem_t *dst, if (s == nil) { *coerce(const char **, dst) = 0; } else { - const wchar_t *ws = c_str(s); + const wchar_t *ws = c_str(s, self); char *u8s = utf8_dup_to(ws); *coerce(const char **, dst) = u8s; } @@ -2006,7 +2006,7 @@ static void ffi_wstr_put(struct txr_ffi_type *tft, val s, mem_t *dst, if (s == nil) { *coerce(const wchar_t **, dst) = 0; } else { - const wchar_t *ws = c_str(s); + const wchar_t *ws = c_str(s, self); *coerce(const wchar_t **, dst) = chk_strdup(ws); } } @@ -2042,7 +2042,7 @@ static void ffi_bstr_put(struct txr_ffi_type *tft, val s, mem_t *dst, if (s == nil) { *coerce(unsigned char **, dst) = 0; } else { - const wchar_t *ws = c_str(s); + const wchar_t *ws = c_str(s, self); unsigned char *u8s = chk_strdup_8bit(ws); *coerce(unsigned char **, dst) = u8s; } @@ -2477,10 +2477,10 @@ static val ffi_char_array_get(struct txr_ffi_type *tft, mem_t *src, } static void ffi_char_array_put(struct txr_ffi_type *tft, val str, mem_t *dst, - cnum nelem) + cnum nelem, val self) { int nt = tft->null_term; - const wchar_t *wstr = c_str(str); + const wchar_t *wstr = c_str(str, self); cnum needed = utf8_to_buf(0, wstr, nt); if (needed <= nelem) { @@ -2533,9 +2533,9 @@ static val ffi_wchar_array_get(struct txr_ffi_type *tft, mem_t *src, } static void ffi_wchar_array_put(struct txr_ffi_type *tft, val str, mem_t *dst, - cnum nelem) + cnum nelem, val self) { - const wchar_t *wstr = c_str(str); + const wchar_t *wstr = c_str(str, self); wcsncpy(coerce(wchar_t *, dst), wstr, nelem); if (tft->null_term) dst[nelem - 1] = 0; @@ -2558,7 +2558,7 @@ static val ffi_bchar_array_get(struct txr_ffi_type *tft, mem_t *src, static void ffi_bchar_array_put(struct txr_ffi_type *tft, val str, mem_t *dst, cnum nelem, val self) { - const wchar_t *wstr = c_str(str); + const wchar_t *wstr = c_str(str, self); cnum i; for (i = 0; i < nelem && wstr[i]; i++) { @@ -2691,10 +2691,10 @@ static void ffi_array_put(struct txr_ffi_type *tft, val vec, mem_t *dst, switch (tft->ch_conv) { case conv_char: case conv_zchar: - ffi_char_array_put(tft, vec, dst, tft->nelem); + ffi_char_array_put(tft, vec, dst, tft->nelem, self); break; case conv_wchar: - ffi_wchar_array_put(tft, vec, dst, tft->nelem); + ffi_wchar_array_put(tft, vec, dst, tft->nelem, self); break; case conv_bchar: ffi_bchar_array_put(tft, vec, dst, tft->nelem, self); @@ -2741,10 +2741,10 @@ static void ffi_array_out(struct txr_ffi_type *tft, int copy, val vec, switch (tft->ch_conv) { case conv_char: case conv_zchar: - ffi_char_array_put(tft, vec, dst, tft->nelem); + ffi_char_array_put(tft, vec, dst, tft->nelem, self); break; case conv_wchar: - ffi_wchar_array_put(tft, vec, dst, tft->nelem); + ffi_wchar_array_put(tft, vec, dst, tft->nelem, self); break; case conv_bchar: ffi_bchar_array_put(tft, vec, dst, tft->nelem, self); @@ -2841,10 +2841,10 @@ static void ffi_varray_put(struct txr_ffi_type *tft, val vec, mem_t *dst, switch (tft->ch_conv) { case conv_char: case conv_zchar: - ffi_char_array_put(tft, vec, dst, nelem); + ffi_char_array_put(tft, vec, dst, nelem, self); break; case conv_wchar: - ffi_wchar_array_put(tft, vec, dst, nelem); + ffi_wchar_array_put(tft, vec, dst, nelem, self); break; case conv_bchar: ffi_bchar_array_put(tft, vec, dst, nelem, self); |