| 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/file.h" | 7 #include "bin/file.h" |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 return NewDartOSError(&os_error); | 304 return NewDartOSError(&os_error); |
| 305 } | 305 } |
| 306 | 306 |
| 307 | 307 |
| 308 Dart_Handle DartUtils::NewDartOSError(OSError* os_error) { | 308 Dart_Handle DartUtils::NewDartOSError(OSError* os_error) { |
| 309 // Create a Dart OSError object with the information retrieved from the OS. | 309 // Create a Dart OSError object with the information retrieved from the OS. |
| 310 Dart_Handle url = Dart_NewString("dart:io"); | 310 Dart_Handle url = Dart_NewString("dart:io"); |
| 311 if (Dart_IsError(url)) return url; | 311 if (Dart_IsError(url)) return url; |
| 312 Dart_Handle lib = Dart_LookupLibrary(url); | 312 Dart_Handle lib = Dart_LookupLibrary(url); |
| 313 if (Dart_IsError(lib)) return lib; | 313 if (Dart_IsError(lib)) return lib; |
| 314 Dart_Handle function_name = Dart_NewString("_makeOSError"); | 314 Dart_Handle class_name = Dart_NewString("OSError"); |
| 315 if (Dart_IsError(function_name)) return function_name; | 315 if (Dart_IsError(class_name)) return class_name; |
| 316 Dart_Handle clazz = Dart_GetClass(lib, class_name); |
| 317 if (Dart_IsError(clazz)) return clazz; |
| 316 Dart_Handle args[2]; | 318 Dart_Handle args[2]; |
| 317 args[0] = Dart_NewString(os_error->message()); | 319 args[0] = Dart_NewString(os_error->message()); |
| 318 if (Dart_IsError(args[0])) return args[0]; | 320 if (Dart_IsError(args[0])) return args[0]; |
| 319 args[1] = Dart_NewInteger(os_error->code()); | 321 args[1] = Dart_NewInteger(os_error->code()); |
| 320 if (Dart_IsError(args[1])) return args[1]; | 322 if (Dart_IsError(args[1])) return args[1]; |
| 321 Dart_Handle err = Dart_Invoke(lib, function_name, 2, args); | 323 Dart_Handle err = Dart_New(clazz, Dart_Null(), 2, args); |
| 322 return err; | 324 return err; |
| 323 } | 325 } |
| 324 | 326 |
| 325 | 327 |
| 326 // Statically allocated Dart_CObject instances for immutable | 328 // Statically allocated Dart_CObject instances for immutable |
| 327 // objects. As these will be used by different threads the use of | 329 // objects. As these will be used by different threads the use of |
| 328 // these depends on the fact that the marking internally in the | 330 // these depends on the fact that the marking internally in the |
| 329 // Dart_CObject structure is not marking simple value objects. | 331 // Dart_CObject structure is not marking simple value objects. |
| 330 Dart_CObject CObject::api_null_ = { Dart_CObject::kNull , { 0 } }; | 332 Dart_CObject CObject::api_null_ = { Dart_CObject::kNull , { 0 } }; |
| 331 Dart_CObject CObject::api_true_ = { Dart_CObject::kBool , { true } }; | 333 Dart_CObject CObject::api_true_ = { Dart_CObject::kBool , { true } }; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 453 |
| 452 CObject* CObject::NewOSError(OSError* os_error) { | 454 CObject* CObject::NewOSError(OSError* os_error) { |
| 453 CObject* error_message = | 455 CObject* error_message = |
| 454 new CObjectString(CObject::NewString(os_error->message())); | 456 new CObjectString(CObject::NewString(os_error->message())); |
| 455 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 457 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 456 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 458 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 457 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 459 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 458 result->SetAt(2, error_message); | 460 result->SetAt(2, error_message); |
| 459 return result; | 461 return result; |
| 460 } | 462 } |
| OLD | NEW |