From 3ce50f60f32b5f49a53b315a12cb25ab7f5d738c Mon Sep 17 00:00:00 2001 From: Tom Schroeder Date: Mon, 2 Feb 2015 11:25:01 -0600 Subject: [PATCH] Made functions inline to avoid 'multiple definition' errors --- native/error.h | 2 +- native/fs.h | 24 ++++++++++++------------ native/handle.h | 4 ++-- native/http.h | 6 +++--- native/loop.h | 4 ++-- native/net.h | 8 ++++---- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/native/error.h b/native/error.h index f499cb22..996b080b 100644 --- a/native/error.h +++ b/native/error.h @@ -40,7 +40,7 @@ namespace native uv_err_t uv_err_; }; - error get_last_error() { return uv_last_error(uv_default_loop()); } + inline error get_last_error() { return uv_last_error(uv_default_loop()); } } diff --git a/native/fs.h b/native/fs.h index 82e99ec8..80248fe3 100644 --- a/native/fs.h +++ b/native/fs.h @@ -73,7 +73,7 @@ namespace native delete req; } - void delete_req(uv_fs_t* req) + inline void delete_req(uv_fs_t* req) { delete reinterpret_cast(req->data); uv_fs_req_cleanup(req); @@ -122,7 +122,7 @@ namespace native } } - bool open(const std::string& path, int flags, int mode, std::function callback) + inline bool open(const std::string& path, int flags, int mode, std::function callback) { auto req = internal::create_req(callback); if(uv_fs_open(uv_default_loop(), req, path.c_str(), flags, mode, [](uv_fs_t* req) { @@ -140,7 +140,7 @@ namespace native return true; } - bool read(file_handle fd, size_t len, off_t offset, std::function callback) + inline bool read(file_handle fd, size_t len, off_t offset, std::function callback) { auto buf = new char[len]; auto req = internal::create_req(callback, buf); @@ -172,7 +172,7 @@ namespace native return true; } - bool write(file_handle fd, const char* buf, size_t len, off_t offset, std::function callback) + inline bool write(file_handle fd, const char* buf, size_t len, off_t offset, std::function callback) { auto req = internal::create_req(callback); @@ -198,7 +198,7 @@ namespace native return true; } - bool read_to_end(file_handle fd, std::function callback) + inline bool read_to_end(file_handle fd, std::function callback) { auto ctx = new internal::rte_context; ctx->file = fd; @@ -212,7 +212,7 @@ namespace native return true; } - bool close(file_handle fd, std::function callback) + inline bool close(file_handle fd, std::function callback) { auto req = internal::create_req(callback); if(uv_fs_close(uv_default_loop(), req, fd, [](uv_fs_t* req){ @@ -226,7 +226,7 @@ namespace native return true; } - bool unlink(const std::string& path, std::function callback) + inline bool unlink(const std::string& path, std::function callback) { auto req = internal::create_req(callback); if(uv_fs_unlink(uv_default_loop(), req, path.c_str(), [](uv_fs_t* req){ @@ -240,7 +240,7 @@ namespace native return true; } - bool mkdir(const std::string& path, int mode, std::function callback) + inline bool mkdir(const std::string& path, int mode, std::function callback) { auto req = internal::create_req(callback); if(uv_fs_mkdir(uv_default_loop(), req, path.c_str(), mode, [](uv_fs_t* req){ @@ -254,7 +254,7 @@ namespace native return true; } - bool rmdir(const std::string& path, std::function callback) + inline bool rmdir(const std::string& path, std::function callback) { auto req = internal::create_req(callback); if(uv_fs_rmdir(uv_default_loop(), req, path.c_str(), [](uv_fs_t* req){ @@ -268,7 +268,7 @@ namespace native return true; } - bool rename(const std::string& path, const std::string& new_path, std::function callback) + inline bool rename(const std::string& path, const std::string& new_path, std::function callback) { auto req = internal::create_req(callback); if(uv_fs_rename(uv_default_loop(), req, path.c_str(), new_path.c_str(), [](uv_fs_t* req){ @@ -282,7 +282,7 @@ namespace native return true; } - bool chmod(const std::string& path, int mode, std::function callback) + inline bool chmod(const std::string& path, int mode, std::function callback) { auto req = internal::create_req(callback); if(uv_fs_chmod(uv_default_loop(), req, path.c_str(), mode, [](uv_fs_t* req){ @@ -296,7 +296,7 @@ namespace native return true; } - bool chown(const std::string& path, int uid, int gid, std::function callback) + inline bool chown(const std::string& path, int uid, int gid, std::function callback) { auto req = internal::create_req(callback); if(uv_fs_chown(uv_default_loop(), req, path.c_str(), uid, gid, [](uv_fs_t* req){ diff --git a/native/handle.h b/native/handle.h index 70549120..1becc8ac 100644 --- a/native/handle.h +++ b/native/handle.h @@ -10,7 +10,7 @@ namespace native { class handle; - void _delete_handle(uv_handle_t* h); + inline void _delete_handle(uv_handle_t* h); class handle { @@ -67,7 +67,7 @@ namespace native uv_handle_t* uv_handle_; }; - void _delete_handle(uv_handle_t* h) + inline void _delete_handle(uv_handle_t* h) { assert(h); diff --git a/native/http.h b/native/http.h index a7d2da15..1c0dcaf1 100644 --- a/native/http.h +++ b/native/http.h @@ -501,17 +501,17 @@ namespace native typedef http_parser_url_fields url_fields; typedef http_errno error; - const char* get_error_name(error err) + inline const char* get_error_name(error err) { return http_errno_name(err); } - const char* get_error_description(error err) + inline const char* get_error_description(error err) { return http_errno_description(err); } - const char* get_method_name(method m) + inline const char* get_method_name(method m) { return http_method_str(m); } diff --git a/native/loop.h b/native/loop.h index 5b0ffc33..5e4897c0 100644 --- a/native/loop.h +++ b/native/loop.h @@ -86,7 +86,7 @@ namespace native /*! * Starts the default loop. */ - int run() + inline int run() { /*New libuv requires a runmode enum argument*/ return uv_run(uv_default_loop(),UV_RUN_DEFAULT); @@ -95,7 +95,7 @@ namespace native /*! * Polls for new events without blocking for the default loop. */ - int run_once() + inline int run_once() { /*New libuv requires a runmode argument*/ return uv_run(uv_default_loop(),UV_RUN_ONCE); diff --git a/native/net.h b/native/net.h index a1238a21..55b7b9ca 100644 --- a/native/net.h +++ b/native/net.h @@ -11,10 +11,10 @@ namespace native typedef sockaddr_in ip4_addr; typedef sockaddr_in6 ip6_addr; - ip4_addr to_ip4_addr(const std::string& ip, int port) { return uv_ip4_addr(ip.c_str(), port); } - ip6_addr to_ip6_addr(const std::string& ip, int port) { return uv_ip6_addr(ip.c_str(), port); } + inline ip4_addr to_ip4_addr(const std::string& ip, int port) { return uv_ip4_addr(ip.c_str(), port); } + inline ip6_addr to_ip6_addr(const std::string& ip, int port) { return uv_ip6_addr(ip.c_str(), port); } - bool from_ip4_addr(ip4_addr* src, std::string& ip, int& port) + inline bool from_ip4_addr(ip4_addr* src, std::string& ip, int& port) { char dest[16]; if(uv_ip4_name(src, dest, 16) == 0) @@ -26,7 +26,7 @@ namespace native return false; } - bool from_ip6_addr(ip6_addr* src, std::string& ip, int& port) + inline bool from_ip6_addr(ip6_addr* src, std::string& ip, int& port) { char dest[46]; if(uv_ip6_name(src, dest, 46) == 0)