Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From f4cd2655fa103edba20ac0f34e612b70e5fbe261 Mon Sep 17 00:00:00 2001
- From: Bert Belder <bertbelder@gmail.com>
- Date: Wed, 24 Aug 2011 00:24:24 +0200
- Subject: [PATCH 1/1] Define uv_object_t, a base class for handles and
- requests
- ---
- include/uv-unix.h | 2 ++
- include/uv-win.h | 3 +++
- include/uv.h | 31 +++++++++++++++++++------------
- src/uv-unix.c | 2 +-
- src/win/req.c | 2 +-
- 5 files changed, 26 insertions(+), 14 deletions(-)
- diff --git a/include/uv-unix.h b/include/uv-unix.h
- index e918e4d..62498a7 100644
- --- a/include/uv-unix.h
- +++ b/include/uv-unix.h
- @@ -39,6 +39,8 @@ typedef struct {
- size_t len;
- } uv_buf_t;
- +#define UV_OBJECT_PRIVATE_FIELDS /* empty */
- +
- #define UV_REQ_BUFSML_SIZE (4)
- #define UV_REQ_PRIVATE_FIELDS /* empty */
- diff --git a/include/uv-win.h b/include/uv-win.h
- index a3ad457..a150011 100644
- --- a/include/uv-win.h
- +++ b/include/uv-win.h
- @@ -51,6 +51,9 @@ typedef struct uv_buf_t {
- UV_PROCESS_CLOSE, \
- UV_UDP_RECV
- +#define UV_OBJECT_PRIVATE_FIELDS \
- + /* empty */
- +
- #define UV_REQ_PRIVATE_FIELDS \
- union { \
- /* Used by I/O operations */ \
- diff --git a/include/uv.h b/include/uv.h
- index 2dd5034..30334a0 100644
- --- a/include/uv.h
- +++ b/include/uv.h
- @@ -42,6 +42,7 @@ typedef intptr_t ssize_t;
- #endif
- typedef struct uv_err_s uv_err_t;
- +typedef struct uv_object_s uv_object_t;
- typedef struct uv_handle_s uv_handle_t;
- typedef struct uv_stream_s uv_stream_t;
- typedef struct uv_tcp_s uv_tcp_t;
- @@ -173,7 +174,7 @@ typedef enum {
- } uv_err_code;
- typedef enum {
- - UV_UNKNOWN_HANDLE = 0,
- + UV_UNKNOWN_OBJECT = 0,
- UV_TCP,
- UV_UDP,
- UV_NAMED_PIPE,
- @@ -187,11 +188,7 @@ typedef enum {
- UV_ARES_TASK,
- UV_ARES_EVENT,
- UV_GETADDRINFO,
- - UV_PROCESS
- -} uv_handle_type;
- -
- -typedef enum {
- - UV_UNKNOWN_REQ = 0,
- + UV_PROCESS,
- UV_CONNECT,
- UV_ACCEPT,
- UV_READ,
- @@ -200,7 +197,7 @@ typedef enum {
- UV_WAKEUP,
- UV_UDP_SEND,
- UV_REQ_TYPE_PRIVATE
- -} uv_req_type;
- +} uv_object_type;
- struct uv_err_s {
- @@ -221,9 +218,20 @@ char* uv_strerror(uv_err_t err);
- const char* uv_err_name(uv_err_t err);
- -#define UV_REQ_FIELDS \
- +#define UV_OBJECT_FIELDS \
- /* read-only */ \
- - uv_req_type type; \
- + uv_object_type type; \
- + /* private */ \
- + UV_OBJECT_PRIVATE_FIELDS
- +
- +/* Abstract base class of all requests and handles. */
- +struct uv_object_s {
- + UV_OBJECT_FIELDS
- +};
- +
- +
- +#define UV_REQ_FIELDS \
- + UV_OBJECT_FIELDS \
- /* public */ \
- void* data; \
- /* private */ \
- @@ -258,15 +266,14 @@ struct uv_shutdown_s {
- #define UV_HANDLE_FIELDS \
- - /* read-only */ \
- - uv_handle_type type; \
- + UV_OBJECT_FIELDS \
- /* public */ \
- uv_close_cb close_cb; \
- void* data; \
- /* private */ \
- UV_HANDLE_PRIVATE_FIELDS
- -/* The abstract base class of all handles. */
- +/* The abstract base class of all handles. */
- struct uv_handle_s {
- UV_HANDLE_FIELDS
- };
- diff --git a/src/uv-unix.c b/src/uv-unix.c
- index 1cb418c..bb2d74e 100644
- --- a/src/uv-unix.c
- +++ b/src/uv-unix.c
- @@ -1824,7 +1824,7 @@ int uv_read_stop(uv_stream_t* stream) {
- void uv__req_init(uv_req_t* req) {
- uv_counters()->req_init++;
- - req->type = UV_UNKNOWN_REQ;
- + req->type = UV_UNKNOWN_OBJECT;
- req->data = NULL;
- }
- diff --git a/src/win/req.c b/src/win/req.c
- index 12c5346..62cbed9 100644
- --- a/src/win/req.c
- +++ b/src/win/req.c
- @@ -28,7 +28,7 @@
- void uv_req_init(uv_req_t* req) {
- uv_counters()->req_init++;
- - req->type = UV_UNKNOWN_REQ;
- + req->type = UV_UNKNOWN_OBJECT;
- SET_REQ_SUCCESS(req);
- }
- --
- 1.7.6.msysgit.0
Add Comment
Please, Sign In to add comment