GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
ExpressionsRenamer.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 #ifndef ExpressionsRenamer_H
7 #define ExpressionsRenamer_H
8 #include <map>
9 #include <memory>
10 #include <vector>
11 #include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
12 #include "GDCore/String.h"
13 namespace gd {
14 class BaseEvent;
15 class Platform;
16 class EventsList;
17 } // namespace gd
18 
19 namespace gd {
20 
28  public:
29  ExpressionsRenamer(const gd::Platform &platform_) : platform(platform_){};
30  virtual ~ExpressionsRenamer();
31 
32  ExpressionsRenamer &SetReplacedFreeExpression(
33  const gd::String &oldFunctionName_, const gd::String &newFunctionName_) {
34  objectType = "";
35  behaviorType = "";
36  oldFunctionName = oldFunctionName_;
37  newFunctionName = newFunctionName_;
38  return *this;
39  }
40  ExpressionsRenamer &SetReplacedObjectExpression(
41  const gd::String &objectType_,
42  const gd::String &oldFunctionName_,
43  const gd::String &newFunctionName_) {
44  objectType = objectType_;
45  behaviorType = "";
46  oldFunctionName = oldFunctionName_;
47  newFunctionName = newFunctionName_;
48  return *this;
49  };
50  ExpressionsRenamer &SetReplacedBehaviorExpression(
51  const gd::String &behaviorType_,
52  const gd::String &oldFunctionName_,
53  const gd::String &newFunctionName_) {
54  objectType = "";
55  behaviorType = behaviorType_;
56  oldFunctionName = oldFunctionName_;
57  newFunctionName = newFunctionName_;
58  return *this;
59  };
60 
61  private:
62  bool DoVisitInstruction(gd::Instruction &instruction,
63  bool isCondition) override;
64 
65  const gd::Platform &platform;
66  gd::String oldFunctionName;
67  gd::String newFunctionName;
68  gd::String behaviorType;
69  gd::String objectType;
70 };
71 
72 } // namespace gd
73 
74 #endif // ExpressionsRenamer_H
An events worker that will know about the context (the objects container). Useful for workers working...
Definition: ArbitraryEventsWorker.h:113
Replace in expressions, in parameters of actions or conditions, calls to a function by another functi...
Definition: ExpressionsRenamer.h:27
An instruction is a member of an event: It can be a condition or an action.
Definition: Instruction.h:30
Base class for implementing a platform.
Definition: Platform.h:42
String represents an UTF8 encoded string.
Definition: String.h:31
Definition: CommonTools.h:24