mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
async-wrap: expose async-wrap as binding
Expose basic hooks for AsyncWrap via the async_wrap binding. Right now only the PROVIDER types are exposed. This is a preliminary step before more functionality is added. PR-URL: https://github.com/joyent/node/pull/8110 Signed-off-by: Trevor Norris <trev.norris@gmail.com> Reviewed-by: Fedor Indutny <fedor@indutny.com> Reviewed-by: Alexis Campailla <alexis@janeasystems.com> Reviewed-by: Julien Gilli <julien.gilli@joyent.com>
This commit is contained in:
committed by
Bert Belder
parent
f39b48c26d
commit
afe27e34cf
@@ -28,8 +28,12 @@
|
||||
|
||||
#include "v8.h"
|
||||
|
||||
using v8::Context;
|
||||
using v8::Function;
|
||||
using v8::Handle;
|
||||
using v8::HandleScope;
|
||||
using v8::Integer;
|
||||
using v8::Isolate;
|
||||
using v8::Local;
|
||||
using v8::Object;
|
||||
using v8::TryCatch;
|
||||
@@ -37,6 +41,23 @@ using v8::Value;
|
||||
|
||||
namespace node {
|
||||
|
||||
static void Initialize(Handle<Object> target,
|
||||
Handle<Value> unused,
|
||||
Handle<Context> context) {
|
||||
Environment* env = Environment::GetCurrent(context);
|
||||
Isolate* isolate = env->isolate();
|
||||
HandleScope scope(isolate);
|
||||
|
||||
Local<Object> async_providers = Object::New(isolate);
|
||||
#define V(PROVIDER) \
|
||||
async_providers->Set(FIXED_ONE_BYTE_STRING(isolate, #PROVIDER), \
|
||||
Integer::New(isolate, AsyncWrap::PROVIDER_ ## PROVIDER));
|
||||
NODE_ASYNC_PROVIDER_TYPES(V)
|
||||
#undef V
|
||||
target->Set(FIXED_ONE_BYTE_STRING(isolate, "Providers"), async_providers);
|
||||
}
|
||||
|
||||
|
||||
Handle<Value> AsyncWrap::MakeCallback(const Handle<Function> cb,
|
||||
int argc,
|
||||
Handle<Value>* argv) {
|
||||
@@ -114,3 +135,5 @@ Handle<Value> AsyncWrap::MakeCallback(const Handle<Function> cb,
|
||||
}
|
||||
|
||||
} // namespace node
|
||||
|
||||
NODE_MODULE_CONTEXT_AWARE_BUILTIN(async_wrap, node::Initialize)
|
||||
|
||||
@@ -28,31 +28,37 @@
|
||||
|
||||
namespace node {
|
||||
|
||||
#define NODE_ASYNC_PROVIDER_TYPES(V) \
|
||||
V(NONE) \
|
||||
V(CARES) \
|
||||
V(CONNECTWRAP) \
|
||||
V(CRYPTO) \
|
||||
V(FSEVENTWRAP) \
|
||||
V(FSREQWRAP) \
|
||||
V(GETADDRINFOREQWRAP) \
|
||||
V(GETNAMEINFOREQWRAP) \
|
||||
V(PIPEWRAP) \
|
||||
V(PROCESSWRAP) \
|
||||
V(QUERYWRAP) \
|
||||
V(REQWRAP) \
|
||||
V(SHUTDOWNWRAP) \
|
||||
V(SIGNALWRAP) \
|
||||
V(STATWATCHER) \
|
||||
V(TCPWRAP) \
|
||||
V(TIMERWRAP) \
|
||||
V(TLSWRAP) \
|
||||
V(TTYWRAP) \
|
||||
V(UDPWRAP) \
|
||||
V(WRITEWRAP) \
|
||||
V(ZLIB)
|
||||
|
||||
class AsyncWrap : public BaseObject {
|
||||
public:
|
||||
enum ProviderType {
|
||||
PROVIDER_NONE,
|
||||
PROVIDER_CARES,
|
||||
PROVIDER_CONNECTWRAP,
|
||||
PROVIDER_CRYPTO,
|
||||
PROVIDER_FSEVENTWRAP,
|
||||
PROVIDER_FSREQWRAP,
|
||||
PROVIDER_GETADDRINFOREQWRAP,
|
||||
PROVIDER_GETNAMEINFOREQWRAP,
|
||||
PROVIDER_PIPEWRAP,
|
||||
PROVIDER_PROCESSWRAP,
|
||||
PROVIDER_QUERYWRAP,
|
||||
PROVIDER_REQWRAP,
|
||||
PROVIDER_SHUTDOWNWRAP,
|
||||
PROVIDER_SIGNALWRAP,
|
||||
PROVIDER_STATWATCHER,
|
||||
PROVIDER_TCPWRAP,
|
||||
PROVIDER_TIMERWRAP,
|
||||
PROVIDER_TLSWRAP,
|
||||
PROVIDER_TTYWRAP,
|
||||
PROVIDER_UDPWRAP,
|
||||
PROVIDER_WRITEWRAP,
|
||||
PROVIDER_ZLIB
|
||||
#define V(PROVIDER) \
|
||||
PROVIDER_ ## PROVIDER,
|
||||
NODE_ASYNC_PROVIDER_TYPES(V)
|
||||
#undef V
|
||||
};
|
||||
|
||||
inline AsyncWrap(Environment* env,
|
||||
|
||||
Reference in New Issue
Block a user