aboutsummaryrefslogtreecommitdiff
path: root/src/action.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/action.cpp107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/action.cpp b/src/action.cpp
new file mode 100644
index 0000000..23c24cd
--- /dev/null
+++ b/src/action.cpp
@@ -0,0 +1,107 @@
1#include "action.h"
2#include "ast.h"
3#include "astbranch.h"
4#include "astleaf.h"
5#include "runner.h"
6#include "variable.h"
7
8Action::Action( const class AstBranch *pRoot ) :
9 pRoot( pRoot ),
10 pAst( NULL )
11{
12 sName = dynamic_cast<AstLeaf *>(
13 *(*pRoot->getBranchBegin()).begin()
14 )->getStrValue();
15}
16
17Action::~Action()
18{
19 delete pAst;
20 pAst = NULL;
21}
22
23const Bu::FString &Action::getName() const
24{
25 return sName;
26}
27
28void Action::call( class Runner *pRunner )
29{
30 pRunner->run( (*(pRoot->getBranchBegin()+1)).begin() );
31}
32
33Action *Action::genDefaultAll()
34{
35 Ast *pAst = new Ast();
36 pAst->addNode( AstNode::typeActionDef );
37 pAst->openBranch();
38 pAst->addNode( AstNode::typeString, "all" );
39 pAst->openBranch();
40 pAst->addNode( AstNode::typeProcessTarget );
41 pAst->openBranch();
42 pAst->addNode( AstNode::typeString, "build" );
43 pAst->openBranch();
44 pAst->addNode( AstNode::typeFunction );
45 pAst->openBranch();
46 pAst->addNode( AstNode::typeString, "targets" );
47 pAst->closeNode();
48 pAst->closeNode();
49 pAst->closeNode();
50 Action *pRet = new Action(
51 dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() )
52 );
53 pRet->pAst = pAst;
54
55 return pRet;
56}
57
58Action *Action::genDefaultClean()
59{
60 Ast *pAst = new Ast();
61 pAst->addNode( AstNode::typeActionDef );
62 pAst->openBranch();
63 pAst->addNode( AstNode::typeString, "clean" );
64 pAst->openBranch();
65 pAst->addNode( AstNode::typeProcessTarget );
66 pAst->openBranch();
67 pAst->addNode( AstNode::typeString, "clean" );
68 pAst->openBranch();
69 pAst->addNode( AstNode::typeFunction );
70 pAst->openBranch();
71 pAst->addNode( AstNode::typeString, "targets" );
72 pAst->closeNode();
73 pAst->closeNode();
74 pAst->closeNode();
75 Action *pRet = new Action(
76 dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() )
77 );
78 pRet->pAst = pAst;
79
80 return pRet;
81}
82
83Action *Action::genDefaultDefault()
84{
85 Ast *pAst = new Ast();
86 pAst->addNode( AstNode::typeActionDef );
87 pAst->openBranch();
88 pAst->addNode( AstNode::typeString, "default" );
89 pAst->openBranch();
90 pAst->addNode( AstNode::typeProcessTarget );
91 pAst->openBranch();
92 pAst->addNode( AstNode::typeString, "build" );
93 pAst->openBranch();
94 pAst->addNode( AstNode::typeFunction );
95 pAst->openBranch();
96 pAst->addNode( AstNode::typeString, "targets" );
97 pAst->closeNode();
98 pAst->closeNode();
99 pAst->closeNode();
100 Action *pRet = new Action(
101 dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() )
102 );
103 pRet->pAst = pAst;
104
105 return pRet;
106}
107