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

Side by Side Diff: vm/dart_api_state.h

Issue 12036098: First set of changes towards cleaning up the bytearray access APIs (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 10 months 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 | « vm/dart_api_impl_test.cc ('k') | vm/dart_entry.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) 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 #ifndef VM_DART_API_STATE_H_ 5 #ifndef VM_DART_API_STATE_H_
6 #define VM_DART_API_STATE_H_ 6 #define VM_DART_API_STATE_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "platform/thread.h" 10 #include "platform/thread.h"
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 DISALLOW_COPY_AND_ASSIGN(ApiLocalScope); 519 DISALLOW_COPY_AND_ASSIGN(ApiLocalScope);
520 }; 520 };
521 521
522 522
523 // Implementation of the API State used in dart api for maintaining 523 // Implementation of the API State used in dart api for maintaining
524 // local scopes, persistent handles etc. These are setup on a per isolate 524 // local scopes, persistent handles etc. These are setup on a per isolate
525 // basis and destroyed when the isolate is shutdown. 525 // basis and destroyed when the isolate is shutdown.
526 class ApiState { 526 class ApiState {
527 public: 527 public:
528 ApiState() : top_scope_(NULL), delayed_weak_reference_sets_(NULL), 528 ApiState() : top_scope_(NULL), delayed_weak_reference_sets_(NULL),
529 null_(NULL), true_(NULL), false_(NULL) { } 529 null_(NULL), true_(NULL), false_(NULL),
530 callback_error_(NULL) {}
530 ~ApiState() { 531 ~ApiState() {
531 while (top_scope_ != NULL) { 532 while (top_scope_ != NULL) {
532 ApiLocalScope* scope = top_scope_; 533 ApiLocalScope* scope = top_scope_;
533 top_scope_ = top_scope_->previous(); 534 top_scope_ = top_scope_->previous();
534 delete scope; 535 delete scope;
535 } 536 }
536 if (null_ != NULL) { 537 if (null_ != NULL) {
537 persistent_handles().FreeHandle(null_); 538 persistent_handles().FreeHandle(null_);
538 null_ = NULL; 539 null_ = NULL;
539 } 540 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 PersistentHandle* False() { 669 PersistentHandle* False() {
669 if (false_ == NULL) { 670 if (false_ == NULL) {
670 DARTSCOPE(Isolate::Current()); 671 DARTSCOPE(Isolate::Current());
671 672
672 false_ = persistent_handles().AllocateHandle(); 673 false_ = persistent_handles().AllocateHandle();
673 false_->set_raw(Bool::False()); 674 false_->set_raw(Bool::False());
674 } 675 }
675 return false_; 676 return false_;
676 } 677 }
677 678
679 void SetupCallbackError() {
680 ASSERT(callback_error_ == NULL);
681 callback_error_ = persistent_handles().AllocateHandle();
682 callback_error_->set_raw(
683 String::New("Internal Dart data pointers have been acquired, "
684 "please release them using Dart_ByteArrayReleaseData."));
685 }
686
687 PersistentHandle* CallbackError() const {
688 ASSERT(callback_error_ != NULL);
689 return callback_error_;
690 }
691
678 void DelayWeakReferenceSet(WeakReferenceSet* reference_set) { 692 void DelayWeakReferenceSet(WeakReferenceSet* reference_set) {
679 WeakReferenceSet::Push(reference_set, &delayed_weak_reference_sets_); 693 WeakReferenceSet::Push(reference_set, &delayed_weak_reference_sets_);
680 } 694 }
681 695
682 private: 696 private:
683 PersistentHandles persistent_handles_; 697 PersistentHandles persistent_handles_;
684 FinalizablePersistentHandles weak_persistent_handles_; 698 FinalizablePersistentHandles weak_persistent_handles_;
685 FinalizablePersistentHandles prologue_weak_persistent_handles_; 699 FinalizablePersistentHandles prologue_weak_persistent_handles_;
686 ApiLocalScope* top_scope_; 700 ApiLocalScope* top_scope_;
687 WeakReferenceSet* delayed_weak_reference_sets_; 701 WeakReferenceSet* delayed_weak_reference_sets_;
688 702
689 // Persistent handles to important objects. 703 // Persistent handles to important objects.
690 PersistentHandle* null_; 704 PersistentHandle* null_;
691 PersistentHandle* true_; 705 PersistentHandle* true_;
692 PersistentHandle* false_; 706 PersistentHandle* false_;
707 PersistentHandle* callback_error_;
693 708
694 DISALLOW_COPY_AND_ASSIGN(ApiState); 709 DISALLOW_COPY_AND_ASSIGN(ApiState);
695 }; 710 };
696 711
697 712
698 class ApiNativeScope { 713 class ApiNativeScope {
699 public: 714 public:
700 ApiNativeScope() { 715 ApiNativeScope() {
701 // Currently no support for nesting native scopes. 716 // Currently no support for nesting native scopes.
702 ASSERT(Current() == NULL); 717 ASSERT(Current() == NULL);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 ApiNativeScope::Current()->zone()) {} 749 ApiNativeScope::Current()->zone()) {}
735 ApiGrowableArray() 750 ApiGrowableArray()
736 : BaseGrowableArray<T, ValueObject>( 751 : BaseGrowableArray<T, ValueObject>(
737 ApiNativeScope::Current()->zone()) {} 752 ApiNativeScope::Current()->zone()) {}
738 }; 753 };
739 754
740 755
741 } // namespace dart 756 } // namespace dart
742 757
743 #endif // VM_DART_API_STATE_H_ 758 #endif // VM_DART_API_STATE_H_
OLDNEW
« no previous file with comments | « vm/dart_api_impl_test.cc ('k') | vm/dart_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698