]>
Commit | Line | Data |
---|---|---|
be62a70f ER |
1 | From a9e60792a9c4044e29ec7bbb88419d9283044b86 Mon Sep 17 00:00:00 2001 |
2 | From: "T.C. Hollingsworth" <tchollingsworth@gmail.com> | |
3 | Date: Wed, 18 Jun 2014 23:19:19 -0700 | |
4 | Subject: [PATCH] Revert "src: replace usage of String::Utf8Value" | |
5 | ||
6 | This reverts commit 535c7777ac674ba86cf93c44824e07b0e23ea8c4. | |
7 | --- | |
8 | src/cares_wrap.cc | 8 ++--- | |
9 | src/fs_event_wrap.cc | 3 +- | |
10 | src/node.cc | 42 +++++++++++++------------- | |
11 | src/node_crypto.cc | 31 ++++++++++--------- | |
12 | src/node_dtrace.cc | 6 ++-- | |
13 | src/node_file.cc | 37 +++++++++++------------ | |
14 | src/node_stat_watcher.cc | 3 +- | |
15 | src/process_wrap.cc | 9 +++--- | |
16 | src/udp_wrap.cc | 9 +++--- | |
17 | src/util.h | 78 ------------------------------------------------ | |
18 | 10 files changed, 68 insertions(+), 158 deletions(-) | |
19 | delete mode 100644 src/util.h | |
20 | ||
21 | diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc | |
22 | index 321e144..b7ba828 100644 | |
23 | --- a/src/cares_wrap.cc | |
24 | +++ b/src/cares_wrap.cc | |
25 | @@ -31,8 +31,6 @@ | |
26 | #include "tree.h" | |
27 | #include "uv.h" | |
28 | ||
29 | -#include "util.h" | |
30 | - | |
31 | #if defined(__OpenBSD__) || defined(__MINGW32__) || defined(_MSC_VER) | |
32 | # include <nameser.h> | |
33 | #else | |
34 | @@ -741,7 +739,7 @@ static Handle<Value> Query(const Arguments& args) { | |
35 | // object reference, causing wrap->GetObject() to return undefined. | |
36 | Local<Object> object = Local<Object>::New(wrap->GetObject()); | |
37 | ||
38 | - node::Utf8Value name(args[0]); | |
39 | + String::Utf8Value name(args[0]); | |
40 | ||
41 | int r = wrap->Send(*name); | |
42 | if (r) { | |
43 | @@ -770,7 +768,7 @@ static Handle<Value> QueryWithFamily(const Arguments& args) { | |
44 | // object reference, causing wrap->GetObject() to return undefined. | |
45 | Local<Object> object = Local<Object>::New(wrap->GetObject()); | |
46 | ||
47 | - node::Utf8Value name(args[0]); | |
48 | + String::Utf8Value name(args[0]); | |
49 | int family = args[1]->Int32Value(); | |
50 | ||
51 | int r = wrap->Send(*name, family); | |
52 | @@ -900,7 +898,7 @@ static Handle<Value> IsIP(const Arguments& args) { | |
53 | static Handle<Value> GetAddrInfo(const Arguments& args) { | |
54 | HandleScope scope; | |
55 | ||
56 | - node::Utf8Value hostname(args[0]); | |
57 | + String::Utf8Value hostname(args[0]); | |
58 | ||
59 | int fam = AF_UNSPEC; | |
60 | if (args[1]->IsInt32()) { | |
61 | diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc | |
62 | index fc54283..7e3eb8c 100644 | |
63 | --- a/src/fs_event_wrap.cc | |
64 | +++ b/src/fs_event_wrap.cc | |
65 | @@ -21,7 +21,6 @@ | |
66 | ||
67 | #include "node.h" | |
68 | #include "handle_wrap.h" | |
69 | -#include "util.h" | |
70 | ||
71 | #include <stdlib.h> | |
72 | ||
73 | @@ -98,7 +97,7 @@ Handle<Value> FSEventWrap::Start(const Arguments& args) { | |
74 | return ThrowException(Exception::TypeError(String::New("Bad arguments"))); | |
75 | } | |
76 | ||
77 | - node::Utf8Value path(args[0]); | |
78 | + String::Utf8Value path(args[0]); | |
79 | ||
80 | int r = uv_fs_event_init(uv_default_loop(), &wrap->handle_, *path, OnEvent, 0); | |
81 | if (r == 0) { | |
82 | diff --git a/src/node.cc b/src/node.cc | |
83 | index e9696cd..8257604 100644 | |
84 | --- a/src/node.cc | |
85 | +++ b/src/node.cc | |
86 | @@ -82,8 +82,6 @@ typedef int mode_t; | |
87 | #include "node_script.h" | |
88 | #include "v8_typed_array.h" | |
89 | ||
90 | -#include "util.h" | |
91 | - | |
92 | using namespace v8; | |
93 | ||
94 | # ifdef __APPLE__ | |
95 | @@ -1102,7 +1100,7 @@ enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) { | |
96 | ||
97 | if (!encoding_v->IsString()) return _default; | |
98 | ||
99 | - node::Utf8Value encoding(encoding_v); | |
100 | + String::Utf8Value encoding(encoding_v); | |
101 | ||
102 | if (strcasecmp(*encoding, "utf8") == 0) { | |
103 | return UTF8; | |
104 | @@ -1202,12 +1200,12 @@ void DisplayExceptionLine (TryCatch &try_catch) { | |
105 | ||
106 | if (!message.IsEmpty()) { | |
107 | // Print (filename):(line number): (message). | |
108 | - node::Utf8Value filename(message->GetScriptResourceName()); | |
109 | + String::Utf8Value filename(message->GetScriptResourceName()); | |
110 | const char* filename_string = *filename; | |
111 | int linenum = message->GetLineNumber(); | |
112 | fprintf(stderr, "%s:%i\n", filename_string, linenum); | |
113 | // Print line of source code. | |
114 | - node::Utf8Value sourceline(message->GetSourceLine()); | |
115 | + String::Utf8Value sourceline(message->GetSourceLine()); | |
116 | const char* sourceline_string = *sourceline; | |
117 | ||
118 | // Because of how node modules work, all scripts are wrapped with a | |
119 | @@ -1254,7 +1252,7 @@ static void ReportException(TryCatch &try_catch, bool show_line) { | |
120 | ||
121 | if (show_line) DisplayExceptionLine(try_catch); | |
122 | ||
123 | - node::Utf8Value trace(try_catch.StackTrace()); | |
124 | + String::Utf8Value trace(try_catch.StackTrace()); | |
125 | ||
126 | // range errors have a trace member set to undefined | |
127 | if (trace.length() > 0 && !try_catch.StackTrace()->IsUndefined()) { | |
128 | @@ -1269,11 +1267,11 @@ static void ReportException(TryCatch &try_catch, bool show_line) { | |
129 | !(er->ToObject()->Get(String::New("name"))->IsUndefined()); | |
130 | ||
131 | if (isErrorObject) { | |
132 | - node::Utf8Value name(er->ToObject()->Get(String::New("name"))); | |
133 | + String::Utf8Value name(er->ToObject()->Get(String::New("name"))); | |
134 | fprintf(stderr, "%s: ", *name); | |
135 | } | |
136 | ||
137 | - node::Utf8Value msg(!isErrorObject ? er | |
138 | + String::Utf8Value msg(!isErrorObject ? er | |
139 | : er->ToObject()->Get(String::New("message"))); | |
140 | fprintf(stderr, "%s\n", *msg); | |
141 | } | |
142 | @@ -1355,7 +1353,7 @@ static Handle<Value> Chdir(const Arguments& args) { | |
143 | return ThrowException(Exception::Error(String::New("Bad argument."))); | |
144 | } | |
145 | ||
146 | - node::Utf8Value path(args[0]); | |
147 | + String::Utf8Value path(args[0]); | |
148 | ||
149 | uv_err_t r = uv_chdir(*path); | |
150 | ||
151 | @@ -1406,7 +1404,7 @@ static Handle<Value> Umask(const Arguments& args) { | |
152 | oct = args[0]->Uint32Value(); | |
153 | } else { | |
154 | oct = 0; | |
155 | - node::Utf8Value str(args[0]); | |
156 | + String::Utf8Value str(args[0]); | |
157 | ||
158 | // Parse the octal string. | |
159 | for (int i = 0; i < str.length(); i++) { | |
160 | @@ -1512,7 +1510,7 @@ static uid_t uid_by_name(Handle<Value> value) { | |
161 | if (value->IsUint32()) { | |
162 | return static_cast<uid_t>(value->Uint32Value()); | |
163 | } else { | |
164 | - node::Utf8Value name(value); | |
165 | + String::Utf8Value name(value); | |
166 | return uid_by_name(*name); | |
167 | } | |
168 | } | |
169 | @@ -1522,7 +1520,7 @@ static gid_t gid_by_name(Handle<Value> value) { | |
170 | if (value->IsUint32()) { | |
171 | return static_cast<gid_t>(value->Uint32Value()); | |
172 | } else { | |
173 | - node::Utf8Value name(value); | |
174 | + String::Utf8Value name(value); | |
175 | return gid_by_name(*name); | |
176 | } | |
177 | } | |
178 | @@ -1665,7 +1663,7 @@ static Handle<Value> InitGroups(const Arguments& args) { | |
179 | return ThrowTypeError("argument 2 must be a number or a string"); | |
180 | } | |
181 | ||
182 | - node::Utf8Value arg0(args[0]); | |
183 | + String::Utf8Value arg0(args[0]); | |
184 | gid_t extra_group; | |
185 | bool must_free; | |
186 | char* user; | |
187 | @@ -1826,7 +1824,7 @@ Handle<Value> DLOpen(const v8::Arguments& args) { | |
188 | } | |
189 | ||
190 | Local<Object> module = args[0]->ToObject(); // Cast | |
191 | - node::Utf8Value filename(args[1]); // Cast | |
192 | + String::Utf8Value filename(args[1]); // Cast | |
193 | ||
194 | if (exports_symbol.IsEmpty()) { | |
195 | exports_symbol = NODE_PSYMBOL("exports"); | |
196 | @@ -1842,7 +1840,7 @@ Handle<Value> DLOpen(const v8::Arguments& args) { | |
197 | return ThrowException(Exception::Error(errmsg)); | |
198 | } | |
199 | ||
200 | - node::Utf8Value path(args[1]); | |
201 | + String::Utf8Value path(args[1]); | |
202 | base = *path; | |
203 | ||
204 | /* Find the shared library filename within the full path. */ | |
205 | @@ -1961,7 +1959,7 @@ static Handle<Value> Binding(const Arguments& args) { | |
206 | HandleScope scope; | |
207 | ||
208 | Local<String> module = args[0]->ToString(); | |
209 | - node::Utf8Value module_v(module); | |
210 | + String::Utf8Value module_v(module); | |
211 | node_module_struct* modp; | |
212 | ||
213 | if (binding_cache.IsEmpty()) { | |
214 | @@ -2020,7 +2018,7 @@ static void ProcessTitleSetter(Local<String> property, | |
215 | Local<Value> value, | |
216 | const AccessorInfo& info) { | |
217 | HandleScope scope; | |
218 | - node::Utf8Value title(value); | |
219 | + String::Utf8Value title(value); | |
220 | // TODO: protect with a lock | |
221 | uv_set_process_title(*title); | |
222 | } | |
223 | @@ -2030,7 +2028,7 @@ static Handle<Value> EnvGetter(Local<String> property, | |
224 | const AccessorInfo& info) { | |
225 | HandleScope scope; | |
226 | #ifdef __POSIX__ | |
227 | - node::Utf8Value key(property); | |
228 | + String::Utf8Value key(property); | |
229 | const char* val = getenv(*key); | |
230 | if (val) { | |
231 | return scope.Close(String::New(val)); | |
232 | @@ -2059,8 +2057,8 @@ static Handle<Value> EnvSetter(Local<String> property, | |
233 | const AccessorInfo& info) { | |
234 | HandleScope scope; | |
235 | #ifdef __POSIX__ | |
236 | - node::Utf8Value key(property); | |
237 | - node::Utf8Value val(value); | |
238 | + String::Utf8Value key(property); | |
239 | + String::Utf8Value val(value); | |
240 | setenv(*key, *val, 1); | |
241 | #else // _WIN32 | |
242 | String::Value key(property); | |
243 | @@ -2080,7 +2078,7 @@ static Handle<Integer> EnvQuery(Local<String> property, | |
244 | const AccessorInfo& info) { | |
245 | HandleScope scope; | |
246 | #ifdef __POSIX__ | |
247 | - node::Utf8Value key(property); | |
248 | + String::Utf8Value key(property); | |
249 | if (getenv(*key)) { | |
250 | return scope.Close(Integer::New(0)); | |
251 | } | |
252 | @@ -2108,7 +2106,7 @@ static Handle<Boolean> EnvDeleter(Local<String> property, | |
253 | const AccessorInfo& info) { | |
254 | HandleScope scope; | |
255 | #ifdef __POSIX__ | |
256 | - node::Utf8Value key(property); | |
257 | + String::Utf8Value key(property); | |
258 | if (!getenv(*key)) return False(); | |
259 | unsetenv(*key); // can't check return value, it's void on some platforms | |
260 | return True(); | |
261 | diff --git a/src/node_crypto.cc b/src/node_crypto.cc | |
262 | index 46faba2..0ae1f8a 100644 | |
263 | --- a/src/node_crypto.cc | |
264 | +++ b/src/node_crypto.cc | |
265 | @@ -26,7 +26,6 @@ | |
266 | #include "node.h" | |
267 | #include "node_buffer.h" | |
268 | #include "string_bytes.h" | |
269 | -#include "util.h" | |
270 | ||
271 | #include <string.h> | |
272 | #ifdef _MSC_VER | |
273 | @@ -242,7 +241,7 @@ Handle<Value> SecureContext::Init(const Arguments& args) { | |
274 | OPENSSL_CONST SSL_METHOD *method = SSLv23_method(); | |
275 | ||
276 | if (args.Length() == 1 && args[0]->IsString()) { | |
277 | - node::Utf8Value sslmethod(args[0]); | |
278 | + String::Utf8Value sslmethod(args[0]); | |
279 | ||
280 | if (strcmp(*sslmethod, "SSLv2_method") == 0) { | |
281 | #ifndef OPENSSL_NO_SSL2 | |
282 | @@ -362,7 +361,7 @@ static BIO* LoadBIO (Handle<Value> v) { | |
283 | int r = -1; | |
284 | ||
285 | if (v->IsString()) { | |
286 | - node::Utf8Value s(v); | |
287 | + String::Utf8Value s(v); | |
288 | r = BIO_write(bio, *s, s.length()); | |
289 | } else if (Buffer::HasInstance(v)) { | |
290 | char* buffer_data = Buffer::Data(v); | |
291 | @@ -414,7 +413,7 @@ Handle<Value> SecureContext::SetKey(const Arguments& args) { | |
292 | BIO *bio = LoadBIO(args[0]); | |
293 | if (!bio) return False(); | |
294 | ||
295 | - node::Utf8Value passphrase(args[1]); | |
296 | + String::Utf8Value passphrase(args[1]); | |
297 | ||
298 | EVP_PKEY* key = PEM_read_bio_PrivateKey(bio, NULL, NULL, | |
299 | len == 1 ? NULL : *passphrase); | |
300 | @@ -644,7 +643,7 @@ Handle<Value> SecureContext::SetCiphers(const Arguments& args) { | |
301 | return ThrowException(Exception::TypeError(String::New("Bad parameter"))); | |
302 | } | |
303 | ||
304 | - node::Utf8Value ciphers(args[0]); | |
305 | + String::Utf8Value ciphers(args[0]); | |
306 | SSL_CTX_set_cipher_list(sc->ctx_, *ciphers); | |
307 | ||
308 | return True(); | |
309 | @@ -673,7 +672,7 @@ Handle<Value> SecureContext::SetSessionIdContext(const Arguments& args) { | |
310 | return ThrowException(Exception::TypeError(String::New("Bad parameter"))); | |
311 | } | |
312 | ||
313 | - node::Utf8Value sessionIdContext(args[0]); | |
314 | + String::Utf8Value sessionIdContext(args[0]); | |
315 | const unsigned char* sid_ctx = (const unsigned char*) *sessionIdContext; | |
316 | unsigned int sid_ctx_len = sessionIdContext.length(); | |
317 | ||
318 | @@ -1281,7 +1280,7 @@ Handle<Value> Connection::New(const Arguments& args) { | |
319 | if (is_server) { | |
320 | SSL_CTX_set_tlsext_servername_callback(sc->ctx_, SelectSNIContextCallback_); | |
321 | } else { | |
322 | - node::Utf8Value servername(args[2]); | |
323 | + String::Utf8Value servername(args[2]); | |
324 | SSL_set_tlsext_host_name(p->ssl_, *servername); | |
325 | } | |
326 | #endif | |
327 | @@ -2234,7 +2233,7 @@ class Cipher : public ObjectWrap { | |
328 | ssize_t key_written = DecodeWrite(key_buf, key_buf_len, args[1], BINARY); | |
329 | assert(key_written == key_buf_len); | |
330 | ||
331 | - node::Utf8Value cipherType(args[0]); | |
332 | + String::Utf8Value cipherType(args[0]); | |
333 | ||
334 | bool r = cipher->CipherInit(*cipherType, key_buf, key_buf_len); | |
335 | ||
336 | @@ -2285,7 +2284,7 @@ class Cipher : public ObjectWrap { | |
337 | ssize_t iv_written = DecodeWrite(iv_buf, iv_len, args[2], BINARY); | |
338 | assert(iv_written == iv_len); | |
339 | ||
340 | - node::Utf8Value cipherType(args[0]); | |
341 | + String::Utf8Value cipherType(args[0]); | |
342 | ||
343 | bool r = cipher->CipherInitIv(*cipherType, key_buf,key_len,iv_buf,iv_len); | |
344 | ||
345 | @@ -2544,7 +2543,7 @@ class Decipher : public ObjectWrap { | |
346 | ssize_t key_written = DecodeWrite(key_buf, key_len, args[1], BINARY); | |
347 | assert(key_written == key_len); | |
348 | ||
349 | - node::Utf8Value cipherType(args[0]); | |
350 | + String::Utf8Value cipherType(args[0]); | |
351 | ||
352 | bool r = cipher->DecipherInit(*cipherType, key_buf,key_len); | |
353 | ||
354 | @@ -2595,7 +2594,7 @@ class Decipher : public ObjectWrap { | |
355 | ssize_t iv_written = DecodeWrite(iv_buf, iv_len, args[2], BINARY); | |
356 | assert(iv_written == iv_len); | |
357 | ||
358 | - node::Utf8Value cipherType(args[0]); | |
359 | + String::Utf8Value cipherType(args[0]); | |
360 | ||
361 | bool r = cipher->DecipherInitIv(*cipherType, key_buf,key_len,iv_buf,iv_len); | |
362 | ||
363 | @@ -2776,7 +2775,7 @@ class Hmac : public ObjectWrap { | |
364 | return ThrowException(exception); | |
365 | } | |
366 | ||
367 | - node::Utf8Value hashType(args[0]); | |
368 | + String::Utf8Value hashType(args[0]); | |
369 | ||
370 | bool r; | |
371 | ||
372 | @@ -2921,7 +2920,7 @@ class Hash : public ObjectWrap { | |
373 | "Must give hashtype string as argument"))); | |
374 | } | |
375 | ||
376 | - node::Utf8Value hashType(args[0]); | |
377 | + String::Utf8Value hashType(args[0]); | |
378 | ||
379 | Hash *hash = new Hash(); | |
380 | if (!hash->HashInit(*hashType)) { | |
381 | @@ -3095,7 +3094,7 @@ class Sign : public ObjectWrap { | |
382 | "Must give signtype string as argument"))); | |
383 | } | |
384 | ||
385 | - node::Utf8Value signType(args[0]); | |
386 | + String::Utf8Value signType(args[0]); | |
387 | ||
388 | bool r = sign->SignInit(*signType); | |
389 | ||
390 | @@ -3328,7 +3327,7 @@ class Verify : public ObjectWrap { | |
391 | "Must give verifytype string as argument"))); | |
392 | } | |
393 | ||
394 | - node::Utf8Value verifyType(args[0]); | |
395 | + String::Utf8Value verifyType(args[0]); | |
396 | ||
397 | bool r = verify->VerifyInit(*verifyType); | |
398 | ||
399 | @@ -3511,7 +3510,7 @@ class DiffieHellman : public ObjectWrap { | |
400 | String::New("No group name given"))); | |
401 | } | |
402 | ||
403 | - node::Utf8Value group_name(args[0]); | |
404 | + String::Utf8Value group_name(args[0]); | |
405 | ||
406 | modp_group* it = modp_groups; | |
407 | ||
408 | diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc | |
409 | index 0b2d0f4..4b851e3 100644 | |
410 | --- a/src/node_dtrace.cc | |
411 | +++ b/src/node_dtrace.cc | |
412 | @@ -20,8 +20,6 @@ | |
413 | // USE OR OTHER DEALINGS IN THE SOFTWARE. | |
414 | ||
415 | ||
416 | -#include "util.h" | |
417 | - | |
418 | #ifdef HAVE_DTRACE | |
419 | #include "node_dtrace.h" | |
420 | #include <string.h> | |
421 | @@ -68,7 +66,7 @@ using namespace v8; | |
422 | return (ThrowException(Exception::Error(String::New("expected " \ | |
423 | "object for " #obj " to contain string member " #member)))); \ | |
424 | } \ | |
425 | - node::Utf8Value _##member(obj->Get(String::New(#member))); \ | |
426 | + String::Utf8Value _##member(obj->Get(String::New(#member))); \ | |
427 | if ((*(const char **)valp = *_##member) == NULL) \ | |
428 | *(const char **)valp = "<unknown>"; | |
429 | ||
430 | @@ -243,7 +241,7 @@ Handle<Value> DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) { | |
431 | "object for request to contain string member headers")))); | |
432 | ||
433 | Local<Value> strfwdfor = headers->Get(String::New("x-forwarded-for")); | |
434 | - node::Utf8Value fwdfor(strfwdfor); | |
435 | + String::Utf8Value fwdfor(strfwdfor); | |
436 | ||
437 | if (!strfwdfor->IsString() || (req.forwardedFor = *fwdfor) == NULL) | |
438 | req.forwardedFor = const_cast<char*>(""); | |
439 | diff --git a/src/node_file.cc b/src/node_file.cc | |
440 | index 3c35e0b..f665b19 100644 | |
441 | --- a/src/node_file.cc | |
442 | +++ b/src/node_file.cc | |
443 | @@ -24,7 +24,6 @@ | |
444 | #include "node_buffer.h" | |
445 | #include "node_stat_watcher.h" | |
446 | #include "req_wrap.h" | |
447 | -#include "util.h" | |
448 | ||
449 | #include <fcntl.h> | |
450 | #include <sys/types.h> | |
451 | @@ -404,7 +403,7 @@ static Handle<Value> Stat(const Arguments& args) { | |
452 | if (args.Length() < 1) return TYPE_ERROR("path required"); | |
453 | if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); | |
454 | ||
455 | - node::Utf8Value path(args[0]); | |
456 | + String::Utf8Value path(args[0]); | |
457 | ||
458 | if (args[1]->IsFunction()) { | |
459 | ASYNC_CALL(stat, args[1], *path) | |
460 | @@ -421,7 +420,7 @@ static Handle<Value> LStat(const Arguments& args) { | |
461 | if (args.Length() < 1) return TYPE_ERROR("path required"); | |
462 | if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); | |
463 | ||
464 | - node::Utf8Value path(args[0]); | |
465 | + String::Utf8Value path(args[0]); | |
466 | ||
467 | if (args[1]->IsFunction()) { | |
468 | ASYNC_CALL(lstat, args[1], *path) | |
469 | @@ -459,12 +458,12 @@ static Handle<Value> Symlink(const Arguments& args) { | |
470 | if (!args[0]->IsString()) return TYPE_ERROR("dest path must be a string"); | |
471 | if (!args[1]->IsString()) return TYPE_ERROR("src path must be a string"); | |
472 | ||
473 | - node::Utf8Value dest(args[0]); | |
474 | - node::Utf8Value path(args[1]); | |
475 | + String::Utf8Value dest(args[0]); | |
476 | + String::Utf8Value path(args[1]); | |
477 | int flags = 0; | |
478 | ||
479 | if (args[2]->IsString()) { | |
480 | - node::Utf8Value mode(args[2]); | |
481 | + String::Utf8Value mode(args[2]); | |
482 | if (strcmp(*mode, "dir") == 0) { | |
483 | flags |= UV_FS_SYMLINK_DIR; | |
484 | } else if (strcmp(*mode, "junction") == 0) { | |
485 | @@ -492,8 +491,8 @@ static Handle<Value> Link(const Arguments& args) { | |
486 | if (!args[0]->IsString()) return TYPE_ERROR("dest path must be a string"); | |
487 | if (!args[1]->IsString()) return TYPE_ERROR("src path must be a string"); | |
488 | ||
489 | - node::Utf8Value orig_path(args[0]); | |
490 | - node::Utf8Value new_path(args[1]); | |
491 | + String::Utf8Value orig_path(args[0]); | |
492 | + String::Utf8Value new_path(args[1]); | |
493 | ||
494 | if (args[2]->IsFunction()) { | |
495 | ASYNC_DEST_CALL(link, args[2], *new_path, *orig_path, *new_path) | |
496 | @@ -509,7 +508,7 @@ static Handle<Value> ReadLink(const Arguments& args) { | |
497 | if (args.Length() < 1) return TYPE_ERROR("path required"); | |
498 | if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); | |
499 | ||
500 | - node::Utf8Value path(args[0]); | |
501 | + String::Utf8Value path(args[0]); | |
502 | ||
503 | if (args[1]->IsFunction()) { | |
504 | ASYNC_CALL(readlink, args[1], *path) | |
505 | @@ -528,8 +527,8 @@ static Handle<Value> Rename(const Arguments& args) { | |
506 | if (!args[0]->IsString()) return TYPE_ERROR("old path must be a string"); | |
507 | if (!args[1]->IsString()) return TYPE_ERROR("new path must be a string"); | |
508 | ||
509 | - node::Utf8Value old_path(args[0]); | |
510 | - node::Utf8Value new_path(args[1]); | |
511 | + String::Utf8Value old_path(args[0]); | |
512 | + String::Utf8Value new_path(args[1]); | |
513 | ||
514 | if (args[2]->IsFunction()) { | |
515 | ASYNC_DEST_CALL(rename, args[2], *new_path, *old_path, *new_path) | |
516 | @@ -599,7 +598,7 @@ static Handle<Value> Unlink(const Arguments& args) { | |
517 | if (args.Length() < 1) return TYPE_ERROR("path required"); | |
518 | if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); | |
519 | ||
520 | - node::Utf8Value path(args[0]); | |
521 | + String::Utf8Value path(args[0]); | |
522 | ||
523 | if (args[1]->IsFunction()) { | |
524 | ASYNC_CALL(unlink, args[1], *path) | |
525 | @@ -615,7 +614,7 @@ static Handle<Value> RMDir(const Arguments& args) { | |
526 | if (args.Length() < 1) return TYPE_ERROR("path required"); | |
527 | if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); | |
528 | ||
529 | - node::Utf8Value path(args[0]); | |
530 | + String::Utf8Value path(args[0]); | |
531 | ||
532 | if (args[1]->IsFunction()) { | |
533 | ASYNC_CALL(rmdir, args[1], *path) | |
534 | @@ -632,7 +631,7 @@ static Handle<Value> MKDir(const Arguments& args) { | |
535 | return THROW_BAD_ARGS; | |
536 | } | |
537 | ||
538 | - node::Utf8Value path(args[0]); | |
539 | + String::Utf8Value path(args[0]); | |
540 | int mode = static_cast<int>(args[1]->Int32Value()); | |
541 | ||
542 | if (args[2]->IsFunction()) { | |
543 | @@ -649,7 +648,7 @@ static Handle<Value> ReadDir(const Arguments& args) { | |
544 | if (args.Length() < 1) return TYPE_ERROR("path required"); | |
545 | if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); | |
546 | ||
547 | - node::Utf8Value path(args[0]); | |
548 | + String::Utf8Value path(args[0]); | |
549 | ||
550 | if (args[1]->IsFunction()) { | |
551 | ASYNC_CALL(readdir, args[1], *path, 0 /*flags*/) | |
552 | @@ -687,7 +686,7 @@ static Handle<Value> Open(const Arguments& args) { | |
553 | if (!args[1]->IsInt32()) return TYPE_ERROR("flags must be an int"); | |
554 | if (!args[2]->IsInt32()) return TYPE_ERROR("mode must be an int"); | |
555 | ||
556 | - node::Utf8Value path(args[0]); | |
557 | + String::Utf8Value path(args[0]); | |
558 | int flags = args[1]->Int32Value(); | |
559 | int mode = static_cast<int>(args[2]->Int32Value()); | |
560 | ||
561 | @@ -827,7 +826,7 @@ static Handle<Value> Chmod(const Arguments& args) { | |
562 | if(args.Length() < 2 || !args[0]->IsString() || !args[1]->IsInt32()) { | |
563 | return THROW_BAD_ARGS; | |
564 | } | |
565 | - node::Utf8Value path(args[0]); | |
566 | + String::Utf8Value path(args[0]); | |
567 | int mode = static_cast<int>(args[1]->Int32Value()); | |
568 | ||
569 | if(args[2]->IsFunction()) { | |
570 | @@ -874,7 +873,7 @@ static Handle<Value> Chown(const Arguments& args) { | |
571 | if (!args[1]->IsUint32()) return TYPE_ERROR("uid must be an unsigned int"); | |
572 | if (!args[2]->IsUint32()) return TYPE_ERROR("gid must be an unsigned int"); | |
573 | ||
574 | - node::Utf8Value path(args[0]); | |
575 | + String::Utf8Value path(args[0]); | |
576 | uv_uid_t uid = static_cast<uv_uid_t>(args[1]->Uint32Value()); | |
577 | uv_gid_t gid = static_cast<uv_gid_t>(args[2]->Uint32Value()); | |
578 | ||
579 | @@ -925,7 +924,7 @@ static Handle<Value> UTimes(const Arguments& args) { | |
580 | if (!args[1]->IsNumber()) return TYPE_ERROR("atime must be a number"); | |
581 | if (!args[2]->IsNumber()) return TYPE_ERROR("mtime must be a number"); | |
582 | ||
583 | - const node::Utf8Value path(args[0]); | |
584 | + const String::Utf8Value path(args[0]); | |
585 | const double atime = static_cast<double>(args[1]->NumberValue()); | |
586 | const double mtime = static_cast<double>(args[2]->NumberValue()); | |
587 | ||
588 | diff --git a/src/node_stat_watcher.cc b/src/node_stat_watcher.cc | |
589 | index fd3e5d1..c3f668c 100644 | |
590 | --- a/src/node_stat_watcher.cc | |
591 | +++ b/src/node_stat_watcher.cc | |
592 | @@ -20,7 +20,6 @@ | |
593 | // USE OR OTHER DEALINGS IN THE SOFTWARE. | |
594 | ||
595 | #include "node_stat_watcher.h" | |
596 | -#include "util.h" | |
597 | ||
598 | #include <assert.h> | |
599 | #include <string.h> | |
600 | @@ -105,7 +104,7 @@ Handle<Value> StatWatcher::Start(const Arguments& args) { | |
601 | HandleScope scope; | |
602 | ||
603 | StatWatcher* wrap = ObjectWrap::Unwrap<StatWatcher>(args.Holder()); | |
604 | - node::Utf8Value path(args[0]); | |
605 | + String::Utf8Value path(args[0]); | |
606 | const bool persistent = args[1]->BooleanValue(); | |
607 | const uint32_t interval = args[2]->Uint32Value(); | |
608 | ||
609 | diff --git a/src/process_wrap.cc b/src/process_wrap.cc | |
610 | index ac63e4b..784300f 100644 | |
611 | --- a/src/process_wrap.cc | |
612 | +++ b/src/process_wrap.cc | |
613 | @@ -25,7 +25,6 @@ | |
614 | #include "tty_wrap.h" | |
615 | #include "tcp_wrap.h" | |
616 | #include "udp_wrap.h" | |
617 | -#include "util.h" | |
618 | ||
619 | #include <string.h> | |
620 | #include <stdlib.h> | |
621 | @@ -188,7 +187,7 @@ class ProcessWrap : public HandleWrap { | |
622 | ||
623 | // options.file | |
624 | Local<Value> file_v = js_options->Get(String::NewSymbol("file")); | |
625 | - node::Utf8Value file(file_v->IsString() ? file_v : Local<Value>()); | |
626 | + String::Utf8Value file(file_v->IsString() ? file_v : Local<Value>()); | |
627 | if (file.length() > 0) { | |
628 | options.file = *file; | |
629 | } else { | |
630 | @@ -203,7 +202,7 @@ class ProcessWrap : public HandleWrap { | |
631 | // Heap allocate to detect errors. +1 is for NULL. | |
632 | options.args = new char*[argc + 1]; | |
633 | for (int i = 0; i < argc; i++) { | |
634 | - node::Utf8Value arg(js_argv->Get(i)); | |
635 | + String::Utf8Value arg(js_argv->Get(i)); | |
636 | options.args[i] = strdup(*arg); | |
637 | } | |
638 | options.args[argc] = NULL; | |
639 | @@ -211,7 +210,7 @@ class ProcessWrap : public HandleWrap { | |
640 | ||
641 | // options.cwd | |
642 | Local<Value> cwd_v = js_options->Get(String::NewSymbol("cwd")); | |
643 | - node::Utf8Value cwd(cwd_v->IsString() ? cwd_v : Local<Value>()); | |
644 | + String::Utf8Value cwd(cwd_v->IsString() ? cwd_v : Local<Value>()); | |
645 | if (cwd.length() > 0) { | |
646 | options.cwd = *cwd; | |
647 | } | |
648 | @@ -223,7 +222,7 @@ class ProcessWrap : public HandleWrap { | |
649 | int envc = env->Length(); | |
650 | options.env = new char*[envc + 1]; // Heap allocated to detect errors. | |
651 | for (int i = 0; i < envc; i++) { | |
652 | - node::Utf8Value pair(env->Get(i)); | |
653 | + String::Utf8Value pair(env->Get(i)); | |
654 | options.env[i] = strdup(*pair); | |
655 | } | |
656 | options.env[envc] = NULL; | |
657 | diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc | |
658 | index 31a4e78..b33f4e8 100644 | |
659 | --- a/src/udp_wrap.cc | |
660 | +++ b/src/udp_wrap.cc | |
661 | @@ -25,7 +25,6 @@ | |
662 | #include "req_wrap.h" | |
663 | #include "handle_wrap.h" | |
664 | #include "udp_wrap.h" | |
665 | -#include "util.h" | |
666 | ||
667 | #include <stdlib.h> | |
668 | ||
669 | @@ -161,7 +160,7 @@ Handle<Value> UDPWrap::DoBind(const Arguments& args, int family) { | |
670 | // bind(ip, port, flags) | |
671 | assert(args.Length() == 3); | |
672 | ||
673 | - node::Utf8Value address(args[0]); | |
674 | + String::Utf8Value address(args[0]); | |
675 | const int port = args[1]->Uint32Value(); | |
676 | const int flags = args[2]->Uint32Value(); | |
677 | ||
678 | @@ -220,8 +219,8 @@ Handle<Value> UDPWrap::SetMembership(const Arguments& args, | |
679 | ||
680 | assert(args.Length() == 2); | |
681 | ||
682 | - node::Utf8Value address(args[0]); | |
683 | - node::Utf8Value iface(args[1]); | |
684 | + String::Utf8Value address(args[0]); | |
685 | + String::Utf8Value iface(args[1]); | |
686 | ||
687 | const char* iface_cstr = *iface; | |
688 | if (args[1]->IsUndefined() || args[1]->IsNull()) { | |
689 | @@ -272,7 +271,7 @@ Handle<Value> UDPWrap::DoSend(const Arguments& args, int family) { | |
690 | length); | |
691 | ||
692 | const unsigned short port = args[3]->Uint32Value(); | |
693 | - node::Utf8Value address(args[4]); | |
694 | + String::Utf8Value address(args[4]); | |
695 | ||
696 | switch (family) { | |
697 | case AF_INET: | |
698 | diff --git a/src/util.h b/src/util.h | |
699 | deleted file mode 100644 | |
700 | index 0dbf7f4..0000000 | |
701 | --- a/src/util.h | |
702 | +++ /dev/null | |
703 | @@ -1,78 +0,0 @@ | |
704 | -// Copyright Joyent, Inc. and other Node contributors. | |
705 | -// | |
706 | -// Permission is hereby granted, free of charge, to any person obtaining a | |
707 | -// copy of this software and associated documentation files (the | |
708 | -// "Software"), to deal in the Software without restriction, including | |
709 | -// without limitation the rights to use, copy, modify, merge, publish, | |
710 | -// distribute, sublicense, and/or sell copies of the Software, and to permit | |
711 | -// persons to whom the Software is furnished to do so, subject to the | |
712 | -// following conditions: | |
713 | -// | |
714 | -// The above copyright notice and this permission notice shall be included | |
715 | -// in all copies or substantial portions of the Software. | |
716 | -// | |
717 | -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
718 | -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
719 | -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | |
720 | -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | |
721 | -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | |
722 | -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | |
723 | -// USE OR OTHER DEALINGS IN THE SOFTWARE. | |
724 | - | |
725 | -#ifndef SRC_UTIL_H_ | |
726 | -#define SRC_UTIL_H_ | |
727 | - | |
728 | -#include "v8.h" | |
729 | -#include "string_bytes.h" | |
730 | - | |
731 | -namespace node { | |
732 | - | |
733 | -class Utf8Value { | |
734 | - public: | |
735 | - explicit Utf8Value(v8::Handle<v8::Value> value) | |
736 | - : length_(0), str_(NULL) { | |
737 | - if (value.IsEmpty()) | |
738 | - return; | |
739 | - | |
740 | - v8::Local<v8::String> val_ = value->ToString(); | |
741 | - | |
742 | - // Allocate enough space to include the null terminator | |
743 | - size_t len = StringBytes::StorageSize(val_, UTF8) + 1; | |
744 | - | |
745 | - char* str = static_cast<char*>(calloc(1, len)); | |
746 | - | |
747 | - int flags = WRITE_UTF8_FLAGS; | |
748 | - flags |= ~v8::String::NO_NULL_TERMINATION; | |
749 | - | |
750 | - length_ = val_->WriteUtf8(str, | |
751 | - len, | |
752 | - 0, | |
753 | - flags); | |
754 | - | |
755 | - str_ = reinterpret_cast<char*>(str); | |
756 | - } | |
757 | - | |
758 | - ~Utf8Value() { | |
759 | - free(str_); | |
760 | - } | |
761 | - | |
762 | - char* operator*() { | |
763 | - return str_; | |
764 | - }; | |
765 | - | |
766 | - const char* operator*() const { | |
767 | - return str_; | |
768 | - }; | |
769 | - | |
770 | - size_t length() const { | |
771 | - return length_; | |
772 | - }; | |
773 | - | |
774 | - private: | |
775 | - size_t length_; | |
776 | - char* str_; | |
777 | -}; | |
778 | - | |
779 | -} // namespace node | |
780 | - | |
781 | -#endif // SRC_UTIL_H_ | |
782 | -- | |
783 | 1.9.3 | |
784 |