summaryrefslogtreecommitdiff
path: root/src/node_http_parser.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2014-10-13 15:19:55 +0200
committerFedor Indutny <fedor@indutny.com>2014-10-13 23:46:46 +0400
commitd3c317e08ac6a624fde8b242905992eafdd954ac (patch)
tree1dd2756855ab5b4513503acc660705fa898c5c64 /src/node_http_parser.cc
parentb45d33617b569bf5fa84c9343da9f7d129756968 (diff)
downloadandroid-node-v8-d3c317e08ac6a624fde8b242905992eafdd954ac.tar.gz
android-node-v8-d3c317e08ac6a624fde8b242905992eafdd954ac.tar.bz2
android-node-v8-d3c317e08ac6a624fde8b242905992eafdd954ac.zip
src: attach env directly to api functions
Attach the per-context execution environment directly to API functions. Rationale: * Gets node one step closer to multi-isolate readiness. * Avoids multi-context confusion, e.g. when the caller and callee live in different contexts. * Avoids expensive calls to pthread_getspecific() on platforms where V8 does not know how to use the thread-local storage directly. (Linux, the BSDs.) PR-URL: https://github.com/node-forward/node/pull/18 Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'src/node_http_parser.cc')
-rw-r--r--src/node_http_parser.cc25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc
index dc25e8c760..eb89829547 100644
--- a/src/node_http_parser.cc
+++ b/src/node_http_parser.cc
@@ -350,7 +350,7 @@ class Parser : public BaseObject {
static void New(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
http_parser_type type =
static_cast<http_parser_type>(args[0]->Int32Value());
CHECK(type == HTTP_REQUEST || type == HTTP_RESPONSE);
@@ -380,7 +380,7 @@ class Parser : public BaseObject {
// var bytesParsed = parser->execute(buffer);
static void Execute(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Parser* parser = Unwrap<Parser>(args.Holder());
CHECK(parser->current_buffer_.IsEmpty());
@@ -434,7 +434,7 @@ class Parser : public BaseObject {
static void Finish(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Parser* parser = Unwrap<Parser>(args.Holder());
@@ -461,7 +461,7 @@ class Parser : public BaseObject {
static void Reinitialize(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
http_parser_type type =
static_cast<http_parser_type>(args[0]->Int32Value());
@@ -476,7 +476,7 @@ class Parser : public BaseObject {
template <bool should_pause>
static void Pause(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args.GetIsolate());
+ Environment* env = Environment::GetCurrent(args);
Parser* parser = Unwrap<Parser>(args.Holder());
// Should always be called from the same context.
CHECK_EQ(env, parser->env());
@@ -569,8 +569,7 @@ void InitHttpParser(Handle<Object> target,
Handle<Context> context,
void* priv) {
Environment* env = Environment::GetCurrent(context);
- Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate(),
- Parser::New);
+ Local<FunctionTemplate> t = env->NewFunctionTemplate(Parser::New);
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "HTTPParser"));
@@ -594,12 +593,12 @@ void InitHttpParser(Handle<Object> target,
#undef V
t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "methods"), methods);
- NODE_SET_PROTOTYPE_METHOD(t, "close", Parser::Close);
- NODE_SET_PROTOTYPE_METHOD(t, "execute", Parser::Execute);
- NODE_SET_PROTOTYPE_METHOD(t, "finish", Parser::Finish);
- NODE_SET_PROTOTYPE_METHOD(t, "reinitialize", Parser::Reinitialize);
- NODE_SET_PROTOTYPE_METHOD(t, "pause", Parser::Pause<true>);
- NODE_SET_PROTOTYPE_METHOD(t, "resume", Parser::Pause<false>);
+ env->SetProtoMethod(t, "close", Parser::Close);
+ env->SetProtoMethod(t, "execute", Parser::Execute);
+ env->SetProtoMethod(t, "finish", Parser::Finish);
+ env->SetProtoMethod(t, "reinitialize", Parser::Reinitialize);
+ env->SetProtoMethod(t, "pause", Parser::Pause<true>);
+ env->SetProtoMethod(t, "resume", Parser::Pause<false>);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "HTTPParser"),
t->GetFunction());