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

Side by Side Diff: src/api.cc

Issue 11087020: Add an API to let the embedder associate arbitrary data with a v8::Context. (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Add an API to let the embedder associate arbitrary data with a v8::Context. Created 8 years, 2 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 | « include/v8.h ('k') | src/contexts.h » ('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 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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 } 785 }
786 ASSERT(env->IsNativeContext()); 786 ASSERT(env->IsNativeContext());
787 if (!env->IsNativeContext()) { 787 if (!env->IsNativeContext()) {
788 return Local<Value>(); 788 return Local<Value>();
789 } 789 }
790 i::Handle<i::Object> result(env->data(), isolate); 790 i::Handle<i::Object> result(env->data(), isolate);
791 return Utils::ToLocal(result); 791 return Utils::ToLocal(result);
792 } 792 }
793 793
794 794
795 void Context::SetEmbedderData(void* ptr) {
796 i::Handle<i::Context> env = Utils::OpenHandle(this);
797 i::Isolate* isolate = env->GetIsolate();
798 if (IsDeadCheck(isolate, "v8::Context::SetEmbedderData()")) return;
799 Local<Value> data = External::Wrap(ptr);
800 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
801 ASSERT(env->IsNativeContext());
802 env->set_embedder_data(*raw_data);
803 }
804
805
806 void* Context::GetEmbedderData() {
807 i::Handle<i::Context> env = Utils::OpenHandle(this);
808 i::Isolate* isolate = env->GetIsolate();
809 if (IsDeadCheck(isolate, "v8::Context::GetEmbedderData()")) {
810 return 0;
811 }
812 i::Handle<i::Object> result(env->embedder_data(), isolate);
813 Local<Value> data = Utils::ToLocal(result);
814 return External::Unwrap(data);
815 }
816
817
795 i::Object** v8::HandleScope::RawClose(i::Object** value) { 818 i::Object** v8::HandleScope::RawClose(i::Object** value) {
796 if (!ApiCheck(!is_closed_, 819 if (!ApiCheck(!is_closed_,
797 "v8::HandleScope::Close()", 820 "v8::HandleScope::Close()",
798 "Local scope has already been closed")) { 821 "Local scope has already been closed")) {
799 return 0; 822 return 0;
800 } 823 }
801 LOG_API(isolate_, "CloseHandleScope"); 824 LOG_API(isolate_, "CloseHandleScope");
802 825
803 // Read the result before popping the handle block. 826 // Read the result before popping the handle block.
804 i::Object* result = NULL; 827 i::Object* result = NULL;
(...skipping 5785 matching lines...) Expand 10 before | Expand all | Expand 10 after
6590 6613
6591 v->VisitPointers(blocks_.first(), first_block_limit_); 6614 v->VisitPointers(blocks_.first(), first_block_limit_);
6592 6615
6593 for (int i = 1; i < blocks_.length(); i++) { 6616 for (int i = 1; i < blocks_.length(); i++) {
6594 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 6617 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6595 } 6618 }
6596 } 6619 }
6597 6620
6598 6621
6599 } } // namespace v8::internal 6622 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698