From d3c6119a7a68732ff95efdec356ac7abb0f6f6f4 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 27 Jun 2012 13:14:04 -0700 Subject: More keyword paring and migration in runtime, docs, code modes. --- src/rt/rust_uv.cpp | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/rt/rust_uv.cpp') diff --git a/src/rt/rust_uv.cpp b/src/rt/rust_uv.cpp index 0ad59a73161..1873ae33e9c 100644 --- a/src/rt/rust_uv.cpp +++ b/src/rt/rust_uv.cpp @@ -8,11 +8,11 @@ #include "rust_log.h" #include "uv.h" -// crust fn pointers -typedef void (*crust_async_op_cb)(uv_loop_t* loop, void* data, +// extern fn pointers +typedef void (*extern_async_op_cb)(uv_loop_t* loop, void* data, uv_async_t* op_handle); -typedef void (*crust_simple_cb)(uint8_t* id_buf, void* loop_data); -typedef void (*crust_close_cb)(uint8_t* id_buf, void* handle, +typedef void (*extern_simple_cb)(uint8_t* id_buf, void* loop_data); +typedef void (*extern_close_cb)(uint8_t* id_buf, void* handle, void* data); // data types @@ -20,8 +20,8 @@ typedef void (*crust_close_cb)(uint8_t* id_buf, void* handle, struct handle_data { uint8_t id_buf[RUST_UV_HANDLE_LEN]; - crust_simple_cb cb; - crust_close_cb close_cb; + extern_simple_cb cb; + extern_close_cb close_cb; }; // helpers @@ -37,7 +37,7 @@ current_kernel_free(void* ptr) { } static handle_data* -new_handle_data_from(uint8_t* buf, crust_simple_cb cb) { +new_handle_data_from(uint8_t* buf, extern_simple_cb cb) { handle_data* data = (handle_data*)current_kernel_malloc( sizeof(handle_data), "handle_data"); @@ -48,39 +48,39 @@ new_handle_data_from(uint8_t* buf, crust_simple_cb cb) { // libuv callback impls static void -native_crust_async_op_cb(uv_async_t* handle, int status) { - crust_async_op_cb cb = (crust_async_op_cb)handle->data; +foreign_extern_async_op_cb(uv_async_t* handle, int status) { + extern_async_op_cb cb = (extern_async_op_cb)handle->data; void* loop_data = handle->loop->data; cb(handle->loop, loop_data, handle); } static void -native_async_cb(uv_async_t* handle, int status) { +foreign_async_cb(uv_async_t* handle, int status) { handle_data* handle_d = (handle_data*)handle->data; void* loop_data = handle->loop->data; handle_d->cb(handle_d->id_buf, loop_data); } static void -native_timer_cb(uv_timer_t* handle, int status) { +foreign_timer_cb(uv_timer_t* handle, int status) { handle_data* handle_d = (handle_data*)handle->data; void* loop_data = handle->loop->data; handle_d->cb(handle_d->id_buf, loop_data); } static void -native_close_cb(uv_handle_t* handle) { +foreign_close_cb(uv_handle_t* handle) { handle_data* data = (handle_data*)handle->data; data->close_cb(data->id_buf, handle, handle->loop->data); } static void -native_close_op_cb(uv_handle_t* op_handle) { +foreign_close_op_cb(uv_handle_t* op_handle) { current_kernel_free(op_handle); // uv_run() should return after this.. } -// native fns bound in rust +// foreign fns bound in rust extern "C" void rust_uv_free(void* ptr) { current_kernel_free(ptr); @@ -122,11 +122,11 @@ rust_uv_loop_set_data(uv_loop_t* loop, void* data) { } extern "C" void* -rust_uv_bind_op_cb(uv_loop_t* loop, crust_async_op_cb cb) { +rust_uv_bind_op_cb(uv_loop_t* loop, extern_async_op_cb cb) { uv_async_t* async = (uv_async_t*)current_kernel_malloc( sizeof(uv_async_t), "uv_async_t"); - uv_async_init(loop, async, native_crust_async_op_cb); + uv_async_init(loop, async, foreign_extern_async_op_cb); async->data = (void*)cb; // decrement the ref count, so that our async bind // doesn't count towards keeping the loop alive @@ -136,7 +136,7 @@ rust_uv_bind_op_cb(uv_loop_t* loop, crust_async_op_cb cb) { extern "C" void rust_uv_stop_op_cb(uv_handle_t* op_handle) { - uv_close(op_handle, native_close_op_cb); + uv_close(op_handle, foreign_close_op_cb); } extern "C" void @@ -150,10 +150,10 @@ rust_uv_close(uv_handle_t* handle, uv_close_cb cb) { } extern "C" void -rust_uv_hilvl_close(uv_handle_t* handle, crust_close_cb cb) { +rust_uv_hilvl_close(uv_handle_t* handle, extern_close_cb cb) { handle_data* data = (handle_data*)handle->data; data->close_cb = cb; - uv_close(handle, native_close_cb); + uv_close(handle, foreign_close_cb); } extern "C" void @@ -181,12 +181,12 @@ rust_uv_async_init(uv_loop_t* loop_handle, } extern "C" void* -rust_uv_hilvl_async_init(uv_loop_t* loop, crust_simple_cb cb, +rust_uv_hilvl_async_init(uv_loop_t* loop, extern_simple_cb cb, uint8_t* buf) { uv_async_t* async = (uv_async_t*)current_kernel_malloc( sizeof(uv_async_t), "uv_async_t"); - uv_async_init(loop, async, native_async_cb); + uv_async_init(loop, async, foreign_async_cb); handle_data* data = new_handle_data_from(buf, cb); async->data = data; @@ -194,7 +194,7 @@ rust_uv_hilvl_async_init(uv_loop_t* loop, crust_simple_cb cb, } extern "C" void* -rust_uv_hilvl_timer_init(uv_loop_t* loop, crust_simple_cb cb, +rust_uv_hilvl_timer_init(uv_loop_t* loop, extern_simple_cb cb, uint8_t* buf) { uv_timer_t* new_timer = (uv_timer_t*)current_kernel_malloc( sizeof(uv_timer_t), @@ -209,7 +209,7 @@ rust_uv_hilvl_timer_init(uv_loop_t* loop, crust_simple_cb cb, extern "C" void rust_uv_hilvl_timer_start(uv_timer_t* the_timer, uint32_t timeout, uint32_t repeat) { - uv_timer_start(the_timer, native_timer_cb, timeout, repeat); + uv_timer_start(the_timer, foreign_timer_cb, timeout, repeat); } extern "C" int -- cgit 1.4.1-3-g733a5