aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-08 22:58:28 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-08 22:58:28 +0000
commit52be1ef0d126f09ba943c7afcf367e7d9347f2fd (patch)
treefd4b0dd148751c3c6c1b95296c3b82cb86051b83 /src
parent795d0737fed40d88a7801b451b7750ba90802345 (diff)
downloadbuild-52be1ef0d126f09ba943c7afcf367e7d9347f2fd.tar.gz
build-52be1ef0d126f09ba943c7afcf367e7d9347f2fd.tar.bz2
build-52be1ef0d126f09ba943c7afcf367e7d9347f2fd.tar.xz
build-52be1ef0d126f09ba943c7afcf367e7d9347f2fd.zip
tabconv: it's all spaces now.
Diffstat (limited to 'src')
-rw-r--r--src/action.cpp178
-rw-r--r--src/action.h22
-rw-r--r--src/ast.cpp106
-rw-r--r--src/ast.h46
-rw-r--r--src/astbranch.cpp36
-rw-r--r--src/astbranch.h16
-rw-r--r--src/astleaf.cpp132
-rw-r--r--src/astleaf.h44
-rw-r--r--src/astnode.cpp184
-rw-r--r--src/astnode.h174
-rw-r--r--src/buildparser.cpp150
-rw-r--r--src/buildparser.h28
-rw-r--r--src/cache.cpp50
-rw-r--r--src/cache.h28
-rw-r--r--src/condition.h8
-rw-r--r--src/conditionalways.cpp6
-rw-r--r--src/conditionalways.h8
-rw-r--r--src/conditionfileexists.cpp24
-rw-r--r--src/conditionfileexists.h8
-rw-r--r--src/conditionfiletime.cpp100
-rw-r--r--src/conditionfiletime.h8
-rw-r--r--src/conditionnever.cpp6
-rw-r--r--src/conditionnever.h8
-rw-r--r--src/conditionplugger.cpp50
-rw-r--r--src/conditionplugger.h6
-rw-r--r--src/context.cpp808
-rw-r--r--src/context.h150
-rw-r--r--src/filemgr.cpp48
-rw-r--r--src/filemgr.h16
-rw-r--r--src/function.cpp4
-rw-r--r--src/function.h12
-rw-r--r--src/functionast.cpp44
-rw-r--r--src/functionast.h14
-rw-r--r--src/functionclose.cpp8
-rw-r--r--src/functionclose.h8
-rw-r--r--src/functiondirname.cpp40
-rw-r--r--src/functiondirname.h8
-rw-r--r--src/functiondirs.cpp64
-rw-r--r--src/functiondirs.h8
-rw-r--r--src/functionexecute.cpp90
-rw-r--r--src/functionexecute.h8
-rw-r--r--src/functionexists.cpp30
-rw-r--r--src/functionexists.h8
-rw-r--r--src/functionfilename.cpp36
-rw-r--r--src/functionfilename.h8
-rw-r--r--src/functionfiles.cpp64
-rw-r--r--src/functionfiles.h8
-rw-r--r--src/functiongetmakedeps.cpp78
-rw-r--r--src/functiongetmakedeps.h8
-rw-r--r--src/functionmatches.cpp216
-rw-r--r--src/functionmatches.h20
-rw-r--r--src/functionopen.cpp40
-rw-r--r--src/functionopen.h8
-rw-r--r--src/functionplugger.cpp74
-rw-r--r--src/functionplugger.h6
-rw-r--r--src/functionrange.cpp94
-rw-r--r--src/functionrange.h8
-rw-r--r--src/functionread.cpp36
-rw-r--r--src/functionread.h8
-rw-r--r--src/functionregex.cpp184
-rw-r--r--src/functionregex.h14
-rw-r--r--src/functionreplace.cpp60
-rw-r--r--src/functionreplace.h8
-rw-r--r--src/functiontargets.cpp40
-rw-r--r--src/functiontargets.h8
-rw-r--r--src/functiontostring.cpp58
-rw-r--r--src/functiontostring.h8
-rw-r--r--src/functionunique.cpp40
-rw-r--r--src/functionunique.h8
-rw-r--r--src/functionunlink.cpp58
-rw-r--r--src/functionunlink.h8
-rw-r--r--src/functionwrite.cpp24
-rw-r--r--src/functionwrite.h8
-rw-r--r--src/location.cpp32
-rw-r--r--src/location.h20
-rw-r--r--src/main.cpp562
-rw-r--r--src/plugins/pluginConditionRandom.cpp34
-rw-r--r--src/profile.cpp102
-rw-r--r--src/profile.h26
-rw-r--r--src/rule.cpp168
-rw-r--r--src/rule.h52
-rw-r--r--src/runner.cpp1690
-rw-r--r--src/runner.h52
-rw-r--r--src/target.cpp466
-rw-r--r--src/target.h116
-rw-r--r--src/variable.cpp1542
-rw-r--r--src/variable.h190
-rw-r--r--src/view.h50
-rw-r--r--src/viewdefault.cpp242
-rw-r--r--src/viewdefault.h58
-rw-r--r--src/viewmake.cpp24
-rw-r--r--src/viewmake.h50
-rw-r--r--src/viewplugger.cpp40
-rw-r--r--src/viewplugger.h6
94 files changed, 4777 insertions, 4777 deletions
diff --git a/src/action.cpp b/src/action.cpp
index 1a2b8b1..e06fb45 100644
--- a/src/action.cpp
+++ b/src/action.cpp
@@ -6,127 +6,127 @@
6#include "variable.h" 6#include "variable.h"
7 7
8Action::Action( const class AstBranch *pRoot ) : 8Action::Action( const class AstBranch *pRoot ) :
9 pRoot( pRoot ), 9 pRoot( pRoot ),
10 pAst( NULL ) 10 pAst( NULL )
11{ 11{
12 sName = dynamic_cast<AstLeaf *>( 12 sName = dynamic_cast<AstLeaf *>(
13 *(*pRoot->getBranchBegin()).begin() 13 *(*pRoot->getBranchBegin()).begin()
14 )->getStrValue(); 14 )->getStrValue();
15} 15}
16 16
17Action::~Action() 17Action::~Action()
18{ 18{
19 delete pAst; 19 delete pAst;
20 pAst = NULL; 20 pAst = NULL;
21} 21}
22 22
23const Bu::String &Action::getName() const 23const Bu::String &Action::getName() const
24{ 24{
25 return sName; 25 return sName;
26} 26}
27 27
28void Action::call( class Runner *pRunner ) 28void Action::call( class Runner *pRunner )
29{ 29{
30 pRunner->run( (*(pRoot->getBranchBegin()+1)).begin() ); 30 pRunner->run( (*(pRoot->getBranchBegin()+1)).begin() );
31} 31}
32 32
33Action *Action::genDefaultAll() 33Action *Action::genDefaultAll()
34{ 34{
35 Ast *pAst = new Ast(); 35 Ast *pAst = new Ast();
36 pAst->addNode( AstNode::typeActionDef ); 36 pAst->addNode( AstNode::typeActionDef );
37 pAst->openBranch(); 37 pAst->openBranch();
38 pAst->addNode( AstNode::typeString, "all" ); 38 pAst->addNode( AstNode::typeString, "all" );
39 pAst->openBranch(); 39 pAst->openBranch();
40 pAst->addNode( AstNode::typeProcessTarget ); 40 pAst->addNode( AstNode::typeProcessTarget );
41 pAst->openBranch(); 41 pAst->openBranch();
42 pAst->addNode( AstNode::typeString, "build" ); 42 pAst->addNode( AstNode::typeString, "build" );
43 pAst->openBranch(); 43 pAst->openBranch();
44 pAst->addNode( AstNode::typeFunction ); 44 pAst->addNode( AstNode::typeFunction );
45 pAst->openBranch(); 45 pAst->openBranch();
46 pAst->addNode( AstNode::typeString, "targets" ); 46 pAst->addNode( AstNode::typeString, "targets" );
47 pAst->closeNode(); 47 pAst->closeNode();
48 pAst->closeNode(); 48 pAst->closeNode();
49 pAst->closeNode(); 49 pAst->closeNode();
50 Action *pRet = new Action( 50 Action *pRet = new Action(
51 dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() ) 51 dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() )
52 ); 52 );
53 pRet->pAst = pAst; 53 pRet->pAst = pAst;
54 54
55 return pRet; 55 return pRet;
56} 56}
57 57
58Action *Action::genDefaultClean() 58Action *Action::genDefaultClean()
59{ 59{
60 Ast *pAst = new Ast(); 60 Ast *pAst = new Ast();
61 pAst->addNode( AstNode::typeActionDef ); 61 pAst->addNode( AstNode::typeActionDef );
62 pAst->openBranch(); 62 pAst->openBranch();
63 pAst->addNode( AstNode::typeString, "clean" ); 63 pAst->addNode( AstNode::typeString, "clean" );
64 pAst->openBranch(); 64 pAst->openBranch();
65 pAst->addNode( AstNode::typeProcessTarget ); 65 pAst->addNode( AstNode::typeProcessTarget );
66 pAst->openBranch(); 66 pAst->openBranch();
67 pAst->addNode( AstNode::typeString, "clean" ); 67 pAst->addNode( AstNode::typeString, "clean" );
68 pAst->openBranch(); 68 pAst->openBranch();
69 pAst->addNode( AstNode::typeFunction ); 69 pAst->addNode( AstNode::typeFunction );
70 pAst->openBranch(); 70 pAst->openBranch();
71 pAst->addNode( AstNode::typeString, "targets" ); 71 pAst->addNode( AstNode::typeString, "targets" );
72 pAst->closeNode(); 72 pAst->closeNode();
73 pAst->closeNode(); 73 pAst->closeNode();
74 pAst->closeNode(); 74 pAst->closeNode();
75 Action *pRet = new Action( 75 Action *pRet = new Action(
76 dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() ) 76 dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() )
77 ); 77 );
78 pRet->pAst = pAst; 78 pRet->pAst = pAst;
79 79
80 return pRet; 80 return pRet;
81} 81}
82 82
83Action *Action::genDefaultCleanAll() 83Action *Action::genDefaultCleanAll()
84{ 84{
85 Ast *pAst = new Ast(); 85 Ast *pAst = new Ast();
86 pAst->addNode( AstNode::typeActionDef ); 86 pAst->addNode( AstNode::typeActionDef );
87 pAst->openBranch(); 87 pAst->openBranch();
88 pAst->addNode( AstNode::typeString, "clean-all" ); 88 pAst->addNode( AstNode::typeString, "clean-all" );
89 pAst->openBranch(); 89 pAst->openBranch();
90 pAst->addNode( AstNode::typeProcessTarget ); 90 pAst->addNode( AstNode::typeProcessTarget );
91 pAst->openBranch(); 91 pAst->openBranch();
92 pAst->addNode( AstNode::typeString, "clean" ); 92 pAst->addNode( AstNode::typeString, "clean" );
93 pAst->openBranch(); 93 pAst->openBranch();
94 pAst->addNode( AstNode::typeFunction ); 94 pAst->addNode( AstNode::typeFunction );
95 pAst->openBranch(); 95 pAst->openBranch();
96 pAst->addNode( AstNode::typeString, "targets" ); 96 pAst->addNode( AstNode::typeString, "targets" );
97 pAst->closeNode(); 97 pAst->closeNode();
98 pAst->closeNode(); 98 pAst->closeNode();
99 pAst->closeNode(); 99 pAst->closeNode();
100 Action *pRet = new Action( 100 Action *pRet = new Action(
101 dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() ) 101 dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() )
102 ); 102 );
103 pRet->pAst = pAst; 103 pRet->pAst = pAst;
104 104
105 return pRet; 105 return pRet;
106} 106}
107 107
108Action *Action::genDefaultDefault() 108Action *Action::genDefaultDefault()
109{ 109{
110 Ast *pAst = new Ast(); 110 Ast *pAst = new Ast();
111 pAst->addNode( AstNode::typeActionDef ); 111 pAst->addNode( AstNode::typeActionDef );
112 pAst->openBranch(); 112 pAst->openBranch();
113 pAst->addNode( AstNode::typeString, "default" ); 113 pAst->addNode( AstNode::typeString, "default" );
114 pAst->openBranch(); 114 pAst->openBranch();
115 pAst->addNode( AstNode::typeProcessTarget ); 115 pAst->addNode( AstNode::typeProcessTarget );
116 pAst->openBranch(); 116 pAst->openBranch();
117 pAst->addNode( AstNode::typeString, "build" ); 117 pAst->addNode( AstNode::typeString, "build" );
118 pAst->openBranch(); 118 pAst->openBranch();
119 pAst->addNode( AstNode::typeFunction ); 119 pAst->addNode( AstNode::typeFunction );
120 pAst->openBranch(); 120 pAst->openBranch();
121 pAst->addNode( AstNode::typeString, "targets" ); 121 pAst->addNode( AstNode::typeString, "targets" );
122 pAst->closeNode(); 122 pAst->closeNode();
123 pAst->closeNode(); 123 pAst->closeNode();
124 pAst->closeNode(); 124 pAst->closeNode();
125 Action *pRet = new Action( 125 Action *pRet = new Action(
126 dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() ) 126 dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() )
127 ); 127 );
128 pRet->pAst = pAst; 128 pRet->pAst = pAst;
129 129
130 return pRet; 130 return pRet;
131} 131}
132 132
diff --git a/src/action.h b/src/action.h
index de08911..0808fdb 100644
--- a/src/action.h
+++ b/src/action.h
@@ -6,22 +6,22 @@
6class Action 6class Action
7{ 7{
8public: 8public:
9 Action( const class AstBranch *pRoot ); 9 Action( const class AstBranch *pRoot );
10 virtual ~Action(); 10 virtual ~Action();
11 11
12 const Bu::String &getName() const; 12 const Bu::String &getName() const;
13 13
14 void call( class Runner *pRunner ); 14 void call( class Runner *pRunner );
15 15
16 static Action *genDefaultAll(); 16 static Action *genDefaultAll();
17 static Action *genDefaultClean(); 17 static Action *genDefaultClean();
18 static Action *genDefaultCleanAll(); 18 static Action *genDefaultCleanAll();
19 static Action *genDefaultDefault(); 19 static Action *genDefaultDefault();
20 20
21private: 21private:
22 Bu::String sName; 22 Bu::String sName;
23 const class AstBranch *pRoot; 23 const class AstBranch *pRoot;
24 class Ast *pAst; 24 class Ast *pAst;
25}; 25};
26 26
27#endif 27#endif
diff --git a/src/ast.cpp b/src/ast.cpp
index 005372b..6c03607 100644
--- a/src/ast.cpp
+++ b/src/ast.cpp
@@ -15,122 +15,122 @@ Ast::~Ast()
15 15
16void Ast::addNode( YYLTYPE &loc, AstNode::Type eType ) 16void Ast::addNode( YYLTYPE &loc, AstNode::Type eType )
17{ 17{
18 switch( eType&AstNode::typeClassMask ) 18 switch( eType&AstNode::typeClassMask )
19 { 19 {
20 case AstNode::typeBranch: 20 case AstNode::typeBranch:
21 { 21 {
22 AstBranch *pNode = new AstBranch( loc, eType ); 22 AstBranch *pNode = new AstBranch( loc, eType );
23 addNode( pNode ); 23 addNode( pNode );
24 sBranch.push( pNode ); 24 sBranch.push( pNode );
25 } 25 }
26 break; 26 break;
27 27
28 case AstNode::typeLeaf: 28 case AstNode::typeLeaf:
29 { 29 {
30 AstLeaf *pNode = new AstLeaf( loc, eType ); 30 AstLeaf *pNode = new AstLeaf( loc, eType );
31 addNode( pNode ); 31 addNode( pNode );
32 } 32 }
33 break; 33 break;
34 34
35 default: 35 default:
36 throw Bu::ExceptionBase("You got it wrong."); 36 throw Bu::ExceptionBase("You got it wrong.");
37 break; 37 break;
38 } 38 }
39} 39}
40 40
41void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, int iVal ) 41void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, int iVal )
42{ 42{
43 addNode( new AstLeaf( loc, eType, iVal ) ); 43 addNode( new AstLeaf( loc, eType, iVal ) );
44} 44}
45 45
46void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, float fVal ) 46void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, float fVal )
47{ 47{
48 addNode( new AstLeaf( loc, eType, fVal ) ); 48 addNode( new AstLeaf( loc, eType, fVal ) );
49} 49}
50 50
51void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, bool bVal ) 51void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, bool bVal )
52{ 52{
53 addNode( new AstLeaf( loc, eType, bVal ) ); 53 addNode( new AstLeaf( loc, eType, bVal ) );
54} 54}
55 55
56void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, const Bu::String &sVal ) 56void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, const Bu::String &sVal )
57{ 57{
58 addNode( new AstLeaf( loc, eType, sVal ) ); 58 addNode( new AstLeaf( loc, eType, sVal ) );
59} 59}
60 60
61void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, const char *sVal ) 61void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, const char *sVal )
62{ 62{
63 addNode( new AstLeaf( loc, eType, sVal ) ); 63 addNode( new AstLeaf( loc, eType, sVal ) );
64} 64}
65 65
66void Ast::addNode( AstNode::Type eType ) 66void Ast::addNode( AstNode::Type eType )
67{ 67{
68 YYLTYPE none = {-1, -1, -1, -1}; 68 YYLTYPE none = {-1, -1, -1, -1};
69 addNode( none, eType ); 69 addNode( none, eType );
70} 70}
71 71
72void Ast::addNode( AstNode::Type eType, int iVal ) 72void Ast::addNode( AstNode::Type eType, int iVal )
73{ 73{
74 YYLTYPE none = {-1, -1, -1, -1}; 74 YYLTYPE none = {-1, -1, -1, -1};
75 addNode( none, eType, iVal ); 75 addNode( none, eType, iVal );
76} 76}
77 77
78void Ast::addNode( AstNode::Type eType, float fVal ) 78void Ast::addNode( AstNode::Type eType, float fVal )
79{ 79{
80 YYLTYPE none = {-1, -1, -1, -1}; 80 YYLTYPE none = {-1, -1, -1, -1};
81 addNode( none, eType, fVal ); 81 addNode( none, eType, fVal );
82} 82}
83 83
84void Ast::addNode( AstNode::Type eType, bool bVal ) 84void Ast::addNode( AstNode::Type eType, bool bVal )
85{ 85{
86 YYLTYPE none = {-1, -1, -1, -1}; 86 YYLTYPE none = {-1, -1, -1, -1};
87 addNode( none, eType, bVal ); 87 addNode( none, eType, bVal );
88} 88}
89 89
90void Ast::addNode( AstNode::Type eType, const Bu::String &sVal ) 90void Ast::addNode( AstNode::Type eType, const Bu::String &sVal )
91{ 91{
92 YYLTYPE none = {-1, -1, -1, -1}; 92 YYLTYPE none = {-1, -1, -1, -1};
93 addNode( none, eType, sVal ); 93 addNode( none, eType, sVal );
94} 94}
95 95
96void Ast::addNode( AstNode::Type eType, const char *sVal ) 96void Ast::addNode( AstNode::Type eType, const char *sVal )
97{ 97{
98 YYLTYPE none = {-1, -1, -1, -1}; 98 YYLTYPE none = {-1, -1, -1, -1};
99 addNode( none, eType, sVal ); 99 addNode( none, eType, sVal );
100} 100}
101 101
102void Ast::addNode( AstNode *pNode ) 102void Ast::addNode( AstNode *pNode )
103{ 103{
104 if( sBranch.isEmpty() ) 104 if( sBranch.isEmpty() )
105 lNode.append( pNode ); 105 lNode.append( pNode );
106 else 106 else
107 sBranch.peek()->addNode( pNode ); 107 sBranch.peek()->addNode( pNode );
108} 108}
109 109
110void Ast::openBranch() 110void Ast::openBranch()
111{ 111{
112 sBranch.peek()->addBranch(); 112 sBranch.peek()->addBranch();
113} 113}
114 114
115void Ast::closeNode() 115void Ast::closeNode()
116{ 116{
117 sBranch.pop(); 117 sBranch.pop();
118} 118}
119 119
120Ast::NodeList::const_iterator Ast::getNodeBegin() const 120Ast::NodeList::const_iterator Ast::getNodeBegin() const
121{ 121{
122 return lNode.begin(); 122 return lNode.begin();
123} 123}
124 124
125Bu::Formatter &operator<<( Bu::Formatter &f, const Ast &a ) 125Bu::Formatter &operator<<( Bu::Formatter &f, const Ast &a )
126{ 126{
127 f << "Abstract Syntax Tree:"; 127 f << "Abstract Syntax Tree:";
128 f.incIndent(); 128 f.incIndent();
129 f << f.nl; 129 f << f.nl;
130 for( Ast::NodeList::const_iterator i = a.getNodeBegin(); i; i++ ) 130 for( Ast::NodeList::const_iterator i = a.getNodeBegin(); i; i++ )
131 f << **i << f.nl; 131 f << **i << f.nl;
132 f << f.nl; 132 f << f.nl;
133 f.decIndent(); 133 f.decIndent();
134 return f; 134 return f;
135} 135}
136 136
diff --git a/src/ast.h b/src/ast.h
index 3cc7206..b859064 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -15,36 +15,36 @@
15class Ast 15class Ast
16{ 16{
17public: 17public:
18 typedef Bu::List<AstNode *> NodeList; 18 typedef Bu::List<AstNode *> NodeList;
19 Ast(); 19 Ast();
20 virtual ~Ast(); 20 virtual ~Ast();
21 21
22 void addNode( struct YYLTYPE &loc, AstNode::Type eType ); 22 void addNode( struct YYLTYPE &loc, AstNode::Type eType );
23 void addNode( struct YYLTYPE &loc, AstNode::Type eType, int iVal ); 23 void addNode( struct YYLTYPE &loc, AstNode::Type eType, int iVal );
24 void addNode( struct YYLTYPE &loc, AstNode::Type eType, float fVal ); 24 void addNode( struct YYLTYPE &loc, AstNode::Type eType, float fVal );
25 void addNode( struct YYLTYPE &loc, AstNode::Type eType, bool bVal ); 25 void addNode( struct YYLTYPE &loc, AstNode::Type eType, bool bVal );
26 void addNode( struct YYLTYPE &loc, AstNode::Type eType, 26 void addNode( struct YYLTYPE &loc, AstNode::Type eType,
27 const Bu::String &sVal ); 27 const Bu::String &sVal );
28 void addNode( struct YYLTYPE &loc, AstNode::Type eType, const char *sVal ); 28 void addNode( struct YYLTYPE &loc, AstNode::Type eType, const char *sVal );
29 29
30 void addNode( AstNode::Type eType ); 30 void addNode( AstNode::Type eType );
31 void addNode( AstNode::Type eType, int iVal ); 31 void addNode( AstNode::Type eType, int iVal );
32 void addNode( AstNode::Type eType, float fVal ); 32 void addNode( AstNode::Type eType, float fVal );
33 void addNode( AstNode::Type eType, bool bVal ); 33 void addNode( AstNode::Type eType, bool bVal );
34 void addNode( AstNode::Type eType, const Bu::String &sVal ); 34 void addNode( AstNode::Type eType, const Bu::String &sVal );
35 void addNode( AstNode::Type eType, const char *sVal ); 35 void addNode( AstNode::Type eType, const char *sVal );
36 void addNode( AstNode *pNode ); 36 void addNode( AstNode *pNode );
37 37
38 void openBranch(); 38 void openBranch();
39 39
40 void closeNode(); 40 void closeNode();
41 41
42 NodeList::const_iterator getNodeBegin() const; 42 NodeList::const_iterator getNodeBegin() const;
43 43
44private: 44private:
45 NodeList lNode; 45 NodeList lNode;
46 typedef Bu::Stack<class AstBranch *> BranchStack; 46 typedef Bu::Stack<class AstBranch *> BranchStack;
47 BranchStack sBranch; 47 BranchStack sBranch;
48}; 48};
49 49
50Bu::Formatter &operator<<( Bu::Formatter &f, const Ast &a ); 50Bu::Formatter &operator<<( Bu::Formatter &f, const Ast &a );
diff --git a/src/astbranch.cpp b/src/astbranch.cpp
index d247b30..83ecdd7 100644
--- a/src/astbranch.cpp
+++ b/src/astbranch.cpp
@@ -1,7 +1,7 @@
1#include "astbranch.h" 1#include "astbranch.h"
2 2
3AstBranch::AstBranch( const Location &loc, Type eType ) : 3AstBranch::AstBranch( const Location &loc, Type eType ) :
4 AstNode( loc, eType ) 4 AstNode( loc, eType )
5{ 5{
6} 6}
7 7
@@ -11,34 +11,34 @@ AstBranch::~AstBranch()
11 11
12void AstBranch::addBranch() 12void AstBranch::addBranch()
13{ 13{
14 lBranch.append( NodeList() ); 14 lBranch.append( NodeList() );
15} 15}
16 16
17void AstBranch::addNode( AstNode *pNode ) 17void AstBranch::addNode( AstNode *pNode )
18{ 18{
19 lBranch.last().append( pNode ); 19 lBranch.last().append( pNode );
20} 20}
21 21
22AstBranch::BranchList::const_iterator AstBranch::getBranchBegin() const 22AstBranch::BranchList::const_iterator AstBranch::getBranchBegin() const
23{ 23{
24 return lBranch.begin(); 24 return lBranch.begin();
25} 25}
26 26
27Bu::Formatter &operator<<( Bu::Formatter &f, const AstBranch &l ) 27Bu::Formatter &operator<<( Bu::Formatter &f, const AstBranch &l )
28{ 28{
29 f.incIndent(); 29 f.incIndent();
30 f << ":"; 30 f << ":";
31 for( AstBranch::BranchList::const_iterator i = l.getBranchBegin(); i; i++ ) 31 for( AstBranch::BranchList::const_iterator i = l.getBranchBegin(); i; i++ )
32 { 32 {
33 f << f.nl << "Branch:"; 33 f << f.nl << "Branch:";
34 f.incIndent(); 34 f.incIndent();
35 for( AstBranch::NodeList::const_iterator j = i->begin(); j; j++ ) 35 for( AstBranch::NodeList::const_iterator j = i->begin(); j; j++ )
36 { 36 {
37 f << f.nl << **j; 37 f << f.nl << **j;
38 } 38 }
39 f.decIndent(); 39 f.decIndent();
40 } 40 }
41 f.decIndent(); 41 f.decIndent();
42 return f; 42 return f;
43} 43}
44 44
diff --git a/src/astbranch.h b/src/astbranch.h
index b582b9f..8140d3c 100644
--- a/src/astbranch.h
+++ b/src/astbranch.h
@@ -8,18 +8,18 @@
8class AstBranch : public AstNode 8class AstBranch : public AstNode
9{ 9{
10public: 10public:
11 typedef Bu::List<AstNode *> NodeList; 11 typedef Bu::List<AstNode *> NodeList;
12 typedef Bu::List<NodeList> BranchList; 12 typedef Bu::List<NodeList> BranchList;
13 AstBranch( const Location &loc, Type eType ); 13 AstBranch( const Location &loc, Type eType );
14 virtual ~AstBranch(); 14 virtual ~AstBranch();
15 15
16 void addBranch(); 16 void addBranch();
17 void addNode( AstNode *pNode ); 17 void addNode( AstNode *pNode );
18 18
19 BranchList::const_iterator getBranchBegin() const; 19 BranchList::const_iterator getBranchBegin() const;
20 20
21private: 21private:
22 BranchList lBranch; 22 BranchList lBranch;
23}; 23};
24 24
25Bu::Formatter &operator<<( Bu::Formatter &f, const AstBranch &l ); 25Bu::Formatter &operator<<( Bu::Formatter &f, const AstBranch &l );
diff --git a/src/astleaf.cpp b/src/astleaf.cpp
index c192dbf..f9ede90 100644
--- a/src/astleaf.cpp
+++ b/src/astleaf.cpp
@@ -1,137 +1,137 @@
1#include "astleaf.h" 1#include "astleaf.h"
2 2
3AstLeaf::AstLeaf( const Location &loc, Type eType ) : 3AstLeaf::AstLeaf( const Location &loc, Type eType ) :
4 AstNode( loc, eType ), 4 AstNode( loc, eType ),
5 sVal( NULL ) 5 sVal( NULL )
6{ 6{
7} 7}
8 8
9AstLeaf::AstLeaf( const Location &loc, Type eType, int iNew ) : 9AstLeaf::AstLeaf( const Location &loc, Type eType, int iNew ) :
10 AstNode( loc, eType ), 10 AstNode( loc, eType ),
11 sVal( NULL ) 11 sVal( NULL )
12{ 12{
13 setIntValue( iNew ); 13 setIntValue( iNew );
14} 14}
15 15
16AstLeaf::AstLeaf( const Location &loc, Type eType, float fNew ) : 16AstLeaf::AstLeaf( const Location &loc, Type eType, float fNew ) :
17 AstNode( loc, eType ), 17 AstNode( loc, eType ),
18 sVal( NULL ) 18 sVal( NULL )
19{ 19{
20 setFloatValue( fNew ); 20 setFloatValue( fNew );
21} 21}
22 22
23AstLeaf::AstLeaf( const Location &loc, Type eType, bool bNew ) : 23AstLeaf::AstLeaf( const Location &loc, Type eType, bool bNew ) :
24 AstNode( loc, eType ), 24 AstNode( loc, eType ),
25 sVal( NULL ) 25 sVal( NULL )
26{ 26{
27 setBoolValue( bNew ); 27 setBoolValue( bNew );
28} 28}
29 29
30AstLeaf::AstLeaf( const Location &loc, Type eType, const Bu::String &sNew ) : 30AstLeaf::AstLeaf( const Location &loc, Type eType, const Bu::String &sNew ) :
31 AstNode( loc, eType ), 31 AstNode( loc, eType ),
32 sVal( NULL ) 32 sVal( NULL )
33{ 33{
34 setStrValue( sNew ); 34 setStrValue( sNew );
35} 35}
36 36
37AstLeaf::AstLeaf( const Location &loc, Type eType, const char *sNew ) : 37AstLeaf::AstLeaf( const Location &loc, Type eType, const char *sNew ) :
38 AstNode( loc, eType ), 38 AstNode( loc, eType ),
39 sVal( NULL ) 39 sVal( NULL )
40{ 40{
41 setStrValue( sNew ); 41 setStrValue( sNew );
42} 42}
43 43
44AstLeaf::~AstLeaf() 44AstLeaf::~AstLeaf()
45{ 45{
46 if( getDataType() == typeDataString ) 46 if( getDataType() == typeDataString )
47 delete sVal; 47 delete sVal;
48} 48}
49 49
50void AstLeaf::setIntValue( int iNew ) 50void AstLeaf::setIntValue( int iNew )
51{ 51{
52 if( getDataType() != typeDataInt ) 52 if( getDataType() != typeDataInt )
53 throw Bu::ExceptionBase("Type is not int."); 53 throw Bu::ExceptionBase("Type is not int.");
54 iVal = iNew; 54 iVal = iNew;
55} 55}
56 56
57void AstLeaf::setFloatValue( float fNew ) 57void AstLeaf::setFloatValue( float fNew )
58{ 58{
59 if( getDataType() != typeDataFloat ) 59 if( getDataType() != typeDataFloat )
60 throw Bu::ExceptionBase("Type is not float."); 60 throw Bu::ExceptionBase("Type is not float.");
61 fVal = fNew; 61 fVal = fNew;
62} 62}
63 63
64void AstLeaf::setBoolValue( bool bNew ) 64void AstLeaf::setBoolValue( bool bNew )
65{ 65{
66 if( getDataType() != typeDataBool ) 66 if( getDataType() != typeDataBool )
67 throw Bu::ExceptionBase("Type is not bool."); 67 throw Bu::ExceptionBase("Type is not bool.");
68 bVal = bNew; 68 bVal = bNew;
69} 69}
70 70
71void AstLeaf::setStrValue( const Bu::String &sNew ) 71void AstLeaf::setStrValue( const Bu::String &sNew )
72{ 72{
73 if( getDataType() != typeDataString ) 73 if( getDataType() != typeDataString )
74 throw Bu::ExceptionBase("Type is not string."); 74 throw Bu::ExceptionBase("Type is not string.");
75 if( sVal == NULL ) 75 if( sVal == NULL )
76 sVal = new Bu::String( sNew ); 76 sVal = new Bu::String( sNew );
77 else 77 else
78 *sVal = sNew; 78 *sVal = sNew;
79} 79}
80 80
81int AstLeaf::getIntValue() const 81int AstLeaf::getIntValue() const
82{ 82{
83 if( getDataType() != typeDataInt ) 83 if( getDataType() != typeDataInt )
84 throw Bu::ExceptionBase("Type is not int."); 84 throw Bu::ExceptionBase("Type is not int.");
85 return iVal; 85 return iVal;
86} 86}
87 87
88float AstLeaf::getFloatValue() const 88float AstLeaf::getFloatValue() const
89{ 89{
90 if( getDataType() != typeDataFloat ) 90 if( getDataType() != typeDataFloat )
91 throw Bu::ExceptionBase("Type is not float."); 91 throw Bu::ExceptionBase("Type is not float.");
92 return fVal; 92 return fVal;
93} 93}
94 94
95bool AstLeaf::getBoolValue() const 95bool AstLeaf::getBoolValue() const
96{ 96{
97 if( getDataType() != typeDataBool ) 97 if( getDataType() != typeDataBool )
98 throw Bu::ExceptionBase("Type is not bool."); 98 throw Bu::ExceptionBase("Type is not bool.");
99 return bVal; 99 return bVal;
100} 100}
101 101
102Bu::String &AstLeaf::getStrValue() const 102Bu::String &AstLeaf::getStrValue() const
103{ 103{
104 if( getDataType() != typeDataString ) 104 if( getDataType() != typeDataString )
105 throw Bu::ExceptionBase("Type is not string."); 105 throw Bu::ExceptionBase("Type is not string.");
106 return *sVal; 106 return *sVal;
107} 107}
108 108
109Bu::Formatter &operator<<( Bu::Formatter &f, const AstLeaf &l ) 109Bu::Formatter &operator<<( Bu::Formatter &f, const AstLeaf &l )
110{ 110{
111 switch( l.getDataType() ) 111 switch( l.getDataType() )
112 { 112 {
113 case AstNode::typeDataInt: 113 case AstNode::typeDataInt:
114 f << ": " << l.getIntValue(); 114 f << ": " << l.getIntValue();
115 break; 115 break;
116 116
117 case AstNode::typeDataFloat: 117 case AstNode::typeDataFloat:
118 f << ": " << l.getFloatValue(); 118 f << ": " << l.getFloatValue();
119 break; 119 break;
120 120
121 case AstNode::typeDataBool: 121 case AstNode::typeDataBool:
122 f << ": " << l.getBoolValue(); 122 f << ": " << l.getBoolValue();
123 break; 123 break;
124 124
125 case AstNode::typeDataString: 125 case AstNode::typeDataString:
126 f << ": '" << l.getStrValue() << "'"; 126 f << ": '" << l.getStrValue() << "'";
127 break; 127 break;
128 128
129 case AstNode::typeDataNone: 129 case AstNode::typeDataNone:
130 break; 130 break;
131 131
132 default: 132 default:
133 f << ": " << "!! Invalid Type !!"; 133 f << ": " << "!! Invalid Type !!";
134 } 134 }
135 return f; 135 return f;
136} 136}
137 137
diff --git a/src/astleaf.h b/src/astleaf.h
index 85293f1..f78e593 100644
--- a/src/astleaf.h
+++ b/src/astleaf.h
@@ -8,32 +8,32 @@
8class AstLeaf : public AstNode 8class AstLeaf : public AstNode
9{ 9{
10public: 10public:
11 AstLeaf( const Location &loc, Type eType ); 11 AstLeaf( const Location &loc, Type eType );
12 AstLeaf( const Location &loc, Type eType, int iNew ); 12 AstLeaf( const Location &loc, Type eType, int iNew );
13 AstLeaf( const Location &loc, Type eType, float fNew ); 13 AstLeaf( const Location &loc, Type eType, float fNew );
14 AstLeaf( const Location &loc, Type eType, bool bNew ); 14 AstLeaf( const Location &loc, Type eType, bool bNew );
15 AstLeaf( const Location &loc, Type eType, const Bu::String &sNew ); 15 AstLeaf( const Location &loc, Type eType, const Bu::String &sNew );
16 AstLeaf( const Location &loc, Type eType, const char *sNew ); 16 AstLeaf( const Location &loc, Type eType, const char *sNew );
17 virtual ~AstLeaf(); 17 virtual ~AstLeaf();
18 18
19 void setIntValue( int iNew ); 19 void setIntValue( int iNew );
20 void setFloatValue( float fNew ); 20 void setFloatValue( float fNew );
21 void setBoolValue( bool bNew ); 21 void setBoolValue( bool bNew );
22 void setStrValue( const Bu::String &sNew ); 22 void setStrValue( const Bu::String &sNew );
23 23
24 int getIntValue() const; 24 int getIntValue() const;
25 float getFloatValue() const; 25 float getFloatValue() const;
26 bool getBoolValue() const; 26 bool getBoolValue() const;
27 Bu::String &getStrValue() const; 27 Bu::String &getStrValue() const;
28 28
29private: 29private:
30 union 30 union
31 { 31 {
32 int iVal; 32 int iVal;
33 float fVal; 33 float fVal;
34 bool bVal; 34 bool bVal;
35 Bu::String *sVal; 35 Bu::String *sVal;
36 }; 36 };
37}; 37};
38 38
39Bu::Formatter &operator<<( Bu::Formatter &f, const AstLeaf &l ); 39Bu::Formatter &operator<<( Bu::Formatter &f, const AstLeaf &l );
diff --git a/src/astnode.cpp b/src/astnode.cpp
index 87b9383..1e86bdd 100644
--- a/src/astnode.cpp
+++ b/src/astnode.cpp
@@ -3,8 +3,8 @@
3#include "astbranch.h" 3#include "astbranch.h"
4 4
5AstNode::AstNode( const Location &loc, Type eType ) : 5AstNode::AstNode( const Location &loc, Type eType ) :
6 eType( eType ), 6 eType( eType ),
7 loc( loc ) 7 loc( loc )
8{ 8{
9} 9}
10 10
@@ -14,101 +14,101 @@ AstNode::~AstNode()
14 14
15Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode &n ) 15Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode &n )
16{ 16{
17 f << n.getType(); 17 f << n.getType();
18 if( n.getClass() == AstNode::typeBranch ) 18 if( n.getClass() == AstNode::typeBranch )
19 { 19 {
20 f << *dynamic_cast<const AstBranch *>(&n); 20 f << *dynamic_cast<const AstBranch *>(&n);
21 } 21 }
22 else 22 else
23 { 23 {
24 f << *dynamic_cast<const AstLeaf *>(&n); 24 f << *dynamic_cast<const AstLeaf *>(&n);
25 } 25 }
26 return f; 26 return f;
27} 27}
28 28
29Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode::Type &t ) 29Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode::Type &t )
30{ 30{
31 switch( t ) 31 switch( t )
32 { 32 {
33 case AstNode::typeFunction: f << "Function"; break; 33 case AstNode::typeFunction: f << "Function"; break;
34 case AstNode::typeSet: f << "Set"; break; 34 case AstNode::typeSet: f << "Set"; break;
35 case AstNode::typeUnset: f << "Unset"; break; 35 case AstNode::typeUnset: f << "Unset"; break;
36 case AstNode::typeIf: f << "If"; break; 36 case AstNode::typeIf: f << "If"; break;
37 case AstNode::typeInclude: f << "Include"; break; 37 case AstNode::typeInclude: f << "Include"; break;
38 case AstNode::typeTarget: f << "Target"; break; 38 case AstNode::typeTarget: f << "Target"; break;
39 case AstNode::typeRule: f << "Rule"; break; 39 case AstNode::typeRule: f << "Rule"; break;
40 case AstNode::typeConfig: f << "Config"; break; 40 case AstNode::typeConfig: f << "Config"; break;
41 case AstNode::typeList: f << "List"; break; 41 case AstNode::typeList: f << "List"; break;
42 case AstNode::typeInlineFunc: f << "InlineFunc"; break; 42 case AstNode::typeInlineFunc: f << "InlineFunc"; break;
43 case AstNode::typeRequires: f << "Requires"; break; 43 case AstNode::typeRequires: f << "Requires"; break;
44 case AstNode::typeFor: f << "For"; break; 44 case AstNode::typeFor: f << "For"; break;
45 case AstNode::typeFunctionDef: f << "FunctionDef"; break; 45 case AstNode::typeFunctionDef: f << "FunctionDef"; break;
46 case AstNode::typeReturn: f << "Return"; break; 46 case AstNode::typeReturn: f << "Return"; break;
47 case AstNode::typeProfile: f << "Profile"; break; 47 case AstNode::typeProfile: f << "Profile"; break;
48 case AstNode::typeInput: f << "Input"; break; 48 case AstNode::typeInput: f << "Input"; break;
49 case AstNode::typeRuleDef: f << "RuleDef"; break; 49 case AstNode::typeRuleDef: f << "RuleDef"; break;
50 case AstNode::typeOutput: f << "Output"; break; 50 case AstNode::typeOutput: f << "Output"; break;
51 case AstNode::typeAutoConfig: f << "AutoConfig"; break; 51 case AstNode::typeAutoConfig: f << "AutoConfig"; break;
52 case AstNode::typeGlobalConfig: f << "GlobalConfig"; break; 52 case AstNode::typeGlobalConfig: f << "GlobalConfig"; break;
53 case AstNode::typeType: f << "Type"; break; 53 case AstNode::typeType: f << "Type"; break;
54 case AstNode::typeValue: f << "Value"; break; 54 case AstNode::typeValue: f << "Value"; break;
55 case AstNode::typeAllow: f << "Allow"; break; 55 case AstNode::typeAllow: f << "Allow"; break;
56 case AstNode::typeDefault: f << "Default"; break; 56 case AstNode::typeDefault: f << "Default"; break;
57 case AstNode::typeExport: f << "Export"; break; 57 case AstNode::typeExport: f << "Export"; break;
58 case AstNode::typeExpr: f << "Expr"; break; 58 case AstNode::typeExpr: f << "Expr"; break;
59 case AstNode::typeActionDef: f << "ActionDef"; break; 59 case AstNode::typeActionDef: f << "ActionDef"; break;
60 case AstNode::typeProcessTarget:f << "ProcessTarget"; break; 60 case AstNode::typeProcessTarget:f << "ProcessTarget"; break;
61 case AstNode::typeTag: f << "Tag"; break; 61 case AstNode::typeTag: f << "Tag"; break;
62 62
63 case AstNode::typeVariable: f << "Variable"; break; 63 case AstNode::typeVariable: f << "Variable"; break;
64 case AstNode::typeString: f << "String"; break; 64 case AstNode::typeString: f << "String"; break;
65 case AstNode::typeInt: f << "Int"; break; 65 case AstNode::typeInt: f << "Int"; break;
66 case AstNode::typeFloat: f << "Float"; break; 66 case AstNode::typeFloat: f << "Float"; break;
67 case AstNode::typeBool: f << "Bool"; break; 67 case AstNode::typeBool: f << "Bool"; break;
68 case AstNode::typeVersion: f << "Version"; break; 68 case AstNode::typeVersion: f << "Version"; break;
69 case AstNode::typeOpEq: f << "Operator ="; break; 69 case AstNode::typeOpEq: f << "Operator ="; break;
70 case AstNode::typeOpPlusEq: f << "Operator +="; break; 70 case AstNode::typeOpPlusEq: f << "Operator +="; break;
71 case AstNode::typeOpPlusEqRaw: f << "Operator <<"; break; 71 case AstNode::typeOpPlusEqRaw: f << "Operator <<"; break;
72 case AstNode::typeError: f << "Error"; break; 72 case AstNode::typeError: f << "Error"; break;
73 case AstNode::typeWarning: f << "Warning"; break; 73 case AstNode::typeWarning: f << "Warning"; break;
74 case AstNode::typeNotice: f << "Notice"; break; 74 case AstNode::typeNotice: f << "Notice"; break;
75 case AstNode::typeTypeString: f << "Type String"; break; 75 case AstNode::typeTypeString: f << "Type String"; break;
76 case AstNode::typeTypeInt: f << "Type Int"; break; 76 case AstNode::typeTypeInt: f << "Type Int"; break;
77 case AstNode::typeTypeFloat: f << "Type Float"; break; 77 case AstNode::typeTypeFloat: f << "Type Float"; break;
78 case AstNode::typeTypeBool: f << "Type Bool"; break; 78 case AstNode::typeTypeBool: f << "Type Bool"; break;
79 case AstNode::typeTypeVersion: f << "Type Version"; break; 79 case AstNode::typeTypeVersion: f << "Type Version"; break;
80 case AstNode::typeCmpEq: f << "Compare ="; break; 80 case AstNode::typeCmpEq: f << "Compare ="; break;
81 case AstNode::typeCmpLt: f << "Compare <"; break; 81 case AstNode::typeCmpLt: f << "Compare <"; break;
82 case AstNode::typeCmpGt: f << "Compare >"; break; 82 case AstNode::typeCmpGt: f << "Compare >"; break;
83 case AstNode::typeCmpNe: f << "Compare !="; break; 83 case AstNode::typeCmpNe: f << "Compare !="; break;
84 case AstNode::typeCmpLtEq: f << "Compare <="; break; 84 case AstNode::typeCmpLtEq: f << "Compare <="; break;
85 case AstNode::typeCmpGtEq: f << "Compare >="; break; 85 case AstNode::typeCmpGtEq: f << "Compare >="; break;
86 case AstNode::typeCondition: f << "Condition"; break; 86 case AstNode::typeCondition: f << "Condition"; break;
87 case AstNode::typeDisplay: f << "Display"; break; 87 case AstNode::typeDisplay: f << "Display"; break;
88 case AstNode::typeCache: f << "Cache"; break; 88 case AstNode::typeCache: f << "Cache"; break;
89 case AstNode::typePushPrefix: f << "Push Prefix"; break; 89 case AstNode::typePushPrefix: f << "Push Prefix"; break;
90 case AstNode::typePopPrefix: f << "Pop Prefix"; break; 90 case AstNode::typePopPrefix: f << "Pop Prefix"; break;
91 case AstNode::typeNull: f << "Null"; break; 91 case AstNode::typeNull: f << "Null"; break;
92 case AstNode::typeVariableRef: f << "VariableRef"; break; 92 case AstNode::typeVariableRef: f << "VariableRef"; break;
93 case AstNode::typeOpPlus: f << "Operator +"; break; 93 case AstNode::typeOpPlus: f << "Operator +"; break;
94 case AstNode::typeOpMinus: f << "Operator -"; break; 94 case AstNode::typeOpMinus: f << "Operator -"; break;
95 case AstNode::typeOpMultiply: f << "Operator *"; break; 95 case AstNode::typeOpMultiply: f << "Operator *"; break;
96 case AstNode::typeOpDivide: f << "Operator /"; break; 96 case AstNode::typeOpDivide: f << "Operator /"; break;
97 case AstNode::typeOpNegate: f << "Operator negate"; break; 97 case AstNode::typeOpNegate: f << "Operator negate"; break;
98 case AstNode::typeOpNot: f << "Operator not"; break; 98 case AstNode::typeOpNot: f << "Operator not"; break;
99 99
100 case AstNode::typeBranch: f << "Branch"; break; 100 case AstNode::typeBranch: f << "Branch"; break;
101 case AstNode::typeLeaf: f << "Leaf"; break; 101 case AstNode::typeLeaf: f << "Leaf"; break;
102 case AstNode::typeClassMask: f << "ClassMask"; break; 102 case AstNode::typeClassMask: f << "ClassMask"; break;
103 103
104 case AstNode::typeDataNone: f << "<Data None>"; break; 104 case AstNode::typeDataNone: f << "<Data None>"; break;
105 case AstNode::typeDataString: f << "<Data String>"; break; 105 case AstNode::typeDataString: f << "<Data String>"; break;
106 case AstNode::typeDataInt: f << "<Data Int>"; break; 106 case AstNode::typeDataInt: f << "<Data Int>"; break;
107 case AstNode::typeDataFloat: f << "<Data Float>"; break; 107 case AstNode::typeDataFloat: f << "<Data Float>"; break;
108 case AstNode::typeDataBool: f << "<Data Bool>"; break; 108 case AstNode::typeDataBool: f << "<Data Bool>"; break;
109 case AstNode::typeDataVersion: f << "<Data Version>"; break; 109 case AstNode::typeDataVersion: f << "<Data Version>"; break;
110 case AstNode::typeDataMask: f << "<Data Mask>"; break; 110 case AstNode::typeDataMask: f << "<Data Mask>"; break;
111 } 111 }
112 return f; 112 return f;
113} 113}
114 114
diff --git a/src/astnode.h b/src/astnode.h
index 843dba8..f3b2d70 100644
--- a/src/astnode.h
+++ b/src/astnode.h
@@ -7,101 +7,101 @@
7class AstNode 7class AstNode
8{ 8{
9public: 9public:
10 enum Type 10 enum Type
11 { 11 {
12 // Branching types 12 // Branching types
13 typeFunction = 0x100001, 13 typeFunction = 0x100001,
14 typeSet = 0x100002, 14 typeSet = 0x100002,
15 typeUnset = 0x100003, 15 typeUnset = 0x100003,
16 typeIf = 0x100004, 16 typeIf = 0x100004,
17 typeInclude = 0x100005, 17 typeInclude = 0x100005,
18 typeTarget = 0x100006, 18 typeTarget = 0x100006,
19 typeRule = 0x100007, 19 typeRule = 0x100007,
20 typeConfig = 0x100008, 20 typeConfig = 0x100008,
21 typeList = 0x100009, 21 typeList = 0x100009,
22 typeInlineFunc = 0x10000A, 22 typeInlineFunc = 0x10000A,
23 typeRequires = 0x10000B, 23 typeRequires = 0x10000B,
24 typeFor = 0x10000C, 24 typeFor = 0x10000C,
25 typeFunctionDef = 0x10000D, 25 typeFunctionDef = 0x10000D,
26 typeReturn = 0x10000E, 26 typeReturn = 0x10000E,
27 typeProfile = 0x10000F, 27 typeProfile = 0x10000F,
28 typeInput = 0x100010, 28 typeInput = 0x100010,
29 typeRuleDef = 0x100011, 29 typeRuleDef = 0x100011,
30 typeOutput = 0x100012, 30 typeOutput = 0x100012,
31 typeAutoConfig = 0x100013, 31 typeAutoConfig = 0x100013,
32 typeGlobalConfig = 0x100014, 32 typeGlobalConfig = 0x100014,
33 typeType = 0x100015, 33 typeType = 0x100015,
34 typeValue = 0x100016, 34 typeValue = 0x100016,
35 typeAllow = 0x100017, 35 typeAllow = 0x100017,
36 typeDefault = 0x100018, 36 typeDefault = 0x100018,
37 typeExport = 0x100019, 37 typeExport = 0x100019,
38 typeExpr = 0x10001A, /***< Stack based compound expression.*/ 38 typeExpr = 0x10001A, /***< Stack based compound expression.*/
39 typeActionDef = 0x10001B, 39 typeActionDef = 0x10001B,
40 typeProcessTarget = 0x10001C, 40 typeProcessTarget = 0x10001C,
41 typeTag = 0x10001D, 41 typeTag = 0x10001D,
42 42
43 // Leaf types 43 // Leaf types
44 typeVariable = 0x210001, 44 typeVariable = 0x210001,
45 typeString = 0x210002, 45 typeString = 0x210002,
46 typeInt = 0x220003, 46 typeInt = 0x220003,
47 typeFloat = 0x230004, 47 typeFloat = 0x230004,
48 typeBool = 0x240005, 48 typeBool = 0x240005,
49 typeVersion = 0x250006, 49 typeVersion = 0x250006,
50 typeOpEq = 0x200007, 50 typeOpEq = 0x200007,
51 typeOpPlusEq = 0x200008, 51 typeOpPlusEq = 0x200008,
52 typeOpPlusEqRaw = 0x200009, 52 typeOpPlusEqRaw = 0x200009,
53 typeError = 0x21000A, 53 typeError = 0x21000A,
54 typeWarning = 0x21000B, 54 typeWarning = 0x21000B,
55 typeNotice = 0x21000C, 55 typeNotice = 0x21000C,
56 typeTypeString = 0x20000D, 56 typeTypeString = 0x20000D,
57 typeTypeInt = 0x20000E, 57 typeTypeInt = 0x20000E,
58 typeTypeFloat = 0x20000F, 58 typeTypeFloat = 0x20000F,
59 typeTypeBool = 0x200010, 59 typeTypeBool = 0x200010,
60 typeTypeVersion = 0x200011, 60 typeTypeVersion = 0x200011,
61 typeCmpEq = 0x200012, 61 typeCmpEq = 0x200012,
62 typeCmpLt = 0x200013, 62 typeCmpLt = 0x200013,
63 typeCmpGt = 0x200014, 63 typeCmpGt = 0x200014,
64 typeCmpNe = 0x200015, 64 typeCmpNe = 0x200015,
65 typeCmpLtEq = 0x200016, 65 typeCmpLtEq = 0x200016,
66 typeCmpGtEq = 0x200017, 66 typeCmpGtEq = 0x200017,
67 typeCondition = 0x210018, 67 typeCondition = 0x210018,
68 typeDisplay = 0x210019, 68 typeDisplay = 0x210019,
69 typeCache = 0x24001A, 69 typeCache = 0x24001A,
70 typePushPrefix = 0x21001B, 70 typePushPrefix = 0x21001B,
71 typePopPrefix = 0x20001C, 71 typePopPrefix = 0x20001C,
72 typeNull = 0x20001D, 72 typeNull = 0x20001D,
73 typeVariableRef = 0x21001E, 73 typeVariableRef = 0x21001E,
74 typeOpPlus = 0x20001F, 74 typeOpPlus = 0x20001F,
75 typeOpMinus = 0x200020, 75 typeOpMinus = 0x200020,
76 typeOpMultiply = 0x200021, 76 typeOpMultiply = 0x200021,
77 typeOpDivide = 0x200022, 77 typeOpDivide = 0x200022,
78 typeOpNegate = 0x200023, 78 typeOpNegate = 0x200023,
79 typeOpNot = 0x200024, 79 typeOpNot = 0x200024,
80 80
81 typeBranch = 0x100000, 81 typeBranch = 0x100000,
82 typeLeaf = 0x200000, 82 typeLeaf = 0x200000,
83 typeClassMask = 0x300000, 83 typeClassMask = 0x300000,
84 84
85 typeDataNone = 0x000000, 85 typeDataNone = 0x000000,
86 typeDataString = 0x010000, 86 typeDataString = 0x010000,
87 typeDataInt = 0x020000, 87 typeDataInt = 0x020000,
88 typeDataFloat = 0x030000, 88 typeDataFloat = 0x030000,
89 typeDataBool = 0x040000, 89 typeDataBool = 0x040000,
90 typeDataVersion = 0x050000, 90 typeDataVersion = 0x050000,
91 91
92 typeDataMask = 0x0F0000 92 typeDataMask = 0x0F0000
93 }; 93 };
94public: 94public:
95 AstNode( const Location &loc, Type eType ); 95 AstNode( const Location &loc, Type eType );
96 virtual ~AstNode(); 96 virtual ~AstNode();
97 97
98 Type getType() const { return eType; } 98 Type getType() const { return eType; }
99 Type getClass() const { return (Type)(eType&typeClassMask); } 99 Type getClass() const { return (Type)(eType&typeClassMask); }
100 Type getDataType() const { return (Type)(eType&typeDataMask); } 100 Type getDataType() const { return (Type)(eType&typeDataMask); }
101 101
102private: 102private:
103 Type eType; 103 Type eType;
104 Location loc; 104 Location loc;
105}; 105};
106 106
107Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode &n ); 107Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode &n );
diff --git a/src/buildparser.cpp b/src/buildparser.cpp
index cf98090..6ab23cd 100644
--- a/src/buildparser.cpp
+++ b/src/buildparser.cpp
@@ -7,9 +7,9 @@
7using Bu::sio; 7using Bu::sio;
8 8
9BuildParser::BuildParser( Ast &rAst ) : 9BuildParser::BuildParser( Ast &rAst ) :
10 xAst( rAst ) 10 xAst( rAst )
11{ 11{
12 lIncludePaths.append("./"); 12 lIncludePaths.append("./");
13 StrList lConds = ConditionPlugger::getInstance().getPluginList(); 13 StrList lConds = ConditionPlugger::getInstance().getPluginList();
14 for( StrList::iterator i = lConds.begin(); i; i++ ) 14 for( StrList::iterator i = lConds.begin(); i; i++ )
15 hConds.insert( *i, true ); 15 hConds.insert( *i, true );
@@ -23,37 +23,37 @@ int build_parse( yyscan_t yyscanner, BuildParser &bld );
23 23
24void BuildParser::load( const Bu::String &sFile ) 24void BuildParser::load( const Bu::String &sFile )
25{ 25{
26 yyscan_t scanner; 26 yyscan_t scanner;
27 27
28 sFilename.push( sFile ); 28 sFilename.push( sFile );
29 FILE *fIn = fopen( sFile.getStr(), "rt" ); 29 FILE *fIn = fopen( sFile.getStr(), "rt" );
30 if( fIn == NULL ) 30 if( fIn == NULL )
31 { 31 {
32 throw Bu::ExceptionBase("Cannot open file: %s", sFile.getStr() ); 32 throw Bu::ExceptionBase("Cannot open file: %s", sFile.getStr() );
33 } 33 }
34 build_lex_init( &scanner ); 34 build_lex_init( &scanner );
35 // build_set_debug( true, scanner ); 35 // build_set_debug( true, scanner );
36 build_set_in( fIn, scanner ); 36 build_set_in( fIn, scanner );
37 37
38 build_parse( scanner, *this ); 38 build_parse( scanner, *this );
39 39
40 build_lex_destroy( scanner ); 40 build_lex_destroy( scanner );
41 fclose( fIn ); 41 fclose( fIn );
42 42
43 // Bu::sio << xAst; 43 // Bu::sio << xAst;
44} 44}
45 45
46bool BuildParser::isKeyword( const Bu::String &sStr ) 46bool BuildParser::isKeyword( const Bu::String &sStr )
47{ 47{
48 if( sStr == "important" ) 48 if( sStr == "important" )
49 return true; 49 return true;
50 if( sStr == "normal" ) 50 if( sStr == "normal" )
51 return true; 51 return true;
52 if( sStr == "hidden" ) 52 if( sStr == "hidden" )
53 return true; 53 return true;
54 if( sStr == "autogenerated" ) 54 if( sStr == "autogenerated" )
55 return true; 55 return true;
56 return false; 56 return false;
57} 57}
58 58
59bool BuildParser::isCond( const Bu::String &sStr ) 59bool BuildParser::isCond( const Bu::String &sStr )
@@ -70,67 +70,67 @@ bool BuildParser::isCond( const Bu::String &sStr )
70 70
71void BuildParser::include( const Bu::String &sStr, void *scanner, YYLTYPE *loc ) 71void BuildParser::include( const Bu::String &sStr, void *scanner, YYLTYPE *loc )
72{ 72{
73 for( StrList::iterator pi = lIncludePaths.begin(); pi; pi++ ) 73 for( StrList::iterator pi = lIncludePaths.begin(); pi; pi++ )
74 { 74 {
75 FILE *fIn = fopen( (*pi + sStr).getStr(), "rt" ); 75 FILE *fIn = fopen( (*pi + sStr).getStr(), "rt" );
76 if( fIn == NULL ) 76 if( fIn == NULL )
77 { 77 {
78 continue; 78 continue;
79 } 79 }
80 sFilename.push( sStr ); 80 sFilename.push( sStr );
81 sLocation.push( *loc ); 81 sLocation.push( *loc );
82 loc->first_line = loc->last_line = 1; 82 loc->first_line = loc->last_line = 1;
83 loc->first_column = loc->last_column = 0; 83 loc->first_column = loc->last_column = 0;
84 build_push_buffer_state( 84 build_push_buffer_state(
85 build__create_buffer( fIn, YY_READ_BUF_SIZE, scanner ), 85 build__create_buffer( fIn, YY_READ_BUF_SIZE, scanner ),
86 scanner 86 scanner
87 ); 87 );
88 Bu::String::const_iterator i = sStr.find('/'); 88 Bu::String::const_iterator i = sStr.find('/');
89 if( i ) 89 if( i )
90 { 90 {
91 for(;;) 91 for(;;)
92 { 92 {
93 Bu::String::const_iterator j = i.find('/'); 93 Bu::String::const_iterator j = i.find('/');
94 if( !j ) 94 if( !j )
95 break; 95 break;
96 i = j+1; 96 i = j+1;
97 } 97 }
98 sio << "Hey, found it from here: " << sStr.getSubStr( sStr.begin(), i ) << sio.nl; 98 sio << "Hey, found it from here: " << sStr.getSubStr( sStr.begin(), i ) << sio.nl;
99 xAst.addNode( AstNode::typePushPrefix, sStr.getSubStr( sStr.begin(), i ) ); 99 xAst.addNode( AstNode::typePushPrefix, sStr.getSubStr( sStr.begin(), i ) );
100 } 100 }
101 else 101 else
102 { 102 {
103 xAst.addNode( AstNode::typePushPrefix, "" ); 103 xAst.addNode( AstNode::typePushPrefix, "" );
104 } 104 }
105 return; 105 return;
106 } 106 }
107 Bu::String msg("Could not open include file: "); 107 Bu::String msg("Could not open include file: ");
108 msg += sStr; 108 msg += sStr;
109 error( 109 error(
110 loc->first_line, loc->last_line, 110 loc->first_line, loc->last_line,
111 loc->first_column, loc->last_column, 111 loc->first_column, loc->last_column,
112 msg 112 msg
113 ); 113 );
114} 114}
115 115
116void BuildParser::endInclude( YYLTYPE *loc ) 116void BuildParser::endInclude( YYLTYPE *loc )
117{ 117{
118 sFilename.pop(); 118 sFilename.pop();
119 memcpy( loc, &sLocation.peek(), sizeof(YYLTYPE) ); 119 memcpy( loc, &sLocation.peek(), sizeof(YYLTYPE) );
120 sLocation.pop(); 120 sLocation.pop();
121 xAst.addNode( AstNode::typePopPrefix ); 121 xAst.addNode( AstNode::typePopPrefix );
122} 122}
123 123
124void BuildParser::error( int iLine1, int iLine2, int iCol1, int iCol2, 124void BuildParser::error( int iLine1, int iLine2, int iCol1, int iCol2,
125 const Bu::String &sMsg ) 125 const Bu::String &sMsg )
126{ 126{
127 throw Bu::ExceptionBase("%s: %d-%d:%d-%d: %s", 127 throw Bu::ExceptionBase("%s: %d-%d:%d-%d: %s",
128 sFilename.peek().getStr(), iLine1, iLine2, iCol1, iCol2, sMsg.getStr() 128 sFilename.peek().getStr(), iLine1, iLine2, iCol1, iCol2, sMsg.getStr()
129 ); 129 );
130} 130}
131 131
132void BuildParser::addIncludePath( const Bu::String &sPath ) 132void BuildParser::addIncludePath( const Bu::String &sPath )
133{ 133{
134 lIncludePaths.append( sPath + "/" ); 134 lIncludePaths.append( sPath + "/" );
135} 135}
136 136
diff --git a/src/buildparser.h b/src/buildparser.h
index 53e2a50..a6149f0 100644
--- a/src/buildparser.h
+++ b/src/buildparser.h
@@ -10,27 +10,27 @@
10class BuildParser 10class BuildParser
11{ 11{
12public: 12public:
13 BuildParser( class Ast &rAst ); 13 BuildParser( class Ast &rAst );
14 virtual ~BuildParser(); 14 virtual ~BuildParser();
15 15
16 void load( const Bu::String &sFile ); 16 void load( const Bu::String &sFile );
17 17
18 bool isKeyword( const Bu::String &sStr ); 18 bool isKeyword( const Bu::String &sStr );
19 bool isCond( const Bu::String &sStr ); 19 bool isCond( const Bu::String &sStr );
20 void include( const Bu::String &sStr, void *scanner, YYLTYPE *loc ); 20 void include( const Bu::String &sStr, void *scanner, YYLTYPE *loc );
21 void endInclude( YYLTYPE *loc ); 21 void endInclude( YYLTYPE *loc );
22 22
23 void error( int iLine1, int iLine2, int iCol1, int iCol2, 23 void error( int iLine1, int iLine2, int iCol1, int iCol2,
24 const Bu::String &sMsg ); 24 const Bu::String &sMsg );
25 25
26 class Ast &xAst; 26 class Ast &xAst;
27 27
28 void addIncludePath( const Bu::String &sPath ); 28 void addIncludePath( const Bu::String &sPath );
29 29
30private: 30private:
31 Bu::Stack<Bu::String> sFilename; 31 Bu::Stack<Bu::String> sFilename;
32 Bu::Stack<YYLTYPE> sLocation; 32 Bu::Stack<YYLTYPE> sLocation;
33 StrList lIncludePaths; 33 StrList lIncludePaths;
34 Bu::Hash<Bu::String, bool> hConds; 34 Bu::Hash<Bu::String, bool> hConds;
35}; 35};
36 36
diff --git a/src/cache.cpp b/src/cache.cpp
index d6269e3..8d6a91e 100644
--- a/src/cache.cpp
+++ b/src/cache.cpp
@@ -5,60 +5,60 @@
5using namespace Bu; 5using namespace Bu;
6 6
7Cache::Cache() : 7Cache::Cache() :
8 bCacheChanged( false ), 8 bCacheChanged( false ),
9 bIsLoaded( false ) 9 bIsLoaded( false )
10{ 10{
11} 11}
12 12
13Cache::~Cache() 13Cache::~Cache()
14{ 14{
15 save(); 15 save();
16} 16}
17 17
18void Cache::bind( const Bu::String &sCacheFile ) 18void Cache::bind( const Bu::String &sCacheFile )
19{ 19{
20 this->sCacheFile = sCacheFile; 20 this->sCacheFile = sCacheFile;
21 load(); 21 load();
22} 22}
23 23
24void Cache::load() 24void Cache::load()
25{ 25{
26 if( bIsLoaded ) 26 if( bIsLoaded )
27 return; 27 return;
28 28
29 try 29 try
30 { 30 {
31 Bu::File fIn( sCacheFile, Bu::File::Read ); 31 Bu::File fIn( sCacheFile, Bu::File::Read );
32 Bu::Archive ar( fIn, Bu::Archive::load ); 32 Bu::Archive ar( fIn, Bu::Archive::load );
33 33
34 ar >> hRequires >> hVariables; 34 ar >> hRequires >> hVariables;
35 } 35 }
36 catch(...) { } 36 catch(...) { }
37 37
38 bIsLoaded = true; 38 bIsLoaded = true;
39} 39}
40 40
41void Cache::save() 41void Cache::save()
42{ 42{
43 if( !bIsLoaded ) 43 if( !bIsLoaded )
44 return; 44 return;
45 if( bCacheChanged == false ) 45 if( bCacheChanged == false )
46 return; 46 return;
47 47
48 Bu::File fIn( sCacheFile, Bu::File::WriteNew ); 48 Bu::File fIn( sCacheFile, Bu::File::WriteNew );
49 Bu::Archive ar( fIn, Bu::Archive::save ); 49 Bu::Archive ar( fIn, Bu::Archive::save );
50 50
51 ar << hRequires << hVariables; 51 ar << hRequires << hVariables;
52} 52}
53 53
54StrList Cache::getRequires( const Bu::String &sOutput ) 54StrList Cache::getRequires( const Bu::String &sOutput )
55{ 55{
56 return hRequires.get( sOutput ); 56 return hRequires.get( sOutput );
57} 57}
58 58
59void Cache::setRequires( const Bu::String &sOutput, StrList lReqs ) 59void Cache::setRequires( const Bu::String &sOutput, StrList lReqs )
60{ 60{
61 hRequires.insert( sOutput, lReqs ); 61 hRequires.insert( sOutput, lReqs );
62 bCacheChanged = true; 62 bCacheChanged = true;
63} 63}
64 64
diff --git a/src/cache.h b/src/cache.h
index 57df281..9a53803 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -13,26 +13,26 @@ class Cache : public Bu::Singleton<Cache>
13{ 13{
14friend class Bu::Singleton<Cache>; 14friend class Bu::Singleton<Cache>;
15private: 15private:
16 Cache(); 16 Cache();
17 virtual ~Cache(); 17 virtual ~Cache();
18 18
19public: 19public:
20 void bind( const Bu::String &sCacheFile ); 20 void bind( const Bu::String &sCacheFile );
21 21
22 void load(); 22 void load();
23 void save(); 23 void save();
24 24
25 StrList getRequires( const Bu::String &sOutput ); 25 StrList getRequires( const Bu::String &sOutput );
26 void setRequires( const Bu::String &sOutput, StrList lReqs ); 26 void setRequires( const Bu::String &sOutput, StrList lReqs );
27 27
28private: 28private:
29 bool bCacheChanged; 29 bool bCacheChanged;
30 Bu::String sCacheFile; 30 Bu::String sCacheFile;
31 bool bIsLoaded; 31 bool bIsLoaded;
32 typedef Bu::Hash<Bu::String, StrList> ReqHash; 32 typedef Bu::Hash<Bu::String, StrList> ReqHash;
33 ReqHash hRequires; 33 ReqHash hRequires;
34 typedef Bu::Hash<Bu::String, Variable> VarHash; 34 typedef Bu::Hash<Bu::String, Variable> VarHash;
35 VarHash hVariables; 35 VarHash hVariables;
36}; 36};
37 37
38#endif 38#endif
diff --git a/src/condition.h b/src/condition.h
index 2e9b26a..a6b38bb 100644
--- a/src/condition.h
+++ b/src/condition.h
@@ -4,11 +4,11 @@
4class Condition 4class Condition
5{ 5{
6public: 6public:
7 Condition(); 7 Condition();
8 virtual ~Condition(); 8 virtual ~Condition();
9 9
10 virtual bool shouldExec( class Runner &r, class Target &rTarget )=0; 10 virtual bool shouldExec( class Runner &r, class Target &rTarget )=0;
11 virtual Condition *clone()=0; 11 virtual Condition *clone()=0;
12 12
13private: 13private:
14}; 14};
diff --git a/src/conditionalways.cpp b/src/conditionalways.cpp
index 8c245f4..c5fc0b0 100644
--- a/src/conditionalways.cpp
+++ b/src/conditionalways.cpp
@@ -3,7 +3,7 @@
3 3
4#include <bu/plugger.h> 4#include <bu/plugger.h>
5PluginInterface3( pluginConditionAlways, always, ConditionAlways, Condition, 5PluginInterface3( pluginConditionAlways, always, ConditionAlways, Condition,
6 "Mike Buland", 0, 1 ); 6 "Mike Buland", 0, 1 );
7 7
8ConditionAlways::ConditionAlways() 8ConditionAlways::ConditionAlways()
9{ 9{
@@ -15,11 +15,11 @@ ConditionAlways::~ConditionAlways()
15 15
16bool ConditionAlways::shouldExec( class Runner &/*r*/, Target &/*rTarget*/ ) 16bool ConditionAlways::shouldExec( class Runner &/*r*/, Target &/*rTarget*/ )
17{ 17{
18 return true; 18 return true;
19} 19}
20 20
21Condition *ConditionAlways::clone() 21Condition *ConditionAlways::clone()
22{ 22{
23 return new ConditionAlways(); 23 return new ConditionAlways();
24} 24}
25 25
diff --git a/src/conditionalways.h b/src/conditionalways.h
index 1eeeb71..2ac5a79 100644
--- a/src/conditionalways.h
+++ b/src/conditionalways.h
@@ -6,11 +6,11 @@
6class ConditionAlways : public Condition 6class ConditionAlways : public Condition
7{ 7{
8public: 8public:
9 ConditionAlways(); 9 ConditionAlways();
10 virtual ~ConditionAlways(); 10 virtual ~ConditionAlways();
11 11
12 virtual bool shouldExec( class Runner &r, class Target &rTarget ); 12 virtual bool shouldExec( class Runner &r, class Target &rTarget );
13 virtual Condition *clone(); 13 virtual Condition *clone();
14}; 14};
15 15
16#endif 16#endif
diff --git a/src/conditionfileexists.cpp b/src/conditionfileexists.cpp
index 0585351..fd21716 100644
--- a/src/conditionfileexists.cpp
+++ b/src/conditionfileexists.cpp
@@ -10,7 +10,7 @@ using namespace Bu;
10 10
11#include <bu/plugger.h> 11#include <bu/plugger.h>
12PluginInterface3( pluginConditionFileExists, fileExists, ConditionFileExists, 12PluginInterface3( pluginConditionFileExists, fileExists, ConditionFileExists,
13 Condition, "Mike Buland", 0, 1 ); 13 Condition, "Mike Buland", 0, 1 );
14 14
15ConditionFileExists::ConditionFileExists() 15ConditionFileExists::ConditionFileExists()
16{ 16{
@@ -22,20 +22,20 @@ ConditionFileExists::~ConditionFileExists()
22 22
23bool ConditionFileExists::shouldExec( class Runner &r, Target &rTarget ) 23bool ConditionFileExists::shouldExec( class Runner &r, Target &rTarget )
24{ 24{
25 for( StrList::const_iterator j = rTarget.getOutputList().begin(); j; j++ ) 25 for( StrList::const_iterator j = rTarget.getOutputList().begin(); j; j++ )
26 { 26 {
27 // If any input exists, then return true, we should exec. 27 // If any input exists, then return true, we should exec.
28 if( !access( (*j).getStr(), F_OK ) ) 28 if( !access( (*j).getStr(), F_OK ) )
29 { 29 {
30 return true; 30 return true;
31 } 31 }
32 } 32 }
33 33
34 return false; 34 return false;
35} 35}
36 36
37Condition *ConditionFileExists::clone() 37Condition *ConditionFileExists::clone()
38{ 38{
39 return new ConditionFileExists(); 39 return new ConditionFileExists();
40} 40}
41 41
diff --git a/src/conditionfileexists.h b/src/conditionfileexists.h
index 6f30297..f1fe568 100644
--- a/src/conditionfileexists.h
+++ b/src/conditionfileexists.h
@@ -6,11 +6,11 @@
6class ConditionFileExists : public Condition 6class ConditionFileExists : public Condition
7{ 7{
8public: 8public:
9 ConditionFileExists(); 9 ConditionFileExists();
10 virtual ~ConditionFileExists(); 10 virtual ~ConditionFileExists();
11 11
12 virtual bool shouldExec( class Runner &r, class Target &rTarget ); 12 virtual bool shouldExec( class Runner &r, class Target &rTarget );
13 virtual Condition *clone(); 13 virtual Condition *clone();
14}; 14};
15 15
16#endif 16#endif
diff --git a/src/conditionfiletime.cpp b/src/conditionfiletime.cpp
index 43df53b..82d147c 100644
--- a/src/conditionfiletime.cpp
+++ b/src/conditionfiletime.cpp
@@ -10,7 +10,7 @@ using namespace Bu;
10 10
11#include <bu/plugger.h> 11#include <bu/plugger.h>
12PluginInterface3( pluginConditionFileTime, fileTime, ConditionFileTime, 12PluginInterface3( pluginConditionFileTime, fileTime, ConditionFileTime,
13 Condition, "Mike Buland", 0, 1 ); 13 Condition, "Mike Buland", 0, 1 );
14 14
15ConditionFileTime::ConditionFileTime() 15ConditionFileTime::ConditionFileTime()
16{ 16{
@@ -22,59 +22,59 @@ ConditionFileTime::~ConditionFileTime()
22 22
23bool ConditionFileTime::shouldExec( class Runner &r, Target &rTarget ) 23bool ConditionFileTime::shouldExec( class Runner &r, Target &rTarget )
24{ 24{
25 for( StrList::const_iterator j = rTarget.getOutputList().begin(); j; j++ ) 25 for( StrList::const_iterator j = rTarget.getOutputList().begin(); j; j++ )
26 { 26 {
27 if( access( (*j).getStr(), F_OK ) ) 27 if( access( (*j).getStr(), F_OK ) )
28 { 28 {
29 //sio << "-- Target processed because '" << *j << "' doesn't exist." 29 //sio << "-- Target processed because '" << *j << "' doesn't exist."
30 // << sio.nl; 30 // << sio.nl;
31 // Output doesn't exist 31 // Output doesn't exist
32 rTarget.buildRequires( r ); 32 rTarget.buildRequires( r );
33 return true; 33 return true;
34 } 34 }
35 } 35 }
36 36
37 time_t tOut = 0; 37 time_t tOut = 0;
38 struct stat s; 38 struct stat s;
39 for( StrList::const_iterator j = rTarget.getOutputList().begin(); 39 for( StrList::const_iterator j = rTarget.getOutputList().begin();
40 j; j++ ) 40 j; j++ )
41 { 41 {
42 stat( (*j).getStr(), &s ); 42 stat( (*j).getStr(), &s );
43 if( tOut == 0 || tOut > s.st_mtime ) 43 if( tOut == 0 || tOut > s.st_mtime )
44 { 44 {
45 tOut = s.st_mtime; 45 tOut = s.st_mtime;
46 } 46 }
47 } 47 }
48 for( StrList::const_iterator j = rTarget.getInputList().begin(); 48 for( StrList::const_iterator j = rTarget.getInputList().begin();
49 j; j++ ) 49 j; j++ )
50 { 50 {
51 stat( (*j).getStr(), &s ); 51 stat( (*j).getStr(), &s );
52 if( tOut < s.st_mtime ) 52 if( tOut < s.st_mtime )
53 { 53 {
54 //sio << "-- Target processed because '" << *j 54 //sio << "-- Target processed because '" << *j
55 // << "' is newer than output." << sio.nl; 55 // << "' is newer than output." << sio.nl;
56 rTarget.buildRequires( r ); 56 rTarget.buildRequires( r );
57 return true; 57 return true;
58 } 58 }
59 } 59 }
60 rTarget.gatherRequires( r ); 60 rTarget.gatherRequires( r );
61 for( StrList::const_iterator j = rTarget.getRequiresList().begin(); 61 for( StrList::const_iterator j = rTarget.getRequiresList().begin();
62 j; j++ ) 62 j; j++ )
63 { 63 {
64 stat( (*j).getStr(), &s ); 64 stat( (*j).getStr(), &s );
65 if( tOut < s.st_mtime ) 65 if( tOut < s.st_mtime )
66 { 66 {
67 //sio << "-- Target processed because '" << *j 67 //sio << "-- Target processed because '" << *j
68 // << "' is newer than output." << sio.nl; 68 // << "' is newer than output." << sio.nl;
69 rTarget.buildRequires( r ); 69 rTarget.buildRequires( r );
70 return true; 70 return true;
71 } 71 }
72 } 72 }
73 return false; 73 return false;
74} 74}
75 75
76Condition *ConditionFileTime::clone() 76Condition *ConditionFileTime::clone()
77{ 77{
78 return new ConditionFileTime(); 78 return new ConditionFileTime();
79} 79}
80 80
diff --git a/src/conditionfiletime.h b/src/conditionfiletime.h
index 6fb2e9d..54cc83b 100644
--- a/src/conditionfiletime.h
+++ b/src/conditionfiletime.h
@@ -6,11 +6,11 @@
6class ConditionFileTime : public Condition 6class ConditionFileTime : public Condition
7{ 7{
8public: 8public:
9 ConditionFileTime(); 9 ConditionFileTime();
10 virtual ~ConditionFileTime(); 10 virtual ~ConditionFileTime();
11 11
12 virtual bool shouldExec( class Runner &r, class Target &rTarget ); 12 virtual bool shouldExec( class Runner &r, class Target &rTarget );
13 virtual Condition *clone(); 13 virtual Condition *clone();
14}; 14};
15 15
16#endif 16#endif
diff --git a/src/conditionnever.cpp b/src/conditionnever.cpp
index f99feb6..74f493b 100644
--- a/src/conditionnever.cpp
+++ b/src/conditionnever.cpp
@@ -3,7 +3,7 @@
3 3
4#include <bu/plugger.h> 4#include <bu/plugger.h>
5PluginInterface3( pluginConditionNever, never, ConditionNever, Condition, 5PluginInterface3( pluginConditionNever, never, ConditionNever, Condition,
6 "Mike Buland", 0, 1 ); 6 "Mike Buland", 0, 1 );
7 7
8ConditionNever::ConditionNever() 8ConditionNever::ConditionNever()
9{ 9{
@@ -15,11 +15,11 @@ ConditionNever::~ConditionNever()
15 15
16bool ConditionNever::shouldExec( class Runner &/*r*/, Target &/*rTarget*/ ) 16bool ConditionNever::shouldExec( class Runner &/*r*/, Target &/*rTarget*/ )
17{ 17{
18 return false; 18 return false;
19} 19}
20 20
21Condition *ConditionNever::clone() 21Condition *ConditionNever::clone()
22{ 22{
23 return new ConditionNever(); 23 return new ConditionNever();
24} 24}
25 25
diff --git a/src/conditionnever.h b/src/conditionnever.h
index b7e5e92..d0b6e22 100644
--- a/src/conditionnever.h
+++ b/src/conditionnever.h
@@ -6,11 +6,11 @@
6class ConditionNever : public Condition 6class ConditionNever : public Condition
7{ 7{
8public: 8public:
9 ConditionNever(); 9 ConditionNever();
10 virtual ~ConditionNever(); 10 virtual ~ConditionNever();
11 11
12 virtual bool shouldExec( class Runner &r, class Target &rTarget ); 12 virtual bool shouldExec( class Runner &r, class Target &rTarget );
13 virtual Condition *clone(); 13 virtual Condition *clone();
14}; 14};
15 15
16#endif 16#endif
diff --git a/src/conditionplugger.cpp b/src/conditionplugger.cpp
index 53f613a..6eb54cf 100644
--- a/src/conditionplugger.cpp
+++ b/src/conditionplugger.cpp
@@ -10,31 +10,31 @@ extern Bu::PluginInfo pluginConditionFileExists;
10 10
11ConditionPlugger::ConditionPlugger() 11ConditionPlugger::ConditionPlugger()
12{ 12{
13 registerBuiltinPlugin( &pluginConditionAlways ); 13 registerBuiltinPlugin( &pluginConditionAlways );
14 registerBuiltinPlugin( &pluginConditionNever ); 14 registerBuiltinPlugin( &pluginConditionNever );
15 registerBuiltinPlugin( &pluginConditionFileTime ); 15 registerBuiltinPlugin( &pluginConditionFileTime );
16 registerBuiltinPlugin( &pluginConditionFileExists ); 16 registerBuiltinPlugin( &pluginConditionFileExists );
17 17
18 DIR *dir = opendir("/usr/lib/build"); 18 DIR *dir = opendir("/usr/lib/build");
19 if( !dir ) 19 if( !dir )
20 return; 20 return;
21 struct dirent *de; 21 struct dirent *de;
22 while( (de = readdir( dir )) ) 22 while( (de = readdir( dir )) )
23 { 23 {
24 if( strncmp("pluginCondition", de->d_name, 15 ) ) 24 if( strncmp("pluginCondition", de->d_name, 15 ) )
25 continue; 25 continue;
26 26
27 Bu::String sFile("/usr/lib/build/"); 27 Bu::String sFile("/usr/lib/build/");
28 sFile += de->d_name; 28 sFile += de->d_name;
29 char *s = de->d_name; 29 char *s = de->d_name;
30 for(; *s && *s != '.'; s++ ) { } 30 for(; *s && *s != '.'; s++ ) { }
31 registerExternalPlugin( 31 registerExternalPlugin(
32 sFile, 32 sFile,
33 Bu::String( de->d_name, (ptrdiff_t)s-(ptrdiff_t)de->d_name ) 33 Bu::String( de->d_name, (ptrdiff_t)s-(ptrdiff_t)de->d_name )
34 ); 34 );
35 } 35 }
36 36
37 closedir( dir ); 37 closedir( dir );
38} 38}
39 39
40ConditionPlugger::~ConditionPlugger() 40ConditionPlugger::~ConditionPlugger()
diff --git a/src/conditionplugger.h b/src/conditionplugger.h
index 71fa7e3..294614b 100644
--- a/src/conditionplugger.h
+++ b/src/conditionplugger.h
@@ -6,12 +6,12 @@
6#include <bu/singleton.h> 6#include <bu/singleton.h>
7 7
8class ConditionPlugger : public Bu::Plugger<Condition>, 8class ConditionPlugger : public Bu::Plugger<Condition>,
9 public Bu::Singleton<ConditionPlugger> 9 public Bu::Singleton<ConditionPlugger>
10{ 10{
11friend class Bu::Singleton<ConditionPlugger>; 11friend class Bu::Singleton<ConditionPlugger>;
12private: 12private:
13 ConditionPlugger(); 13 ConditionPlugger();
14 virtual ~ConditionPlugger(); 14 virtual ~ConditionPlugger();
15}; 15};
16 16
17#endif 17#endif
diff --git a/src/context.cpp b/src/context.cpp
index 22bea57..7f0c56f 100644
--- a/src/context.cpp
+++ b/src/context.cpp
@@ -14,9 +14,9 @@
14using namespace Bu; 14using namespace Bu;
15 15
16Context::Context() : 16Context::Context() :
17 pView( NULL ) 17 pView( NULL )
18{ 18{
19 pushScope(); 19 pushScope();
20} 20}
21 21
22Context::~Context() 22Context::~Context()
@@ -25,522 +25,522 @@ Context::~Context()
25 25
26void Context::addTarget( Target *pTarget ) 26void Context::addTarget( Target *pTarget )
27{ 27{
28 for( StrList::const_iterator i = pTarget->getOutputList().begin(); i; i++ ) 28 for( StrList::const_iterator i = pTarget->getOutputList().begin(); i; i++ )
29 { 29 {
30 hTarget.insert( (*i).getStr(), pTarget ); 30 hTarget.insert( (*i).getStr(), pTarget );
31 } 31 }
32} 32}
33 33
34void Context::addRule( Rule *pRule ) 34void Context::addRule( Rule *pRule )
35{ 35{
36 hRule.insert( pRule->getName(), pRule ); 36 hRule.insert( pRule->getName(), pRule );
37} 37}
38 38
39void Context::addFunction( Function *pFunction ) 39void Context::addFunction( Function *pFunction )
40{ 40{
41 pFunction->setContext( this ); 41 pFunction->setContext( this );
42 hFunction.insert( pFunction->getName(), pFunction ); 42 hFunction.insert( pFunction->getName(), pFunction );
43} 43}
44 44
45void Context::addVariable( const Bu::String &sName, const Variable &vValue ) 45void Context::addVariable( const Bu::String &sName, const Variable &vValue )
46{ 46{
47 for( ScopeStack::iterator i = sVars.begin(); i; i++ ) 47 for( ScopeStack::iterator i = sVars.begin(); i; i++ )
48 { 48 {
49 if( (*i).has( sName ) ) 49 if( (*i).has( sName ) )
50 { 50 {
51// sio << "Replacing higher scope variable \"" << sName << "\" with value \"" << (*i).get( sName ) << "\" with new value \"" << vValue << "\"" << sio.nl; 51// sio << "Replacing higher scope variable \"" << sName << "\" with value \"" << (*i).get( sName ) << "\" with new value \"" << vValue << "\"" << sio.nl;
52 (*i).insert( sName, vValue ); 52 (*i).insert( sName, vValue );
53 return; 53 return;
54 } 54 }
55 } 55 }
56 sVars.first().insert( sName, vValue ); 56 sVars.first().insert( sName, vValue );
57} 57}
58 58
59void Context::addAction( Action *pAction ) 59void Context::addAction( Action *pAction )
60{ 60{
61 hAction.insert( pAction->getName(), pAction ); 61 hAction.insert( pAction->getName(), pAction );
62} 62}
63 63
64Action *Context::getAction( const Bu::String &sName ) 64Action *Context::getAction( const Bu::String &sName )
65{ 65{
66 return hAction.get( sName ); 66 return hAction.get( sName );
67} 67}
68 68
69void Context::addTargetToTag( Target *pTarget, const Bu::String &sTag ) 69void Context::addTargetToTag( Target *pTarget, const Bu::String &sTag )
70{ 70{
71 if( !hTag.has( sTag ) ) 71 if( !hTag.has( sTag ) )
72 { 72 {
73 hTag.insert( sTag, TargetList() ); 73 hTag.insert( sTag, TargetList() );
74 } 74 }
75 hTag.get( sTag ).append( pTarget ); 75 hTag.get( sTag ).append( pTarget );
76} 76}
77 77
78void Context::addTargetToTags( Target *pTarget, const StrList &sTags ) 78void Context::addTargetToTags( Target *pTarget, const StrList &sTags )
79{ 79{
80 for( StrList::const_iterator i = sTags.begin(); i; i++ ) 80 for( StrList::const_iterator i = sTags.begin(); i; i++ )
81 { 81 {
82 addTargetToTag( pTarget, *i ); 82 addTargetToTag( pTarget, *i );
83 } 83 }
84} 84}
85 85
86TargetList &Context::getTag( const Bu::String &sTag ) 86TargetList &Context::getTag( const Bu::String &sTag )
87{ 87{
88 return hTag.get( sTag ); 88 return hTag.get( sTag );
89} 89}
90 90
91Variable &Context::getVariable( const Bu::String &sName ) 91Variable &Context::getVariable( const Bu::String &sName )
92{ 92{
93 for( ScopeStack::iterator i = sVars.begin(); i; i++ ) 93 for( ScopeStack::iterator i = sVars.begin(); i; i++ )
94 { 94 {
95 if( (*i).has( sName ) ) 95 if( (*i).has( sName ) )
96 { 96 {
97 return (*i).get( sName ); 97 return (*i).get( sName );
98 } 98 }
99 } 99 }
100 throw Bu::ExceptionBase("No such variable."); 100 throw Bu::ExceptionBase("No such variable.");
101} 101}
102 102
103void Context::delVariable( const Bu::String &sName ) 103void Context::delVariable( const Bu::String &sName )
104{ 104{
105 for( ScopeStack::iterator i = sVars.begin(); i; i++ ) 105 for( ScopeStack::iterator i = sVars.begin(); i; i++ )
106 { 106 {
107 if( (*i).has( sName ) ) 107 if( (*i).has( sName ) )
108 { 108 {
109 (*i).erase( sName ); 109 (*i).erase( sName );
110 } 110 }
111 } 111 }
112} 112}
113 113
114void Context::pushScope() 114void Context::pushScope()
115{ 115{
116 VarHash h; 116 VarHash h;
117 if( !sVars.isEmpty() ) 117 if( !sVars.isEmpty() )
118 h = sVars.peek(); 118 h = sVars.peek();
119 sVars.push( h ); 119 sVars.push( h );
120} 120}
121 121
122void Context::pushScope( const VarHash &hNewVars ) 122void Context::pushScope( const VarHash &hNewVars )
123{ 123{
124// sio << "Pushing scope, merging contexts." << sio.nl << sio.nl; 124// sio << "Pushing scope, merging contexts." << sio.nl << sio.nl;
125 VarHash h = hNewVars; 125 VarHash h = hNewVars;
126 if( !sVars.isEmpty() ) 126 if( !sVars.isEmpty() )
127 { 127 {
128// sio << "hNewVars = " << h << sio.nl << sio.nl 128// sio << "hNewVars = " << h << sio.nl << sio.nl
129// << "sVars = " << sVars.peek() << sio.nl; 129// << "sVars = " << sVars.peek() << sio.nl;
130 for( VarHash::iterator i = sVars.peek().begin(); i; i++ ) 130 for( VarHash::iterator i = sVars.peek().begin(); i; i++ )
131 { 131 {
132// sio << "Checking '" << i.getKey() << "' (" << i.getValue() << ")." << sio.nl; 132// sio << "Checking '" << i.getKey() << "' (" << i.getValue() << ")." << sio.nl;
133 if( !h.has( i.getKey() ) ) 133 if( !h.has( i.getKey() ) )
134 { 134 {
135// sio << " Context doesn't have '" << i.getKey() << "' adding... '" << i.getValue() << "'." << sio.nl; 135// sio << " Context doesn't have '" << i.getKey() << "' adding... '" << i.getValue() << "'." << sio.nl;
136 h.insert( i.getKey(), i.getValue() ); 136 h.insert( i.getKey(), i.getValue() );
137 } 137 }
138 } 138 }
139 } 139 }
140 sVars.push( h ); 140 sVars.push( h );
141} 141}
142 142
143VarHash &Context::getScope() 143VarHash &Context::getScope()
144{ 144{
145 return sVars.peek(); 145 return sVars.peek();
146} 146}
147 147
148void Context::popScope() 148void Context::popScope()
149{ 149{
150 sVars.pop(); 150 sVars.pop();
151} 151}
152 152
153Variable Context::call( const Bu::String &sName, Variable &input, 153Variable Context::call( const Bu::String &sName, Variable &input,
154 VarList lParams ) 154 VarList lParams )
155{ 155{
156 if( !hFunction.has( sName ) ) 156 if( !hFunction.has( sName ) )
157 { 157 {
158 // Try to load the function... 158 // Try to load the function...
159 try 159 try
160 { 160 {
161 addFunction( FunctionPlugger::getInstance().instantiate( sName ) ); 161 addFunction( FunctionPlugger::getInstance().instantiate( sName ) );
162 } 162 }
163 catch(...) 163 catch(...)
164 { 164 {
165 throw Bu::ExceptionBase("Unknown function called: %s", 165 throw Bu::ExceptionBase("Unknown function called: %s",
166 sName.getStr() ); 166 sName.getStr() );
167 } 167 }
168 } 168 }
169 return hFunction.get( sName )->call( input, lParams ); 169 return hFunction.get( sName )->call( input, lParams );
170} 170}
171 171
172#include <bu/sio.h> 172#include <bu/sio.h>
173using namespace Bu; 173using namespace Bu;
174Bu::String Context::expand( const Bu::String &sInS ) 174Bu::String Context::expand( const Bu::String &sInS )
175{ 175{
176 Bu::String sRet; 176 Bu::String sRet;
177 Bu::String sIn = sInS; 177 Bu::String sIn = sInS;
178 178
179 for( int iPass = 0; iPass < 2; iPass++ ) 179 for( int iPass = 0; iPass < 2; iPass++ )
180 { 180 {
181 Bu::String::const_iterator b = sIn.begin(); 181 Bu::String::const_iterator b = sIn.begin();
182 sRet.clear(); 182 sRet.clear();
183 for(;;) 183 for(;;)
184 { 184 {
185 Bu::String::const_iterator e = b.find('$'); 185 Bu::String::const_iterator e = b.find('$');
186 if( !e ) 186 if( !e )
187 { 187 {
188 sRet.append( b ); 188 sRet.append( b );
189 break; 189 break;
190 } 190 }
191 sRet.append( b, e ); 191 sRet.append( b, e );
192 b = e+1; 192 b = e+1;
193 if( !b ) 193 if( !b )
194 { 194 {
195 sRet.append('$'); 195 sRet.append('$');
196 } 196 }
197 else if( *b == '{' ) 197 else if( *b == '{' )
198 { 198 {
199 b++; 199 b++;
200 e = b.find('}'); 200 e = b.find('}');
201 Bu::String sVar( b, e ); 201 Bu::String sVar( b, e );
202 try 202 try
203 { 203 {
204 sRet.append( getVariable( sVar ).toString() ); 204 sRet.append( getVariable( sVar ).toString() );
205 } catch(...) 205 } catch(...)
206 { 206 {
207 // TODO: This may be handy debugging later... 207 // TODO: This may be handy debugging later...
208 //sio << "No variable named " << sVar << sio.nl; 208 //sio << "No variable named " << sVar << sio.nl;
209 //sio << "Vars: " << sVars << sio.nl << sio.nl; 209 //sio << "Vars: " << sVars << sio.nl << sio.nl;
210 } 210 }
211 b = e+1; 211 b = e+1;
212 } 212 }
213 else if( *b == '(' && iPass == 1 ) 213 else if( *b == '(' && iPass == 1 )
214 { 214 {
215 Bu::String sCmd; 215 Bu::String sCmd;
216 b++; 216 b++;
217 for( e = b; e != ')'; e++ ) 217 for( e = b; e != ')'; e++ )
218 { 218 {
219 if( *e == '\\' && *(e+1) == ')' ) 219 if( *e == '\\' && *(e+1) == ')' )
220 { 220 {
221 sCmd += ')'; 221 sCmd += ')';
222 e++; 222 e++;
223 } 223 }
224 else 224 else
225 sCmd += *e; 225 sCmd += *e;
226 } 226 }
227 //e = b.find(')'); 227 //e = b.find(')');
228// Bu::String sCmd( b, e ); 228// Bu::String sCmd( b, e );
229 Bu::String sBuf; 229 Bu::String sBuf;
230 try 230 try
231 { 231 {
232 //sio << "Executing command: >>>" << sCmd << "<<<" << sio.nl; 232 //sio << "Executing command: >>>" << sCmd << "<<<" << sio.nl;
233 Process p( Process::StdOut, 233 Process p( Process::StdOut,
234 "/bin/bash", "/bin/bash", "-c", sCmd.getStr(), NULL 234 "/bin/bash", "/bin/bash", "-c", sCmd.getStr(), NULL
235 ); 235 );
236 char buf[4096]; 236 char buf[4096];
237 do 237 do
238 { 238 {
239 sBuf.append( buf, p.read( buf, 4096 ) ); 239 sBuf.append( buf, p.read( buf, 4096 ) );
240 } 240 }
241 while( p.isRunning() ); 241 while( p.isRunning() );
242 sBuf.append( buf, p.read( buf, 4096 ) ); 242 sBuf.append( buf, p.read( buf, 4096 ) );
243 sBuf = sBuf.replace("\n", " ").replace("\r", " "). 243 sBuf = sBuf.replace("\n", " ").replace("\r", " ").
244 trimWhitespace(); 244 trimWhitespace();
245 sRet.append( sBuf ); 245 sRet.append( sBuf );
246 } catch(...) 246 } catch(...)
247 { 247 {
248 // TODO: This may be handy debugging later... 248 // TODO: This may be handy debugging later...
249 //sio << "No variable named " << sVar << sio.nl; 249 //sio << "No variable named " << sVar << sio.nl;
250 //sio << "Vars: " << sVars << sio.nl << sio.nl; 250 //sio << "Vars: " << sVars << sio.nl << sio.nl;
251 } 251 }
252 b = e+1; 252 b = e+1;
253 } 253 }
254 else 254 else
255 { 255 {
256 // Not a match, uh, just output the $ for now... 256 // Not a match, uh, just output the $ for now...
257 sRet.append('$'); 257 sRet.append('$');
258 } 258 }
259 } 259 }
260 260
261 sIn = sRet; 261 sIn = sRet;
262 } 262 }
263 return sRet; 263 return sRet;
264} 264}
265 265
266Target *Context::getTarget( const Bu::String &sOutput ) 266Target *Context::getTarget( const Bu::String &sOutput )
267{ 267{
268 return hTarget.get( sOutput ); 268 return hTarget.get( sOutput );
269} 269}
270 270
271TargetList Context::getExplicitTargets() 271TargetList Context::getExplicitTargets()
272{ 272{
273 TargetList lRet; 273 TargetList lRet;
274 for( TargetHash::iterator i = hTarget.begin(); i; i++ ) 274 for( TargetHash::iterator i = hTarget.begin(); i; i++ )
275 { 275 {
276 if( (*i)->isExplicit() ) 276 if( (*i)->isExplicit() )
277 lRet.append( *i ); 277 lRet.append( *i );
278 } 278 }
279 return lRet; 279 return lRet;
280} 280}
281 281
282void Context::buildTargetTree( Runner &r ) 282void Context::buildTargetTree( Runner &r )
283{ 283{
284 TargetList lTargets = hTarget.getValues(); 284 TargetList lTargets = hTarget.getValues();
285 285
286 for( TargetList::iterator i = lTargets.begin(); i; i++ ) 286 for( TargetList::iterator i = lTargets.begin(); i; i++ )
287 { 287 {
288 // I believe we only want to autogenerate targets for explicit targets 288 // I believe we only want to autogenerate targets for explicit targets
289 // that have rules defined. 289 // that have rules defined.
290 if( !(*i)->isExplicit() || !(*i)->hasRule() ) 290 if( !(*i)->isExplicit() || !(*i)->hasRule() )
291 continue; 291 continue;
292 292
293 StrList lNewIns; // The new "changed" inputs for this target 293 StrList lNewIns; // The new "changed" inputs for this target
294 294
295 Rule *pMaster; 295 Rule *pMaster;
296 try 296 try
297 { 297 {
298 pMaster = hRule.get( (*i)->getRule() ); 298 pMaster = hRule.get( (*i)->getRule() );
299 } 299 }
300 catch( Bu::HashException &e ) 300 catch( Bu::HashException &e )
301 { 301 {
302 throw Bu::ExceptionBase("Unknown rule: %s", (*i)->getRule().getStr() ); 302 throw Bu::ExceptionBase("Unknown rule: %s", (*i)->getRule().getStr() );
303 } 303 }
304 304
305 for( StrList::const_iterator j = (*i)->getInputList().begin(); j; j++ ) 305 for( StrList::const_iterator j = (*i)->getInputList().begin(); j; j++ )
306 { 306 {
307 if( pMaster->ruleMatches( r, *j ) ) 307 if( pMaster->ruleMatches( r, *j ) )
308 { 308 {
309 lNewIns.append( *j ); 309 lNewIns.append( *j );
310 } 310 }
311 311
312 if( hTarget.has( *j ) ) 312 if( hTarget.has( *j ) )
313 { 313 {
314 // Find the existing dependancy 314 // Find the existing dependancy
315 lNewIns.append( *j ); 315 lNewIns.append( *j );
316 } 316 }
317 //else 317 //else
318 //{ 318 //{
319 buildTargetTree( r, *i, *j, pMaster, lNewIns ); 319 buildTargetTree( r, *i, *j, pMaster, lNewIns );
320 //} 320 //}
321 } 321 }
322 322
323 pMaster->prepTarget( *i ); 323 pMaster->prepTarget( *i );
324 (*i)->resetInputList( lNewIns ); 324 (*i)->resetInputList( lNewIns );
325 } 325 }
326 //sio << "Building dependancies: " << Fmt(3) << 0 << "%\r" << sio.flush; 326 //sio << "Building dependancies: " << Fmt(3) << 0 << "%\r" << sio.flush;
327 //int iSize = hTarget.getSize(), iCur = 0; 327 //int iSize = hTarget.getSize(), iCur = 0;
328 for( TargetHash::iterator i = hTarget.begin(); i; i++ ) 328 for( TargetHash::iterator i = hTarget.begin(); i; i++ )
329 { 329 {
330 // Before we can take a look at the requirements, we need to build 330 // Before we can take a look at the requirements, we need to build
331 // them... 331 // them...
332 // (*i)->buildRequires( r ); 332 // (*i)->buildRequires( r );
333 333
334 // For every target we have to examine both it's inputs and it's 334 // For every target we have to examine both it's inputs and it's
335 // additional requirements. Inputs first 335 // additional requirements. Inputs first
336 StrList lDeps( (*i)->getInputList() ); 336 StrList lDeps( (*i)->getInputList() );
337 lDeps += (*i)->getRequiresList(); 337 lDeps += (*i)->getRequiresList();
338 for( StrList::const_iterator j = lDeps.begin(); j; j++ ) 338 for( StrList::const_iterator j = lDeps.begin(); j; j++ )
339 { 339 {
340 try 340 try
341 { 341 {
342 (*i)->addDep( hTarget.get( *j ) ); 342 (*i)->addDep( hTarget.get( *j ) );
343 } 343 }
344 catch(...) 344 catch(...)
345 { 345 {
346 } 346 }
347 } 347 }
348 //iCur++; 348 //iCur++;
349 // sio << "Building dependancies: " << Fmt(3) << (iCur*100/iSize) << "%\r" << sio.flush; 349 // sio << "Building dependancies: " << Fmt(3) << (iCur*100/iSize) << "%\r" << sio.flush;
350 (*i)->collapseDeps(); 350 (*i)->collapseDeps();
351 } 351 }
352// sio << sio.nl; 352// sio << sio.nl;
353 353
354 for( TargetHash::iterator i = hTarget.begin(); i; i++ ) 354 for( TargetHash::iterator i = hTarget.begin(); i; i++ )
355 { 355 {
356 if( !(*i)->isExplicit() ) 356 if( !(*i)->isExplicit() )
357 continue; 357 continue;
358 (*i)->setDepCount(); 358 (*i)->setDepCount();
359 (*i)->resetRun( false ); 359 (*i)->resetRun( false );
360 } 360 }
361} 361}
362 362
363void Context::buildTargetTree( class Runner &r, class Target *pTarget, const Bu::String &sInput, Rule *pMaster, StrList &lNewIns ) 363void Context::buildTargetTree( class Runner &r, class Target *pTarget, const Bu::String &sInput, Rule *pMaster, StrList &lNewIns )
364{ 364{
365 Target *pNewTarget = NULL; 365 Target *pNewTarget = NULL;
366 for( RuleHash::iterator i = hRule.begin(); i; i++ ) 366 for( RuleHash::iterator i = hRule.begin(); i; i++ )
367 { 367 {
368 if( (*i)->hasOutputs() && (*i)->ruleMatches( r, sInput ) ) 368 if( (*i)->hasOutputs() && (*i)->ruleMatches( r, sInput ) )
369 { 369 {
370 pNewTarget = (*i)->createTarget( r, sInput, pTarget ); 370 pNewTarget = (*i)->createTarget( r, sInput, pTarget );
371 371
372 Bu::Hash<ptrdiff_t, bool> hDone; 372 Bu::Hash<ptrdiff_t, bool> hDone;
373 for( StrList::const_iterator oi = 373 for( StrList::const_iterator oi =
374 pNewTarget->getOutputList().begin(); oi; oi++ ) 374 pNewTarget->getOutputList().begin(); oi; oi++ )
375 { 375 {
376 try 376 try
377 { 377 {
378 Target *pOver = hTarget.get( *oi ); 378 Target *pOver = hTarget.get( *oi );
379 if( hDone.has( (ptrdiff_t)pOver ) ) 379 if( hDone.has( (ptrdiff_t)pOver ) )
380 continue; 380 continue;
381 hDone.insert( (ptrdiff_t)pOver, true ); 381 hDone.insert( (ptrdiff_t)pOver, true );
382 if( !pOver->isExplicit() ) 382 if( !pOver->isExplicit() )
383 { 383 {
384 delete pNewTarget; 384 delete pNewTarget;
385 pNewTarget = pOver; 385 pNewTarget = pOver;
386 break; 386 break;
387 } 387 }
388 pOver->mergeUnder( pNewTarget ); 388 pOver->mergeUnder( pNewTarget );
389 delete pNewTarget; 389 delete pNewTarget;
390// sio << "Delete: " << Fmt::ptr() << (ptrdiff_t)pNewTarget << sio.nl; 390// sio << "Delete: " << Fmt::ptr() << (ptrdiff_t)pNewTarget << sio.nl;
391 pNewTarget = pOver; 391 pNewTarget = pOver;
392 break; 392 break;
393 } 393 }
394 catch(...) 394 catch(...)
395 { 395 {
396 } 396 }
397 } 397 }
398 398
399 // We actually want to add this either way, if the merge added new 399 // We actually want to add this either way, if the merge added new
400 // outputs, then we need to take them into account. 400 // outputs, then we need to take them into account.
401 addTarget( pNewTarget ); 401 addTarget( pNewTarget );
402 addTargetToTags( pNewTarget, (*i)->getTagList() ); 402 addTargetToTags( pNewTarget, (*i)->getTagList() );
403 403
404 // We have created a new target (or not, either way, we need to 404 // We have created a new target (or not, either way, we need to
405 // check if it matches.) 405 // check if it matches.)
406 for( StrList::const_iterator m = 406 for( StrList::const_iterator m =
407 pNewTarget->getOutputList().begin(); m; m++ ) 407 pNewTarget->getOutputList().begin(); m; m++ )
408 { 408 {
409 // Does the new output match the master rule? 409 // Does the new output match the master rule?
410 if( pMaster->ruleMatches( r, (*m) ) ) 410 if( pMaster->ruleMatches( r, (*m) ) )
411 { 411 {
412 lNewIns.append( (*m) ); 412 lNewIns.append( (*m) );
413 413
414// sio << "What?" << sio.nl; 414// sio << "What?" << sio.nl;
415 // These relationships are difficult to pick up on except 415 // These relationships are difficult to pick up on except
416 // that one target was created by the other, I suppose. 416 // that one target was created by the other, I suppose.
417 // Anyway, that means that we need to add this while we 417 // Anyway, that means that we need to add this while we
418 // can. 418 // can.
419// pTarget->addDep( pNewTarget ); 419// pTarget->addDep( pNewTarget );
420 } 420 }
421 // else 421 // else
422 // { 422 // {
423 buildTargetTree( r, pNewTarget, *m, pMaster, lNewIns ); 423 buildTargetTree( r, pNewTarget, *m, pMaster, lNewIns );
424 // } 424 // }
425 } 425 }
426 426
427 return; 427 return;
428 } 428 }
429 } 429 }
430 if( !pNewTarget ) 430 if( !pNewTarget )
431 { 431 {
432 //sio << "Incomplete tree created, trying to find purpose for \"" 432 //sio << "Incomplete tree created, trying to find purpose for \""
433 // << sInput << "\"." << sio.nl; 433 // << sInput << "\"." << sio.nl;
434 return; 434 return;
435 } 435 }
436} 436}
437 437
438void Context::attachDefaults() 438void Context::attachDefaults()
439{ 439{
440 for( TargetHash::iterator i = hTarget.begin(); i; i++ ) 440 for( TargetHash::iterator i = hTarget.begin(); i; i++ )
441 { 441 {
442 if( !(*i)->hasProfile("clean") ) 442 if( !(*i)->hasProfile("clean") )
443 { 443 {
444 (*i)->addProfile( Profile::genDefaultClean() ); 444 (*i)->addProfile( Profile::genDefaultClean() );
445 } 445 }
446 } 446 }
447} 447}
448 448
449void Context::genDefaultActions() 449void Context::genDefaultActions()
450{ 450{
451 if( !hAction.has("all") ) 451 if( !hAction.has("all") )
452 { 452 {
453 addAction( Action::genDefaultAll() ); 453 addAction( Action::genDefaultAll() );
454 } 454 }
455 if( !hAction.has("clean") ) 455 if( !hAction.has("clean") )
456 { 456 {
457 addAction( Action::genDefaultClean() ); 457 addAction( Action::genDefaultClean() );
458 } 458 }
459 if( !hAction.has("clean-all") ) 459 if( !hAction.has("clean-all") )
460 { 460 {
461 addAction( Action::genDefaultCleanAll() ); 461 addAction( Action::genDefaultCleanAll() );
462 } 462 }
463 if( !hAction.has("default") ) 463 if( !hAction.has("default") )
464 { 464 {
465 addAction( Action::genDefaultDefault() ); 465 addAction( Action::genDefaultDefault() );
466 } 466 }
467} 467}
468 468
469void Context::writeTargetDot() 469void Context::writeTargetDot()
470{ 470{
471 Bu::Hash<ptrdiff_t, bool> hDone; 471 Bu::Hash<ptrdiff_t, bool> hDone;
472 sio << "digraph {" << sio.nl 472 sio << "digraph {" << sio.nl
473 << "\trankdir=LR;" << sio.nl; 473 << "\trankdir=LR;" << sio.nl;
474 for( TargetHash::iterator i = hTarget.begin(); i; i++ ) 474 for( TargetHash::iterator i = hTarget.begin(); i; i++ )
475 { 475 {
476 if( hDone.has( (ptrdiff_t)*i ) ) 476 if( hDone.has( (ptrdiff_t)*i ) )
477 continue; 477 continue;
478 hDone.insert( (ptrdiff_t)*i, true ); 478 hDone.insert( (ptrdiff_t)*i, true );
479 for( StrList::const_iterator l = (*i)->getOutputList().begin(); 479 for( StrList::const_iterator l = (*i)->getOutputList().begin();
480 l; l++ ) 480 l; l++ )
481 { 481 {
482 for( StrList::const_iterator k = (*i)->getInputList().begin(); 482 for( StrList::const_iterator k = (*i)->getInputList().begin();
483 k; k++ ) 483 k; k++ )
484 { 484 {
485 sio << "\t\"" << *k << "\" -> \"" 485 sio << "\t\"" << *k << "\" -> \""
486 << *l << "\";" << sio.nl; 486 << *l << "\";" << sio.nl;
487 } 487 }
488 for( StrList::const_iterator k = (*i)->getRequiresList().begin(); 488 for( StrList::const_iterator k = (*i)->getRequiresList().begin();
489 k; k++ ) 489 k; k++ )
490 { 490 {
491 sio << "\t\"" << *k << "\" -> \"" 491 sio << "\t\"" << *k << "\" -> \""
492 << *l << "\" [color=red];" << sio.nl; 492 << *l << "\" [color=red];" << sio.nl;
493 } 493 }
494 } 494 }
495 495
496 } 496 }
497 sio << "}" << sio.nl; 497 sio << "}" << sio.nl;
498} 498}
499 499
500void Context::setView( View *pNewView ) 500void Context::setView( View *pNewView )
501{ 501{
502 delete pView; 502 delete pView;
503 pView = pNewView; 503 pView = pNewView;
504} 504}
505 505
506View *Context::getView() 506View *Context::getView()
507{ 507{
508 return pView; 508 return pView;
509} 509}
510 510
511Bu::Formatter &operator<<( Bu::Formatter &f, const Context &c ) 511Bu::Formatter &operator<<( Bu::Formatter &f, const Context &c )
512{ 512{
513 f << "Variables: " << c.sVars << f.nl; 513 f << "Variables: " << c.sVars << f.nl;
514 f << "Targets: " << c.hTarget << f.nl; 514 f << "Targets: " << c.hTarget << f.nl;
515 f << "Rules: " << c.hRule << f.nl; 515 f << "Rules: " << c.hRule << f.nl;
516 516
517 return f; 517 return f;
518} 518}
519 519
520void Context::printBasicInfo() 520void Context::printBasicInfo()
521{ 521{
522 sio << "Available actions:" << sio.nl << "\t"; 522 sio << "Available actions:" << sio.nl << "\t";
523 for( ActionHash::iterator i = hAction.begin(); i; i++ ) 523 for( ActionHash::iterator i = hAction.begin(); i; i++ )
524 { 524 {
525 if( i != hAction.begin() ) 525 if( i != hAction.begin() )
526 sio << ", "; 526 sio << ", ";
527 sio << i.getKey(); 527 sio << i.getKey();
528 } 528 }
529 529
530 TargetList lTargets = getExplicitTargets(); 530 TargetList lTargets = getExplicitTargets();
531 sio << sio.nl << sio.nl << "Available targets:" << sio.nl << "\t"; 531 sio << sio.nl << sio.nl << "Available targets:" << sio.nl << "\t";
532 for( TargetList::iterator i = lTargets.begin(); i; i++ ) 532 for( TargetList::iterator i = lTargets.begin(); i; i++ )
533 { 533 {
534 if( i != lTargets.begin() ) 534 if( i != lTargets.begin() )
535 sio << ", "; 535 sio << ", ";
536 for( StrList::const_iterator j = (*i)->getOutputList().begin(); j; j++ ) 536 for( StrList::const_iterator j = (*i)->getOutputList().begin(); j; j++ )
537 { 537 {
538 if( j != (*i)->getOutputList().begin() ) 538 if( j != (*i)->getOutputList().begin() )
539 sio << ", "; 539 sio << ", ";
540 sio << (*j); 540 sio << (*j);
541 } 541 }
542 } 542 }
543 543
544 sio << sio.nl << sio.nl; 544 sio << sio.nl << sio.nl;
545} 545}
546 546
diff --git a/src/context.h b/src/context.h
index 4eaeb25..8dc7527 100644
--- a/src/context.h
+++ b/src/context.h
@@ -14,86 +14,86 @@ class View;
14 14
15class Context 15class Context
16{ 16{
17 friend Bu::Formatter &operator<<( Bu::Formatter &f, const Context &c ); 17 friend Bu::Formatter &operator<<( Bu::Formatter &f, const Context &c );
18public: 18public:
19 Context(); 19 Context();
20 virtual ~Context(); 20 virtual ~Context();
21 21
22 void addTarget( Target *pTarget ); 22 void addTarget( Target *pTarget );
23 void addRule( Rule *pRule ); 23 void addRule( Rule *pRule );
24 void addFunction( Function *pFunction ); 24 void addFunction( Function *pFunction );
25 void addVariable( const Bu::String &sName, const Variable &vValue ); 25 void addVariable( const Bu::String &sName, const Variable &vValue );
26 void addAction( Action *pAction ); 26 void addAction( Action *pAction );
27 Action *getAction( const Bu::String &sName ); 27 Action *getAction( const Bu::String &sName );
28 28
29 void addTargetToTag( Target *pTarget, const Bu::String &sTag ); 29 void addTargetToTag( Target *pTarget, const Bu::String &sTag );
30 void addTargetToTags( Target *pTarget, const StrList &sTags ); 30 void addTargetToTags( Target *pTarget, const StrList &sTags );
31 TargetList &getTag( const Bu::String &sTag ); 31 TargetList &getTag( const Bu::String &sTag );
32 32
33 Variable &getVariable( const Bu::String &sName ); 33 Variable &getVariable( const Bu::String &sName );
34 void delVariable( const Bu::String &sName ); 34 void delVariable( const Bu::String &sName );
35 35
36 void pushScope(); 36 void pushScope();
37 void pushScope( const VarHash &hNewVars ); 37 void pushScope( const VarHash &hNewVars );
38 VarHash &getScope(); 38 VarHash &getScope();
39 void popScope(); 39 void popScope();
40 40
41 Variable call( const Bu::String &sName, Variable &input, VarList lParams ); 41 Variable call( const Bu::String &sName, Variable &input, VarList lParams );
42 42
43 Bu::String expand( const Bu::String &sIn ); 43 Bu::String expand( const Bu::String &sIn );
44 44
45 Target *getTarget( const Bu::String &sOutput ); 45 Target *getTarget( const Bu::String &sOutput );
46 TargetList getExplicitTargets(); 46 TargetList getExplicitTargets();
47 47
48 /** 48 /**
49 * This function actually builds the dependancy tree, and is responsible 49 * This function actually builds the dependancy tree, and is responsible
50 * for creating all of the auto-generated targets that are required by the 50 * for creating all of the auto-generated targets that are required by the
51 * explicitly created targets. 51 * explicitly created targets.
52 */ 52 */
53 void buildTargetTree( class Runner &r ); 53 void buildTargetTree( class Runner &r );
54 54
55 /** 55 /**
56 * This is done as a final step, it goes through all targets and 56 * This is done as a final step, it goes through all targets and
57 * attaches things that they should have even if they haven't defined them, 57 * attaches things that they should have even if they haven't defined them,
58 * like a clean profile, they'll get that even if they haven't added one of 58 * like a clean profile, they'll get that even if they haven't added one of
59 * their own. The defaults in this routine are added only if they aren't 59 * their own. The defaults in this routine are added only if they aren't
60 * already defined in the target. It should be excetued after 60 * already defined in the target. It should be excetued after
61 * buildTargetTree, which means it doesn't need to affect rules. 61 * buildTargetTree, which means it doesn't need to affect rules.
62 */ 62 */
63 void attachDefaults(); 63 void attachDefaults();
64 64
65 /** 65 /**
66 * This function generates some default actions if they don't already 66 * This function generates some default actions if they don't already
67 * exist, pretty straight forward, it will create all, clean, and default 67 * exist, pretty straight forward, it will create all, clean, and default
68 * (default is the same as all). 68 * (default is the same as all).
69 */ 69 */
70 void genDefaultActions(); 70 void genDefaultActions();
71 71
72 void writeTargetDot(); 72 void writeTargetDot();
73 73
74 void setView( View *pNewView ); 74 void setView( View *pNewView );
75 View *getView(); 75 View *getView();
76 76
77 void printBasicInfo(); 77 void printBasicInfo();
78 78
79private: 79private:
80 void buildTargetTree( class Runner &r, class Target *pTarget, const Bu::String &sInput, class Rule *pMaster, StrList &lNewIns ); 80 void buildTargetTree( class Runner &r, class Target *pTarget, const Bu::String &sInput, class Rule *pMaster, StrList &lNewIns );
81 81
82private: 82private:
83 typedef Bu::Hash<Bu::String, Target *> TargetHash; 83 typedef Bu::Hash<Bu::String, Target *> TargetHash;
84 typedef Bu::Hash<Bu::String, Rule *> RuleHash; 84 typedef Bu::Hash<Bu::String, Rule *> RuleHash;
85 typedef Bu::Hash<Bu::String, Function *> FunctionHash; 85 typedef Bu::Hash<Bu::String, Function *> FunctionHash;
86 typedef Bu::Hash<Bu::String, Action *> ActionHash; 86 typedef Bu::Hash<Bu::String, Action *> ActionHash;
87 typedef Bu::List<VarHash> ScopeStack; 87 typedef Bu::List<VarHash> ScopeStack;
88 typedef Bu::Hash<Bu::String, TargetList> TagHash; 88 typedef Bu::Hash<Bu::String, TargetList> TagHash;
89 89
90 TargetHash hTarget; 90 TargetHash hTarget;
91 RuleHash hRule; 91 RuleHash hRule;
92 FunctionHash hFunction; 92 FunctionHash hFunction;
93 ScopeStack sVars; 93 ScopeStack sVars;
94 ActionHash hAction; 94 ActionHash hAction;
95 TagHash hTag; 95 TagHash hTag;
96 View *pView; 96 View *pView;
97}; 97};
98 98
99Bu::Formatter &operator<<( Bu::Formatter &f, const Context &c ); 99Bu::Formatter &operator<<( Bu::Formatter &f, const Context &c );
diff --git a/src/filemgr.cpp b/src/filemgr.cpp
index 00f0410..16f2ba7 100644
--- a/src/filemgr.cpp
+++ b/src/filemgr.cpp
@@ -1,46 +1,46 @@
1#include "filemgr.h" 1#include "filemgr.h"
2 2
3FileMgr::FileMgr() : 3FileMgr::FileMgr() :
4 iNextId( 1 ) 4 iNextId( 1 )
5{ 5{
6} 6}
7 7
8FileMgr::~FileMgr() 8FileMgr::~FileMgr()
9{ 9{
10 for( FileHash::iterator i = hFile.begin(); i; i++ ) 10 for( FileHash::iterator i = hFile.begin(); i; i++ )
11 { 11 {
12 delete *i; 12 delete *i;
13 } 13 }
14} 14}
15 15
16int FileMgr::open( const Bu::String &sPath, int iMode ) 16int FileMgr::open( const Bu::String &sPath, int iMode )
17{ 17{
18 hFile.insert( iNextId, new Bu::File( sPath, iMode ) ); 18 hFile.insert( iNextId, new Bu::File( sPath, iMode ) );
19 return iNextId++; 19 return iNextId++;
20} 20}
21 21
22Bu::File &FileMgr::get( int iId ) 22Bu::File &FileMgr::get( int iId )
23{ 23{
24 try 24 try
25 { 25 {
26 return *hFile.get( iId ); 26 return *hFile.get( iId );
27 } 27 }
28 catch(...) 28 catch(...)
29 { 29 {
30 throw Bu::ExceptionBase("Invalid file handle accessed."); 30 throw Bu::ExceptionBase("Invalid file handle accessed.");
31 } 31 }
32} 32}
33 33
34void FileMgr::close( int iId ) 34void FileMgr::close( int iId )
35{ 35{
36 try 36 try
37 { 37 {
38 delete hFile.get( iId ); 38 delete hFile.get( iId );
39 hFile.erase( iId ); 39 hFile.erase( iId );
40 } 40 }
41 catch(...) 41 catch(...)
42 { 42 {
43 throw Bu::ExceptionBase("Invalid file handle accessed."); 43 throw Bu::ExceptionBase("Invalid file handle accessed.");
44 } 44 }
45} 45}
46 46
diff --git a/src/filemgr.h b/src/filemgr.h
index 517e784..5241eee 100644
--- a/src/filemgr.h
+++ b/src/filemgr.h
@@ -9,18 +9,18 @@ class FileMgr : public Bu::Singleton<FileMgr>
9{ 9{
10friend class Bu::Singleton<FileMgr>; 10friend class Bu::Singleton<FileMgr>;
11private: 11private:
12 FileMgr(); 12 FileMgr();
13 virtual ~FileMgr(); 13 virtual ~FileMgr();
14 14
15public: 15public:
16 int open( const Bu::String &sPath, int iMode ); 16 int open( const Bu::String &sPath, int iMode );
17 Bu::File &get( int iId ); 17 Bu::File &get( int iId );
18 void close( int iId ); 18 void close( int iId );
19 19
20private: 20private:
21 typedef Bu::Hash<int, Bu::File *> FileHash; 21 typedef Bu::Hash<int, Bu::File *> FileHash;
22 FileHash hFile; 22 FileHash hFile;
23 int iNextId; 23 int iNextId;
24}; 24};
25 25
26#endif 26#endif
diff --git a/src/function.cpp b/src/function.cpp
index f73f576..c4bf966 100644
--- a/src/function.cpp
+++ b/src/function.cpp
@@ -1,7 +1,7 @@
1#include "function.h" 1#include "function.h"
2 2
3Function::Function() : 3Function::Function() :
4 pContext( NULL ) 4 pContext( NULL )
5{ 5{
6} 6}
7 7
@@ -11,6 +11,6 @@ Function::~Function()
11 11
12void Function::setContext( class Context *p ) 12void Function::setContext( class Context *p )
13{ 13{
14 pContext = p; 14 pContext = p;
15} 15}
16 16
diff --git a/src/function.h b/src/function.h
index 1575bfd..71d87ba 100644
--- a/src/function.h
+++ b/src/function.h
@@ -7,17 +7,17 @@
7class Function 7class Function
8{ 8{
9public: 9public:
10 Function(); 10 Function();
11 virtual ~Function(); 11 virtual ~Function();
12 12
13 virtual Bu::String getName() const=0; 13 virtual Bu::String getName() const=0;
14 14
15 virtual Variable call( Variable &input, VarList lParams )=0; 15 virtual Variable call( Variable &input, VarList lParams )=0;
16 16
17 void setContext( class Context *p ); 17 void setContext( class Context *p );
18 18
19protected: 19protected:
20 class Context *pContext; 20 class Context *pContext;
21}; 21};
22 22
23#endif 23#endif
diff --git a/src/functionast.cpp b/src/functionast.cpp
index d4ec61f..437ddd4 100644
--- a/src/functionast.cpp
+++ b/src/functionast.cpp
@@ -8,12 +8,12 @@
8using namespace Bu; 8using namespace Bu;
9 9
10FunctionAst::FunctionAst( const AstBranch *pRoot, class Runner *pRunner ) : 10FunctionAst::FunctionAst( const AstBranch *pRoot, class Runner *pRunner ) :
11 pRoot( pRoot ), 11 pRoot( pRoot ),
12 pRunner( pRunner ) 12 pRunner( pRunner )
13{ 13{
14 sName = dynamic_cast<AstLeaf *>( 14 sName = dynamic_cast<AstLeaf *>(
15 *(*pRoot->getBranchBegin()).begin() 15 *(*pRoot->getBranchBegin()).begin()
16 )->getStrValue(); 16 )->getStrValue();
17} 17}
18 18
19FunctionAst::~FunctionAst() 19FunctionAst::~FunctionAst()
@@ -22,26 +22,26 @@ FunctionAst::~FunctionAst()
22 22
23Bu::String FunctionAst::getName() const 23Bu::String FunctionAst::getName() const
24{ 24{
25 return sName; 25 return sName;
26} 26}
27 27
28Variable FunctionAst::call( Variable &input, VarList lParams ) 28Variable FunctionAst::call( Variable &input, VarList lParams )
29{ 29{
30 pContext->pushScope(); 30 pContext->pushScope();
31 31
32 AstBranch::NodeList::const_iterator vName = 32 AstBranch::NodeList::const_iterator vName =
33 (*(pRoot->getBranchBegin()+1)).begin(); 33 (*(pRoot->getBranchBegin()+1)).begin();
34 VarList::iterator vValue = lParams.begin(); 34 VarList::iterator vValue = lParams.begin();
35 for( ; vName && vValue; vName++, vValue++ ) 35 for( ; vName && vValue; vName++, vValue++ )
36 { 36 {
37 pContext->addVariable( 37 pContext->addVariable(
38 dynamic_cast<const AstLeaf *>(*vName)->getStrValue(), 38 dynamic_cast<const AstLeaf *>(*vName)->getStrValue(),
39 *vValue 39 *vValue
40 ); 40 );
41 } 41 }
42 pContext->addVariable("INPUT", input ); 42 pContext->addVariable("INPUT", input );
43 Variable vRet = pRunner->run( (*(pRoot->getBranchBegin()+2)).begin() ); 43 Variable vRet = pRunner->run( (*(pRoot->getBranchBegin()+2)).begin() );
44 pContext->popScope(); 44 pContext->popScope();
45 return vRet; 45 return vRet;
46} 46}
47 47
diff --git a/src/functionast.h b/src/functionast.h
index 0de564f..75af751 100644
--- a/src/functionast.h
+++ b/src/functionast.h
@@ -6,16 +6,16 @@
6class FunctionAst : public Function 6class FunctionAst : public Function
7{ 7{
8public: 8public:
9 FunctionAst( const class AstBranch *pRoot, class Runner *pRunner ); 9 FunctionAst( const class AstBranch *pRoot, class Runner *pRunner );
10 virtual ~FunctionAst(); 10 virtual ~FunctionAst();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14 14
15private: 15private:
16 Bu::String sName; 16 Bu::String sName;
17 const class AstBranch *pRoot; 17 const class AstBranch *pRoot;
18 class Runner *pRunner; 18 class Runner *pRunner;
19}; 19};
20 20
21#endif 21#endif
diff --git a/src/functionclose.cpp b/src/functionclose.cpp
index d652913..173e224 100644
--- a/src/functionclose.cpp
+++ b/src/functionclose.cpp
@@ -3,7 +3,7 @@
3 3
4#include <bu/plugger.h> 4#include <bu/plugger.h>
5PluginInterface3( pluginFunctionClose, close, FunctionClose, Function, 5PluginInterface3( pluginFunctionClose, close, FunctionClose, Function,
6 "Mike Buland", 0, 1 ); 6 "Mike Buland", 0, 1 );
7 7
8FunctionClose::FunctionClose() 8FunctionClose::FunctionClose()
9{ 9{
@@ -15,12 +15,12 @@ FunctionClose::~FunctionClose()
15 15
16Bu::String FunctionClose::getName() const 16Bu::String FunctionClose::getName() const
17{ 17{
18 return "close"; 18 return "close";
19} 19}
20 20
21Variable FunctionClose::call( Variable &input, VarList ) 21Variable FunctionClose::call( Variable &input, VarList )
22{ 22{
23 FileMgr::getInstance().close( (ptrdiff_t)input.getOpaque() ); 23 FileMgr::getInstance().close( (ptrdiff_t)input.getOpaque() );
24 return Variable(); 24 return Variable();
25} 25}
26 26
diff --git a/src/functionclose.h b/src/functionclose.h
index 0a30427..225dca0 100644
--- a/src/functionclose.h
+++ b/src/functionclose.h
@@ -6,11 +6,11 @@
6class FunctionClose : public Function 6class FunctionClose : public Function
7{ 7{
8public: 8public:
9 FunctionClose(); 9 FunctionClose();
10 virtual ~FunctionClose(); 10 virtual ~FunctionClose();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14 14
15}; 15};
16 16
diff --git a/src/functiondirname.cpp b/src/functiondirname.cpp
index 7fc3bf2..c33771e 100644
--- a/src/functiondirname.cpp
+++ b/src/functiondirname.cpp
@@ -2,7 +2,7 @@
2 2
3#include <bu/plugger.h> 3#include <bu/plugger.h>
4PluginInterface3( pluginFunctionDirName, dirName, FunctionDirName, Function, 4PluginInterface3( pluginFunctionDirName, dirName, FunctionDirName, Function,
5 "Mike Buland", 0, 1 ); 5 "Mike Buland", 0, 1 );
6 6
7FunctionDirName::FunctionDirName() 7FunctionDirName::FunctionDirName()
8{ 8{
@@ -14,29 +14,29 @@ FunctionDirName::~FunctionDirName()
14 14
15Bu::String FunctionDirName::getName() const 15Bu::String FunctionDirName::getName() const
16{ 16{
17 return "dirName"; 17 return "dirName";
18} 18}
19 19
20Variable FunctionDirName::call( Variable &input, VarList /*lParams*/ ) 20Variable FunctionDirName::call( Variable &input, VarList /*lParams*/ )
21{ 21{
22 Bu::String sFile; 22 Bu::String sFile;
23 sFile = input.getString(); 23 sFile = input.getString();
24 24
25 Bu::String::const_iterator i = sFile.begin(); 25 Bu::String::const_iterator i = sFile.begin();
26 Bu::String::const_iterator io; 26 Bu::String::const_iterator io;
27 for(;;) 27 for(;;)
28 { 28 {
29 Bu::String::const_iterator b = i.find('/'); 29 Bu::String::const_iterator b = i.find('/');
30 if( !b ) 30 if( !b )
31 { 31 {
32 return Variable( Bu::String( sFile.begin(), io ) ); 32 return Variable( Bu::String( sFile.begin(), io ) );
33 } 33 }
34 io = b; 34 io = b;
35 i = b+1; 35 i = b+1;
36 if( !i ) 36 if( !i )
37 { 37 {
38 return Variable( Bu::String( sFile.begin(), io ) ); 38 return Variable( Bu::String( sFile.begin(), io ) );
39 } 39 }
40 } 40 }
41} 41}
42 42
diff --git a/src/functiondirname.h b/src/functiondirname.h
index 45a943e..763e243 100644
--- a/src/functiondirname.h
+++ b/src/functiondirname.h
@@ -6,11 +6,11 @@
6class FunctionDirName : public Function 6class FunctionDirName : public Function
7{ 7{
8public: 8public:
9 FunctionDirName(); 9 FunctionDirName();
10 virtual ~FunctionDirName(); 10 virtual ~FunctionDirName();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14 14
15}; 15};
16 16
diff --git a/src/functiondirs.cpp b/src/functiondirs.cpp
index e3b88dd..8ed0442 100644
--- a/src/functiondirs.cpp
+++ b/src/functiondirs.cpp
@@ -7,7 +7,7 @@
7 7
8#include <bu/plugger.h> 8#include <bu/plugger.h>
9PluginInterface3( pluginFunctionDirs, dirs, FunctionDirs, Function, 9PluginInterface3( pluginFunctionDirs, dirs, FunctionDirs, Function,
10 "Mike Buland", 0, 1 ); 10 "Mike Buland", 0, 1 );
11 11
12FunctionDirs::FunctionDirs() 12FunctionDirs::FunctionDirs()
13{ 13{
@@ -19,47 +19,47 @@ FunctionDirs::~FunctionDirs()
19 19
20Bu::String FunctionDirs::getName() const 20Bu::String FunctionDirs::getName() const
21{ 21{
22 return "dirs"; 22 return "dirs";
23} 23}
24 24
25Variable FunctionDirs::call( Variable &/*input*/, VarList lParams ) 25Variable FunctionDirs::call( Variable &/*input*/, VarList lParams )
26{ 26{
27 glob_t globbuf; 27 glob_t globbuf;
28 28
29 int flags = 0; 29 int flags = 0;
30 30
31 for( VarList::const_iterator i = lParams.begin(); i; i++ ) 31 for( VarList::const_iterator i = lParams.begin(); i; i++ )
32 { 32 {
33 switch( (*i).getType() ) 33 switch( (*i).getType() )
34 { 34 {
35 case Variable::typeString: 35 case Variable::typeString:
36 glob( (*i).getString().getStr(), flags, NULL, &globbuf ); 36 glob( (*i).getString().getStr(), flags, NULL, &globbuf );
37 flags |= GLOB_APPEND; 37 flags |= GLOB_APPEND;
38 break; 38 break;
39 39
40 case Variable::typeList: 40 case Variable::typeList:
41 throw Bu::ExceptionBase("Lists not supported in glob yet."); 41 throw Bu::ExceptionBase("Lists not supported in glob yet.");
42 break; 42 break;
43 43
44 default: 44 default:
45 throw Bu::ExceptionBase( 45 throw Bu::ExceptionBase(
46 "Cannot use a non-string or non-list as a parameter to glob" 46 "Cannot use a non-string or non-list as a parameter to glob"
47 ); 47 );
48 break; 48 break;
49 } 49 }
50 } 50 }
51 51
52 Variable vRet( Variable::typeList ); 52 Variable vRet( Variable::typeList );
53 struct stat s; 53 struct stat s;
54 for( size_t j = 0; j < globbuf.gl_pathc; j++ ) 54 for( size_t j = 0; j < globbuf.gl_pathc; j++ )
55 { 55 {
56 stat( globbuf.gl_pathv[j], &s ); 56 stat( globbuf.gl_pathv[j], &s );
57 if( S_ISDIR( s.st_mode ) ) 57 if( S_ISDIR( s.st_mode ) )
58 vRet.append( globbuf.gl_pathv[j] ); 58 vRet.append( globbuf.gl_pathv[j] );
59 } 59 }
60 60
61 globfree( &globbuf ); 61 globfree( &globbuf );
62 62
63 return vRet; 63 return vRet;
64} 64}
65 65
diff --git a/src/functiondirs.h b/src/functiondirs.h
index 899c1ac..60522dc 100644
--- a/src/functiondirs.h
+++ b/src/functiondirs.h
@@ -6,11 +6,11 @@
6class FunctionDirs : public Function 6class FunctionDirs : public Function
7{ 7{
8public: 8public:
9 FunctionDirs(); 9 FunctionDirs();
10 virtual ~FunctionDirs(); 10 virtual ~FunctionDirs();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14 14
15}; 15};
16 16
diff --git a/src/functionexecute.cpp b/src/functionexecute.cpp
index 070ca53..cad65fa 100644
--- a/src/functionexecute.cpp
+++ b/src/functionexecute.cpp
@@ -8,7 +8,7 @@ using namespace Bu;
8 8
9#include <bu/plugger.h> 9#include <bu/plugger.h>
10PluginInterface3( pluginFunctionExecute, execute, FunctionExecute, Function, 10PluginInterface3( pluginFunctionExecute, execute, FunctionExecute, Function,
11 "Mike Buland", 0, 1 ); 11 "Mike Buland", 0, 1 );
12 12
13FunctionExecute::FunctionExecute() 13FunctionExecute::FunctionExecute()
14{ 14{
@@ -20,54 +20,54 @@ FunctionExecute::~FunctionExecute()
20 20
21Bu::String FunctionExecute::getName() const 21Bu::String FunctionExecute::getName() const
22{ 22{
23 return "execute"; 23 return "execute";
24} 24}
25 25
26Variable FunctionExecute::call( Variable &/*input*/, VarList lParams ) 26Variable FunctionExecute::call( Variable &/*input*/, VarList lParams )
27{ 27{
28 // TODO This is lame, really lame, we need to exec on our own and process 28 // TODO This is lame, really lame, we need to exec on our own and process
29 // output appropriately. 29 // output appropriately.
30 pContext->getView()->cmdStarted( lParams.first().getString() ); 30 pContext->getView()->cmdStarted( lParams.first().getString() );
31 Process pCmd( Process::Both, "/bin/bash", "/bin/bash", "-c", 31 Process pCmd( Process::Both, "/bin/bash", "/bin/bash", "-c",
32 lParams.first().getString().getStr(), NULL ); 32 lParams.first().getString().getStr(), NULL );
33 String sStdOut, sStdErr; 33 String sStdOut, sStdErr;
34 do 34 do
35 { 35 {
36 char buf[4096]; 36 char buf[4096];
37 bool out, err; 37 bool out, err;
38 pCmd.select( out, err ); 38 pCmd.select( out, err );
39 if( err ) 39 if( err )
40 { 40 {
41 int iRead = pCmd.readErr( buf, 4096 ); 41 int iRead = pCmd.readErr( buf, 4096 );
42 sStdErr.append( buf, iRead ); 42 sStdErr.append( buf, iRead );
43 //sio << "Read " << iRead << " bytes of stderr." << sio.nl; 43 //sio << "Read " << iRead << " bytes of stderr." << sio.nl;
44 } 44 }
45 if( out ) 45 if( out )
46 { 46 {
47 int iRead = pCmd.read( buf, 4096 ); 47 int iRead = pCmd.read( buf, 4096 );
48 sStdOut.append( buf, iRead ); 48 sStdOut.append( buf, iRead );
49 //sio << "Read " << iRead << " bytes of stdout." << sio.nl; 49 //sio << "Read " << iRead << " bytes of stdout." << sio.nl;
50 } 50 }
51 } 51 }
52 while( pCmd.isRunning() ); 52 while( pCmd.isRunning() );
53 53
54 pContext->getView()->cmdFinished( 54 pContext->getView()->cmdFinished(
55 sStdOut, sStdErr, pCmd.childExitStatus() 55 sStdOut, sStdErr, pCmd.childExitStatus()
56 ); 56 );
57 if( pCmd.childExited() ) 57 if( pCmd.childExited() )
58 { 58 {
59 if( pCmd.childExitStatus() != 0 ) 59 if( pCmd.childExitStatus() != 0 )
60 { 60 {
61 throw Bu::ExceptionBase("Command exited with errorcode %d.", pCmd.childExitStatus() ); 61 throw Bu::ExceptionBase("Command exited with errorcode %d.", pCmd.childExitStatus() );
62 } 62 }
63 } 63 }
64 else 64 else
65 { 65 {
66 pContext->getView()->cmdFinished( 66 pContext->getView()->cmdFinished(
67 sStdOut, sStdErr, pCmd.childExitStatus() 67 sStdOut, sStdErr, pCmd.childExitStatus()
68 ); 68 );
69 throw Bu::ExceptionBase("Command Failed"); 69 throw Bu::ExceptionBase("Command Failed");
70 } 70 }
71 return Variable( pCmd.childExitStatus() ); 71 return Variable( pCmd.childExitStatus() );
72} 72}
73 73
diff --git a/src/functionexecute.h b/src/functionexecute.h
index b70a2c5..3066440 100644
--- a/src/functionexecute.h
+++ b/src/functionexecute.h
@@ -6,11 +6,11 @@
6class FunctionExecute : public Function 6class FunctionExecute : public Function
7{ 7{
8public: 8public:
9 FunctionExecute(); 9 FunctionExecute();
10 virtual ~FunctionExecute(); 10 virtual ~FunctionExecute();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14}; 14};
15 15
16#endif 16#endif
diff --git a/src/functionexists.cpp b/src/functionexists.cpp
index 5c71874..0fad1e1 100644
--- a/src/functionexists.cpp
+++ b/src/functionexists.cpp
@@ -4,7 +4,7 @@
4 4
5#include <bu/plugger.h> 5#include <bu/plugger.h>
6PluginInterface3( pluginFunctionExists, exists, FunctionExists, Function, 6PluginInterface3( pluginFunctionExists, exists, FunctionExists, Function,
7 "Mike Buland", 0, 1 ); 7 "Mike Buland", 0, 1 );
8 8
9FunctionExists::FunctionExists() 9FunctionExists::FunctionExists()
10{ 10{
@@ -16,23 +16,23 @@ FunctionExists::~FunctionExists()
16 16
17Bu::String FunctionExists::getName() const 17Bu::String FunctionExists::getName() const
18{ 18{
19 return "exists"; 19 return "exists";
20} 20}
21 21
22Variable FunctionExists::call( Variable &input, VarList lParams ) 22Variable FunctionExists::call( Variable &input, VarList lParams )
23{ 23{
24 Bu::String sFile; 24 Bu::String sFile;
25 if( input.getType() != Variable::typeNone ) 25 if( input.getType() != Variable::typeNone )
26 { 26 {
27 sFile = input.toString(); 27 sFile = input.toString();
28 } 28 }
29 else 29 else
30 { 30 {
31 sFile = lParams.first().toString(); 31 sFile = lParams.first().toString();
32 } 32 }
33 if( access( sFile.getStr(), F_OK ) == 0 ) 33 if( access( sFile.getStr(), F_OK ) == 0 )
34 return Variable( true ); 34 return Variable( true );
35 else 35 else
36 return Variable( false ); 36 return Variable( false );
37} 37}
38 38
diff --git a/src/functionexists.h b/src/functionexists.h
index f4629fb..e2e7688 100644
--- a/src/functionexists.h
+++ b/src/functionexists.h
@@ -6,11 +6,11 @@
6class FunctionExists : public Function 6class FunctionExists : public Function
7{ 7{
8public: 8public:
9 FunctionExists(); 9 FunctionExists();
10 virtual ~FunctionExists(); 10 virtual ~FunctionExists();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14 14
15}; 15};
16 16
diff --git a/src/functionfilename.cpp b/src/functionfilename.cpp
index 40f0048..36cb61c 100644
--- a/src/functionfilename.cpp
+++ b/src/functionfilename.cpp
@@ -2,7 +2,7 @@
2 2
3#include <bu/plugger.h> 3#include <bu/plugger.h>
4PluginInterface3( pluginFunctionFileName, fileName, FunctionFileName, Function, 4PluginInterface3( pluginFunctionFileName, fileName, FunctionFileName, Function,
5 "Mike Buland", 0, 1 ); 5 "Mike Buland", 0, 1 );
6 6
7FunctionFileName::FunctionFileName() 7FunctionFileName::FunctionFileName()
8{ 8{
@@ -14,27 +14,27 @@ FunctionFileName::~FunctionFileName()
14 14
15Bu::String FunctionFileName::getName() const 15Bu::String FunctionFileName::getName() const
16{ 16{
17 return "fileName"; 17 return "fileName";
18} 18}
19 19
20Variable FunctionFileName::call( Variable &input, VarList /*lParams*/ ) 20Variable FunctionFileName::call( Variable &input, VarList /*lParams*/ )
21{ 21{
22 Bu::String sFile; 22 Bu::String sFile;
23 sFile = input.getString(); 23 sFile = input.getString();
24 24
25 Bu::String::const_iterator i = sFile.begin(); 25 Bu::String::const_iterator i = sFile.begin();
26 for(;;) 26 for(;;)
27 { 27 {
28 Bu::String::const_iterator b = i.find('/'); 28 Bu::String::const_iterator b = i.find('/');
29 if( !b ) 29 if( !b )
30 { 30 {
31 return Variable( Bu::String( i ) ); 31 return Variable( Bu::String( i ) );
32 } 32 }
33 i = b+1; 33 i = b+1;
34 if( !i ) 34 if( !i )
35 { 35 {
36 return Variable( Bu::String( i ) ); 36 return Variable( Bu::String( i ) );
37 } 37 }
38 } 38 }
39} 39}
40 40
diff --git a/src/functionfilename.h b/src/functionfilename.h
index 8f1cd13..2bead88 100644
--- a/src/functionfilename.h
+++ b/src/functionfilename.h
@@ -6,11 +6,11 @@
6class FunctionFileName : public Function 6class FunctionFileName : public Function
7{ 7{
8public: 8public:
9 FunctionFileName(); 9 FunctionFileName();
10 virtual ~FunctionFileName(); 10 virtual ~FunctionFileName();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14 14
15}; 15};
16 16
diff --git a/src/functionfiles.cpp b/src/functionfiles.cpp
index cd5b122..051ee3a 100644
--- a/src/functionfiles.cpp
+++ b/src/functionfiles.cpp
@@ -7,7 +7,7 @@
7 7
8#include <bu/plugger.h> 8#include <bu/plugger.h>
9PluginInterface3( pluginFunctionFiles, files, FunctionFiles, Function, 9PluginInterface3( pluginFunctionFiles, files, FunctionFiles, Function,
10 "Mike Buland", 0, 1 ); 10 "Mike Buland", 0, 1 );
11 11
12FunctionFiles::FunctionFiles() 12FunctionFiles::FunctionFiles()
13{ 13{
@@ -19,47 +19,47 @@ FunctionFiles::~FunctionFiles()
19 19
20Bu::String FunctionFiles::getName() const 20Bu::String FunctionFiles::getName() const
21{ 21{
22 return "files"; 22 return "files";
23} 23}
24 24
25Variable FunctionFiles::call( Variable &/*input*/, VarList lParams ) 25Variable FunctionFiles::call( Variable &/*input*/, VarList lParams )
26{ 26{
27 glob_t globbuf; 27 glob_t globbuf;
28 28
29 int flags = 0; 29 int flags = 0;
30 30
31 for( VarList::const_iterator i = lParams.begin(); i; i++ ) 31 for( VarList::const_iterator i = lParams.begin(); i; i++ )
32 { 32 {
33 switch( (*i).getType() ) 33 switch( (*i).getType() )
34 { 34 {
35 case Variable::typeString: 35 case Variable::typeString:
36 glob( (*i).getString().getStr(), flags, NULL, &globbuf ); 36 glob( (*i).getString().getStr(), flags, NULL, &globbuf );
37 flags |= GLOB_APPEND; 37 flags |= GLOB_APPEND;
38 break; 38 break;
39 39
40 case Variable::typeList: 40 case Variable::typeList:
41 throw Bu::ExceptionBase("Lists not supported in glob yet."); 41 throw Bu::ExceptionBase("Lists not supported in glob yet.");
42 break; 42 break;
43 43
44 default: 44 default:
45 throw Bu::ExceptionBase( 45 throw Bu::ExceptionBase(
46 "Cannot use a non-string or non-list as a parameter to glob" 46 "Cannot use a non-string or non-list as a parameter to glob"
47 ); 47 );
48 break; 48 break;
49 } 49 }
50 } 50 }
51 51
52 Variable vRet( Variable::typeList ); 52 Variable vRet( Variable::typeList );
53 struct stat s; 53 struct stat s;
54 for( size_t j = 0; j < globbuf.gl_pathc; j++ ) 54 for( size_t j = 0; j < globbuf.gl_pathc; j++ )
55 { 55 {
56 stat( globbuf.gl_pathv[j], &s ); 56 stat( globbuf.gl_pathv[j], &s );
57 if( S_ISREG( s.st_mode ) ) 57 if( S_ISREG( s.st_mode ) )
58 vRet.append( globbuf.gl_pathv[j] ); 58 vRet.append( globbuf.gl_pathv[j] );
59 } 59 }
60 60
61 globfree( &globbuf ); 61 globfree( &globbuf );
62 62
63 return vRet; 63 return vRet;
64} 64}
65 65
diff --git a/src/functionfiles.h b/src/functionfiles.h
index 3828c3e..af04132 100644
--- a/src/functionfiles.h
+++ b/src/functionfiles.h
@@ -6,11 +6,11 @@
6class FunctionFiles : public Function 6class FunctionFiles : public Function
7{ 7{
8public: 8public:
9 FunctionFiles(); 9 FunctionFiles();
10 virtual ~FunctionFiles(); 10 virtual ~FunctionFiles();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14 14
15}; 15};
16 16
diff --git a/src/functiongetmakedeps.cpp b/src/functiongetmakedeps.cpp
index fda6aa2..22cf4aa 100644
--- a/src/functiongetmakedeps.cpp
+++ b/src/functiongetmakedeps.cpp
@@ -8,7 +8,7 @@ using namespace Bu;
8 8
9#include <bu/plugger.h> 9#include <bu/plugger.h>
10PluginInterface3( pluginFunctionGetMakeDeps, getMakeDeps, FunctionGetMakeDeps, 10PluginInterface3( pluginFunctionGetMakeDeps, getMakeDeps, FunctionGetMakeDeps,
11 Function, "Mike Buland", 0, 1 ); 11 Function, "Mike Buland", 0, 1 );
12 12
13FunctionGetMakeDeps::FunctionGetMakeDeps() 13FunctionGetMakeDeps::FunctionGetMakeDeps()
14{ 14{
@@ -20,50 +20,50 @@ FunctionGetMakeDeps::~FunctionGetMakeDeps()
20 20
21Bu::String FunctionGetMakeDeps::getName() const 21Bu::String FunctionGetMakeDeps::getName() const
22{ 22{
23 return "getMakeDeps"; 23 return "getMakeDeps";
24} 24}
25 25
26Variable FunctionGetMakeDeps::call( Variable &/*input*/, VarList lParams ) 26Variable FunctionGetMakeDeps::call( Variable &/*input*/, VarList lParams )
27{ 27{
28 pContext->getView()->cmdStarted( lParams.first().getString().getStr() ); 28 pContext->getView()->cmdStarted( lParams.first().getString().getStr() );
29 Process p( Process::StdOut, "/bin/bash", "/bin/bash", "-c", 29 Process p( Process::StdOut, "/bin/bash", "/bin/bash", "-c",
30 lParams.first().getString().getStr(), NULL ); 30 lParams.first().getString().getStr(), NULL );
31 31
32 // Gather all data from the command. 32 // Gather all data from the command.
33 Bu::String sBuf; 33 Bu::String sBuf;
34 do 34 do
35 { 35 {
36 char buf[4096]; 36 char buf[4096];
37 int iRead = p.read( buf, 4096 ); 37 int iRead = p.read( buf, 4096 );
38 sBuf.append( buf, iRead ); 38 sBuf.append( buf, iRead );
39 } 39 }
40 while( !p.isEos() ); 40 while( !p.isEos() );
41 41
42 pContext->getView()->cmdFinished( "", "", p.childExitStatus() ); 42 pContext->getView()->cmdFinished( "", "", p.childExitStatus() );
43 43
44 Variable vRet( Variable::typeList ); 44 Variable vRet( Variable::typeList );
45 45
46 Bu::String::iterator i, j; 46 Bu::String::iterator i, j;
47 i = sBuf.find(':')+2; 47 i = sBuf.find(':')+2;
48 while( i ) 48 while( i )
49 { 49 {
50 // Find whitespace at the end of the word, this one is easy, there's 50 // Find whitespace at the end of the word, this one is easy, there's
51 // always a space after a word 51 // always a space after a word
52 for( j = i; j && *j != ' ' && *j != '\n' && *j != '\r'; j++ ) { } 52 for( j = i; j && *j != ' ' && *j != '\n' && *j != '\r'; j++ ) { }
53 53
54 Bu::String sTmp( i, j ); 54 Bu::String sTmp( i, j );
55 vRet.append( sTmp ); 55 vRet.append( sTmp );
56 56
57 // Find the begining of the next word, trickier, we don't want to go 57 // Find the begining of the next word, trickier, we don't want to go
58 // off the end, and we need to skip \ chars at the ends of lines, right 58 // off the end, and we need to skip \ chars at the ends of lines, right
59 // now this is too stupid to do that, so it may not work on windows. 59 // now this is too stupid to do that, so it may not work on windows.
60 // TODO: perhaps make this only skip \ chars at the ends of lines, 60 // TODO: perhaps make this only skip \ chars at the ends of lines,
61 // we'll see if it matters. 61 // we'll see if it matters.
62 for( i = j+1; 62 for( i = j+1;
63 i && (*i == ' ' || *i == '\\' || *i == '\n' || *i == '\r'); i++ ) 63 i && (*i == ' ' || *i == '\\' || *i == '\n' || *i == '\r'); i++ )
64 { } 64 { }
65 } 65 }
66 66
67 return vRet; 67 return vRet;
68} 68}
69 69
diff --git a/src/functiongetmakedeps.h b/src/functiongetmakedeps.h
index 566a96b..caa0952 100644
--- a/src/functiongetmakedeps.h
+++ b/src/functiongetmakedeps.h
@@ -6,11 +6,11 @@
6class FunctionGetMakeDeps : public Function 6class FunctionGetMakeDeps : public Function
7{ 7{
8public: 8public:
9 FunctionGetMakeDeps(); 9 FunctionGetMakeDeps();
10 virtual ~FunctionGetMakeDeps(); 10 virtual ~FunctionGetMakeDeps();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14}; 14};
15 15
16#endif 16#endif
diff --git a/src/functionmatches.cpp b/src/functionmatches.cpp
index 0f76316..b5b5b64 100644
--- a/src/functionmatches.cpp
+++ b/src/functionmatches.cpp
@@ -4,7 +4,7 @@
4 4
5#include <bu/plugger.h> 5#include <bu/plugger.h>
6PluginInterface3( pluginFunctionMatches, matches, FunctionMatches, Function, 6PluginInterface3( pluginFunctionMatches, matches, FunctionMatches, Function,
7 "Mike Buland", 0, 1 ); 7 "Mike Buland", 0, 1 );
8 8
9FunctionMatches::FunctionMatches() 9FunctionMatches::FunctionMatches()
10{ 10{
@@ -16,130 +16,130 @@ FunctionMatches::~FunctionMatches()
16 16
17Bu::String FunctionMatches::getName() const 17Bu::String FunctionMatches::getName() const
18{ 18{
19 return "matches"; 19 return "matches";
20} 20}
21 21
22bool FunctionMatches::globcmp( const Bu::String &sTxt, const Bu::String &sMatches ) 22bool FunctionMatches::globcmp( const Bu::String &sTxt, const Bu::String &sMatches )
23{ 23{
24 Bu::String::const_iterator t, g; 24 Bu::String::const_iterator t, g;
25 t = sTxt.begin(); 25 t = sTxt.begin();
26 g = sMatches.begin(); 26 g = sMatches.begin();
27 27
28 while( g && t ) 28 while( g && t )
29 { 29 {
30 switch( *g ) 30 switch( *g )
31 { 31 {
32 case '*': 32 case '*':
33 // First, if the * is at the end, then we do match, it doesn't 33 // First, if the * is at the end, then we do match, it doesn't
34 // matter what is in sTxt 34 // matter what is in sTxt
35 if( !(g+1) ) 35 if( !(g+1) )
36 return true; 36 return true;
37 // Now attempt to scan for the remainder as a matched set 37 // Now attempt to scan for the remainder as a matched set
38 { 38 {
39 Bu::String::const_iterator tn = t+1, gn = g+1, gi=g+1; 39 Bu::String::const_iterator tn = t+1, gn = g+1, gi=g+1;
40 bool bFoundMatch = false; 40 bool bFoundMatch = false;
41 while( tn && gn ) 41 while( tn && gn )
42 { 42 {
43 if( *gn == '*' ) 43 if( *gn == '*' )
44 { 44 {
45 g = gn; 45 g = gn;
46 t = tn; 46 t = tn;
47 break; 47 break;
48 } 48 }
49 if( *tn == *gn ) 49 if( *tn == *gn )
50 { 50 {
51 g = gn; 51 g = gn;
52 t = tn; 52 t = tn;
53 tn++; 53 tn++;
54 gn++; 54 gn++;
55 bFoundMatch = true; 55 bFoundMatch = true;
56 } 56 }
57 else 57 else
58 { 58 {
59 gn = gi; 59 gn = gi;
60 tn++; 60 tn++;
61 bFoundMatch = false; 61 bFoundMatch = false;
62 } 62 }
63 } 63 }
64 if( bFoundMatch == false ) 64 if( bFoundMatch == false )
65 return false; 65 return false;
66 if( !tn && !gn && bFoundMatch ) 66 if( !tn && !gn && bFoundMatch )
67 return true; 67 return true;
68 } 68 }
69 break; 69 break;
70 70
71 case '?': 71 case '?':
72 // Don't bother checking. 72 // Don't bother checking.
73 t++; 73 t++;
74 g++; 74 g++;
75 break; 75 break;
76 76
77 default: 77 default:
78 if( *t != *g ) 78 if( *t != *g )
79 return false; 79 return false;
80 t++; 80 t++;
81 g++; 81 g++;
82 break; 82 break;
83 } 83 }
84 } 84 }
85 if( t || (g && *g != '*') ) 85 if( t || (g && *g != '*') )
86 return false; 86 return false;
87 return true; 87 return true;
88} 88}
89 89
90bool FunctionMatches::matchlist( const Bu::String &sTxt, VarList &lParams ) 90bool FunctionMatches::matchlist( const Bu::String &sTxt, VarList &lParams )
91{ 91{
92 for( VarList::iterator i = lParams.begin(); i; i++ ) 92 for( VarList::iterator i = lParams.begin(); i; i++ )
93 { 93 {
94 if( (*i).getType() == Variable::typeList ) 94 if( (*i).getType() == Variable::typeList )
95 { 95 {
96 for( VarList::iterator j = (*i).begin(); j; j++ ) 96 for( VarList::iterator j = (*i).begin(); j; j++ )
97 { 97 {
98 if( globcmp( sTxt, (*j).toString() ) ) 98 if( globcmp( sTxt, (*j).toString() ) )
99 return true; 99 return true;
100 } 100 }
101 } 101 }
102 else 102 else
103 { 103 {
104 if( globcmp( sTxt, (*i).toString() ) ) 104 if( globcmp( sTxt, (*i).toString() ) )
105 return true; 105 return true;
106 } 106 }
107 } 107 }
108 return false; 108 return false;
109} 109}
110 110
111Variable FunctionMatches::call( Variable &input, VarList lParams ) 111Variable FunctionMatches::call( Variable &input, VarList lParams )
112{ 112{
113 switch( input.getType() ) 113 switch( input.getType() )
114 { 114 {
115 case Variable::typeString: 115 case Variable::typeString:
116 { 116 {
117 Bu::String sTxt = input.getString(); 117 Bu::String sTxt = input.getString();
118 return Variable( matchlist( sTxt, lParams ) ); 118 return Variable( matchlist( sTxt, lParams ) );
119 } 119 }
120 break; 120 break;
121 121
122 case Variable::typeList: 122 case Variable::typeList:
123 { 123 {
124 Variable vRet( Variable::typeList ); 124 Variable vRet( Variable::typeList );
125 for( VarList::iterator i = input.begin(); i; i++ ) 125 for( VarList::iterator i = input.begin(); i; i++ )
126 { 126 {
127 if( (*i).getType() != Variable::typeString ) 127 if( (*i).getType() != Variable::typeString )
128 continue; 128 continue;
129 Bu::String sTxt = (*i).getString(); 129 Bu::String sTxt = (*i).getString();
130 if( matchlist( sTxt, lParams ) ) 130 if( matchlist( sTxt, lParams ) )
131 vRet.append( *i ); 131 vRet.append( *i );
132 } 132 }
133 return vRet; 133 return vRet;
134 } 134 }
135 break; 135 break;
136 136
137 default: 137 default:
138 throw Bu::ExceptionBase("You can only use a string or list as the " 138 throw Bu::ExceptionBase("You can only use a string or list as the "
139 "input to matches."); 139 "input to matches.");
140 break; 140 break;
141 } 141 }
142 142
143 return Variable(); 143 return Variable();
144} 144}
145 145
diff --git a/src/functionmatches.h b/src/functionmatches.h
index 92ffe26..b569e0b 100644
--- a/src/functionmatches.h
+++ b/src/functionmatches.h
@@ -6,17 +6,17 @@
6class FunctionMatches : public Function 6class FunctionMatches : public Function
7{ 7{
8public: 8public:
9 FunctionMatches(); 9 FunctionMatches();
10 virtual ~FunctionMatches(); 10 virtual ~FunctionMatches();
11 11
12 /** 12 /**
13 * Really basic globbing function, it doesn't handle character classes, 13 * Really basic globbing function, it doesn't handle character classes,
14 * just * and ?. We can expand on it later, it may be handy. 14 * just * and ?. We can expand on it later, it may be handy.
15 */ 15 */
16 bool globcmp( const Bu::String &sTxt, const Bu::String &sMatches ); 16 bool globcmp( const Bu::String &sTxt, const Bu::String &sMatches );
17 bool matchlist( const Bu::String &sTxt, VarList &lParams ); 17 bool matchlist( const Bu::String &sTxt, VarList &lParams );
18 virtual Bu::String getName() const; 18 virtual Bu::String getName() const;
19 virtual Variable call( Variable &input, VarList lParams ); 19 virtual Variable call( Variable &input, VarList lParams );
20 20
21}; 21};
22 22
diff --git a/src/functionopen.cpp b/src/functionopen.cpp
index 4026a8c..075f43c 100644
--- a/src/functionopen.cpp
+++ b/src/functionopen.cpp
@@ -3,7 +3,7 @@
3 3
4#include <bu/plugger.h> 4#include <bu/plugger.h>
5PluginInterface3( pluginFunctionOpen, open, FunctionOpen, Function, 5PluginInterface3( pluginFunctionOpen, open, FunctionOpen, Function,
6 "Mike Buland", 0, 1 ); 6 "Mike Buland", 0, 1 );
7 7
8FunctionOpen::FunctionOpen() 8FunctionOpen::FunctionOpen()
9{ 9{
@@ -15,28 +15,28 @@ FunctionOpen::~FunctionOpen()
15 15
16Bu::String FunctionOpen::getName() const 16Bu::String FunctionOpen::getName() const
17{ 17{
18 return "open"; 18 return "open";
19} 19}
20 20
21Variable FunctionOpen::call( Variable &input, VarList lParams ) 21Variable FunctionOpen::call( Variable &input, VarList lParams )
22{ 22{
23 if( lParams.getSize() != 2 ) 23 if( lParams.getSize() != 2 )
24 { 24 {
25 throw Bu::ExceptionBase( 25 throw Bu::ExceptionBase(
26 "open takes two parameters, filename and mode." 26 "open takes two parameters, filename and mode."
27 ); 27 );
28 } 28 }
29 Bu::String sMode = lParams.last().toString().toLower(); 29 Bu::String sMode = lParams.last().toString().toLower();
30 int iMode = Bu::File::Create; 30 int iMode = Bu::File::Create;
31 if( sMode.find('w') ) 31 if( sMode.find('w') )
32 iMode |= Bu::File::Write; 32 iMode |= Bu::File::Write;
33 if( sMode.find('r') ) 33 if( sMode.find('r') )
34 iMode |= Bu::File::Read; 34 iMode |= Bu::File::Read;
35 Variable vRet( 35 Variable vRet(
36 (void *)FileMgr::getInstance().open( 36 (void *)FileMgr::getInstance().open(
37 lParams.first().toString(), iMode 37 lParams.first().toString(), iMode
38 ) 38 )
39 ); 39 );
40 return vRet; 40 return vRet;
41} 41}
42 42
diff --git a/src/functionopen.h b/src/functionopen.h
index 5ab3cab..27a18ad 100644
--- a/src/functionopen.h
+++ b/src/functionopen.h
@@ -6,11 +6,11 @@
6class FunctionOpen : public Function 6class FunctionOpen : public Function
7{ 7{
8public: 8public:
9 FunctionOpen(); 9 FunctionOpen();
10 virtual ~FunctionOpen(); 10 virtual ~FunctionOpen();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14 14
15}; 15};
16 16
diff --git a/src/functionplugger.cpp b/src/functionplugger.cpp
index 1f2bcf5..3999021 100644
--- a/src/functionplugger.cpp
+++ b/src/functionplugger.cpp
@@ -25,46 +25,46 @@ extern Bu::PluginInfo pluginFunctionUnique;
25 25
26FunctionPlugger::FunctionPlugger() 26FunctionPlugger::FunctionPlugger()
27{ 27{
28 registerBuiltinPlugin( &pluginFunctionDirName ); 28 registerBuiltinPlugin( &pluginFunctionDirName );
29 registerBuiltinPlugin( &pluginFunctionDirs ); 29 registerBuiltinPlugin( &pluginFunctionDirs );
30 registerBuiltinPlugin( &pluginFunctionExecute ); 30 registerBuiltinPlugin( &pluginFunctionExecute );
31 registerBuiltinPlugin( &pluginFunctionExists ); 31 registerBuiltinPlugin( &pluginFunctionExists );
32 registerBuiltinPlugin( &pluginFunctionFileName ); 32 registerBuiltinPlugin( &pluginFunctionFileName );
33 registerBuiltinPlugin( &pluginFunctionFiles ); 33 registerBuiltinPlugin( &pluginFunctionFiles );
34 registerBuiltinPlugin( &pluginFunctionGetMakeDeps ); 34 registerBuiltinPlugin( &pluginFunctionGetMakeDeps );
35 registerBuiltinPlugin( &pluginFunctionMatches ); 35 registerBuiltinPlugin( &pluginFunctionMatches );
36 registerBuiltinPlugin( &pluginFunctionReplace ); 36 registerBuiltinPlugin( &pluginFunctionReplace );
37 registerBuiltinPlugin( &pluginFunctionTargets ); 37 registerBuiltinPlugin( &pluginFunctionTargets );
38 registerBuiltinPlugin( &pluginFunctionToString ); 38 registerBuiltinPlugin( &pluginFunctionToString );
39 registerBuiltinPlugin( &pluginFunctionUnlink ); 39 registerBuiltinPlugin( &pluginFunctionUnlink );
40 registerBuiltinPlugin( &pluginFunctionRegEx ); 40 registerBuiltinPlugin( &pluginFunctionRegEx );
41 registerBuiltinPlugin( &pluginFunctionRange ); 41 registerBuiltinPlugin( &pluginFunctionRange );
42 registerBuiltinPlugin( &pluginFunctionOpen ); 42 registerBuiltinPlugin( &pluginFunctionOpen );
43 registerBuiltinPlugin( &pluginFunctionClose ); 43 registerBuiltinPlugin( &pluginFunctionClose );
44 registerBuiltinPlugin( &pluginFunctionRead ); 44 registerBuiltinPlugin( &pluginFunctionRead );
45 registerBuiltinPlugin( &pluginFunctionWrite ); 45 registerBuiltinPlugin( &pluginFunctionWrite );
46 registerBuiltinPlugin( &pluginFunctionUnique ); 46 registerBuiltinPlugin( &pluginFunctionUnique );
47 47
48 DIR *dir = opendir("/usr/lib/build"); 48 DIR *dir = opendir("/usr/lib/build");
49 if( !dir ) 49 if( !dir )
50 return; 50 return;
51 struct dirent *de; 51 struct dirent *de;
52 while( (de = readdir( dir )) ) 52 while( (de = readdir( dir )) )
53 { 53 {
54 if( strncmp("pluginFunction", de->d_name, 15 ) ) 54 if( strncmp("pluginFunction", de->d_name, 15 ) )
55 continue; 55 continue;
56 56
57 Bu::String sFile("/usr/lib/build/"); 57 Bu::String sFile("/usr/lib/build/");
58 sFile += de->d_name; 58 sFile += de->d_name;
59 char *s = de->d_name; 59 char *s = de->d_name;
60 for(; *s && *s != '.'; s++ ) { } 60 for(; *s && *s != '.'; s++ ) { }
61 registerExternalPlugin( 61 registerExternalPlugin(
62 sFile, 62 sFile,
63 Bu::String( de->d_name, (ptrdiff_t)s-(ptrdiff_t)de->d_name ) 63 Bu::String( de->d_name, (ptrdiff_t)s-(ptrdiff_t)de->d_name )
64 ); 64 );
65 } 65 }
66 66
67 closedir( dir ); 67 closedir( dir );
68} 68}
69 69
70FunctionPlugger::~FunctionPlugger() 70FunctionPlugger::~FunctionPlugger()
diff --git a/src/functionplugger.h b/src/functionplugger.h
index 30022f6..12655f7 100644
--- a/src/functionplugger.h
+++ b/src/functionplugger.h
@@ -6,12 +6,12 @@
6#include <bu/singleton.h> 6#include <bu/singleton.h>
7 7
8class FunctionPlugger : public Bu::Plugger<Function>, 8class FunctionPlugger : public Bu::Plugger<Function>,
9 public Bu::Singleton<FunctionPlugger> 9 public Bu::Singleton<FunctionPlugger>
10{ 10{
11friend class Bu::Singleton<FunctionPlugger>; 11friend class Bu::Singleton<FunctionPlugger>;
12private: 12private:
13 FunctionPlugger(); 13 FunctionPlugger();
14 virtual ~FunctionPlugger(); 14 virtual ~FunctionPlugger();
15}; 15};
16 16
17#endif 17#endif
diff --git a/src/functionrange.cpp b/src/functionrange.cpp
index f45cf0e..e6267cf 100644
--- a/src/functionrange.cpp
+++ b/src/functionrange.cpp
@@ -2,7 +2,7 @@
2 2
3#include <bu/plugger.h> 3#include <bu/plugger.h>
4PluginInterface3( pluginFunctionRange, range, FunctionRange, Function, 4PluginInterface3( pluginFunctionRange, range, FunctionRange, Function,
5 "Mike Buland", 0, 1 ); 5 "Mike Buland", 0, 1 );
6 6
7FunctionRange::FunctionRange() 7FunctionRange::FunctionRange()
8{ 8{
@@ -14,58 +14,58 @@ FunctionRange::~FunctionRange()
14 14
15Bu::String FunctionRange::getName() const 15Bu::String FunctionRange::getName() const
16{ 16{
17 return "range"; 17 return "range";
18} 18}
19 19
20Variable FunctionRange::call( Variable &input, VarList lParams ) 20Variable FunctionRange::call( Variable &input, VarList lParams )
21{ 21{
22 Variable vRet( Variable::typeList ); 22 Variable vRet( Variable::typeList );
23 int iLow = 1; 23 int iLow = 1;
24 int iHigh = 1; 24 int iHigh = 1;
25 int iStep = 1; 25 int iStep = 1;
26 if( lParams.getSize() == 1 ) 26 if( lParams.getSize() == 1 )
27 { 27 {
28 iHigh = lParams.first().toInt(); 28 iHigh = lParams.first().toInt();
29 } 29 }
30 else if( lParams.getSize() == 2 ) 30 else if( lParams.getSize() == 2 )
31 { 31 {
32 iLow = lParams.first().toInt(); 32 iLow = lParams.first().toInt();
33 iHigh = lParams.last().toInt(); 33 iHigh = lParams.last().toInt();
34 } 34 }
35 else if( lParams.getSize() == 3 ) 35 else if( lParams.getSize() == 3 )
36 { 36 {
37 VarList::iterator i = lParams.begin(); 37 VarList::iterator i = lParams.begin();
38 iLow = (*i).toInt(); 38 iLow = (*i).toInt();
39 i++; 39 i++;
40 iHigh = (*i).toInt(); 40 iHigh = (*i).toInt();
41 i++; 41 i++;
42 iStep = (*i).toInt(); 42 iStep = (*i).toInt();
43 } 43 }
44 if( iStep == 0 ) 44 if( iStep == 0 )
45 throw Bu::ExceptionBase("Step cannot be zero."); 45 throw Bu::ExceptionBase("Step cannot be zero.");
46 46
47 if( iHigh < iLow ) 47 if( iHigh < iLow )
48 { 48 {
49 if( iStep > 0 ) 49 if( iStep > 0 )
50 throw Bu::ExceptionBase( 50 throw Bu::ExceptionBase(
51 "If start is less than end then step must be negative."); 51 "If start is less than end then step must be negative.");
52 for( int j = iLow; j >= iHigh; j += iStep ) 52 for( int j = iLow; j >= iHigh; j += iStep )
53 { 53 {
54 vRet.append( Variable( j ) ); 54 vRet.append( Variable( j ) );
55 } 55 }
56 } 56 }
57 else 57 else
58 { 58 {
59 if( iStep < 0 ) 59 if( iStep < 0 )
60 throw Bu::ExceptionBase( 60 throw Bu::ExceptionBase(
61 "If start is more than end then step must be positive."); 61 "If start is more than end then step must be positive.");
62 for( int j = iLow; j <= iHigh; j += iStep ) 62 for( int j = iLow; j <= iHigh; j += iStep )
63 { 63 {
64 vRet.append( Variable( j ) ); 64 vRet.append( Variable( j ) );
65 } 65 }
66 } 66 }
67 67
68 68
69 return vRet; 69 return vRet;
70} 70}
71 71
diff --git a/src/functionrange.h b/src/functionrange.h
index 1f6d8c5..ddd7650 100644
--- a/src/functionrange.h
+++ b/src/functionrange.h
@@ -6,11 +6,11 @@
6class FunctionRange : public Function 6class FunctionRange : public Function
7{ 7{
8public: 8public:
9 FunctionRange(); 9 FunctionRange();
10 virtual ~FunctionRange(); 10 virtual ~FunctionRange();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14 14
15}; 15};
16 16
diff --git a/src/functionread.cpp b/src/functionread.cpp
index b9c8397..a59519c 100644
--- a/src/functionread.cpp
+++ b/src/functionread.cpp
@@ -3,7 +3,7 @@
3 3
4#include <bu/plugger.h> 4#include <bu/plugger.h>
5PluginInterface3( pluginFunctionRead, read, FunctionRead, Function, 5PluginInterface3( pluginFunctionRead, read, FunctionRead, Function,
6 "Mike Buland", 0, 1 ); 6 "Mike Buland", 0, 1 );
7 7
8FunctionRead::FunctionRead() 8FunctionRead::FunctionRead()
9{ 9{
@@ -15,26 +15,26 @@ FunctionRead::~FunctionRead()
15 15
16Bu::String FunctionRead::getName() const 16Bu::String FunctionRead::getName() const
17{ 17{
18 return "read"; 18 return "read";
19} 19}
20 20
21Variable FunctionRead::call( Variable &input, VarList lParams ) 21Variable FunctionRead::call( Variable &input, VarList lParams )
22{ 22{
23 Variable vRet; 23 Variable vRet;
24 if( lParams.getSize() == 1 ) 24 if( lParams.getSize() == 1 )
25 { 25 {
26 int iSize = lParams.first().toInt(); 26 int iSize = lParams.first().toInt();
27 Bu::String sBuf( iSize ); 27 Bu::String sBuf( iSize );
28 sBuf.resize( 28 sBuf.resize(
29 FileMgr::getInstance().get( (ptrdiff_t)input.getOpaque() ).read( 29 FileMgr::getInstance().get( (ptrdiff_t)input.getOpaque() ).read(
30 sBuf.getStr(), iSize 30 sBuf.getStr(), iSize
31 ) 31 )
32 ); 32 );
33 vRet = sBuf; 33 vRet = sBuf;
34 return vRet; 34 return vRet;
35 } 35 }
36 throw Bu::ExceptionBase( 36 throw Bu::ExceptionBase(
37 "read takes zero or one parameters." 37 "read takes zero or one parameters."
38 ); 38 );
39} 39}
40 40
diff --git a/src/functionread.h b/src/functionread.h
index 39bf32e..8bb6e8a 100644
--- a/src/functionread.h
+++ b/src/functionread.h
@@ -6,11 +6,11 @@
6class FunctionRead : public Function 6class FunctionRead : public Function
7{ 7{
8public: 8public:
9 FunctionRead(); 9 FunctionRead();
10 virtual ~FunctionRead(); 10 virtual ~FunctionRead();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14 14
15}; 15};
16 16
diff --git a/src/functionregex.cpp b/src/functionregex.cpp
index c80f527..007b3fe 100644
--- a/src/functionregex.cpp
+++ b/src/functionregex.cpp
@@ -3,7 +3,7 @@
3#include <bu/regex.h> 3#include <bu/regex.h>
4#include <bu/plugger.h> 4#include <bu/plugger.h>
5PluginInterface3( pluginFunctionRegEx, regex, FunctionRegEx, Function, 5PluginInterface3( pluginFunctionRegEx, regex, FunctionRegEx, Function,
6 "Mike Buland", 0, 1 ); 6 "Mike Buland", 0, 1 );
7 7
8FunctionRegEx::FunctionRegEx() 8FunctionRegEx::FunctionRegEx()
9{ 9{
@@ -15,112 +15,112 @@ FunctionRegEx::~FunctionRegEx()
15 15
16Bu::String FunctionRegEx::getName() const 16Bu::String FunctionRegEx::getName() const
17{ 17{
18 return "regex"; 18 return "regex";
19} 19}
20 20
21Variable FunctionRegEx::call( Variable &input, VarList lParams ) 21Variable FunctionRegEx::call( Variable &input, VarList lParams )
22{ 22{
23 if( lParams.getSize() == 1 ) 23 if( lParams.getSize() == 1 )
24 { 24 {
25 Bu::RegEx re( lParams.first().getString() ); 25 Bu::RegEx re( lParams.first().getString() );
26 switch( input.getType() ) 26 switch( input.getType() )
27 { 27 {
28 case Variable::typeString: 28 case Variable::typeString:
29 return re.execute( input.getString() ); 29 return re.execute( input.getString() );
30 30
31 case Variable::typeList: 31 case Variable::typeList:
32 { 32 {
33 Variable vOut( Variable::typeList ); 33 Variable vOut( Variable::typeList );
34 for( VarList::iterator i = input.begin(); i; i++ ) 34 for( VarList::iterator i = input.begin(); i; i++ )
35 { 35 {
36 if( re.execute( (*i).toString() ) ) 36 if( re.execute( (*i).toString() ) )
37 vOut.append( *i ); 37 vOut.append( *i );
38 } 38 }
39 return vOut; 39 return vOut;
40 } 40 }
41 break; 41 break;
42 42
43 default: 43 default:
44 break; 44 break;
45 } 45 }
46 } 46 }
47 else if( lParams.getSize() == 2 ) 47 else if( lParams.getSize() == 2 )
48 { 48 {
49 Bu::RegEx re( lParams.first().getString() ); 49 Bu::RegEx re( lParams.first().getString() );
50 Bu::String sPat = lParams.last().getString(); 50 Bu::String sPat = lParams.last().getString();
51 switch( input.getType() ) 51 switch( input.getType() )
52 { 52 {
53 case Variable::typeString: 53 case Variable::typeString:
54 if( re.execute( input.getString() ) ) 54 if( re.execute( input.getString() ) )
55 { 55 {
56 return replace( re, input.getString(), sPat ); 56 return replace( re, input.getString(), sPat );
57 } 57 }
58 else 58 else
59 { 59 {
60 return input; 60 return input;
61 } 61 }
62 break; 62 break;
63 63
64 case Variable::typeList: 64 case Variable::typeList:
65 { 65 {
66 Variable vOut( Variable::typeList ); 66 Variable vOut( Variable::typeList );
67 for( VarList::iterator i = input.begin(); i; i++ ) 67 for( VarList::iterator i = input.begin(); i; i++ )
68 { 68 {
69 if( re.execute( (*i).toString() ) ) 69 if( re.execute( (*i).toString() ) )
70 vOut.append( replace( re, (*i).toString(), sPat ) ); 70 vOut.append( replace( re, (*i).toString(), sPat ) );
71 else 71 else
72 vOut.append( *i ); 72 vOut.append( *i );
73 } 73 }
74 return vOut; 74 return vOut;
75 } 75 }
76 break; 76 break;
77 77
78 default: 78 default:
79 break; 79 break;
80 } 80 }
81 } 81 }
82 throw Bu::ExceptionBase( 82 throw Bu::ExceptionBase(
83 "regex does not work on non-string or non-list types."); 83 "regex does not work on non-string or non-list types.");
84} 84}
85 85
86Bu::String FunctionRegEx::replace( Bu::RegEx &re, const Bu::String &sSrc, 86Bu::String FunctionRegEx::replace( Bu::RegEx &re, const Bu::String &sSrc,
87 const Bu::String &sPat ) 87 const Bu::String &sPat )
88{ 88{
89 Bu::String sOut; 89 Bu::String sOut;
90 90
91 int iStart, iEnd; 91 int iStart, iEnd;
92 re.getSubStringRange( 0, iStart, iEnd ); // Get the range of the full match 92 re.getSubStringRange( 0, iStart, iEnd ); // Get the range of the full match
93 93
94 if( iStart > 0 ) 94 if( iStart > 0 )
95 sOut.append( sSrc, 0, iStart ); 95 sOut.append( sSrc, 0, iStart );
96 96
97 for( Bu::String::const_iterator i = sPat.begin(); i; i++ ) 97 for( Bu::String::const_iterator i = sPat.begin(); i; i++ )
98 { 98 {
99 if( *i == '\\' ) 99 if( *i == '\\' )
100 { 100 {
101 i++; 101 i++;
102 if( *i <= '9' && *i >= '0' ) 102 if( *i <= '9' && *i >= '0' )
103 { 103 {
104 int iInd = *i-'0'; 104 int iInd = *i-'0';
105 if( iInd < re.getNumSubStrings() ) 105 if( iInd < re.getNumSubStrings() )
106 sOut += re.getSubString( iInd ); 106 sOut += re.getSubString( iInd );
107 } 107 }
108 else 108 else
109 { 109 {
110 sOut += *i; 110 sOut += *i;
111 } 111 }
112 } 112 }
113 else 113 else
114 { 114 {
115 sOut += *i; 115 sOut += *i;
116 } 116 }
117 } 117 }
118 118
119 if( iEnd < sSrc.getSize() ) 119 if( iEnd < sSrc.getSize() )
120 { 120 {
121 sOut.append( sSrc, iEnd, -1 ); 121 sOut.append( sSrc, iEnd, -1 );
122 } 122 }
123 123
124 return sOut; 124 return sOut;
125} 125}
126 126
diff --git a/src/functionregex.h b/src/functionregex.h
index edc21c6..1ded9ab 100644
--- a/src/functionregex.h
+++ b/src/functionregex.h
@@ -5,20 +5,20 @@
5 5
6namespace Bu 6namespace Bu
7{ 7{
8 class RegEx; 8 class RegEx;
9} 9}
10 10
11class FunctionRegEx : public Function 11class FunctionRegEx : public Function
12{ 12{
13public: 13public:
14 FunctionRegEx(); 14 FunctionRegEx();
15 virtual ~FunctionRegEx(); 15 virtual ~FunctionRegEx();
16 16
17 virtual Bu::String getName() const; 17 virtual Bu::String getName() const;
18 virtual Variable call( Variable &input, VarList lParams ); 18 virtual Variable call( Variable &input, VarList lParams );
19 19
20 Bu::String replace( Bu::RegEx &re, const Bu::String &sSrc, 20 Bu::String replace( Bu::RegEx &re, const Bu::String &sSrc,
21 const Bu::String &sPat ); 21 const Bu::String &sPat );
22}; 22};
23 23
24#endif 24#endif
diff --git a/src/functionreplace.cpp b/src/functionreplace.cpp
index 589ef55..6cf455e 100644
--- a/src/functionreplace.cpp
+++ b/src/functionreplace.cpp
@@ -2,7 +2,7 @@
2 2
3#include <bu/plugger.h> 3#include <bu/plugger.h>
4PluginInterface3( pluginFunctionReplace, replace, FunctionReplace, Function, 4PluginInterface3( pluginFunctionReplace, replace, FunctionReplace, Function,
5 "Mike Buland", 0, 1 ); 5 "Mike Buland", 0, 1 );
6 6
7FunctionReplace::FunctionReplace() 7FunctionReplace::FunctionReplace()
8{ 8{
@@ -14,38 +14,38 @@ FunctionReplace::~FunctionReplace()
14 14
15Bu::String FunctionReplace::getName() const 15Bu::String FunctionReplace::getName() const
16{ 16{
17 return "replace"; 17 return "replace";
18} 18}
19 19
20Variable FunctionReplace::call( Variable &input, VarList lParams ) 20Variable FunctionReplace::call( Variable &input, VarList lParams )
21{ 21{
22 Bu::String sA, sB; 22 Bu::String sA, sB;
23 sA = lParams.first().getString(); 23 sA = lParams.first().getString();
24 sB = lParams.last().getString(); 24 sB = lParams.last().getString();
25 switch( input.getType() ) 25 switch( input.getType() )
26 { 26 {
27 case Variable::typeString: 27 case Variable::typeString:
28 { 28 {
29 Variable vOut( input.getString().replace( sA, sB ) ); 29 Variable vOut( input.getString().replace( sA, sB ) );
30 return vOut; 30 return vOut;
31 } 31 }
32 break; 32 break;
33 33
34 case Variable::typeList: 34 case Variable::typeList:
35 { 35 {
36 Variable vOut( Variable::typeList ); 36 Variable vOut( Variable::typeList );
37 for( VarList::iterator i = input.begin(); i; i++ ) 37 for( VarList::iterator i = input.begin(); i; i++ )
38 { 38 {
39 vOut.append( (*i).getString().replace( sA, sB ) ); 39 vOut.append( (*i).getString().replace( sA, sB ) );
40 } 40 }
41 return vOut; 41 return vOut;
42 } 42 }
43 break; 43 break;
44 44
45 default: 45 default:
46 break; 46 break;
47 } 47 }
48 throw Bu::ExceptionBase( 48 throw Bu::ExceptionBase(
49 "replace does not work on non-string or non-list types."); 49 "replace does not work on non-string or non-list types.");
50} 50}
51 51
diff --git a/src/functionreplace.h b/src/functionreplace.h
index 05442d8..dbecef6 100644
--- a/src/functionreplace.h
+++ b/src/functionreplace.h
@@ -6,11 +6,11 @@
6class FunctionReplace : public Function 6class FunctionReplace : public Function
7{ 7{
8public: 8public:
9 FunctionReplace(); 9 FunctionReplace();
10 virtual ~FunctionReplace(); 10 virtual ~FunctionReplace();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14}; 14};
15 15
16#endif 16#endif
diff --git a/src/functiontargets.cpp b/src/functiontargets.cpp
index 3fd145e..ad92376 100644
--- a/src/functiontargets.cpp
+++ b/src/functiontargets.cpp
@@ -4,7 +4,7 @@
4 4
5#include <bu/plugger.h> 5#include <bu/plugger.h>
6PluginInterface3( pluginFunctionTargets, targets, FunctionTargets, Function, 6PluginInterface3( pluginFunctionTargets, targets, FunctionTargets, Function,
7 "Mike Buland", 0, 1 ); 7 "Mike Buland", 0, 1 );
8 8
9FunctionTargets::FunctionTargets() 9FunctionTargets::FunctionTargets()
10{ 10{
@@ -16,28 +16,28 @@ FunctionTargets::~FunctionTargets()
16 16
17Bu::String FunctionTargets::getName() const 17Bu::String FunctionTargets::getName() const
18{ 18{
19 return "targets"; 19 return "targets";
20} 20}
21 21
22Variable FunctionTargets::call( Variable &/*input*/, VarList lParams ) 22Variable FunctionTargets::call( Variable &/*input*/, VarList lParams )
23{ 23{
24 Variable vRet( Variable::typeList ); 24 Variable vRet( Variable::typeList );
25 TargetList lTrg; 25 TargetList lTrg;
26 if( lParams.getSize() == 0 ) 26 if( lParams.getSize() == 0 )
27 { 27 {
28 lTrg = pContext->getExplicitTargets(); 28 lTrg = pContext->getExplicitTargets();
29 } 29 }
30 else 30 else
31 { 31 {
32 lTrg = pContext->getTag( lParams.first().toString() ); 32 lTrg = pContext->getTag( lParams.first().toString() );
33 } 33 }
34 for( TargetList::const_iterator i = lTrg.begin(); i; i++ ) 34 for( TargetList::const_iterator i = lTrg.begin(); i; i++ )
35 { 35 {
36 for( StrList::const_iterator j = (*i)->getOutputList().begin(); j; j++ ) 36 for( StrList::const_iterator j = (*i)->getOutputList().begin(); j; j++ )
37 { 37 {
38 vRet.append( *j ); 38 vRet.append( *j );
39 } 39 }
40 } 40 }
41 return vRet; 41 return vRet;
42} 42}
43 43
diff --git a/src/functiontargets.h b/src/functiontargets.h
index a6e7d21..6b892e2 100644
--- a/src/functiontargets.h
+++ b/src/functiontargets.h
@@ -6,11 +6,11 @@
6class FunctionTargets : public Function 6class FunctionTargets : public Function
7{ 7{
8public: 8public:
9 FunctionTargets(); 9 FunctionTargets();
10 virtual ~FunctionTargets(); 10 virtual ~FunctionTargets();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14}; 14};
15 15
16#endif 16#endif
diff --git a/src/functiontostring.cpp b/src/functiontostring.cpp
index bc5db6c..b3ffb5b 100644
--- a/src/functiontostring.cpp
+++ b/src/functiontostring.cpp
@@ -6,7 +6,7 @@ using namespace Bu;
6 6
7#include <bu/plugger.h> 7#include <bu/plugger.h>
8PluginInterface3( pluginFunctionToString, toString, FunctionToString, Function, 8PluginInterface3( pluginFunctionToString, toString, FunctionToString, Function,
9 "Mike Buland", 0, 1 ); 9 "Mike Buland", 0, 1 );
10 10
11FunctionToString::FunctionToString() 11FunctionToString::FunctionToString()
12{ 12{
@@ -18,37 +18,37 @@ FunctionToString::~FunctionToString()
18 18
19Bu::String FunctionToString::getName() const 19Bu::String FunctionToString::getName() const
20{ 20{
21 return "toString"; 21 return "toString";
22} 22}
23 23
24Variable FunctionToString::call( Variable &input, VarList lParams ) 24Variable FunctionToString::call( Variable &input, VarList lParams )
25{ 25{
26 Bu::String sStr; 26 Bu::String sStr;
27 Bu::String sSep; 27 Bu::String sSep;
28 if( lParams.getSize() == 0 ) 28 if( lParams.getSize() == 0 )
29 { 29 {
30 sSep = " "; 30 sSep = " ";
31 } 31 }
32 else 32 else
33 { 33 {
34 sSep = lParams.first().getString(); 34 sSep = lParams.first().getString();
35 } 35 }
36 switch( input.getType() ) 36 switch( input.getType() )
37 { 37 {
38 case Variable::typeString: 38 case Variable::typeString:
39 return input; 39 return input;
40 40
41 case Variable::typeList: 41 case Variable::typeList:
42 for( VarList::iterator i = input.begin(); i; i++ ) 42 for( VarList::iterator i = input.begin(); i; i++ )
43 { 43 {
44 if( i != input.begin() ) 44 if( i != input.begin() )
45 sStr += sSep; 45 sStr += sSep;
46 sStr += (*i).getString(); 46 sStr += (*i).getString();
47 } 47 }
48 return Variable( sStr ); 48 return Variable( sStr );
49 49
50 default: 50 default:
51 return Variable( input.getString() ); 51 return Variable( input.getString() );
52 } 52 }
53} 53}
54 54
diff --git a/src/functiontostring.h b/src/functiontostring.h
index c5bc50d..177ecc6 100644
--- a/src/functiontostring.h
+++ b/src/functiontostring.h
@@ -6,11 +6,11 @@
6class FunctionToString : public Function 6class FunctionToString : public Function
7{ 7{
8public: 8public:
9 FunctionToString(); 9 FunctionToString();
10 virtual ~FunctionToString(); 10 virtual ~FunctionToString();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14}; 14};
15 15
16#endif 16#endif
diff --git a/src/functionunique.cpp b/src/functionunique.cpp
index ca2461f..f12712e 100644
--- a/src/functionunique.cpp
+++ b/src/functionunique.cpp
@@ -3,7 +3,7 @@
3#include <bu/hash.h> 3#include <bu/hash.h>
4#include <bu/plugger.h> 4#include <bu/plugger.h>
5PluginInterface3( pluginFunctionUnique, unique, FunctionUnique, Function, 5PluginInterface3( pluginFunctionUnique, unique, FunctionUnique, Function,
6 "Mike Buland", 0, 1 ); 6 "Mike Buland", 0, 1 );
7 7
8FunctionUnique::FunctionUnique() 8FunctionUnique::FunctionUnique()
9{ 9{
@@ -15,33 +15,33 @@ FunctionUnique::~FunctionUnique()
15 15
16Bu::String FunctionUnique::getName() const 16Bu::String FunctionUnique::getName() const
17{ 17{
18 return "unique"; 18 return "unique";
19} 19}
20 20
21Variable FunctionUnique::call( Variable &input, VarList lParams ) 21Variable FunctionUnique::call( Variable &input, VarList lParams )
22{ 22{
23 if( lParams.getSize() > 0 ) 23 if( lParams.getSize() > 0 )
24 throw Bu::ExceptionBase("Unique does not take any parameters."); 24 throw Bu::ExceptionBase("Unique does not take any parameters.");
25 if( input.getType() != Variable::typeList ) 25 if( input.getType() != Variable::typeList )
26 throw Bu::ExceptionBase("unique does not work on non-list types."); 26 throw Bu::ExceptionBase("unique does not work on non-list types.");
27 27
28 Bu::Hash<Bu::String, bool> hHas; 28 Bu::Hash<Bu::String, bool> hHas;
29 29
30 Variable vOut( Variable::typeList ); 30 Variable vOut( Variable::typeList );
31 for( VarList::iterator i = input.begin(); i; i++ ) 31 for( VarList::iterator i = input.begin(); i; i++ )
32 { 32 {
33 if( (*i).getType() != Variable::typeString ) 33 if( (*i).getType() != Variable::typeString )
34 continue; 34 continue;
35 35
36 Bu::String s = (*i).getString(); 36 Bu::String s = (*i).getString();
37 37
38 if( hHas.has( s ) ) 38 if( hHas.has( s ) )
39 continue; 39 continue;
40 40
41 hHas.insert( s, true ); 41 hHas.insert( s, true );
42 vOut.append( *i ); 42 vOut.append( *i );
43 } 43 }
44 44
45 return vOut; 45 return vOut;
46} 46}
47 47
diff --git a/src/functionunique.h b/src/functionunique.h
index 6bc4225..cb7132a 100644
--- a/src/functionunique.h
+++ b/src/functionunique.h
@@ -6,11 +6,11 @@
6class FunctionUnique : public Function 6class FunctionUnique : public Function
7{ 7{
8public: 8public:
9 FunctionUnique(); 9 FunctionUnique();
10 virtual ~FunctionUnique(); 10 virtual ~FunctionUnique();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14}; 14};
15 15
16#endif 16#endif
diff --git a/src/functionunlink.cpp b/src/functionunlink.cpp
index 48985bb..590833c 100644
--- a/src/functionunlink.cpp
+++ b/src/functionunlink.cpp
@@ -7,7 +7,7 @@ using namespace Bu;
7 7
8#include <bu/plugger.h> 8#include <bu/plugger.h>
9PluginInterface3( pluginFunctionUnlink, unlink, FunctionUnlink, Function, 9PluginInterface3( pluginFunctionUnlink, unlink, FunctionUnlink, Function,
10 "Mike Buland", 0, 1 ); 10 "Mike Buland", 0, 1 );
11 11
12FunctionUnlink::FunctionUnlink() 12FunctionUnlink::FunctionUnlink()
13{ 13{
@@ -19,37 +19,37 @@ FunctionUnlink::~FunctionUnlink()
19 19
20Bu::String FunctionUnlink::getName() const 20Bu::String FunctionUnlink::getName() const
21{ 21{
22 return "unlink"; 22 return "unlink";
23} 23}
24 24
25Variable FunctionUnlink::call( Variable &/*input*/, VarList lParams ) 25Variable FunctionUnlink::call( Variable &/*input*/, VarList lParams )
26{ 26{
27 //sio << "Unlink called: " << lParams << sio.nl; 27 //sio << "Unlink called: " << lParams << sio.nl;
28 for( VarList::iterator p = lParams.begin(); p; p++ ) 28 for( VarList::iterator p = lParams.begin(); p; p++ )
29 { 29 {
30 switch( (*p).getType() ) 30 switch( (*p).getType() )
31 { 31 {
32 case Variable::typeString: 32 case Variable::typeString:
33 //sio << " xx> " << (*p).getString() << sio.nl; 33 //sio << " xx> " << (*p).getString() << sio.nl;
34 unlink( (*p).getString().getStr() ); 34 unlink( (*p).getString().getStr() );
35 break; 35 break;
36 36
37 case Variable::typeList: 37 case Variable::typeList:
38 //sio << " xx>"; 38 //sio << " xx>";
39 for( VarList::iterator i = (*p).begin(); i; i++ ) 39 for( VarList::iterator i = (*p).begin(); i; i++ )
40 { 40 {
41 //sio << " " << (*i).getString(); 41 //sio << " " << (*i).getString();
42 unlink( (*i).getString().getStr() ); 42 unlink( (*i).getString().getStr() );
43 } 43 }
44 //sio << sio.nl; 44 //sio << sio.nl;
45 break; 45 break;
46 46
47 default: 47 default:
48 throw Bu::ExceptionBase("Hey, wrong type passed."); 48 throw Bu::ExceptionBase("Hey, wrong type passed.");
49 break; 49 break;
50 } 50 }
51 } 51 }
52 52
53 return Variable(); 53 return Variable();
54} 54}
55 55
diff --git a/src/functionunlink.h b/src/functionunlink.h
index ab95615..ef1c4e4 100644
--- a/src/functionunlink.h
+++ b/src/functionunlink.h
@@ -6,11 +6,11 @@
6class FunctionUnlink : public Function 6class FunctionUnlink : public Function
7{ 7{
8public: 8public:
9 FunctionUnlink(); 9 FunctionUnlink();
10 virtual ~FunctionUnlink(); 10 virtual ~FunctionUnlink();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14}; 14};
15 15
16#endif 16#endif
diff --git a/src/functionwrite.cpp b/src/functionwrite.cpp
index 14a396a..4aee4e0 100644
--- a/src/functionwrite.cpp
+++ b/src/functionwrite.cpp
@@ -3,7 +3,7 @@
3 3
4#include <bu/plugger.h> 4#include <bu/plugger.h>
5PluginInterface3( pluginFunctionWrite, write, FunctionWrite, Function, 5PluginInterface3( pluginFunctionWrite, write, FunctionWrite, Function,
6 "Mike Buland", 0, 1 ); 6 "Mike Buland", 0, 1 );
7 7
8FunctionWrite::FunctionWrite() 8FunctionWrite::FunctionWrite()
9{ 9{
@@ -15,20 +15,20 @@ FunctionWrite::~FunctionWrite()
15 15
16Bu::String FunctionWrite::getName() const 16Bu::String FunctionWrite::getName() const
17{ 17{
18 return "write"; 18 return "write";
19} 19}
20 20
21Variable FunctionWrite::call( Variable &input, VarList lParams ) 21Variable FunctionWrite::call( Variable &input, VarList lParams )
22{ 22{
23 if( lParams.getSize() != 1 ) 23 if( lParams.getSize() != 1 )
24 { 24 {
25 throw Bu::ExceptionBase( 25 throw Bu::ExceptionBase(
26 "write takes one parameter, the string to write." 26 "write takes one parameter, the string to write."
27 ); 27 );
28 } 28 }
29 FileMgr::getInstance().get( (ptrdiff_t)input.getOpaque() ).write( 29 FileMgr::getInstance().get( (ptrdiff_t)input.getOpaque() ).write(
30 lParams.first().toString() 30 lParams.first().toString()
31 ); 31 );
32 return Variable(); 32 return Variable();
33} 33}
34 34
diff --git a/src/functionwrite.h b/src/functionwrite.h
index 75b2283..6a7678d 100644
--- a/src/functionwrite.h
+++ b/src/functionwrite.h
@@ -6,11 +6,11 @@
6class FunctionWrite : public Function 6class FunctionWrite : public Function
7{ 7{
8public: 8public:
9 FunctionWrite(); 9 FunctionWrite();
10 virtual ~FunctionWrite(); 10 virtual ~FunctionWrite();
11 11
12 virtual Bu::String getName() const; 12 virtual Bu::String getName() const;
13 virtual Variable call( Variable &input, VarList lParams ); 13 virtual Variable call( Variable &input, VarList lParams );
14 14
15}; 15};
16 16
diff --git a/src/location.cpp b/src/location.cpp
index 933379c..3dba48f 100644
--- a/src/location.cpp
+++ b/src/location.cpp
@@ -2,30 +2,30 @@
2#include "build.tab.h" 2#include "build.tab.h"
3 3
4Location::Location() : 4Location::Location() :
5 sFile("none"), 5 sFile("none"),
6 iStartRow( -1 ), 6 iStartRow( -1 ),
7 iStartCol( -1 ), 7 iStartCol( -1 ),
8 iEndRow( -1 ), 8 iEndRow( -1 ),
9 iEndCol( -1 ) 9 iEndCol( -1 )
10{ 10{
11} 11}
12 12
13Location::Location( struct YYLTYPE &loc ) : 13Location::Location( struct YYLTYPE &loc ) :
14 sFile("???"), 14 sFile("???"),
15 iStartRow( loc.first_line ), 15 iStartRow( loc.first_line ),
16 iStartCol( loc.first_column ), 16 iStartCol( loc.first_column ),
17 iEndRow( loc.last_line ), 17 iEndRow( loc.last_line ),
18 iEndCol( loc.last_column ) 18 iEndCol( loc.last_column )
19{ 19{
20} 20}
21 21
22Location::Location( const Bu::String &sFile, int iStartRow, int iStartCol, 22Location::Location( const Bu::String &sFile, int iStartRow, int iStartCol,
23 int iEndRow, int iEndCol ) : 23 int iEndRow, int iEndCol ) :
24 sFile( sFile ), 24 sFile( sFile ),
25 iStartRow( iStartRow ), 25 iStartRow( iStartRow ),
26 iStartCol( iStartCol ), 26 iStartCol( iStartCol ),
27 iEndRow( iEndRow ), 27 iEndRow( iEndRow ),
28 iEndCol( iEndCol ) 28 iEndCol( iEndCol )
29{ 29{
30} 30}
31 31
diff --git a/src/location.h b/src/location.h
index db329bb..a141073 100644
--- a/src/location.h
+++ b/src/location.h
@@ -6,18 +6,18 @@
6class Location 6class Location
7{ 7{
8public: 8public:
9 Location(); 9 Location();
10 Location( struct YYLTYPE &loc ); 10 Location( struct YYLTYPE &loc );
11 Location( const Bu::String &sFile, int iStartRow, int iStartCol, 11 Location( const Bu::String &sFile, int iStartRow, int iStartCol,
12 int iEndRow, int iEndCol ); 12 int iEndRow, int iEndCol );
13 virtual ~Location(); 13 virtual ~Location();
14 14
15private: 15private:
16 const Bu::String sFile; 16 const Bu::String sFile;
17 int iStartRow; 17 int iStartRow;
18 int iStartCol; 18 int iStartCol;
19 int iEndRow; 19 int iEndRow;
20 int iEndCol; 20 int iEndCol;
21}; 21};
22 22
23#endif 23#endif
diff --git a/src/main.cpp b/src/main.cpp
index caa33e6..ded91ba 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -24,290 +24,290 @@ using namespace Bu;
24class Options : public Bu::OptParser 24class Options : public Bu::OptParser
25{ 25{
26public: 26public:
27 Options( int argc, char *argv[] ) : 27 Options( int argc, char *argv[] ) :
28 sView("default"), 28 sView("default"),
29 sAction("default"), 29 sAction("default"),
30 sConfig("default.bld"), 30 sConfig("default.bld"),
31 sCacheFile(".build_cache"), 31 sCacheFile(".build_cache"),
32 bDot( false ), 32 bDot( false ),
33 bDebug( false ), 33 bDebug( false ),
34 bAutoInclude( true ), 34 bAutoInclude( true ),
35 bAstDump( false ), 35 bAstDump( false ),
36 bEnviron( true ), 36 bEnviron( true ),
37 bCache( true ), 37 bCache( true ),
38 iInfoLevel( 0 ) 38 iInfoLevel( 0 )
39 { 39 {
40 bool bClean = false; 40 bool bClean = false;
41 addHelpBanner("build mark 3\n"); 41 addHelpBanner("build mark 3\n");
42 42
43 Bu::String sViews("Select a view from: "); 43 Bu::String sViews("Select a view from: ");
44 StrList lViews = ViewPlugger::getInstance().getPluginList(); 44 StrList lViews = ViewPlugger::getInstance().getPluginList();
45 for( StrList::iterator i = lViews.begin(); i; i++ ) 45 for( StrList::iterator i = lViews.begin(); i; i++ )
46 { 46 {
47 if( i != lViews.begin() ) 47 if( i != lViews.begin() )
48 sViews += ", "; 48 sViews += ", ";
49 sViews += *i; 49 sViews += *i;
50 } 50 }
51 51
52 addHelpBanner("The following options do things other than build:"); 52 addHelpBanner("The following options do things other than build:");
53 addOption( iInfoLevel, 'i', "info", "Display some basic info about the " 53 addOption( iInfoLevel, 'i', "info", "Display some basic info about the "
54 "loaded build config, including available targets."); 54 "loaded build config, including available targets.");
55 addOption( slot( this, &Options::onListPlugins), "list-plugins", 55 addOption( slot( this, &Options::onListPlugins), "list-plugins",
56 "List all available plugins."); 56 "List all available plugins.");
57 addHelpOption(); 57 addHelpOption();
58 58
59 addHelpBanner("\nThe following options control general execution:"); 59 addHelpBanner("\nThe following options control general execution:");
60 addOption( sView, 'v', "view", sViews ); 60 addOption( sView, 'v', "view", sViews );
61 addOption( sConfig, 'f', "file", "Select a different config file." ); 61 addOption( sConfig, 'f', "file", "Select a different config file." );
62 addOption( bClean, 'c', "Shorthand for running action 'clean'. If an " 62 addOption( bClean, 'c', "Shorthand for running action 'clean'. If an "
63 "action is specified, this will modify it to run 'clean-action'."); 63 "action is specified, this will modify it to run 'clean-action'.");
64 addOption( slot(this, &Options::onChdir), 'C', "chdir", 64 addOption( slot(this, &Options::onChdir), 'C', "chdir",
65 "Change to directory before doing anything else."); 65 "Change to directory before doing anything else.");
66 addOption( sCacheFile, "cache", "Select a different cache file."); 66 addOption( sCacheFile, "cache", "Select a different cache file.");
67 addOption( bCache, "no-cache", "Disable using the cache."); 67 addOption( bCache, "no-cache", "Disable using the cache.");
68 68
69 addHelpBanner("\nThe following options control debugging:"); 69 addHelpBanner("\nThe following options control debugging:");
70 addOption( bEnviron, "no-env", "Do not import environment variables."); 70 addOption( bEnviron, "no-env", "Do not import environment variables.");
71 addOption( bDot, "dot", "Generate a dot chart after execution." ); 71 addOption( bDot, "dot", "Generate a dot chart after execution." );
72 addOption( bDebug, "debug", 72 addOption( bDebug, "debug",
73 "Dump massive amounts of hard to read debugging data." ); 73 "Dump massive amounts of hard to read debugging data." );
74 addOption( bAstDump, "debug-ast", 74 addOption( bAstDump, "debug-ast",
75 "Display the raw AST that is computed from parsing the input. " 75 "Display the raw AST that is computed from parsing the input. "
76 "You should probably never ever use this, it'll scare you." 76 "You should probably never ever use this, it'll scare you."
77 ); 77 );
78 78
79 setHelpDefault( "view", "=[view]" ); 79 setHelpDefault( "view", "=[view]" );
80 setHelpDefault( "file", "=[file]" ); 80 setHelpDefault( "file", "=[file]" );
81 setHelpDefault( "cache", "=[file]" ); 81 setHelpDefault( "cache", "=[file]" );
82 setHelpDefault( "chdir", "=[dir]" ); 82 setHelpDefault( "chdir", "=[dir]" );
83 83
84 setOverride( "no-env", "false" ); 84 setOverride( "no-env", "false" );
85 setOverride( "dot", "true" ); 85 setOverride( "dot", "true" );
86 setOverride( "debug", "true" ); 86 setOverride( "debug", "true" );
87 setOverride( "debug-ast", "true" ); 87 setOverride( "debug-ast", "true" );
88 setOverride( "info", "1" ); 88 setOverride( "info", "1" );
89 setOverride( 'c', "true" ); 89 setOverride( 'c', "true" );
90 setOverride( "no-cache", "false" ); 90 setOverride( "no-cache", "false" );
91 91
92 setNonOption( slot( this, &Options::onNonOption ) ); 92 setNonOption( slot( this, &Options::onNonOption ) );
93 93
94 parse( argc, argv ); 94 parse( argc, argv );
95 95
96 if( bClean ) 96 if( bClean )
97 { 97 {
98 if( sAction == "default" ) 98 if( sAction == "default" )
99 sAction = "clean"; 99 sAction = "clean";
100 else 100 else
101 sAction.prepend("clean-"); 101 sAction.prepend("clean-");
102 } 102 }
103 } 103 }
104 104
105 virtual ~Options() 105 virtual ~Options()
106 { 106 {
107 } 107 }
108 108
109 int onChdir( StrArray sParams ) 109 int onChdir( StrArray sParams )
110 { 110 {
111 if( sParams.getSize() == 0 ) 111 if( sParams.getSize() == 0 )
112 { 112 {
113 sio << "You must specify a directory name!" << sio.nl << sio.nl; 113 sio << "You must specify a directory name!" << sio.nl << sio.nl;
114 exit(2); 114 exit(2);
115 } 115 }
116 chdir( sParams[1].getStr() ); 116 chdir( sParams[1].getStr() );
117 return 1; 117 return 1;
118 } 118 }
119 119
120 int onNonOption( StrArray sParams ) 120 int onNonOption( StrArray sParams )
121 { 121 {
122 sAction = sParams[0]; 122 sAction = sParams[0];
123 return 0; 123 return 0;
124 } 124 }
125 125
126 int onListPlugins( StrArray /*sParams*/ ) 126 int onListPlugins( StrArray /*sParams*/ )
127 { 127 {
128 StrList lViews = ViewPlugger::getInstance().getPluginList(); 128 StrList lViews = ViewPlugger::getInstance().getPluginList();
129 sio << "Available view plugins:" << sio.nl << "\t"; 129 sio << "Available view plugins:" << sio.nl << "\t";
130 for( StrList::iterator i = lViews.begin(); i; i++ ) 130 for( StrList::iterator i = lViews.begin(); i; i++ )
131 { 131 {
132 if( i != lViews.begin() ) 132 if( i != lViews.begin() )
133 sio << ", "; 133 sio << ", ";
134 sio << *i; 134 sio << *i;
135 } 135 }
136 136
137 StrList lFuncs = FunctionPlugger::getInstance().getPluginList(); 137 StrList lFuncs = FunctionPlugger::getInstance().getPluginList();
138 sio << sio.nl << sio.nl << "Available function plugins:" 138 sio << sio.nl << sio.nl << "Available function plugins:"
139 << sio.nl << "\t"; 139 << sio.nl << "\t";
140 for( StrList::iterator i = lFuncs.begin(); i; i++ ) 140 for( StrList::iterator i = lFuncs.begin(); i; i++ )
141 { 141 {
142 if( i != lFuncs.begin() ) 142 if( i != lFuncs.begin() )
143 sio << ", "; 143 sio << ", ";
144 sio << *i; 144 sio << *i;
145 } 145 }
146 146
147 StrList lConds = ConditionPlugger::getInstance().getPluginList(); 147 StrList lConds = ConditionPlugger::getInstance().getPluginList();
148 sio << sio.nl << sio.nl << "Available condition plugins:" 148 sio << sio.nl << sio.nl << "Available condition plugins:"
149 << sio.nl << "\t"; 149 << sio.nl << "\t";
150 for( StrList::iterator i = lConds.begin(); i; i++ ) 150 for( StrList::iterator i = lConds.begin(); i; i++ )
151 { 151 {
152 if( i != lConds.begin() ) 152 if( i != lConds.begin() )
153 sio << ", "; 153 sio << ", ";
154 sio << *i; 154 sio << *i;
155 } 155 }
156 156
157 sio << sio.nl << sio.nl; 157 sio << sio.nl << sio.nl;
158 158
159 return 0; 159 return 0;
160 } 160 }
161 161
162 Bu::String sView; 162 Bu::String sView;
163 Bu::String sAction; 163 Bu::String sAction;
164 Bu::String sConfig; 164 Bu::String sConfig;
165 Bu::String sCacheFile; 165 Bu::String sCacheFile;
166 bool bDot; 166 bool bDot;
167 bool bDebug; 167 bool bDebug;
168 bool bAutoInclude; 168 bool bAutoInclude;
169 bool bAstDump; 169 bool bAstDump;
170 bool bEnviron; 170 bool bEnviron;
171 bool bCache; 171 bool bCache;
172 int iInfoLevel; 172 int iInfoLevel;
173}; 173};
174 174
175int main( int argc, char *argv[] ) 175int main( int argc, char *argv[] )
176{ 176{
177 typedef Bu::List<Bu::String> StrList; 177 typedef Bu::List<Bu::String> StrList;
178 StrList lShareList; 178 StrList lShareList;
179 lShareList.append("/usr/share/build/").append("./share/"); 179 lShareList.append("/usr/share/build/").append("./share/");
180 Ast ast; 180 Ast ast;
181 Context cnt; 181 Context cnt;
182 BuildParser bp( ast ); 182 BuildParser bp( ast );
183 183
184 for( StrList::iterator i = lShareList.begin(); i; i++ ) 184 for( StrList::iterator i = lShareList.begin(); i; i++ )
185 { 185 {
186 bp.addIncludePath( *i + "include"); 186 bp.addIncludePath( *i + "include");
187 } 187 }
188 188
189 Options opts( argc, argv ); 189 Options opts( argc, argv );
190 190
191 try 191 try
192 { 192 {
193 cnt.setView( ViewPlugger::getInstance().instantiate( opts.sView ) ); 193 cnt.setView( ViewPlugger::getInstance().instantiate( opts.sView ) );
194 } 194 }
195 catch( Bu::HashException &e ) 195 catch( Bu::HashException &e )
196 { 196 {
197 sio << "Error: Invalid view specified, please choose from the " 197 sio << "Error: Invalid view specified, please choose from the "
198 "following choices:" << sio.nl << sio.nl << "\t"; 198 "following choices:" << sio.nl << sio.nl << "\t";
199 199
200 StrList lViews = ViewPlugger::getInstance().getPluginList(); 200 StrList lViews = ViewPlugger::getInstance().getPluginList();
201 for( StrList::iterator i = lViews.begin(); i; i++ ) 201 for( StrList::iterator i = lViews.begin(); i; i++ )
202 { 202 {
203 if( i != lViews.begin() ) 203 if( i != lViews.begin() )
204 sio << ", "; 204 sio << ", ";
205 sio << *i; 205 sio << *i;
206 } 206 }
207 sio << sio.nl << sio.nl; 207 sio << sio.nl << sio.nl;
208 return 1; 208 return 1;
209 } 209 }
210 210
211 if( opts.bCache ) 211 if( opts.bCache )
212 { 212 {
213 Cache::getInstance().bind( opts.sCacheFile ); 213 Cache::getInstance().bind( opts.sCacheFile );
214 } 214 }
215 215
216 // Load up the environment as vars. 216 // Load up the environment as vars.
217 if( opts.bEnviron ) 217 if( opts.bEnviron )
218 { 218 {
219 for( char **env = environ; *env; env++ ) 219 for( char **env = environ; *env; env++ )
220 { 220 {
221 int iSplit; 221 int iSplit;
222 for( iSplit = 0; (*env)[iSplit] != '='; iSplit++ ) { } 222 for( iSplit = 0; (*env)[iSplit] != '='; iSplit++ ) { }
223 cnt.addVariable( 223 cnt.addVariable(
224 String( *env, iSplit ), 224 String( *env, iSplit ),
225 String( *env+iSplit+1 ) 225 String( *env+iSplit+1 )
226 ); 226 );
227 } 227 }
228 } 228 }
229 229
230 if( opts.bAutoInclude ) 230 if( opts.bAutoInclude )
231 { 231 {
232 DIR *d; 232 DIR *d;
233 Bu::String sAutoDir; 233 Bu::String sAutoDir;
234 for( StrList::iterator i = lShareList.begin(); i; i++ ) 234 for( StrList::iterator i = lShareList.begin(); i; i++ )
235 { 235 {
236 sAutoDir = *i + "autoinclude"; 236 sAutoDir = *i + "autoinclude";
237 d = opendir( sAutoDir.getStr() ); 237 d = opendir( sAutoDir.getStr() );
238 if( d ) 238 if( d )
239 break; 239 break;
240 } 240 }
241 if( !d ) 241 if( !d )
242 { 242 {
243 cnt.getView()->sysWarning( 243 cnt.getView()->sysWarning(
244 "Could not find an autoinclude directory." 244 "Could not find an autoinclude directory."
245 ); 245 );
246 } 246 }
247 else 247 else
248 { 248 {
249 struct dirent *de; 249 struct dirent *de;
250 while( (de = readdir( d )) ) 250 while( (de = readdir( d )) )
251 { 251 {
252 if( de->d_name[0] == '.' || (de->d_type != DT_REG) ) 252 if( de->d_name[0] == '.' || (de->d_type != DT_REG) )
253 continue; 253 continue;
254 //sio << "Auto-including: " << de->d_name << sio.nl; 254 //sio << "Auto-including: " << de->d_name << sio.nl;
255 bp.load( sAutoDir + "/" + de->d_name ); 255 bp.load( sAutoDir + "/" + de->d_name );
256 } 256 }
257 } 257 }
258 } 258 }
259 259
260 bp.load( opts.sConfig ); 260 bp.load( opts.sConfig );
261 261
262 if( opts.bAstDump ) 262 if( opts.bAstDump )
263 { 263 {
264 sio << ast << sio.nl << sio.nl; 264 sio << ast << sio.nl << sio.nl;
265 return 0; 265 return 0;
266 } 266 }
267 267
268// sio << ast << sio.nl; 268// sio << ast << sio.nl;
269 269
270 Runner r( ast, cnt ); 270 Runner r( ast, cnt );
271 r.initialize(); 271 r.initialize();
272 272
273 r.run(); 273 r.run();
274 274
275 switch( opts.iInfoLevel ) 275 switch( opts.iInfoLevel )
276 { 276 {
277 case 0: 277 case 0:
278 // Do nothing 278 // Do nothing
279 break; 279 break;
280 280
281 case 1: 281 case 1:
282 cnt.printBasicInfo(); 282 cnt.printBasicInfo();
283 return 0; 283 return 0;
284 } 284 }
285 285
286 try 286 try
287 { 287 {
288 r.execAction( opts.sAction ); 288 r.execAction( opts.sAction );
289 } 289 }
290 catch( std::exception &e ) 290 catch( std::exception &e )
291 { 291 {
292 cnt.getView()->sysError(e.what()); 292 cnt.getView()->sysError(e.what());
293 } 293 }
294 catch( ... ) 294 catch( ... )
295 { 295 {
296 cnt.getView()->sysError( 296 cnt.getView()->sysError(
297 "Unknown error occured, this is probably bad..." 297 "Unknown error occured, this is probably bad..."
298 ); 298 );
299 } 299 }
300 300
301 if( opts.bDot ) 301 if( opts.bDot )
302 { 302 {
303 cnt.writeTargetDot(); 303 cnt.writeTargetDot();
304 } 304 }
305 305
306 if( opts.bDebug ) 306 if( opts.bDebug )
307 { 307 {
308 sio << "Final context:" << sio.nl << cnt << sio.nl << sio.nl; 308 sio << "Final context:" << sio.nl << cnt << sio.nl << sio.nl;
309 } 309 }
310 310
311 return 0; 311 return 0;
312} 312}
313 313
diff --git a/src/plugins/pluginConditionRandom.cpp b/src/plugins/pluginConditionRandom.cpp
index 42a4e00..facd201 100644
--- a/src/plugins/pluginConditionRandom.cpp
+++ b/src/plugins/pluginConditionRandom.cpp
@@ -4,28 +4,28 @@
4class ConditionRandom : public Condition 4class ConditionRandom : public Condition
5{ 5{
6public: 6public:
7 ConditionRandom() 7 ConditionRandom()
8 { 8 {
9 } 9 }
10 10
11 virtual ~ConditionRandom() 11 virtual ~ConditionRandom()
12 { 12 {
13 } 13 }
14 14
15 virtual bool shouldExec( class Runner &, class Target & ) 15 virtual bool shouldExec( class Runner &, class Target & )
16 { 16 {
17 if( (random()/(double)RAND_MAX) >= .5 ) 17 if( (random()/(double)RAND_MAX) >= .5 )
18 return true; 18 return true;
19 return false; 19 return false;
20 } 20 }
21 21
22 virtual Condition *clone() 22 virtual Condition *clone()
23 { 23 {
24 return new ConditionRandom(); 24 return new ConditionRandom();
25 } 25 }
26}; 26};
27 27
28#include <bu/plugger.h> 28#include <bu/plugger.h>
29PluginInterface3( pluginConditionRandom, random, ConditionRandom, Condition, 29PluginInterface3( pluginConditionRandom, random, ConditionRandom, Condition,
30 "Mike Buland", 0, 1 ); 30 "Mike Buland", 0, 1 );
31 31
diff --git a/src/profile.cpp b/src/profile.cpp
index a9c1d5b..20251c3 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -10,92 +10,92 @@
10using namespace Bu; 10using namespace Bu;
11 11
12Profile::Profile( const class AstBranch *pRoot ) : 12Profile::Profile( const class AstBranch *pRoot ) :
13 pRoot( pRoot ), 13 pRoot( pRoot ),
14 pCond( NULL ), 14 pCond( NULL ),
15 pAst( NULL ) 15 pAst( NULL )
16{ 16{
17 sName = dynamic_cast<const AstLeaf *>( 17 sName = dynamic_cast<const AstLeaf *>(
18 (*pRoot->getBranchBegin()).first() 18 (*pRoot->getBranchBegin()).first()
19 )->getStrValue(); 19 )->getStrValue();
20 20
21 setCondition(); 21 setCondition();
22} 22}
23 23
24Profile::Profile( const Profile &rSrc ) : 24Profile::Profile( const Profile &rSrc ) :
25 sName( rSrc.sName ), 25 sName( rSrc.sName ),
26 pRoot( rSrc.pRoot ), 26 pRoot( rSrc.pRoot ),
27 pCond( rSrc.pCond->clone() ), 27 pCond( rSrc.pCond->clone() ),
28 pAst( NULL ) 28 pAst( NULL )
29{ 29{
30} 30}
31 31
32Profile::~Profile() 32Profile::~Profile()
33{ 33{
34 delete pAst; 34 delete pAst;
35 pAst = NULL; 35 pAst = NULL;
36} 36}
37 37
38const Bu::String &Profile::getName() const 38const Bu::String &Profile::getName() const
39{ 39{
40 return sName; 40 return sName;
41} 41}
42 42
43const AstBranch *Profile::getRoot() const 43const AstBranch *Profile::getRoot() const
44{ 44{
45 return pRoot; 45 return pRoot;
46} 46}
47 47
48const Condition *Profile::getCond() const 48const Condition *Profile::getCond() const
49{ 49{
50 return pCond; 50 return pCond;
51} 51}
52 52
53bool Profile::shouldExec( class Runner &r, class Target &rTarget ) const 53bool Profile::shouldExec( class Runner &r, class Target &rTarget ) const
54{ 54{
55 return pCond->shouldExec( r, rTarget ); 55 return pCond->shouldExec( r, rTarget );
56} 56}
57 57
58Profile *Profile::genDefaultClean() 58Profile *Profile::genDefaultClean()
59{ 59{
60 Ast *pAst = new Ast(); 60 Ast *pAst = new Ast();
61 pAst->addNode( AstNode::typeProfile ); 61 pAst->addNode( AstNode::typeProfile );
62 pAst->openBranch(); 62 pAst->openBranch();
63 pAst->addNode( AstNode::typeString, "clean" ); 63 pAst->addNode( AstNode::typeString, "clean" );
64 pAst->openBranch(); 64 pAst->openBranch();
65 pAst->addNode( AstNode::typeCondition, "fileExists" ); 65 pAst->addNode( AstNode::typeCondition, "fileExists" );
66 pAst->addNode( AstNode::typeFunction ); 66 pAst->addNode( AstNode::typeFunction );
67 pAst->openBranch(); 67 pAst->openBranch();
68 pAst->addNode( AstNode::typeString, "unlink" ); 68 pAst->addNode( AstNode::typeString, "unlink" );
69 pAst->openBranch(); 69 pAst->openBranch();
70 pAst->addNode( AstNode::typeVariable, "OUTPUT" ); 70 pAst->addNode( AstNode::typeVariable, "OUTPUT" );
71 pAst->closeNode(); 71 pAst->closeNode();
72 pAst->closeNode(); 72 pAst->closeNode();
73 //pAst->closeNode(); 73 //pAst->closeNode();
74 Profile *pRet = new Profile( 74 Profile *pRet = new Profile(
75 dynamic_cast<const AstBranch *>(*pAst->getNodeBegin()) 75 dynamic_cast<const AstBranch *>(*pAst->getNodeBegin())
76 ); 76 );
77 pRet->pAst = pAst; 77 pRet->pAst = pAst;
78 78
79 return pRet; 79 return pRet;
80} 80}
81 81
82void Profile::setCondition() 82void Profile::setCondition()
83{ 83{
84 for( AstBranch::NodeList::const_iterator i = 84 for( AstBranch::NodeList::const_iterator i =
85 (*(pRoot->getBranchBegin()+1)).begin(); i; i++ ) 85 (*(pRoot->getBranchBegin()+1)).begin(); i; i++ )
86 { 86 {
87 if( (*i)->getType() == AstNode::typeCondition ) 87 if( (*i)->getType() == AstNode::typeCondition )
88 { 88 {
89 Bu::String sCond = dynamic_cast<const AstLeaf *>(*i)->getStrValue(); 89 Bu::String sCond = dynamic_cast<const AstLeaf *>(*i)->getStrValue();
90 delete pCond; 90 delete pCond;
91 pCond = ConditionPlugger::getInstance().instantiate( sCond ); 91 pCond = ConditionPlugger::getInstance().instantiate( sCond );
92 } 92 }
93 } 93 }
94 94
95 if( pCond == NULL ) 95 if( pCond == NULL )
96 { 96 {
97 // The default condition 97 // The default condition
98 pCond = ConditionPlugger::getInstance().instantiate("fileTime"); 98 pCond = ConditionPlugger::getInstance().instantiate("fileTime");
99 } 99 }
100} 100}
101 101
diff --git a/src/profile.h b/src/profile.h
index 4f89306..8490121 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -6,25 +6,25 @@
6class Profile 6class Profile
7{ 7{
8public: 8public:
9 Profile( const class AstBranch *pRoot ); 9 Profile( const class AstBranch *pRoot );
10 Profile( const Profile &rSrc ); 10 Profile( const Profile &rSrc );
11 virtual ~Profile(); 11 virtual ~Profile();
12 12
13 const Bu::String &getName() const; 13 const Bu::String &getName() const;
14 const class AstBranch *getRoot() const; 14 const class AstBranch *getRoot() const;
15 const class Condition *getCond() const; 15 const class Condition *getCond() const;
16 bool shouldExec( class Runner &r, class Target &rTarget ) const; 16 bool shouldExec( class Runner &r, class Target &rTarget ) const;
17 17
18 static Profile *genDefaultClean(); 18 static Profile *genDefaultClean();
19 19
20private: 20private:
21 void setCondition(); 21 void setCondition();
22 22
23private: 23private:
24 Bu::String sName; 24 Bu::String sName;
25 const class AstBranch *pRoot; 25 const class AstBranch *pRoot;
26 class Condition *pCond; 26 class Condition *pCond;
27 class Ast *pAst; 27 class Ast *pAst;
28}; 28};
29 29
30#endif 30#endif
diff --git a/src/rule.cpp b/src/rule.cpp
index 81e775e..15b2388 100644
--- a/src/rule.cpp
+++ b/src/rule.cpp
@@ -12,8 +12,8 @@
12using namespace Bu; 12using namespace Bu;
13 13
14Rule::Rule( const Bu::String &sName ) : 14Rule::Rule( const Bu::String &sName ) :
15 sName( sName ), 15 sName( sName ),
16 pInput( NULL ) 16 pInput( NULL )
17{ 17{
18} 18}
19 19
@@ -23,146 +23,146 @@ Rule::~Rule()
23 23
24const Bu::String &Rule::getName() const 24const Bu::String &Rule::getName() const
25{ 25{
26 return sName; 26 return sName;
27} 27}
28 28
29void Rule::setInput( const AstBranch *pNewInput ) 29void Rule::setInput( const AstBranch *pNewInput )
30{ 30{
31 pInput = pNewInput; 31 pInput = pNewInput;
32} 32}
33 33
34const AstBranch *Rule::getInput() const 34const AstBranch *Rule::getInput() const
35{ 35{
36 return pInput; 36 return pInput;
37} 37}
38 38
39bool Rule::hasOutputs() const 39bool Rule::hasOutputs() const
40{ 40{
41 return !lOutput.isEmpty(); 41 return !lOutput.isEmpty();
42} 42}
43 43
44void Rule::addOutput( const AstBranch *pNewOutput ) 44void Rule::addOutput( const AstBranch *pNewOutput )
45{ 45{
46 lOutput.append( pNewOutput ); 46 lOutput.append( pNewOutput );
47} 47}
48 48
49void Rule::addProfile( const AstBranch *pProfRoot ) 49void Rule::addProfile( const AstBranch *pProfRoot )
50{ 50{
51 Profile *pProf = new Profile( pProfRoot ); 51 Profile *pProf = new Profile( pProfRoot );
52 hProfiles.insert( pProf->getName(), pProf ); 52 hProfiles.insert( pProf->getName(), pProf );
53 /* 53 /*
54 hProfiles.insert( 54 hProfiles.insert(
55 dynamic_cast<const AstLeaf *>( 55 dynamic_cast<const AstLeaf *>(
56 (*pProfile->getBranchBegin()).first() 56 (*pProfile->getBranchBegin()).first()
57 )->getStrValue(), 57 )->getStrValue(),
58 pProfile 58 pProfile
59 ); 59 );
60 */ 60 */
61} 61}
62 62
63void Rule::prepTarget( class Target *pTarget ) 63void Rule::prepTarget( class Target *pTarget )
64{ 64{
65 pTarget->setDisplay( getDisplay() ); 65 pTarget->setDisplay( getDisplay() );
66 for( ProfileHash::iterator i = hProfiles.begin(); i; i++ ) 66 for( ProfileHash::iterator i = hProfiles.begin(); i; i++ )
67 { 67 {
68 pTarget->addProfile( *i ); 68 pTarget->addProfile( *i );
69 } 69 }
70 for( AstBranchList::iterator i = lRequires.begin(); i; i++ ) 70 for( AstBranchList::iterator i = lRequires.begin(); i; i++ )
71 { 71 {
72 pTarget->addRequires( *i ); 72 pTarget->addRequires( *i );
73 } 73 }
74} 74}
75 75
76Target *Rule::createTarget( class Runner &r, const Bu::String &sInput, 76Target *Rule::createTarget( class Runner &r, const Bu::String &sInput,
77 Target *pParent ) 77 Target *pParent )
78{ 78{
79 r.getContext().pushScope( pParent->getVars() ); 79 r.getContext().pushScope( pParent->getVars() );
80 r.getContext().addVariable("INPUT", sInput ); 80 r.getContext().addVariable("INPUT", sInput );
81 Target *pTrg = new Target( false ); 81 Target *pTrg = new Target( false );
82 for( AstBranchList::iterator i = lOutput.begin(); i; i++ ) 82 for( AstBranchList::iterator i = lOutput.begin(); i; i++ )
83 { 83 {
84 Variable vOut = r.execExpr( 84 Variable vOut = r.execExpr(
85 (*(*i)->getBranchBegin()).begin(), 85 (*(*i)->getBranchBegin()).begin(),
86 Variable( sInput ) 86 Variable( sInput )
87 ); 87 );
88 if( vOut.getType() == Variable::typeString ) 88 if( vOut.getType() == Variable::typeString )
89 { 89 {
90 pTrg->addOutput( vOut.getString() ); 90 pTrg->addOutput( vOut.getString() );
91 } 91 }
92 else if( vOut.getType() == Variable::typeList ) 92 else if( vOut.getType() == Variable::typeList )
93 { 93 {
94 for( VarList::iterator j = vOut.begin(); j; j++ ) 94 for( VarList::iterator j = vOut.begin(); j; j++ )
95 { 95 {
96 pTrg->addOutput( (*j).getString() ); 96 pTrg->addOutput( (*j).getString() );
97 } 97 }
98 } 98 }
99 } 99 }
100 r.getContext().addVariable("OUTPUT", pTrg->getOutputList() ); 100 r.getContext().addVariable("OUTPUT", pTrg->getOutputList() );
101 pTrg->addInput( sInput ); 101 pTrg->addInput( sInput );
102 pTrg->setDisplay( getDisplay() ); 102 pTrg->setDisplay( getDisplay() );
103 for( ProfileHash::iterator i = hProfiles.begin(); i; i++ ) 103 for( ProfileHash::iterator i = hProfiles.begin(); i; i++ )
104 { 104 {
105 pTrg->addProfile( *i ); 105 pTrg->addProfile( *i );
106 } 106 }
107 for( AstBranchList::iterator i = lRequires.begin(); i; i++ ) 107 for( AstBranchList::iterator i = lRequires.begin(); i; i++ )
108 { 108 {
109 pTrg->addRequires( *i ); 109 pTrg->addRequires( *i );
110 } 110 }
111 pTrg->setVars( r.getContext().getScope() ); 111 pTrg->setVars( r.getContext().getScope() );
112 r.getContext().popScope(); 112 r.getContext().popScope();
113 113
114 return pTrg; 114 return pTrg;
115} 115}
116 116
117bool Rule::ruleMatches( Runner &r, const Bu::String &sInput ) 117bool Rule::ruleMatches( Runner &r, const Bu::String &sInput )
118{ 118{
119 r.getContext().pushScope(); 119 r.getContext().pushScope();
120 r.getContext().addVariable("INPUT", sInput ); 120 r.getContext().addVariable("INPUT", sInput );
121 Variable vInput( sInput ); 121 Variable vInput( sInput );
122 Variable vOut = r.execExpr( 122 Variable vOut = r.execExpr(
123 (*pInput->getBranchBegin()).begin(), 123 (*pInput->getBranchBegin()).begin(),
124 vInput 124 vInput
125 ); 125 );
126 r.getContext().popScope(); 126 r.getContext().popScope();
127 if( vOut.getType() == Variable::typeBool ) 127 if( vOut.getType() == Variable::typeBool )
128 return vOut.getBool(); 128 return vOut.getBool();
129 else if( vOut.getType() == Variable::typeList ) 129 else if( vOut.getType() == Variable::typeList )
130 return vOut.begin(); 130 return vOut.begin();
131 return false; 131 return false;
132} 132}
133 133
134void Rule::addTag( const Bu::String &sTag ) 134void Rule::addTag( const Bu::String &sTag )
135{ 135{
136 lsTags.append( sTag ); 136 lsTags.append( sTag );
137} 137}
138 138
139const StrList &Rule::getTagList() const 139const StrList &Rule::getTagList() const
140{ 140{
141 return lsTags; 141 return lsTags;
142} 142}
143 143
144void Rule::setDisplay( const Bu::String &sStr ) 144void Rule::setDisplay( const Bu::String &sStr )
145{ 145{
146 sDisplay = sStr; 146 sDisplay = sStr;
147} 147}
148 148
149const Bu::String &Rule::getDisplay() const 149const Bu::String &Rule::getDisplay() const
150{ 150{
151 return (sDisplay.isSet())?(sDisplay):(sName); 151 return (sDisplay.isSet())?(sDisplay):(sName);
152} 152}
153 153
154void Rule::addRequires( const AstBranch *pBr ) 154void Rule::addRequires( const AstBranch *pBr )
155{ 155{
156 lRequires.append( pBr ); 156 lRequires.append( pBr );
157} 157}
158 158
159Bu::Formatter &operator<<( Bu::Formatter &f, const Rule &/*t*/ ) 159Bu::Formatter &operator<<( Bu::Formatter &f, const Rule &/*t*/ )
160{ 160{
161 return f << "rule"; 161 return f << "rule";
162} 162}
163 163
164template<> Bu::Formatter &Bu::operator<< <Rule>( Bu::Formatter &f, const Rule *t ) 164template<> Bu::Formatter &Bu::operator<< <Rule>( Bu::Formatter &f, const Rule *t )
165{ 165{
166 return f << (*t); 166 return f << (*t);
167} 167}
168 168
diff --git a/src/rule.h b/src/rule.h
index d8accf0..5e12a20 100644
--- a/src/rule.h
+++ b/src/rule.h
@@ -6,49 +6,49 @@
6 6
7class Rule 7class Rule
8{ 8{
9 friend Bu::Formatter &operator<<( Bu::Formatter &f, const Rule &t ); 9 friend Bu::Formatter &operator<<( Bu::Formatter &f, const Rule &t );
10public: 10public:
11 Rule( const Bu::String &sName ); 11 Rule( const Bu::String &sName );
12 virtual ~Rule(); 12 virtual ~Rule();
13 13
14 const Bu::String &getName() const; 14 const Bu::String &getName() const;
15 15
16 void setInput( const AstBranch *pNewInput ); 16 void setInput( const AstBranch *pNewInput );
17 const AstBranch *getInput() const; 17 const AstBranch *getInput() const;
18 18
19 bool hasOutputs() const; 19 bool hasOutputs() const;
20 20
21 void addOutput( const AstBranch *pNewOutput ); 21 void addOutput( const AstBranch *pNewOutput );
22 void addProfile( const AstBranch *pProfile ); 22 void addProfile( const AstBranch *pProfile );
23 23
24 void prepTarget( class Target *pTarget ); 24 void prepTarget( class Target *pTarget );
25 class Target *createTarget( class Runner &r, const Bu::String &sInput, 25 class Target *createTarget( class Runner &r, const Bu::String &sInput,
26 class Target *pParent ); 26 class Target *pParent );
27 bool ruleMatches( class Runner &r, const Bu::String &sInput ); 27 bool ruleMatches( class Runner &r, const Bu::String &sInput );
28 28
29 void addTag( const Bu::String &sTag ); 29 void addTag( const Bu::String &sTag );
30 const StrList &getTagList() const; 30 const StrList &getTagList() const;
31 31
32 void setDisplay( const Bu::String &sStr ); 32 void setDisplay( const Bu::String &sStr );
33 const Bu::String &getDisplay() const; 33 const Bu::String &getDisplay() const;
34 34
35 void addRequires( const AstBranch *pBr ); 35 void addRequires( const AstBranch *pBr );
36 36
37private: 37private:
38 Bu::String sName; 38 Bu::String sName;
39 Bu::String sDisplay; 39 Bu::String sDisplay;
40 const AstBranch *pInput; 40 const AstBranch *pInput;
41 AstBranchList lOutput; 41 AstBranchList lOutput;
42 ProfileHash hProfiles; 42 ProfileHash hProfiles;
43 StrList lsTags; 43 StrList lsTags;
44 AstBranchList lRequires; 44 AstBranchList lRequires;
45}; 45};
46 46
47Bu::Formatter &operator<<( Bu::Formatter &f, const Rule &t ); 47Bu::Formatter &operator<<( Bu::Formatter &f, const Rule &t );
48 48
49namespace Bu 49namespace Bu
50{ 50{
51 template<> Bu::Formatter &operator<< <Rule>( Bu::Formatter &f, const Rule *t ); 51 template<> Bu::Formatter &operator<< <Rule>( Bu::Formatter &f, const Rule *t );
52}; 52};
53 53
54#endif 54#endif
diff --git a/src/runner.cpp b/src/runner.cpp
index 64ad8e8..766a2f5 100644
--- a/src/runner.cpp
+++ b/src/runner.cpp
@@ -17,10 +17,10 @@
17using Bu::sio; 17using Bu::sio;
18 18
19Runner::Runner( Ast &rAst, Context &rCont ) : 19Runner::Runner( Ast &rAst, Context &rCont ) :
20 rAst( rAst ), 20 rAst( rAst ),
21 rCont( rCont ), 21 rCont( rCont ),
22 pCurTarget( NULL ), 22 pCurTarget( NULL ),
23 pCurRule( NULL ) 23 pCurRule( NULL )
24{ 24{
25} 25}
26 26
@@ -30,897 +30,897 @@ Runner::~Runner()
30 30
31void Runner::initialize() 31void Runner::initialize()
32{ 32{
33 for( Ast::NodeList::const_iterator i = rAst.getNodeBegin(); i; i++ ) 33 for( Ast::NodeList::const_iterator i = rAst.getNodeBegin(); i; i++ )
34 { 34 {
35 if( (*i)->getType() == AstNode::typeFunctionDef ) 35 if( (*i)->getType() == AstNode::typeFunctionDef )
36 { 36 {
37 AstBranch *pFnc = dynamic_cast<AstBranch *>(*i); 37 AstBranch *pFnc = dynamic_cast<AstBranch *>(*i);
38 rCont.addFunction( new FunctionAst( pFnc, this ) ); 38 rCont.addFunction( new FunctionAst( pFnc, this ) );
39 } 39 }
40 else if( (*i)->getType() == AstNode::typeActionDef ) 40 else if( (*i)->getType() == AstNode::typeActionDef )
41 { 41 {
42 AstBranch *pAction = dynamic_cast<AstBranch *>(*i); 42 AstBranch *pAction = dynamic_cast<AstBranch *>(*i);
43 rCont.addAction( new Action( pAction ) ); 43 rCont.addAction( new Action( pAction ) );
44 } 44 }
45 } 45 }
46} 46}
47 47
48Variable Runner::execFunc( const AstBranch *pFunc, Variable &vIn ) 48Variable Runner::execFunc( const AstBranch *pFunc, Variable &vIn )
49{ 49{
50 Bu::String sName = dynamic_cast<const AstLeaf *>( 50 Bu::String sName = dynamic_cast<const AstLeaf *>(
51 (*pFunc->getBranchBegin()).first())->getStrValue(); 51 (*pFunc->getBranchBegin()).first())->getStrValue();
52 52
53 VarList lParams; 53 VarList lParams;
54 for( AstBranch::BranchList::const_iterator p = 54 for( AstBranch::BranchList::const_iterator p =
55 pFunc->getBranchBegin()+1; p; p++ ) 55 pFunc->getBranchBegin()+1; p; p++ )
56 { 56 {
57 lParams.append( execExpr( (*p).begin() ) ); 57 lParams.append( execExpr( (*p).begin() ) );
58 } 58 }
59 59
60 return rCont.call( sName, vIn, lParams ); 60 return rCont.call( sName, vIn, lParams );
61} 61}
62 62
63Variable Runner::execExpr( AstBranch::NodeList::const_iterator e ) 63Variable Runner::execExpr( AstBranch::NodeList::const_iterator e )
64{ 64{
65 Variable vBlank; 65 Variable vBlank;
66 return execExpr( e, vBlank ); 66 return execExpr( e, vBlank );
67} 67}
68 68
69Variable Runner::execExpr( AstBranch::NodeList::const_iterator e, 69Variable Runner::execExpr( AstBranch::NodeList::const_iterator e,
70 const Variable &vIn ) 70 const Variable &vIn )
71{ 71{
72// Variable v( vIn ); 72// Variable v( vIn );
73 VarList lStack; 73 VarList lStack;
74 lStack.push( vIn ); 74 lStack.push( vIn );
75 75
76 for(; e; e++ ) 76 for(; e; e++ )
77 { 77 {
78 if( ((*e)->getType()&AstNode::typeClassMask) == AstNode::typeBranch ) 78 if( ((*e)->getType()&AstNode::typeClassMask) == AstNode::typeBranch )
79 { 79 {
80 const AstBranch *pBranch = dynamic_cast<const AstBranch *>( *e ); 80 const AstBranch *pBranch = dynamic_cast<const AstBranch *>( *e );
81 switch( pBranch->getType() ) 81 switch( pBranch->getType() )
82 { 82 {
83 case AstNode::typeFunction: 83 case AstNode::typeFunction:
84 //sio << "FUNC: " << *pBranch << sio.nl << sio.nl; 84 //sio << "FUNC: " << *pBranch << sio.nl << sio.nl;
85 { 85 {
86 Variable v = lStack.peekPop(); 86 Variable v = lStack.peekPop();
87 lStack.push( execFunc( pBranch, v ) ); 87 lStack.push( execFunc( pBranch, v ) );
88 } 88 }
89 break; 89 break;
90 90
91 case AstNode::typeSet: 91 case AstNode::typeSet:
92 lStack.push( doSet( pBranch ) ); 92 lStack.push( doSet( pBranch ) );
93 break; 93 break;
94 94
95 case AstNode::typeList: 95 case AstNode::typeList:
96 { 96 {
97 Variable vLst( Variable::typeList ); 97 Variable vLst( Variable::typeList );
98 for( AstBranch::BranchList::const_iterator i = 98 for( AstBranch::BranchList::const_iterator i =
99 pBranch->getBranchBegin(); i; i++ ) 99 pBranch->getBranchBegin(); i; i++ )
100 { 100 {
101 vLst.append( execExpr( (*i).begin() ) ); 101 vLst.append( execExpr( (*i).begin() ) );
102 } 102 }
103 lStack.push( vLst ); 103 lStack.push( vLst );
104 } 104 }
105 break; 105 break;
106 106
107 case AstNode::typeExpr: 107 case AstNode::typeExpr:
108 { 108 {
109 sio << "!!! typeExpr in an expr maybe should be an error..." << sio.nl; 109 sio << "!!! typeExpr in an expr maybe should be an error..." << sio.nl;
110 for( AstBranch::BranchList::const_iterator i = 110 for( AstBranch::BranchList::const_iterator i =
111 pBranch->getBranchBegin(); i; i++ ) 111 pBranch->getBranchBegin(); i; i++ )
112 { 112 {
113 lStack.push( 113 lStack.push(
114 execExpr( (*i).begin() ) // Are they atomic? 114 execExpr( (*i).begin() ) // Are they atomic?
115 ); 115 );
116 } 116 }
117 if( lStack.getSize() != 1 ) 117 if( lStack.getSize() != 1 )
118 { 118 {
119 throw Bu::ExceptionBase( 119 throw Bu::ExceptionBase(
120 "Something went wrong, expression processing " 120 "Something went wrong, expression processing "
121 "left %d elements on stack, should be 1.", 121 "left %d elements on stack, should be 1.",
122 lStack.getSize() ); 122 lStack.getSize() );
123 } 123 }
124 } 124 }
125 break; 125 break;
126 126
127 default: 127 default:
128 sio << "?? branch ???: " 128 sio << "?? branch ???: "
129 << (pBranch)->getType(); 129 << (pBranch)->getType();
130 break; 130 break;
131 } 131 }
132 } 132 }
133 else 133 else
134 { 134 {
135 const AstLeaf *pLeaf = dynamic_cast<const AstLeaf *>( *e ); 135 const AstLeaf *pLeaf = dynamic_cast<const AstLeaf *>( *e );
136 switch( pLeaf->getType() ) 136 switch( pLeaf->getType() )
137 { 137 {
138 case AstNode::typeVariable: 138 case AstNode::typeVariable:
139 try 139 try
140 { 140 {
141 lStack.push( 141 lStack.push(
142 rCont.getVariable( pLeaf->getStrValue() ) 142 rCont.getVariable( pLeaf->getStrValue() )
143 ); 143 );
144 } 144 }
145 catch(...) 145 catch(...)
146 { 146 {
147 lStack.push( Variable() ); 147 lStack.push( Variable() );
148 } 148 }
149 break; 149 break;
150 150
151 case AstNode::typeVariableRef: 151 case AstNode::typeVariableRef:
152 lStack.push( 152 lStack.push(
153 Variable::mkRef( pLeaf->getStrValue() ) 153 Variable::mkRef( pLeaf->getStrValue() )
154 ); 154 );
155 break; 155 break;
156 156
157 case AstNode::typeString: 157 case AstNode::typeString:
158 lStack.push( 158 lStack.push(
159 rCont.expand( pLeaf->getStrValue() ) 159 rCont.expand( pLeaf->getStrValue() )
160 ); 160 );
161 break; 161 break;
162 162
163 case AstNode::typeInt: 163 case AstNode::typeInt:
164 lStack.push( 164 lStack.push(
165 pLeaf->getIntValue() 165 pLeaf->getIntValue()
166 ); 166 );
167 break; 167 break;
168 168
169 case AstNode::typeFloat: 169 case AstNode::typeFloat:
170 lStack.push( 170 lStack.push(
171 pLeaf->getFloatValue() 171 pLeaf->getFloatValue()
172 ); 172 );
173 break; 173 break;
174 174
175 case AstNode::typeBool: 175 case AstNode::typeBool:
176 lStack.push( 176 lStack.push(
177 pLeaf->getBoolValue() 177 pLeaf->getBoolValue()
178 ); 178 );
179 break; 179 break;
180 180
181 case AstNode::typeVersion: 181 case AstNode::typeVersion:
182 break; 182 break;
183 183
184 case AstNode::typeNull: 184 case AstNode::typeNull:
185 lStack.push( 185 lStack.push(
186 Variable() 186 Variable()
187 ); 187 );
188 break; 188 break;
189 189
190 case AstNode::typeCmpEq: 190 case AstNode::typeCmpEq:
191 { 191 {
192 Variable a, b; 192 Variable a, b;
193 a = lStack.peekPop(); 193 a = lStack.peekPop();
194 b = lStack.peekPop(); 194 b = lStack.peekPop();
195 lStack.push( Variable( a == b ) ); 195 lStack.push( Variable( a == b ) );
196 } 196 }
197 break; 197 break;
198 198
199 case AstNode::typeCmpLt: 199 case AstNode::typeCmpLt:
200 { 200 {
201 Variable a, b; 201 Variable a, b;
202 a = lStack.peekPop(); 202 a = lStack.peekPop();
203 b = lStack.peekPop(); 203 b = lStack.peekPop();
204 lStack.push( Variable( b < a ) ); 204 lStack.push( Variable( b < a ) );
205 } 205 }
206 break; 206 break;
207 207
208 case AstNode::typeCmpGt: 208 case AstNode::typeCmpGt:
209 { 209 {
210 Variable a, b; 210 Variable a, b;
211 a = lStack.peekPop(); 211 a = lStack.peekPop();
212 b = lStack.peekPop(); 212 b = lStack.peekPop();
213 lStack.push( Variable( b > a ) ); 213 lStack.push( Variable( b > a ) );
214 } 214 }
215 break; 215 break;
216 216
217 case AstNode::typeCmpNe: 217 case AstNode::typeCmpNe:
218 { 218 {
219 Variable a, b; 219 Variable a, b;
220 a = lStack.peekPop(); 220 a = lStack.peekPop();
221 b = lStack.peekPop(); 221 b = lStack.peekPop();
222 lStack.push( Variable( a != b ) ); 222 lStack.push( Variable( a != b ) );
223 } 223 }
224 break; 224 break;
225 225
226 case AstNode::typeCmpLtEq: 226 case AstNode::typeCmpLtEq:
227 { 227 {
228 Variable a, b; 228 Variable a, b;
229 a = lStack.peekPop(); 229 a = lStack.peekPop();
230 b = lStack.peekPop(); 230 b = lStack.peekPop();
231 lStack.push( Variable( b <= a ) ); 231 lStack.push( Variable( b <= a ) );
232 } 232 }
233 break; 233 break;
234 234
235 case AstNode::typeCmpGtEq: 235 case AstNode::typeCmpGtEq:
236 { 236 {
237 Variable a, b; 237 Variable a, b;
238 a = lStack.peekPop(); 238 a = lStack.peekPop();
239 b = lStack.peekPop(); 239 b = lStack.peekPop();
240 lStack.push( Variable( b >= a ) ); 240 lStack.push( Variable( b >= a ) );
241 } 241 }
242 break; 242 break;
243 243
244 case AstNode::typeOpEq: 244 case AstNode::typeOpEq:
245 { 245 {
246 Variable ref, val; 246 Variable ref, val;
247 val = lStack.peekPop(); 247 val = lStack.peekPop();
248 ref = lStack.peekPop(); 248 ref = lStack.peekPop();
249 rCont.addVariable( ref.getString(), val ); 249 rCont.addVariable( ref.getString(), val );
250 lStack.push( val ); 250 lStack.push( val );
251 } 251 }
252 break; 252 break;
253 253
254 case AstNode::typeOpPlusEq: 254 case AstNode::typeOpPlusEq:
255 { 255 {
256 Variable ref, val; 256 Variable ref, val;
257 val = lStack.peekPop(); 257 val = lStack.peekPop();
258 ref = lStack.peekPop(); 258 ref = lStack.peekPop();
259 try 259 try
260 { 260 {
261 Variable &nVal = rCont.getVariable( 261 Variable &nVal = rCont.getVariable(
262 ref.getString() 262 ref.getString()
263 ); 263 );
264 nVal += val; 264 nVal += val;
265 lStack.push( nVal ); 265 lStack.push( nVal );
266 } catch(...) 266 } catch(...)
267 { 267 {
268 rCont.addVariable( ref.getString(), val ); 268 rCont.addVariable( ref.getString(), val );
269 lStack.push( val ); 269 lStack.push( val );
270 } 270 }
271 } 271 }
272 break; 272 break;
273 273
274 case AstNode::typeOpPlusEqRaw: 274 case AstNode::typeOpPlusEqRaw:
275 { 275 {
276 Variable ref, val; 276 Variable ref, val;
277 val = lStack.peekPop(); 277 val = lStack.peekPop();
278 ref = lStack.peekPop(); 278 ref = lStack.peekPop();
279 try 279 try
280 { 280 {
281 Variable &nVal = rCont.getVariable( 281 Variable &nVal = rCont.getVariable(
282 ref.getString() 282 ref.getString()
283 ); 283 );
284 nVal << val; 284 nVal << val;
285 lStack.push( nVal ); 285 lStack.push( nVal );
286 } catch(...) 286 } catch(...)
287 { 287 {
288 rCont.addVariable( ref.getString(), val ); 288 rCont.addVariable( ref.getString(), val );
289 lStack.push( val ); 289 lStack.push( val );
290 } 290 }
291 } 291 }
292 break; 292 break;
293 293
294 case AstNode::typeOpPlus: 294 case AstNode::typeOpPlus:
295 { 295 {
296 Variable a, b; 296 Variable a, b;
297 a = lStack.peekPop(); 297 a = lStack.peekPop();
298 b = lStack.peekPop(); 298 b = lStack.peekPop();
299 lStack.push( Variable( b + a ) ); 299 lStack.push( Variable( b + a ) );
300 } 300 }
301 break; 301 break;
302 302
303 case AstNode::typeOpMinus: 303 case AstNode::typeOpMinus:
304 { 304 {
305 Variable a, b; 305 Variable a, b;
306 a = lStack.peekPop(); 306 a = lStack.peekPop();
307 b = lStack.peekPop(); 307 b = lStack.peekPop();
308 lStack.push( Variable( b - a ) ); 308 lStack.push( Variable( b - a ) );
309 } 309 }
310 break; 310 break;
311 311
312 case AstNode::typeOpMultiply: 312 case AstNode::typeOpMultiply:
313 { 313 {
314 Variable a, b; 314 Variable a, b;
315 a = lStack.peekPop(); 315 a = lStack.peekPop();
316 b = lStack.peekPop(); 316 b = lStack.peekPop();
317 lStack.push( Variable( b * a ) ); 317 lStack.push( Variable( b * a ) );
318 } 318 }
319 break; 319 break;
320 320
321 case AstNode::typeOpDivide: 321 case AstNode::typeOpDivide:
322 { 322 {
323 Variable a, b; 323 Variable a, b;
324 a = lStack.peekPop(); 324 a = lStack.peekPop();
325 b = lStack.peekPop(); 325 b = lStack.peekPop();
326 lStack.push( Variable( b / a ) ); 326 lStack.push( Variable( b / a ) );
327 } 327 }
328 break; 328 break;
329 329
330 case AstNode::typeOpNegate: 330 case AstNode::typeOpNegate:
331 lStack.peek().doNegate(); 331 lStack.peek().doNegate();
332 break; 332 break;
333 333
334 case AstNode::typeOpNot: 334 case AstNode::typeOpNot:
335 lStack.peek().doNot(); 335 lStack.peek().doNot();
336 break; 336 break;
337 337
338 default: 338 default:
339 sio << "?? leaf ???: " 339 sio << "?? leaf ???: "
340 << (pLeaf)->getType(); 340 << (pLeaf)->getType();
341 break; 341 break;
342 } 342 }
343 } 343 }
344 } 344 }
345 345
346 return lStack.peek(); 346 return lStack.peek();
347} 347}
348 348
349void Runner::run() 349void Runner::run()
350{ 350{
351 run( rAst.getNodeBegin() ); 351 run( rAst.getNodeBegin() );
352 352
353 rCont.buildTargetTree( *this ); 353 rCont.buildTargetTree( *this );
354 354
355 rCont.attachDefaults(); 355 rCont.attachDefaults();
356 rCont.genDefaultActions(); 356 rCont.genDefaultActions();
357 357
358// rCont.writeTargetDot(); 358// rCont.writeTargetDot();
359} 359}
360 360
361Variable Runner::run( AstBranch::NodeList::const_iterator n ) 361Variable Runner::run( AstBranch::NodeList::const_iterator n )
362{ 362{
363 /* Execute the top level code. */ 363 /* Execute the top level code. */
364 364
365 Variable vReturn; 365 Variable vReturn;
366 Bu::List<Ast::NodeList::const_iterator> sI; 366 Bu::List<Ast::NodeList::const_iterator> sI;
367 sI.push( n ); 367 sI.push( n );
368// for( Ast::NodeList::const_iterator i = rAst.getNodeBegin(); i; i++ ) 368// for( Ast::NodeList::const_iterator i = rAst.getNodeBegin(); i; i++ )
369 while( !sI.isEmpty() ) 369 while( !sI.isEmpty() )
370 { 370 {
371 while( !sI.isEmpty() && !(sI.peek()) ) 371 while( !sI.isEmpty() && !(sI.peek()) )
372 { 372 {
373 sI.pop(); 373 sI.pop();
374 } 374 }
375 if( sI.isEmpty() ) 375 if( sI.isEmpty() )
376 break; 376 break;
377 Ast::NodeList::const_iterator &i = sI.peek(); 377 Ast::NodeList::const_iterator &i = sI.peek();
378 if( ((*i)->getType()&AstNode::typeClassMask) == AstNode::typeLeaf ) 378 if( ((*i)->getType()&AstNode::typeClassMask) == AstNode::typeLeaf )
379 { 379 {
380 const AstLeaf *pExpr = dynamic_cast<const AstLeaf *>( *i ); 380 const AstLeaf *pExpr = dynamic_cast<const AstLeaf *>( *i );
381 switch( pExpr->getType() ) 381 switch( pExpr->getType() )
382 { 382 {
383 case AstNode::typeError: 383 case AstNode::typeError:
384 { 384 {
385 Bu::String sMsg = rCont.expand( pExpr->getStrValue() ); 385 Bu::String sMsg = rCont.expand( pExpr->getStrValue() );
386 rCont.getView()->userError( sMsg.getStr() ); 386 rCont.getView()->userError( sMsg.getStr() );
387 throw Bu::ExceptionBase( sMsg.getStr() ); 387 throw Bu::ExceptionBase( sMsg.getStr() );
388 } 388 }
389 break; 389 break;
390 390
391 case AstNode::typeWarning: 391 case AstNode::typeWarning:
392 rCont.getView()->userWarning( 392 rCont.getView()->userWarning(
393 rCont.expand( pExpr->getStrValue() ) 393 rCont.expand( pExpr->getStrValue() )
394 ); 394 );
395 break; 395 break;
396 396
397 case AstNode::typeNotice: 397 case AstNode::typeNotice:
398 rCont.getView()->userNotice( 398 rCont.getView()->userNotice(
399 rCont.expand( pExpr->getStrValue() ) 399 rCont.expand( pExpr->getStrValue() )
400 ); 400 );
401 break; 401 break;
402 402
403 case AstNode::typeCondition: 403 case AstNode::typeCondition:
404 break; 404 break;
405 405
406 case AstNode::typeDisplay: 406 case AstNode::typeDisplay:
407 if( pCurTarget ) 407 if( pCurTarget )
408 { 408 {
409 pCurTarget->setDisplay( 409 pCurTarget->setDisplay(
410 rCont.expand( pExpr->getStrValue() ) 410 rCont.expand( pExpr->getStrValue() )
411 ); 411 );
412 } 412 }
413 else if( pCurRule ) 413 else if( pCurRule )
414 { 414 {
415 pCurRule->setDisplay( 415 pCurRule->setDisplay(
416 rCont.expand( pExpr->getStrValue() ) 416 rCont.expand( pExpr->getStrValue() )
417 ); 417 );
418 } 418 }
419 break; 419 break;
420 420
421 case AstNode::typePushPrefix: 421 case AstNode::typePushPrefix:
422 case AstNode::typePopPrefix: 422 case AstNode::typePopPrefix:
423 break; 423 break;
424/* 424/*
425 case AstNode::typeCondition: 425 case AstNode::typeCondition:
426 if( pCurTarget ) 426 if( pCurTarget )
427 { 427 {
428 if( pExpr->getStrValue() == "filetime" ) 428 if( pExpr->getStrValue() == "filetime" )
429 { 429 {
430 pCurTarget->setCondition( 430 pCurTarget->setCondition(
431 new ConditionFileTime() 431 new ConditionFileTime()
432 ); 432 );
433 } 433 }
434 } 434 }
435 else if( pCurRule ) 435 else if( pCurRule )
436 { 436 {
437 if( pExpr->getStrValue() == "filetime" ) 437 if( pExpr->getStrValue() == "filetime" )
438 { 438 {
439 pCurRule->setCondition( 439 pCurRule->setCondition(
440 new ConditionFileTime() 440 new ConditionFileTime()
441 ); 441 );
442 } 442 }
443 } 443 }
444 else 444 else
445 { 445 {
446 throw Bu::ExceptionBase( 446 throw Bu::ExceptionBase(
447 "You can only set a condition in a target or rule."); 447 "You can only set a condition in a target or rule.");
448 } 448 }
449 break; 449 break;
450*/ 450*/
451 default: 451 default:
452 sio << "Leaf? " << (*i)->getType() << sio.nl; 452 sio << "Leaf? " << (*i)->getType() << sio.nl;
453 break; 453 break;
454 } 454 }
455 } 455 }
456 else 456 else
457 { 457 {
458 const AstBranch *pExpr = dynamic_cast<const AstBranch *>( *i ); 458 const AstBranch *pExpr = dynamic_cast<const AstBranch *>( *i );
459 switch( pExpr->getType() ) 459 switch( pExpr->getType() )
460 { 460 {
461 case AstNode::typeSet: 461 case AstNode::typeSet:
462 { 462 {
463 // This is effectively legacy, if we add the set 463 // This is effectively legacy, if we add the set
464 // keyword back in I want it to work. 464 // keyword back in I want it to work.
465 doSet( pExpr ); 465 doSet( pExpr );
466 } 466 }
467 break; 467 break;
468 468
469 case AstNode::typeUnset: 469 case AstNode::typeUnset:
470 { 470 {
471 AstBranch::NodeList::const_iterator n = 471 AstBranch::NodeList::const_iterator n =
472 (*pExpr->getBranchBegin()).begin(); 472 (*pExpr->getBranchBegin()).begin();
473 Bu::String sVar = dynamic_cast<const AstLeaf *>( 473 Bu::String sVar = dynamic_cast<const AstLeaf *>(
474 *n )->getStrValue(); 474 *n )->getStrValue();
475 rCont.delVariable( sVar ); 475 rCont.delVariable( sVar );
476 } 476 }
477 break; 477 break;
478 478
479 case AstNode::typeIf: 479 case AstNode::typeIf:
480 { 480 {
481 AstBranch::BranchList::const_iterator b = 481 AstBranch::BranchList::const_iterator b =
482 pExpr->getBranchBegin(); 482 pExpr->getBranchBegin();
483 483
484 Variable v = execExpr( (*b).begin() ); 484 Variable v = execExpr( (*b).begin() );
485 if( v.getType() != Variable::typeBool ) 485 if( v.getType() != Variable::typeBool )
486 { 486 {
487 throw Bu::ExceptionBase( 487 throw Bu::ExceptionBase(
488 "If statement evaluated to non-boolean."); 488 "If statement evaluated to non-boolean.");
489 } 489 }
490 b++; 490 b++;
491 if( v.getBool() ) 491 if( v.getBool() )
492 { 492 {
493 i++; 493 i++;
494 sI.push( (*b).begin() ); 494 sI.push( (*b).begin() );
495 continue; 495 continue;
496 } 496 }
497 else 497 else
498 { 498 {
499 b++; 499 b++;
500 if( b ) 500 if( b )
501 { 501 {
502 i++; 502 i++;
503 sI.push( (*b).begin() ); 503 sI.push( (*b).begin() );
504 continue; 504 continue;
505 } 505 }
506 } 506 }
507 } 507 }
508 break; 508 break;
509 509
510 case AstNode::typeFor: 510 case AstNode::typeFor:
511 { 511 {
512 AstBranch::BranchList::const_iterator b = 512 AstBranch::BranchList::const_iterator b =
513 pExpr->getBranchBegin(); 513 pExpr->getBranchBegin();
514 Bu::String sVar = dynamic_cast<const AstLeaf *>( 514 Bu::String sVar = dynamic_cast<const AstLeaf *>(
515 (*b).first() )->getStrValue(); 515 (*b).first() )->getStrValue();
516 b++; 516 b++;
517 Variable v = execExpr( (*b).begin() ); 517 Variable v = execExpr( (*b).begin() );
518 b++; 518 b++;
519 for( VarList::const_iterator vi = v.getList().begin(); 519 for( VarList::const_iterator vi = v.getList().begin();
520 vi; vi++ ) 520 vi; vi++ )
521 { 521 {
522 rCont.addVariable( sVar, *vi ); 522 rCont.addVariable( sVar, *vi );
523 run( (*b).begin() ); 523 run( (*b).begin() );
524 } 524 }
525 } 525 }
526 break; 526 break;
527 527
528 case AstNode::typeFunction: 528 case AstNode::typeFunction:
529 { 529 {
530 Variable vIn; 530 Variable vIn;
531 execFunc( pExpr, vIn ); 531 execFunc( pExpr, vIn );
532 } 532 }
533 break; 533 break;
534 534
535 case AstNode::typeReturn: 535 case AstNode::typeReturn:
536 vReturn = execExpr( (*pExpr->getBranchBegin()).begin() ); 536 vReturn = execExpr( (*pExpr->getBranchBegin()).begin() );
537 return vReturn; 537 return vReturn;
538 break; 538 break;
539 539
540 case AstNode::typeFunctionDef: 540 case AstNode::typeFunctionDef:
541 case AstNode::typeActionDef: 541 case AstNode::typeActionDef:
542 // We ignore these, we already dealt with them 542 // We ignore these, we already dealt with them
543 break; 543 break;
544 544
545 case AstNode::typeTarget: 545 case AstNode::typeTarget:
546 // This actually runs exactly like a for loop, if there's 546 // This actually runs exactly like a for loop, if there's
547 // only one item, then we only go once, if it's a list, go 547 // only one item, then we only go once, if it's a list, go
548 // more than once :-P 548 // more than once :-P
549 if( pCurTarget == NULL ) 549 if( pCurTarget == NULL )
550 { 550 {
551 AstBranch::BranchList::const_iterator b = 551 AstBranch::BranchList::const_iterator b =
552 pExpr->getBranchBegin(); 552 pExpr->getBranchBegin();
553 Variable vLoop = execExpr( (*b).begin() ); 553 Variable vLoop = execExpr( (*b).begin() );
554 b++; 554 b++;
555 if( vLoop.getType() == Variable::typeString ) 555 if( vLoop.getType() == Variable::typeString )
556 { 556 {
557 rCont.addTarget( 557 rCont.addTarget(
558 buildTarget( 558 buildTarget(
559 vLoop.getString(), (*b).begin() 559 vLoop.getString(), (*b).begin()
560 ) 560 )
561 ); 561 );
562 } 562 }
563 else if( vLoop.getType() == Variable::typeList ) 563 else if( vLoop.getType() == Variable::typeList )
564 { 564 {
565 for( VarList::iterator i = vLoop.begin(); i; i++ ) 565 for( VarList::iterator i = vLoop.begin(); i; i++ )
566 { 566 {
567 rCont.addTarget( 567 rCont.addTarget(
568 buildTarget( 568 buildTarget(
569 (*i).getString(), (*b).begin() 569 (*i).getString(), (*b).begin()
570 ) 570 )
571 ); 571 );
572 } 572 }
573 } 573 }
574 } 574 }
575 else 575 else
576 { 576 {
577 throw Bu::ExceptionBase( 577 throw Bu::ExceptionBase(
578 "You cannot declare a target within " 578 "You cannot declare a target within "
579 "a target decleration."); 579 "a target decleration.");
580 } 580 }
581 break; 581 break;
582 582
583 case AstNode::typeRuleDef: 583 case AstNode::typeRuleDef:
584 if( pCurRule == NULL ) 584 if( pCurRule == NULL )
585 { 585 {
586 AstBranch::BranchList::const_iterator b = 586 AstBranch::BranchList::const_iterator b =
587 pExpr->getBranchBegin(); 587 pExpr->getBranchBegin();
588 Bu::String sName = dynamic_cast<const AstLeaf *>( 588 Bu::String sName = dynamic_cast<const AstLeaf *>(
589 (*b).first() 589 (*b).first()
590 )->getStrValue(); 590 )->getStrValue();
591 b++; 591 b++;
592 rCont.addRule( buildRule( sName, (*b).begin() ) ); 592 rCont.addRule( buildRule( sName, (*b).begin() ) );
593 } 593 }
594 else 594 else
595 { 595 {
596 throw Bu::ExceptionBase( 596 throw Bu::ExceptionBase(
597 "You cannot declare a rule within " 597 "You cannot declare a rule within "
598 "a rule decleration."); 598 "a rule decleration.");
599 } 599 }
600 break; 600 break;
601 601
602 case AstNode::typeInput: 602 case AstNode::typeInput:
603 if( pCurTarget != NULL ) 603 if( pCurTarget != NULL )
604 { 604 {
605 Variable vRet = execExpr( 605 Variable vRet = execExpr(
606 (*pExpr->getBranchBegin()).begin() 606 (*pExpr->getBranchBegin()).begin()
607 ); 607 );
608 if( vRet.getType() == Variable::typeString ) 608 if( vRet.getType() == Variable::typeString )
609 { 609 {
610 pCurTarget->addInput( vRet.getString() ); 610 pCurTarget->addInput( vRet.getString() );
611 } 611 }
612 else if( vRet.getType() == Variable::typeList ) 612 else if( vRet.getType() == Variable::typeList )
613 { 613 {
614 for( VarList::iterator i = vRet.begin(); i; i++ ) 614 for( VarList::iterator i = vRet.begin(); i; i++ )
615 { 615 {
616 pCurTarget->addInput( 616 pCurTarget->addInput(
617 (*i).getString() 617 (*i).getString()
618 ); 618 );
619 } 619 }
620 } 620 }
621 } 621 }
622 else if( pCurRule != NULL ) 622 else if( pCurRule != NULL )
623 { 623 {
624 pCurRule->setInput( pExpr ); 624 pCurRule->setInput( pExpr );
625 } 625 }
626 else 626 else
627 { 627 {
628 throw Bu::ExceptionBase( 628 throw Bu::ExceptionBase(
629 "input can only occur within a target or rule."); 629 "input can only occur within a target or rule.");
630 } 630 }
631 break; 631 break;
632 632
633 case AstNode::typeRequires: 633 case AstNode::typeRequires:
634 if( pCurTarget != NULL ) 634 if( pCurTarget != NULL )
635 { 635 {
636 Variable vRet = execExpr( 636 Variable vRet = execExpr(
637 (*pExpr->getBranchBegin()).begin() 637 (*pExpr->getBranchBegin()).begin()
638 ); 638 );
639 if( vRet.getType() == Variable::typeString ) 639 if( vRet.getType() == Variable::typeString )
640 { 640 {
641 pCurTarget->addRequires( vRet.getString() ); 641 pCurTarget->addRequires( vRet.getString() );
642 } 642 }
643 else if( vRet.getType() == Variable::typeList ) 643 else if( vRet.getType() == Variable::typeList )
644 { 644 {
645 for( VarList::iterator i = vRet.begin(); i; i++ ) 645 for( VarList::iterator i = vRet.begin(); i; i++ )
646 { 646 {
647 pCurTarget->addRequires( 647 pCurTarget->addRequires(
648 (*i).getString() 648 (*i).getString()
649 ); 649 );
650 } 650 }
651 } 651 }
652 } 652 }
653 else if( pCurRule != NULL ) 653 else if( pCurRule != NULL )
654 { 654 {
655 pCurRule->addRequires( pExpr ); 655 pCurRule->addRequires( pExpr );
656 } 656 }
657 else 657 else
658 { 658 {
659 throw Bu::ExceptionBase( 659 throw Bu::ExceptionBase(
660 "requires can only occur within a target or rule."); 660 "requires can only occur within a target or rule.");
661 } 661 }
662 break; 662 break;
663 663
664 case AstNode::typeRule: 664 case AstNode::typeRule:
665 if( pCurTarget ) 665 if( pCurTarget )
666 { 666 {
667 pCurTarget->setRule( 667 pCurTarget->setRule(
668 dynamic_cast<const AstLeaf *>( 668 dynamic_cast<const AstLeaf *>(
669 (*pExpr->getBranchBegin()).first() 669 (*pExpr->getBranchBegin()).first()
670 )->getStrValue() 670 )->getStrValue()
671 ); 671 );
672 } 672 }
673 else 673 else
674 { 674 {
675 throw Bu::ExceptionBase( 675 throw Bu::ExceptionBase(
676 "rule can only occur within a target."); 676 "rule can only occur within a target.");
677 } 677 }
678 break; 678 break;
679 679
680 case AstNode::typeProfile: 680 case AstNode::typeProfile:
681 if( pCurTarget ) 681 if( pCurTarget )
682 { 682 {
683 pCurTarget->addProfile( pExpr ); 683 pCurTarget->addProfile( pExpr );
684 } 684 }
685 else if( pCurRule ) 685 else if( pCurRule )
686 { 686 {
687 pCurRule->addProfile( pExpr ); 687 pCurRule->addProfile( pExpr );
688 } 688 }
689 else 689 else
690 { 690 {
691 throw Bu::ExceptionBase( 691 throw Bu::ExceptionBase(
692 "profile can only occur within a target or rule."); 692 "profile can only occur within a target or rule.");
693 } 693 }
694 break; 694 break;
695 695
696 case AstNode::typeOutput: 696 case AstNode::typeOutput:
697 if( pCurRule ) 697 if( pCurRule )
698 { 698 {
699 pCurRule->addOutput( pExpr ); 699 pCurRule->addOutput( pExpr );
700 } 700 }
701 else 701 else
702 { 702 {
703 throw Bu::ExceptionBase( 703 throw Bu::ExceptionBase(
704 "output can only occur within a rule."); 704 "output can only occur within a rule.");
705 } 705 }
706 break; 706 break;
707 707
708 case AstNode::typeProcessTarget: 708 case AstNode::typeProcessTarget:
709 { 709 {
710 AstBranch::BranchList::const_iterator b = 710 AstBranch::BranchList::const_iterator b =
711 pExpr->getBranchBegin(); 711 pExpr->getBranchBegin();
712 Bu::String sProfile = dynamic_cast<const AstLeaf *>( 712 Bu::String sProfile = dynamic_cast<const AstLeaf *>(
713 (*b).first() 713 (*b).first()
714 )->getStrValue(); 714 )->getStrValue();
715 b++; 715 b++;
716 Variable vTargs = execExpr( (*b).begin() ); 716 Variable vTargs = execExpr( (*b).begin() );
717 if( vTargs.getType() == Variable::typeString ) 717 if( vTargs.getType() == Variable::typeString )
718 { 718 {
719 rCont.getTarget( vTargs.getString() )->process( 719 rCont.getTarget( vTargs.getString() )->process(
720 *this, sProfile 720 *this, sProfile
721 ); 721 );
722 } 722 }
723 else if( vTargs.getType() == Variable::typeList ) 723 else if( vTargs.getType() == Variable::typeList )
724 { 724 {
725 for( VarList::iterator v = vTargs.begin(); 725 for( VarList::iterator v = vTargs.begin();
726 v; v++ ) { 726 v; v++ ) {
727 rCont.getTarget( (*v).getString() )->process( 727 rCont.getTarget( (*v).getString() )->process(
728 *this, sProfile 728 *this, sProfile
729 ); 729 );
730 } 730 }
731 } 731 }
732 } 732 }
733 break; 733 break;
734 734
735 case AstNode::typeTag: 735 case AstNode::typeTag:
736 if( pCurTarget ) 736 if( pCurTarget )
737 { 737 {
738 AstBranch::BranchList::const_iterator b = 738 AstBranch::BranchList::const_iterator b =
739 pExpr->getBranchBegin(); 739 pExpr->getBranchBegin();
740 Variable vTags = execExpr( (*b).begin() ); 740 Variable vTags = execExpr( (*b).begin() );
741 if( vTags.getType() == Variable::typeList ) 741 if( vTags.getType() == Variable::typeList )
742 { 742 {
743 for( VarList::iterator i = vTags.begin(); i; i++ ) 743 for( VarList::iterator i = vTags.begin(); i; i++ )
744 { 744 {
745 rCont.addTargetToTag( pCurTarget, (*i).toString() ); 745 rCont.addTargetToTag( pCurTarget, (*i).toString() );
746 } 746 }
747 } 747 }
748 else 748 else
749 { 749 {
750 Bu::String sTag = vTags.toString(); 750 Bu::String sTag = vTags.toString();
751 if( sTag.isSet() ) 751 if( sTag.isSet() )
752 { 752 {
753 rCont.addTargetToTag( pCurTarget, sTag ); 753 rCont.addTargetToTag( pCurTarget, sTag );
754 } 754 }
755 else 755 else
756 { 756 {
757 throw Bu::ExceptionBase( 757 throw Bu::ExceptionBase(
758 "A tag evaluted to empty string." 758 "A tag evaluted to empty string."
759 ); 759 );
760 } 760 }
761 } 761 }
762 } 762 }
763 else if( pCurRule ) 763 else if( pCurRule )
764 { 764 {
765 AstBranch::BranchList::const_iterator b = 765 AstBranch::BranchList::const_iterator b =
766 pExpr->getBranchBegin(); 766 pExpr->getBranchBegin();
767 Variable vTags = execExpr( (*b).begin() ); 767 Variable vTags = execExpr( (*b).begin() );
768 if( vTags.getType() == Variable::typeList ) 768 if( vTags.getType() == Variable::typeList )
769 { 769 {
770 for( VarList::iterator i = vTags.begin(); i; i++ ) 770 for( VarList::iterator i = vTags.begin(); i; i++ )
771 { 771 {
772 pCurRule->addTag( (*i).toString() ); 772 pCurRule->addTag( (*i).toString() );
773 } 773 }
774 } 774 }
775 else 775 else
776 { 776 {
777 Bu::String sTag = vTags.toString(); 777 Bu::String sTag = vTags.toString();
778 if( sTag.isSet() ) 778 if( sTag.isSet() )
779 { 779 {
780 pCurRule->addTag( sTag ); 780 pCurRule->addTag( sTag );
781 } 781 }
782 else 782 else
783 { 783 {
784 throw Bu::ExceptionBase( 784 throw Bu::ExceptionBase(
785 "A tag evaluted to empty string." 785 "A tag evaluted to empty string."
786 ); 786 );
787 } 787 }
788 } 788 }
789 } 789 }
790 else 790 else
791 { 791 {
792 throw Bu::ExceptionBase( 792 throw Bu::ExceptionBase(
793 "tag can only occur within a target or rule."); 793 "tag can only occur within a target or rule.");
794 } 794 }
795 break; 795 break;
796 796
797 case AstNode::typeExpr: 797 case AstNode::typeExpr:
798 execExpr( (*pExpr->getBranchBegin()).begin() ); 798 execExpr( (*pExpr->getBranchBegin()).begin() );
799 break; 799 break;
800 800
801 default: 801 default:
802 sio << "Branch? " << (*i)->getType() << sio.nl; 802 sio << "Branch? " << (*i)->getType() << sio.nl;
803 break; 803 break;
804 } 804 }
805 } 805 }
806 806
807 i++; 807 i++;
808 } 808 }
809 809
810 return vReturn; 810 return vReturn;
811} 811}
812 812
813void Runner::execProfile( Target *pTarget, const Bu::String &sProfile ) 813void Runner::execProfile( Target *pTarget, const Bu::String &sProfile )
814{ 814{
815 rCont.pushScope( pTarget->getVars() ); 815 rCont.pushScope( pTarget->getVars() );
816 run( (*(pTarget->getProfile( sProfile )->getRoot()-> 816 run( (*(pTarget->getProfile( sProfile )->getRoot()->
817 getBranchBegin()+1)).begin() ); 817 getBranchBegin()+1)).begin() );
818 rCont.popScope(); 818 rCont.popScope();
819} 819}
820 820
821void Runner::execAction( const Bu::String &sName ) 821void Runner::execAction( const Bu::String &sName )
822{ 822{
823 try 823 try
824 { 824 {
825 Action *pAct = rCont.getAction( sName ); 825 Action *pAct = rCont.getAction( sName );
826 826
827 pAct->call( this ); 827 pAct->call( this );
828 } 828 }
829 catch( Bu::HashException &e ) 829 catch( Bu::HashException &e )
830 { 830 {
831 Bu::String sError("No such action '" + sName + "' found."); 831 Bu::String sError("No such action '" + sName + "' found.");
832 rCont.getView()->sysError( sError ); 832 rCont.getView()->sysError( sError );
833 } 833 }
834} 834}
835 835
836Context &Runner::getContext() 836Context &Runner::getContext()
837{ 837{
838 return rCont; 838 return rCont;
839} 839}
840 840
841Target *Runner::buildTarget( const Bu::String &sOutput, 841Target *Runner::buildTarget( const Bu::String &sOutput,
842 AstBranch::NodeList::const_iterator n ) 842 AstBranch::NodeList::const_iterator n )
843{ 843{
844 Target *pTrg = NULL; 844 Target *pTrg = NULL;
845 try 845 try
846 { 846 {
847 pTrg = rCont.getTarget( sOutput ); 847 pTrg = rCont.getTarget( sOutput );
848 rCont.pushScope( pTrg->getVars() ); 848 rCont.pushScope( pTrg->getVars() );
849 } 849 }
850 catch( Bu::HashException &e ) 850 catch( Bu::HashException &e )
851 { 851 {
852 pTrg = new Target( sOutput, true ); 852 pTrg = new Target( sOutput, true );
853 rCont.pushScope(); 853 rCont.pushScope();
854 } 854 }
855 855
856 // sio << " (target) \"" << sOutput << "\" explicit." << sio.nl; 856 // sio << " (target) \"" << sOutput << "\" explicit." << sio.nl;
857 857
858 rCont.addVariable("OUTPUT", sOutput ); 858 rCont.addVariable("OUTPUT", sOutput );
859 pCurTarget = pTrg; 859 pCurTarget = pTrg;
860 run( n ); 860 run( n );
861 861
862 rCont.addVariable("INPUT", pTrg->getInputList() ); 862 rCont.addVariable("INPUT", pTrg->getInputList() );
863 pCurTarget = NULL; 863 pCurTarget = NULL;
864 864
865 pTrg->setVars( rCont.getScope() ); 865 pTrg->setVars( rCont.getScope() );
866 rCont.popScope(); 866 rCont.popScope();
867 867
868 return pTrg; 868 return pTrg;
869} 869}
870 870
871Rule *Runner::buildRule( const Bu::String &sName, 871Rule *Runner::buildRule( const Bu::String &sName,
872 AstBranch::NodeList::const_iterator n ) 872 AstBranch::NodeList::const_iterator n )
873{ 873{
874 Rule *pRule = new Rule( sName ); 874 Rule *pRule = new Rule( sName );
875 875
876 rCont.pushScope(); 876 rCont.pushScope();
877 pCurRule = pRule; 877 pCurRule = pRule;
878 run( n ); 878 run( n );
879 rCont.popScope(); 879 rCont.popScope();
880 pCurRule = NULL; 880 pCurRule = NULL;
881 881
882 return pRule; 882 return pRule;
883} 883}
884 884
885Variable Runner::doSet( const AstBranch *pRoot ) 885Variable Runner::doSet( const AstBranch *pRoot )
886{ 886{
887 AstBranch::NodeList::const_iterator n = 887 AstBranch::NodeList::const_iterator n =
888 (*pRoot->getBranchBegin()).begin(); 888 (*pRoot->getBranchBegin()).begin();
889 Bu::String sVar = dynamic_cast<const AstLeaf *>( *n )->getStrValue(); 889 Bu::String sVar = dynamic_cast<const AstLeaf *>( *n )->getStrValue();
890 n++; 890 n++;
891 const AstLeaf *pLeaf = dynamic_cast<const AstLeaf *>( *n ); 891 const AstLeaf *pLeaf = dynamic_cast<const AstLeaf *>( *n );
892 n++; 892 n++;
893 Variable v = execExpr( n ); 893 Variable v = execExpr( n );
894 894
895 switch( pLeaf->getType() ) 895 switch( pLeaf->getType() )
896 { 896 {
897 case AstNode::typeOpEq: 897 case AstNode::typeOpEq:
898 rCont.addVariable( sVar, v ); 898 rCont.addVariable( sVar, v );
899 break; 899 break;
900 900
901 case AstNode::typeOpPlusEq: 901 case AstNode::typeOpPlusEq:
902 try 902 try
903 { 903 {
904 rCont.getVariable( sVar ) += v; 904 rCont.getVariable( sVar ) += v;
905 } catch(...) 905 } catch(...)
906 { 906 {
907 rCont.addVariable( sVar, v ); 907 rCont.addVariable( sVar, v );
908 } 908 }
909 break; 909 break;
910 910
911 case AstNode::typeOpPlusEqRaw: 911 case AstNode::typeOpPlusEqRaw:
912 try 912 try
913 { 913 {
914 rCont.getVariable( sVar ) << v; 914 rCont.getVariable( sVar ) << v;
915 } catch(...) 915 } catch(...)
916 { 916 {
917 rCont.addVariable( sVar, v ); 917 rCont.addVariable( sVar, v );
918 } 918 }
919 break; 919 break;
920 920
921 default: break; 921 default: break;
922 } 922 }
923 923
924 return v; 924 return v;
925} 925}
926 926
diff --git a/src/runner.h b/src/runner.h
index 0efcb44..59f1703 100644
--- a/src/runner.h
+++ b/src/runner.h
@@ -6,38 +6,38 @@
6class Runner 6class Runner
7{ 7{
8public: 8public:
9 Runner( class Ast &rAst, class Context &rCont ); 9 Runner( class Ast &rAst, class Context &rCont );
10 virtual ~Runner(); 10 virtual ~Runner();
11 11
12 /** 12 /**
13 * Run through and pull out all of the functions. Maybe more later. 13 * Run through and pull out all of the functions. Maybe more later.
14 */ 14 */
15 void initialize(); 15 void initialize();
16 class Variable execExpr( AstBranch::NodeList::const_iterator e ); 16 class Variable execExpr( AstBranch::NodeList::const_iterator e );
17 class Variable execExpr( AstBranch::NodeList::const_iterator e, 17 class Variable execExpr( AstBranch::NodeList::const_iterator e,
18 const class Variable &vIn ); 18 const class Variable &vIn );
19 void run(); 19 void run();
20 Variable run( AstBranch::NodeList::const_iterator n ); 20 Variable run( AstBranch::NodeList::const_iterator n );
21 class Variable execFunc( const class AstBranch *pFunc, 21 class Variable execFunc( const class AstBranch *pFunc,
22 class Variable &vIn ); 22 class Variable &vIn );
23 void execProfile( class Target *pTarget, const Bu::String &sProfile ); 23 void execProfile( class Target *pTarget, const Bu::String &sProfile );
24 void execAction( const Bu::String &sName ); 24 void execAction( const Bu::String &sName );
25 25
26 Context &getContext(); 26 Context &getContext();
27 27
28private: 28private:
29 class Target *buildTarget( const Bu::String &sOutput, 29 class Target *buildTarget( const Bu::String &sOutput,
30 AstBranch::NodeList::const_iterator n ); 30 AstBranch::NodeList::const_iterator n );
31 class Rule *buildRule( const Bu::String &sName, 31 class Rule *buildRule( const Bu::String &sName,
32 AstBranch::NodeList::const_iterator n ); 32 AstBranch::NodeList::const_iterator n );
33 void attachDefaults(); 33 void attachDefaults();
34 Variable doSet( const AstBranch *pRoot ); 34 Variable doSet( const AstBranch *pRoot );
35 35
36private: 36private:
37 class Ast &rAst; 37 class Ast &rAst;
38 class Context &rCont; 38 class Context &rCont;
39 Target *pCurTarget; 39 Target *pCurTarget;
40 Rule *pCurRule; 40 Rule *pCurRule;
41}; 41};
42 42
43#endif 43#endif
diff --git a/src/target.cpp b/src/target.cpp
index 3a90c01..175030c 100644
--- a/src/target.cpp
+++ b/src/target.cpp
@@ -17,16 +17,16 @@
17using namespace Bu; 17using namespace Bu;
18 18
19Target::Target( bool bExplicit ) : 19Target::Target( bool bExplicit ) :
20 bExplicit( bExplicit ), 20 bExplicit( bExplicit ),
21 bRun( false ), 21 bRun( false ),
22 iDepCount( 0 ) 22 iDepCount( 0 )
23{ 23{
24} 24}
25 25
26Target::Target( const Bu::String &sOutput, bool bExplicit ) : 26Target::Target( const Bu::String &sOutput, bool bExplicit ) :
27 bExplicit( bExplicit ), 27 bExplicit( bExplicit ),
28 lsOutput( sOutput ), 28 lsOutput( sOutput ),
29 iDepCount( 0 ) 29 iDepCount( 0 )
30{ 30{
31} 31}
32 32
@@ -36,385 +36,385 @@ Target::~Target()
36 36
37void Target::addInput( const Bu::String &sInput ) 37void Target::addInput( const Bu::String &sInput )
38{ 38{
39 lsInput.append( sInput ); 39 lsInput.append( sInput );
40} 40}
41 41
42const StrList &Target::getInputList() const 42const StrList &Target::getInputList() const
43{ 43{
44 return lsInput; 44 return lsInput;
45} 45}
46 46
47void Target::resetInputList( const StrList &lInputs ) 47void Target::resetInputList( const StrList &lInputs )
48{ 48{
49 lsInput = lInputs; 49 lsInput = lInputs;
50 if( lsInput.getSize() == 1 ) 50 if( lsInput.getSize() == 1 )
51 { 51 {
52 hVars.insert("INPUT", lsInput.first() ); 52 hVars.insert("INPUT", lsInput.first() );
53 } 53 }
54 else 54 else
55 { 55 {
56 Variable vInput( Variable::typeList ); 56 Variable vInput( Variable::typeList );
57 for( StrList::iterator i = lsInput.begin(); i; i++ ) 57 for( StrList::iterator i = lsInput.begin(); i; i++ )
58 { 58 {
59 vInput.append( Variable( *i ) ); 59 vInput.append( Variable( *i ) );
60 } 60 }
61 hVars.insert("INPUT", vInput ); 61 hVars.insert("INPUT", vInput );
62 } 62 }
63} 63}
64 64
65void Target::addRequires( const Bu::String &sReq ) 65void Target::addRequires( const Bu::String &sReq )
66{ 66{
67 lsRequires.append( sReq ); 67 lsRequires.append( sReq );
68} 68}
69 69
70void Target::addRequires( const AstBranch *pBr ) 70void Target::addRequires( const AstBranch *pBr )
71{ 71{
72 lbRequires.append( pBr ); 72 lbRequires.append( pBr );
73} 73}
74 74
75const StrList &Target::getRequiresList() const 75const StrList &Target::getRequiresList() const
76{ 76{
77 return lsRequires; 77 return lsRequires;
78} 78}
79 79
80void Target::gatherRequires( Runner &r ) 80void Target::gatherRequires( Runner &r )
81{ 81{
82 Cache &c = Cache::getInstance(); 82 Cache &c = Cache::getInstance();
83 try 83 try
84 { 84 {
85 lsRequires = c.getRequires( lsOutput.first() ); 85 lsRequires = c.getRequires( lsOutput.first() );
86 } 86 }
87 catch( Bu::HashException &e ) 87 catch( Bu::HashException &e )
88 { 88 {
89 buildRequires( r ); 89 buildRequires( r );
90 } 90 }
91} 91}
92 92
93void Target::buildRequires( Runner &r ) 93void Target::buildRequires( Runner &r )
94{ 94{
95 r.getContext().getView()->buildRequires( *this ); 95 r.getContext().getView()->buildRequires( *this );
96 r.getContext().pushScope( hVars ); 96 r.getContext().pushScope( hVars );
97 for( AstBranchList::iterator i = lbRequires.begin(); i; i++ ) 97 for( AstBranchList::iterator i = lbRequires.begin(); i; i++ )
98 { 98 {
99 Variable v = r.execExpr( (*(*i)->getBranchBegin()).begin() ); 99 Variable v = r.execExpr( (*(*i)->getBranchBegin()).begin() );
100 if( v.getType() == Variable::typeList ) 100 if( v.getType() == Variable::typeList )
101 { 101 {
102 for( VarList::iterator j = v.begin(); j; j++ ) 102 for( VarList::iterator j = v.begin(); j; j++ )
103 { 103 {
104 Bu::String sReq = (*j).toString(); 104 Bu::String sReq = (*j).toString();
105 addRequires( sReq ); 105 addRequires( sReq );
106 /* try 106 /* try
107 { 107 {
108 addDep( r.getContext().getTarget( sReq ) ); 108 addDep( r.getContext().getTarget( sReq ) );
109 } 109 }
110 catch(...) { }*/ 110 catch(...) { }*/
111 } 111 }
112 } 112 }
113 else 113 else
114 { 114 {
115 Bu::String sReq = v.toString(); 115 Bu::String sReq = v.toString();
116 addRequires( sReq ); 116 addRequires( sReq );
117 /* try 117 /* try
118 { 118 {
119 addDep( r.getContext().getTarget( sReq ) ); 119 addDep( r.getContext().getTarget( sReq ) );
120 } 120 }
121 catch(...) { }*/ 121 catch(...) { }*/
122 } 122 }
123 } 123 }
124 r.getContext().popScope(); 124 r.getContext().popScope();
125 125
126 Cache &c = Cache::getInstance(); 126 Cache &c = Cache::getInstance();
127 c.setRequires( lsOutput.first(), lsRequires ); 127 c.setRequires( lsOutput.first(), lsRequires );
128} 128}
129 129
130void Target::addOutput( const Bu::String &sOutput ) 130void Target::addOutput( const Bu::String &sOutput )
131{ 131{
132 lsOutput.append( sOutput ); 132 lsOutput.append( sOutput );
133} 133}
134 134
135const StrList &Target::getOutputList() const 135const StrList &Target::getOutputList() const
136{ 136{
137 return lsOutput; 137 return lsOutput;
138} 138}
139 139
140void Target::setPrefix( const Bu::String &sPrefix ) 140void Target::setPrefix( const Bu::String &sPrefix )
141{ 141{
142 this->sPrefix = sPrefix; 142 this->sPrefix = sPrefix;
143} 143}
144 144
145const Bu::String &Target::getPrefix() const 145const Bu::String &Target::getPrefix() const
146{ 146{
147 return sPrefix; 147 return sPrefix;
148} 148}
149 149
150void Target::setRule( const Bu::String &sRule ) 150void Target::setRule( const Bu::String &sRule )
151{ 151{
152 this->sRule = sRule; 152 this->sRule = sRule;
153} 153}
154 154
155const Bu::String &Target::getRule() const 155const Bu::String &Target::getRule() const
156{ 156{
157 return sRule; 157 return sRule;
158} 158}
159 159
160bool Target::hasRule() const 160bool Target::hasRule() const
161{ 161{
162 return !sRule.isEmpty(); 162 return !sRule.isEmpty();
163} 163}
164 164
165bool Target::isExplicit() const 165bool Target::isExplicit() const
166{ 166{
167 return bExplicit; 167 return bExplicit;
168} 168}
169 169
170void Target::addDep( Target *pDep ) 170void Target::addDep( Target *pDep )
171{ 171{
172 lDeps.append( pDep ); 172 lDeps.append( pDep );
173} 173}
174 174
175const TargetList &Target::getDepList() const 175const TargetList &Target::getDepList() const
176{ 176{
177 return lDeps; 177 return lDeps;
178} 178}
179 179
180void Target::addProfile( const class AstBranch *pProfRoot ) 180void Target::addProfile( const class AstBranch *pProfRoot )
181{ 181{
182 Profile *pProf = new Profile( pProfRoot ); 182 Profile *pProf = new Profile( pProfRoot );
183 hProfiles.insert( pProf->getName(), pProf ); 183 hProfiles.insert( pProf->getName(), pProf );
184 /* 184 /*
185 hProfiles.insert( 185 hProfiles.insert(
186 dynamic_cast<const AstLeaf *>( 186 dynamic_cast<const AstLeaf *>(
187 (*pProfRoot->getBranchBegin()).first() 187 (*pProfRoot->getBranchBegin()).first()
188 )->getStrValue(), 188 )->getStrValue(),
189 pProfRoot 189 pProfRoot
190 ); 190 );
191 */ 191 */
192} 192}
193 193
194void Target::addProfile( const class Profile *pSrc ) 194void Target::addProfile( const class Profile *pSrc )
195{ 195{
196 hProfiles.insert( pSrc->getName(), new Profile( *pSrc ) ); 196 hProfiles.insert( pSrc->getName(), new Profile( *pSrc ) );
197} 197}
198 198
199bool Target::hasProfile( const Bu::String &sName ) const 199bool Target::hasProfile( const Bu::String &sName ) const
200{ 200{
201 return hProfiles.has( sName ); 201 return hProfiles.has( sName );
202} 202}
203 203
204const Profile *Target::getProfile( const Bu::String &sName ) const 204const Profile *Target::getProfile( const Bu::String &sName ) const
205{ 205{
206 return hProfiles.get( sName ); 206 return hProfiles.get( sName );
207} 207}
208 208
209void Target::setVars( const VarHash &hNewVars ) 209void Target::setVars( const VarHash &hNewVars )
210{ 210{
211 211
212 hVars = hNewVars; 212 hVars = hNewVars;
213} 213}
214 214
215const VarHash &Target::getVars() const 215const VarHash &Target::getVars() const
216{ 216{
217 return hVars; 217 return hVars;
218} 218}
219 219
220void Target::setDisplay( const Bu::String &sNewDisplay ) 220void Target::setDisplay( const Bu::String &sNewDisplay )
221{ 221{
222 if( !sDisplay.isSet() ) 222 if( !sDisplay.isSet() )
223 sDisplay = sNewDisplay; 223 sDisplay = sNewDisplay;
224} 224}
225 225
226const Bu::String &Target::getDisplay() const 226const Bu::String &Target::getDisplay() const
227{ 227{
228 return sDisplay; 228 return sDisplay;
229} 229}
230 230
231void Target::process( class Runner &r, const Bu::String &sProfile ) 231void Target::process( class Runner &r, const Bu::String &sProfile )
232{ 232{
233 r.getContext().getView()->beginTarget( sProfile, *this ); 233 r.getContext().getView()->beginTarget( sProfile, *this );
234 bRun = true; 234 bRun = true;
235 bool bShouldExec = false; 235 bool bShouldExec = false;
236 236
237 for( TargetList::iterator i = lDeps.begin(); i; i++ ) 237 for( TargetList::iterator i = lDeps.begin(); i; i++ )
238 { 238 {
239 if( (*i)->bRun ) 239 if( (*i)->bRun )
240 continue; 240 continue;
241 241
242 // TODO: This is important, in the future, it may be possible for a 242 // TODO: This is important, in the future, it may be possible for a
243 // target to be triggered by multiple dependant targets, to cover for 243 // target to be triggered by multiple dependant targets, to cover for
244 // this the below mergeUnder should be *TEMPORARY* and the target 244 // this the below mergeUnder should be *TEMPORARY* and the target
245 // that was marged to be reset post processing. 245 // that was marged to be reset post processing.
246 (*i)->mergeUnder( hVars ); 246 (*i)->mergeUnder( hVars );
247 (*i)->process( r, sProfile ); 247 (*i)->process( r, sProfile );
248 } 248 }
249 try 249 try
250 { 250 {
251 bShouldExec = hProfiles.get( sProfile )->shouldExec( r, *this ); 251 bShouldExec = hProfiles.get( sProfile )->shouldExec( r, *this );
252 } 252 }
253 catch( Bu::HashException &e ) 253 catch( Bu::HashException &e )
254 { 254 {
255 } 255 }
256 256
257 if( !bShouldExec ) 257 if( !bShouldExec )
258 { 258 {
259 r.getContext().getView()->skipTarget( sProfile, *this ); 259 r.getContext().getView()->skipTarget( sProfile, *this );
260 } 260 }
261 else 261 else
262 { 262 {
263 r.getContext().getView()->processTarget( sProfile, *this ); 263 r.getContext().getView()->processTarget( sProfile, *this );
264 r.execProfile( this, sProfile ); 264 r.execProfile( this, sProfile );
265 } 265 }
266 266
267 r.getContext().getView()->endTarget(); 267 r.getContext().getView()->endTarget();
268} 268}
269 269
270void Target::mergeUnder( const VarHash &hNewVars ) 270void Target::mergeUnder( const VarHash &hNewVars )
271{ 271{
272 for( VarHash::const_iterator i = hNewVars.begin(); i; i++ ) 272 for( VarHash::const_iterator i = hNewVars.begin(); i; i++ )
273 { 273 {
274 if( !hVars.has( i.getKey() ) ) 274 if( !hVars.has( i.getKey() ) )
275 { 275 {
276 hVars.insert( i.getKey(), i.getValue() ); 276 hVars.insert( i.getKey(), i.getValue() );
277 } 277 }
278 } 278 }
279} 279}
280 280
281bool Target::hasRun() 281bool Target::hasRun()
282{ 282{
283 return bRun; 283 return bRun;
284} 284}
285 285
286void Target::mergeUnder( const Target *pSrc ) 286void Target::mergeUnder( const Target *pSrc )
287{ 287{
288 // If either are explicit, then it's explicit 288 // If either are explicit, then it's explicit
289 bExplicit = bExplicit || pSrc->bExplicit; 289 bExplicit = bExplicit || pSrc->bExplicit;
290 290
291 merge( lsInput, pSrc->lsInput ); 291 merge( lsInput, pSrc->lsInput );
292 merge( lsRequires, pSrc->lsRequires ); 292 merge( lsRequires, pSrc->lsRequires );
293 merge( lsOutput, pSrc->lsOutput ); 293 merge( lsOutput, pSrc->lsOutput );
294 294
295 if( !sPrefix.isSet() ) 295 if( !sPrefix.isSet() )
296 sPrefix = pSrc->sPrefix; 296 sPrefix = pSrc->sPrefix;
297 297
298 sRule = pSrc->sRule; 298 sRule = pSrc->sRule;
299 299
300 mergeUnder( pSrc->hVars ); 300 mergeUnder( pSrc->hVars );
301 301
302 // Deps? They should be computed much after merging anyway, peh! 302 // Deps? They should be computed much after merging anyway, peh!
303 303
304 for( ProfileHash::const_iterator i = pSrc->hProfiles.begin(); i; i++ ) 304 for( ProfileHash::const_iterator i = pSrc->hProfiles.begin(); i; i++ )
305 { 305 {
306 if( !hProfiles.has( i.getKey() ) ) 306 if( !hProfiles.has( i.getKey() ) )
307 { 307 {
308 hProfiles.insert( i.getKey(), i.getValue() ); 308 hProfiles.insert( i.getKey(), i.getValue() );
309 } 309 }
310 } 310 }
311 311
312 if( !sDisplay.isSet() ) 312 if( !sDisplay.isSet() )
313 sDisplay = pSrc->sDisplay; 313 sDisplay = pSrc->sDisplay;
314 314
315 // Now we need to reset our vars. 315 // Now we need to reset our vars.
316 hVars.insert("INPUT", lsInput ); 316 hVars.insert("INPUT", lsInput );
317 hVars.insert("REQUIRES", lsRequires ); 317 hVars.insert("REQUIRES", lsRequires );
318 hVars.insert("OUTPUT", lsOutput ); 318 hVars.insert("OUTPUT", lsOutput );
319} 319}
320 320
321void Target::merge( StrList &lOut, const StrList &lIn ) 321void Target::merge( StrList &lOut, const StrList &lIn )
322{ 322{
323 Bu::Heap<Bu::String> hStr; 323 Bu::Heap<Bu::String> hStr;
324 for( StrList::const_iterator i = lOut.begin(); i; i++ ) 324 for( StrList::const_iterator i = lOut.begin(); i; i++ )
325 { 325 {
326 hStr.enqueue( *i ); 326 hStr.enqueue( *i );
327 } 327 }
328 for( StrList::const_iterator i = lIn.begin(); i; i++ ) 328 for( StrList::const_iterator i = lIn.begin(); i; i++ )
329 { 329 {
330 hStr.enqueue( *i ); 330 hStr.enqueue( *i );
331 } 331 }
332 332
333 lOut.clear(); 333 lOut.clear();
334 334
335 if( hStr.isEmpty() ) 335 if( hStr.isEmpty() )
336 return; 336 return;
337 337
338 lOut.append( hStr.dequeue() ); 338 lOut.append( hStr.dequeue() );
339 while( !hStr.isEmpty() ) 339 while( !hStr.isEmpty() )
340 { 340 {
341 if( hStr.peek() == lOut.last() ) 341 if( hStr.peek() == lOut.last() )
342 { 342 {
343 hStr.dequeue(); 343 hStr.dequeue();
344 } 344 }
345 else 345 else
346 { 346 {
347 lOut.append( hStr.dequeue() ); 347 lOut.append( hStr.dequeue() );
348 } 348 }
349 } 349 }
350} 350}
351 351
352void Target::resetRun( bool bHasRun ) 352void Target::resetRun( bool bHasRun )
353{ 353{
354 bRun = bHasRun; 354 bRun = bHasRun;
355 355
356 for( TargetList::iterator i = lDeps.begin(); i; i++ ) 356 for( TargetList::iterator i = lDeps.begin(); i; i++ )
357 { 357 {
358 (*i)->resetRun( bHasRun ); 358 (*i)->resetRun( bHasRun );
359 } 359 }
360} 360}
361 361
362void Target::setDepCount() 362void Target::setDepCount()
363{ 363{
364 bRun = true; 364 bRun = true;
365 iDepCount = 1; 365 iDepCount = 1;
366 for( TargetList::iterator i = lDeps.begin(); i; i++ ) 366 for( TargetList::iterator i = lDeps.begin(); i; i++ )
367 { 367 {
368 if( (*i)->bRun ) 368 if( (*i)->bRun )
369 { 369 {
370 continue; 370 continue;
371 } 371 }
372 (*i)->setDepCount(); 372 (*i)->setDepCount();
373 iDepCount += (*i)->getDepCount(); 373 iDepCount += (*i)->getDepCount();
374 } 374 }
375} 375}
376 376
377int Target::getDepCount() const 377int Target::getDepCount() const
378{ 378{
379 return iDepCount; 379 return iDepCount;
380} 380}
381 381
382void Target::collapseDeps() 382void Target::collapseDeps()
383{ 383{
384 if( lDeps.getSize() <= 1 ) 384 if( lDeps.getSize() <= 1 )
385 return; 385 return;
386 Bu::Hash<ptrdiff_t, bool> hDep; 386 Bu::Hash<ptrdiff_t, bool> hDep;
387 for( TargetList::iterator i = lDeps.begin(); i; i++ ) 387 for( TargetList::iterator i = lDeps.begin(); i; i++ )
388 { 388 {
389 if( hDep.has( (ptrdiff_t)*i ) ) 389 if( hDep.has( (ptrdiff_t)*i ) )
390 { 390 {
391 lDeps.erase( i ); 391 lDeps.erase( i );
392 i--; 392 i--;
393 } 393 }
394 else 394 else
395 { 395 {
396 hDep.insert( (ptrdiff_t)*i, true ); 396 hDep.insert( (ptrdiff_t)*i, true );
397 } 397 }
398 } 398 }
399} 399}
400 400
401Bu::Formatter &operator<<( Bu::Formatter &f, const Target &t ) 401Bu::Formatter &operator<<( Bu::Formatter &f, const Target &t )
402{ 402{
403 f.incIndent(); 403 f.incIndent();
404 f << f.nl << "Input = " << t.lsInput << "," << f.nl 404 f << f.nl << "Input = " << t.lsInput << "," << f.nl
405 << "Requires = " << t.lsRequires << "," << f.nl 405 << "Requires = " << t.lsRequires << "," << f.nl
406 << "Output = \"" << t.lsOutput << "\"," << f.nl 406 << "Output = \"" << t.lsOutput << "\"," << f.nl
407 << "Prefix = \"" << t.sPrefix << "\"," << f.nl 407 << "Prefix = \"" << t.sPrefix << "\"," << f.nl
408 << "Rule = \"" << t.sRule << "\"," << f.nl 408 << "Rule = \"" << t.sRule << "\"," << f.nl
409 << "Explicit = " << t.bExplicit << "," << f.nl 409 << "Explicit = " << t.bExplicit << "," << f.nl
410 << "Vars = " << t.hVars 410 << "Vars = " << t.hVars
411 << f.nl; 411 << f.nl;
412 f.decIndent(); 412 f.decIndent();
413 return f; 413 return f;
414} 414}
415 415
416template<> Bu::Formatter &Bu::operator<< <Target>( Bu::Formatter &f, const Target *t ) 416template<> Bu::Formatter &Bu::operator<< <Target>( Bu::Formatter &f, const Target *t )
417{ 417{
418 return f << (*t); 418 return f << (*t);
419} 419}
420 420
diff --git a/src/target.h b/src/target.h
index b325682..e7645dc 100644
--- a/src/target.h
+++ b/src/target.h
@@ -6,90 +6,90 @@
6 6
7class Target 7class Target
8{ 8{
9 friend Bu::Formatter &operator<<( Bu::Formatter &f, const Target &t ); 9 friend Bu::Formatter &operator<<( Bu::Formatter &f, const Target &t );
10public: 10public:
11 Target( bool bExplicit ); 11 Target( bool bExplicit );
12 Target( const Bu::String &sOutput, bool bExplicit ); 12 Target( const Bu::String &sOutput, bool bExplicit );
13 virtual ~Target(); 13 virtual ~Target();
14 14
15 void addInput( const Bu::String &sInput ); 15 void addInput( const Bu::String &sInput );
16 const StrList &getInputList() const; 16 const StrList &getInputList() const;
17 void resetInputList( const StrList &lInputs ); 17 void resetInputList( const StrList &lInputs );
18 18
19 void addRequires( const Bu::String &sReq ); 19 void addRequires( const Bu::String &sReq );
20 void addRequires( const AstBranch *pBr ); 20 void addRequires( const AstBranch *pBr );
21 const StrList &getRequiresList() const; 21 const StrList &getRequiresList() const;
22 /** 22 /**
23 * This function will get the cached requires if they exist, build them 23 * This function will get the cached requires if they exist, build them
24 * if they don't. Use this is conditions, but use buildRequires to force 24 * if they don't. Use this is conditions, but use buildRequires to force
25 * a rebuild even if cached data exists. 25 * a rebuild even if cached data exists.
26 */ 26 */
27 void gatherRequires( class Runner &r ); 27 void gatherRequires( class Runner &r );
28 void buildRequires( class Runner &r ); 28 void buildRequires( class Runner &r );
29 29
30 void addOutput( const Bu::String &sOutput ); 30 void addOutput( const Bu::String &sOutput );
31 const StrList &getOutputList() const; 31 const StrList &getOutputList() const;
32 32
33 void setPrefix( const Bu::String &sPrefix ); 33 void setPrefix( const Bu::String &sPrefix );
34 const Bu::String &getPrefix() const; 34 const Bu::String &getPrefix() const;
35 35
36 void setRule( const Bu::String &sRule ); 36 void setRule( const Bu::String &sRule );
37 const Bu::String &getRule() const; 37 const Bu::String &getRule() const;
38 bool hasRule() const; 38 bool hasRule() const;
39 39
40 bool isExplicit() const; 40 bool isExplicit() const;
41 41
42 void addDep( Target *pDep ); 42 void addDep( Target *pDep );
43 const TargetList &getDepList() const; 43 const TargetList &getDepList() const;
44 44
45 void addProfile( const class AstBranch *pProfRoot ); 45 void addProfile( const class AstBranch *pProfRoot );
46 void addProfile( const class Profile *pSrc ); 46 void addProfile( const class Profile *pSrc );
47 bool hasProfile( const Bu::String &sName ) const; 47 bool hasProfile( const Bu::String &sName ) const;
48 const class Profile *getProfile( const Bu::String &sName ) const; 48 const class Profile *getProfile( const Bu::String &sName ) const;
49 49
50 void setVars( const VarHash &hNewVars ); 50 void setVars( const VarHash &hNewVars );
51 const VarHash &getVars() const; 51 const VarHash &getVars() const;
52 52
53 void setDisplay( const Bu::String &sNewDisplay ); 53 void setDisplay( const Bu::String &sNewDisplay );
54 const Bu::String &getDisplay() const; 54 const Bu::String &getDisplay() const;
55 55
56 void process( class Runner &r, const Bu::String &sProfile ); 56 void process( class Runner &r, const Bu::String &sProfile );
57 57
58 void mergeUnder( const Target *pSrc ); 58 void mergeUnder( const Target *pSrc );
59 59
60 bool hasRun(); 60 bool hasRun();
61 61
62 void resetRun( bool bHasRun=true ); 62 void resetRun( bool bHasRun=true );
63 void setDepCount(); 63 void setDepCount();
64 int getDepCount() const; 64 int getDepCount() const;
65 65
66 void collapseDeps(); 66 void collapseDeps();
67 67
68private: 68private:
69 void mergeUnder( const VarHash &hVars ); 69 void mergeUnder( const VarHash &hVars );
70 void merge( StrList &lOut, const StrList &lIn ); 70 void merge( StrList &lOut, const StrList &lIn );
71 71
72private: 72private:
73 bool bExplicit; 73 bool bExplicit;
74 StrList lsInput; 74 StrList lsInput;
75 StrList lsRequires; 75 StrList lsRequires;
76 StrList lsOutput; 76 StrList lsOutput;
77 Bu::String sPrefix; 77 Bu::String sPrefix;
78 Bu::String sRule; 78 Bu::String sRule;
79 VarHash hVars; 79 VarHash hVars;
80 TargetList lDeps; 80 TargetList lDeps;
81 ProfileHash hProfiles; 81 ProfileHash hProfiles;
82 Bu::String sDisplay; 82 Bu::String sDisplay;
83 bool bRun; 83 bool bRun;
84 AstBranchList lbRequires; 84 AstBranchList lbRequires;
85 int iDepCount; 85 int iDepCount;
86}; 86};
87 87
88Bu::Formatter &operator<<( Bu::Formatter &f, const Target &t ); 88Bu::Formatter &operator<<( Bu::Formatter &f, const Target &t );
89 89
90namespace Bu 90namespace Bu
91{ 91{
92 template<> Bu::Formatter &operator<< <Target>( Bu::Formatter &f, const Target *t ); 92 template<> Bu::Formatter &operator<< <Target>( Bu::Formatter &f, const Target *t );
93}; 93};
94 94
95#endif 95#endif
diff --git a/src/variable.cpp b/src/variable.cpp
index ffc41a6..bef0ca8 100644
--- a/src/variable.cpp
+++ b/src/variable.cpp
@@ -6,1036 +6,1036 @@ using Bu::sio;
6#include <stdlib.h> 6#include <stdlib.h>
7 7
8Variable::Variable() : 8Variable::Variable() :
9 eType( typeNone ) 9 eType( typeNone )
10{ 10{
11 memset( &uVal, 0, sizeof(uVal) ); 11 memset( &uVal, 0, sizeof(uVal) );
12} 12}
13 13
14Variable::Variable( Type t ) : 14Variable::Variable( Type t ) :
15 eType( t ) 15 eType( t )
16{ 16{
17 memset( &uVal, 0, sizeof(uVal) ); 17 memset( &uVal, 0, sizeof(uVal) );
18 if( eType == typeString || eType == typeRef ) 18 if( eType == typeString || eType == typeRef )
19 { 19 {
20 uVal.sVal = new Bu::String; 20 uVal.sVal = new Bu::String;
21 } 21 }
22 else if( eType == typeList ) 22 else if( eType == typeList )
23 { 23 {
24 uVal.lVal = new VarList; 24 uVal.lVal = new VarList;
25 } 25 }
26} 26}
27 27
28Variable::Variable( int iVal ) : 28Variable::Variable( int iVal ) :
29 eType( typeInt ) 29 eType( typeInt )
30{ 30{
31 memset( &uVal, 0, sizeof(uVal) ); 31 memset( &uVal, 0, sizeof(uVal) );
32 uVal.iVal = iVal; 32 uVal.iVal = iVal;
33} 33}
34 34
35Variable::Variable( double fVal ) : 35Variable::Variable( double fVal ) :
36 eType( typeFloat ) 36 eType( typeFloat )
37{ 37{
38 memset( &uVal, 0, sizeof(uVal) ); 38 memset( &uVal, 0, sizeof(uVal) );
39 uVal.fVal = fVal; 39 uVal.fVal = fVal;
40} 40}
41 41
42Variable::Variable( bool bVal ) : 42Variable::Variable( bool bVal ) :
43 eType( typeBool ) 43 eType( typeBool )
44{ 44{
45 memset( &uVal, 0, sizeof(uVal) ); 45 memset( &uVal, 0, sizeof(uVal) );
46 uVal.bVal = bVal; 46 uVal.bVal = bVal;
47} 47}
48 48
49Variable::Variable( const Bu::String &sVal ) : 49Variable::Variable( const Bu::String &sVal ) :
50 eType( typeString ) 50 eType( typeString )
51{ 51{
52 memset( &uVal, 0, sizeof(uVal) ); 52 memset( &uVal, 0, sizeof(uVal) );
53 uVal.sVal = new Bu::String( sVal ); 53 uVal.sVal = new Bu::String( sVal );
54} 54}
55 55
56Variable::Variable( const char *sVal ) : 56Variable::Variable( const char *sVal ) :
57 eType( typeString ) 57 eType( typeString )
58{ 58{
59 memset( &uVal, 0, sizeof(uVal) ); 59 memset( &uVal, 0, sizeof(uVal) );
60 uVal.sVal = new Bu::String( sVal ); 60 uVal.sVal = new Bu::String( sVal );
61} 61}
62 62
63Variable::Variable( const Variable &v ) : 63Variable::Variable( const Variable &v ) :
64 eType( v.eType ) 64 eType( v.eType )
65{ 65{
66 memset( &uVal, 0, sizeof(uVal) ); 66 memset( &uVal, 0, sizeof(uVal) );
67 if( eType == typeString || eType == typeRef ) 67 if( eType == typeString || eType == typeRef )
68 { 68 {
69 uVal.sVal = new Bu::String( *v.uVal.sVal ); 69 uVal.sVal = new Bu::String( *v.uVal.sVal );
70 } 70 }
71 else if( eType == typeList ) 71 else if( eType == typeList )
72 { 72 {
73 uVal.lVal = new VarList( *v.uVal.lVal ); 73 uVal.lVal = new VarList( *v.uVal.lVal );
74 } 74 }
75 else 75 else
76 { 76 {
77 uVal = v.uVal; 77 uVal = v.uVal;
78 } 78 }
79} 79}
80 80
81Variable::Variable( const class AstLeaf &l ) 81Variable::Variable( const class AstLeaf &l )
82{ 82{
83 switch( l.getDataType() ) 83 switch( l.getDataType() )
84 { 84 {
85 case AstNode::typeDataInt: 85 case AstNode::typeDataInt:
86 eType = typeInt; 86 eType = typeInt;
87 uVal.iVal = l.getIntValue(); 87 uVal.iVal = l.getIntValue();
88 break; 88 break;
89 89
90 case AstNode::typeDataFloat: 90 case AstNode::typeDataFloat:
91 eType = typeFloat; 91 eType = typeFloat;
92 uVal.fVal = l.getFloatValue(); 92 uVal.fVal = l.getFloatValue();
93 break; 93 break;
94 94
95 case AstNode::typeDataBool: 95 case AstNode::typeDataBool:
96 eType = typeBool; 96 eType = typeBool;
97 uVal.bVal = l.getBoolValue(); 97 uVal.bVal = l.getBoolValue();
98 break; 98 break;
99 99
100 case AstNode::typeDataString: 100 case AstNode::typeDataString:
101 eType = typeString; 101 eType = typeString;
102 uVal.sVal = new Bu::String( l.getStrValue() ); 102 uVal.sVal = new Bu::String( l.getStrValue() );
103 break; 103 break;
104 104
105 case AstNode::typeDataNone: 105 case AstNode::typeDataNone:
106 eType = typeNone; 106 eType = typeNone;
107 memset( &uVal, 0, sizeof(uVal) ); 107 memset( &uVal, 0, sizeof(uVal) );
108 break; 108 break;
109 109
110 default: 110 default:
111 sio << "Unhandled type <<!>>" << sio.nl << sio.nl; 111 sio << "Unhandled type <<!>>" << sio.nl << sio.nl;
112 break; 112 break;
113 } 113 }
114} 114}
115 115
116Variable::Variable( const StrList &lst ) 116Variable::Variable( const StrList &lst )
117{ 117{
118 if( lst.getSize() == 1 ) 118 if( lst.getSize() == 1 )
119 { 119 {
120 eType = typeString; 120 eType = typeString;
121 uVal.sVal = new Bu::String( lst.first() ); 121 uVal.sVal = new Bu::String( lst.first() );
122 } 122 }
123 else 123 else
124 { 124 {
125 eType = typeList; 125 eType = typeList;
126 uVal.lVal = new VarList(); 126 uVal.lVal = new VarList();
127 for( StrList::const_iterator i = lst.begin(); i; i++ ) 127 for( StrList::const_iterator i = lst.begin(); i; i++ )
128 { 128 {
129 uVal.lVal->append( Variable( *i ) ); 129 uVal.lVal->append( Variable( *i ) );
130 } 130 }
131 } 131 }
132} 132}
133 133
134Variable::Variable( const VarList &lst ) 134Variable::Variable( const VarList &lst )
135{ 135{
136 eType = typeList; 136 eType = typeList;
137 uVal.lVal = new VarList( lst ); 137 uVal.lVal = new VarList( lst );
138} 138}
139 139
140Variable::Variable( void *oVal ) : 140Variable::Variable( void *oVal ) :
141 eType( typeOpaque ) 141 eType( typeOpaque )
142{ 142{
143 memset( &uVal, 0, sizeof(uVal) ); 143 memset( &uVal, 0, sizeof(uVal) );
144 uVal.oVal = oVal; 144 uVal.oVal = oVal;
145} 145}
146 146
147Variable::~Variable() 147Variable::~Variable()
148{ 148{
149 if( eType == typeString || eType == typeRef ) 149 if( eType == typeString || eType == typeRef )
150 { 150 {
151 delete uVal.sVal; 151 delete uVal.sVal;
152 } 152 }
153 else if( eType == typeList ) 153 else if( eType == typeList )
154 { 154 {
155 delete uVal.lVal; 155 delete uVal.lVal;
156 } 156 }
157} 157}
158 158
159Variable Variable::mkRef( const Bu::String &sVal ) 159Variable Variable::mkRef( const Bu::String &sVal )
160{ 160{
161 Variable v( typeRef ); 161 Variable v( typeRef );
162 (*v.uVal.sVal) = sVal; 162 (*v.uVal.sVal) = sVal;
163 return v; 163 return v;
164} 164}
165 165
166Variable::Type Variable::getType() const 166Variable::Type Variable::getType() const
167{ 167{
168 return eType; 168 return eType;
169} 169}
170 170
171int Variable::getInt() const 171int Variable::getInt() const
172{ 172{
173 if( eType != typeInt ) throw Bu::ExceptionBase("Wrong variable type."); 173 if( eType != typeInt ) throw Bu::ExceptionBase("Wrong variable type.");
174 return uVal.iVal; 174 return uVal.iVal;
175} 175}
176 176
177double Variable::getFloat() const 177double Variable::getFloat() const
178{ 178{
179 if( eType != typeFloat ) throw Bu::ExceptionBase("Wrong variable type."); 179 if( eType != typeFloat ) throw Bu::ExceptionBase("Wrong variable type.");
180 return uVal.fVal; 180 return uVal.fVal;
181} 181}
182 182
183bool Variable::getBool() const 183bool Variable::getBool() const
184{ 184{
185 if( eType != typeBool ) throw Bu::ExceptionBase("Wrong variable type."); 185 if( eType != typeBool ) throw Bu::ExceptionBase("Wrong variable type.");
186 return uVal.bVal; 186 return uVal.bVal;
187} 187}
188 188
189const Bu::String &Variable::getString() const 189const Bu::String &Variable::getString() const
190{ 190{
191 if( eType != typeString && eType != typeRef ) throw Bu::ExceptionBase("Wrong variable type."); 191 if( eType != typeString && eType != typeRef ) throw Bu::ExceptionBase("Wrong variable type.");
192 return *uVal.sVal; 192 return *uVal.sVal;
193} 193}
194 194
195const VarList &Variable::getList() const 195const VarList &Variable::getList() const
196{ 196{
197 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type."); 197 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type.");
198 return *uVal.lVal; 198 return *uVal.lVal;
199} 199}
200 200
201const void *Variable::getOpaque() const 201const void *Variable::getOpaque() const
202{ 202{
203 if( eType != typeOpaque ) throw Bu::ExceptionBase("Wrong variable type."); 203 if( eType != typeOpaque ) throw Bu::ExceptionBase("Wrong variable type.");
204 return uVal.oVal; 204 return uVal.oVal;
205} 205}
206 206
207int Variable::toInt() const 207int Variable::toInt() const
208{ 208{
209 switch( eType ) 209 switch( eType )
210 { 210 {
211 case typeInt: 211 case typeInt:
212 return uVal.iVal; 212 return uVal.iVal;
213 213
214 case typeFloat: 214 case typeFloat:
215 return (int)uVal.fVal; 215 return (int)uVal.fVal;
216 216
217 case typeBool: 217 case typeBool:
218 return (uVal.bVal)?(1):(0); 218 return (uVal.bVal)?(1):(0);
219 219
220 case typeString: 220 case typeString:
221 case typeRef: 221 case typeRef:
222 return strtol( uVal.sVal->getStr(), NULL, 0 ); 222 return strtol( uVal.sVal->getStr(), NULL, 0 );
223 223
224 default: 224 default:
225 return 0; 225 return 0;
226 } 226 }
227 return 0; 227 return 0;
228} 228}
229 229
230double Variable::toFloat() const 230double Variable::toFloat() const
231{ 231{
232 switch( eType ) 232 switch( eType )
233 { 233 {
234 case typeInt: 234 case typeInt:
235 return (double)uVal.iVal; 235 return (double)uVal.iVal;
236 236
237 case typeFloat: 237 case typeFloat:
238 return uVal.fVal; 238 return uVal.fVal;
239 239
240 case typeBool: 240 case typeBool:
241 return (uVal.bVal)?(1.0):(0.0); 241 return (uVal.bVal)?(1.0):(0.0);
242 242
243 case typeString: 243 case typeString:
244 case typeRef: 244 case typeRef:
245 return strtod( uVal.sVal->getStr(), NULL ); 245 return strtod( uVal.sVal->getStr(), NULL );
246 246
247 default: 247 default:
248 return 0.0; 248 return 0.0;
249 } 249 }
250 return 0.0; 250 return 0.0;
251} 251}
252 252
253bool Variable::toBool() const 253bool Variable::toBool() const
254{ 254{
255 switch( eType ) 255 switch( eType )
256 { 256 {
257 case typeInt: 257 case typeInt:
258 return uVal.iVal != 0; 258 return uVal.iVal != 0;
259 259
260 case typeFloat: 260 case typeFloat:
261 return uVal.fVal != 0.0; 261 return uVal.fVal != 0.0;
262 262
263 case typeBool: 263 case typeBool:
264 return uVal.bVal; 264 return uVal.bVal;
265 265
266 case typeString: 266 case typeString:
267 case typeRef: 267 case typeRef:
268 return (*uVal.sVal) == "true"; 268 return (*uVal.sVal) == "true";
269 269
270 case typeList: 270 case typeList:
271 return !(*uVal.lVal).isEmpty(); 271 return !(*uVal.lVal).isEmpty();
272 272
273 default: 273 default:
274 return false; 274 return false;
275 } 275 }
276 return false; 276 return false;
277} 277}
278 278
279Bu::String Variable::toString() const 279Bu::String Variable::toString() const
280{ 280{
281 Bu::String sRet; 281 Bu::String sRet;
282 switch( eType ) 282 switch( eType )
283 { 283 {
284 case typeNone: 284 case typeNone:
285 // No type, no data, we return empty string 285 // No type, no data, we return empty string
286 break; 286 break;
287 287
288 case typeInt: 288 case typeInt:
289 sRet = Bu::String("%1").arg( uVal.iVal ); 289 sRet = Bu::String("%1").arg( uVal.iVal );
290 break; 290 break;
291 291
292 case typeFloat: 292 case typeFloat:
293 sRet = Bu::String("%1").arg( uVal.fVal ); 293 sRet = Bu::String("%1").arg( uVal.fVal );
294 break; 294 break;
295 295
296 case typeBool: 296 case typeBool:
297 sRet = (uVal.bVal)?("true"):("false"); 297 sRet = (uVal.bVal)?("true"):("false");
298 break; 298 break;
299 299
300 case typeString: 300 case typeString:
301 case typeRef: 301 case typeRef:
302 sRet = *uVal.sVal; 302 sRet = *uVal.sVal;
303 break; 303 break;
304 304
305 case typeList: 305 case typeList:
306 { 306 {
307 for( VarList::const_iterator i = uVal.lVal->begin(); i; i++ ) 307 for( VarList::const_iterator i = uVal.lVal->begin(); i; i++ )
308 { 308 {
309 if( i != uVal.lVal->begin() ) 309 if( i != uVal.lVal->begin() )
310 sRet += " "; 310 sRet += " ";
311 sRet += (*i).toString(); 311 sRet += (*i).toString();
312 } 312 }
313 } 313 }
314 break; 314 break;
315 315
316 case typeVersion: 316 case typeVersion:
317 break; 317 break;
318 318
319 case typeOpaque: 319 case typeOpaque:
320 sRet = Bu::String("<opaque:%1>").arg( uVal.oVal ); 320 sRet = Bu::String("<opaque:%1>").arg( uVal.oVal );
321 break; 321 break;
322 } 322 }
323 323
324 return sRet; 324 return sRet;
325} 325}
326 326
327VarList Variable::toList() const 327VarList Variable::toList() const
328{ 328{
329 if( eType == typeList ) 329 if( eType == typeList )
330 return *uVal.lVal; 330 return *uVal.lVal;
331 return VarList( *this ); 331 return VarList( *this );
332} 332}
333 333
334Variable Variable::toType( Type eNewType ) const 334Variable Variable::toType( Type eNewType ) const
335{ 335{
336 switch( eNewType ) 336 switch( eNewType )
337 { 337 {
338 case typeNone: 338 case typeNone:
339 return Variable(); 339 return Variable();
340 340
341 case typeBool: 341 case typeBool:
342 return Variable( toBool() ); 342 return Variable( toBool() );
343 343
344 case typeInt: 344 case typeInt:
345 return Variable( toInt() ); 345 return Variable( toInt() );
346 346
347 case typeFloat: 347 case typeFloat:
348 return Variable( toFloat() ); 348 return Variable( toFloat() );
349 349
350 case typeVersion: 350 case typeVersion:
351 return Variable(); 351 return Variable();
352 352
353 case typeString: 353 case typeString:
354 return Variable( toString() ); 354 return Variable( toString() );
355 355
356 case typeList: 356 case typeList:
357 return Variable( toList() ); 357 return Variable( toList() );
358 358
359 case typeRef: 359 case typeRef:
360 return Variable::mkRef( toString() ); 360 return Variable::mkRef( toString() );
361 361
362 case typeOpaque: 362 case typeOpaque:
363 throw Bu::ExceptionBase("Cannot convert opaque types."); 363 throw Bu::ExceptionBase("Cannot convert opaque types.");
364 } 364 }
365 throw Bu::ExceptionBase("Unhandled case in Variable toType"); 365 throw Bu::ExceptionBase("Unhandled case in Variable toType");
366} 366}
367 367
368void Variable::append( const Variable &v ) 368void Variable::append( const Variable &v )
369{ 369{
370 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type."); 370 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type.");
371 371
372 if( v.eType == typeList ) 372 if( v.eType == typeList )
373 { 373 {
374 uVal.lVal->append( *v.uVal.lVal ); 374 uVal.lVal->append( *v.uVal.lVal );
375 } 375 }
376 else 376 else
377 { 377 {
378 uVal.lVal->append( v ); 378 uVal.lVal->append( v );
379 } 379 }
380} 380}
381 381
382VarList::iterator Variable::begin() 382VarList::iterator Variable::begin()
383{ 383{
384 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type."); 384 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type.");
385 385
386 return uVal.lVal->begin(); 386 return uVal.lVal->begin();
387} 387}
388 388
389VarList::const_iterator Variable::begin() const 389VarList::const_iterator Variable::begin() const
390{ 390{
391 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type."); 391 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type.");
392 392
393 return const_cast<const VarList *>(uVal.lVal)->begin(); 393 return const_cast<const VarList *>(uVal.lVal)->begin();
394} 394}
395 395
396void Variable::doNegate() 396void Variable::doNegate()
397{ 397{
398 switch( eType ) 398 switch( eType )
399 { 399 {
400 case typeNone: 400 case typeNone:
401 break; 401 break;
402 402
403 case typeBool: 403 case typeBool:
404 throw Bu::ExceptionBase("You cannot negate boolean values."); 404 throw Bu::ExceptionBase("You cannot negate boolean values.");
405 405
406 case typeInt: 406 case typeInt:
407 uVal.iVal = -uVal.iVal; 407 uVal.iVal = -uVal.iVal;
408 break; 408 break;
409 409
410 case typeFloat: 410 case typeFloat:
411 uVal.fVal = -uVal.fVal; 411 uVal.fVal = -uVal.fVal;
412 break; 412 break;
413 413
414 case typeVersion: 414 case typeVersion:
415 throw Bu::ExceptionBase("You cannot negate version values."); 415 throw Bu::ExceptionBase("You cannot negate version values.");
416 416
417 case typeString: 417 case typeString:
418 throw Bu::ExceptionBase("You cannot negate string values."); 418 throw Bu::ExceptionBase("You cannot negate string values.");
419 419
420 case typeList: 420 case typeList:
421 throw Bu::ExceptionBase("You cannot negate list values."); 421 throw Bu::ExceptionBase("You cannot negate list values.");
422 422
423 case typeRef: 423 case typeRef:
424 throw Bu::ExceptionBase("You cannot negate reference values."); 424 throw Bu::ExceptionBase("You cannot negate reference values.");
425 425
426 case typeOpaque: 426 case typeOpaque:
427 throw Bu::ExceptionBase("You cannot negate opaque values."); 427 throw Bu::ExceptionBase("You cannot negate opaque values.");
428 } 428 }
429} 429}
430 430
431void Variable::doNot() 431void Variable::doNot()
432{ 432{
433 bool bVal = !toBool(); 433 bool bVal = !toBool();
434 reset( typeBool ); 434 reset( typeBool );
435 uVal.bVal = bVal; 435 uVal.bVal = bVal;
436} 436}
437 437
438const Variable &Variable::operator=( const Variable &rhs ) 438const Variable &Variable::operator=( const Variable &rhs )
439{ 439{
440 reset( rhs.eType ); 440 reset( rhs.eType );
441 if( rhs.eType == typeString || rhs.eType == typeRef ) 441 if( rhs.eType == typeString || rhs.eType == typeRef )
442 { 442 {
443 uVal.sVal = new Bu::String( *rhs.uVal.sVal ); 443 uVal.sVal = new Bu::String( *rhs.uVal.sVal );
444 } 444 }
445 else if( rhs.eType == typeList ) 445 else if( rhs.eType == typeList )
446 { 446 {
447 uVal.lVal = new VarList( *rhs.uVal.lVal ); 447 uVal.lVal = new VarList( *rhs.uVal.lVal );
448 } 448 }
449 else 449 else
450 { 450 {
451 uVal = rhs.uVal; 451 uVal = rhs.uVal;
452 } 452 }
453 453
454 return *this; 454 return *this;
455} 455}
456 456
457const Variable &Variable::operator=( const int &rhs ) 457const Variable &Variable::operator=( const int &rhs )
458{ 458{
459 reset( typeInt ); 459 reset( typeInt );
460 uVal.iVal = rhs; 460 uVal.iVal = rhs;
461 461
462 return *this; 462 return *this;
463} 463}
464 464
465const Variable &Variable::operator=( const double &rhs ) 465const Variable &Variable::operator=( const double &rhs )
466{ 466{
467 reset( typeFloat ); 467 reset( typeFloat );
468 uVal.fVal = rhs; 468 uVal.fVal = rhs;
469 469
470 return *this; 470 return *this;
471} 471}
472 472
473const Variable &Variable::operator=( const bool &rhs ) 473const Variable &Variable::operator=( const bool &rhs )
474{ 474{
475 reset( typeBool ); 475 reset( typeBool );
476 uVal.bVal = rhs; 476 uVal.bVal = rhs;
477 477
478 return *this; 478 return *this;
479} 479}
480 480
481const Variable &Variable::operator=( const Bu::String &rhs ) 481const Variable &Variable::operator=( const Bu::String &rhs )
482{ 482{
483 reset( typeString ); 483 reset( typeString );
484 uVal.sVal = new Bu::String( rhs ); 484 uVal.sVal = new Bu::String( rhs );
485 485
486 return *this; 486 return *this;
487} 487}
488 488
489const Variable &Variable::operator=( void *rhs ) 489const Variable &Variable::operator=( void *rhs )
490{ 490{
491 reset( typeOpaque ); 491 reset( typeOpaque );
492 uVal.oVal = rhs; 492 uVal.oVal = rhs;
493 493
494 return *this; 494 return *this;
495} 495}
496 496
497const Variable &Variable::operator+=( const Variable &rhs ) 497const Variable &Variable::operator+=( const Variable &rhs )
498{ 498{
499 switch( eType ) 499 switch( eType )
500 { 500 {
501 case typeNone: 501 case typeNone:
502 reset( rhs.eType ); 502 reset( rhs.eType );
503 if( eType == typeString || eType == typeRef ) 503 if( eType == typeString || eType == typeRef )
504 { 504 {
505 uVal.sVal = new Bu::String( *rhs.uVal.sVal ); 505 uVal.sVal = new Bu::String( *rhs.uVal.sVal );
506 } 506 }
507 else if( eType == typeList ) 507 else if( eType == typeList )
508 { 508 {
509 uVal.lVal = new VarList( *rhs.uVal.lVal ); 509 uVal.lVal = new VarList( *rhs.uVal.lVal );
510 } 510 }
511 else 511 else
512 { 512 {
513 uVal = rhs.uVal; 513 uVal = rhs.uVal;
514 } 514 }
515 break; 515 break;
516 516
517 case typeInt: 517 case typeInt:
518 uVal.iVal += rhs.getInt(); 518 uVal.iVal += rhs.getInt();
519 break; 519 break;
520 520
521 case typeFloat: 521 case typeFloat:
522 uVal.fVal += rhs.getFloat(); 522 uVal.fVal += rhs.getFloat();
523 break; 523 break;
524 524
525 case typeBool: 525 case typeBool:
526 throw Bu::ExceptionBase("Can't += with a boolean..."); 526 throw Bu::ExceptionBase("Can't += with a boolean...");
527 break; 527 break;
528 528
529 case typeString: 529 case typeString:
530 uVal.sVal->append(" "); 530 uVal.sVal->append(" ");
531 uVal.sVal->append( rhs.getString() ); 531 uVal.sVal->append( rhs.getString() );
532 break; 532 break;
533 533
534 case typeList: 534 case typeList:
535 uVal.lVal->append( rhs.getList() ); 535 uVal.lVal->append( rhs.getList() );
536 break; 536 break;
537 537
538 case typeVersion: 538 case typeVersion:
539 break; 539 break;
540 540
541 default: 541 default:
542 break; 542 break;
543 } 543 }
544 return *this; 544 return *this;
545} 545}
546 546
547const Variable &Variable::operator<<( const Variable &rhs ) 547const Variable &Variable::operator<<( const Variable &rhs )
548{ 548{
549 switch( eType ) 549 switch( eType )
550 { 550 {
551 case typeNone: 551 case typeNone:
552 reset( rhs.eType ); 552 reset( rhs.eType );
553 if( eType == typeString ) 553 if( eType == typeString )
554 { 554 {
555 uVal.sVal = new Bu::String( *rhs.uVal.sVal ); 555 uVal.sVal = new Bu::String( *rhs.uVal.sVal );
556 } 556 }
557 else if( eType == typeList ) 557 else if( eType == typeList )
558 { 558 {
559 uVal.lVal = new VarList( *rhs.uVal.lVal ); 559 uVal.lVal = new VarList( *rhs.uVal.lVal );
560 } 560 }
561 else 561 else
562 { 562 {
563 uVal = rhs.uVal; 563 uVal = rhs.uVal;
564 } 564 }
565 break; 565 break;
566 566
567 case typeString: 567 case typeString:
568 uVal.sVal->append( rhs.getString() ); 568 uVal.sVal->append( rhs.getString() );
569 break; 569 break;
570 570
571 case typeList: 571 case typeList:
572 uVal.lVal->append( rhs.getList() ); 572 uVal.lVal->append( rhs.getList() );
573 break; 573 break;
574 574
575 default: 575 default:
576 throw Bu::ExceptionBase("Can't << with non-string or non-list."); 576 throw Bu::ExceptionBase("Can't << with non-string or non-list.");
577 break; 577 break;
578 } 578 }
579 return *this; 579 return *this;
580} 580}
581 581
582bool Variable::operator==( const Variable &rhs ) const 582bool Variable::operator==( const Variable &rhs ) const
583{ 583{
584 if( eType != rhs.eType ) 584 if( eType != rhs.eType )
585 return false; 585 return false;
586 switch( eType ) 586 switch( eType )
587 { 587 {
588 case typeNone: 588 case typeNone:
589 return true; 589 return true;
590 590
591 case typeInt: 591 case typeInt:
592 return uVal.iVal == rhs.uVal.iVal; 592 return uVal.iVal == rhs.uVal.iVal;
593 593
594 case typeFloat: 594 case typeFloat:
595 return uVal.fVal == rhs.uVal.fVal; 595 return uVal.fVal == rhs.uVal.fVal;
596 596
597 case typeBool: 597 case typeBool:
598 return uVal.bVal == rhs.uVal.bVal; 598 return uVal.bVal == rhs.uVal.bVal;
599 599
600 case typeString: 600 case typeString:
601 case typeRef: 601 case typeRef:
602 return *uVal.sVal == *rhs.uVal.sVal; 602 return *uVal.sVal == *rhs.uVal.sVal;
603 603
604 case typeList: 604 case typeList:
605 return *uVal.lVal == *rhs.uVal.lVal; 605 return *uVal.lVal == *rhs.uVal.lVal;
606 606
607 case typeVersion: 607 case typeVersion:
608 return false; 608 return false;
609 609
610 case typeOpaque: 610 case typeOpaque:
611 return uVal.oVal == rhs.uVal.oVal; 611 return uVal.oVal == rhs.uVal.oVal;
612 } 612 }
613 613
614 return false; 614 return false;
615} 615}
616 616
617bool Variable::operator!=( const Variable &rhs ) const 617bool Variable::operator!=( const Variable &rhs ) const
618{ 618{
619 return !(*this == rhs); 619 return !(*this == rhs);
620} 620}
621 621
622bool Variable::operator<( const Variable &rhs ) const 622bool Variable::operator<( const Variable &rhs ) const
623{ 623{
624 Type eTop = Bu::buMax( eType, rhs.eType ); 624 Type eTop = Bu::buMax( eType, rhs.eType );
625 switch( eTop ) 625 switch( eTop )
626 { 626 {
627 case typeNone: 627 case typeNone:
628 return false; 628 return false;
629 629
630 case typeBool: 630 case typeBool:
631 throw Bu::ExceptionBase("You cannot < compare boolean values."); 631 throw Bu::ExceptionBase("You cannot < compare boolean values.");
632 632
633 case typeInt: 633 case typeInt:
634 return toInt() < rhs.toInt(); 634 return toInt() < rhs.toInt();
635 635
636 case typeFloat: 636 case typeFloat:
637 return toFloat() < rhs.toFloat(); 637 return toFloat() < rhs.toFloat();
638 638
639 case typeVersion: 639 case typeVersion:
640 return true; 640 return true;
641 641
642 case typeString: 642 case typeString:
643 return toString() < rhs.toString(); 643 return toString() < rhs.toString();
644 644
645 case typeList: 645 case typeList:
646 throw Bu::ExceptionBase("You cannot < compare list values."); 646 throw Bu::ExceptionBase("You cannot < compare list values.");
647 647
648 case typeRef: 648 case typeRef:
649 throw Bu::ExceptionBase("You cannot < compare reference values."); 649 throw Bu::ExceptionBase("You cannot < compare reference values.");
650 650
651 case typeOpaque: 651 case typeOpaque:
652 throw Bu::ExceptionBase("You cannot < compare opaque values."); 652 throw Bu::ExceptionBase("You cannot < compare opaque values.");
653 } 653 }
654 throw Bu::ExceptionBase("Unhandled case in Variable < compare"); 654 throw Bu::ExceptionBase("Unhandled case in Variable < compare");
655} 655}
656 656
657bool Variable::operator>( const Variable &rhs ) const 657bool Variable::operator>( const Variable &rhs ) const
658{ 658{
659 Type eTop = Bu::buMax( eType, rhs.eType ); 659 Type eTop = Bu::buMax( eType, rhs.eType );
660 switch( eTop ) 660 switch( eTop )
661 { 661 {
662 case typeNone: 662 case typeNone:
663 return false; 663 return false;
664 664
665 case typeBool: 665 case typeBool:
666 throw Bu::ExceptionBase("You cannot > compare boolean values."); 666 throw Bu::ExceptionBase("You cannot > compare boolean values.");
667 667
668 case typeInt: 668 case typeInt:
669 return toInt() > rhs.toInt(); 669 return toInt() > rhs.toInt();
670 670
671 case typeFloat: 671 case typeFloat:
672 return toFloat() > rhs.toFloat(); 672 return toFloat() > rhs.toFloat();
673 673
674 case typeVersion: 674 case typeVersion:
675 return true; 675 return true;
676 676
677 case typeString: 677 case typeString:
678 return toString() > rhs.toString(); 678 return toString() > rhs.toString();
679 679
680 case typeList: 680 case typeList:
681 throw Bu::ExceptionBase("You cannot > compare list values."); 681 throw Bu::ExceptionBase("You cannot > compare list values.");
682 682
683 case typeRef: 683 case typeRef:
684 throw Bu::ExceptionBase("You cannot > compare reference values."); 684 throw Bu::ExceptionBase("You cannot > compare reference values.");
685 685
686 case typeOpaque: 686 case typeOpaque:
687 throw Bu::ExceptionBase("You cannot > compare opaque values."); 687 throw Bu::ExceptionBase("You cannot > compare opaque values.");
688 } 688 }
689 throw Bu::ExceptionBase("Unhandled case in Variable > compare"); 689 throw Bu::ExceptionBase("Unhandled case in Variable > compare");
690} 690}
691 691
692bool Variable::operator<=( const Variable &rhs ) const 692bool Variable::operator<=( const Variable &rhs ) const
693{ 693{
694 Type eTop = Bu::buMax( eType, rhs.eType ); 694 Type eTop = Bu::buMax( eType, rhs.eType );
695 switch( eTop ) 695 switch( eTop )
696 { 696 {
697 case typeNone: 697 case typeNone:
698 return false; 698 return false;
699 699
700 case typeBool: 700 case typeBool:
701 throw Bu::ExceptionBase("You cannot <= compare boolean values."); 701 throw Bu::ExceptionBase("You cannot <= compare boolean values.");
702 702
703 case typeInt: 703 case typeInt:
704 return toInt() <= rhs.toInt(); 704 return toInt() <= rhs.toInt();
705 705
706 case typeFloat: 706 case typeFloat:
707 return toFloat() <= rhs.toFloat(); 707 return toFloat() <= rhs.toFloat();
708 708
709 case typeVersion: 709 case typeVersion:
710 return true; 710 return true;
711 711
712 case typeString: 712 case typeString:
713 return toString() <= rhs.toString(); 713 return toString() <= rhs.toString();
714 714
715 case typeList: 715 case typeList:
716 throw Bu::ExceptionBase("You cannot <= compare list values."); 716 throw Bu::ExceptionBase("You cannot <= compare list values.");
717 717
718 case typeRef: 718 case typeRef:
719 throw Bu::ExceptionBase("You cannot <= compare reference values."); 719 throw Bu::ExceptionBase("You cannot <= compare reference values.");
720 720
721 case typeOpaque: 721 case typeOpaque:
722 throw Bu::ExceptionBase("You cannot <= compare opaque values."); 722 throw Bu::ExceptionBase("You cannot <= compare opaque values.");
723 } 723 }
724 throw Bu::ExceptionBase("Unhandled case in Variable <= compare"); 724 throw Bu::ExceptionBase("Unhandled case in Variable <= compare");
725} 725}
726 726
727bool Variable::operator>=( const Variable &rhs ) const 727bool Variable::operator>=( const Variable &rhs ) const
728{ 728{
729 Type eTop = Bu::buMax( eType, rhs.eType ); 729 Type eTop = Bu::buMax( eType, rhs.eType );
730 switch( eTop ) 730 switch( eTop )
731 { 731 {
732 case typeNone: 732 case typeNone:
733 return false; 733 return false;
734 734
735 case typeBool: 735 case typeBool:
736 throw Bu::ExceptionBase("You cannot >= compare boolean values."); 736 throw Bu::ExceptionBase("You cannot >= compare boolean values.");
737 737
738 case typeInt: 738 case typeInt:
739 return toInt() >= rhs.toInt(); 739 return toInt() >= rhs.toInt();
740 740
741 case typeFloat: 741 case typeFloat:
742 return toFloat() >= rhs.toFloat(); 742 return toFloat() >= rhs.toFloat();
743 743
744 case typeVersion: 744 case typeVersion:
745 return true; 745 return true;
746 746
747 case typeString: 747 case typeString:
748 return toString() >= rhs.toString(); 748 return toString() >= rhs.toString();
749 749
750 case typeList: 750 case typeList:
751 throw Bu::ExceptionBase("You cannot >= compare list values."); 751 throw Bu::ExceptionBase("You cannot >= compare list values.");
752 752
753 case typeRef: 753 case typeRef:
754 throw Bu::ExceptionBase("You cannot >= compare reference values."); 754 throw Bu::ExceptionBase("You cannot >= compare reference values.");
755 755
756 case typeOpaque: 756 case typeOpaque:
757 throw Bu::ExceptionBase("You cannot >= compare opaque values."); 757 throw Bu::ExceptionBase("You cannot >= compare opaque values.");
758 } 758 }
759 throw Bu::ExceptionBase("Unhandled case in Variable >= compare"); 759 throw Bu::ExceptionBase("Unhandled case in Variable >= compare");
760} 760}
761 761
762Variable Variable::operator+( const Variable &rhs ) const 762Variable Variable::operator+( const Variable &rhs ) const
763{ 763{
764 Type eTop = Bu::buMax( eType, rhs.eType ); 764 Type eTop = Bu::buMax( eType, rhs.eType );
765 switch( eTop ) 765 switch( eTop )
766 { 766 {
767 case typeNone: 767 case typeNone:
768 return Variable(); 768 return Variable();
769 769
770 case typeBool: 770 case typeBool:
771 throw Bu::ExceptionBase("You cannot add boolean values."); 771 throw Bu::ExceptionBase("You cannot add boolean values.");
772 772
773 case typeInt: 773 case typeInt:
774 return Variable( toInt() + rhs.toInt() ); 774 return Variable( toInt() + rhs.toInt() );
775 775
776 case typeFloat: 776 case typeFloat:
777 return Variable( toFloat() + rhs.toFloat() ); 777 return Variable( toFloat() + rhs.toFloat() );
778 778
779 case typeVersion: 779 case typeVersion:
780 throw Bu::ExceptionBase("You cannot add version values."); 780 throw Bu::ExceptionBase("You cannot add version values.");
781 781
782 case typeString: 782 case typeString:
783 return Variable( toString() + rhs.toString() ); 783 return Variable( toString() + rhs.toString() );
784 784
785 case typeList: 785 case typeList:
786 return Variable( toList() + rhs.toList() ); 786 return Variable( toList() + rhs.toList() );
787 787
788 case typeRef: 788 case typeRef:
789 throw Bu::ExceptionBase("You cannot add reference values."); 789 throw Bu::ExceptionBase("You cannot add reference values.");
790 790
791 case typeOpaque: 791 case typeOpaque:
792 throw Bu::ExceptionBase("You cannot add opaque values."); 792 throw Bu::ExceptionBase("You cannot add opaque values.");
793 } 793 }
794 throw Bu::ExceptionBase("Unhandled case in Variable add"); 794 throw Bu::ExceptionBase("Unhandled case in Variable add");
795} 795}
796 796
797Variable Variable::operator-( const Variable &rhs ) const 797Variable Variable::operator-( const Variable &rhs ) const
798{ 798{
799 Type eTop = Bu::buMax( eType, rhs.eType ); 799 Type eTop = Bu::buMax( eType, rhs.eType );
800 switch( eTop ) 800 switch( eTop )
801 { 801 {
802 case typeNone: 802 case typeNone:
803 return Variable(); 803 return Variable();
804 804
805 case typeBool: 805 case typeBool:
806 throw Bu::ExceptionBase("You cannot subtract boolean values."); 806 throw Bu::ExceptionBase("You cannot subtract boolean values.");
807 807
808 case typeInt: 808 case typeInt:
809 return Variable( toInt() - rhs.toInt() ); 809 return Variable( toInt() - rhs.toInt() );
810 810
811 case typeFloat: 811 case typeFloat:
812 return Variable( toFloat() - rhs.toFloat() ); 812 return Variable( toFloat() - rhs.toFloat() );
813 813
814 case typeVersion: 814 case typeVersion:
815 throw Bu::ExceptionBase("You cannot subtract version values."); 815 throw Bu::ExceptionBase("You cannot subtract version values.");
816 816
817 case typeString: 817 case typeString:
818 throw Bu::ExceptionBase("You cannot subtract string values."); 818 throw Bu::ExceptionBase("You cannot subtract string values.");
819 819
820 case typeList: 820 case typeList:
821 return Variable( toList() - rhs.toList() ); 821 return Variable( toList() - rhs.toList() );
822 822
823 case typeRef: 823 case typeRef:
824 throw Bu::ExceptionBase("You cannot subtract reference values."); 824 throw Bu::ExceptionBase("You cannot subtract reference values.");
825 825
826 case typeOpaque: 826 case typeOpaque:
827 throw Bu::ExceptionBase("You cannot subtract opaque values."); 827 throw Bu::ExceptionBase("You cannot subtract opaque values.");
828 } 828 }
829 throw Bu::ExceptionBase("Unhandled case in Variable subtract"); 829 throw Bu::ExceptionBase("Unhandled case in Variable subtract");
830} 830}
831 831
832Variable Variable::operator*( const Variable &rhs ) const 832Variable Variable::operator*( const Variable &rhs ) const
833{ 833{
834 Type eTop = Bu::buMax( eType, rhs.eType ); 834 Type eTop = Bu::buMax( eType, rhs.eType );
835 switch( eTop ) 835 switch( eTop )
836 { 836 {
837 case typeNone: 837 case typeNone:
838 return Variable(); 838 return Variable();
839 839
840 case typeBool: 840 case typeBool:
841 throw Bu::ExceptionBase("You cannot multiply boolean values."); 841 throw Bu::ExceptionBase("You cannot multiply boolean values.");
842 842
843 case typeInt: 843 case typeInt:
844 return Variable( toInt() * rhs.toInt() ); 844 return Variable( toInt() * rhs.toInt() );
845 845
846 case typeFloat: 846 case typeFloat:
847 return Variable( toFloat() * rhs.toFloat() ); 847 return Variable( toFloat() * rhs.toFloat() );
848 848
849 case typeVersion: 849 case typeVersion:
850 throw Bu::ExceptionBase("You cannot multiply version values."); 850 throw Bu::ExceptionBase("You cannot multiply version values.");
851 851
852 case typeString: 852 case typeString:
853 throw Bu::ExceptionBase("You cannot multiply string values."); 853 throw Bu::ExceptionBase("You cannot multiply string values.");
854 854
855 case typeList: 855 case typeList:
856 throw Bu::ExceptionBase("You cannot multiply list values."); 856 throw Bu::ExceptionBase("You cannot multiply list values.");
857 857
858 case typeRef: 858 case typeRef:
859 throw Bu::ExceptionBase("You cannot multiply reference values."); 859 throw Bu::ExceptionBase("You cannot multiply reference values.");
860 860
861 case typeOpaque: 861 case typeOpaque:
862 throw Bu::ExceptionBase("You cannot multiply opaque values."); 862 throw Bu::ExceptionBase("You cannot multiply opaque values.");
863 } 863 }
864 throw Bu::ExceptionBase("Unhandled case in Variable multiply"); 864 throw Bu::ExceptionBase("Unhandled case in Variable multiply");
865} 865}
866 866
867Variable Variable::operator/( const Variable &rhs ) const 867Variable Variable::operator/( const Variable &rhs ) const
868{ 868{
869 Type eTop = Bu::buMax( eType, rhs.eType ); 869 Type eTop = Bu::buMax( eType, rhs.eType );
870 switch( eTop ) 870 switch( eTop )
871 { 871 {
872 case typeNone: 872 case typeNone:
873 return Variable(); 873 return Variable();
874 874
875 case typeBool: 875 case typeBool:
876 throw Bu::ExceptionBase("You cannot divide boolean values."); 876 throw Bu::ExceptionBase("You cannot divide boolean values.");
877 877
878 case typeInt: 878 case typeInt:
879 return Variable( toInt() / rhs.toInt() ); 879 return Variable( toInt() / rhs.toInt() );
880 880
881 case typeFloat: 881 case typeFloat:
882 return Variable( toFloat() / rhs.toFloat() ); 882 return Variable( toFloat() / rhs.toFloat() );
883 883
884 case typeVersion: 884 case typeVersion:
885 throw Bu::ExceptionBase("You cannot divide version values."); 885 throw Bu::ExceptionBase("You cannot divide version values.");
886 886
887 case typeString: 887 case typeString:
888 throw Bu::ExceptionBase("You cannot divide string values."); 888 throw Bu::ExceptionBase("You cannot divide string values.");
889 889
890 case typeList: 890 case typeList:
891 throw Bu::ExceptionBase("You cannot divide list values."); 891 throw Bu::ExceptionBase("You cannot divide list values.");
892 892
893 case typeRef: 893 case typeRef:
894 throw Bu::ExceptionBase("You cannot divide reference values."); 894 throw Bu::ExceptionBase("You cannot divide reference values.");
895 895
896 case typeOpaque: 896 case typeOpaque:
897 throw Bu::ExceptionBase("You cannot divide opaque values."); 897 throw Bu::ExceptionBase("You cannot divide opaque values.");
898 } 898 }
899 throw Bu::ExceptionBase("Unhandled case in Variable divide"); 899 throw Bu::ExceptionBase("Unhandled case in Variable divide");
900} 900}
901 901
902void Variable::reset( Type eNewType ) 902void Variable::reset( Type eNewType )
903{ 903{
904 if( eType == typeString || eType == typeRef ) 904 if( eType == typeString || eType == typeRef )
905 { 905 {
906 delete uVal.sVal; 906 delete uVal.sVal;
907 } 907 }
908 else if( eType == typeList ) 908 else if( eType == typeList )
909 { 909 {
910 delete uVal.lVal; 910 delete uVal.lVal;
911 } 911 }
912 memset( &uVal, 0, sizeof(uVal) ); 912 memset( &uVal, 0, sizeof(uVal) );
913 913
914 eType = eNewType; 914 eType = eNewType;
915} 915}
916 916
917Bu::Formatter &operator<<( Bu::Formatter &f, const Variable::Type &t ) 917Bu::Formatter &operator<<( Bu::Formatter &f, const Variable::Type &t )
918{ 918{
919 switch( t ) 919 switch( t )
920 { 920 {
921 case Variable::typeNone: f << "*typeless*"; break; 921 case Variable::typeNone: f << "*typeless*"; break;
922 case Variable::typeInt: f << "int"; break; 922 case Variable::typeInt: f << "int"; break;
923 case Variable::typeFloat: f << "double"; break; 923 case Variable::typeFloat: f << "double"; break;
924 case Variable::typeBool: f << "bool"; break; 924 case Variable::typeBool: f << "bool"; break;
925 case Variable::typeString: f << "string"; break; 925 case Variable::typeString: f << "string"; break;
926 case Variable::typeList: f << "list"; break; 926 case Variable::typeList: f << "list"; break;
927 case Variable::typeVersion: f << "version"; break; 927 case Variable::typeVersion: f << "version"; break;
928 case Variable::typeRef: f << "ref"; break; 928 case Variable::typeRef: f << "ref"; break;
929 case Variable::typeOpaque: f << "opaque"; break; 929 case Variable::typeOpaque: f << "opaque"; break;
930 } 930 }
931 return f; 931 return f;
932} 932}
933 933
934Bu::Formatter &operator<<( Bu::Formatter &f, const Variable &v ) 934Bu::Formatter &operator<<( Bu::Formatter &f, const Variable &v )
935{ 935{
936 f << "Variable(" << v.getType() << ") = "; 936 f << "Variable(" << v.getType() << ") = ";
937 switch( v.getType() ) 937 switch( v.getType() )
938 { 938 {
939 case Variable::typeNone: break; 939 case Variable::typeNone: break;
940 case Variable::typeInt: f << v.getInt(); break; 940 case Variable::typeInt: f << v.getInt(); break;
941 case Variable::typeFloat: f << v.getFloat(); break; 941 case Variable::typeFloat: f << v.getFloat(); break;
942 case Variable::typeBool: f << v.getBool(); break; 942 case Variable::typeBool: f << v.getBool(); break;
943 case Variable::typeString: f << v.getString(); break; 943 case Variable::typeString: f << v.getString(); break;
944 case Variable::typeList: f << v.getList(); break; 944 case Variable::typeList: f << v.getList(); break;
945 case Variable::typeVersion:/*f << v.getVersion();*/ break; 945 case Variable::typeVersion:/*f << v.getVersion();*/ break;
946 case Variable::typeRef: f << v.getString(); break; 946 case Variable::typeRef: f << v.getString(); break;
947 case Variable::typeOpaque: f << "<opaque:" << v.getOpaque() << ">"; 947 case Variable::typeOpaque: f << "<opaque:" << v.getOpaque() << ">";
948 break; 948 break;
949 } 949 }
950 950
951 return f; 951 return f;
952} 952}
953 953
954Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Variable &v ) 954Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Variable &v )
955{ 955{
956 ar << (int8_t)v.eType; 956 ar << (int8_t)v.eType;
957 switch( v.eType ) 957 switch( v.eType )
958 { 958 {
959 case Variable::typeNone: 959 case Variable::typeNone:
960 break; 960 break;
961 961
962 case Variable::typeBool: 962 case Variable::typeBool:
963 ar << v.uVal.bVal; 963 ar << v.uVal.bVal;
964 break; 964 break;
965 965
966 case Variable::typeInt: 966 case Variable::typeInt:
967 ar << v.uVal.iVal; 967 ar << v.uVal.iVal;
968 break; 968 break;
969 969
970 case Variable::typeFloat: 970 case Variable::typeFloat:
971 ar << v.uVal.fVal; 971 ar << v.uVal.fVal;
972 break; 972 break;
973 973
974 case Variable::typeVersion: 974 case Variable::typeVersion:
975 break; 975 break;
976 976
977 case Variable::typeString: 977 case Variable::typeString:
978 ar << *v.uVal.sVal; 978 ar << *v.uVal.sVal;
979 break; 979 break;
980 980
981 case Variable::typeList: 981 case Variable::typeList:
982 ar << *v.uVal.lVal; 982 ar << *v.uVal.lVal;
983 break; 983 break;
984 984
985 case Variable::typeRef: 985 case Variable::typeRef:
986 ar << *v.uVal.sVal; 986 ar << *v.uVal.sVal;
987 break; 987 break;
988 988
989 case Variable::typeOpaque: 989 case Variable::typeOpaque:
990 break; 990 break;
991 } 991 }
992 992
993 return ar; 993 return ar;
994} 994}
995 995
996Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Variable &v ) 996Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Variable &v )
997{ 997{
998 int8_t t; 998 int8_t t;
999 ar >> t; 999 ar >> t;
1000 v.eType = (Variable::Type)t; 1000 v.eType = (Variable::Type)t;
1001 v.reset( v.eType ); 1001 v.reset( v.eType );
1002 switch( v.eType ) 1002 switch( v.eType )
1003 { 1003 {
1004 case Variable::typeNone: 1004 case Variable::typeNone:
1005 break; 1005 break;
1006 1006
1007 case Variable::typeBool: 1007 case Variable::typeBool:
1008 ar >> v.uVal.bVal; 1008 ar >> v.uVal.bVal;
1009 break; 1009 break;
1010 1010
1011 case Variable::typeInt: 1011 case Variable::typeInt:
1012 ar >> v.uVal.iVal; 1012 ar >> v.uVal.iVal;
1013 break; 1013 break;
1014 1014
1015 case Variable::typeFloat: 1015 case Variable::typeFloat:
1016 ar >> v.uVal.fVal; 1016 ar >> v.uVal.fVal;
1017 break; 1017 break;
1018 1018
1019 case Variable::typeVersion: 1019 case Variable::typeVersion:
1020 break; 1020 break;
1021 1021
1022 case Variable::typeString: 1022 case Variable::typeString:
1023 ar >> *v.uVal.sVal; 1023 ar >> *v.uVal.sVal;
1024 break; 1024 break;
1025 1025
1026 case Variable::typeList: 1026 case Variable::typeList:
1027 ar >> *v.uVal.lVal; 1027 ar >> *v.uVal.lVal;
1028 break; 1028 break;
1029 1029
1030 case Variable::typeRef: 1030 case Variable::typeRef:
1031 ar >> *v.uVal.sVal; 1031 ar >> *v.uVal.sVal;
1032 break; 1032 break;
1033 1033
1034 case Variable::typeOpaque: 1034 case Variable::typeOpaque:
1035 break; 1035 break;
1036 } 1036 }
1037 1037
1038 return ar; 1038 return ar;
1039} 1039}
1040 1040
1041VarList operator-( const VarList &rBase, const VarList &rSub ) 1041VarList operator-( const VarList &rBase, const VarList &rSub )
diff --git a/src/variable.h b/src/variable.h
index 890552a..f6c2044 100644
--- a/src/variable.h
+++ b/src/variable.h
@@ -12,109 +12,109 @@ class Variable
12friend Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Variable &v ); 12friend Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Variable &v );
13friend Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Variable &v ); 13friend Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Variable &v );
14public: 14public:
15 enum Type 15 enum Type
16 { 16 {
17 typeNone, 17 typeNone,
18 typeBool, 18 typeBool,
19 typeInt, 19 typeInt,
20 typeFloat, 20 typeFloat,
21 typeVersion, 21 typeVersion,
22 typeString, 22 typeString,
23 typeList, 23 typeList,
24 typeRef, /**< Reference by name, it's just a string. */ 24 typeRef, /**< Reference by name, it's just a string. */
25 typeOpaque /**< Only useful to functions. */ 25 typeOpaque /**< Only useful to functions. */
26 }; 26 };
27 27
28public: 28public:
29 Variable(); 29 Variable();
30 Variable( Type t ); 30 Variable( Type t );
31 Variable( int iVal ); 31 Variable( int iVal );
32 Variable( double fVal ); 32 Variable( double fVal );
33 Variable( bool bVal ); 33 Variable( bool bVal );
34 Variable( const Bu::String &sVal ); 34 Variable( const Bu::String &sVal );
35 Variable( const char *sVal ); 35 Variable( const char *sVal );
36 Variable( const Variable &v ); 36 Variable( const Variable &v );
37 Variable( const class AstLeaf &l ); 37 Variable( const class AstLeaf &l );
38 /** 38 /**
39 * This special case function turns the variable into a string if there is 39 * This special case function turns the variable into a string if there is
40 * only one string in the list, or a list of strings if there is more or 40 * only one string in the list, or a list of strings if there is more or
41 * less than one. 41 * less than one.
42 */ 42 */
43 Variable( const StrList &lst ); 43 Variable( const StrList &lst );
44 Variable( const VarList &lst ); 44 Variable( const VarList &lst );
45 Variable( void *oVal ); 45 Variable( void *oVal );
46 virtual ~Variable(); 46 virtual ~Variable();
47 47
48 static Variable mkRef( const Bu::String &sVal ); 48 static Variable mkRef( const Bu::String &sVal );
49 49
50 Type getType() const; 50 Type getType() const;
51 51
52 // Raw aquisition functions, if the type isn't right, 52 // Raw aquisition functions, if the type isn't right,
53 // they throw an exception 53 // they throw an exception
54 int getInt() const; 54 int getInt() const;
55 double getFloat() const; 55 double getFloat() const;
56 bool getBool() const; 56 bool getBool() const;
57 const Bu::String &getString() const; 57 const Bu::String &getString() const;
58 const VarList &getList() const; 58 const VarList &getList() const;
59 const void *getOpaque() const; 59 const void *getOpaque() const;
60 60
61 // Conversion functions, they'll return the requested type, maybe an error 61 // Conversion functions, they'll return the requested type, maybe an error
62 // if the source data is really bad 62 // if the source data is really bad
63 int toInt() const; 63 int toInt() const;
64 double toFloat() const; 64 double toFloat() const;
65 bool toBool() const; 65 bool toBool() const;
66 Bu::String toString() const; 66 Bu::String toString() const;
67 VarList toList() const; 67 VarList toList() const;
68 68
69 Variable toType( Type eNewType ) const; 69 Variable toType( Type eNewType ) const;
70 70
71 void append( const Variable &v ); 71 void append( const Variable &v );
72 VarList::iterator begin(); 72 VarList::iterator begin();
73 VarList::const_iterator begin() const; 73 VarList::const_iterator begin() const;
74 74
75 void doNegate(); 75 void doNegate();
76 void doNot(); 76 void doNot();
77 77
78 const Variable &operator=( const Variable &rhs ); 78 const Variable &operator=( const Variable &rhs );
79 const Variable &operator=( const int &rhs ); 79 const Variable &operator=( const int &rhs );
80 const Variable &operator=( const double &rhs ); 80 const Variable &operator=( const double &rhs );
81 const Variable &operator=( const bool &rhs ); 81 const Variable &operator=( const bool &rhs );
82 const Variable &operator=( const Bu::String &rhs ); 82 const Variable &operator=( const Bu::String &rhs );
83 const Variable &operator=( void *rhs ); 83 const Variable &operator=( void *rhs );
84 84
85 const Variable &operator+=( const Variable &rhs ); 85 const Variable &operator+=( const Variable &rhs );
86 const Variable &operator<<( const Variable &rhs ); 86 const Variable &operator<<( const Variable &rhs );
87 87
88 bool operator==( const Variable &rhs ) const; 88 bool operator==( const Variable &rhs ) const;
89 bool operator!=( const Variable &rhs ) const; 89 bool operator!=( const Variable &rhs ) const;
90 bool operator<( const Variable &rhs ) const; 90 bool operator<( const Variable &rhs ) const;
91 bool operator>( const Variable &rhs ) const; 91 bool operator>( const Variable &rhs ) const;
92 bool operator<=( const Variable &rhs ) const; 92 bool operator<=( const Variable &rhs ) const;
93 bool operator>=( const Variable &rhs ) const; 93 bool operator>=( const Variable &rhs ) const;
94 94
95 Variable operator+( const Variable &rhs ) const; 95 Variable operator+( const Variable &rhs ) const;
96 Variable operator-( const Variable &rhs ) const; 96 Variable operator-( const Variable &rhs ) const;
97 Variable operator*( const Variable &rhs ) const; 97 Variable operator*( const Variable &rhs ) const;
98 Variable operator/( const Variable &rhs ) const; 98 Variable operator/( const Variable &rhs ) const;
99 99
100private: 100private:
101 Type eType; 101 Type eType;
102 union 102 union
103 { 103 {
104 int iVal; 104 int iVal;
105 double fVal; 105 double fVal;
106 bool bVal; 106 bool bVal;
107 Bu::String *sVal; 107 Bu::String *sVal;
108 VarList *lVal; 108 VarList *lVal;
109 void *oVal; 109 void *oVal;
110 } uVal; 110 } uVal;
111 111
112 void reset( Type eType ); 112 void reset( Type eType );
113}; 113};
114 114
115namespace Bu 115namespace Bu
116{ 116{
117 class Formatter; 117 class Formatter;
118} 118}
119 119
120Bu::Formatter &operator<<( Bu::Formatter &f, const Variable::Type &t ); 120Bu::Formatter &operator<<( Bu::Formatter &f, const Variable::Type &t );
diff --git a/src/view.h b/src/view.h
index 389ad15..d1e1936 100644
--- a/src/view.h
+++ b/src/view.h
@@ -14,31 +14,31 @@
14class View 14class View
15{ 15{
16public: 16public:
17 View(); 17 View();
18 virtual ~View(); 18 virtual ~View();
19 19
20 virtual void beginAction( const Bu::String &sAction )=0; 20 virtual void beginAction( const Bu::String &sAction )=0;
21 virtual void endAction()=0; 21 virtual void endAction()=0;
22 22
23 virtual void skipTarget( const Bu::String &sProfile, 23 virtual void skipTarget( const Bu::String &sProfile,
24 const Target &rTarget )=0; 24 const Target &rTarget )=0;
25 virtual void beginTarget( const Bu::String &sProfile, 25 virtual void beginTarget( const Bu::String &sProfile,
26 const Target &rTarget )=0; 26 const Target &rTarget )=0;
27 virtual void processTarget( const Bu::String &sProfile, 27 virtual void processTarget( const Bu::String &sProfile,
28 const Target &rTarget )=0; 28 const Target &rTarget )=0;
29 virtual void endTarget()=0; 29 virtual void endTarget()=0;
30 30
31 virtual void buildRequires( const Target &rTarget )=0; 31 virtual void buildRequires( const Target &rTarget )=0;
32 virtual void cmdStarted( const Bu::String &sCmd )=0; 32 virtual void cmdStarted( const Bu::String &sCmd )=0;
33 virtual void cmdFinished( const Bu::String &sStdOut, 33 virtual void cmdFinished( const Bu::String &sStdOut,
34 const Bu::String &sStdErr, long iExit )=0; 34 const Bu::String &sStdErr, long iExit )=0;
35 35
36 virtual void userError( const Bu::String &sMsg )=0; 36 virtual void userError( const Bu::String &sMsg )=0;
37 virtual void userWarning( const Bu::String &sMsg )=0; 37 virtual void userWarning( const Bu::String &sMsg )=0;
38 virtual void userNotice( const Bu::String &sMsg )=0; 38 virtual void userNotice( const Bu::String &sMsg )=0;
39 39
40 virtual void sysError( const Bu::String &sMsg )=0; 40 virtual void sysError( const Bu::String &sMsg )=0;
41 virtual void sysWarning( const Bu::String &sMsg )=0; 41 virtual void sysWarning( const Bu::String &sMsg )=0;
42 42
43private: 43private:
44}; 44};
diff --git a/src/viewdefault.cpp b/src/viewdefault.cpp
index 8b7e345..815be39 100644
--- a/src/viewdefault.cpp
+++ b/src/viewdefault.cpp
@@ -7,44 +7,44 @@
7using namespace Bu; 7using namespace Bu;
8 8
9PluginInterface3( pluginViewDefault, default, ViewDefault, View, 9PluginInterface3( pluginViewDefault, default, ViewDefault, View,
10 "Mike Buland", 0, 1 ); 10 "Mike Buland", 0, 1 );
11 11
12#define ESC "\x1b" 12#define ESC "\x1b"
13 13
14#define C_RESET ESC "[0m" 14#define C_RESET ESC "[0m"
15#define C_RED ESC "[31m" 15#define C_RED ESC "[31m"
16#define C_GREEN ESC "[32m" 16#define C_GREEN ESC "[32m"
17#define C_YELLOW ESC "[33m" 17#define C_YELLOW ESC "[33m"
18#define C_BLUE ESC "[34m" 18#define C_BLUE ESC "[34m"
19#define C_MAGENTA ESC "[35m" 19#define C_MAGENTA ESC "[35m"
20#define C_CYAN ESC "[36m" 20#define C_CYAN ESC "[36m"
21#define C_WHITE ESC "[37m" 21#define C_WHITE ESC "[37m"
22#define C_DEFAULT ESC "[39m" 22#define C_DEFAULT ESC "[39m"
23 23
24#define C_BR_RED ESC "[1;31m" 24#define C_BR_RED ESC "[1;31m"
25#define C_BR_GREEN ESC "[1;32m" 25#define C_BR_GREEN ESC "[1;32m"
26#define C_BR_YELLOW ESC "[1;33m" 26#define C_BR_YELLOW ESC "[1;33m"
27#define C_BR_BLUE ESC "[1;34m" 27#define C_BR_BLUE ESC "[1;34m"
28#define C_BR_MAGENTA ESC "[1;35m" 28#define C_BR_MAGENTA ESC "[1;35m"
29#define C_BR_CYAN ESC "[1;36m" 29#define C_BR_CYAN ESC "[1;36m"
30#define C_BR_WHITE ESC "[1;37m" 30#define C_BR_WHITE ESC "[1;37m"
31 31
32ViewDefault::ViewDefault() : 32ViewDefault::ViewDefault() :
33 bFirst( true ), 33 bFirst( true ),
34 bDisped( false ), 34 bDisped( false ),
35 bDispedTrg( false ), 35 bDispedTrg( false ),
36 iDepth( 0 ), 36 iDepth( 0 ),
37 iTotal( 0 ), 37 iTotal( 0 ),
38 iCurrent( 0 ) 38 iCurrent( 0 )
39{ 39{
40} 40}
41 41
42ViewDefault::~ViewDefault() 42ViewDefault::~ViewDefault()
43{ 43{
44 if( bDisped == false ) 44 if( bDisped == false )
45 { 45 {
46 sio << "Nothing to be done." << sio.nl << sio.nl; 46 sio << "Nothing to be done." << sio.nl << sio.nl;
47 } 47 }
48} 48}
49 49
50void ViewDefault::beginAction( const Bu::String &/*sAction*/ ) 50void ViewDefault::beginAction( const Bu::String &/*sAction*/ )
@@ -56,73 +56,73 @@ void ViewDefault::endAction()
56} 56}
57 57
58void ViewDefault::skipTarget( const Bu::String &/*sProfile*/, 58void ViewDefault::skipTarget( const Bu::String &/*sProfile*/,
59 const Target &/*rTarget*/ ) 59 const Target &/*rTarget*/ )
60{ 60{
61 iCurrent++; 61 iCurrent++;
62} 62}
63 63
64void ViewDefault::beginTarget( const Bu::String &sProfile, 64void ViewDefault::beginTarget( const Bu::String &sProfile,
65 const Target &rTarget ) 65 const Target &rTarget )
66{ 66{
67 if( iDepth == 0 ) 67 if( iDepth == 0 )
68 { 68 {
69 bDispedTrg = false; 69 bDispedTrg = false;
70 iTotal = rTarget.getDepCount(); 70 iTotal = rTarget.getDepCount();
71 iCurrent = 0; 71 iCurrent = 0;
72 sTopTarget = rTarget.getOutputList().first(); 72 sTopTarget = rTarget.getOutputList().first();
73 } 73 }
74 iDepth++; 74 iDepth++;
75 75
76 sCurProfile = sProfile; 76 sCurProfile = sProfile;
77} 77}
78 78
79void ViewDefault::drawTargetHdr( const Bu::String &sProfile, 79void ViewDefault::drawTargetHdr( const Bu::String &sProfile,
80 const Target &rTarget ) 80 const Target &rTarget )
81{ 81{
82 if( bDispedTrg == false ) 82 if( bDispedTrg == false )
83 { 83 {
84 bDispedTrg = true; 84 bDispedTrg = true;
85 if( bFirst == false ) 85 if( bFirst == false )
86 { 86 {
87 sio << sio.nl; 87 sio << sio.nl;
88 } 88 }
89 bFirst = false; 89 bFirst = false;
90 sio << C_BR_WHITE << " --- " << C_BR_CYAN << sProfile << " " 90 sio << C_BR_WHITE << " --- " << C_BR_CYAN << sProfile << " "
91 << sTopTarget << C_BR_WHITE << " --- " 91 << sTopTarget << C_BR_WHITE << " --- "
92 << C_RESET << sio.nl; 92 << C_RESET << sio.nl;
93 } 93 }
94} 94}
95 95
96void ViewDefault::processTarget( const Bu::String &sProfile, 96void ViewDefault::processTarget( const Bu::String &sProfile,
97 const Target &rTarget ) 97 const Target &rTarget )
98{ 98{
99 drawTargetHdr( sProfile, rTarget ); 99 drawTargetHdr( sProfile, rTarget );
100 iCurrent++; 100 iCurrent++;
101 101
102 int iPct = (iTotal>0)?(iCurrent*100/iTotal):(100); 102 int iPct = (iTotal>0)?(iCurrent*100/iTotal):(100);
103 sio << C_BR_WHITE << "[" << C_BR_GREEN << Fmt(3) << iPct 103 sio << C_BR_WHITE << "[" << C_BR_GREEN << Fmt(3) << iPct
104 << "%" << C_BR_WHITE << "] " << C_BR_MAGENTA 104 << "%" << C_BR_WHITE << "] " << C_BR_MAGENTA
105 << Fmt(10) << rTarget.getDisplay() << C_BR_WHITE 105 << Fmt(10) << rTarget.getDisplay() << C_BR_WHITE
106 << ": " << rTarget.getOutputList().first() << C_RESET << sio.nl; 106 << ": " << rTarget.getOutputList().first() << C_RESET << sio.nl;
107 107
108 bDisped = true; 108 bDisped = true;
109} 109}
110 110
111void ViewDefault::endTarget() 111void ViewDefault::endTarget()
112{ 112{
113 iDepth--; 113 iDepth--;
114} 114}
115 115
116void ViewDefault::buildRequires( const Target &rTarget ) 116void ViewDefault::buildRequires( const Target &rTarget )
117{ 117{
118 drawTargetHdr( sCurProfile, rTarget ); 118 drawTargetHdr( sCurProfile, rTarget );
119 119
120 int iPct = (iTotal>0)?(iCurrent*100/iTotal):(100); 120 int iPct = (iTotal>0)?(iCurrent*100/iTotal):(100);
121 sio << C_BR_WHITE << "[" << C_BR_GREEN << Fmt(3) << iPct 121 sio << C_BR_WHITE << "[" << C_BR_GREEN << Fmt(3) << iPct
122 << "%" << C_BR_WHITE << "] " << C_BR_MAGENTA 122 << "%" << C_BR_WHITE << "] " << C_BR_MAGENTA
123 << Fmt(10) << "deps" << C_BR_WHITE 123 << Fmt(10) << "deps" << C_BR_WHITE
124 << ": " << rTarget.getOutputList().first() << C_RESET << sio.nl; 124 << ": " << rTarget.getOutputList().first() << C_RESET << sio.nl;
125 bDisped = true; 125 bDisped = true;
126} 126}
127 127
128void ViewDefault::cmdStarted( const Bu::String &/*sCmd*/ ) 128void ViewDefault::cmdStarted( const Bu::String &/*sCmd*/ )
@@ -130,72 +130,72 @@ void ViewDefault::cmdStarted( const Bu::String &/*sCmd*/ )
130} 130}
131 131
132void ViewDefault::cmdFinished( const Bu::String &sStdOut, 132void ViewDefault::cmdFinished( const Bu::String &sStdOut,
133 const Bu::String &sStdErr, long /*iExit*/ ) 133 const Bu::String &sStdErr, long /*iExit*/ )
134{ 134{
135 if( sStdOut.isSet() ) 135 if( sStdOut.isSet() )
136 { 136 {
137 Bu::String::const_iterator b; 137 Bu::String::const_iterator b;
138 b = sStdOut.begin(); 138 b = sStdOut.begin();
139 while( b ) 139 while( b )
140 { 140 {
141 Bu::String::const_iterator e, max; 141 Bu::String::const_iterator e, max;
142 max = b + 78; 142 max = b + 78;
143 for( e = b; e != max && *e != '\n'; e++ ) { } 143 for( e = b; e != max && *e != '\n'; e++ ) { }
144 sio << C_BR_GREEN << "| " << C_RESET << String( b, e ) << sio.nl; 144 sio << C_BR_GREEN << "| " << C_RESET << String( b, e ) << sio.nl;
145 b = e; 145 b = e;
146 if( *b == '\n' ) 146 if( *b == '\n' )
147 b++; 147 b++;
148 } 148 }
149 sio << C_BR_GREEN << "\\-----" << C_RESET << sio.nl; 149 sio << C_BR_GREEN << "\\-----" << C_RESET << sio.nl;
150 } 150 }
151 if( sStdErr.isSet() ) 151 if( sStdErr.isSet() )
152 { 152 {
153 Bu::String::const_iterator b; 153 Bu::String::const_iterator b;
154 b = sStdErr.begin(); 154 b = sStdErr.begin();
155 while( b ) 155 while( b )
156 { 156 {
157 Bu::String::const_iterator e, max; 157 Bu::String::const_iterator e, max;
158 max = b + 78; 158 max = b + 78;
159 for( e = b; e != max && *e != '\n'; e++ ) { } 159 for( e = b; e != max && *e != '\n'; e++ ) { }
160 sio << C_BR_RED << "| " << C_RESET << String( b, e ) << sio.nl; 160 sio << C_BR_RED << "| " << C_RESET << String( b, e ) << sio.nl;
161 b = e; 161 b = e;
162 if( *b == '\n' ) 162 if( *b == '\n' )
163 b++; 163 b++;
164 } 164 }
165 sio << C_BR_RED << "\\-----" << C_RESET << sio.nl; 165 sio << C_BR_RED << "\\-----" << C_RESET << sio.nl;
166 } 166 }
167 //sio << C_BR_WHITE << "[" << C_BR_GREEN << sStdOut << C_BR_WHITE << "]" << sio.nl; 167 //sio << C_BR_WHITE << "[" << C_BR_GREEN << sStdOut << C_BR_WHITE << "]" << sio.nl;
168 //sio << C_BR_WHITE << "[" << C_BR_RED << sStdErr << C_BR_WHITE << "]" << sio.nl; 168 //sio << C_BR_WHITE << "[" << C_BR_RED << sStdErr << C_BR_WHITE << "]" << sio.nl;
169 bDisped = true; 169 bDisped = true;
170} 170}
171 171
172void ViewDefault::userError( const Bu::String &sMsg ) 172void ViewDefault::userError( const Bu::String &sMsg )
173{ 173{
174 sio << C_BR_RED << "Error: " << sMsg << C_RESET << sio.nl; 174 sio << C_BR_RED << "Error: " << sMsg << C_RESET << sio.nl;
175 bDisped = true; 175 bDisped = true;
176} 176}
177 177
178void ViewDefault::userWarning( const Bu::String &sMsg ) 178void ViewDefault::userWarning( const Bu::String &sMsg )
179{ 179{
180 sio << C_BR_YELLOW << "Warning: " << sMsg << C_RESET << sio.nl; 180 sio << C_BR_YELLOW << "Warning: " << sMsg << C_RESET << sio.nl;
181 bDisped = true; 181 bDisped = true;
182} 182}
183 183
184void ViewDefault::userNotice( const Bu::String &sMsg ) 184void ViewDefault::userNotice( const Bu::String &sMsg )
185{ 185{
186 sio << C_BR_GREEN << "Notice: " << sMsg << C_RESET << sio.nl; 186 sio << C_BR_GREEN << "Notice: " << sMsg << C_RESET << sio.nl;
187 bDisped = true; 187 bDisped = true;
188} 188}
189 189
190void ViewDefault::sysError( const Bu::String &sMsg ) 190void ViewDefault::sysError( const Bu::String &sMsg )
191{ 191{
192 sio << C_BR_RED << sMsg << C_RESET << sio.nl; 192 sio << C_BR_RED << sMsg << C_RESET << sio.nl;
193 bDisped = true; 193 bDisped = true;
194} 194}
195 195
196void ViewDefault::sysWarning( const Bu::String &sMsg ) 196void ViewDefault::sysWarning( const Bu::String &sMsg )
197{ 197{
198 sio << C_BR_YELLOW << sMsg << C_RESET << sio.nl; 198 sio << C_BR_YELLOW << sMsg << C_RESET << sio.nl;
199 bDisped = true; 199 bDisped = true;
200} 200}
201 201
diff --git a/src/viewdefault.h b/src/viewdefault.h
index ee9302b..35d420b 100644
--- a/src/viewdefault.h
+++ b/src/viewdefault.h
@@ -6,43 +6,43 @@
6class ViewDefault : public View 6class ViewDefault : public View
7{ 7{
8public: 8public:
9 ViewDefault(); 9 ViewDefault();
10 virtual ~ViewDefault(); 10 virtual ~ViewDefault();
11 11
12 virtual void beginAction( const Bu::String &sAction ); 12 virtual void beginAction( const Bu::String &sAction );
13 virtual void endAction(); 13 virtual void endAction();
14 14
15 virtual void skipTarget( const Bu::String &sProfile, 15 virtual void skipTarget( const Bu::String &sProfile,
16 const Target &rTarget ); 16 const Target &rTarget );
17 virtual void beginTarget( const Bu::String &sProfile, 17 virtual void beginTarget( const Bu::String &sProfile,
18 const Target &rTarget ); 18 const Target &rTarget );
19 virtual void processTarget( const Bu::String &sProfile, 19 virtual void processTarget( const Bu::String &sProfile,
20 const Target &rTarget ); 20 const Target &rTarget );
21 virtual void endTarget(); 21 virtual void endTarget();
22 22
23 virtual void buildRequires( const Target &rTarget ); 23 virtual void buildRequires( const Target &rTarget );
24 virtual void cmdStarted( const Bu::String &sCmd ); 24 virtual void cmdStarted( const Bu::String &sCmd );
25 virtual void cmdFinished( const Bu::String &sStdOut, 25 virtual void cmdFinished( const Bu::String &sStdOut,
26 const Bu::String &sStdErr, long iExit ); 26 const Bu::String &sStdErr, long iExit );
27 27
28 virtual void userError( const Bu::String &sMsg ); 28 virtual void userError( const Bu::String &sMsg );
29 virtual void userWarning( const Bu::String &sMsg ); 29 virtual void userWarning( const Bu::String &sMsg );
30 virtual void userNotice( const Bu::String &sMsg ); 30 virtual void userNotice( const Bu::String &sMsg );
31 31
32 virtual void sysError( const Bu::String &sMsg ); 32 virtual void sysError( const Bu::String &sMsg );
33 virtual void sysWarning( const Bu::String &sMsg ); 33 virtual void sysWarning( const Bu::String &sMsg );
34 34
35 void drawTargetHdr( const Bu::String &sProfile, const Target &rTarget ); 35 void drawTargetHdr( const Bu::String &sProfile, const Target &rTarget );
36 36
37private: 37private:
38 bool bFirst; 38 bool bFirst;
39 bool bDisped; 39 bool bDisped;
40 bool bDispedTrg; 40 bool bDispedTrg;
41 int iDepth; 41 int iDepth;
42 int iTotal; 42 int iTotal;
43 int iCurrent; 43 int iCurrent;
44 Bu::String sCurProfile; 44 Bu::String sCurProfile;
45 Bu::String sTopTarget; 45 Bu::String sTopTarget;
46}; 46};
47 47
48#endif 48#endif
diff --git a/src/viewmake.cpp b/src/viewmake.cpp
index 14f5526..4b0cc12 100644
--- a/src/viewmake.cpp
+++ b/src/viewmake.cpp
@@ -7,7 +7,7 @@
7using namespace Bu; 7using namespace Bu;
8 8
9PluginInterface3( pluginViewMake, make, ViewMake, View, 9PluginInterface3( pluginViewMake, make, ViewMake, View,
10 "Mike Buland", 0, 1 ); 10 "Mike Buland", 0, 1 );
11 11
12ViewMake::ViewMake() 12ViewMake::ViewMake()
13{ 13{
@@ -26,17 +26,17 @@ void ViewMake::endAction()
26} 26}
27 27
28void ViewMake::skipTarget( const Bu::String &/*sProfile*/, 28void ViewMake::skipTarget( const Bu::String &/*sProfile*/,
29 const Target &/*rTarget*/ ) 29 const Target &/*rTarget*/ )
30{ 30{
31} 31}
32 32
33void ViewMake::beginTarget( const Bu::String &/*sProfile*/, 33void ViewMake::beginTarget( const Bu::String &/*sProfile*/,
34 const Target &/*rTarget*/ ) 34 const Target &/*rTarget*/ )
35{ 35{
36} 36}
37 37
38void ViewMake::processTarget( const Bu::String &/*sProfile*/, 38void ViewMake::processTarget( const Bu::String &/*sProfile*/,
39 const Target &/*rTarget*/ ) 39 const Target &/*rTarget*/ )
40{ 40{
41} 41}
42 42
@@ -50,37 +50,37 @@ void ViewMake::buildRequires( const Target &/*rTarget*/ )
50 50
51void ViewMake::cmdStarted( const Bu::String &sCmd ) 51void ViewMake::cmdStarted( const Bu::String &sCmd )
52{ 52{
53 sio << sCmd << sio.nl; 53 sio << sCmd << sio.nl;
54} 54}
55 55
56void ViewMake::cmdFinished( const Bu::String &sStdOut, 56void ViewMake::cmdFinished( const Bu::String &sStdOut,
57 const Bu::String &sStdErr, long /*iExit*/ ) 57 const Bu::String &sStdErr, long /*iExit*/ )
58{ 58{
59 sio << sStdOut << sStdErr; 59 sio << sStdOut << sStdErr;
60} 60}
61 61
62void ViewMake::userError( const Bu::String &sMsg ) 62void ViewMake::userError( const Bu::String &sMsg )
63{ 63{
64 sio << "Error: " << sMsg << sio.nl; 64 sio << "Error: " << sMsg << sio.nl;
65} 65}
66 66
67void ViewMake::userWarning( const Bu::String &sMsg ) 67void ViewMake::userWarning( const Bu::String &sMsg )
68{ 68{
69 sio << "Warning: " << sMsg << sio.nl; 69 sio << "Warning: " << sMsg << sio.nl;
70} 70}
71 71
72void ViewMake::userNotice( const Bu::String &sMsg ) 72void ViewMake::userNotice( const Bu::String &sMsg )
73{ 73{
74 sio << "Notice: " << sMsg << sio.nl; 74 sio << "Notice: " << sMsg << sio.nl;
75} 75}
76 76
77void ViewMake::sysError( const Bu::String &sMsg ) 77void ViewMake::sysError( const Bu::String &sMsg )
78{ 78{
79 sio << sMsg << sio.nl; 79 sio << sMsg << sio.nl;
80} 80}
81 81
82void ViewMake::sysWarning( const Bu::String &sMsg ) 82void ViewMake::sysWarning( const Bu::String &sMsg )
83{ 83{
84 sio << sMsg << sio.nl; 84 sio << sMsg << sio.nl;
85} 85}
86 86
diff --git a/src/viewmake.h b/src/viewmake.h
index 8960ef0..0c50b00 100644
--- a/src/viewmake.h
+++ b/src/viewmake.h
@@ -6,31 +6,31 @@
6class ViewMake : public View 6class ViewMake : public View
7{ 7{
8public: 8public:
9 ViewMake(); 9 ViewMake();
10 virtual ~ViewMake(); 10 virtual ~ViewMake();
11 11
12 virtual void beginAction( const Bu::String &sAction ); 12 virtual void beginAction( const Bu::String &sAction );
13 virtual void endAction(); 13 virtual void endAction();
14 14
15 virtual void skipTarget( const Bu::String &sProfile, 15 virtual void skipTarget( const Bu::String &sProfile,
16 const Target &rTarget ); 16 const Target &rTarget );
17 virtual void beginTarget( const Bu::String &sProfile, 17 virtual void beginTarget( const Bu::String &sProfile,
18 const Target &rTarget ); 18 const Target &rTarget );
19 virtual void processTarget( const Bu::String &sProfile, 19 virtual void processTarget( const Bu::String &sProfile,
20 const Target &rTarget ); 20 const Target &rTarget );
21 virtual void endTarget(); 21 virtual void endTarget();
22 22
23 virtual void buildRequires( const Target &rTarget ); 23 virtual void buildRequires( const Target &rTarget );
24 virtual void cmdStarted( const Bu::String &sCmd ); 24 virtual void cmdStarted( const Bu::String &sCmd );
25 virtual void cmdFinished( const Bu::String &sStdOut, 25 virtual void cmdFinished( const Bu::String &sStdOut,
26 const Bu::String &sStdErr, long iExit ); 26 const Bu::String &sStdErr, long iExit );
27 27
28 virtual void userError( const Bu::String &sMsg ); 28 virtual void userError( const Bu::String &sMsg );
29 virtual void userWarning( const Bu::String &sMsg ); 29 virtual void userWarning( const Bu::String &sMsg );
30 virtual void userNotice( const Bu::String &sMsg ); 30 virtual void userNotice( const Bu::String &sMsg );
31 31
32 virtual void sysError( const Bu::String &sMsg ); 32 virtual void sysError( const Bu::String &sMsg );
33 virtual void sysWarning( const Bu::String &sMsg ); 33 virtual void sysWarning( const Bu::String &sMsg );
34}; 34};
35 35
36#endif 36#endif
diff --git a/src/viewplugger.cpp b/src/viewplugger.cpp
index cdde2f6..1187ab7 100644
--- a/src/viewplugger.cpp
+++ b/src/viewplugger.cpp
@@ -7,29 +7,29 @@ extern Bu::PluginInfo pluginViewDefault;
7extern Bu::PluginInfo pluginViewMake; 7extern Bu::PluginInfo pluginViewMake;
8ViewPlugger::ViewPlugger() 8ViewPlugger::ViewPlugger()
9{ 9{
10 registerBuiltinPlugin( &pluginViewDefault ); 10 registerBuiltinPlugin( &pluginViewDefault );
11 registerBuiltinPlugin( &pluginViewMake ); 11 registerBuiltinPlugin( &pluginViewMake );
12 12
13 DIR *dir = opendir("/usr/lib/build"); 13 DIR *dir = opendir("/usr/lib/build");
14 if( !dir ) 14 if( !dir )
15 return; 15 return;
16 struct dirent *de; 16 struct dirent *de;
17 while( (de = readdir( dir )) ) 17 while( (de = readdir( dir )) )
18 { 18 {
19 if( strncmp("pluginView", de->d_name, 15 ) ) 19 if( strncmp("pluginView", de->d_name, 15 ) )
20 continue; 20 continue;
21 21
22 Bu::String sFile("/usr/lib/build/"); 22 Bu::String sFile("/usr/lib/build/");
23 sFile += de->d_name; 23 sFile += de->d_name;
24 char *s = de->d_name; 24 char *s = de->d_name;
25 for(; *s && *s != '.'; s++ ) { } 25 for(; *s && *s != '.'; s++ ) { }
26 registerExternalPlugin( 26 registerExternalPlugin(
27 sFile, 27 sFile,
28 Bu::String( de->d_name, (ptrdiff_t)s-(ptrdiff_t)de->d_name ) 28 Bu::String( de->d_name, (ptrdiff_t)s-(ptrdiff_t)de->d_name )
29 ); 29 );
30 } 30 }
31 31
32 closedir( dir ); 32 closedir( dir );
33} 33}
34 34
35ViewPlugger::~ViewPlugger() 35ViewPlugger::~ViewPlugger()
diff --git a/src/viewplugger.h b/src/viewplugger.h
index b58635c..bea5c5f 100644
--- a/src/viewplugger.h
+++ b/src/viewplugger.h
@@ -7,12 +7,12 @@
7 7
8class ViewPlugger : public Bu::Plugger<View>, public Bu::Singleton<ViewPlugger> 8class ViewPlugger : public Bu::Plugger<View>, public Bu::Singleton<ViewPlugger>
9{ 9{
10 friend class Bu::Singleton<ViewPlugger>; 10 friend class Bu::Singleton<ViewPlugger>;
11private: 11private:
12 ViewPlugger(); 12 ViewPlugger();
13 13
14public: 14public:
15 virtual ~ViewPlugger(); 15 virtual ~ViewPlugger();
16 16
17private: 17private:
18}; 18};