@@ -19,83 +19,23 @@ namespace node {
19
19
using v8::Array;
20
20
using v8::Context;
21
21
using v8::FunctionCallbackInfo;
22
- using v8::FunctionTemplate;
23
22
using v8::Handle ;
24
23
using v8::HandleScope;
25
24
using v8::Integer;
26
25
using v8::Local;
27
26
using v8::Number;
28
27
using v8::Object;
29
- using v8::PropertyAttribute;
30
- using v8::PropertyCallbackInfo;
31
28
using v8::String;
32
29
using v8::Value;
33
30
34
- template void StreamBase::AddMethods<StreamWrap>(Environment* env,
35
- Handle <FunctionTemplate> t);
36
- template void StreamBase::AddMethods<TLSWrap>(Environment* env,
37
- Handle <FunctionTemplate> t);
38
- template void StreamBase::AddMethods<JSStream>(Environment* env,
39
- Handle <FunctionTemplate> t);
40
-
41
-
42
- template <class Base >
43
- void StreamBase::AddMethods (Environment* env, Handle <FunctionTemplate> t) {
44
- HandleScope scope (env->isolate ());
45
-
46
- enum PropertyAttribute attributes =
47
- static_cast <PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
48
- t->InstanceTemplate ()->SetAccessor (env->fd_string (),
49
- GetFD<Base>,
50
- nullptr ,
51
- Handle <Value>(),
52
- v8::DEFAULT,
53
- attributes);
54
-
55
- env->SetProtoMethod (t, " readStart" , JSMethod<Base, &StreamBase::ReadStart>);
56
- env->SetProtoMethod (t, " readStop" , JSMethod<Base, &StreamBase::ReadStop>);
57
- env->SetProtoMethod (t, " shutdown" , JSMethod<Base, &StreamBase::Shutdown>);
58
- env->SetProtoMethod (t, " writev" , JSMethod<Base, &StreamBase::Writev>);
59
- env->SetProtoMethod (t,
60
- " writeBuffer" ,
61
- JSMethod<Base, &StreamBase::WriteBuffer>);
62
- env->SetProtoMethod (t,
63
- " writeAsciiString" ,
64
- JSMethod<Base, &StreamBase::WriteString<ASCII> >);
65
- env->SetProtoMethod (t,
66
- " writeUtf8String" ,
67
- JSMethod<Base, &StreamBase::WriteString<UTF8> >);
68
- env->SetProtoMethod (t,
69
- " writeUcs2String" ,
70
- JSMethod<Base, &StreamBase::WriteString<UCS2> >);
71
- env->SetProtoMethod (t,
72
- " writeBinaryString" ,
73
- JSMethod<Base, &StreamBase::WriteString<BINARY> >);
74
- }
75
-
76
-
77
- template <class Base >
78
- void StreamBase::GetFD (Local<String> key,
79
- const PropertyCallbackInfo<Value>& args) {
80
- StreamBase* wrap = Unwrap<Base>(args.Holder ());
81
-
82
- if (!wrap->IsAlive ())
83
- return args.GetReturnValue ().Set (UV_EINVAL);
84
-
85
- args.GetReturnValue ().Set (wrap->GetFD ());
86
- }
87
-
88
-
89
- template <class Base ,
90
- int (StreamBase::*Method)(const FunctionCallbackInfo<Value>& args)>
91
- void StreamBase::JSMethod(const FunctionCallbackInfo<Value>& args) {
92
- StreamBase* wrap = Unwrap<Base>(args.Holder ());
93
-
94
- if (!wrap->IsAlive ())
95
- return args.GetReturnValue ().Set (UV_EINVAL);
96
-
97
- args.GetReturnValue ().Set ((wrap->*Method)(args));
98
- }
31
+ template int StreamBase::WriteString<ASCII>(
32
+ const FunctionCallbackInfo<Value>& args);
33
+ template int StreamBase::WriteString<UTF8>(
34
+ const FunctionCallbackInfo<Value>& args);
35
+ template int StreamBase::WriteString<UCS2>(
36
+ const FunctionCallbackInfo<Value>& args);
37
+ template int StreamBase::WriteString<BINARY>(
38
+ const FunctionCallbackInfo<Value>& args);
99
39
100
40
101
41
int StreamBase::ReadStart (const FunctionCallbackInfo<Value>& args) {
0 commit comments