Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: tools/gn/value.cc

Issue 223783005: Add support for reading .gypi files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/value.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/value.cc
diff --git a/tools/gn/value.cc b/tools/gn/value.cc
index 6bf78da2cfaf5753b7af7c6586a284f7c6edd29d..1fb7155dc1b609d410f884d5f3163b7b016ca760 100644
--- a/tools/gn/value.cc
+++ b/tools/gn/value.cc
@@ -5,12 +5,12 @@
#include "tools/gn/value.h"
#include "base/strings/string_number_conversions.h"
+#include "tools/gn/scope.h"
Value::Value()
: type_(NONE),
boolean_value_(false),
int_value_(0),
- scope_value_(NULL),
origin_(NULL) {
}
@@ -18,7 +18,6 @@ Value::Value(const ParseNode* origin, Type t)
: type_(t),
boolean_value_(false),
int_value_(0),
- scope_value_(NULL),
origin_(origin) {
}
@@ -26,7 +25,6 @@ Value::Value(const ParseNode* origin, bool bool_val)
: type_(BOOLEAN),
boolean_value_(bool_val),
int_value_(0),
- scope_value_(NULL),
origin_(origin) {
}
@@ -34,7 +32,6 @@ Value::Value(const ParseNode* origin, int64 int_val)
: type_(INTEGER),
boolean_value_(false),
int_value_(int_val),
- scope_value_(NULL),
origin_(origin) {
}
@@ -43,7 +40,6 @@ Value::Value(const ParseNode* origin, std::string str_val)
string_value_(),
boolean_value_(false),
int_value_(0),
- scope_value_(NULL),
origin_(origin) {
string_value_.swap(str_val);
}
@@ -53,22 +49,44 @@ Value::Value(const ParseNode* origin, const char* str_val)
string_value_(str_val),
boolean_value_(false),
int_value_(0),
- scope_value_(NULL),
origin_(origin) {
}
-Value::Value(const ParseNode* origin, Scope* scope)
+Value::Value(const ParseNode* origin, scoped_ptr<Scope> scope)
: type_(SCOPE),
string_value_(),
boolean_value_(false),
int_value_(0),
- scope_value_(scope),
+ scope_value_(scope.Pass()),
origin_(origin) {
}
+Value::Value(const Value& other)
+ : type_(other.type_),
+ string_value_(other.string_value_),
+ boolean_value_(other.boolean_value_),
+ int_value_(other.int_value_),
+ list_value_(other.list_value_),
+ origin_(other.origin_) {
+ if (type() == SCOPE && other.scope_value_.get())
+ scope_value_ = other.scope_value_->MakeClosure();
+}
+
Value::~Value() {
}
+Value& Value::operator=(const Value& other) {
+ type_ = other.type_;
+ string_value_ = other.string_value_;
+ boolean_value_ = other.boolean_value_;
+ int_value_ = other.int_value_;
+ list_value_ = other.list_value_;
+ if (type() == SCOPE && other.scope_value_.get())
+ scope_value_ = other.scope_value_->MakeClosure();
+ origin_ = other.origin_;
+ return *this;
+}
+
void Value::RecursivelySetOrigin(const ParseNode* origin) {
set_origin(origin);
if (type_ == Value::LIST) {
@@ -98,6 +116,11 @@ const char* Value::DescribeType(Type t) {
}
}
+void Value::SetScopeValue(scoped_ptr<Scope> scope) {
+ DCHECK(type_ == SCOPE);
+ scope_value_ = scope.Pass();
+}
+
std::string Value::ToString(bool quote_string) const {
switch (type_) {
case NONE:
@@ -154,9 +177,10 @@ bool Value::operator==(const Value& other) const {
}
return true;
case Value::SCOPE:
- // Its not clear what people mean when comparing scope values, so we test
- // for scope identity and not contents equality.
- return scope_value() == other.scope_value();
+ // Scopes are always considered not equal because there's currently
+ // no use case for comparing them, and it requires a bunch of complex
+ // iteration code.
+ return false;
default:
return false;
}
« no previous file with comments | « tools/gn/value.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698