e32tools/elf2e32/source/parametermanager.h
changeset 0 044383f39525
child 589 851206cea67b
child 666 76dc8e3e7f2e
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Implementation of the Header file for Class ParameterManager of the elf2e32 tool
       
    15 // @internalComponent
       
    16 // @released
       
    17 // 
       
    18 //
       
    19 
       
    20 #if !defined(SYMBIAN_PARAMETERMANAGER_H_)
       
    21 #define SYMBIAN_PARAMETERMANAGER_H_
       
    22 
       
    23 #include "parameterlistinterface.h"
       
    24 #include <vector>
       
    25 #include <map>
       
    26 #include <string>
       
    27 
       
    28 class UseCaseBase;
       
    29 class Symbol;
       
    30 
       
    31 
       
    32 
       
    33 /**
       
    34 This class is derived from ParameterListInterface (the abstract base class). 
       
    35 
       
    36 @internalComponent
       
    37 @released
       
    38 */
       
    39 class ParameterManager : public ParameterListInterface
       
    40 {
       
    41 
       
    42 public:
       
    43 
       
    44 	typedef std::vector<char *> ParamList;
       
    45 
       
    46 	struct OptionDesc
       
    47 	{
       
    48 		char * iName;
       
    49 		const void * iParser;
       
    50 		char * iDoc;
       
    51 	};
       
    52 
       
    53 	struct TargetTypeDesc
       
    54 	{
       
    55 		const char * iName;
       
    56 		ETargetType iTargetType;
       
    57 	};
       
    58 
       
    59 	struct PriorityValueDesc
       
    60 	{
       
    61 		const char * iName;
       
    62 		TProcessPriority iPriority;
       
    63 	};
       
    64 	
       
    65 	struct CompressionMethodDesc
       
    66 	{
       
    67 		const char *iMethodName;
       
    68 		UINT		iMethodUid;
       
    69 	};
       
    70 
       
    71 	/*struct SysDefs
       
    72 	{
       
    73 		int iSysDefOrdinalNum;
       
    74 		char * iSysDefSymbolName;
       
    75 	};
       
    76 
       
    77 	typedef struct SysDefs Sys;*/
       
    78 
       
    79 	typedef std::string string;
       
    80 	typedef std::less<string> OptionCompare;
       
    81 	typedef std::map<string, const OptionDesc *, OptionCompare> OptionMap;
       
    82 	typedef vector<char *> LibSearchPaths;
       
    83 
       
    84 	typedef void (*ParserFn)(ParameterManager *, char *, char *, const OptionDesc *);
       
    85 
       
    86 
       
    87 	#define DECLARE_PARAM_PARSER(name) \
       
    88 		static void name(ParameterManager* aPM, char* aOption, char* aValue, void* aDesc)
       
    89 	
       
    90 	#define DEFINE_PARAM_PARSER(name) \
       
    91 		void name(ParameterManager * aPM, char * aOption, char* aValue, void * aDesc)
       
    92 	
       
    93 	#define INITIALISE_PARAM_PARSER \
       
    94 		aOption = aOption; \
       
    95 		aValue = aValue; \
       
    96 		aDesc = aDesc;
       
    97 
       
    98 	DECLARE_PARAM_PARSER(ParseDefInput);
       
    99 	DECLARE_PARAM_PARSER(ParseDSOOutput);
       
   100 	DECLARE_PARAM_PARSER(ParseTargetTypeName);
       
   101 	DECLARE_PARAM_PARSER(ParseLinkAs);
       
   102 	DECLARE_PARAM_PARSER(ParseDefOutput);
       
   103 	DECLARE_PARAM_PARSER(ParseElfInput);
       
   104 	DECLARE_PARAM_PARSER(ParseFileDump);
       
   105 	DECLARE_PARAM_PARSER(ParseE32ImageInput);
       
   106 	DECLARE_PARAM_PARSER(ParseOutput);
       
   107 	DECLARE_PARAM_PARSER(ParseLogFile);
       
   108 	DECLARE_PARAM_PARSER(ParseMessageFile);
       
   109 	DECLARE_PARAM_PARSER(ParseDumpMessageFile);
       
   110 	
       
   111 	DECLARE_PARAM_PARSER(ParamHelp);
       
   112 	DECLARE_PARAM_PARSER(ParseUID1);
       
   113 	DECLARE_PARAM_PARSER(ParseUID2);
       
   114 	DECLARE_PARAM_PARSER(ParseUID3);
       
   115 
       
   116 
       
   117 	DECLARE_PARAM_PARSER(ParseCapability);
       
   118 	DECLARE_PARAM_PARSER(ParseSecureId);
       
   119 	DECLARE_PARAM_PARSER(ParseVendorId);
       
   120 	DECLARE_PARAM_PARSER(ParseFixedAddress);
       
   121 	DECLARE_PARAM_PARSER(ParseUncompressed);
       
   122 	DECLARE_PARAM_PARSER(ParseCompressionMethod);
       
   123 	DECLARE_PARAM_PARSER(ParseHeap);
       
   124 	DECLARE_PARAM_PARSER(ParseStackCommitted);
       
   125 	DECLARE_PARAM_PARSER(ParseUnfrozen);
       
   126 	DECLARE_PARAM_PARSER(ParseIgnoreNonCallable);
       
   127 	DECLARE_PARAM_PARSER(ParseLibPaths);
       
   128 	DECLARE_PARAM_PARSER(ParseSysDefs);
       
   129 	DECLARE_PARAM_PARSER(ParseAllowDllData);
       
   130 	DECLARE_PARAM_PARSER(ParsePriority);
       
   131 	DECLARE_PARAM_PARSER(ParseVersion);
       
   132 	DECLARE_PARAM_PARSER(ParseCallEntryPoint);
       
   133 	DECLARE_PARAM_PARSER(ParseFPU);
       
   134 
       
   135 	DECLARE_PARAM_PARSER(ParsePaged);
       
   136 	DECLARE_PARAM_PARSER(ParseUnpaged);
       
   137 	DECLARE_PARAM_PARSER(ParseDefaultPaged);
       
   138 
       
   139 	DECLARE_PARAM_PARSER(ParseCodePaging);
       
   140 	DECLARE_PARAM_PARSER(ParseDataPaging);
       
   141 
       
   142 	DECLARE_PARAM_PARSER(ParseExcludeUnwantedExports);
       
   143 	DECLARE_PARAM_PARSER(ParseIsCustomDllTarget);
       
   144 	DECLARE_PARAM_PARSER(ParseSymNamedLookup);
       
   145 	DECLARE_PARAM_PARSER(ParseDebuggable);
       
   146 	DECLARE_PARAM_PARSER(ParseSmpSafe);
       
   147 
       
   148 	ParameterManager(int aArgc, char** aArgv);
       
   149 	virtual ~ParameterManager();
       
   150 	void ParameterAnalyser();
       
   151 	void SetDefInput(char * aDefInputVal);
       
   152 	void SetDSOOutput(char * aDSOOutputVal);
       
   153 	void SetElfInput(char * aSetElfInput);
       
   154 	void SetE32Input(char * aSetE32Input);
       
   155 	void SetFileDumpOptions(char * aSetE32DumpOptions);
       
   156 	void SetE32Output(char * aSetE32Output);
       
   157 	void SetDefOutput(char * aSetDefOutput);
       
   158 	void SetTargetTypeName(ETargetType  aSetTargetTypeName);
       
   159 	void SetLinkDLLName(char * aSetLinkDLLName);
       
   160 	void SetUID1(UINT aSetUINT1);
       
   161 	void SetUID2(UINT aSetUINT2);
       
   162 	void SetUID3(UINT aSetUINT3);
       
   163 	void SetFixedAddress(bool aSetFixedAddress);
       
   164 	void SetCompress(bool aSetCompress);
       
   165 	void SetCompressionMethod(UINT aCompressionMethod);
       
   166 	void SetSecureId(UINT aSetSecureID);
       
   167 	void SetVendorId(UINT aSetVendorID);
       
   168 	void SetHeapCommittedSize(UINT aSetHeapCommittedSize);
       
   169 	void SetHeapReservedSize(UINT aSetHeapReservedSize);
       
   170 	void SetStackCommittedSize(UINT aSetStackCommittedSize);
       
   171 	void SetUnfrozen(bool aVal);
       
   172 	void SetIgnoreNonCallable(bool aVal);
       
   173 	void SetCapability(unsigned int newVal);
       
   174 	void SetCapability(SCapabilitySet & newVal);
       
   175 	void SetSysDefs(unsigned int aSysDefOrdinal, char * aSysDefSymbol, int aCount);
       
   176 	void SetLogFile(char * aSetLogFile);
       
   177 	void SetMessageFile(char *aMessageFile);
       
   178 	void SetDumpMessageFile(char *aDumpMessageFile);
       
   179 	void SetDllDataP(bool newVal);
       
   180 	void SetPriority(TProcessPriority anewVal);
       
   181 	void SetVersion(UINT aSetVersion);
       
   182 	void SetCallEntryPoint(bool aCallEntryPoint);
       
   183 	void SetFPU(UINT aVal);
       
   184 
       
   185 	void SetCodePaged(bool);
       
   186 	void SetCodeUnpaged(bool);
       
   187 	void SetCodeDefaultPaged(bool);
       
   188 
       
   189 	void SetDataPaged(bool);
       
   190 	void SetDataUnpaged(bool);
       
   191 	void SetDataDefaultPaged(bool);
       
   192 	
       
   193 	void SetExcludeUnwantedExports(bool aVal);
       
   194 	void SetCustomDllTarget(bool aVal);
       
   195 	void SetSymNamedLookup(bool aVal);
       
   196 	void SetDebuggable(bool aVal);
       
   197 	void SetSmpSafe(bool aVal);
       
   198 
       
   199 	int NumOptions();
       
   200 	int NumShortOptions();
       
   201 	void InitParamParser();
       
   202 	void ParseCommandLine();
       
   203 	void RecordImageLocation();
       
   204 	char * Path(char * aArg);
       
   205 	ETargetType TargetTypeName();
       
   206 	ETargetType ValidateTargetType(const char * aTargetType);
       
   207 	LibSearchPaths& LibPath();
       
   208 	char * DefInput();
       
   209 	char * ElfInput();
       
   210 	char * E32Input();
       
   211 	bool DefFileInOption();
       
   212 	bool DefFileOutOption();
       
   213 	bool ElfFileInOption();
       
   214 	bool E32ImageInOption();
       
   215 	bool FileDumpOption();
       
   216 	bool DSOFileOutOption();
       
   217 	bool E32OutOption();
       
   218 	bool LinkAsOption();
       
   219 	bool Uid1Option();
       
   220 	bool SecureIdOption();
       
   221 	bool VendorIdOption();
       
   222 	bool SysDefOption();
       
   223 	bool LogFileOption();
       
   224 	bool MessageFileOption();
       
   225 	bool DumpMessageFileOption();
       
   226 	bool DllDataP();
       
   227 	TProcessPriority Priority();
       
   228 	bool PriorityOption();
       
   229 	bool VersionOption();
       
   230 	bool CallEntryPoint();
       
   231 	bool FPUOption();
       
   232 
       
   233 	char * DefOutput();
       
   234 	char * DSOOutput();
       
   235 	char * E32ImageOutput();
       
   236 	char * LinkAsDLLName();
       
   237 	char * FileName(char * aArg);
       
   238 	char * LogFile();
       
   239 	char * MessageFile();
       
   240 	char * DumpMessageFile();
       
   241 	char * FileDumpOptions();
       
   242 	char * FileDumpSubOptions();
       
   243 	int DumpOptions();
       
   244 	int SysDefCount();
       
   245 	char DirectorySeparator();
       
   246 	//int SysDefOrdinalNum();
       
   247 	//char * SysDefSymbol();
       
   248 	Sys SysDefSymbols(int count);
       
   249 	UINT Uid1();
       
   250 	UINT Uid2();
       
   251 	UINT Uid3();
       
   252 	UINT SecureId();
       
   253 	UINT VendorId();
       
   254 	UINT Version();
       
   255 	bool FixedAddress();
       
   256 	bool Compress();
       
   257 	UINT CompressionMethod();
       
   258 	size_t HeapCommittedSize();
       
   259 	size_t HeapReservedSize();
       
   260 	size_t StackCommittedSize();
       
   261 	bool Unfrozen();
       
   262 	bool IgnoreNonCallable();
       
   263 	UseCaseBase * SelectUseCase();
       
   264 	SCapabilitySet Capability();
       
   265 	void ParseCapability1(const char * name, const char * end, SCapabilitySet& aCapabilities, bool invert);
       
   266 	void ParseCapabilitiesArg(SCapabilitySet& aCapabilities, const char *aText);
       
   267 	UINT FPU();
       
   268 
       
   269 	bool IsCodePaged();
       
   270 	bool IsCodeUnpaged();
       
   271 	bool IsCodeDefaultPaged();
       
   272 
       
   273 	bool IsDataPaged();
       
   274 	bool IsDataUnpaged();
       
   275 	bool IsDataDefaultPaged();
       
   276 
       
   277 	bool ExcludeUnwantedExports();
       
   278 	bool IsCustomDllTarget();
       
   279 	bool SymNamedLookup();
       
   280 	bool IsDebuggable();
       
   281 	bool IsSmpSafe();
       
   282 
       
   283 private:
       
   284 	/** The number of command line arguments passed into the program */
       
   285 	int iArgc;
       
   286 
       
   287 	/** The listing of all the arguments */
       
   288 	char ** iArgv;
       
   289 
       
   290 	/** REVISIT */
       
   291 	char * iImageLocation;
       
   292 
       
   293 	/** REVISIT */
       
   294 	char * iImageName;
       
   295 
       
   296 	/** To check if the --targettypeoption (Option to pass the target type of the final image) is provided */
       
   297 	 bool iTargetTypeOption;
       
   298 
       
   299 	/** To check if the --definput (Option to pass the input DEF File) is passed as input */
       
   300 	 bool iDefFileInOption;
       
   301 
       
   302 	/** To check if the --defoutput (Option to pass the output DEF File name) is passed as input */
       
   303 	bool iDefFileOutOption;
       
   304 	
       
   305 	/** To check if the --dump is passed as input */
       
   306 	bool iFileDumpOption;
       
   307 
       
   308 	/** To check if the --dso (Option to pass the output DSO File name) is passed as input */
       
   309 	bool iDSOFileOutOption;
       
   310 	
       
   311 	/** To check if the --output (Option to pass the output image name) is passed as input */
       
   312 	bool iOutFileOption;
       
   313 	
       
   314 	/** To check if the --elfinput (Option to pass the input Elf File) is passed as input */
       
   315 	bool iElfFileInOption;
       
   316 	
       
   317 	/** To check if the --e32input (Option to pass the input E32 File) is passed as input */
       
   318 	bool iE32ImageInOption;
       
   319 	
       
   320 	/** To check if the --linkas (Option to pass DLL name to be linked with) is passed as input */
       
   321 	bool iLinkAsOption;
       
   322 
       
   323 	bool iUid1Option;
       
   324 	bool iSecureIDOption;
       
   325 	bool iVendorIDOption;
       
   326 
       
   327 	/** System level identifier, identifies the general type of a Symbian OS object */
       
   328 	UINT iUID1;
       
   329 
       
   330 	/** Interface identifier, distinguishes within a type (i.e.within a UID1) */
       
   331 	UINT iUID2;
       
   332 
       
   333 	/** Project identifier, identifies a particular subtype */ 
       
   334 	UINT iUID3;
       
   335 
       
   336 	UINT iSecureID;
       
   337 
       
   338 	UINT iVendorID;
       
   339 
       
   340 	bool iCompress;
       
   341 	UINT iCompressionMethod;
       
   342 
       
   343 	bool iFixedAddress;
       
   344 
       
   345 	size_t iHeapCommittedSize;
       
   346 	size_t iHeapReservedSize;
       
   347 	size_t iStackCommittedSize;
       
   348 	bool iUnfrozen;
       
   349 	bool iIgnoreNonCallable;
       
   350 
       
   351 
       
   352 	/** List of the parameters */
       
   353 	ParamList iParamList;
       
   354 
       
   355 	/** The short prefix '-' used for the command line options for the program */
       
   356 	static const char * iParamShortPrefix;
       
   357 
       
   358 	/** The normal prefix '--' used for the command line options for the program */
       
   359 	static const char * iParamPrefix;
       
   360 
       
   361 	/** The '=' used for passing the arguments to the command line options for the program */
       
   362 	static const char iParamEquals; 
       
   363 
       
   364 	/** The list of command line options (with normal prefix '--') that will be accepted by the program */
       
   365 	static const OptionDesc iOptions[];
       
   366 
       
   367 	/** The list of command line options (with short prefix '-') that will be accepted by the program */
       
   368 	static const OptionDesc iShortOptions[];
       
   369 
       
   370 	/** The map between the command line option (with normal prefix '--') and the corresponding function */
       
   371 	OptionMap iOptionMap;
       
   372 
       
   373 	/** The map between the command line option (with short prefix '-') and the corresponding function */
       
   374 	OptionMap iShortOptionMap;
       
   375 
       
   376 	/** The usecase that is selected, could either be LibraryTarget or DLLTarget or EXETarget */
       
   377 	UseCaseBase *iUseCase;
       
   378 
       
   379 	/** Target Type that is passed as input to the --targettype option */
       
   380 	ETargetType iTargetTypeName;
       
   381 
       
   382 	/** File name of the output DEF file passed as input to the --defoutput option */
       
   383 	char * iDefOutput;
       
   384 
       
   385 	/** File name of the output DSO file passed as input to the --dso option */
       
   386 	char * iDSOOutput;
       
   387 
       
   388 	/** File name of the output image passed as input to the --output option */
       
   389 	char * iOutFileName;
       
   390 
       
   391 	/** File name of the input DEF file passed as input to the --definput option */
       
   392 	char * iDefInput;
       
   393 
       
   394 	/** File name of the input DSO file passed as input to the --dsoin option */
       
   395 	char * iElfInput;
       
   396 
       
   397 	/** File name of the input E32 image passed as input to the --e32dump option */
       
   398 	char * iE32Input;
       
   399 
       
   400 	/** File name of the DLL to be linked with passed as input to the --linkas option */
       
   401 	char * iLinkDLLName;
       
   402 
       
   403 	/** Path name of the intermediate libraries passed as input to the --libpath option */
       
   404 	char * iLibPath;
       
   405 
       
   406 	int iDumpOptions;
       
   407 	char *iFileDumpSubOptions;
       
   408 
       
   409 	bool iSysDefOption;
       
   410 	char * iLogFileName;
       
   411 	bool iLogFileOption;
       
   412 	char * iMessageFileName;
       
   413 	bool iMessageFileOption;
       
   414 	char * iDumpMessageFileName;
       
   415 	bool iDumpMessageFileOption;
       
   416 
       
   417 	bool iDllDataP;
       
   418 	
       
   419 	//vector<char*> iLibPathList;
       
   420 	LibSearchPaths iLibPathList;
       
   421 	SCapabilitySet iCapability;
       
   422 	//struct SysDefs iSysDefSymbols[10];
       
   423 	Sys iSysDefSymbols[10];
       
   424 	int iSysDefCount;
       
   425 	bool iPriorityOption;
       
   426 	TProcessPriority iPriorityVal;
       
   427 	UINT iVersion;
       
   428 	bool iVersionOption;
       
   429 	bool iCallEntryPoint;
       
   430 	UINT iFPU;
       
   431 	bool iFPUOption;
       
   432 
       
   433 	int iArgumentCount;
       
   434 	
       
   435 	bool iCodePaged;
       
   436 	bool iCodeUnpaged;
       
   437 	bool iCodeDefaultPaged;
       
   438 
       
   439 	bool iDataPaged;
       
   440 	bool iDataUnpaged;
       
   441 	bool iDataDefaultPaged;
       
   442 
       
   443 	bool iExcludeUnwantedExports;
       
   444 	bool iCustomDllTarget;
       
   445 	bool iSymNamedLookup;
       
   446 	bool iDebuggable;
       
   447 	bool iSmpSafe;
       
   448 };
       
   449 
       
   450 
       
   451 #endif // !defined(SYMBIAN_PARAMETERMANAGER_H_)