OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "bin/dartutils.h" | 5 #include "bin/dartutils.h" |
6 | 6 |
7 #include "bin/extensions.h" | 7 #include "bin/extensions.h" |
8 #include "bin/directory.h" | 8 #include "bin/directory.h" |
9 #include "bin/file.h" | 9 #include "bin/file.h" |
10 #include "include/dart_api.h" | 10 #include "include/dart_api.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 Dart_Handle result = Dart_BooleanValue(bool_obj, &value); | 92 Dart_Handle result = Dart_BooleanValue(bool_obj, &value); |
93 ASSERT(!Dart_IsError(result)); | 93 ASSERT(!Dart_IsError(result)); |
94 return value; | 94 return value; |
95 } | 95 } |
96 | 96 |
97 | 97 |
98 void DartUtils::SetIntegerField(Dart_Handle handle, | 98 void DartUtils::SetIntegerField(Dart_Handle handle, |
99 const char* name, | 99 const char* name, |
100 intptr_t val) { | 100 intptr_t val) { |
101 Dart_Handle result = Dart_SetField(handle, | 101 Dart_Handle result = Dart_SetField(handle, |
102 Dart_NewString(name), | 102 NewString(name), |
103 Dart_NewInteger(val)); | 103 Dart_NewInteger(val)); |
104 ASSERT(!Dart_IsError(result)); | 104 ASSERT(!Dart_IsError(result)); |
105 } | 105 } |
106 | 106 |
107 | 107 |
108 intptr_t DartUtils::GetIntegerField(Dart_Handle handle, | 108 intptr_t DartUtils::GetIntegerField(Dart_Handle handle, |
109 const char* name) { | 109 const char* name) { |
110 Dart_Handle result = Dart_GetField(handle, Dart_NewString(name)); | 110 Dart_Handle result = Dart_GetField(handle, NewString(name)); |
111 ASSERT(!Dart_IsError(result)); | 111 ASSERT(!Dart_IsError(result)); |
112 intptr_t value = DartUtils::GetIntegerValue(result); | 112 intptr_t value = DartUtils::GetIntegerValue(result); |
113 return value; | 113 return value; |
114 } | 114 } |
115 | 115 |
116 | 116 |
117 void DartUtils::SetStringField(Dart_Handle handle, | 117 void DartUtils::SetStringField(Dart_Handle handle, |
118 const char* name, | 118 const char* name, |
119 const char* val) { | 119 const char* val) { |
120 Dart_Handle result = Dart_SetField(handle, | 120 Dart_Handle result = Dart_SetField(handle, NewString(name), NewString(val)); |
121 Dart_NewString(name), | |
122 Dart_NewString(val)); | |
123 ASSERT(!Dart_IsError(result)); | 121 ASSERT(!Dart_IsError(result)); |
124 } | 122 } |
125 | 123 |
126 | 124 |
127 bool DartUtils::IsDartSchemeURL(const char* url_name) { | 125 bool DartUtils::IsDartSchemeURL(const char* url_name) { |
128 static const intptr_t kDartSchemeLen = strlen(kDartScheme); | 126 static const intptr_t kDartSchemeLen = strlen(kDartScheme); |
129 // If the URL starts with "dart:" then it is considered as a special | 127 // If the URL starts with "dart:" then it is considered as a special |
130 // library URL which is handled differently from other URLs. | 128 // library URL which is handled differently from other URLs. |
131 return (strncmp(url_name, kDartScheme, kDartSchemeLen) == 0); | 129 return (strncmp(url_name, kDartScheme, kDartSchemeLen) == 0); |
132 } | 130 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 165 |
168 | 166 |
169 Dart_Handle DartUtils::CanonicalizeURL(CommandLineOptions* url_mapping, | 167 Dart_Handle DartUtils::CanonicalizeURL(CommandLineOptions* url_mapping, |
170 Dart_Handle library, | 168 Dart_Handle library, |
171 const char* url_str) { | 169 const char* url_str) { |
172 // Get the url of the including library. | 170 // Get the url of the including library. |
173 Dart_Handle library_url = Dart_LibraryUrl(library); | 171 Dart_Handle library_url = Dart_LibraryUrl(library); |
174 if (Dart_IsError(library_url)) { | 172 if (Dart_IsError(library_url)) { |
175 return Dart_Error("accessing library url failed"); | 173 return Dart_Error("accessing library url failed"); |
176 } | 174 } |
177 if (!Dart_IsString8(library_url)) { | 175 if (!Dart_IsString(library_url)) { |
178 return Dart_Error("library url is not a string"); | 176 return Dart_Error("library url is not a string"); |
179 } | 177 } |
180 const char* library_url_str = NULL; | 178 const char* library_url_str = NULL; |
181 Dart_Handle result = Dart_StringToCString(library_url, &library_url_str); | 179 Dart_Handle result = Dart_StringToCString(library_url, &library_url_str); |
182 if (Dart_IsError(result)) { | 180 if (Dart_IsError(result)) { |
183 return Dart_Error("accessing library url characters failed"); | 181 return Dart_Error("accessing library url characters failed"); |
184 } | 182 } |
185 if (url_mapping != NULL) { | 183 if (url_mapping != NULL) { |
186 const char* mapped_library_url_str = MapLibraryUrl(url_mapping, | 184 const char* mapped_library_url_str = MapLibraryUrl(url_mapping, |
187 library_url_str); | 185 library_url_str); |
188 if (mapped_library_url_str != NULL) { | 186 if (mapped_library_url_str != NULL) { |
189 library_url_str = mapped_library_url_str; | 187 library_url_str = mapped_library_url_str; |
190 } | 188 } |
191 } | 189 } |
192 // Calculate the canonical path. | 190 // Calculate the canonical path. |
193 const char* canon_url_str = GetCanonicalPath(library_url_str, url_str); | 191 const char* canon_url_str = GetCanonicalPath(library_url_str, url_str); |
194 Dart_Handle canon_url = Dart_NewString(canon_url_str); | 192 Dart_Handle canon_url = NewString(canon_url_str); |
195 free(const_cast<char*>(canon_url_str)); | 193 free(const_cast<char*>(canon_url_str)); |
196 | 194 |
197 return canon_url; | 195 return canon_url; |
198 } | 196 } |
199 | 197 |
200 | 198 |
201 Dart_Handle DartUtils::ReadStringFromFile(const char* filename) { | 199 Dart_Handle DartUtils::ReadStringFromFile(const char* filename) { |
202 File* file = File::Open(filename, File::kRead); | 200 File* file = File::Open(filename, File::kRead); |
203 if (file == NULL) { | 201 if (file == NULL) { |
204 const char* format = "Unable to open file: %s"; | 202 const char* format = "Unable to open file: %s"; |
205 intptr_t len = snprintf(NULL, 0, format, filename); | 203 intptr_t len = snprintf(NULL, 0, format, filename); |
206 // TODO(iposva): Allocate from the zone instead of leaking error string | 204 // TODO(iposva): Allocate from the zone instead of leaking error string |
207 // here. On the other hand the binary is about the exit anyway. | 205 // here. On the other hand the binary is about the exit anyway. |
208 char* error_msg = reinterpret_cast<char*>(malloc(len + 1)); | 206 char* error_msg = reinterpret_cast<char*>(malloc(len + 1)); |
209 snprintf(error_msg, len + 1, format, filename); | 207 snprintf(error_msg, len + 1, format, filename); |
210 return Dart_Error(error_msg); | 208 return Dart_Error(error_msg); |
211 } | 209 } |
212 intptr_t len = file->Length(); | 210 intptr_t len = file->Length(); |
213 char* text_buffer = reinterpret_cast<char*>(malloc(len + 1)); | 211 uint8_t* text_buffer = reinterpret_cast<uint8_t*>(malloc(len)); |
214 if (text_buffer == NULL) { | 212 if (text_buffer == NULL) { |
215 delete file; | 213 delete file; |
216 return Dart_Error("Unable to allocate buffer"); | 214 return Dart_Error("Unable to allocate buffer"); |
217 } | 215 } |
218 if (!file->ReadFully(text_buffer, len)) { | 216 if (!file->ReadFully(text_buffer, len)) { |
219 delete file; | 217 delete file; |
| 218 free(text_buffer); |
220 return Dart_Error("Unable to fully read contents"); | 219 return Dart_Error("Unable to fully read contents"); |
221 } | 220 } |
222 text_buffer[len] = '\0'; | |
223 delete file; | 221 delete file; |
224 Dart_Handle str = Dart_NewString(text_buffer); | 222 Dart_Handle str = Dart_NewStringFromUTF8(text_buffer, len); |
225 free(text_buffer); | 223 free(text_buffer); |
226 return str; | 224 return str; |
227 } | 225 } |
228 | 226 |
229 | 227 |
230 static Dart_Handle ResolveScriptUri(Dart_Handle script_uri, | 228 static Dart_Handle ResolveScriptUri(Dart_Handle script_uri, |
231 Dart_Handle builtin_lib) { | 229 Dart_Handle builtin_lib) { |
232 const int kNumArgs = 3; | 230 const int kNumArgs = 3; |
233 Dart_Handle dart_args[kNumArgs]; | 231 Dart_Handle dart_args[kNumArgs]; |
234 dart_args[0] = Dart_NewString(DartUtils::original_working_directory); | 232 dart_args[0] = DartUtils::NewString(DartUtils::original_working_directory); |
235 dart_args[1] = script_uri; | 233 dart_args[1] = script_uri; |
236 dart_args[2] = (IsWindowsHost() ? Dart_True() : Dart_False()); | 234 dart_args[2] = (IsWindowsHost() ? Dart_True() : Dart_False()); |
237 return Dart_Invoke( | 235 return Dart_Invoke(builtin_lib, |
238 builtin_lib, Dart_NewString("_resolveScriptUri"), kNumArgs, dart_args); | 236 DartUtils::NewString("_resolveScriptUri"), |
| 237 kNumArgs, |
| 238 dart_args); |
239 } | 239 } |
240 | 240 |
241 | 241 |
242 static Dart_Handle FilePathFromUri(Dart_Handle script_uri, | 242 static Dart_Handle FilePathFromUri(Dart_Handle script_uri, |
243 Dart_Handle builtin_lib) { | 243 Dart_Handle builtin_lib) { |
244 const int kNumArgs = 2; | 244 const int kNumArgs = 2; |
245 Dart_Handle dart_args[kNumArgs]; | 245 Dart_Handle dart_args[kNumArgs]; |
246 dart_args[0] = script_uri; | 246 dart_args[0] = script_uri; |
247 dart_args[1] = (IsWindowsHost() ? Dart_True() : Dart_False()); | 247 dart_args[1] = (IsWindowsHost() ? Dart_True() : Dart_False()); |
248 Dart_Handle script_path = Dart_Invoke( | 248 Dart_Handle script_path = Dart_Invoke( |
249 builtin_lib, Dart_NewString("_filePathFromUri"), kNumArgs, dart_args); | 249 builtin_lib, |
| 250 DartUtils::NewString("_filePathFromUri"), |
| 251 kNumArgs, |
| 252 dart_args); |
250 return script_path; | 253 return script_path; |
251 } | 254 } |
252 | 255 |
253 | 256 |
254 Dart_Handle DartUtils::LibraryTagHandler(Dart_LibraryTag tag, | 257 Dart_Handle DartUtils::LibraryTagHandler(Dart_LibraryTag tag, |
255 Dart_Handle library, | 258 Dart_Handle library, |
256 Dart_Handle url) { | 259 Dart_Handle url) { |
257 if (!Dart_IsLibrary(library)) { | 260 if (!Dart_IsLibrary(library)) { |
258 return Dart_Error("not a library"); | 261 return Dart_Error("not a library"); |
259 } | 262 } |
260 if (!Dart_IsString8(url)) { | 263 if (!Dart_IsString(url)) { |
261 return Dart_Error("url is not a string"); | 264 return Dart_Error("url is not a string"); |
262 } | 265 } |
263 const char* url_string = NULL; | 266 const char* url_string = NULL; |
264 Dart_Handle result = Dart_StringToCString(url, &url_string); | 267 Dart_Handle result = Dart_StringToCString(url, &url_string); |
265 if (Dart_IsError(result)) { | 268 if (Dart_IsError(result)) { |
266 return result; | 269 return result; |
267 } | 270 } |
268 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); | 271 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); |
269 bool is_dart_extension_url = DartUtils::IsDartExtensionSchemeURL(url_string); | 272 bool is_dart_extension_url = DartUtils::IsDartExtensionSchemeURL(url_string); |
270 if (tag == kCanonicalizeUrl) { | 273 if (tag == kCanonicalizeUrl) { |
271 // If this is a Dart Scheme URL then it is not modified as it will be | 274 // If this is a Dart Scheme URL then it is not modified as it will be |
272 // handled by the VM internally. | 275 // handled by the VM internally. |
273 if (is_dart_scheme_url) { | 276 if (is_dart_scheme_url) { |
274 return url; | 277 return url; |
275 } | 278 } |
276 // Resolve the url within the context of the library's URL. | 279 // Resolve the url within the context of the library's URL. |
277 Dart_Handle builtin_lib = | 280 Dart_Handle builtin_lib = |
278 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); | 281 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
279 Dart_Handle library_url = Dart_LibraryUrl(library); | 282 Dart_Handle library_url = Dart_LibraryUrl(library); |
280 if (Dart_IsError(library_url)) { | 283 if (Dart_IsError(library_url)) { |
281 return library_url; | 284 return library_url; |
282 } | 285 } |
283 const int kNumArgs = 2; | 286 const int kNumArgs = 2; |
284 Dart_Handle dart_args[kNumArgs]; | 287 Dart_Handle dart_args[kNumArgs]; |
285 dart_args[0] = library_url; | 288 dart_args[0] = library_url; |
286 dart_args[1] = url; | 289 dart_args[1] = url; |
287 return Dart_Invoke( | 290 return Dart_Invoke( |
288 builtin_lib, Dart_NewString("_resolveUri"), kNumArgs, dart_args); | 291 builtin_lib, NewString("_resolveUri"), kNumArgs, dart_args); |
289 } | 292 } |
290 if (is_dart_scheme_url) { | 293 if (is_dart_scheme_url) { |
291 ASSERT(tag == kImportTag); | 294 ASSERT(tag == kImportTag); |
292 // Handle imports of other built-in libraries present in the SDK. | 295 // Handle imports of other built-in libraries present in the SDK. |
293 Builtin::BuiltinLibraryId id; | 296 Builtin::BuiltinLibraryId id; |
294 if (DartUtils::IsDartCryptoLibURL(url_string)) { | 297 if (DartUtils::IsDartCryptoLibURL(url_string)) { |
295 id = Builtin::kCryptoLibrary; | 298 id = Builtin::kCryptoLibrary; |
296 } else if (DartUtils::IsDartIOLibURL(url_string)) { | 299 } else if (DartUtils::IsDartIOLibURL(url_string)) { |
297 id = Builtin::kIOLibrary; | 300 id = Builtin::kIOLibrary; |
298 } else if (DartUtils::IsDartJsonLibURL(url_string)) { | 301 } else if (DartUtils::IsDartJsonLibURL(url_string)) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 const char* script_path_cstr; | 342 const char* script_path_cstr; |
340 Dart_StringToCString(script_path, &script_path_cstr); | 343 Dart_StringToCString(script_path, &script_path_cstr); |
341 Dart_Handle source = DartUtils::ReadStringFromFile(script_path_cstr); | 344 Dart_Handle source = DartUtils::ReadStringFromFile(script_path_cstr); |
342 return source; | 345 return source; |
343 } | 346 } |
344 | 347 |
345 | 348 |
346 Dart_Handle DartUtils::LoadScript(const char* script_uri, | 349 Dart_Handle DartUtils::LoadScript(const char* script_uri, |
347 Dart_Handle builtin_lib) { | 350 Dart_Handle builtin_lib) { |
348 Dart_Handle resolved_script_uri; | 351 Dart_Handle resolved_script_uri; |
349 resolved_script_uri = ResolveScriptUri(Dart_NewString(script_uri), | 352 resolved_script_uri = ResolveScriptUri(NewString(script_uri), builtin_lib); |
350 builtin_lib); | |
351 if (Dart_IsError(resolved_script_uri)) { | 353 if (Dart_IsError(resolved_script_uri)) { |
352 return resolved_script_uri; | 354 return resolved_script_uri; |
353 } | 355 } |
354 Dart_Handle source = ReadSource(resolved_script_uri, builtin_lib); | 356 Dart_Handle source = ReadSource(resolved_script_uri, builtin_lib); |
355 if (Dart_IsError(source)) { | 357 if (Dart_IsError(source)) { |
356 return source; | 358 return source; |
357 } | 359 } |
358 return Dart_LoadScript(resolved_script_uri, source); | 360 return Dart_LoadScript(resolved_script_uri, source); |
359 } | 361 } |
360 | 362 |
(...skipping 24 matching lines...) Expand all Loading... |
385 } else if (tag == kSourceTag) { | 387 } else if (tag == kSourceTag) { |
386 return Dart_LoadSource(library, url, source); | 388 return Dart_LoadSource(library, url, source); |
387 } | 389 } |
388 return Dart_Error("wrong tag"); | 390 return Dart_Error("wrong tag"); |
389 } | 391 } |
390 | 392 |
391 | 393 |
392 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root, | 394 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root, |
393 Dart_Handle builtin_lib) { | 395 Dart_Handle builtin_lib) { |
394 // Setup the corelib 'print' function. | 396 // Setup the corelib 'print' function. |
395 Dart_Handle print = | 397 Dart_Handle print = Dart_Invoke( |
396 Dart_Invoke(builtin_lib, Dart_NewString("_getPrintClosure"), 0, 0); | 398 builtin_lib, NewString("_getPrintClosure"), 0, 0); |
397 Dart_Handle corelib = Dart_LookupLibrary(Dart_NewString("dart:core")); | 399 Dart_Handle corelib = Dart_LookupLibrary(NewString("dart:core")); |
398 Dart_Handle result = Dart_SetField(corelib, | 400 Dart_Handle result = Dart_SetField(corelib, |
399 Dart_NewString("_printClosure"), print); | 401 NewString("_printClosure"), |
| 402 print); |
400 | 403 |
401 // Setup the 'timer' factory. | 404 // Setup the 'timer' factory. |
402 Dart_Handle url = Dart_NewString(kIsolateLibURL); | 405 Dart_Handle url = NewString(kIsolateLibURL); |
403 DART_CHECK_VALID(url); | 406 DART_CHECK_VALID(url); |
404 Dart_Handle isolate_lib = Dart_LookupLibrary(url); | 407 Dart_Handle isolate_lib = Dart_LookupLibrary(url); |
405 DART_CHECK_VALID(isolate_lib); | 408 DART_CHECK_VALID(isolate_lib); |
406 Dart_Handle io_lib = Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); | 409 Dart_Handle io_lib = Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); |
407 Dart_Handle timer_closure = | 410 Dart_Handle timer_closure = |
408 Dart_Invoke(io_lib, Dart_NewString("_getTimerFactoryClosure"), 0, NULL); | 411 Dart_Invoke(io_lib, NewString("_getTimerFactoryClosure"), 0, NULL); |
409 Dart_Handle args[1]; | 412 Dart_Handle args[1]; |
410 args[0] = timer_closure; | 413 args[0] = timer_closure; |
411 DART_CHECK_VALID(Dart_Invoke(isolate_lib, | 414 DART_CHECK_VALID(Dart_Invoke( |
412 Dart_NewString("_setTimerFactoryClosure"), | 415 isolate_lib, NewString("_setTimerFactoryClosure"), 1, args)); |
413 1, args)); | |
414 | 416 |
415 // Set up package root if specified. | 417 // Set up package root if specified. |
416 if (package_root != NULL) { | 418 if (package_root != NULL) { |
417 result = Dart_NewString(package_root); | 419 result = NewString(package_root); |
418 if (!Dart_IsError(result)) { | 420 if (!Dart_IsError(result)) { |
419 const int kNumArgs = 1; | 421 const int kNumArgs = 1; |
420 Dart_Handle dart_args[kNumArgs]; | 422 Dart_Handle dart_args[kNumArgs]; |
421 dart_args[0] = result; | 423 dart_args[0] = result; |
422 return Dart_Invoke(builtin_lib, | 424 return Dart_Invoke(builtin_lib, |
423 Dart_NewString("_setPackageRoot"), | 425 NewString("_setPackageRoot"), |
424 kNumArgs, | 426 kNumArgs, |
425 dart_args); | 427 dart_args); |
426 } | 428 } |
427 } | 429 } |
428 return result; | 430 return result; |
429 } | 431 } |
430 | 432 |
431 | 433 |
432 const char* DartUtils::GetCanonicalPath(const char* reference_dir, | 434 const char* DartUtils::GetCanonicalPath(const char* reference_dir, |
433 const char* filename) { | 435 const char* filename) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 | 487 |
486 Dart_Handle DartUtils::NewDartOSError() { | 488 Dart_Handle DartUtils::NewDartOSError() { |
487 // Extract the current OS error. | 489 // Extract the current OS error. |
488 OSError os_error; | 490 OSError os_error; |
489 return NewDartOSError(&os_error); | 491 return NewDartOSError(&os_error); |
490 } | 492 } |
491 | 493 |
492 | 494 |
493 Dart_Handle DartUtils::NewDartOSError(OSError* os_error) { | 495 Dart_Handle DartUtils::NewDartOSError(OSError* os_error) { |
494 // Create a Dart OSError object with the information retrieved from the OS. | 496 // Create a Dart OSError object with the information retrieved from the OS. |
495 Dart_Handle url = Dart_NewString("dart:io"); | 497 Dart_Handle url = NewString("dart:io"); |
496 if (Dart_IsError(url)) return url; | 498 if (Dart_IsError(url)) return url; |
497 Dart_Handle lib = Dart_LookupLibrary(url); | 499 Dart_Handle lib = Dart_LookupLibrary(url); |
498 if (Dart_IsError(lib)) return lib; | 500 if (Dart_IsError(lib)) return lib; |
499 Dart_Handle class_name = Dart_NewString("OSError"); | 501 Dart_Handle class_name = NewString("OSError"); |
500 if (Dart_IsError(class_name)) return class_name; | 502 if (Dart_IsError(class_name)) return class_name; |
501 Dart_Handle clazz = Dart_GetClass(lib, class_name); | 503 Dart_Handle clazz = Dart_GetClass(lib, class_name); |
502 if (Dart_IsError(clazz)) return clazz; | 504 if (Dart_IsError(clazz)) return clazz; |
503 Dart_Handle args[2]; | 505 Dart_Handle args[2]; |
504 args[0] = Dart_NewString(os_error->message()); | 506 args[0] = NewString(os_error->message()); |
505 if (Dart_IsError(args[0])) return args[0]; | 507 if (Dart_IsError(args[0])) return args[0]; |
506 args[1] = Dart_NewInteger(os_error->code()); | 508 args[1] = Dart_NewInteger(os_error->code()); |
507 if (Dart_IsError(args[1])) return args[1]; | 509 if (Dart_IsError(args[1])) return args[1]; |
508 Dart_Handle err = Dart_New(clazz, Dart_Null(), 2, args); | 510 Dart_Handle err = Dart_New(clazz, Dart_Null(), 2, args); |
509 return err; | 511 return err; |
510 } | 512 } |
511 | 513 |
512 | 514 |
513 void DartUtils::SetOriginalWorkingDirectory() { | 515 void DartUtils::SetOriginalWorkingDirectory() { |
514 original_working_directory = Directory::Current(); | 516 original_working_directory = Directory::Current(); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 | 658 |
657 CObject* CObject::NewOSError(OSError* os_error) { | 659 CObject* CObject::NewOSError(OSError* os_error) { |
658 CObject* error_message = | 660 CObject* error_message = |
659 new CObjectString(CObject::NewString(os_error->message())); | 661 new CObjectString(CObject::NewString(os_error->message())); |
660 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 662 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
661 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 663 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
662 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 664 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
663 result->SetAt(2, error_message); | 665 result->SetAt(2, error_message); |
664 return result; | 666 return result; |
665 } | 667 } |
OLD | NEW |