| OLD | NEW |
| 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 <type_traits> | 8 #include <type_traits> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 } // namespace | 84 } // namespace |
| 85 | 85 |
| 86 | 86 |
| 87 // ObjectTemplateBuilder provides a handy interface to creating | 87 // ObjectTemplateBuilder provides a handy interface to creating |
| 88 // v8::ObjectTemplate instances with various sorts of properties. | 88 // v8::ObjectTemplate instances with various sorts of properties. |
| 89 class GIN_EXPORT ObjectTemplateBuilder { | 89 class GIN_EXPORT ObjectTemplateBuilder { |
| 90 public: | 90 public: |
| 91 explicit ObjectTemplateBuilder(v8::Isolate* isolate); | 91 explicit ObjectTemplateBuilder(v8::Isolate* isolate); |
| 92 ObjectTemplateBuilder(const ObjectTemplateBuilder& other); |
| 92 ~ObjectTemplateBuilder(); | 93 ~ObjectTemplateBuilder(); |
| 93 | 94 |
| 94 // It's against Google C++ style to return a non-const ref, but we take some | 95 // It's against Google C++ style to return a non-const ref, but we take some |
| 95 // poetic license here in order that all calls to Set() can be via the '.' | 96 // poetic license here in order that all calls to Set() can be via the '.' |
| 96 // operator and line up nicely. | 97 // operator and line up nicely. |
| 97 template<typename T> | 98 template<typename T> |
| 98 ObjectTemplateBuilder& SetValue(const base::StringPiece& name, T val) { | 99 ObjectTemplateBuilder& SetValue(const base::StringPiece& name, T val) { |
| 99 return SetImpl(name, ConvertToV8(isolate_, val)); | 100 return SetImpl(name, ConvertToV8(isolate_, val)); |
| 100 } | 101 } |
| 101 | 102 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 142 |
| 142 v8::Isolate* isolate_; | 143 v8::Isolate* isolate_; |
| 143 | 144 |
| 144 // ObjectTemplateBuilder should only be used on the stack. | 145 // ObjectTemplateBuilder should only be used on the stack. |
| 145 v8::Local<v8::ObjectTemplate> template_; | 146 v8::Local<v8::ObjectTemplate> template_; |
| 146 }; | 147 }; |
| 147 | 148 |
| 148 } // namespace gin | 149 } // namespace gin |
| 149 | 150 |
| 150 #endif // GIN_OBJECT_TEMPLATE_BUILDER_H_ | 151 #endif // GIN_OBJECT_TEMPLATE_BUILDER_H_ |
| OLD | NEW |