Skip to content

Commit c679ac8

Browse files
committed
build: fix windows build
Be very careful with forward declarations, MSVC is quite picky and rather stupid about it. Fixes nodejs#5810.
1 parent 6acde21 commit c679ac8

File tree

5 files changed

+46
-59
lines changed

5 files changed

+46
-59
lines changed

src/node.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ Local<Value> ErrnoException(int errorno,
740740
const char *path) {
741741
Local<Value> e;
742742
Local<String> estring = String::NewSymbol(errno_string(errorno));
743-
if (!msg[0]) {
743+
if (msg == NULL || msg[0] == '\0') {
744744
msg = strerror(errorno);
745745
}
746746
Local<String> message = String::NewSymbol(msg);

src/node.h

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,36 @@
6666

6767
#include "node_object_wrap.h"
6868

69+
// Forward-declare these functions now to stop MSVS from becoming
70+
// terminally confused when it's done in node_internals.h
71+
namespace node {
72+
73+
NODE_EXTERN v8::Local<v8::Value> ErrnoException(int errorno,
74+
const char* syscall = NULL,
75+
const char* message = NULL,
76+
const char* path = NULL);
77+
NODE_EXTERN v8::Local<v8::Value> UVException(int errorno,
78+
const char* syscall = NULL,
79+
const char* message = NULL,
80+
const char* path = NULL);
81+
NODE_EXTERN v8::Handle<v8::Value> MakeCallback(
82+
const v8::Handle<v8::Object> recv,
83+
const char* method,
84+
int argc,
85+
v8::Handle<v8::Value>* argv);
86+
NODE_EXTERN v8::Handle<v8::Value> MakeCallback(
87+
const v8::Handle<v8::Object> object,
88+
const v8::Handle<v8::String> symbol,
89+
int argc,
90+
v8::Handle<v8::Value>* argv);
91+
NODE_EXTERN v8::Handle<v8::Value> MakeCallback(
92+
const v8::Handle<v8::Object> object,
93+
const v8::Handle<v8::Function> callback,
94+
int argc,
95+
v8::Handle<v8::Value>* argv);
96+
97+
} // namespace node
98+
6999
#if NODE_WANT_INTERNALS
70100
# include "node_internals.h"
71101
#endif
@@ -147,16 +177,6 @@ NODE_EXTERN ssize_t DecodeWrite(char *buf,
147177
v8::Local<v8::Object> BuildStatsObject(const uv_stat_t* s);
148178

149179

150-
NODE_EXTERN v8::Local<v8::Value> ErrnoException(int errorno,
151-
const char *syscall = NULL,
152-
const char *msg = "",
153-
const char *path = NULL);
154-
155-
NODE_EXTERN v8::Local<v8::Value> UVException(int errorno,
156-
const char *syscall = NULL,
157-
const char *msg = NULL,
158-
const char *path = NULL);
159-
160180
#ifdef _WIN32
161181
NODE_EXTERN v8::Local<v8::Value> WinapiErrnoException(int errorno,
162182
const char *syscall = NULL, const char *msg = "",
@@ -217,23 +237,6 @@ node_module_struct* get_builtin_module(const char *name);
217237
NODE_EXTERN void AtExit(void (*cb)(void* arg), void* arg = 0);
218238

219239
NODE_EXTERN void SetErrno(uv_err_t err);
220-
NODE_EXTERN v8::Handle<v8::Value>
221-
MakeCallback(const v8::Handle<v8::Object> object,
222-
const char* method,
223-
int argc,
224-
v8::Handle<v8::Value> argv[]);
225-
226-
NODE_EXTERN v8::Handle<v8::Value>
227-
MakeCallback(const v8::Handle<v8::Object> object,
228-
const v8::Handle<v8::String> symbol,
229-
int argc,
230-
v8::Handle<v8::Value> argv[]);
231-
232-
NODE_EXTERN v8::Handle<v8::Value>
233-
MakeCallback(const v8::Handle<v8::Object> object,
234-
const v8::Handle<v8::Function> callback,
235-
int argc,
236-
v8::Handle<v8::Value> argv[]);
237240

238241
} // namespace node
239242

src/node_buffer.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222

2323
#include "node.h"
24-
#include "node_internals.h"
2524
#include "node_buffer.h"
2625
#include "smalloc.h"
2726
#include "string_bytes.h"

src/node_internals.h

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@
2929

3030
namespace node {
3131

32+
// Forward declarations from node_buffer.h. We can't include node_buffer.h
33+
// in this file because:
34+
//
35+
// a) we're included early on in node.h, and
36+
// b) node_buffer.h depends on the definition of the |encoding| enum that's
37+
// defined further down in node.h...
38+
namespace Buffer {
39+
40+
NODE_EXTERN char* Data(v8::Handle<v8::Value>);
41+
NODE_EXTERN char* Data(v8::Handle<v8::Object>);
42+
NODE_EXTERN size_t Length(v8::Handle<v8::Value>);
43+
NODE_EXTERN size_t Length(v8::Handle<v8::Object>);
44+
45+
} // namespace Buffer
46+
3247
// Defined in node.cc
3348
extern v8::Isolate* node_isolate;
3449

@@ -177,21 +192,13 @@ inline static void ThrowErrnoException(int errorno,
177192
const char* syscall = NULL,
178193
const char* message = NULL,
179194
const char* path = NULL) {
180-
NODE_EXTERN v8::Local<v8::Value> ErrnoException(int errorno,
181-
const char* syscall = NULL,
182-
const char* message = NULL,
183-
const char* path = NULL);
184195
v8::ThrowException(ErrnoException(errorno, syscall, message, path));
185196
}
186197

187198
inline static void ThrowUVException(int errorno,
188199
const char* syscall = NULL,
189200
const char* message = NULL,
190201
const char* path = NULL) {
191-
NODE_EXTERN v8::Local<v8::Value> UVException(int errorno,
192-
const char* syscall = NULL,
193-
const char* message = NULL,
194-
const char* path = NULL);
195202
v8::ThrowException(UVException(errorno, syscall, message, path));
196203
}
197204

@@ -309,23 +316,6 @@ inline void Cached<v8::Value>::operator=(v8::Handle<v8::Value> that) {
309316
CachedBase<v8::Value>::operator=(that);
310317
}
311318

312-
// Forward declarations, see node.h
313-
NODE_EXTERN v8::Handle<v8::Value> MakeCallback(
314-
const v8::Handle<v8::Object> recv,
315-
const char* method,
316-
int argc,
317-
v8::Handle<v8::Value>* argv);
318-
NODE_EXTERN v8::Handle<v8::Value> MakeCallback(
319-
const v8::Handle<v8::Object> object,
320-
const v8::Handle<v8::String> symbol,
321-
int argc,
322-
v8::Handle<v8::Value>* argv);
323-
NODE_EXTERN v8::Handle<v8::Value> MakeCallback(
324-
const v8::Handle<v8::Object> object,
325-
const v8::Handle<v8::Function> callback,
326-
int argc,
327-
v8::Handle<v8::Value>* argv);
328-
329319
template <typename TypeName>
330320
v8::Handle<v8::Value> MakeCallback(
331321
const v8::Persistent<v8::Object>& recv,
@@ -364,15 +354,11 @@ namespace Buffer {
364354

365355
template <typename TypeName>
366356
inline char* Data(v8::Persistent<TypeName>& val) {
367-
NODE_EXTERN char* Data(v8::Handle<v8::Value>);
368-
NODE_EXTERN char* Data(v8::Handle<v8::Object>);
369357
return Data(PersistentToLocal(val));
370358
}
371359

372360
template <typename TypeName>
373361
inline size_t Length(v8::Persistent<TypeName>& val) {
374-
NODE_EXTERN size_t Length(v8::Handle<v8::Value>);
375-
NODE_EXTERN size_t Length(v8::Handle<v8::Object>);
376362
return Length(PersistentToLocal(val));
377363
}
378364

src/req_wrap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#define REQ_WRAP_H_
2424

2525
#include "queue.h"
26-
#include "node_internals.h"
2726

2827
namespace node {
2928

0 commit comments

Comments
 (0)