summaryrefslogtreecommitdiffstats
path: root/tools/gn/template.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gn/template.h')
-rw-r--r--tools/gn/template.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/tools/gn/template.h b/tools/gn/template.h
new file mode 100644
index 0000000..0176862
--- /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_