GeezerVison is showing github.com — src: add HandleWrap::AddWrapMethods · nodejs/node@4ed5d1a
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/handle_wrap.cc +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,6 +29,7 @@ namespace node { | 29 | 29 |
| 30 | 30 | using v8::Context; | 31 | 31 | using v8::FunctionCallbackInfo; | | 32 | +using v8::FunctionTemplate; | 32 | 33 | using v8::HandleScope; | 33 | 34 | using v8::Local; | 34 | 35 | using v8::Object; | @@ -130,4 +131,13 @@ void HandleWrap::OnClose(uv_handle_t* handle) { | 130 | 131 | } | 131 | 132 |
| 132 | 133 |
| | 134 | +void HandleWrap::AddWrapMethods(Environment* env, | | 135 | + Local<FunctionTemplate> t) { | | 136 | + env->SetProtoMethod(t, "close", HandleWrap::Close); | | 137 | + env->SetProtoMethodNoSideEffect(t, "hasRef", HandleWrap::HasRef); | | 138 | + env->SetProtoMethod(t, "ref", HandleWrap::Ref); | | 139 | + env->SetProtoMethod(t, "unref", HandleWrap::Unref); | | 140 | +} | | 141 | + | | 142 | + | 133 | 143 | } // namespace node |
Collapse file Copy file name to clipboardExpand all lines: src/handle_wrap.h +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -73,6 +73,9 @@ class HandleWrap : public AsyncWrap { | 73 | 73 | virtual void Close( | 74 | 74 | v8::Local<v8::Value> close_callback = v8::Local<v8::Value>()); | 75 | 75 |
| | 76 | + static void AddWrapMethods(Environment* env, | | 77 | + v8::Local<v8::FunctionTemplate> constructor); | | 78 | + | 76 | 79 | protected: | 77 | 80 | HandleWrap(Environment* env, | 78 | 81 | v8::Local<v8::Object> object, | |
Collapse file Copy file name to clipboardExpand all lines: src/node_messaging.cc +1-4Lines changed: 1 addition & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -724,15 +724,12 @@ MaybeLocal<Function> GetMessagePortConstructor( | 724 | 724 | m->InstanceTemplate()->SetInternalFieldCount(1); | 725 | 725 |
| 726 | 726 | AsyncWrap::AddWrapMethods(env, m); | | 727 | + HandleWrap::AddWrapMethods(env, m); | 727 | 728 |
| 728 | 729 | env->SetProtoMethod(m, "postMessage", MessagePort::PostMessage); | 729 | 730 | env->SetProtoMethod(m, "start", MessagePort::Start); | 730 | 731 | env->SetProtoMethod(m, "stop", MessagePort::Stop); | 731 | 732 | env->SetProtoMethod(m, "drain", MessagePort::Drain); | 732 | | - env->SetProtoMethod(m, "close", HandleWrap::Close); | 733 | | - env->SetProtoMethod(m, "unref", HandleWrap::Unref); | 734 | | - env->SetProtoMethod(m, "ref", HandleWrap::Ref); | 735 | | - env->SetProtoMethod(m, "hasRef", HandleWrap::HasRef); | 736 | 733 |
| 737 | 734 | env->set_message_port_constructor_template(m); | 738 | 735 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/node_stat_watcher.cc +2-4Lines changed: 2 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -52,11 +52,9 @@ void StatWatcher::Initialize(Environment* env, Local<Object> target) { | 52 | 52 | t->SetClassName(statWatcherString); | 53 | 53 |
| 54 | 54 | AsyncWrap::AddWrapMethods(env, t); | | 55 | + HandleWrap::AddWrapMethods(env, t); | | 56 | + | 55 | 57 | env->SetProtoMethod(t, "start", StatWatcher::Start); | 56 | | - env->SetProtoMethod(t, "close", HandleWrap::Close); | 57 | | - env->SetProtoMethod(t, "ref", HandleWrap::Ref); | 58 | | - env->SetProtoMethod(t, "unref", HandleWrap::Unref); | 59 | | - env->SetProtoMethod(t, "hasRef", HandleWrap::HasRef); | 60 | 58 |
| 61 | 59 | target->Set(statWatcherString, t->GetFunction()); | 62 | 60 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/pipe_wrap.cc +1-6Lines changed: 1 addition & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -77,12 +77,7 @@ void PipeWrap::Initialize(Local<Object> target, | 77 | 77 | t->InstanceTemplate()->SetInternalFieldCount(1); | 78 | 78 |
| 79 | 79 | AsyncWrap::AddWrapMethods(env, t); | 80 | | - | 81 | | - env->SetProtoMethod(t, "close", HandleWrap::Close); | 82 | | - env->SetProtoMethod(t, "unref", HandleWrap::Unref); | 83 | | - env->SetProtoMethod(t, "ref", HandleWrap::Ref); | 84 | | - env->SetProtoMethod(t, "hasRef", HandleWrap::HasRef); | 85 | | - | | 80 | + HandleWrap::AddWrapMethods(env, t); | 86 | 81 | LibuvStreamWrap::AddMethods(env, t); | 87 | 82 |
| 88 | 83 | env->SetProtoMethod(t, "bind", Bind); | |
Collapse file Copy file name to clipboardExpand all lines: src/process_wrap.cc +1-6Lines changed: 1 addition & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -58,16 +58,11 @@ class ProcessWrap : public HandleWrap { | 58 | 58 | constructor->SetClassName(processString); | 59 | 59 |
| 60 | 60 | AsyncWrap::AddWrapMethods(env, constructor); | 61 | | - | 62 | | - env->SetProtoMethod(constructor, "close", HandleWrap::Close); | | 61 | + HandleWrap::AddWrapMethods(env, constructor); | 63 | 62 |
| 64 | 63 | env->SetProtoMethod(constructor, "spawn", Spawn); | 65 | 64 | env->SetProtoMethod(constructor, "kill", Kill); | 66 | 65 |
| 67 | | - env->SetProtoMethod(constructor, "ref", HandleWrap::Ref); | 68 | | - env->SetProtoMethod(constructor, "unref", HandleWrap::Unref); | 69 | | - env->SetProtoMethod(constructor, "hasRef", HandleWrap::HasRef); | 70 | | - | 71 | 66 | target->Set(processString, constructor->GetFunction()); | 72 | 67 | } | 73 | 68 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/signal_wrap.cc +2-4Lines changed: 2 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -52,10 +52,8 @@ class SignalWrap : public HandleWrap { | 52 | 52 | constructor->SetClassName(signalString); | 53 | 53 |
| 54 | 54 | AsyncWrap::AddWrapMethods(env, constructor); | 55 | | - env->SetProtoMethod(constructor, "close", HandleWrap::Close); | 56 | | - env->SetProtoMethod(constructor, "ref", HandleWrap::Ref); | 57 | | - env->SetProtoMethod(constructor, "unref", HandleWrap::Unref); | 58 | | - env->SetProtoMethod(constructor, "hasRef", HandleWrap::HasRef); | | 55 | + HandleWrap::AddWrapMethods(env, constructor); | | 56 | + | 59 | 57 | env->SetProtoMethod(constructor, "start", Start); | 60 | 58 | env->SetProtoMethod(constructor, "stop", Stop); | 61 | 59 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/tcp_wrap.cc +1-7Lines changed: 1 addition & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -86,13 +86,7 @@ void TCPWrap::Initialize(Local<Object> target, | 86 | 86 | t->InstanceTemplate()->Set(env->onconnection_string(), Null(env->isolate())); | 87 | 87 |
| 88 | 88 | AsyncWrap::AddWrapMethods(env, t, AsyncWrap::kFlagHasReset); | 89 | | - | 90 | | - env->SetProtoMethod(t, "close", HandleWrap::Close); | 91 | | - | 92 | | - env->SetProtoMethod(t, "ref", HandleWrap::Ref); | 93 | | - env->SetProtoMethod(t, "unref", HandleWrap::Unref); | 94 | | - env->SetProtoMethod(t, "hasRef", HandleWrap::HasRef); | 95 | | - | | 89 | + HandleWrap::AddWrapMethods(env, t); | 96 | 90 | LibuvStreamWrap::AddMethods(env, t); | 97 | 91 |
| 98 | 92 | env->SetProtoMethod(t, "open", Open); | |
Collapse file Copy file name to clipboardExpand all lines: src/timer_wrap.cc +1-5Lines changed: 1 addition & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -55,11 +55,7 @@ class TimerWrap : public HandleWrap { | 55 | 55 | env->SetTemplateMethod(constructor, "now", Now); | 56 | 56 |
| 57 | 57 | AsyncWrap::AddWrapMethods(env, constructor); | 58 | | - | 59 | | - env->SetProtoMethod(constructor, "close", HandleWrap::Close); | 60 | | - env->SetProtoMethod(constructor, "ref", HandleWrap::Ref); | 61 | | - env->SetProtoMethod(constructor, "unref", HandleWrap::Unref); | 62 | | - env->SetProtoMethod(constructor, "hasRef", HandleWrap::HasRef); | | 58 | + HandleWrap::AddWrapMethods(env, constructor); | 63 | 59 |
| 64 | 60 | env->SetProtoMethod(constructor, "start", Start); | 65 | 61 | env->SetProtoMethod(constructor, "stop", Stop); | |
Collapse file Copy file name to clipboardExpand all lines: src/tty_wrap.cc +1-6Lines changed: 1 addition & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -54,12 +54,7 @@ void TTYWrap::Initialize(Local<Object> target, | 54 | 54 | t->InstanceTemplate()->SetInternalFieldCount(1); | 55 | 55 |
| 56 | 56 | AsyncWrap::AddWrapMethods(env, t); | 57 | | - | 58 | | - env->SetProtoMethod(t, "close", HandleWrap::Close); | 59 | | - env->SetProtoMethod(t, "unref", HandleWrap::Unref); | 60 | | - env->SetProtoMethod(t, "ref", HandleWrap::Ref); | 61 | | - env->SetProtoMethodNoSideEffect(t, "hasRef", HandleWrap::HasRef); | 62 | | - | | 57 | + HandleWrap::AddWrapMethods(env, t); | 63 | 58 | LibuvStreamWrap::AddMethods(env, t); | 64 | 59 |
| 65 | 60 | env->SetProtoMethodNoSideEffect(t, "getWindowSize", TTYWrap::GetWindowSize); | |
|