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

Side by Side Diff: gin/per_isolate_data.cc

Issue 67763002: Add gin, a lightweight bindings system for V8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Now with runner Created 7 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "gin/per_isolate_data.h"
6
7 using v8::Eternal;
8 using v8::Handle;
9 using v8::Isolate;
10 using v8::Local;
11 using v8::Object;
12 using v8::ObjectTemplate;
13
14 namespace gin {
15
16 PerIsolateData::PerIsolateData(Isolate* isolate)
17 : isolate_(isolate) {
18 isolate_->SetData(this);
19 }
20
21 PerIsolateData::~PerIsolateData() {
22 }
23
24 PerIsolateData* PerIsolateData::From(Isolate* isolate) {
25 return static_cast<PerIsolateData*>(isolate->GetData());
26 }
27
28 void PerIsolateData::RegisterObjectTemplate(
29 WrapperInfo* info, Local<ObjectTemplate> object_template) {
30 object_templates_[info] = Eternal<ObjectTemplate>(isolate_, object_template);
31 }
32
33 Handle<Object> PerIsolateData::CreateObject(WrapperInfo* info) {
34 Handle<ObjectTemplate> templ = object_templates_[info].Get(isolate_);
35 Handle<Object> object = templ->NewInstance();
36 object->SetAlignedPointerInInternalField(kWrapperInfoIndex, info);
37 return object;
38 }
39
40 } // namespace gin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698