diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/build.cpp | 11 | ||||
-rw-r--r-- | src/buildparser.cpp | 30 | ||||
-rw-r--r-- | src/rule.cpp | 1 | ||||
-rw-r--r-- | src/rule.h | 8 | ||||
-rw-r--r-- | src/stringproc.cpp | 12 | ||||
-rw-r--r-- | src/stringproc.h | 28 | ||||
-rw-r--r-- | src/stringprocbuild.cpp | 52 | ||||
-rw-r--r-- | src/stringprocbuild.h | 20 |
8 files changed, 161 insertions, 1 deletions
diff --git a/src/build.cpp b/src/build.cpp index ec97ccb..03d3c5a 100644 --- a/src/build.cpp +++ b/src/build.cpp | |||
@@ -138,5 +138,16 @@ void Build::debugDump() | |||
138 | ); | 138 | ); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | |||
142 | printf("Rules:\n"); | ||
143 | for( RuleMap::iterator i = mRule.begin(); i != mRule.end(); i++ ) | ||
144 | { | ||
145 | printf(" %s:\n", (*i).first.c_str() ); | ||
146 | printf(" Matches: func\n"); | ||
147 | printf(" Filters: %d\n", (*i).second->getFilterList().size() ); | ||
148 | printf(" Performs: %d\n", (*i).second->getPerformList().size() ); | ||
149 | printf(" Produces:\n"); | ||
150 | printf(" Requires:\n"); | ||
151 | } | ||
141 | } | 152 | } |
142 | 153 | ||
diff --git a/src/buildparser.cpp b/src/buildparser.cpp index 7903e04..5ebcfd3 100644 --- a/src/buildparser.cpp +++ b/src/buildparser.cpp | |||
@@ -411,6 +411,36 @@ Build *BuildParser::genBuild() | |||
411 | } | 411 | } |
412 | } | 412 | } |
413 | 413 | ||
414 | for( RuleTmpList::iterator i = lRuleTmp.begin(); i != lRuleTmp.end(); i++ ) | ||
415 | { | ||
416 | Rule *pRule = new Rule; | ||
417 | pRule->setName( (*i).sName ); | ||
418 | pRule->getMatchesList().push_back( (*i).pMatches ); | ||
419 | |||
420 | for( FunctionList::iterator j = (*i).lFilter.begin(); | ||
421 | j != (*i).lFilter.end(); j++ ) | ||
422 | { | ||
423 | pRule->getFilterList().push_back( *j ); | ||
424 | } | ||
425 | |||
426 | for( PerformList::iterator j = (*i).lPerform.begin(); | ||
427 | j != (*i).lPerform.end(); j++ ) | ||
428 | { | ||
429 | pRule->getPerformList().push_back( *j ); | ||
430 | } | ||
431 | |||
432 | /*StringList lITmp = buildToStringList( | ||
433 | (*i).lProduces, StringList() | ||
434 | ); | ||
435 | |||
436 | for( StringList::iterator i = lITmp.begin(); i != lITmp.end(); i++ ) | ||
437 | { | ||
438 | get | ||
439 | }*/ | ||
440 | |||
441 | bld->addRule( pRule ); | ||
442 | } | ||
443 | |||
414 | return bld; | 444 | return bld; |
415 | } | 445 | } |
416 | 446 | ||
diff --git a/src/rule.cpp b/src/rule.cpp index 22af322..2212936 100644 --- a/src/rule.cpp +++ b/src/rule.cpp | |||
@@ -7,3 +7,4 @@ Rule::Rule() | |||
7 | Rule::~Rule() | 7 | Rule::~Rule() |
8 | { | 8 | { |
9 | } | 9 | } |
10 | |||
@@ -27,7 +27,7 @@ public: | |||
27 | this->sName = sName; | 27 | this->sName = sName; |
28 | } | 28 | } |
29 | 29 | ||
30 | FunctionList &getFunctionList() | 30 | FunctionList &getFilterList() |
31 | { | 31 | { |
32 | return lFilter; | 32 | return lFilter; |
33 | } | 33 | } |
@@ -37,8 +37,14 @@ public: | |||
37 | return lPerform; | 37 | return lPerform; |
38 | } | 38 | } |
39 | 39 | ||
40 | FunctionList &getMatchesList() | ||
41 | { | ||
42 | return lMatches; | ||
43 | } | ||
44 | |||
40 | private: | 45 | private: |
41 | std::string sName; | 46 | std::string sName; |
47 | FunctionList lMatches; | ||
42 | FunctionList lFilter; | 48 | FunctionList lFilter; |
43 | PerformList lPerform; | 49 | PerformList lPerform; |
44 | }; | 50 | }; |
diff --git a/src/stringproc.cpp b/src/stringproc.cpp new file mode 100644 index 0000000..23abca9 --- /dev/null +++ b/src/stringproc.cpp | |||
@@ -0,0 +1,12 @@ | |||
1 | #include "stringproc.h" | ||
2 | |||
3 | StringProc::StringProc( Build *pBld ) : | ||
4 | pBld( pBld ) | ||
5 | { | ||
6 | } | ||
7 | |||
8 | StringProc::~StringProc() | ||
9 | { | ||
10 | } | ||
11 | |||
12 | |||
diff --git a/src/stringproc.h b/src/stringproc.h new file mode 100644 index 0000000..237ad6f --- /dev/null +++ b/src/stringproc.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef STRING_PROC_H | ||
2 | #define STRING_PROC_H | ||
3 | |||
4 | #include <stdint.h> | ||
5 | #include <string> | ||
6 | |||
7 | class Build; | ||
8 | |||
9 | class StringProc | ||
10 | { | ||
11 | public: | ||
12 | StringProc( Build *pBld ); | ||
13 | virtual ~StringProc(); | ||
14 | |||
15 | virtual std::string replVars( const std::string &sSrc, const std::string &sCont )=0; | ||
16 | |||
17 | protected: | ||
18 | Build *getBuild() | ||
19 | { | ||
20 | return pBld; | ||
21 | } | ||
22 | |||
23 | private: | ||
24 | Build *pBld; | ||
25 | |||
26 | }; | ||
27 | |||
28 | #endif | ||
diff --git a/src/stringprocbuild.cpp b/src/stringprocbuild.cpp new file mode 100644 index 0000000..56eae12 --- /dev/null +++ b/src/stringprocbuild.cpp | |||
@@ -0,0 +1,52 @@ | |||
1 | #include "stringprocbuild.h" | ||
2 | #include "build.h" | ||
3 | |||
4 | StringProcBuild::StringProcBuild( Build *pBld ) : | ||
5 | StringProc( pBld ) | ||
6 | { | ||
7 | } | ||
8 | |||
9 | StringProcBuild::~StringProcBuild() | ||
10 | { | ||
11 | } | ||
12 | |||
13 | std::string StringProcBuild::replVars( const std::string &sSrc, const std::string &sCont ) | ||
14 | { | ||
15 | std::string sDes, sBuf; | ||
16 | int nMode = 0; | ||
17 | |||
18 | int nLen = sSrc.size(); | ||
19 | for( int j = 0; j < nLen; j++ ) | ||
20 | { | ||
21 | if( sSrc[j] == '{' ) | ||
22 | { | ||
23 | sBuf = ""; | ||
24 | nMode = 1; | ||
25 | } | ||
26 | else if( nMode == 0 ) | ||
27 | { | ||
28 | sDes += sSrc[j]; | ||
29 | } | ||
30 | else if( nMode == 1 ) | ||
31 | { | ||
32 | if( sSrc[j] == '}' ) | ||
33 | { | ||
34 | sDes += getBuild()->getVar( sCont, sBuf ); | ||
35 | nMode = 0; | ||
36 | } | ||
37 | else | ||
38 | { | ||
39 | sBuf += sSrc[j]; | ||
40 | } | ||
41 | } | ||
42 | } | ||
43 | |||
44 | if( nMode == 1 ) | ||
45 | { | ||
46 | throw BuildException( | ||
47 | "Unterminated variable replacement found: \"%s\"", | ||
48 | sSrc.c_str() | ||
49 | ); | ||
50 | } | ||
51 | } | ||
52 | |||
diff --git a/src/stringprocbuild.h b/src/stringprocbuild.h new file mode 100644 index 0000000..13dd4f6 --- /dev/null +++ b/src/stringprocbuild.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef STRING_PROC_BUILD_H | ||
2 | #define STRING_PROC_BUILD_H | ||
3 | |||
4 | #include <stdint.h> | ||
5 | |||
6 | #include "stringproc.h" | ||
7 | |||
8 | class StringProcBuild : public StringProc | ||
9 | { | ||
10 | public: | ||
11 | StringProcBuild( Build *pBld ); | ||
12 | virtual ~StringProcBuild(); | ||
13 | |||
14 | virtual std::string replVars( const std::string &sSrc, const std::string &sCont ); | ||
15 | |||
16 | private: | ||
17 | |||
18 | }; | ||
19 | |||
20 | #endif | ||