| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "tools/gn/value.h" | 5 #include "tools/gn/value.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 11 #include "tools/gn/scope.h" | 12 #include "tools/gn/scope.h" |
| 12 | 13 |
| 13 Value::Value() | 14 Value::Value() |
| 14 : type_(NONE), | 15 : type_(NONE), |
| 15 boolean_value_(false), | 16 boolean_value_(false), |
| 16 int_value_(0), | 17 int_value_(0), |
| 17 origin_(nullptr) { | 18 origin_(nullptr) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 boolean_value_(false), | 54 boolean_value_(false), |
| 54 int_value_(0), | 55 int_value_(0), |
| 55 origin_(origin) { | 56 origin_(origin) { |
| 56 } | 57 } |
| 57 | 58 |
| 58 Value::Value(const ParseNode* origin, scoped_ptr<Scope> scope) | 59 Value::Value(const ParseNode* origin, scoped_ptr<Scope> scope) |
| 59 : type_(SCOPE), | 60 : type_(SCOPE), |
| 60 string_value_(), | 61 string_value_(), |
| 61 boolean_value_(false), | 62 boolean_value_(false), |
| 62 int_value_(0), | 63 int_value_(0), |
| 63 scope_value_(scope.Pass()), | 64 scope_value_(std::move(scope)), |
| 64 origin_(origin) { | 65 origin_(origin) {} |
| 65 } | |
| 66 | 66 |
| 67 Value::Value(const Value& other) | 67 Value::Value(const Value& other) |
| 68 : type_(other.type_), | 68 : type_(other.type_), |
| 69 string_value_(other.string_value_), | 69 string_value_(other.string_value_), |
| 70 boolean_value_(other.boolean_value_), | 70 boolean_value_(other.boolean_value_), |
| 71 int_value_(other.int_value_), | 71 int_value_(other.int_value_), |
| 72 list_value_(other.list_value_), | 72 list_value_(other.list_value_), |
| 73 origin_(other.origin_) { | 73 origin_(other.origin_) { |
| 74 if (type() == SCOPE && other.scope_value_.get()) | 74 if (type() == SCOPE && other.scope_value_.get()) |
| 75 scope_value_ = other.scope_value_->MakeClosure(); | 75 scope_value_ = other.scope_value_->MakeClosure(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 106 case SCOPE: | 106 case SCOPE: |
| 107 return "scope"; | 107 return "scope"; |
| 108 default: | 108 default: |
| 109 NOTREACHED(); | 109 NOTREACHED(); |
| 110 return "UNKNOWN"; | 110 return "UNKNOWN"; |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 void Value::SetScopeValue(scoped_ptr<Scope> scope) { | 114 void Value::SetScopeValue(scoped_ptr<Scope> scope) { |
| 115 DCHECK(type_ == SCOPE); | 115 DCHECK(type_ == SCOPE); |
| 116 scope_value_ = scope.Pass(); | 116 scope_value_ = std::move(scope); |
| 117 } | 117 } |
| 118 | 118 |
| 119 std::string Value::ToString(bool quote_string) const { | 119 std::string Value::ToString(bool quote_string) const { |
| 120 switch (type_) { | 120 switch (type_) { |
| 121 case NONE: | 121 case NONE: |
| 122 return "<void>"; | 122 return "<void>"; |
| 123 case BOOLEAN: | 123 case BOOLEAN: |
| 124 return boolean_value_ ? "true" : "false"; | 124 return boolean_value_ ? "true" : "false"; |
| 125 case INTEGER: | 125 case INTEGER: |
| 126 return base::Int64ToString(int_value_); | 126 return base::Int64ToString(int_value_); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // iteration code. | 214 // iteration code. |
| 215 return false; | 215 return false; |
| 216 default: | 216 default: |
| 217 return false; | 217 return false; |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 bool Value::operator!=(const Value& other) const { | 221 bool Value::operator!=(const Value& other) const { |
| 222 return !operator==(other); | 222 return !operator==(other); |
| 223 } | 223 } |
| OLD | NEW |