/src/node/src/async_wrap-inl.h
Line | Count | Source |
1 | | // Copyright Joyent, Inc. and other Node contributors. |
2 | | // |
3 | | // Permission is hereby granted, free of charge, to any person obtaining a |
4 | | // copy of this software and associated documentation files (the |
5 | | // "Software"), to deal in the Software without restriction, including |
6 | | // without limitation the rights to use, copy, modify, merge, publish, |
7 | | // distribute, sublicense, and/or sell copies of the Software, and to permit |
8 | | // persons to whom the Software is furnished to do so, subject to the |
9 | | // following conditions: |
10 | | // |
11 | | // The above copyright notice and this permission notice shall be included |
12 | | // in all copies or substantial portions of the Software. |
13 | | // |
14 | | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
15 | | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
16 | | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
17 | | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
18 | | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
19 | | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
20 | | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
21 | | |
22 | | #ifndef SRC_ASYNC_WRAP_INL_H_ |
23 | | #define SRC_ASYNC_WRAP_INL_H_ |
24 | | |
25 | | #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS |
26 | | |
27 | | #include "async_wrap.h" |
28 | | #include "base_object-inl.h" |
29 | | #include "node_internals.h" |
30 | | |
31 | | namespace node { |
32 | | |
33 | 0 | inline AsyncWrap::ProviderType AsyncWrap::provider_type() const { |
34 | 0 | return provider_type_; |
35 | 0 | } |
36 | | |
37 | | inline AsyncWrap::ProviderType AsyncWrap::set_provider_type( |
38 | 0 | AsyncWrap::ProviderType provider) { |
39 | 0 | provider_type_ = provider; |
40 | 0 | return provider_type_; |
41 | 0 | } |
42 | | |
43 | 0 | inline double AsyncWrap::get_async_id() const { |
44 | 0 | return async_id_; |
45 | 0 | } |
46 | | |
47 | | |
48 | 0 | inline double AsyncWrap::get_trigger_async_id() const { |
49 | 0 | return trigger_async_id_; |
50 | 0 | } |
51 | | |
52 | 0 | inline v8::Local<v8::Value> AsyncWrap::context_frame() const { |
53 | 0 | return context_frame_.Get(env()->isolate()); |
54 | 0 | } |
55 | | |
56 | | inline v8::MaybeLocal<v8::Value> AsyncWrap::MakeCallback( |
57 | | const v8::Local<v8::String> symbol, |
58 | | int argc, |
59 | 0 | v8::Local<v8::Value>* argv) { |
60 | 0 | return MakeCallback(symbol.As<v8::Name>(), argc, argv); |
61 | 0 | } |
62 | | |
63 | | |
64 | | inline v8::MaybeLocal<v8::Value> AsyncWrap::MakeCallback( |
65 | | const v8::Local<v8::Symbol> symbol, |
66 | | int argc, |
67 | 0 | v8::Local<v8::Value>* argv) { |
68 | 0 | return MakeCallback(symbol.As<v8::Name>(), argc, argv); |
69 | 0 | } |
70 | | |
71 | | |
72 | | inline v8::MaybeLocal<v8::Value> AsyncWrap::MakeCallback( |
73 | | const v8::Local<v8::Name> symbol, |
74 | | int argc, |
75 | 0 | v8::Local<v8::Value>* argv) { |
76 | 0 | v8::Local<v8::Value> cb_v; |
77 | 0 | if (!object()->Get(env()->context(), symbol).ToLocal(&cb_v)) |
78 | 0 | return v8::MaybeLocal<v8::Value>(); |
79 | 0 | if (!cb_v->IsFunction()) { |
80 | 0 | v8::Isolate* isolate = env()->isolate(); |
81 | 0 | return Undefined(isolate); |
82 | 0 | } |
83 | 0 | return MakeCallback(cb_v.As<v8::Function>(), argc, argv); |
84 | 0 | } |
85 | | |
86 | | // static |
87 | | inline v8::Local<v8::FunctionTemplate> AsyncWrap::GetConstructorTemplate( |
88 | 0 | Environment* env) { |
89 | 0 | return GetConstructorTemplate(env->isolate_data()); |
90 | 0 | } |
91 | | |
92 | | } // namespace node |
93 | | |
94 | | #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS |
95 | | |
96 | | #endif // SRC_ASYNC_WRAP_INL_H_ |