{"_id":"macro-inferno","_rev":"17-08b7d0510c44c0e5a0c32768d120e9e4","name":"macro-inferno","description":"A header library with various helpers for native node.js addon development.","dist-tags":{"latest":"0.2.3"},"versions":{"0.0.0":{"name":"macro-inferno","version":"0.0.0","description":"A header library with various helpers for native node.js addon development.","keywords":["nodejs","native","addon","c++","macro","helper","util","node-gyp"],"main":"./index.js","author":{"name":"justadudewhohacks"},"license":"ISC","gypfile":true,"dependencies":{"nan":"^2.7.0"},"gitHead":"09650c546345ee914f29b9792777986e75ea79d9","_id":"macro-inferno@0.0.0","_npmVersion":"5.3.0","_nodeVersion":"8.1.1","_npmUser":{"name":"justadudewhohacks","email":"muehler.v@gmail.com"},"dist":{"integrity":"sha512-m9c/3sxnyvwTaEWIjKc1x7oj9tqpg/DGqYyeN1aQQYFI2/MSyLNqkoop/ReIJuom44YTvYM4xHxoh2x0RavhZA==","shasum":"79b52ebb220f76707517f7e680eddd23d85295c0","tarball":"https://registry.npmjs.org/macro-inferno/-/macro-inferno-0.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBLROrAiOOIyJW6axhL50ooSWTm/kBYK1rpTeyt9GcUIAiEA7KjdeQ/mFYx2z0PPss6F1ezHDiI1cgATllAJtDOsi40="}]},"maintainers":[{"name":"justadudewhohacks","email":"muehler.v@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/macro-inferno-0.0.0.tgz_1504966184534_0.29244715441018343"},"directories":{}},"0.0.1":{"name":"macro-inferno","version":"0.0.1","description":"A header library with various helpers for native node.js addon development.","keywords":["nodejs","native","addon","c++","macro","helper","util","node-gyp"],"main":"./index.js","author":{"name":"justadudewhohacks"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/justadudewhohacks/macro-inferno.git"},"dependencies":{"nan":"^2.7.0"},"gitHead":"fb1e1a7da9743545c28d0e6cbcbe9155f9097306","bugs":{"url":"https://github.com/justadudewhohacks/macro-inferno/issues"},"homepage":"https://github.com/justadudewhohacks/macro-inferno#readme","_id":"macro-inferno@0.0.1","_npmVersion":"5.3.0","_nodeVersion":"8.1.1","_npmUser":{"name":"justadudewhohacks","email":"muehler.v@gmail.com"},"dist":{"integrity":"sha512-atfMB8xc/96/a7sLb8PeJGbI4AtBbPWVWpzmEhjDmd5JUuk8X9/+4Z5yXnccQoFrk1GQp7mjWKgVegPphO367A==","shasum":"92aaacbbb66fec46681c6c6d760ebcfa7ac9e016","tarball":"https://registry.npmjs.org/macro-inferno/-/macro-inferno-0.0.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDe9LkgdOscMrQP7O+Onm5zlASymDDD0xW0hsybmMJ7CgIhAMLyDOBUiHjMbsh5fpZm7ZfPL+JCGZcn6DNFvanTOMBx"}]},"maintainers":[{"name":"justadudewhohacks","email":"muehler.v@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/macro-inferno-0.0.1.tgz_1505041313678_0.8952015081886202"},"directories":{}},"0.1.0":{"name":"macro-inferno","version":"0.1.0","description":"A header library with various helpers for native node.js addon development.","keywords":["nodejs","native","addon","c++","macro","helper","util","node-gyp"],"main":"./index.js","author":{"name":"justadudewhohacks"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/justadudewhohacks/macro-inferno.git"},"dependencies":{"nan":"^2.7.0"},"gitHead":"fdff1a019ab0b42785e6d7394b70b1298388f4b5","bugs":{"url":"https://github.com/justadudewhohacks/macro-inferno/issues"},"homepage":"https://github.com/justadudewhohacks/macro-inferno#readme","_id":"macro-inferno@0.1.0","_npmVersion":"5.3.0","_nodeVersion":"8.1.1","_npmUser":{"name":"justadudewhohacks","email":"muehler.v@gmail.com"},"dist":{"integrity":"sha512-74LkWxE0y5/8c0beItxl31yN3yo30zXc3vfaPs/QI69A6sAAJEKO3nE2bqZ/PPdLG+BcBZtQVOHbcQik0o1VZw==","shasum":"440fa57da8564aa3612f51d4a0399effc6075852","tarball":"https://registry.npmjs.org/macro-inferno/-/macro-inferno-0.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICcbU/L+B5p92q6PR/s8nTqYgN63t7eT4oDZgont17I0AiEAyqzsRVbVgrQufKv69xOw85YCHnR2tZW6gBc3hRCzFF0="}]},"maintainers":[{"name":"justadudewhohacks","email":"muehler.v@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/macro-inferno-0.1.0.tgz_1505069623810_0.05142228282056749"},"directories":{}},"0.1.1":{"name":"macro-inferno","version":"0.1.1","description":"A header library with various helpers for native node.js addon development.","keywords":["nodejs","native","addon","c++","macro","helper","util","node-gyp"],"main":"./index.js","author":{"name":"justadudewhohacks"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/justadudewhohacks/macro-inferno.git"},"dependencies":{"nan":"^2.7.0"},"gitHead":"62fc17b2fab6dcd029d6850ca1bbfc33cbaef92d","bugs":{"url":"https://github.com/justadudewhohacks/macro-inferno/issues"},"homepage":"https://github.com/justadudewhohacks/macro-inferno#readme","_id":"macro-inferno@0.1.1","_npmVersion":"5.3.0","_nodeVersion":"8.1.1","_npmUser":{"name":"justadudewhohacks","email":"muehler.v@gmail.com"},"dist":{"integrity":"sha512-dWCUxFhrKixnxL7bVOMekjzyotUEU069BptlnQTGfTtJycNBu3nUcFpIGpvA3CBnlIQHHAkrx9b5rBEakXUR3w==","shasum":"19f5adc3a2cd002500f526eb6ca81d0065bfc4f4","tarball":"https://registry.npmjs.org/macro-inferno/-/macro-inferno-0.1.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAUPY9M+73R24rUiOC3j4CFXojQC/zFUKNKJFKAlkedpAiAhE437gHQ5pWqctrmgvXHC952Fu8EAhDM7qXJlVzqPcw=="}]},"maintainers":[{"name":"justadudewhohacks","email":"muehler.v@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/macro-inferno-0.1.1.tgz_1505157940141_0.29812880838289857"},"directories":{}},"0.2.0":{"name":"macro-inferno","version":"0.2.0","description":"A header library with various helpers for native node.js addon development.","keywords":["nodejs","native","addon","c++","macro","helper","util","node-gyp"],"main":"./index.js","author":{"name":"justadudewhohacks"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/justadudewhohacks/macro-inferno.git"},"dependencies":{"nan":"^2.7.0"},"gitHead":"1cb9b9295f3ea29f06e065cb08a6bbcdae82d6b1","bugs":{"url":"https://github.com/justadudewhohacks/macro-inferno/issues"},"homepage":"https://github.com/justadudewhohacks/macro-inferno#readme","_id":"macro-inferno@0.2.0","_npmVersion":"5.3.0","_nodeVersion":"8.1.1","_npmUser":{"name":"justadudewhohacks","email":"muehler.v@gmail.com"},"dist":{"integrity":"sha512-dHLv1Ut77Vk5S2G15ulu5VfG07puHtnag0x2oJzumLsdw9hQBc7/v2F5fbI/OiZF3WAPDflgItBbaWG3NazLZw==","shasum":"86f83f52bc70d0e576c695e1100d9e71c0f8772d","tarball":"https://registry.npmjs.org/macro-inferno/-/macro-inferno-0.2.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCO6L+38ze861LFTS7j1zbz3E1pmzFq0spPRYVIUlEBJAIgTOXA1uuJdAmNRJwloiKD2ZCVC9KRFCaRtWF4EOMceqw="}]},"maintainers":[{"name":"justadudewhohacks","email":"muehler.v@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/macro-inferno-0.2.0.tgz_1505197713417_0.37079676799476147"},"directories":{}},"0.2.1":{"name":"macro-inferno","version":"0.2.1","description":"A header library with various helpers for native node.js addon development.","keywords":["nodejs","native","addon","c++","macro","helper","util","node-gyp"],"main":"./index.js","author":{"name":"justadudewhohacks"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/justadudewhohacks/macro-inferno.git"},"dependencies":{"nan":"^2.7.0"},"gitHead":"66e73e09bf8d28cd5143d6bfc6b66c4c282730b6","bugs":{"url":"https://github.com/justadudewhohacks/macro-inferno/issues"},"homepage":"https://github.com/justadudewhohacks/macro-inferno#readme","_id":"macro-inferno@0.2.1","_npmVersion":"5.3.0","_nodeVersion":"8.1.1","_npmUser":{"name":"justadudewhohacks","email":"muehler.v@gmail.com"},"dist":{"integrity":"sha512-5fnnX5OJSJq4PFMKiiv+lKJqbxHHQXfvTLbRjV3fHIr86ELpljOzVEjEmsY2VI3R2RwWLUM0NHrygpexdH4S4g==","shasum":"20de3ae8e9ac76b3fc652cbf6c25f325a9ba2e22","tarball":"https://registry.npmjs.org/macro-inferno/-/macro-inferno-0.2.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHvIXkexXhbUbaFvcisFzJckj8sJ6Y9wKnNTTWyW3uqpAiA8+543aU9jgyzHf1AW9wwKUEIB9zGpwMsZ8+zfem314g=="}]},"maintainers":[{"name":"justadudewhohacks","email":"muehler.v@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/macro-inferno-0.2.1.tgz_1505209856634_0.3468864751048386"},"directories":{}},"0.2.2":{"name":"macro-inferno","version":"0.2.2","description":"A header library with various helpers for native node.js addon development.","keywords":["nodejs","native","addon","c++","macro","helper","util","node-gyp"],"main":"./index.js","author":{"name":"justadudewhohacks"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/justadudewhohacks/macro-inferno.git"},"dependencies":{"nan":"^2.7.0"},"gitHead":"dc328c4d4c81b0f8ed0d09c96d5bc55a7d7460af","bugs":{"url":"https://github.com/justadudewhohacks/macro-inferno/issues"},"homepage":"https://github.com/justadudewhohacks/macro-inferno#readme","_id":"macro-inferno@0.2.2","_npmVersion":"5.6.0","_nodeVersion":"10.2.1","_npmUser":{"name":"justadudewhohacks","email":"muehler.v@gmail.com"},"dist":{"integrity":"sha512-ouyDKrSzOdZVm7ViR/W9+qRPtrZ2Ml3QD4NNekXrMbAjN32xD1C/lRYl3t0Bf/sG5elNnBEzVfLr93HNzheSQw==","shasum":"57dd960f9fa3e117ef9f46dbf0629d08d1d04c5f","tarball":"https://registry.npmjs.org/macro-inferno/-/macro-inferno-0.2.2.tgz","fileCount":9,"unpackedSize":38109,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbu1lQCRA9TVsSAnZWagAAwdUP/0G5GxFJYMIQyLF83cEV\nUPZUOJ+pVJ3lI0PgPFsTv5AleFOmyekj+Uv1bLTCf60Treb9a+BOClmdd1/Y\nHfE3huf1yJehVFjXSk0C1xCS30AlZivGlUu0gQWJypkKTUfc9vjn6eQNR8bg\nUPEOeXGBbxbW6pw2ce8LyGAnWWORQnNkb6+CJ3H4Rezs69iRRgZW/MWy7e1v\n11I8nE3BZrU2wvUcJg1rbP+I02CgUSWUcf3luU+0MbRIGpUht1/Gqmjs7R9j\nBcw5ISLzgNHs9DxPVhp+bL6OhD2BmPEo0CvJs8UfACuVfnUOILNsOtlxc8FK\nQARKcMQStarP3YGm9nYkOQgn01dx2FgmXpOXhT2eQqUbFo6ITUHJo8P4O95y\nAIjzXXgYI5c+AhFdtbobJjBQ5uyGWEK0EqqX+2nZt2c7Z2clmM+fUcNVZGiH\n2KQN9CqFyItninC707ianXJYm1rGWz0Rnj6PZj0NUrCAnUbD/F2WHdcqwx8d\nurwJZDudER5j7TI4a/JfrbwnlcwV9HNLbJTh76PGZalPKMe/wmTPFejacwcN\nAk/r3WtCRWHpanz67+/uuA4pDoZaf+PM9DNOcTtx7Le0sO68rEAoPIzzo4sk\nOvFf/YH2pF2BVYxMJuQvhepRQp80srBk7gy3iDbyIE108Ub7JHp9SyySnD7q\nyTiY\r\n=SYJ2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFFmYmGTpJ/g/Ge7P9BsM6G0lfsGopbk6OM/9PUqmpxVAiEAlSbUnIzIROksXHCbKdD6E+8GKSJE9eJiVWVDLZhWgUw="}]},"maintainers":[{"name":"justadudewhohacks","email":"muehler.v@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/macro-inferno_0.2.2_1539004752476_0.24150102826094777"},"_hasShrinkwrap":false},"0.2.3":{"name":"macro-inferno","version":"0.2.3","description":"A header library with various helpers for native node.js addon development.","keywords":["nodejs","native","addon","c++","macro","helper","util","node-gyp"],"main":"./index.js","author":{"name":"justadudewhohacks"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/justadudewhohacks/macro-inferno.git"},"dependencies":{"nan":"^2.12.1"},"gitHead":"6dcf0885996ae6f792c8a430cc2a5408a0c3b019","bugs":{"url":"https://github.com/justadudewhohacks/macro-inferno/issues"},"homepage":"https://github.com/justadudewhohacks/macro-inferno#readme","_id":"macro-inferno@0.2.3","_npmVersion":"6.5.0-next.0","_nodeVersion":"11.6.0","_npmUser":{"name":"justadudewhohacks","email":"muehler.v@gmail.com"},"dist":{"integrity":"sha512-CVcgZNONoQcLrhqoMEI7yRqFtEZEu0lelbVvNkAnC4RSkiQinzVFUEeTUVj1ZC7XnyP1L9Bw3EbzfudQJxWV0g==","shasum":"206e9698d006d9a4421cdfca240ef93c2cafc174","tarball":"https://registry.npmjs.org/macro-inferno/-/macro-inferno-0.2.3.tgz","fileCount":8,"unpackedSize":28886,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcMdmeCRA9TVsSAnZWagAAP/oP/id6pCCcERbY/XkxDhY3\nVKzEq3A/t6tPe4/02bLfltpak4po6ERzt8XnXlm0lx1vd8anl1+jt9lr/wpK\nQoW7J70jKAwzAH5e2s8KGdTNZNi8k8TDidbC9Zte5d2plWTbhXQ7Yn+plIwN\no2GmhPNVPCKGpnJF3w6mGYLSpK9HEWZ643ea4w7QLPYNhQGzovnaqpNB3uZ0\nTgNFu/o9Wi/0fnZC1lhOMwYMGdLQzgc40x9vEYXFAmMax5vUO1+3vh2emggv\nkCIMvX/ta6YnG5shIAFo8qNG56gD5KJkNjZDWykQpF1udZqCfyC88qnNwhF1\ntaKgiLkGe5lSSSCWixhM9NADJaMeMPtKSkiPyK7nIAN/mLE1C673Pot95NUA\nkPkKY/90qyhIBU+rc9ZswnuXtlEhTLyMCqocyyXbT7M+hjtdLHBv15vS273F\nnSIuU/gU5to/+EjKMJ0quWaILEuIZngkgpNUj4SWHhFZ/GtbMHktzD2jQtsv\n0nOkETni0tIkUVhbR0Yp0n+NrqXC9kvVAt2RtSlzu/M6Mgrltq5TLaFjQ+NL\npHCykqDTSRx5xpoeTPQjYFU9IznZJIPbpHiNYSjI4yCg0WgKGKrkJ7ZNRp3S\nr1O2fasxP/7UTYgtJo5VeDYGiI0E6aseLltOqQz3HvOEKD2Nts4L1hzz+JDD\nsx2y\r\n=xNx+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGCLtgmCD7bZn0NJqcwtTJDci1JlS6ZczWKDL+niUujQAiEAzH4oylCx0YQro7pJC/yMpt9gaXYFBwFuSzItuofTUMk="}]},"maintainers":[{"name":"justadudewhohacks","email":"muehler.v@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/macro-inferno_0.2.3_1546770846207_0.25377939738096056"},"_hasShrinkwrap":false}},"readme":"macro-inferno\r\n=============\r\n\r\n**A header library with various helpers for native node.js addon development built on top of NAN. Write one-liners for typechecking and converting arguments, unpacking and packing v8::Arrays, unwrapping and wrapping objects and property getters.**\r\n\r\nCollapse complex statements into one-liners and avoid writing the same stuff over and over again in each function that your module exposes. Converting JS objects, wrapping and unwrapping instances, packing and unpacking arrays, type checking... , all this can be done using macro-inferno macros, which avoids repetitive and unreadable code and saves you a lot of time that you would spend copy and pasting.\r\n\r\n## Why? - Write one-liners instead of massive statements\r\n### Typechecked conversions:\r\nIf you care about displaying meaningful error messages to the user of your API, you may end up writing code like this ...\r\n``` c++\r\nNAN_METHOD(aClass::aMethodName) {\r\n  // make sure argument 0 is a string\r\n  if (info.Length() < 1 || !info[0]->IsString()) {\r\n    return Nan::ThrowError(Nan::New(\r\n      \"aMethodName - expected arg 0 to be of type: STRING\"\r\n    ).ToLocalChecked());\r\n  }\r\n  std::string arg0 = std::string(*Nan::Utf8String(info[0]->ToString()));\r\n\r\n  // make sure argument 1 is a number if it was passed\r\n  // otherwise assign a default value\r\n  double arg1;\r\n  if (info.Length() > 1) {\r\n    if (!info[1]->IsNumber()) {\r\n      return Nan::ThrowError(Nan::New(\r\n        \"aMethodName - expected arg 0 to be of type: NUMBER\"\r\n      ).ToLocalChecked());\r\n    }\r\n    arg1 = info[1]->NumberValue();\r\n  } else {\r\n    arg1 = 0.1;\r\n  }\r\n}\r\n```\r\n\r\nSimply write 3 lines of code instead:\r\n``` c++\r\nNAN_METHOD(aClass::aMethodName) {\r\n  FF_METHOD_CONTEXT(\"aMethodName\");\r\n  FF_ARG_STRING(0, std::string arg0);\r\n  FF_ARG_NUMBER_IFDEF(1, double arg1, 0.1);\r\n}\r\n```\r\n\r\n### Typechecked conversion of arrays:\r\nUnpacking arrays to std::vector ...\r\n``` c++\r\nNAN_METHOD(aClass::aMethodName) {\r\n  if (info.Length() < 1 || !info[0]->IsArray) {\r\n    return Nan::ThrowError(Nan::New(\r\n      \"aMethodName - expected arg 0 to be of type: ARRAY\"\r\n    ).ToLocalChecked());\r\n  }\r\n  v8::Local<v8::Array> arr = v8::Local<v8::Array>::Cast(info[0]);\r\n\r\n  std::vector<int> intVec;\r\n  for (int i = 0; i < arr->Length(); i++) {\r\n    v8::Local<v8::Value> val = arr->Get(i);\r\n    if (!val->IsInt32()) {\r\n      return Nan::ThrowError(Nan::New(\r\n        \"expected array element to be of type: INT, at index: \" + std::to_string(i)\r\n      ).ToLocalChecked());\r\n    }\r\n    vec.push_back(info[0]->Int32Value());\r\n  }\r\n}\r\n```\r\n\r\nSimply write:\r\n``` c++\r\nNAN_METHOD(aClass::aMethodName) {\r\n  FF_METHOD_CONTEXT(\"aMethodName\");\r\n  FF_ARG_UNPACK_INT_ARRAY(0, intVec);\r\n}\r\n```\r\n\r\n## Documentation\r\n\r\n### Shortcuts\r\n``` c++\r\nFF_OBJ obj = FF_NEW_OBJ();\r\nv8::Local<v8::Object> obj = Nan::New<v8::Object>();\r\n\r\nFF_ARR arr = FF_NEW_ARRAY(10);\r\nv8::Local<v8::Array> arr = Nan::New<v8::Array>(10);\r\n\r\nFF_VAL val;\r\nv8::Local<v8::Value> val;\r\n\r\nstd::string str = FF_NEW_STRING(\"foo\");\r\nstd::string str = Nan::New(\"foo\").ToLocalChecked();\r\n\r\nFF_RETURN(val);\r\ninfo.GetReturnValue().Set(val);\r\n\r\nbool hasProperty = FF_HAS(obj, \"aProperty\");\r\nbool hasProperty = Nan::HasOwnProperty(obj, Nan::New(\"aProperty\").ToLocalChecked()).FromJust();\r\n```\r\n\r\n### Convert and typecheck native types\r\n\r\n#### Required arguments:\r\nCast argument n to native type or throw a meaningful type error.\r\n\r\n``` c++\r\n/* FF_ARG_type(arg number, variable declaration) */\r\n\r\nFF_ARG_BOOL(0, bool aBool);\r\nFF_ARG_NUMBER(1, double aNumber);\r\nFF_ARG_UINT(2, uint anUint);\r\nFF_ARG_INT(3, int anInt);\r\nFF_ARG_STRING(4, std::string aString);\r\nFF_ARG_ARRAY(5, FF_ARR anArray);\r\nFF_ARG_OBJ(6, FF_OBJ anObject);\r\n```\r\n\r\nFor example:\r\n``` c++\r\nNAN_METHOD(aClass::aMethodName) {\r\n  FF_METHOD_CONTEXT(\"aMethodName\");\r\n  FF_ARG_NUMBER(0, double arg);\r\n}\r\n```\r\n\r\ninvoked like this:\r\n``` javascript\r\n// will not throw\r\nmodule.aMethodName(0.1);\r\nmodule.aMethodName(1);\r\nmodule.aMethodName(-1);\r\n\r\n// will throw: aMethodName - expected arg 0 to be of type: NUMBER\r\nmodule.aMethodName(undefined);\r\nmodule.aMethodName(null);\r\nmodule.aMethodName(true);\r\nmodule.aMethodName('aString');\r\nmodule.aMethodName([]);\r\nmodule.aMethodName({});\r\n```\r\n\r\n#### Optional arguments:\r\nIf defined, cast argument n to native type or throw a meaningful type error, else initialize with default value.\r\n\r\n``` c++\r\n/* FF_ARG_type(arg number, variable declaration, default value) */\r\n\r\nFF_ARG_BOOL_IFDEF(0, bool aBool, true);\r\nFF_ARG_NUMBER_IFDEF(1, double aNumber, 0.1);\r\nFF_ARG_UINT_IFDEF(2, uint anUint, 1);\r\nFF_ARG_INT_IFDEF(3, int anInt, -1);\r\nFF_ARG_STRING_IFDEF(4, std::string aString, \"foo\");\r\nFF_ARG_ARRAY_IFDEF(5, FF_ARR anArray, FF_NEW_ARRAY(0));\r\nFF_ARG_OBJ_IFDEF(6, FF_OBJ anObject, FF_NEW_OBJECT())\r\n```\r\n\r\nFor example:\r\n``` c++\r\nNAN_METHOD(aClass::aMethodName) {\r\n  FF_METHOD_CONTEXT(\"aMethodName\");\r\n  FF_ARG_NUMBER(0, double arg0);\r\n  FF_ARG_NUMBER_IFDEF(1, double arg1, 0.1);\r\n}\r\n```\r\n\r\ninvoked like this:\r\n``` javascript\r\n// will not throw\r\nmodule.aMethodName(0.1, 1);\r\nmodule.aMethodName(0.1, -1);\r\nmodule.aMethodName(0.1, 0.1);\r\n\r\n// will not throw and set arg 1 to the default value\r\nmodule.aMethodName(0.1);\r\n\r\n// will throw: aMethodName - expected arg 1 to be of type: NUMBER\r\nmodule.aMethodName(0.1, undefined);\r\nmodule.aMethodName(0.1, null);\r\nmodule.aMethodName(0.1, true);\r\nmodule.aMethodName(0.1, 'aString');\r\nmodule.aMethodName(0.1, []);\r\nmodule.aMethodName(0.1, {});\r\n```\r\n\r\n### Typechecked conversion between arrays and std::vectors\r\n``` c++\r\n// unpack v8::Local<v8::Array> to std::vector<double> vec\r\nFF_ARR someArray = ...\r\nFF_UNPACK_NUMBER_ARRAY(vec, someArray);\r\n\r\n// convert numberVec to a v8::Local<v8::Array>\r\nstd::vector<double> numberVec = ...\r\nFF_PACK_ARRAY(theNumberArray, numberVec);\r\n\r\n// convert stringVec to a v8::Local<v8::Array>\r\nstd::vector<std::string> stringVec = ...\r\nFF_PACK_STRING_ARRAY(theStringArray, stringVec);\r\n```","maintainers":[{"name":"justadudewhohacks","email":"muehler.v@gmail.com"}],"time":{"modified":"2022-05-08T16:02:54.786Z","created":"2017-09-09T14:09:45.416Z","0.0.0":"2017-09-09T14:09:45.416Z","0.0.1":"2017-09-10T11:01:54.592Z","0.1.0":"2017-09-10T18:53:44.680Z","0.1.1":"2017-09-11T19:25:41.176Z","0.2.0":"2017-09-12T06:28:34.458Z","0.2.1":"2017-09-12T09:50:57.665Z","0.2.2":"2018-10-08T13:19:12.596Z","0.2.3":"2019-01-06T10:34:06.377Z"},"keywords":["nodejs","native","addon","c++","macro","helper","util","node-gyp"],"author":{"name":"justadudewhohacks"},"license":"ISC","readmeFilename":"README.md","homepage":"https://github.com/justadudewhohacks/macro-inferno#readme","repository":{"type":"git","url":"git+https://github.com/justadudewhohacks/macro-inferno.git"},"bugs":{"url":"https://github.com/justadudewhohacks/macro-inferno/issues"},"users":{"donryan":true,"mattlnl":true,"stjalano":true,"jphils2":true,"jcoltier":true,"chassefranc":true,"chavezt":true,"cooperantonio":true,"lukemcdaniels79":true}}