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

Unified Diff: tools/gn/template.h

Issue 212933008: Don't dynamically scope GN templates. (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/scope_unittest.cc ('k') | tools/gn/template.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/template.h
diff --git a/tools/gn/template.h b/tools/gn/template.h
new file mode 100644
index 0000000000000000000000000000000000000000..01768620ec98bbe293d05ba66c5044ddfa2f1a97
--- /dev/null
+++ b/tools/gn/template.h
@@ -0,0 +1,53 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TOOLS_GN_TEMPLATE_H_
+#define TOOLS_GN_TEMPLATE_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+
+class BlockNode;
+class Err;
+class FunctionCallNode;
+class LocationRange;
+class Scope;
+class Value;
+
+class Template {
+ public:
+ // Makes a new closure based on the given scope.
+ Template(const Scope* scope, const FunctionCallNode* def);
+
+ // Takes ownership of a previously-constructed closure.
+ Template(scoped_ptr<Scope> closure, const FunctionCallNode* def);
+
+ ~Template();
+
+ // Makes a copy of this template.
+ scoped_ptr<Template> Clone() const;
+
+ // Invoke the template. The values correspond to the state of the code
+ // invoking the template.
+ Value Invoke(Scope* scope,
+ const FunctionCallNode* invocation,
+ const std::vector<Value>& args,
+ BlockNode* block,
+ Err* err) const;
+
+ // Returns the location range where this template was defined.
+ LocationRange GetDefinitionRange() const;
+
+ private:
+ Template();
+
+ scoped_ptr<Scope> closure_;
+ const FunctionCallNode* definition_;
+
+ DISALLOW_COPY_AND_ASSIGN(Template);
+};
+
+#endif // TOOLS_GN_TEMPLATE_H_
« no previous file with comments | « tools/gn/scope_unittest.cc ('k') | tools/gn/template.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698