addon-tools-raub
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -66,2 +66,3 @@ 'use strict'; | ||
module.exports = { | ||
@@ -68,0 +69,0 @@ |
{ | ||
"author": "Luis Blanco <luisblanco1337@gmail.com>", | ||
"name": "addon-tools-raub", | ||
"version": "0.1.8", | ||
"description": "A set of extra tools for Node.js addons", | ||
"version": "0.1.9", | ||
"description": "Helpers for Node.js addons and dependency packages", | ||
"license": "MIT", | ||
@@ -28,3 +28,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "https://github.com/node-3d/node-addon-tools.git" | ||
"url": "https://github.com/node-3d/addon-tools-raub.git" | ||
}, | ||
@@ -31,0 +31,0 @@ "dependencies": { |
132
README.md
# Addon Tools | ||
This is a part of [Node3D](https://github.com/node-3d) project. | ||
## Synopsis | ||
This is a set of helpers for simplification and standardization of addons and | ||
dependency packages. | ||
Helpers for Node.js addons and dependency packages: | ||
* EventEmitter C++ implementation. | ||
* Contains helpers of following types: GYP, C++, JS, BAT (Windows). | ||
* Platforms: win x32/x64, linux x32/x64, mac x64. | ||
* Useful links: [V8 Ref](https://v8docs.nodesource.com/node-0.8/d2/dc3/namespacev8.html), | ||
* `EventEmitter` C++ implementation. | ||
* C++ macros and shortcuts. | ||
* Crossplatform commands for GYP: `cp`, `rm`, `mkdir`. | ||
* Regarded platforms: win x32/x64, linux x32/x64, mac x64. | ||
Useful links: [V8 Ref](https://v8docs.nodesource.com/node-0.8/d2/dc3/namespacev8.html), | ||
[Nan Docs](https://github.com/nodejs/nan#api), | ||
@@ -32,3 +35,3 @@ [GYP Docs](https://gyp.gsrc.io/docs/UserDocumentation.md). | ||
[Cross-platform commands](#cross-platform-commands) | ||
[Crossplatform commands](#crossplatform-commands) | ||
@@ -42,5 +45,6 @@ [Class EventEmitter](#class-eventemitter) | ||
### binding.gyp | ||
* Cross-platform file/folder removers/creators are present, you can put them into variables for later use. | ||
* Crossplatform commands can be put into the variables for later use. | ||
@@ -64,4 +68,8 @@ ``` | ||
* Intermediate files can be removed in a separate build-step with `<(rm)`. | ||
* Intermediate build-files can be removed in a separate build-step with `<(rm)`. | ||
<details> | ||
<summary>Show Snippet</summary> | ||
``` | ||
@@ -85,3 +93,5 @@ [ 'OS=="linux"', { 'action' : [ | ||
</details> | ||
### Binary dependencies | ||
@@ -108,7 +118,12 @@ | ||
<details> | ||
<summary>Show Snippet</summary> | ||
``` | ||
{ | ||
'variables': { | ||
'rm' : '<!(node -e "require(\'addon-tools-raub\').rm()")', | ||
'rem' : '<!(node -e "require(\'.\').rem()")', | ||
'rm' : '<!(node -e "require(\'addon-tools-raub\').rm()")', | ||
'rem' : '<!(node -e "require(\'.\').rem()")', | ||
'XALL%': 'false', | ||
}, | ||
@@ -119,3 +134,3 @@ 'targets': [ | ||
'type' : 'none', | ||
'actions' : [ | ||
'conditions' : [['XALL=="false"', {'actions': [ | ||
{ | ||
@@ -127,3 +142,3 @@ 'action_name' : 'Unnecessary binaries removed.', | ||
} | ||
], | ||
]}]], | ||
} | ||
@@ -135,4 +150,11 @@ ] | ||
Notice the `XALL` variable here. If the package is installed with `npm i`, then | ||
quite expectedly all but the required arch directories are removed. But with | ||
`npm i --XALL` you can keep all the binaries. It might be useful when debugging | ||
multiple archs and switching Node.js versions with | ||
[NVM](https://github.com/creationix/nvm). | ||
</details> | ||
### Compiled addon | ||
@@ -143,2 +165,6 @@ | ||
<details> | ||
<summary>Show Snippet</summary> | ||
``` | ||
@@ -169,2 +195,4 @@ { | ||
</details> | ||
Here `MY_ADDON` should be replaced by any name you like. Then require like | ||
@@ -328,3 +356,3 @@ this: | ||
``` | ||
#include <addon-tools.hpp> | ||
#include <addon-tools.hpp> // or event-emitter.hpp | ||
``` | ||
@@ -341,7 +369,9 @@ | ||
In the file, currently there are following helpers: | ||
Currently, there are following helpers in **addon-tools.hpp**: | ||
#### Handle scope | ||
<details> | ||
<summary>Handle scope</summary> | ||
* `NAN_HS` - creates a HandleScope. Also, you do not need them within `NAN_METHOD`, | ||
@@ -360,11 +390,19 @@ `NAN_SETTER`, and `NAN_GETTER`, as it is stated in | ||
</details> | ||
#### Method return | ||
<details> | ||
<summary>Method return</summary> | ||
* `RET_VALUE(VAL)` - set method return value | ||
* `RET_UNDEFINED` - set method return value as undefined | ||
</details> | ||
#### Shortcut types | ||
<details> | ||
<summary>Shortcut types</summary> | ||
* `V8_VAR_VAL` = `v8::Local<v8::Value>` | ||
@@ -382,5 +420,9 @@ * `V8_VAR_OBJ` = `v8::Local<v8::Object>` | ||
</details> | ||
#### New JS value | ||
<details> | ||
<summary>New JS value</summary> | ||
* `JS_STR(...)` - create a string value | ||
@@ -400,5 +442,9 @@ * `JS_UTF8(...)` - same as JS_STR | ||
</details> | ||
#### Method check | ||
<details> | ||
<summary>Method check</summary> | ||
These checks throw JS TypeError if not passed. Here `T` is always used as a typename | ||
@@ -413,3 +459,3 @@ in error messages. `C` is | ||
* `CHECK_REQ_ARG(I, C, T)` - check if argument `I` is approved by `C` check. | ||
* `CHECK_LET_ARG(I, C, T) - check if argument `I` is approved by `C` check or empty. | ||
* `CHECK_LET_ARG(I, C, T)` - check if argument `I` is approved by `C` check or empty. | ||
* `CTOR_CHECK(T)` - check if method is called as a constructor | ||
@@ -419,5 +465,9 @@ * `SETTER_CHECK(C, T)` - check if setter `value` is approved by `C` check. | ||
</details> | ||
#### Method arguments | ||
<details> | ||
<summary>Method arguments</summary> | ||
Two types of argument retrieval are supported: `REQ_` and `LET_`. The difference | ||
@@ -464,5 +514,9 @@ is that `LET_` allows the argument to be empty, using some zero-default in this case. | ||
</details> | ||
#### Set properties | ||
<details> | ||
<summary>Set properties</summary> | ||
Set-helpers for string and numeric keys. String keys are converted to JS strings | ||
@@ -474,5 +528,9 @@ automatically. | ||
</details> | ||
#### Set object accessors | ||
<details> | ||
<summary>Set object accessors</summary> | ||
Simplified accessor assignment, adds accessors of NAME for OBJ. Read accessor is | ||
@@ -495,5 +553,9 @@ assumed to have the name `NAME+'Getter'` and write accessor is `NAME+'Setter'`. | ||
</details> | ||
#### Setter argument | ||
<details> | ||
<summary>Setter argument</summary> | ||
Useful addition to NAN_SETTER macro. Works similar to method arguments. But there | ||
@@ -522,5 +584,9 @@ is always only one required argument stored in `v`. | ||
</details> | ||
#### Data retrieval | ||
<details> | ||
<summary>Data retrieval</summary> | ||
* `T *getArrayData(value, num = NULL)` - extracts TypedArray data of any type from | ||
@@ -536,3 +602,5 @@ the given JS value. Does not accept Array, checked with `IsArrayBufferView()`. | ||
</details> | ||
--- | ||
@@ -566,3 +634,3 @@ | ||
## Cross-platform commands | ||
## Crossplatform commands | ||
@@ -599,3 +667,3 @@ Because of the differences between Windows and Unix command shells, often a whole | ||
Disregard `del` vs `rd` aspect of Windows command line. Now the same command can | ||
Disregard `del` and `rd` on Windows command line. Now the same command can | ||
be used on all platforms to remove single and multiple files and directories. | ||
@@ -654,3 +722,3 @@ | ||
* `virtual void _destroy()` - destroys the object, i.e. deactivates it and frees | ||
resources, also emitting a `'destroy'` event. This is what also called inside | ||
resources. This is what also called inside | ||
`~EventEmitter()`, but only the first call is effective anyway. | ||
@@ -667,3 +735,2 @@ | ||
Though it is the same directory for all the **addon-tools**. | ||
Then include the **event-emitter.hpp**, it also includes **addon-tools.hpp**. | ||
@@ -682,3 +749,6 @@ Inherit from `EventEmitter`, it already inherits from `Nan::ObjectWrap`: | ||
<details> | ||
<summary>V8 Inheritance</summary> | ||
Now that everything is in place, consider providing **V8** with JS inheritance info: | ||
@@ -708,1 +778,3 @@ | ||
``` | ||
</details> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53891
753