diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/README.md b/lib/node_modules/@stdlib/napi/argv-booleanarray/README.md new file mode 100644 index 000000000000..6484f51ae353 --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/README.md @@ -0,0 +1,248 @@ + + +# argv_booleanarray + +> Convert a Node-API value to a boolean array. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var headerDir = require( '@stdlib/napi/argv-booleanarray' ); +``` + +#### headerDir + +Absolute file path for the directory containing header files for C APIs. + +```javascript +var dir = headerDir; +// returns +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + +```javascript +var headerDir = require( '@stdlib/napi/argv-booleanarray' ); + +console.log( headerDir ); +// => +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/napi/argv_booleanarray.h" +``` + +#### stdlib_napi_argv_booleanarray( env, value, \*\*data, \*length, \*message, \*err ) + +Converts a Node-API value to a boolean array. + +```c +#include "stdlib/napi/argv_booleanarray.h" +#include +#include +#include + +static napi_value addon( napi_env env, napi_callback_info info ) { + napi_value value; + + // ... + + bool *X; + int64_t len; + napi_value err; + napi_status status = stdlib_napi_argv_booleanarray( env, value, &X, &len, "Must be a typed array.", &err ); + assert( status == napi_ok ); + if ( err != NULL ) { + assert( napi_throw( env, err ) == napi_ok ); + return NULL; + } + + // ... +} +``` + +The function accepts the following arguments: + +- **env**: `[in] napi_env` environment under which the function is invoked. +- **value**: `[in] napi_value` Node-API value. +- **data**: `[out] bool**` pointer for returning a reference to the output array. +- **length**: `[out] int64_t*` pointer for returning the number of array elements. +- **message**: `[in] char*` error message. +- **err**: `[out] napi_value*` pointer for storing a JavaScript error. If not provided a `Uint8Array`, the function sets `err` with a JavaScript error; otherwise, `err` is set to `NULL`. + +```c +napi_status stdlib_napi_argv_booleanarray( const napi_env env, const napi_value value, bool **data, int64_t *length, const char *message, napi_value *err ); +``` + +The function returns a `napi_status` status code indicating success or failure (returns `napi_ok` if success). + +#### STDLIB_NAPI_ARGV_BOOLEANARRAY( env, X, len, argv, index ) + +Macro for converting an add-on callback argument to a boolean array. + +```c +#include "stdlib/napi/argv_booleanarray.h" +#include "stdlib/napi/argv.h" +#include +#include +#include + +static void fcn( const bool *X, const int64_t xlen, bool *Y, const int64_t ylen ) { + int64_t len; + int64_t i; + + if ( xlen > ylen ) { + len = ylen; + } else { + len = xlen; + } + for ( i = 0; i < len; i++ ) { + Y[ i ] = X[ i ]; + } +} + +// ... + +static napi_value addon( napi_env env, napi_callback_info info ) { + // Retrieve add-on callback arguments: + STDLIB_NAPI_ARGV( env, info, argv, argc, 2 ); + + // Convert the first argument to a C type: + STDLIB_NAPI_ARGV_BOOLEANARRAY( env, X, xlen, argv, 0 ); + + // Convert the second argument to a C type: + STDLIB_NAPI_ARGV_BOOLEANARRAY( env, Y, ylen, argv, 1 ); + + // ... + + fcn( X, xlen, Y, ylen ); +} +``` + +The macro expects the following arguments: + +- **env**: environment under which the callback is invoked. +- **X**: output variable name for the array. +- **len**: output variable name for the array length. +- **argv**: name of the variable containing add-on callback arguments. +- **index**: argument index. + +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/binding.gyp b/lib/node_modules/@stdlib/napi/argv-booleanarray/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/docs/types/index.d.ts b/lib/node_modules/@stdlib/napi/argv-booleanarray/docs/types/index.d.ts new file mode 100644 index 000000000000..023f953ef32f --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/docs/types/index.d.ts @@ -0,0 +1,33 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Absolute file path for the directory containing header files for C APIs. +* +* @example +* var dir = headerDir; +* // returns +*/ +declare const headerDir: string; + + +// EXPORTS // + +export = headerDir; diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/docs/types/test.ts b/lib/node_modules/@stdlib/napi/argv-booleanarray/docs/types/test.ts new file mode 100644 index 000000000000..6df3096e67da --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/docs/types/test.ts @@ -0,0 +1,28 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import headerDir = require( './index' ); + + +// TESTS // + +// The variable is a string... +{ + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + headerDir; // $ExpectType string +} diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/examples/index.js b/lib/node_modules/@stdlib/napi/argv-booleanarray/examples/index.js new file mode 100644 index 000000000000..d6ded1a29e22 --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/examples/index.js @@ -0,0 +1,24 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var headerDir = require( './../lib' ); + +console.log( headerDir ); +// => diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/include.gypi b/lib/node_modules/@stdlib/napi/argv-booleanarray/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' +#include +#include + +/** +* Macro for converting an add-on callback argument to a boolean array. +* +* @param env environment under which the function is invoked +* @param X output variable name for the array +* @param len output variable name for the array length +* @param argv name of the variable containing add-on callback arguments +* @param index argument index +* +* @example +* #include "stdlib/napi/argv_booleanarray.h" +* #include "stdlib/napi/argv.h" +* #include +* #include +* #include +* +* static void fcn( const bool *X, const int64_t xlen, bool *Y, const int64_t ylen ) { +* int64_t len; +* int64_t i; +* +* if ( xlen > ylen ) { +* len = ylen; +* } else { +* len = xlen; +* } +* for ( i = 0; i < len; i++ ) { +* Y[ i ] = X[ i ]; +* } +* } +* +* // ... +* +* static napi_value addon( napi_env env, napi_callback_info info ) { +* // Retrieve add-on callback arguments: +* STDLIB_NAPI_ARGV( env, info, argv, argc, 2 ); +* +* // Convert the first argument to a C type: +* STDLIB_NAPI_ARGV_BOOLEANARRAY( env, X, xlen, argv, 0 ); +* +* // Convert the second argument to a C type: +* STDLIB_NAPI_ARGV_BOOLEANARRAY( env, Y, ylen, argv, 1 ); +* +* // ... +* +* fcn( X, xlen, Y, ylen ); +* } +*/ +#define STDLIB_NAPI_ARGV_BOOLEANARRAY( env, X, len, argv, index ) \ + napi_value __STDLIB_NAPI_ARGV_BOOLEANARRAY_ERR_ ## X; \ + int64_t len; \ + bool *X; \ + stdlib_napi_argv_booleanarray( env, argv[ index ], &X, &len, "invalid argument. " STDLIB_NAPI_ARGV_INDEX2ORDINAL( index ) " argument must be a Uint8Array.", &__STDLIB_NAPI_ARGV_BOOLEANARRAY_ERR_ ## X ); \ + if ( __STDLIB_NAPI_ARGV_BOOLEANARRAY_ERR_ ## X != NULL ) { \ + STDLIB_ASSERT_NAPI_STATUS_OK_RET_NULL( env, napi_throw( env, __STDLIB_NAPI_ARGV_BOOLEANARRAY_ERR_ ## X ), "" ) \ + return NULL; \ + } + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Converts a Node-API value to a boolean array. +*/ +napi_status stdlib_napi_argv_booleanarray( const napi_env env, const napi_value value, bool **data, int64_t *length, const char *message, napi_value *err ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_NAPI_ARGV_BOOLEANARRAY_H diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/lib/browser.js b/lib/node_modules/@stdlib/napi/argv-booleanarray/lib/browser.js new file mode 100644 index 000000000000..fef77f39a5af --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/lib/browser.js @@ -0,0 +1,28 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +var dir = null; + + +// EXPORTS // + +module.exports = dir; diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/lib/index.js b/lib/node_modules/@stdlib/napi/argv-booleanarray/lib/index.js new file mode 100644 index 000000000000..0e87f95ff6e0 --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/lib/index.js @@ -0,0 +1,39 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Absolute file path for the directory containing header files for C APIs. +* +* @module @stdlib/napi/argv-booleanarray +* +* @example +* var headerDir = require( '@stdlib/napi/argv-booleanarray' ); +* +* console.log( headerDir ); +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/lib/main.js b/lib/node_modules/@stdlib/napi/argv-booleanarray/lib/main.js new file mode 100644 index 000000000000..87c1ce69a03c --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/lib/main.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; + + +// MAIN // + +var dir = resolve( __dirname, '..', 'include' ); + + +// EXPORTS // + +module.exports = dir; diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/lib/native.js b/lib/node_modules/@stdlib/napi/argv-booleanarray/lib/native.js new file mode 100644 index 000000000000..c247920b870d --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/lib/native.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var reinterpret = require( '@stdlib/strided/base/reinterpret-boolean' ); +var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Wrapper function exposing the C API to JavaScript. +* +* @private +* @param {BooleanArray} v - input array +* @returns {BooleanArray} input array +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* +* var x = new BooleanArray( 5 ); +* +* wrapper( x ); +*/ +function wrapper( v ) { + if ( isBooleanArray( v ) ) { + v = reinterpret( v, 0 ); + } + addon( v ); + return v; +} + + +// EXPORTS // + +module.exports = wrapper; diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/manifest.json b/lib/node_modules/@stdlib/napi/argv-booleanarray/manifest.json new file mode 100644 index 000000000000..b57bc2e43158 --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/manifest.json @@ -0,0 +1,43 @@ +{ + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/assert/napi/equal-typedarray-types", + "@stdlib/assert/napi/is-typedarray", + "@stdlib/assert/napi/status-ok", + "@stdlib/napi/argv" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/package.json b/lib/node_modules/@stdlib/napi/argv-booleanarray/package.json new file mode 100644 index 000000000000..d7f75448dddc --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/package.json @@ -0,0 +1,71 @@ +{ + "name": "@stdlib/napi/argv-booleanarray", + "version": "0.0.0", + "description": "Convert a Node-API value to a boolean array.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "browser": "./lib/browser.js", + "gypfile": true, + "directories": { + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "napi", + "native", + "addon", + "utilities", + "utils", + "macros", + "bool", + "boolean", + "array" + ], + "__stdlib__": { + "envs": { + "browser": false + } + } +} diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/src/Makefile b/lib/node_modules/@stdlib/napi/argv-booleanarray/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/src/addon.c b/lib/node_modules/@stdlib/napi/argv-booleanarray/src/addon.c new file mode 100644 index 000000000000..15d7a9082f47 --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/src/addon.c @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/napi/argv_booleanarray.h" +#include "stdlib/napi/argv.h" +#include +#include +#include +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + int64_t i; + + STDLIB_NAPI_ARGV( env, info, argv, argc, 1 ) + STDLIB_NAPI_ARGV_BOOLEANARRAY( env, X, len, argv, 0 ) + + for ( i = 0; i < len; i++ ) { + X[ i ] = true; + } + return NULL; +} + +/** +* Initializes a Node-API module. +* +* @param env environment under which the function is invoked +* @param exports exports object +* @return main export +*/ +static napi_value init( napi_env env, napi_value exports ) { + napi_value fcn; + napi_status status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, addon, NULL, &fcn ); + assert( status == napi_ok ); + return fcn; +} + +NAPI_MODULE( NODE_GYP_MODULE_NAME, init ) diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/src/main.c b/lib/node_modules/@stdlib/napi/argv-booleanarray/src/main.c new file mode 100644 index 000000000000..fed507cb46d9 --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/src/main.c @@ -0,0 +1,79 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/napi/argv_booleanarray.h" +#include "stdlib/assert/napi/status_ok.h" +#include "stdlib/assert/napi/is_typedarray.h" +#include "stdlib/assert/napi/equal_typedarray_types.h" +#include +#include +#include + +/** +* Converts a Node-API value to a boolean array. +* +* @param env environment under which the function is invoked +* @param value Node-API value +* @param data pointer for returning a reference to the output array +* @param length pointer for returning the number of array elements +* @param message error message +* @param err pointer for storing a JavaScript error +* @return status code indicating success or failure (returns `napi_ok` if success) +* +* @example +* #include "stdlib/napi/argv_booleanarray.h" +* #include +* #include +* #include +* +* static napi_value addon( napi_env env, napi_callback_info info ) { +* napi_value value; +* +* // ... +* +* bool *X; +* int64_t len; +* napi_value err; +* napi_status status = stdlib_napi_argv_booleanarray( env, value, &X, &len, "Must be a typed array.", &err ); +* assert( status == napi_ok ); +* if ( err != NULL ) { +* assert( napi_throw( env, err ) == napi_ok ); +* return NULL; +* } +* +* // ... +* } +*/ +napi_status stdlib_napi_argv_booleanarray( const napi_env env, const napi_value value, bool **data, int64_t *length, const char *message, napi_value *err ) { + napi_typedarray_type type; + size_t len; + void *X; + + stdlib_assert_napi_value_is_typedarray( env, value, message, err ); + if ( *err != NULL ) { + return napi_ok; + } + STDLIB_ASSERT_NAPI_STATUS_OK_RET_VALUE( env, napi_get_typedarray_info( env, value, &type, &len, &X, NULL, NULL ), "", napi_ok ) + stdlib_assert_napi_equal_typedarray_types( env, type, napi_uint8_array, message, err ); + if ( *err != NULL ) { + return napi_ok; + } + *data = (bool *)X; + *length = (int64_t)len; + return napi_ok; +} diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/test/test.browser.js b/lib/node_modules/@stdlib/napi/argv-booleanarray/test/test.browser.js new file mode 100644 index 000000000000..64de4bf16d9c --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/test/test.browser.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var headerDir = require( './../lib/browser.js' ); + + +// TESTS // + +tape( 'main export is null', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( headerDir, null, 'main export is null' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/test/test.js b/lib/node_modules/@stdlib/napi/argv-booleanarray/test/test.js new file mode 100644 index 000000000000..b07fdee0470e --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/test/test.js @@ -0,0 +1,48 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var headerDir = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a string', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof headerDir, 'string', 'main export is a string' ); + t.end(); +}); + +tape( 'the exported value corresponds to the package directory containing header files', opts, function test( t ) { + var dir = resolve( __dirname, '..', 'include' ); + t.strictEqual( headerDir, dir, 'exports expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/napi/argv-booleanarray/test/test.native.js b/lib/node_modules/@stdlib/napi/argv-booleanarray/test/test.native.js new file mode 100644 index 000000000000..53c98a511bb8 --- /dev/null +++ b/lib/node_modules/@stdlib/napi/argv-booleanarray/test/test.native.js @@ -0,0 +1,95 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var typedarray = require( '@stdlib/array/typed' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-boolean' ); +var filledarray = require( '@stdlib/array/filled' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var addon = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( addon instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof addon, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided an argument which is not a Uint8Array', opts, function test( t ) { + var values; + var i; + + values = [ + '5', + true, + false, + null, + void 0, + [], + {}, + typedarray( 10, 'int32' ), + typedarray( 10, 'float64' ) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided '+values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + addon( value ); + }; + } +}); + +tape( 'the function does not throw an error if provided a BooleanArray', opts, function test( t ) { + var expected; + var values; + var i; + + values = [ + new BooleanArray( 1 ), + new BooleanArray( 2 ), + new BooleanArray( 3 ) + ]; + expected = [ + filledarray( 1, 1, 'uint8' ), + filledarray( 1, 2, 'uint8' ), + filledarray( 1, 3, 'uint8' ) + ]; + for ( i = 0; i < values.length; i++ ) { + addon( values[ i ] ); + t.deepEqual( reinterpret( values[ i ], 0 ), expected[ i ], 'returns expected value when provided an array of length '+values[ i ].length ); + } + t.end(); +});