Print this page
enable v8plus_call to be used in any thread


  12 #include <unordered_map>
  13 #include "v8plus_glue.h"
  14 
  15 /*
  16  * STOP!
  17  *
  18  * Do not #include this header in code that consumes v8+.  This is a private
  19  * implementation header for use by v8+ internal C++ code.  It cannot be
  20  * included from C code and contains nothing usable by consumers.
  21  */
  22 
  23 #define V8PLUS_THROW(_t, _e, _f, _args...) \
  24     v8::ThrowException(v8plus::exception((_t), (_e), (_f), ## _args))
  25 #define V8PLUS_THROW_DEFAULT()          V8PLUS_THROW(NULL, NULL, NULL)
  26 #define V8PLUS_THROW_DECORATED(_e)      V8PLUS_THROW(NULL, (_e), NULL)
  27 
  28 #if NODE_MINOR_VERSION > 7 || NODE_MAJOR_VERSION > 0
  29 #define NODE_MAKECALLBACK_RETURN
  30 #endif
  31 
  32 extern "C" boolean_t v8plus_in_event_thread(void);
  33 extern "C" void v8plus_crossthread_init(void);
  34 
  35 namespace v8plus {
  36 
  37 class ObjectWrap;
  38 
  39 class ObjectWrap : public node::ObjectWrap {
  40 public:
  41         static void init(v8::Handle<v8::Object>);
  42         static v8::Handle<v8::Value> cons(const v8::Arguments &);
  43         static ObjectWrap *objlookup(const void *);
  44         v8::Handle<v8::Value> call(const char *, int, v8::Handle<v8::Value>[]);
  45         void public_Ref(void);
  46         void public_Unref(void);
  47 
  48 private:
  49         static v8::Persistent<v8::Function> _constructor;
  50         static v8plus_method_descr_t *_mtbl;
  51         static v8plus_static_descr_t *_stbl;
  52         static std::unordered_map<void *, ObjectWrap *> _objhash;
  53         void *_c_impl;
  54 


  12 #include <unordered_map>
  13 #include "v8plus_glue.h"
  14 
  15 /*
  16  * STOP!
  17  *
  18  * Do not #include this header in code that consumes v8+.  This is a private
  19  * implementation header for use by v8+ internal C++ code.  It cannot be
  20  * included from C code and contains nothing usable by consumers.
  21  */
  22 
  23 #define V8PLUS_THROW(_t, _e, _f, _args...) \
  24     v8::ThrowException(v8plus::exception((_t), (_e), (_f), ## _args))
  25 #define V8PLUS_THROW_DEFAULT()          V8PLUS_THROW(NULL, NULL, NULL)
  26 #define V8PLUS_THROW_DECORATED(_e)      V8PLUS_THROW(NULL, (_e), NULL)
  27 
  28 #if NODE_MINOR_VERSION > 7 || NODE_MAJOR_VERSION > 0
  29 #define NODE_MAKECALLBACK_RETURN
  30 #endif
  31 



  32 namespace v8plus {
  33 
  34 class ObjectWrap;
  35 
  36 class ObjectWrap : public node::ObjectWrap {
  37 public:
  38         static void init(v8::Handle<v8::Object>);
  39         static v8::Handle<v8::Value> cons(const v8::Arguments &);
  40         static ObjectWrap *objlookup(const void *);
  41         v8::Handle<v8::Value> call(const char *, int, v8::Handle<v8::Value>[]);
  42         void public_Ref(void);
  43         void public_Unref(void);
  44 
  45 private:
  46         static v8::Persistent<v8::Function> _constructor;
  47         static v8plus_method_descr_t *_mtbl;
  48         static v8plus_static_descr_t *_stbl;
  49         static std::unordered_map<void *, ObjectWrap *> _objhash;
  50         void *_c_impl;
  51