OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
6 #include "vm/dart_api_impl.h" | 6 #include "vm/dart_api_impl.h" |
7 #include "vm/datastream.h" | 7 #include "vm/datastream.h" |
8 #include "vm/exceptions.h" | 8 #include "vm/exceptions.h" |
9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 ASSERT(!Dart_IsError(err)); | 409 ASSERT(!Dart_IsError(err)); |
410 | 410 |
411 TarArchive archive(reinterpret_cast<uint8_t*>(bytes), length); | 411 TarArchive archive(reinterpret_cast<uint8_t*>(bytes), length); |
412 archive.Read(); | 412 archive.Read(); |
413 | 413 |
414 err = Dart_TypedDataReleaseData(data_handle); | 414 err = Dart_TypedDataReleaseData(data_handle); |
415 ASSERT(!Dart_IsError(err)); | 415 ASSERT(!Dart_IsError(err)); |
416 | 416 |
417 intptr_t archive_size = archive.Length(); | 417 intptr_t archive_size = archive.Length(); |
418 | 418 |
419 const Array& result_list = Array::Handle(thread->zone(), | 419 Dart_Handle result_list = Dart_NewList(2 * archive_size); |
420 Array::New(2 * archive_size)); | 420 ASSERT(!Dart_IsError(result_list)); |
421 | 421 |
422 intptr_t idx = 0; | 422 intptr_t idx = 0; |
423 while (archive.HasMore()) { | 423 while (archive.HasMore()) { |
424 char* filename = archive.NextFilename(); | 424 char* filename = archive.NextFilename(); |
425 uint8_t* contents = archive.NextContent(); | 425 uint8_t* contents = archive.NextContent(); |
426 intptr_t contents_length = archive.NextContentLength(); | 426 intptr_t contents_length = archive.NextContentLength(); |
427 | 427 |
428 Dart_Handle dart_filename = Dart_NewExternalLatin1String( | 428 Dart_Handle dart_filename = Dart_NewExternalLatin1String( |
429 reinterpret_cast<uint8_t*>(filename), | 429 reinterpret_cast<uint8_t*>(filename), |
430 strlen(filename), | 430 strlen(filename), |
431 filename, | 431 filename, |
432 FilenameFinalizer); | 432 FilenameFinalizer); |
433 ASSERT(!Dart_IsError(dart_filename)); | 433 ASSERT(!Dart_IsError(dart_filename)); |
434 | 434 |
435 Dart_Handle dart_contents = Dart_NewExternalTypedData( | 435 Dart_Handle dart_contents = Dart_NewExternalTypedData( |
436 Dart_TypedData_kUint8, contents, contents_length); | 436 Dart_TypedData_kUint8, contents, contents_length); |
437 ASSERT(!Dart_IsError(dart_contents)); | 437 ASSERT(!Dart_IsError(dart_contents)); |
438 Dart_NewWeakPersistentHandle( | 438 Dart_NewWeakPersistentHandle( |
439 dart_contents, contents, contents_length, ContentsFinalizer); | 439 dart_contents, contents, contents_length, ContentsFinalizer); |
440 | 440 |
441 result_list.SetAt(idx, Api::UnwrapStringHandle( | 441 Dart_ListSetAt(result_list, idx, dart_filename); |
442 thread->zone(), dart_filename)); | 442 Dart_ListSetAt(result_list, (idx + 1), dart_contents); |
443 result_list.SetAt(idx + 1, Api::UnwrapExternalTypedDataHandle( | |
444 thread->zone(), dart_contents)); | |
445 idx += 2; | 443 idx += 2; |
446 } | 444 } |
447 | 445 return Api::UnwrapArrayHandle(thread->zone(), result_list).raw(); |
448 return result_list.raw(); | |
449 #else | 446 #else |
450 return Object::null(); | 447 return Object::null(); |
451 #endif | 448 #endif |
452 } | 449 } |
453 | 450 |
454 | 451 |
455 | 452 |
456 DEFINE_NATIVE_ENTRY(VMService_spawnUriNotify, 2) { | 453 DEFINE_NATIVE_ENTRY(VMService_spawnUriNotify, 2) { |
457 #ifndef PRODUCT | 454 #ifndef PRODUCT |
458 if (!FLAG_support_service) { | 455 if (!FLAG_support_service) { |
(...skipping 25 matching lines...) Expand all Loading... |
484 ServiceEvent spawn_event(NULL, ServiceEvent::kIsolateSpawn); | 481 ServiceEvent spawn_event(NULL, ServiceEvent::kIsolateSpawn); |
485 spawn_event.set_spawn_token(&token); | 482 spawn_event.set_spawn_token(&token); |
486 spawn_event.set_spawn_error(&String::Cast(result)); | 483 spawn_event.set_spawn_error(&String::Cast(result)); |
487 Service::HandleEvent(&spawn_event); | 484 Service::HandleEvent(&spawn_event); |
488 } | 485 } |
489 #endif // PRODUCT | 486 #endif // PRODUCT |
490 return Object::null(); | 487 return Object::null(); |
491 } | 488 } |
492 | 489 |
493 } // namespace dart | 490 } // namespace dart |
OLD | NEW |