mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-20 14:19:18 +02:00
Maybe-null patch for strings in chibi-ffi from Lorenzo.
This commit is contained in:
parent
122d8b8a00
commit
41c80d06ca
2 changed files with 11 additions and 3 deletions
|
@ -869,6 +869,7 @@ SEXP_API sexp sexp_make_unsigned_integer(sexp ctx, sexp_luint_t x);
|
||||||
#define sexp_string_offset(x) (sexp_field(x, string, SEXP_STRING, offset))
|
#define sexp_string_offset(x) (sexp_field(x, string, SEXP_STRING, offset))
|
||||||
#define sexp_string_data(x) (sexp_bytes_data(sexp_string_bytes(x))+sexp_string_offset(x))
|
#define sexp_string_data(x) (sexp_bytes_data(sexp_string_bytes(x))+sexp_string_offset(x))
|
||||||
#endif
|
#endif
|
||||||
|
#define sexp_string_maybe_null_data(x) (sexp_not(x) ? NULL : sexp_string_data(x))
|
||||||
|
|
||||||
#if SEXP_USE_PACKED_STRINGS
|
#if SEXP_USE_PACKED_STRINGS
|
||||||
#define sexp_string_to_bytes(ctx, x) ((x)->tag = SEXP_BYTES, x)
|
#define sexp_string_to_bytes(ctx, x) ((x)->tag = SEXP_BYTES, x)
|
||||||
|
|
|
@ -649,7 +649,10 @@
|
||||||
((eq? base 'env-string)
|
((eq? base 'env-string)
|
||||||
(cat "sexp_concat_env_string(" val ")"))
|
(cat "sexp_concat_env_string(" val ")"))
|
||||||
((string-type? base)
|
((string-type? base)
|
||||||
(cat "sexp_string_data(" val ")"))
|
(cat (if (type-null? type)
|
||||||
|
"sexp_string_maybe_null_data"
|
||||||
|
"sexp_string_data")
|
||||||
|
"(" val ")"))
|
||||||
((eq? base 'port-or-fileno)
|
((eq? base 'port-or-fileno)
|
||||||
(cat "(sexp_portp(" val ") ? sexp_port_fileno(" val ")"
|
(cat "(sexp_portp(" val ") ? sexp_port_fileno(" val ")"
|
||||||
" : sexp_fileno_fd(" val "))"))
|
" : sexp_fileno_fd(" val "))"))
|
||||||
|
@ -714,8 +717,12 @@
|
||||||
")) && sexp_stringp(sexp_cdr(" arg ")))"))
|
")) && sexp_stringp(sexp_cdr(" arg ")))"))
|
||||||
((eq? base 'fileno)
|
((eq? base 'fileno)
|
||||||
(cat "(sexp_filenop(" arg ") || sexp_fixnump(" arg "))"))
|
(cat "(sexp_filenop(" arg ") || sexp_fixnump(" arg "))"))
|
||||||
((or (int-type? base) (float-type? base)
|
((string-type? base)
|
||||||
(string-type? base) (port-type? base))
|
(cat
|
||||||
|
(if (type-null? type) "(" "")
|
||||||
|
(type-predicate type) "(" arg ")"
|
||||||
|
(lambda () (if (type-null? type) (cat " || sexp_not(" arg "))")))))
|
||||||
|
((or (int-type? base) (float-type? base) (port-type? base))
|
||||||
(cat (type-predicate type) "(" arg ")"))
|
(cat (type-predicate type) "(" arg ")"))
|
||||||
((or (lookup-type base) (void-pointer-type? type))
|
((or (lookup-type base) (void-pointer-type? type))
|
||||||
(cat
|
(cat
|
||||||
|
|
Loading…
Add table
Reference in a new issue