e32tools/elf2e32/source/parametermanager.cpp
changeset 589 851206cea67b
parent 0 044383f39525
equal deleted inserted replaced
586:bfc226f3f18c 589:851206cea67b
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
       
    12 // Mike Kinghan, mikek@symbian.org, for Symbian Foundation, 2010
    12 //
    13 //
    13 // Description:
    14 // Description:
    14 // Implementation of the Class ParameterManager for the elf2e32 tool
    15 // Implementation of the Class ParameterManager for the elf2e32 tool
    15 // @internalComponent
    16 // @internalComponent
    16 // @released
    17 // @released
    23 
    24 
    24 #include "pl_common.h"
    25 #include "pl_common.h"
    25 #include "parametermanager.h"
    26 #include "parametermanager.h"
    26 #include "errorhandler.h"
    27 #include "errorhandler.h"
    27 #include <iostream>
    28 #include <iostream>
       
    29 #include <cstdlib>
    28 
    30 
    29 #include "h_utl.h"
    31 #include "h_utl.h"
    30 #include "h_ver.h"
    32 #include "h_ver.h"
    31 /**
    33 /**
    32 Constructor for the ParameterManager.
    34 Constructor for the ParameterManager.
   108 	
   110 	
   109 	iExcludeUnwantedExports(false),
   111 	iExcludeUnwantedExports(false),
   110 	iCustomDllTarget(false),
   112 	iCustomDllTarget(false),
   111 	iSymNamedLookup(false),
   113 	iSymNamedLookup(false),
   112 	iDebuggable(false),
   114 	iDebuggable(false),
   113 	iSmpSafe(false)
   115 	iSmpSafe(false),
       
   116 	iAsmDialect(EArmas)
   114 {
   117 {
   115 	iArgumentCount = aArgc;
   118 	iArgumentCount = aArgc;
   116 	ParamList temp(aArgv, aArgv+aArgc);
   119 	ParamList temp(aArgv, aArgv+aArgc);
   117 	iParamList = temp;
   120 	iParamList = temp;
   118 	iCapability.iCaps[0] = 0;	
   121 	iCapability.iCaps[0] = 0;	
   426 	},
   429 	},
   427 	{
   430 	{
   428 		"smpsafe",
   431 		"smpsafe",
   429 		(void*)ParameterManager::ParseSmpSafe,
   432 		(void*)ParameterManager::ParseSmpSafe,
   430 		"SMP Safe",
   433 		"SMP Safe",
       
   434 	},
       
   435 	{
       
   436 		"asm",
       
   437 		(void*)ParameterManager::ParseAsmDialect,
       
   438 		"Dialect of arm assembly to write for the --dump option. "
       
   439 		"Either \"gas\" (GNU as) or \"armas\" (RVCT as: default)",
   431 	},
   440 	},
   432 	{ 
   441 	{ 
   433 		"help", 
   442 		"help", 
   434 		(void *)ParameterManager::ParamHelp,
   443 		(void *)ParameterManager::ParamHelp,
   435 		0,
   444 		0,
   645 			parser(this, (char *)aName.c_str(), optval, aDesc);
   654 			parser(this, (char *)aName.c_str(), optval, aDesc);
   646 			parser = (ParserFn)aHelpDesc->iParser ;
   655 			parser = (ParserFn)aHelpDesc->iParser ;
   647 			parser(this, "help", 0, 0);
   656 			parser(this, "help", 0, 0);
   648 		}
   657 		}
   649 
   658 
   650 		parser(this, const_cast<char*>(aName.c_str()), optval, aDesc);
   659 		parser(this, aName.c_str(), optval, aDesc);
   651 	}
   660 	}
   652 }
   661 }
   653 
   662 
   654 /**
   663 /**
   655 This function extracts the path
   664 This function extracts the path
  1503 
  1512 
  1504 
  1513 
  1505 bool ParameterManager::IsSmpSafe()
  1514 bool ParameterManager::IsSmpSafe()
  1506 {
  1515 {
  1507 	return iSmpSafe;
  1516 	return iSmpSafe;
       
  1517 }
       
  1518 
       
  1519 /**
       
  1520 This function indicates the asm assembly dialect that will be written for the
       
  1521 --dump option, as determined by the specified or default value of the --asm
       
  1522 option.
       
  1523 
       
  1524 @internalComponent
       
  1525 @released
       
  1526 
       
  1527 @return EArmas if --asm=armas was passed, else EGas
       
  1528 */
       
  1529 EAsmDialect ParameterManager::AsmDialect()
       
  1530 {
       
  1531 	return iAsmDialect;
  1508 }
  1532 }
  1509 
  1533 
  1510 /**
  1534 /**
  1511 This function extracts the filename from the absolute path that is given as input.
  1535 This function extracts the filename from the absolute path that is given as input.
  1512 
  1536 
  2245 		int nq = aSysDefValues.find_first_of(",", q,sizeof(*p));
  2269 		int nq = aSysDefValues.find_first_of(",", q,sizeof(*p));
  2246 		if (nq && (nq != string::npos))
  2270 		if (nq && (nq != string::npos))
  2247 		{
  2271 		{
  2248 			int len = nq;
  2272 			int len = nq;
  2249 			symbol = new char[len+1];
  2273 			symbol = new char[len+1];
  2250 			memcpy(symbol, p, len);
  2274 			memcpy(symbol, &*p, len);
  2251 			symbol[len] = 0;
  2275 			symbol[len] = 0;
  2252 			q = nq+1;
  2276 			q = nq+1;
  2253 
  2277 
  2254 			char val = *(p+q);
  2278 			char val = *(p+q);
  2255 			if (!val || !isdigit(val))
  2279 			if (!val || !isdigit(val))
  2385 		for (; e != aCapList.end(); e++)
  2409 		for (; e != aCapList.end(); e++)
  2386 		{
  2410 		{
  2387 			if (*e == '-' || *e == '+') break;
  2411 			if (*e == '-' || *e == '+') break;
  2388 		}
  2412 		}
  2389 		if (e != b)
  2413 		if (e != b)
  2390 			ParseCapability1(b, e, aCapabilities, invert);
  2414 			ParseCapability1(&*b, &*e, aCapabilities, invert);
  2391 
  2415 
  2392 		b = e;
  2416 		b = e;
  2393 		
  2417 		
  2394 	}
  2418 	}
  2395 }
  2419 }
  2842 DEFINE_PARAM_PARSER(ParameterManager::ParseSmpSafe)
  2866 DEFINE_PARAM_PARSER(ParameterManager::ParseSmpSafe)
  2843 {
  2867 {
  2844 	INITIALISE_PARAM_PARSER;
  2868 	INITIALISE_PARAM_PARSER;
  2845 	CheckInput(aValue, "--smpsafe");
  2869 	CheckInput(aValue, "--smpsafe");
  2846 	aPM->SetSmpSafe(true); 
  2870 	aPM->SetSmpSafe(true); 
       
  2871 }
       
  2872 
       
  2873 DEFINE_PARAM_PARSER(ParameterManager::ParseAsmDialect)
       
  2874 {
       
  2875 	INITIALISE_PARAM_PARSER;
       
  2876 	if (!strcmp(aValue,"gas"))
       
  2877 	{
       
  2878 		aPM->SetAsmDialect(EGas); 
       
  2879 	}
       
  2880 	else if (!strcmp(aValue,"armas"))
       
  2881 	{
       
  2882 		aPM->SetSmpSafe(EArmas); 
       
  2883 	}
       
  2884 	else
       
  2885 	{
       
  2886 		throw InvalidArgumentError(INVALIDARGUMENTERROR, aValue, "--asm");
       
  2887 	} 
  2847 }
  2888 }
  2848 
  2889 
  2849 static const ParameterManager::TargetTypeDesc DefaultTargetTypes[] =
  2890 static const ParameterManager::TargetTypeDesc DefaultTargetTypes[] =
  2850 {
  2891 {
  2851 	{ "DLL", EDll },
  2892 	{ "DLL", EDll },
  3726 
  3767 
  3727 void ParameterManager::SetSmpSafe(bool aVal)
  3768 void ParameterManager::SetSmpSafe(bool aVal)
  3728 {
  3769 {
  3729 	iSmpSafe = aVal;
  3770 	iSmpSafe = aVal;
  3730 }
  3771 }
       
  3772 
       
  3773 /**
       
  3774 This function sets iAsmDialect if --asm is passed in.
       
  3775 
       
  3776 @internalComponent
       
  3777 @released
       
  3778 
       
  3779 @param aVal
       
  3780 A member of enum EAsmDialect
       
  3781 */
       
  3782 void ParameterManager::SetAsmDialect(EAsmDialect aAsmDialect)
       
  3783 {
       
  3784 	iAsmDialect = aAsmDialect;
       
  3785 }
       
  3786