Skip to content

Commit d64e510

Browse files
authored
Merge pull request #40 from jtomschroeder/add_inlines
Made functions inline to avoid 'multiple definition' errors
2 parents 5d7cde4 + 3ce50f6 commit d64e510

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

native/error.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace native
4040
uv_err_t uv_err_;
4141
};
4242

43-
error get_last_error() { return uv_last_error(uv_default_loop()); }
43+
inline error get_last_error() { return uv_last_error(uv_default_loop()); }
4444
}
4545

4646

native/fs.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace native
7373
delete req;
7474
}
7575

76-
void delete_req(uv_fs_t* req)
76+
inline void delete_req(uv_fs_t* req)
7777
{
7878
delete reinterpret_cast<callbacks*>(req->data);
7979
uv_fs_req_cleanup(req);
@@ -122,7 +122,7 @@ namespace native
122122
}
123123
}
124124

125-
bool open(const std::string& path, int flags, int mode, std::function<void(native::fs::file_handle fd, error e)> callback)
125+
inline bool open(const std::string& path, int flags, int mode, std::function<void(native::fs::file_handle fd, error e)> callback)
126126
{
127127
auto req = internal::create_req(callback);
128128
if(uv_fs_open(uv_default_loop(), req, path.c_str(), flags, mode, [](uv_fs_t* req) {
@@ -140,7 +140,7 @@ namespace native
140140
return true;
141141
}
142142

143-
bool read(file_handle fd, size_t len, off_t offset, std::function<void(const std::string& str, error e)> callback)
143+
inline bool read(file_handle fd, size_t len, off_t offset, std::function<void(const std::string& str, error e)> callback)
144144
{
145145
auto buf = new char[len];
146146
auto req = internal::create_req(callback, buf);
@@ -172,7 +172,7 @@ namespace native
172172
return true;
173173
}
174174

175-
bool write(file_handle fd, const char* buf, size_t len, off_t offset, std::function<void(int nwritten, error e)> callback)
175+
inline bool write(file_handle fd, const char* buf, size_t len, off_t offset, std::function<void(int nwritten, error e)> callback)
176176
{
177177
auto req = internal::create_req(callback);
178178

@@ -198,7 +198,7 @@ namespace native
198198
return true;
199199
}
200200

201-
bool read_to_end(file_handle fd, std::function<void(const std::string& str, error e)> callback)
201+
inline bool read_to_end(file_handle fd, std::function<void(const std::string& str, error e)> callback)
202202
{
203203
auto ctx = new internal::rte_context;
204204
ctx->file = fd;
@@ -212,7 +212,7 @@ namespace native
212212
return true;
213213
}
214214

215-
bool close(file_handle fd, std::function<void(error e)> callback)
215+
inline bool close(file_handle fd, std::function<void(error e)> callback)
216216
{
217217
auto req = internal::create_req(callback);
218218
if(uv_fs_close(uv_default_loop(), req, fd, [](uv_fs_t* req){
@@ -226,7 +226,7 @@ namespace native
226226
return true;
227227
}
228228

229-
bool unlink(const std::string& path, std::function<void(error e)> callback)
229+
inline bool unlink(const std::string& path, std::function<void(error e)> callback)
230230
{
231231
auto req = internal::create_req(callback);
232232
if(uv_fs_unlink(uv_default_loop(), req, path.c_str(), [](uv_fs_t* req){
@@ -240,7 +240,7 @@ namespace native
240240
return true;
241241
}
242242

243-
bool mkdir(const std::string& path, int mode, std::function<void(error e)> callback)
243+
inline bool mkdir(const std::string& path, int mode, std::function<void(error e)> callback)
244244
{
245245
auto req = internal::create_req(callback);
246246
if(uv_fs_mkdir(uv_default_loop(), req, path.c_str(), mode, [](uv_fs_t* req){
@@ -254,7 +254,7 @@ namespace native
254254
return true;
255255
}
256256

257-
bool rmdir(const std::string& path, std::function<void(error e)> callback)
257+
inline bool rmdir(const std::string& path, std::function<void(error e)> callback)
258258
{
259259
auto req = internal::create_req(callback);
260260
if(uv_fs_rmdir(uv_default_loop(), req, path.c_str(), [](uv_fs_t* req){
@@ -268,7 +268,7 @@ namespace native
268268
return true;
269269
}
270270

271-
bool rename(const std::string& path, const std::string& new_path, std::function<void(error e)> callback)
271+
inline bool rename(const std::string& path, const std::string& new_path, std::function<void(error e)> callback)
272272
{
273273
auto req = internal::create_req(callback);
274274
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
282282
return true;
283283
}
284284

285-
bool chmod(const std::string& path, int mode, std::function<void(error e)> callback)
285+
inline bool chmod(const std::string& path, int mode, std::function<void(error e)> callback)
286286
{
287287
auto req = internal::create_req(callback);
288288
if(uv_fs_chmod(uv_default_loop(), req, path.c_str(), mode, [](uv_fs_t* req){
@@ -296,7 +296,7 @@ namespace native
296296
return true;
297297
}
298298

299-
bool chown(const std::string& path, int uid, int gid, std::function<void(error e)> callback)
299+
inline bool chown(const std::string& path, int uid, int gid, std::function<void(error e)> callback)
300300
{
301301
auto req = internal::create_req(callback);
302302
if(uv_fs_chown(uv_default_loop(), req, path.c_str(), uid, gid, [](uv_fs_t* req){

native/handle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace native
1010
{
1111
class handle;
1212

13-
void _delete_handle(uv_handle_t* h);
13+
inline void _delete_handle(uv_handle_t* h);
1414

1515
class handle
1616
{
@@ -67,7 +67,7 @@ namespace native
6767
uv_handle_t* uv_handle_;
6868
};
6969

70-
void _delete_handle(uv_handle_t* h)
70+
inline void _delete_handle(uv_handle_t* h)
7171
{
7272
assert(h);
7373

native/http.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,17 +501,17 @@ namespace native
501501
typedef http_parser_url_fields url_fields;
502502
typedef http_errno error;
503503

504-
const char* get_error_name(error err)
504+
inline const char* get_error_name(error err)
505505
{
506506
return http_errno_name(err);
507507
}
508508

509-
const char* get_error_description(error err)
509+
inline const char* get_error_description(error err)
510510
{
511511
return http_errno_description(err);
512512
}
513513

514-
const char* get_method_name(method m)
514+
inline const char* get_method_name(method m)
515515
{
516516
return http_method_str(m);
517517
}

native/loop.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ namespace native
8686
/*!
8787
* Starts the default loop.
8888
*/
89-
int run()
89+
inline int run()
9090
{
9191
/*New libuv requires a runmode enum argument*/
9292
return uv_run(uv_default_loop(),UV_RUN_DEFAULT);
@@ -95,7 +95,7 @@ namespace native
9595
/*!
9696
* Polls for new events without blocking for the default loop.
9797
*/
98-
int run_once()
98+
inline int run_once()
9999
{
100100
/*New libuv requires a runmode argument*/
101101
return uv_run(uv_default_loop(),UV_RUN_ONCE);

native/net.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ namespace native
1111
typedef sockaddr_in ip4_addr;
1212
typedef sockaddr_in6 ip6_addr;
1313

14-
ip4_addr to_ip4_addr(const std::string& ip, int port) { return uv_ip4_addr(ip.c_str(), port); }
15-
ip6_addr to_ip6_addr(const std::string& ip, int port) { return uv_ip6_addr(ip.c_str(), port); }
14+
inline ip4_addr to_ip4_addr(const std::string& ip, int port) { return uv_ip4_addr(ip.c_str(), port); }
15+
inline ip6_addr to_ip6_addr(const std::string& ip, int port) { return uv_ip6_addr(ip.c_str(), port); }
1616

17-
bool from_ip4_addr(ip4_addr* src, std::string& ip, int& port)
17+
inline bool from_ip4_addr(ip4_addr* src, std::string& ip, int& port)
1818
{
1919
char dest[16];
2020
if(uv_ip4_name(src, dest, 16) == 0)
@@ -26,7 +26,7 @@ namespace native
2626
return false;
2727
}
2828

29-
bool from_ip6_addr(ip6_addr* src, std::string& ip, int& port)
29+
inline bool from_ip6_addr(ip6_addr* src, std::string& ip, int& port)
3030
{
3131
char dest[46];
3232
if(uv_ip6_name(src, dest, 46) == 0)

0 commit comments

Comments
 (0)