| 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 #include "bindings/core/v8/V8ObjectBuilder.h" | 5 #include "bindings/core/v8/V8ObjectBuilder.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/V8Binding.h" | 7 #include "bindings/core/v8/V8Binding.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 V8ObjectBuilder::V8ObjectBuilder(ScriptState* scriptState) | 11 V8ObjectBuilder::V8ObjectBuilder(ScriptState* scriptState) |
| 12 : m_scriptState(scriptState), | 12 : m_scriptState(scriptState), |
| 13 m_object(v8::Object::New(scriptState->isolate())) {} | 13 m_object(v8::Object::New(scriptState->isolate())) {} |
| 14 | 14 |
| 15 V8ObjectBuilder& V8ObjectBuilder::add(const StringView& name, | 15 V8ObjectBuilder& V8ObjectBuilder::add(const StringView& name, |
| 16 const V8ObjectBuilder& value) { | 16 const V8ObjectBuilder& value) { |
| 17 addInternal(name, value.v8Value()); | 17 addInternal(name, value.v8Value()); |
| 18 return *this; | 18 return *this; |
| 19 } | 19 } |
| 20 | 20 |
| 21 V8ObjectBuilder& V8ObjectBuilder::addNull(const StringView& name) { | 21 V8ObjectBuilder& V8ObjectBuilder::addNull(const StringView& name) { |
| 22 addInternal(name, v8::Null(m_scriptState->isolate())); | 22 addInternal(name, v8::Null(m_scriptState->isolate())); |
| 23 return *this; | 23 return *this; |
| 24 } | 24 } |
| 25 | 25 |
| 26 V8ObjectBuilder& V8ObjectBuilder::addBoolean(const StringView& name, | 26 V8ObjectBuilder& V8ObjectBuilder::addBoolean(const StringView& name, |
| 27 bool value) { | 27 bool value) { |
| 28 addInternal(name, value ? v8::True(m_scriptState->isolate()) | 28 addInternal(name, |
| 29 : v8::False(m_scriptState->isolate())); | 29 value ? v8::True(m_scriptState->isolate()) |
| 30 : v8::False(m_scriptState->isolate())); |
| 30 return *this; | 31 return *this; |
| 31 } | 32 } |
| 32 | 33 |
| 33 V8ObjectBuilder& V8ObjectBuilder::addNumber(const StringView& name, | 34 V8ObjectBuilder& V8ObjectBuilder::addNumber(const StringView& name, |
| 34 double value) { | 35 double value) { |
| 35 addInternal(name, v8::Number::New(m_scriptState->isolate(), value)); | 36 addInternal(name, v8::Number::New(m_scriptState->isolate(), value)); |
| 36 return *this; | 37 return *this; |
| 37 } | 38 } |
| 38 | 39 |
| 39 V8ObjectBuilder& V8ObjectBuilder::addString(const StringView& name, | 40 V8ObjectBuilder& V8ObjectBuilder::addString(const StringView& name, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 62 return; | 63 return; |
| 63 if (value.IsEmpty() || | 64 if (value.IsEmpty() || |
| 64 m_object | 65 m_object |
| 65 ->CreateDataProperty(m_scriptState->context(), | 66 ->CreateDataProperty(m_scriptState->context(), |
| 66 v8String(m_scriptState->isolate(), name), value) | 67 v8String(m_scriptState->isolate(), name), value) |
| 67 .IsNothing()) | 68 .IsNothing()) |
| 68 m_object.Clear(); | 69 m_object.Clear(); |
| 69 } | 70 } |
| 70 | 71 |
| 71 } // namespace blink | 72 } // namespace blink |
| OLD | NEW |