aboutsummaryrefslogtreecommitdiff
path: root/src/action.cpp
blob: 23c24cd2f24af7fd855a102bed7f9bd47f77089f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "action.h"
#include "ast.h"
#include "astbranch.h"
#include "astleaf.h"
#include "runner.h"
#include "variable.h"

Action::Action( const class AstBranch *pRoot ) :
	pRoot( pRoot ),
	pAst( NULL )
{
	sName = dynamic_cast<AstLeaf *>(
		*(*pRoot->getBranchBegin()).begin()
		)->getStrValue();
}

Action::~Action()
{
	delete pAst;
	pAst = NULL;
}

const Bu::FString &Action::getName() const
{
	return sName;
}

void Action::call( class Runner *pRunner )
{
	pRunner->run( (*(pRoot->getBranchBegin()+1)).begin() );
}

Action *Action::genDefaultAll()
{
	Ast *pAst = new Ast();
	pAst->addNode( AstNode::typeActionDef );
		pAst->openBranch();
			pAst->addNode( AstNode::typeString, "all" );
		pAst->openBranch();
			pAst->addNode( AstNode::typeProcessTarget );
				pAst->openBranch();
					pAst->addNode( AstNode::typeString, "build" );
				pAst->openBranch();
					pAst->addNode( AstNode::typeFunction );
						pAst->openBranch();
							pAst->addNode( AstNode::typeString, "targets" );
					pAst->closeNode();
			pAst->closeNode();
	pAst->closeNode();
	Action *pRet = new Action(
		dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() )
		);
	pRet->pAst = pAst;

	return pRet;
}

Action *Action::genDefaultClean()
{
	Ast *pAst = new Ast();
	pAst->addNode( AstNode::typeActionDef );
		pAst->openBranch();
			pAst->addNode( AstNode::typeString, "clean" );
		pAst->openBranch();
			pAst->addNode( AstNode::typeProcessTarget );
				pAst->openBranch();
					pAst->addNode( AstNode::typeString, "clean" );
				pAst->openBranch();
					pAst->addNode( AstNode::typeFunction );
						pAst->openBranch();
							pAst->addNode( AstNode::typeString, "targets" );
					pAst->closeNode();
			pAst->closeNode();
	pAst->closeNode();
	Action *pRet = new Action(
		dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() )
		);
	pRet->pAst = pAst;

	return pRet;
}

Action *Action::genDefaultDefault()
{
	Ast *pAst = new Ast();
	pAst->addNode( AstNode::typeActionDef );
		pAst->openBranch();
			pAst->addNode( AstNode::typeString, "default" );
		pAst->openBranch();
			pAst->addNode( AstNode::typeProcessTarget );
				pAst->openBranch();
					pAst->addNode( AstNode::typeString, "build" );
				pAst->openBranch();
					pAst->addNode( AstNode::typeFunction );
						pAst->openBranch();
							pAst->addNode( AstNode::typeString, "targets" );
					pAst->closeNode();
			pAst->closeNode();
	pAst->closeNode();
	Action *pRet = new Action(
		dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() )
		);
	pRet->pAst = pAst;

	return pRet;
}