Skip to content

Node.js native module programming

bellbind edited this page Oct 13, 2013 · 11 revisions

Separate application algorithm codes and Node.js plug codes

  • Application codes should be removed any node.js and v8 related definitions.
    • it can use another languages for application code. e.g. C, Objective-C
  • Node.js plug codes are almost for convert arguments and result.

v8 Handles

3 Handle (smart pointer) type exists

  • Handle: as smart pointer of RAII (release the holding resource by its destructor)
  • Local: automatically managed by HandleScope
  • Persistent: explicitly call Dispose() to release

HandleScope instance is stacked memory manager for Local handle.

  • return scope.Close(localHandle): unmanage a localHandle object on the scope, then return localHandle as Handle
Clone this wiki locally