• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// This file is generated by Object_cpp.template.
2
3// Copyright 2016 The Chromium Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style license that can be
5// found in the LICENSE file.
6
7//#include "Object.h"
8
9{% for namespace in config.protocol.namespace %}
10namespace {{namespace}} {
11{% endfor %}
12
13std::unique_ptr<Object> Object::fromValue(protocol::Value* value, ErrorSupport* errors)
14{
15    protocol::DictionaryValue* dictionary = DictionaryValue::cast(value);
16    if (!dictionary) {
17        errors->addError("object expected");
18        return nullptr;
19    }
20    dictionary = static_cast<protocol::DictionaryValue*>(dictionary->clone().release());
21    return std::unique_ptr<Object>(new Object(std::unique_ptr<DictionaryValue>(dictionary)));
22}
23
24std::unique_ptr<protocol::DictionaryValue> Object::toValue() const
25{
26    return DictionaryValue::cast(m_object->clone());
27}
28
29std::unique_ptr<Object> Object::clone() const
30{
31    return std::unique_ptr<Object>(new Object(DictionaryValue::cast(m_object->clone())));
32}
33
34Object::Object(std::unique_ptr<protocol::DictionaryValue> object) : m_object(std::move(object)) { }
35
36Object::~Object() { }
37
38{% for namespace in config.protocol.namespace %}
39} // namespace {{namespace}}
40{% endfor %}
41