From f3f07e67603ced2026c8a77d8e259d1684800408 Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Thu, 22 Dec 2016 04:58:13 +0200 Subject: [PATCH] API docs for duk_is_buffer_data() --- .../api/buffer-null-pointer-ambiguity.html | 8 +++--- website/api/duk_is_buffer.yaml | 5 +++- website/api/duk_is_buffer_data.yaml | 26 +++++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 website/api/duk_is_buffer_data.yaml diff --git a/website/api/buffer-null-pointer-ambiguity.html b/website/api/buffer-null-pointer-ambiguity.html index 7337025a..18aba8ae 100644 --- a/website/api/buffer-null-pointer-ambiguity.html +++ b/website/api/buffer-null-pointer-ambiguity.html @@ -1,6 +1,8 @@
There is no reliable way to distinguish a zero-size buffer from a non-buffer -based on the return values. A NULL with zero size is returned for -a non-buffer. The same values may be returned for a zero-size buffer (although -it is also possible that a non-NULL pointer is returned). +based on the return values alone: a NULL with zero size is returned +for a non-buffer. The same values may be returned for a zero-size buffer (although +it is also possible that a non-NULL pointer is returned). Use +duk_is_buffer_data() when type +checking a buffer or a buffer object.
diff --git a/website/api/duk_is_buffer.yaml b/website/api/duk_is_buffer.yaml index ae3bfe9e..2c778865 100644 --- a/website/api/duk_is_buffer.yaml +++ b/website/api/duk_is_buffer.yaml @@ -7,7 +7,7 @@ stack: | [ ... val! ... ] summary: | -

Returns 1 if value at idx is a buffer, otherwise +

Returns 1 if value at idx is a plain buffer, otherwise returns 0. If idx is invalid, also returns 0.

example: | @@ -19,4 +19,7 @@ tags: - stack - buffer +seealso: + - duk_is_buffer_data + introduced: 1.0.0 diff --git a/website/api/duk_is_buffer_data.yaml b/website/api/duk_is_buffer_data.yaml new file mode 100644 index 00000000..e74d2ece --- /dev/null +++ b/website/api/duk_is_buffer_data.yaml @@ -0,0 +1,26 @@ +name: duk_is_buffer_data + +proto: | + duk_bool_t duk_is_buffer_data(duk_context *ctx, duk_idx_t idx); + +stack: | + [ ... val! ... ] + +summary: | +

Returns 1 if value at idx is a plain buffer or any + buffer object type, otherwise returns 0. If idx is invalid, + also returns 0.

+ +example: | + if (duk_is_buffer_data(ctx, -3)) { + /* ... */ + } + +tags: + - stack + - buffer + +seealso: + - duk_is_buffer + +introduced: 2.0.0