GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
UsedExtensionsFinder.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 
7 #ifndef GDCORE_USED_EXTENSIONS_FINDER_H
8 #define GDCORE_USED_EXTENSIONS_FINDER_H
9 #include <set>
10 
11 #include "GDCore/Events/Parsers/ExpressionParser2NodeWorker.h"
12 #include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
13 #include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
14 #include "GDCore/String.h"
15 
16 namespace gd {
17 class Project;
18 class Object;
19 class Behavior;
20 } // namespace gd
21 
22 namespace gd {
23 
24 class GD_CORE_API UsedExtensionsResult {
25 public:
29  const std::set<gd::String> &GetUsedExtensions() const {
30  return usedExtensions;
31  }
32 
36  const std::set<gd::String> &GetUsedIncludeFiles() const {
37  return usedIncludeFiles;
38  }
39 
43  const std::set<gd::String> &GetUsedRequiredFiles() const {
44  return usedRequiredFiles;
45  }
46 
50  bool Has3DObjects() const {
51  return has3DObjects;
52  }
53 
57  std::set<gd::String> &GetUsedExtensions() { return usedExtensions; }
58 
62  std::set<gd::String> &GetUsedIncludeFiles() { return usedIncludeFiles; }
63 
67  std::set<gd::String> &GetUsedRequiredFiles() { return usedRequiredFiles; }
68 
69  void MarkAsHaving3DObjects() {
70  has3DObjects = true;
71  }
72 
73 private:
74  std::set<gd::String> usedExtensions;
75  std::set<gd::String> usedIncludeFiles;
76  std::set<gd::String> usedRequiredFiles;
77  bool has3DObjects = false;
78 };
79 
80 class GD_CORE_API UsedExtensionsFinder
81  : public ArbitraryObjectsWorker,
84  public:
85  static const UsedExtensionsResult ScanProject(gd::Project& project);
86 
87  private:
88  UsedExtensionsFinder(gd::Project& project_) : project(project_){};
89  gd::Project& project;
90  gd::String rootType;
91  UsedExtensionsResult result;
92 
93  // Object Visitor
94  void DoVisitObject(gd::Object& object) override;
95 
96  // Behavior Visitor
97  void DoVisitBehavior(gd::Behavior& behavior) override;
98 
99  // Instructions Visitor
100  bool DoVisitInstruction(gd::Instruction& instruction,
101  bool isCondition) override;
102 
103  // Expression Visitor
104  void OnVisitSubExpressionNode(SubExpressionNode& node) override;
105  void OnVisitOperatorNode(OperatorNode& node) override;
106  void OnVisitUnaryOperatorNode(UnaryOperatorNode& node) override;
107  void OnVisitNumberNode(NumberNode& node) override;
108  void OnVisitTextNode(TextNode& node) override;
109  void OnVisitVariableNode(VariableNode& node) override;
110  void OnVisitVariableAccessorNode(VariableAccessorNode& node) override;
111  void OnVisitVariableBracketAccessorNode(
112  VariableBracketAccessorNode& node) override;
113  void OnVisitIdentifierNode(IdentifierNode& node) override;
114  void OnVisitObjectFunctionNameNode(ObjectFunctionNameNode& node) override;
115  void OnVisitFunctionCallNode(FunctionCallNode& node) override;
116  void OnVisitEmptyNode(EmptyNode& node) override;
117 };
118 
119 }; // namespace gd
120 
121 #endif
An events worker that will know about the context (the objects container). Useful for workers working...
Definition: ArbitraryEventsWorker.h:113
ArbitraryObjectsWorker is an abstract class used to browse objects (and behaviors) and do some work o...
Definition: ArbitraryObjectsWorker.h:30
Base class used to represents a behavior that can be applied to an object. It stores the content (i....
Definition: Behavior.h:23
The interface for any worker class ("visitor" pattern) that want to interact with the nodes of a pars...
Definition: ExpressionParser2NodeWorker.h:36
An instruction is a member of an event: It can be a condition or an action.
Definition: Instruction.h:30
Represent an object of a platform.
Definition: Object.h:37
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:50
String represents an UTF8 encoded string.
Definition: String.h:31
Definition: UsedExtensionsFinder.h:83
Definition: UsedExtensionsFinder.h:24
std::set< gd::String > & GetUsedIncludeFiles()
Definition: UsedExtensionsFinder.h:62
const std::set< gd::String > & GetUsedExtensions() const
Definition: UsedExtensionsFinder.h:29
std::set< gd::String > & GetUsedRequiredFiles()
Definition: UsedExtensionsFinder.h:67
const std::set< gd::String > & GetUsedRequiredFiles() const
Definition: UsedExtensionsFinder.h:43
std::set< gd::String > & GetUsedExtensions()
Definition: UsedExtensionsFinder.h:57
bool Has3DObjects() const
Return true when at least 1 object uses the 3D renderer.
Definition: UsedExtensionsFinder.h:50
const std::set< gd::String > & GetUsedIncludeFiles() const
Definition: UsedExtensionsFinder.h:36
Definition: CommonTools.h:24
An empty node, used when parsing failed/a syntax error was encountered and any other node could not m...
Definition: ExpressionParser2Node.h:416
A function call node (either free function, object function or object behavior function)....
Definition: ExpressionParser2Node.h:364
An identifier node, usually representing an object or a variable with an optional function name or ch...
Definition: ExpressionParser2Node.h:197
A number node. For example: "123". Its type is always "number".
Definition: ExpressionParser2Node.h:154
The name of a function to call on an object or the behavior For example: "MyObject....
Definition: ExpressionParser2Node.h:314
An operator node. For example: "lhs + rhs".
Definition: ExpressionParser2Node.h:122
Definition: ExpressionParser2Node.h:108
A text node. For example: "Hello World". Its type is always "string".
Definition: ExpressionParser2Node.h:170
A unary operator node. For example: "-2".
Definition: ExpressionParser2Node.h:138
A direct accessor to a child variable. Example: MyChild in MyVariable.MyChild.
Definition: ExpressionParser2Node.h:275
A bracket accessor to a child variable. Example: ["MyChild"] (in MyVariable["MyChild"]).
Definition: ExpressionParser2Node.h:293
A variable, or object variable, with bracket accessor or at least 2 "dot" accessors.
Definition: ExpressionParser2Node.h:254