Print this page
XXX doco cleanup
XXX first cut of crosscall

Split Close
Expand all
Collapse all
          --- old/./README.md
          +++ new/./README.md
↓ open down ↓ 212 lines elided ↑ open up ↑
 213  213  any memory (i.e., `op` is not a pointer to dynamically allocated memory).
 214  214  
 215  215  ### nvlist_t *v8plus_c_method_f(void *op, const nvlist_t *ap)
 216  216  
 217  217  When the JavaScript method is called in the context of your object, the
 218  218  corresponding C function is invoked.  `op` is the C object associated with
 219  219  the JavaScript object, and `ap` is the encoded list of arguments to the
 220  220  function.  Return an encoded object with a `res` member, or use one of the
 221  221  error/exception patterns.
 222  222  
 223      -### nvlist_t *v8plus_c_static_method_f(nvlist_t *ap)
      223 +### nvlist_t *v8plus_c_static_method_f(const nvlist_t *ap)
 224  224  
 225  225  In addition to methods on the native objects returned by your constructor,
 226  226  you can also provide a set of functions on the native binding object itself.
 227  227  This may be useful for providing bindings to libraries for which no object
 228  228  representation makes sense, or that have functions that operate outside the
 229  229  context of any particular object.  Your arguments are once again encoded in
 230  230  `ap`, and your return values are an object containing `res` or an error.
 231  231  
 232  232  ### Argument Handling
 233  233  
↓ open down ↓ 383 lines elided ↑ open up ↑
 617  617                  v8plus_defer(op, cp, async_worker, async_completion);
 618  618  
 619  619                  return (v8plus_void());
 620  620          }
 621  621  
 622  622  This mechanism uses `uv_queue_work()` and as such will tie up one of the
 623  623  worker threads in the pool for as long as `async_worker` is running.
 624  624  
 625  625  The other asynchronous mechanism is the Node.js `EventEmitter` model.  This
 626  626  model requires some assistance from JavaScript code, because v8+ native
 627      -objects no not inherit from `EventEmitter`.  To make this work, you will
      627 +objects do not inherit from `EventEmitter`.  To make this work, you will
 628  628  need to create a JavaScript object (the object your consumers actually use)
 629  629  that inherits from `EventEmitter`, hang your native object off this object,
 630  630  and populate the native object with an appropriate method that will cause
 631  631  the JavaScript object to emit events when the native object invokes that
 632  632  method.  A simple example might look like this:
 633  633  
 634  634          var util = require('util');
 635  635          var binding = require('./native_binding');
 636  636          var events = require('events');
 637  637  
↓ open down ↓ 215 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX