Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 8761007: Stop using void* types in the dart embedding api. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 190 }
191 191
192 192
193 PersistentHandle* Api::UnwrapAsPersistentHandle(const ApiState& state, 193 PersistentHandle* Api::UnwrapAsPersistentHandle(const ApiState& state,
194 Dart_Handle object) { 194 Dart_Handle object) {
195 ASSERT(state.IsValidPersistentHandle(object)); 195 ASSERT(state.IsValidPersistentHandle(object));
196 return reinterpret_cast<PersistentHandle*>(object); 196 return reinterpret_cast<PersistentHandle*>(object);
197 } 197 }
198 198
199 199
200 Dart_Isolate Api::CastIsolate(Isolate* isolate) {
201 return reinterpret_cast<Dart_Isolate>(isolate);
202 }
203
204
205 Dart_Message Api::CastMessage(uint8_t* message) {
206 return reinterpret_cast<Dart_Message>(message);
207 }
208
209
200 Dart_Handle Api::Success() { 210 Dart_Handle Api::Success() {
201 Isolate* isolate = Isolate::Current(); 211 Isolate* isolate = Isolate::Current();
202 ASSERT(isolate != NULL); 212 ASSERT(isolate != NULL);
203 ApiState* state = isolate->api_state(); 213 ApiState* state = isolate->api_state();
204 ASSERT(state != NULL); 214 ASSERT(state != NULL);
205 PersistentHandle* true_handle = state->True(); 215 PersistentHandle* true_handle = state->True();
206 return reinterpret_cast<Dart_Handle>(true_handle); 216 return reinterpret_cast<Dart_Handle>(true_handle);
207 } 217 }
208 218
209 219
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 if (Flags::Lookup(flag_name) != NULL) { 542 if (Flags::Lookup(flag_name) != NULL) {
533 return true; 543 return true;
534 } 544 }
535 return false; 545 return false;
536 } 546 }
537 547
538 548
539 // --- Isolates --- 549 // --- Isolates ---
540 550
541 551
542 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, 552 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const uint8_t* snapshot,
543 void* callback_data, 553 void* callback_data,
544 char** error) { 554 char** error) {
545 Isolate* isolate = Dart::CreateIsolate(); 555 Isolate* isolate = Dart::CreateIsolate();
546 ASSERT(isolate != NULL); 556 ASSERT(isolate != NULL);
547 LongJump* base = isolate->long_jump_base(); 557 LongJump* base = isolate->long_jump_base();
548 LongJump jump; 558 LongJump jump;
549 isolate->set_long_jump_base(&jump); 559 isolate->set_long_jump_base(&jump);
550 if (setjmp(*jump.Set()) == 0) { 560 if (setjmp(*jump.Set()) == 0) {
551 Dart::InitializeIsolate(snapshot, callback_data); 561 Dart::InitializeIsolate(snapshot, callback_data);
552 START_TIMER(time_total_runtime); 562 START_TIMER(time_total_runtime);
(...skipping 13 matching lines...) Expand all
566 576
567 577
568 DART_EXPORT void Dart_ShutdownIsolate() { 578 DART_EXPORT void Dart_ShutdownIsolate() {
569 ASSERT(Isolate::Current() != NULL); 579 ASSERT(Isolate::Current() != NULL);
570 STOP_TIMER(time_total_runtime); 580 STOP_TIMER(time_total_runtime);
571 Dart::ShutdownIsolate(); 581 Dart::ShutdownIsolate();
572 } 582 }
573 583
574 584
575 DART_EXPORT Dart_Isolate Dart_CurrentIsolate() { 585 DART_EXPORT Dart_Isolate Dart_CurrentIsolate() {
576 return reinterpret_cast<Dart_Isolate>(Isolate::Current()); 586 return Api::CastIsolate(Isolate::Current());
577 } 587 }
578 588
579 589
580 DART_EXPORT void Dart_EnterIsolate(Dart_Isolate dart_isolate) { 590 DART_EXPORT void Dart_EnterIsolate(Dart_Isolate dart_isolate) {
581 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); 591 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate);
582 ASSERT(Isolate::Current() == NULL); 592 ASSERT(Isolate::Current() == NULL);
583 Isolate::SetCurrent(isolate); 593 Isolate::SetCurrent(isolate);
584 } 594 }
585 595
586 596
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 728
719 DART_EXPORT bool Dart_PostIntArray(Dart_Port port_id, 729 DART_EXPORT bool Dart_PostIntArray(Dart_Port port_id,
720 intptr_t len, 730 intptr_t len,
721 intptr_t* data) { 731 intptr_t* data) {
722 uint8_t* buffer = NULL; 732 uint8_t* buffer = NULL;
723 MessageWriter writer(&buffer, &allocator); 733 MessageWriter writer(&buffer, &allocator);
724 734
725 writer.WriteMessage(len, data); 735 writer.WriteMessage(len, data);
726 736
727 // Post the message at the given port. 737 // Post the message at the given port.
728 return PortMap::PostMessage(port_id, kNoReplyPort, buffer); 738 return PortMap::PostMessage(port_id, kNoReplyPort, Api::CastMessage(buffer));
729 } 739 }
730 740
731 741
732 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) { 742 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) {
733 DARTSCOPE(Isolate::Current()); 743 DARTSCOPE(Isolate::Current());
734 const Object& object = Object::Handle(Api::UnwrapHandle(handle)); 744 const Object& object = Object::Handle(Api::UnwrapHandle(handle));
735 uint8_t* data = NULL; 745 uint8_t* data = NULL;
736 SnapshotWriter writer(false, &data, &allocator); 746 SnapshotWriter writer(false, &data, &allocator);
737 writer.WriteObject(object.raw()); 747 writer.WriteObject(object.raw());
738 writer.FinalizeBuffer(); 748 writer.FinalizeBuffer();
739 return PortMap::PostMessage(port_id, kNoReplyPort, data); 749 return PortMap::PostMessage(port_id, kNoReplyPort, Api::CastMessage(data));
740 } 750 }
741 751
742 752
743 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) { 753 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) {
744 Isolate* isolate = Isolate::Current(); 754 Isolate* isolate = Isolate::Current();
745 DARTSCOPE(isolate); 755 DARTSCOPE(isolate);
746 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl")); 756 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl"));
747 const String& function_name = String::Handle(String::NewSymbol("_create")); 757 const String& function_name = String::Handle(String::NewSymbol("_create"));
748 const int kNumArguments = 1; 758 const int kNumArguments = 1;
749 const Array& kNoArgumentNames = Array::Handle(); 759 const Array& kNoArgumentNames = Array::Handle();
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 } 2372 }
2363 delete debug_region; 2373 delete debug_region;
2364 } else { 2374 } else {
2365 *buffer = NULL; 2375 *buffer = NULL;
2366 *buffer_size = 0; 2376 *buffer_size = 0;
2367 } 2377 }
2368 } 2378 }
2369 2379
2370 2380
2371 } // namespace dart 2381 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698