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

Side by Side Diff: gin/object_template_builder.h

Issue 194603003: gin: Add the concept of named and indexed interceptors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 6 years, 9 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 | « gin/interceptor_unittest.cc ('k') | gin/object_template_builder.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 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GIN_OBJECT_TEMPLATE_BUILDER_H_ 5 #ifndef GIN_OBJECT_TEMPLATE_BUILDER_H_
6 #define GIN_OBJECT_TEMPLATE_BUILDER_H_ 6 #define GIN_OBJECT_TEMPLATE_BUILDER_H_
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 const T& getter, const U& setter) { 117 const T& getter, const U& setter) {
118 return SetPropertyImpl(name, 118 return SetPropertyImpl(name,
119 CallbackTraits<T>::CreateTemplate(isolate_, getter), 119 CallbackTraits<T>::CreateTemplate(isolate_, getter),
120 CallbackTraits<U>::CreateTemplate(isolate_, setter)); 120 CallbackTraits<U>::CreateTemplate(isolate_, setter));
121 } 121 }
122 template<typename T> 122 template<typename T>
123 ObjectTemplateBuilder& SetCallAsFunctionHandler(const T& callback) { 123 ObjectTemplateBuilder& SetCallAsFunctionHandler(const T& callback) {
124 CallbackTraits<T>::SetAsFunctionHandler(isolate_, template_, callback); 124 CallbackTraits<T>::SetAsFunctionHandler(isolate_, template_, callback);
125 return *this; 125 return *this;
126 } 126 }
127 ObjectTemplateBuilder& AddNamedPropertyInterceptor();
128 ObjectTemplateBuilder& AddIndexedPropertyInterceptor();
127 129
128 v8::Local<v8::ObjectTemplate> Build(); 130 v8::Local<v8::ObjectTemplate> Build();
129 131
130 private: 132 private:
131 ObjectTemplateBuilder& SetImpl(const base::StringPiece& name, 133 ObjectTemplateBuilder& SetImpl(const base::StringPiece& name,
132 v8::Handle<v8::Data> val); 134 v8::Handle<v8::Data> val);
133 ObjectTemplateBuilder& SetPropertyImpl( 135 ObjectTemplateBuilder& SetPropertyImpl(
134 const base::StringPiece& name, v8::Handle<v8::FunctionTemplate> getter, 136 const base::StringPiece& name, v8::Handle<v8::FunctionTemplate> getter,
135 v8::Handle<v8::FunctionTemplate> setter); 137 v8::Handle<v8::FunctionTemplate> setter);
136 138
137 v8::Isolate* isolate_; 139 v8::Isolate* isolate_;
138 140
139 // ObjectTemplateBuilder should only be used on the stack. 141 // ObjectTemplateBuilder should only be used on the stack.
140 v8::Local<v8::ObjectTemplate> template_; 142 v8::Local<v8::ObjectTemplate> template_;
141 }; 143 };
142 144
143 } // namespace gin 145 } // namespace gin
144 146
145 #endif // GIN_OBJECT_TEMPLATE_BUILDER_H_ 147 #endif // GIN_OBJECT_TEMPLATE_BUILDER_H_
OLDNEW
« no previous file with comments | « gin/interceptor_unittest.cc ('k') | gin/object_template_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698