Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 73 lines (57 sloc) 2.617 kB
60818b9 @ry Add missing copyright headers
ry authored
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
1ae1489 @ry Abstract StreamWrap from TCPWrap
ry authored
22 #ifndef STREAM_WRAP_H_
23 #define STREAM_WRAP_H_
24
ff4a9d3 @bnoordhuis core: use proper #include directives
bnoordhuis authored
25 #include "v8.h"
26 #include "node.h"
27 #include "handle_wrap.h"
0c7bf81 @ry Abstract out HandleWrap class
ry authored
28
1ae1489 @ry Abstract StreamWrap from TCPWrap
ry authored
29 namespace node {
30
0c7bf81 @ry Abstract out HandleWrap class
ry authored
31 class StreamWrap : public HandleWrap {
1ae1489 @ry Abstract StreamWrap from TCPWrap
ry authored
32 public:
187fe27 stdio binding + javascript to enable process.stdin.listen()
Igor Zinkovsky authored
33 uv_stream_t* GetStream() { return stream_; }
34
1ae1489 @ry Abstract StreamWrap from TCPWrap
ry authored
35 static void Initialize(v8::Handle<v8::Object> target);
36
37 // JavaScript functions
38 static v8::Handle<v8::Value> Write(const v8::Arguments& args);
39 static v8::Handle<v8::Value> ReadStart(const v8::Arguments& args);
40 static v8::Handle<v8::Value> ReadStop(const v8::Arguments& args);
41 static v8::Handle<v8::Value> Shutdown(const v8::Arguments& args);
42
43 protected:
44 StreamWrap(v8::Handle<v8::Object> object, uv_stream_t* stream);
0c7bf81 @ry Abstract out HandleWrap class
ry authored
45 virtual ~StreamWrap() { }
187fe27 stdio binding + javascript to enable process.stdin.listen()
Igor Zinkovsky authored
46 virtual void SetHandle(uv_handle_t* h);
0c7bf81 @ry Abstract out HandleWrap class
ry authored
47 void StateChange() { }
6050af4 @ry net_uv: properly initialize writeQueueSize
ry authored
48 void UpdateWriteQueueSize();
1ae1489 @ry Abstract StreamWrap from TCPWrap
ry authored
49
50 private:
51 static inline char* NewSlab(v8::Handle<v8::Object> global, v8::Handle<v8::Object> wrap_obj);
52
53 // Callbacks for libuv
54 static void AfterWrite(uv_write_t* req, int status);
2aefea5 @bnoordhuis stream_wrap: update after libuv API change
bnoordhuis authored
55 static uv_buf_t OnAlloc(uv_handle_t* handle, size_t suggested_size);
1ae1489 @ry Abstract StreamWrap from TCPWrap
ry authored
56 static void AfterShutdown(uv_shutdown_t* req, int status);
57
471c570 @ry uv_write2 uv_read2_start binding
ry authored
58 static void OnRead(uv_stream_t* handle, ssize_t nread, uv_buf_t buf);
59 static void OnRead2(uv_pipe_t* handle, ssize_t nread, uv_buf_t buf,
60 uv_handle_type pending);
61 static void OnReadCommon(uv_stream_t* handle, ssize_t nread,
62 uv_buf_t buf, uv_handle_type pending);
63
1ae1489 @ry Abstract StreamWrap from TCPWrap
ry authored
64 size_t slab_offset_;
65 uv_stream_t* stream_;
66 };
67
68
69 } // namespace node
70
71
72 #endif // STREAM_WRAP_H_
Something went wrong with that request. Please try again.