Browse Source

src: replace c-style casts with c++-style casts

v0.11.3-release
Ben Noordhuis 12 years ago
parent
commit
4d68daea0f
  1. 15
      src/cares_wrap.cc
  2. 4
      src/fs_event_wrap.cc
  3. 6
      src/node.cc
  4. 8
      src/node_win32_etw_provider.cc
  5. 13
      src/pipe_wrap.cc
  6. 2
      src/process_wrap.cc
  7. 6
      src/stream_wrap.cc
  8. 16
      src/tcp_wrap.cc
  9. 2
      src/timer_wrap.cc
  10. 2
      src/tty_wrap.cc
  11. 4
      src/udp_wrap.cc

15
src/cares_wrap.cc

@ -120,7 +120,7 @@ static void ares_poll_close_cb(uv_handle_t* watcher) {
/* Allocates and returns a new ares_task_t */
static ares_task_t* ares_task_create(uv_loop_t* loop, ares_socket_t sock) {
ares_task_t* task = (ares_task_t*) malloc(sizeof *task);
ares_task_t* task = static_cast<ares_task_t*>(malloc(sizeof(*task)));
if (task == NULL) {
/* Out of memory. */
@ -141,9 +141,11 @@ static ares_task_t* ares_task_create(uv_loop_t* loop, ares_socket_t sock) {
/* Callback from ares when socket operation is started */
static void ares_sockstate_cb(void* data, ares_socket_t sock,
int read, int write) {
uv_loop_t* loop = (uv_loop_t*) data;
static void ares_sockstate_cb(void* data,
ares_socket_t sock,
int read,
int write) {
uv_loop_t* loop = static_cast<uv_loop_t*>(data);
ares_task_t* task;
ares_task_t lookup_task;
@ -155,7 +157,7 @@ static void ares_sockstate_cb(void* data, ares_socket_t sock,
/* New socket */
/* If this is the first socket then start the timer. */
if (!uv_is_active((uv_handle_t*) &ares_timer)) {
if (!uv_is_active(reinterpret_cast<uv_handle_t*>(&ares_timer))) {
assert(RB_EMPTY(&ares_tasks));
uv_timer_start(&ares_timer, ares_timeout, 1000, 1000);
}
@ -185,7 +187,8 @@ static void ares_sockstate_cb(void* data, ares_socket_t sock,
"When an ares socket is closed we should have a handle for it");
RB_REMOVE(ares_task_list, &ares_tasks, task);
uv_close((uv_handle_t*) &task->poll_watcher, ares_poll_close_cb);
uv_close(reinterpret_cast<uv_handle_t*>(&task->poll_watcher),
ares_poll_close_cb);
if (RB_EMPTY(&ares_tasks)) {
uv_timer_stop(&ares_timer);

4
src/fs_event_wrap.cc

@ -51,8 +51,8 @@ private:
};
FSEventWrap::FSEventWrap(Handle<Object> object): HandleWrap(object,
(uv_handle_t*)&handle_) {
FSEventWrap::FSEventWrap(Handle<Object> object)
: HandleWrap(object, reinterpret_cast<uv_handle_t*>(&handle_)) {
handle_.data = static_cast<void*>(this);
initialized_ = false;
}

6
src/node.cc

@ -179,7 +179,7 @@ Isolate* node_isolate = NULL;
static void Spin(uv_idle_t* handle, int status) {
assert((uv_idle_t*) handle == &tick_spinner);
assert(handle == &tick_spinner);
assert(status == 0);
// Avoid entering a V8 scope.
@ -2972,7 +2972,7 @@ char** Init(int argc, char *argv[]) {
uv_idle_init(uv_default_loop(), &tick_spinner);
uv_check_init(uv_default_loop(), &check_immediate_watcher);
uv_unref((uv_handle_t*) &check_immediate_watcher);
uv_unref(reinterpret_cast<uv_handle_t*>(&check_immediate_watcher));
uv_idle_init(uv_default_loop(), &idle_immediate_dummy);
V8::SetFatalErrorHandler(node::OnFatalError);
@ -2987,7 +2987,7 @@ char** Init(int argc, char *argv[]) {
static uv_signal_t signal_watcher;
uv_signal_init(uv_default_loop(), &signal_watcher);
uv_signal_start(&signal_watcher, EnableDebugSignalHandler, SIGUSR1);
uv_unref((uv_handle_t*)&signal_watcher);
uv_unref(reinterpret_cast<uv_handle_t*>(&signal_watcher));
#endif // __POSIX__
}

8
src/node_win32_etw_provider.cc

@ -173,9 +173,9 @@ void init_etw() {
// create async object used to invoke main thread from callback
uv_async_init(uv_default_loop(),
&dispatch_etw_events_change_async,
etw_events_change_async);
uv_unref((uv_handle_t*) &dispatch_etw_events_change_async);
&dispatch_etw_events_change_async,
etw_events_change_async);
uv_unref(reinterpret_cast<uv_handle_t*>(&dispatch_etw_events_change_async));
if (event_register) {
DWORD status = event_register(&NODE_ETW_PROVIDER,
@ -202,4 +202,4 @@ void shutdown_etw() {
advapi = NULL;
}
}
}
}

13
src/pipe_wrap.cc

@ -135,7 +135,7 @@ Handle<Value> PipeWrap::New(const Arguments& args) {
PipeWrap::PipeWrap(Handle<Object> object, bool ipc)
: StreamWrap(object, (uv_stream_t*) &handle_) {
: StreamWrap(object, reinterpret_cast<uv_stream_t*>(&handle_)) {
int r = uv_pipe_init(uv_default_loop(), &handle_, ipc);
assert(r == 0); // How do we proxy this error up to javascript?
// Suggestion: uv_pipe_init() returns void.
@ -182,7 +182,9 @@ Handle<Value> PipeWrap::Listen(const Arguments& args) {
int backlog = args[0]->Int32Value();
int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection);
int r = uv_listen(reinterpret_cast<uv_stream_t*>(&wrap->handle_),
backlog,
OnConnection);
// Error starting the pipe.
if (r) SetErrno(uv_last_error(uv_default_loop()));
@ -196,7 +198,7 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
HandleScope scope(node_isolate);
PipeWrap* wrap = static_cast<PipeWrap*>(handle->data);
assert(&wrap->handle_ == (uv_pipe_t*)handle);
assert(&wrap->handle_ == reinterpret_cast<uv_pipe_t*>(handle));
// We should not be getting this callback if someone as already called
// uv_close() on the handle.
@ -215,8 +217,9 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
assert(client_obj->InternalFieldCount() > 0);
PipeWrap* client_wrap =
static_cast<PipeWrap*>(client_obj->GetAlignedPointerFromInternalField(0));
if (uv_accept(handle, (uv_stream_t*)&client_wrap->handle_)) return;
uv_stream_t* client_handle =
reinterpret_cast<uv_stream_t*>(&client_wrap->handle_);
if (uv_accept(handle, client_handle)) return;
// Successful accept. Call the onconnection callback in JavaScript land.
Local<Value> argv[1] = { client_obj };

2
src/process_wrap.cc

@ -248,7 +248,7 @@ class ProcessWrap : public HandleWrap {
SetErrno(uv_last_error(uv_default_loop()));
}
else {
wrap->SetHandle((uv_handle_t*)&wrap->process_);
wrap->SetHandle(reinterpret_cast<uv_handle_t*>(&wrap->process_));
assert(wrap->process_.data == wrap);
wrap->object_->Set(String::New("pid"),
Integer::New(wrap->process_.pid, node_isolate));

6
src/stream_wrap.cc

@ -110,7 +110,7 @@ void StreamWrap::Initialize(Handle<Object> target) {
StreamWrap::StreamWrap(Handle<Object> object, uv_stream_t* stream)
: HandleWrap(object, (uv_handle_t*)stream) {
: HandleWrap(object, reinterpret_cast<uv_handle_t*>(stream)) {
stream_ = stream;
if (stream) {
stream->data = this;
@ -151,7 +151,7 @@ Handle<Value> StreamWrap::ReadStart(const Arguments& args) {
UNWRAP(StreamWrap)
bool ipc_pipe = wrap->stream_->type == UV_NAMED_PIPE &&
((uv_pipe_t*)wrap->stream_)->ipc;
reinterpret_cast<uv_pipe_t*>(wrap->stream_)->ipc;
int r;
if (ipc_pipe) {
r = uv_read2_start(wrap->stream_, OnAlloc, OnRead2);
@ -385,7 +385,7 @@ Handle<Value> StreamWrap::WriteStringImpl(const Arguments& args) {
buf.len = data_size;
bool ipc_pipe = wrap->stream_->type == UV_NAMED_PIPE &&
((uv_pipe_t*)wrap->stream_)->ipc;
reinterpret_cast<uv_pipe_t*>(wrap->stream_)->ipc;
if (!ipc_pipe) {
r = uv_write(&req_wrap->req_,

16
src/tcp_wrap.cc

@ -156,7 +156,7 @@ Handle<Value> TCPWrap::New(const Arguments& args) {
TCPWrap::TCPWrap(Handle<Object> object)
: StreamWrap(object, (uv_stream_t*) &handle_) {
: StreamWrap(object, reinterpret_cast<uv_stream_t*>(&handle_)) {
int r = uv_tcp_init(uv_default_loop(), &handle_);
assert(r == 0); // How do we proxy this error up to javascript?
// Suggestion: uv_tcp_init() returns void.
@ -310,7 +310,9 @@ Handle<Value> TCPWrap::Listen(const Arguments& args) {
int backlog = args[0]->Int32Value();
int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection);
int r = uv_listen(reinterpret_cast<uv_stream_t*>(&wrap->handle_),
backlog,
OnConnection);
// Error starting the tcp.
if (r) SetErrno(uv_last_error(uv_default_loop()));
@ -323,7 +325,7 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
HandleScope scope(node_isolate);
TCPWrap* wrap = static_cast<TCPWrap*>(handle->data);
assert(&wrap->handle_ == (uv_tcp_t*)handle);
assert(&wrap->handle_ == reinterpret_cast<uv_tcp_t*>(handle));
// We should not be getting this callback if someone as already called
// uv_close() on the handle.
@ -337,10 +339,12 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
// Unwrap the client javascript object.
assert(client_obj->InternalFieldCount() > 0);
TCPWrap* client_wrap = static_cast<TCPWrap*>(
client_obj->GetAlignedPointerFromInternalField(0));
if (uv_accept(handle, (uv_stream_t*)&client_wrap->handle_)) return;
void* client_wrap_v = client_obj->GetAlignedPointerFromInternalField(0);
TCPWrap* client_wrap = static_cast<TCPWrap*>(client_wrap_v);
uv_stream_t* client_handle =
reinterpret_cast<uv_stream_t*>(&client_wrap->handle_);
if (uv_accept(handle, client_handle)) return;
// Successful accept. Call the onconnection callback in JavaScript land.
argv[0] = client_obj;

2
src/timer_wrap.cc

@ -83,7 +83,7 @@ class TimerWrap : public HandleWrap {
}
TimerWrap(Handle<Object> object)
: HandleWrap(object, (uv_handle_t*) &handle_) {
: HandleWrap(object, reinterpret_cast<uv_handle_t*>(&handle_)) {
int r = uv_timer_init(uv_default_loop(), &handle_);
assert(r == 0);
handle_.data = this;

2
src/tty_wrap.cc

@ -199,7 +199,7 @@ Handle<Value> TTYWrap::New(const Arguments& args) {
TTYWrap::TTYWrap(Handle<Object> object, int fd, bool readable)
: StreamWrap(object, (uv_stream_t*)&handle_) {
: StreamWrap(object, reinterpret_cast<uv_stream_t*>(&handle_)) {
uv_tty_init(uv_default_loop(), &handle_, fd, readable);
}

4
src/udp_wrap.cc

@ -65,8 +65,8 @@ static void DeleteSlabAllocator(void*) {
}
UDPWrap::UDPWrap(Handle<Object> object): HandleWrap(object,
(uv_handle_t*)&handle_) {
UDPWrap::UDPWrap(Handle<Object> object)
: HandleWrap(object, reinterpret_cast<uv_handle_t*>(&handle_)) {
int r = uv_udp_init(uv_default_loop(), &handle_);
assert(r == 0); // can't fail anyway
handle_.data = reinterpret_cast<void*>(this);

Loading…
Cancel
Save