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

Side by Side Diff: src/api.cc

Issue 10907189: Let the embedder store arbitrary Values via Context::SetData (Closed) Base URL: http://git.chromium.org/external/v8.git@master
Patch Set: Created 8 years, 3 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
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 } 756 }
757 757
758 // Content of 'last_context' could be NULL. 758 // Content of 'last_context' could be NULL.
759 i::Context* last_context = 759 i::Context* last_context =
760 isolate->handle_scope_implementer()->RestoreContext(); 760 isolate->handle_scope_implementer()->RestoreContext();
761 isolate->set_context(last_context); 761 isolate->set_context(last_context);
762 isolate->set_context_exit_happened(true); 762 isolate->set_context_exit_happened(true);
763 } 763 }
764 764
765 765
766 void Context::SetData(v8::Handle<String> data) { 766 void Context::SetData(v8::Handle<Value> data) {
767 i::Handle<i::Context> env = Utils::OpenHandle(this); 767 i::Handle<i::Context> env = Utils::OpenHandle(this);
768 i::Isolate* isolate = env->GetIsolate(); 768 i::Isolate* isolate = env->GetIsolate();
769 if (IsDeadCheck(isolate, "v8::Context::SetData()")) return; 769 if (IsDeadCheck(isolate, "v8::Context::SetData()")) return;
770 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data); 770 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
771 ASSERT(env->IsNativeContext()); 771 ASSERT(env->IsNativeContext());
772 if (env->IsNativeContext()) { 772 if (env->IsNativeContext()) {
773 env->set_data(*raw_data); 773 env->set_data(*raw_data);
774 } 774 }
775 } 775 }
776 776
777 777
778 v8::Local<v8::Value> Context::GetData() { 778 v8::Local<v8::Value> Context::GetData() {
779 i::Handle<i::Context> env = Utils::OpenHandle(this); 779 i::Handle<i::Context> env = Utils::OpenHandle(this);
780 i::Isolate* isolate = env->GetIsolate(); 780 i::Isolate* isolate = env->GetIsolate();
781 if (IsDeadCheck(isolate, "v8::Context::GetData()")) { 781 if (IsDeadCheck(isolate, "v8::Context::GetData()")) {
782 return v8::Local<Value>();
783 }
784 i::Object* raw_result = NULL;
785 ASSERT(env->IsNativeContext());
786 if (env->IsNativeContext()) {
787 raw_result = env->data();
788 } else {
789 return Local<Value>(); 782 return Local<Value>();
790 } 783 }
791 i::Handle<i::Object> result(raw_result, isolate); 784 ASSERT(env->IsNativeContext());
785 if (!env->IsNativeContext()) {
Sven Panne 2012/09/13 07:39:28 I see that this has been here before, but it looks
danno 2012/09/14 13:15:14 It's probably outside of the scope of this CL to f
786 return Local<Value>();
787 }
788 i::Handle<i::Object> result(env->data(), isolate);
792 return Utils::ToLocal(result); 789 return Utils::ToLocal(result);
793 } 790 }
794 791
795 792
796 i::Object** v8::HandleScope::RawClose(i::Object** value) { 793 i::Object** v8::HandleScope::RawClose(i::Object** value) {
797 if (!ApiCheck(!is_closed_, 794 if (!ApiCheck(!is_closed_,
798 "v8::HandleScope::Close()", 795 "v8::HandleScope::Close()",
799 "Local scope has already been closed")) { 796 "Local scope has already been closed")) {
800 return 0; 797 return 0;
801 } 798 }
(...skipping 5750 matching lines...) Expand 10 before | Expand all | Expand 10 after
6552 6549
6553 v->VisitPointers(blocks_.first(), first_block_limit_); 6550 v->VisitPointers(blocks_.first(), first_block_limit_);
6554 6551
6555 for (int i = 1; i < blocks_.length(); i++) { 6552 for (int i = 1; i < blocks_.length(); i++) {
6556 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 6553 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6557 } 6554 }
6558 } 6555 }
6559 6556
6560 6557
6561 } } // namespace v8::internal 6558 } } // namespace v8::internal
OLDNEW
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698