OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 V8ObjectBuilder_h | 5 #ifndef V8ObjectBuilder_h |
6 #define V8ObjectBuilder_h | 6 #define V8ObjectBuilder_h |
7 | 7 |
8 #include <v8.h> | 8 #include <v8.h> |
9 #include "bindings/core/v8/ToV8.h" | 9 #include "bindings/core/v8/ToV8.h" |
10 #include "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 V8ObjectBuilder& addNull(const StringView& name); | 29 V8ObjectBuilder& addNull(const StringView& name); |
30 V8ObjectBuilder& addBoolean(const StringView& name, bool value); | 30 V8ObjectBuilder& addBoolean(const StringView& name, bool value); |
31 V8ObjectBuilder& addNumber(const StringView& name, double value); | 31 V8ObjectBuilder& addNumber(const StringView& name, double value); |
32 V8ObjectBuilder& addString(const StringView& name, const StringView& value); | 32 V8ObjectBuilder& addString(const StringView& name, const StringView& value); |
33 V8ObjectBuilder& addStringOrNull(const StringView& name, | 33 V8ObjectBuilder& addStringOrNull(const StringView& name, |
34 const StringView& value); | 34 const StringView& value); |
35 | 35 |
36 template <typename T> | 36 template <typename T> |
37 V8ObjectBuilder& add(const StringView& name, const T& value) { | 37 V8ObjectBuilder& add(const StringView& name, const T& value) { |
38 addInternal(name, v8::Local<v8::Value>( | 38 addInternal( |
39 ToV8(value, m_scriptState->context()->Global(), | 39 name, |
40 m_scriptState->isolate()))); | 40 v8::Local<v8::Value>(ToV8(value, m_scriptState->context()->Global(), |
| 41 m_scriptState->isolate()))); |
41 return *this; | 42 return *this; |
42 } | 43 } |
43 | 44 |
44 ScriptValue scriptValue() const; | 45 ScriptValue scriptValue() const; |
45 v8::Local<v8::Object> v8Value() const { return m_object; } | 46 v8::Local<v8::Object> v8Value() const { return m_object; } |
46 | 47 |
47 private: | 48 private: |
48 void addInternal(const StringView& name, v8::Local<v8::Value>); | 49 void addInternal(const StringView& name, v8::Local<v8::Value>); |
49 | 50 |
50 RefPtr<ScriptState> m_scriptState; | 51 RefPtr<ScriptState> m_scriptState; |
51 v8::Local<v8::Object> m_object; | 52 v8::Local<v8::Object> m_object; |
52 }; | 53 }; |
53 | 54 |
54 } // namespace blink | 55 } // namespace blink |
55 | 56 |
56 #endif // V8ObjectBuilder_h | 57 #endif // V8ObjectBuilder_h |
OLD | NEW |