#ifndef SRC_STREAM_BASE_INL_H_ #define SRC_STREAM_BASE_INL_H_ #include "stream_base.h" #include "node.h" #include "env.h" #include "env-inl.h" #include "v8.h" namespace node { using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::Handle; using v8::HandleScope; using v8::Local; using v8::PropertyAttribute; using v8::PropertyCallbackInfo; using v8::String; using v8::Value; template void StreamBase::AddMethods(Environment* env, Handle t) { HandleScope scope(env->isolate()); enum PropertyAttribute attributes = static_cast(v8::ReadOnly | v8::DontDelete); t->InstanceTemplate()->SetAccessor(env->fd_string(), GetFD, nullptr, Handle(), v8::DEFAULT, attributes); env->SetProtoMethod(t, "readStart", JSMethod); env->SetProtoMethod(t, "readStop", JSMethod); env->SetProtoMethod(t, "shutdown", JSMethod); env->SetProtoMethod(t, "writev", JSMethod); env->SetProtoMethod(t, "writeBuffer", JSMethod); env->SetProtoMethod(t, "writeAsciiString", JSMethod >); env->SetProtoMethod(t, "writeUtf8String", JSMethod >); env->SetProtoMethod(t, "writeUcs2String", JSMethod >); env->SetProtoMethod(t, "writeBinaryString", JSMethod >); } template void StreamBase::GetFD(Local key, const PropertyCallbackInfo& args) { StreamBase* wrap = Unwrap(args.Holder()); if (!wrap->IsAlive()) return args.GetReturnValue().Set(UV_EINVAL); args.GetReturnValue().Set(wrap->GetFD()); } template & args)> void StreamBase::JSMethod(const FunctionCallbackInfo& args) { StreamBase* wrap = Unwrap(args.Holder()); if (!wrap->IsAlive()) return args.GetReturnValue().Set(UV_EINVAL); args.GetReturnValue().Set((wrap->*Method)(args)); } } // namespace node #endif // SRC_STREAM_BASE_INL_H_