e32tools/elf2e32/source/parametermanager.cpp
changeset 666 76dc8e3e7f2e
parent 617 3a747a240983
equal deleted inserted replaced
665:2068325a5906 666:76dc8e3e7f2e
    23 
    23 
    24 #include "pl_common.h"
    24 #include "pl_common.h"
    25 #include "parametermanager.h"
    25 #include "parametermanager.h"
    26 #include "errorhandler.h"
    26 #include "errorhandler.h"
    27 #include <iostream>
    27 #include <iostream>
    28 #include <ctype.h>
    28 #include <cstdlib>
    29 
    29 
    30 #include "h_utl.h"
    30 #include "h_utl.h"
    31 #include "h_ver.h"
    31 #include "h_ver.h"
    32 /**
    32 /**
    33 Constructor for the ParameterManager.
    33 Constructor for the ParameterManager.
   109 	
   109 	
   110 	iExcludeUnwantedExports(false),
   110 	iExcludeUnwantedExports(false),
   111 	iCustomDllTarget(false),
   111 	iCustomDllTarget(false),
   112 	iSymNamedLookup(false),
   112 	iSymNamedLookup(false),
   113 	iDebuggable(false),
   113 	iDebuggable(false),
   114 	iSmpSafe(false)
   114 	iSmpSafe(false),
       
   115 	iAsmDialect(EArmas)
   115 {
   116 {
   116 	iArgumentCount = aArgc;
   117 	iArgumentCount = aArgc;
   117 	ParamList temp(aArgv, aArgv+aArgc);
   118 	ParamList temp(aArgv, aArgv+aArgc);
   118 	iParamList = temp;
   119 	iParamList = temp;
   119 	iCapability.iCaps[0] = 0;	
   120 	iCapability.iCaps[0] = 0;	
   427 	},
   428 	},
   428 	{
   429 	{
   429 		"smpsafe",
   430 		"smpsafe",
   430 		(void*)ParameterManager::ParseSmpSafe,
   431 		(void*)ParameterManager::ParseSmpSafe,
   431 		"SMP Safe",
   432 		"SMP Safe",
       
   433 	},
       
   434 	{
       
   435 		"asm",
       
   436 		(void*)ParameterManager::ParseAsmDialect,
       
   437 		"Dialect of arm assembly to write for the --dump option. "
       
   438 		"Either \"gas\" (GNU as) or \"armas\" (RVCT as: default)",
   432 	},
   439 	},
   433 	{ 
   440 	{ 
   434 		"help", 
   441 		"help", 
   435 		(void *)ParameterManager::ParamHelp,
   442 		(void *)ParameterManager::ParamHelp,
   436 		0,
   443 		0,
   646 			parser(this, (char *)aName.c_str(), optval, aDesc);
   653 			parser(this, (char *)aName.c_str(), optval, aDesc);
   647 			parser = (ParserFn)aHelpDesc->iParser ;
   654 			parser = (ParserFn)aHelpDesc->iParser ;
   648 			parser(this, "help", 0, 0);
   655 			parser(this, "help", 0, 0);
   649 		}
   656 		}
   650 
   657 
   651 		parser(this, const_cast<char*>(aName.c_str()), optval, aDesc);
   658 		parser(this, aName.c_str(), optval, aDesc);
   652 	}
   659 	}
   653 }
   660 }
   654 
   661 
   655 /**
   662 /**
   656 This function extracts the path
   663 This function extracts the path
  1506 bool ParameterManager::IsSmpSafe()
  1513 bool ParameterManager::IsSmpSafe()
  1507 {
  1514 {
  1508 	return iSmpSafe;
  1515 	return iSmpSafe;
  1509 }
  1516 }
  1510 
  1517 
       
  1518 /**
       
  1519 This function indicates the asm assembly dialect that will be written for the
       
  1520 --dump option, as determined by the specified or default value of the --asm
       
  1521 option.
       
  1522 
       
  1523 @internalComponent
       
  1524 @released
       
  1525 
       
  1526 @return EArmas if --asm=armas was passed, else EGas
       
  1527 */
       
  1528 EAsmDialect ParameterManager::AsmDialect()
       
  1529 {
       
  1530 	return iAsmDialect;
       
  1531 }
  1511 /**
  1532 /**
  1512 This function extracts the filename from the absolute path that is given as input.
  1533 This function extracts the filename from the absolute path that is given as input.
  1513 
  1534 
  1514 @internalComponent
  1535 @internalComponent
  1515 @released
  1536 @released
  2254 		{
  2275 		{
  2255 			int len = nq;
  2276 			int len = nq;
  2256 			while (*(p+len-1) == ' ' || *(p+len-1) == '	')
  2277 			while (*(p+len-1) == ' ' || *(p+len-1) == '	')
  2257 				len --;
  2278 				len --;
  2258 			symbol = new char[len+1];
  2279 			symbol = new char[len+1];
  2259 			memcpy(symbol, p, len);
  2280 			memcpy(symbol, &*p, len);
  2260 			symbol[len] = 0;
  2281 			symbol[len] = 0;
  2261 			q = nq+1;
  2282 			q = nq+1;
  2262       while (*(p+q) == ' ' || *(p+q) == '	')
  2283       while (*(p+q) == ' ' || *(p+q) == '	')
  2263       	q ++;
  2284       	q ++;
  2264 
  2285 
  2398 		for (; e != aCapList.end(); e++)
  2419 		for (; e != aCapList.end(); e++)
  2399 		{
  2420 		{
  2400 			if (*e == '-' || *e == '+') break;
  2421 			if (*e == '-' || *e == '+') break;
  2401 		}
  2422 		}
  2402 		if (e != b)
  2423 		if (e != b)
  2403 			ParseCapability1(b, e, aCapabilities, invert);
  2424 			ParseCapability1(&*b, &*e, aCapabilities, invert);
  2404 
  2425 
  2405 		b = e;
  2426 		b = e;
  2406 		
  2427 		
  2407 	}
  2428 	}
  2408 }
  2429 }
  2861 	INITIALISE_PARAM_PARSER;
  2882 	INITIALISE_PARAM_PARSER;
  2862 	CheckInput(aValue, "--smpsafe");
  2883 	CheckInput(aValue, "--smpsafe");
  2863 	aPM->SetSmpSafe(true); 
  2884 	aPM->SetSmpSafe(true); 
  2864 }
  2885 }
  2865 
  2886 
       
  2887 DEFINE_PARAM_PARSER(ParameterManager::ParseAsmDialect)
       
  2888 {
       
  2889 	INITIALISE_PARAM_PARSER;
       
  2890 	if (!strcmp(aValue,"gas"))
       
  2891 	{
       
  2892 		aPM->SetAsmDialect(EGas); 
       
  2893 	}
       
  2894 	else if (!strcmp(aValue,"armas"))
       
  2895 	{
       
  2896 		aPM->SetSmpSafe(EArmas); 
       
  2897 	}
       
  2898 	else
       
  2899 	{
       
  2900 		throw InvalidArgumentError(INVALIDARGUMENTERROR, aValue, "--asm");
       
  2901 	} 
       
  2902 }
  2866 static const ParameterManager::TargetTypeDesc DefaultTargetTypes[] =
  2903 static const ParameterManager::TargetTypeDesc DefaultTargetTypes[] =
  2867 {
  2904 {
  2868 	{ "DLL", EDll },
  2905 	{ "DLL", EDll },
  2869 	{ "LIB", ELib },
  2906 	{ "LIB", ELib },
  2870 	// allow full name
  2907 	// allow full name
  3743 
  3780 
  3744 void ParameterManager::SetSmpSafe(bool aVal)
  3781 void ParameterManager::SetSmpSafe(bool aVal)
  3745 {
  3782 {
  3746 	iSmpSafe = aVal;
  3783 	iSmpSafe = aVal;
  3747 }
  3784 }
       
  3785 /**
       
  3786 This function sets iAsmDialect if --asm is passed in.
       
  3787 
       
  3788 @internalComponent
       
  3789 @released
       
  3790 
       
  3791 @param aVal
       
  3792 A member of enum EAsmDialect
       
  3793 */
       
  3794 void ParameterManager::SetAsmDialect(EAsmDialect aAsmDialect)
       
  3795 {
       
  3796 	iAsmDialect = aAsmDialect;
       
  3797 }