Server IP : 127.0.0.2 / Your IP : 3.16.50.164 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/include/nodejs/src/ |
Upload File : |
#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::External; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::HandleScope; using v8::Local; using v8::Object; using v8::PropertyAttribute; using v8::PropertyCallbackInfo; using v8::String; using v8::Value; template <class Base> void StreamBase::AddMethods(Environment* env, Local<FunctionTemplate> t, int flags) { HandleScope scope(env->isolate()); enum PropertyAttribute attributes = static_cast<PropertyAttribute>(v8::ReadOnly | v8::DontDelete); t->InstanceTemplate()->SetAccessor(env->fd_string(), GetFD<Base>, nullptr, env->as_external(), v8::DEFAULT, attributes); t->InstanceTemplate()->SetAccessor(env->external_stream_string(), GetExternal<Base>, nullptr, env->as_external(), v8::DEFAULT, attributes); env->SetProtoMethod(t, "readStart", JSMethod<Base, &StreamBase::ReadStart>); env->SetProtoMethod(t, "readStop", JSMethod<Base, &StreamBase::ReadStop>); if ((flags & kFlagNoShutdown) == 0) env->SetProtoMethod(t, "shutdown", JSMethod<Base, &StreamBase::Shutdown>); if ((flags & kFlagHasWritev) != 0) env->SetProtoMethod(t, "writev", JSMethod<Base, &StreamBase::Writev>); env->SetProtoMethod(t, "writeBuffer", JSMethod<Base, &StreamBase::WriteBuffer>); env->SetProtoMethod(t, "writeAsciiString", JSMethod<Base, &StreamBase::WriteString<ASCII> >); env->SetProtoMethod(t, "writeUtf8String", JSMethod<Base, &StreamBase::WriteString<UTF8> >); env->SetProtoMethod(t, "writeUcs2String", JSMethod<Base, &StreamBase::WriteString<UCS2> >); env->SetProtoMethod(t, "writeBinaryString", JSMethod<Base, &StreamBase::WriteString<BINARY> >); } template <class Base> void StreamBase::GetFD(Local<String> key, const PropertyCallbackInfo<Value>& args) { StreamBase* wrap = Unwrap<Base>(args.Holder()); if (!wrap->IsAlive()) return args.GetReturnValue().Set(UV_EINVAL); args.GetReturnValue().Set(wrap->GetFD()); } template <class Base> void StreamBase::GetExternal(Local<String> key, const PropertyCallbackInfo<Value>& args) { StreamBase* wrap = Unwrap<Base>(args.Holder()); Local<External> ext = External::New(args.GetIsolate(), wrap); args.GetReturnValue().Set(ext); } template <class Base, int (StreamBase::*Method)(const FunctionCallbackInfo<Value>& args)> void StreamBase::JSMethod(const FunctionCallbackInfo<Value>& args) { StreamBase* wrap = Unwrap<Base>(args.Holder()); if (!wrap->IsAlive()) return args.GetReturnValue().Set(UV_EINVAL); args.GetReturnValue().Set((wrap->*Method)(args)); } WriteWrap* WriteWrap::New(Environment* env, Local<Object> obj, StreamBase* wrap, DoneCb cb, size_t extra) { size_t storage_size = ROUND_UP(sizeof(WriteWrap), kAlignSize) + extra; char* storage = new char[storage_size]; return new(storage) WriteWrap(env, obj, wrap, cb, storage_size); } void WriteWrap::Dispose() { this->~WriteWrap(); delete[] reinterpret_cast<char*>(this); } char* WriteWrap::Extra(size_t offset) { return reinterpret_cast<char*>(this) + ROUND_UP(sizeof(*this), kAlignSize) + offset; } } // namespace node #endif // SRC_STREAM_BASE_INL_H_