From 939c0c0bd057f95cc3f2ce8b6b1f0fbf88dc1546 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 12 Jun 2017 20:56:18 -0700 Subject: buf: new bufp function. * buf.c (bufp): New function. (buf_init): Registered bufp intrisic. * buf.h (bufp): Declared. * txr.1: Documented. --- buf.c | 6 ++++++ buf.h | 1 + txr.1 | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/buf.c b/buf.c index 269ccded..a5ce235f 100644 --- a/buf.c +++ b/buf.c @@ -96,6 +96,11 @@ val make_buf(val len, val init_val, val alloc_size) return obj; } +val bufp(val object) +{ + return tnil(type(object) == BUF); +} + val make_borrowed_buf(val len, mem_t *data) { val obj = make_obj(); @@ -644,6 +649,7 @@ val buf_pprint(val buf, val stream_in) void buf_init(void) { reg_fun(intern(lit("make-buf"), user_package), func_n3o(make_buf, 1)); + reg_fun(intern(lit("bufp"), user_package), func_n1(bufp)); reg_fun(intern(lit("buf-trim"), user_package), func_n1(buf_trim)); reg_fun(intern(lit("buf-set-length"), user_package), func_n3o(buf_set_length, 2)); reg_fun(intern(lit("length-buf"), user_package), func_n1(length_buf)); diff --git a/buf.h b/buf.h index 8102fff8..f3ab4a7b 100644 --- a/buf.h +++ b/buf.h @@ -26,6 +26,7 @@ */ val make_buf(val len, val init_val, val alloc_size); +val bufp(val object); val make_borrowed_buf(val len, mem_t *data); val make_duplicate_buf(val len, mem_t *data); val buf_trim(val buf); diff --git a/txr.1 b/txr.1 index 7c1ec319..07f6d951 100644 --- a/txr.1 +++ b/txr.1 @@ -52756,6 +52756,22 @@ the buffer. If an argument is specified, its value must not be less than .metn len . +.coNP Function @ bufp +.synb +.mets (bufp << object ) +.syne +.desc +The +.code bufp +function returns +.code t +if +.meta object +is a +.codn buf , +otherwise it returns +.codn nil . + .coNP Function @ length-buf .synb .mets (length-buf << buf ) -- cgit v1.2.3