Update broken references to image assets
[chromium-blink-merge.git] / tools / gn / template.h
blob43aaf7f43a919d461ea7a93f06b3974d2d45bb67
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef TOOLS_GN_TEMPLATE_H_
6 #define TOOLS_GN_TEMPLATE_H_
8 #include <vector>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
13 class BlockNode;
14 class Err;
15 class FunctionCallNode;
16 class LocationRange;
17 class Scope;
18 class Value;
20 // Represents the information associated with a template() call in GN, which
21 // includes a closure and the code to run when the template is invoked.
23 // This class is immutable so we can reference it from multiple threads without
24 // locking. Normally, this will be assocated with a .gni file and then a
25 // reference will be taken by each .gn file that imports it. These files might
26 // execute the template in parallel.
27 class Template : public base::RefCountedThreadSafe<Template> {
28 public:
29 // Makes a new closure based on the given scope.
30 Template(const Scope* scope, const FunctionCallNode* def);
32 // Takes ownership of a previously-constructed closure.
33 Template(scoped_ptr<Scope> closure, const FunctionCallNode* def);
35 // Invoke the template. The values correspond to the state of the code
36 // invoking the template.
37 Value Invoke(Scope* scope,
38 const FunctionCallNode* invocation,
39 const std::vector<Value>& args,
40 BlockNode* block,
41 Err* err) const;
43 // Returns the location range where this template was defined.
44 LocationRange GetDefinitionRange() const;
46 private:
47 friend class base::RefCountedThreadSafe<Template>;
49 Template();
50 ~Template();
52 scoped_ptr<Scope> closure_;
53 const FunctionCallNode* definition_;
56 #endif // TOOLS_GN_TEMPLATE_H_