author | jjkang |
Wed, 30 Jun 2010 11:35:58 +0800 | |
changeset 607 | 378360dbbdba |
parent 0 | 044383f39525 |
permissions | -rw-r--r-- |
0
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
1 |
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
2 |
// All rights reserved. |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
3 |
// This component and the accompanying materials are made available |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
4 |
// under the terms of "Eclipse Public License v1.0" |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
5 |
// which accompanies this distribution, and is available |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
7 |
// |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
8 |
// Initial Contributors: |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
9 |
// Nokia Corporation - initial contribution. |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
10 |
// |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
11 |
// Contributors: |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
12 |
// |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
13 |
// Description: |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
14 |
// Implementation of the Class DefFile for the elf2e32 tool |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
15 |
// @internalComponent |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
16 |
// @released |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
17 |
// |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
18 |
// |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
19 |
|
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
20 |
#ifndef _DEF_FILE_ |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
21 |
#define _DEF_FILE_ |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
22 |
|
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
23 |
#include <list> |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
24 |
|
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
25 |
class Symbol; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
26 |
typedef std::list <Symbol*> SymbolList; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
27 |
|
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
28 |
/** |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
29 |
Class for DEF File Handler. |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
30 |
@internalComponent |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
31 |
@released |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
32 |
*/ |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
33 |
class DefFile |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
34 |
{ |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
35 |
public: |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
36 |
DefFile():iSymbolList(NULL){}; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
37 |
virtual ~DefFile(); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
38 |
SymbolList* ReadDefFile(char *defFile); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
39 |
void WriteDefFile(char *fileName, SymbolList *newSymbolList); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
40 |
SymbolList* GetSymbolEntryList(char *defFile); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
41 |
SymbolList* GetSymbolEntryList() { return iSymbolList;} |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
42 |
private: |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
43 |
char *iFileName; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
44 |
SymbolList *iSymbolList; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
45 |
int GetFileSize(FILE * fptrDef); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
46 |
char* OpenDefFile(char *defFile); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
47 |
void ParseDefFile(char *defData); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
48 |
bool Tokenize(char* tokens, int aLineNum, Symbol& aSymbol); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
49 |
}; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
50 |
|
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
51 |
//Different states while parsing a line in the def file. |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
52 |
enum DefStates |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
53 |
{ |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
54 |
EInitState = 0, |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
55 |
ESymbolName = 1, |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
56 |
EAtSymbol, |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
57 |
EOrdinal, |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
58 |
EOptionals, |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
59 |
EComment, |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
60 |
EFinalState, |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
61 |
EInvalidState |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
62 |
}; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
63 |
|
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
64 |
#define CODESYM "CODE" |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
65 |
#define DATASYM "DATA" |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
66 |
|
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
67 |
/** |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
68 |
Class for parsing a line from the DEF File. |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
69 |
@internalComponent |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
70 |
@released |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
71 |
*/ |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
72 |
class LineToken |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
73 |
{ |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
74 |
public: |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
75 |
LineToken(char* , int , char *, Symbol *aSym); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
76 |
char *iLine; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
77 |
Symbol *iSymbol; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
78 |
int iOffset; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
79 |
DefStates iState; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
80 |
|
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
81 |
char *iFileName; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
82 |
int iLineNum; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
83 |
|
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
84 |
bool Tokenize(); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
85 |
void NextToken(); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
86 |
void IncrOffset(int aOff); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
87 |
void SetState(DefStates aState); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
88 |
|
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
89 |
bool IsWhiteSpace(char *aStr, int&); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
90 |
bool IsPattern(char*, int&, int&); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
91 |
bool IsDigit(char*, int&); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
92 |
bool IsWord(char*, int&); |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
93 |
}; |
044383f39525
Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff
changeset
|
94 |
#endif |