Print this page
XXX keith II

Split Close
Expand all
Collapse all
          --- old/./v8plus_glue.h
          +++ new/./v8plus_glue.h
↓ open down ↓ 5 lines elided ↑ open up ↑
   6    6  #define _V8PLUS_GLUE_H
   7    7  
   8    8  #include <stdarg.h>
   9    9  #include <libnvpair.h>
  10   10  #include "v8plus_errno.h"
  11   11  
  12   12  #ifdef  __cplusplus
  13   13  extern "C" {
  14   14  #endif  /* __cplusplus */
  15   15  
       16 +#define __UNUSED        __attribute__((__unused__))
       17 +
  16   18  #define V8PLUS_ARG_F_NOEXTRA    0x01
  17   19  
  18   20  #define V8PLUS_ERRMSG_LEN       512
  19   21  #define V8PLUS_JSF_COOKIE       ".__v8plus_jsfunc_cookie"
  20   22  
  21   23  typedef enum v8plus_type {
  22   24          V8PLUS_TYPE_NONE = 0,           /* N/A */
  23   25          V8PLUS_TYPE_STRING,             /* char * */
  24   26          V8PLUS_TYPE_NUMBER,             /* double */
  25   27          V8PLUS_TYPE_BOOLEAN,            /* boolean_t */
↓ open down ↓ 130 lines elided ↑ open up ↑
 156  158  /*
 157  159   * Call the named JavaScript function in the context of the JS object
 158  160   * represented by the native object.  Calling and return conventions are the
 159  161   * same as for the C interfaces; i.e., the nvlist will be converted into JS
 160  162   * objects and the return value or exception will be in the "res" or "err"
 161  163   * members of the nvlist that is returned, respectively.  If an internal
 162  164   * error occurs, NULL is returned and _v8plus_errno set accordingly.  The
 163  165   * results of calling a method implemented in C via this interface are
 164  166   * undefined.
 165  167   *
 166      - * This can be used in concert with JS code to emit events asynchronously;
 167      - * see the documentation.
      168 + * These methods can be used in concert with JS code to emit events
      169 + * asynchronously; see the documentation.
      170 + *
      171 + * Note: As JavaScript functions must be called from the event loop thread,
      172 + * v8plus_method_call() contains logic to determine whether we are in the
      173 + * correct context or not.  If we are running on some other thread we will
      174 + * queue the request and sleep, waiting for the event loop thread to make the
      175 + * call.  In the simple case, where we are already in the correct thread,
      176 + * we make the call directly.  v8plus_method_call_direct() assumes we are
      177 + * on the correct thread and always makes the call directly.
 168  178   */
 169  179  extern nvlist_t *v8plus_method_call(void *, const char *, const nvlist_t *);
      180 +extern nvlist_t *v8plus_method_call_direct(void *, const char *,
      181 +    const nvlist_t *);
 170  182  
 171  183  /*
 172  184   * These methods are analogous to strerror(3c) and similar functions; they
 173  185   * translate among error names, codes, and default messages.  There is
 174  186   * normally little need for these functions in C methods, as everything
 175  187   * necessary to construct a JavaScript exception is done by v8+, but these
 176  188   * may be useful in the construction of supplementary exception decorations
 177  189   * for debugging purposes.
 178  190   */
 179  191  extern const char *v8plus_strerror(v8plus_errno_t);
↓ open down ↓ 5 lines elided ↑ open up ↑
 185  197   */
 186  198  extern const v8plus_c_ctor_f v8plus_ctor;
 187  199  extern const v8plus_c_dtor_f v8plus_dtor;
 188  200  extern const char *v8plus_js_factory_name;
 189  201  extern const char *v8plus_js_class_name;
 190  202  extern const v8plus_method_descr_t v8plus_methods[];
 191  203  extern const uint_t v8plus_method_count;
 192  204  extern const v8plus_static_descr_t v8plus_static_methods[];
 193  205  extern const uint_t v8plus_static_method_count;
 194  206  
      207 +/*
      208 + * Private methods.
      209 + */
      210 +extern boolean_t v8plus_in_event_thread(void);
      211 +extern void v8plus_crossthread_init(void);
      212 +
 195  213  #ifdef  __cplusplus
 196  214  }
 197  215  #endif  /* __cplusplus */
 198  216  
 199  217  #endif  /* _V8PLUS_GLUE_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX