cdlcompiler/src/CdlCompiler.cpp
changeset 0 f58d6ec98e88
child 1 b700e12870ca
equal deleted inserted replaced
-1:000000000000 0:f58d6ec98e88
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 #pragma warning (disable:4786)	// disable "identifier was truncated to '255' characters in the browser information" warning
       
    18 #include <string>
       
    19 #include <vector>
       
    20 #include <algorithm>
       
    21 #include <iostream>
       
    22 #include <list>
       
    23 #include <sstream>
       
    24 #include <iomanip>
       
    25 #include <direct.h>
       
    26 #include <cdlcompilertoolkit/cdltkutil.h>
       
    27 #include <cdlcompilertoolkit/cdltkprocess.h>
       
    28 using namespace std;
       
    29 using namespace CdlCompilerToolkit;
       
    30 
       
    31 #ifndef _DEBUG
       
    32 #define EXCEPTION_HANDLING
       
    33 #endif
       
    34 
       
    35 
       
    36 typedef list<string> TArgsList;
       
    37 auto_ptr<CCdlTkInterfaceList> ParseList(const TArgsList& aFiles);
       
    38 
       
    39 //
       
    40 // MainArgsErr
       
    41 //
       
    42 
       
    43 class MainArgsErr : public CdlCompilerToolkitErr
       
    44 	{
       
    45 public:
       
    46 	MainArgsErr(const string& aExtraInfo = "");
       
    47 	void Show(ostream& aStream) const;
       
    48 private:
       
    49 	string iExtraInfo;
       
    50 	};
       
    51 
       
    52 MainArgsErr::MainArgsErr(const string& aExtraInfo)
       
    53 : iExtraInfo(aExtraInfo)
       
    54 	{
       
    55 	}
       
    56 
       
    57 void MainArgsErr::Show(ostream& stream) const
       
    58 	{
       
    59 	if (iExtraInfo.size())
       
    60 		{
       
    61 		stream << endl;
       
    62 		stream << iExtraInfo << endl;
       
    63 		}
       
    64 	stream << endl;
       
    65 	stream << "CdlCompiler <mode> [<options>] <mode specific parameters>" << endl;
       
    66 	stream << "  <mode> is:" << endl;
       
    67 	stream << "    \"client\" mode creates the API for a customisable component." << endl;
       
    68 	stream << "    \"instance\" mode creates customisation instance C++ files." << endl;
       
    69 	stream << "    \"package\" mode creates package instance C++ files." << endl;
       
    70 	stream << "    \"dll\" mode creates C++ and project files to collect together customisation instances in a DLL." << endl;
       
    71 	stream << "    \"compare\" compares two CDL interfaces." << endl;
       
    72 	stream << "  <options> are:" << endl;
       
    73 	stream << "    -p<output path>  path for the output files." << endl;
       
    74 	stream << "    -v               show CdlCompiler version." << endl;
       
    75 	stream << "    -h               show help information for a <mode>." << endl;
       
    76 	}
       
    77 
       
    78 
       
    79 //
       
    80 // CCompilerMode
       
    81 //
       
    82 
       
    83 class CCompilerMode 
       
    84 	{
       
    85 public:
       
    86 	virtual ~CCompilerMode();
       
    87 	virtual void ProcessOption(const std::string& aOpt);
       
    88 	virtual int Process(const TArgsList& aArgs) = 0;
       
    89 	virtual void ShowHelp(ostream& aStream) = 0;
       
    90 	};
       
    91 
       
    92 CCompilerMode::~CCompilerMode()
       
    93 	{
       
    94 	}
       
    95 
       
    96 void CCompilerMode::ProcessOption(const std::string& aOpt)
       
    97 	{
       
    98 	throw MainArgsErr(string("unrecognised option for this mode ") + aOpt);
       
    99 	}
       
   100 
       
   101 
       
   102 //
       
   103 // CClientMode
       
   104 //
       
   105 
       
   106 class CClientMode : public CCompilerMode
       
   107 	{
       
   108 public:
       
   109 	int Process(const TArgsList& aArgs);
       
   110 	void ShowHelp(ostream& aStream);
       
   111 	};
       
   112 
       
   113 int CClientMode::Process(const TArgsList& aArgs)
       
   114 	{
       
   115 	auto_ptr<CCdlTkInterfaceList> cdls(ParseList(aArgs));
       
   116 	for (CCdlTkInterfaceList::iterator pCdl = cdls->begin(); pCdl != cdls->end(); ++pCdl)
       
   117 		{
       
   118 		CCdlTkWriteClientHeader processor(**pCdl);
       
   119 		processor.Process();
       
   120 		}
       
   121 	return 0;
       
   122 	}
       
   123 
       
   124 void CClientMode::ShowHelp(ostream& aStream)
       
   125 	{
       
   126 	aStream << "CdlCompiler client <options> [<CDL files>]" << endl;
       
   127 	aStream << "  client mode creates the API for a customisable component." << endl;
       
   128 	aStream << "  For each CDL file parameter, it creates C++ header files containing the API." << endl;
       
   129 	aStream << "  By default, these headers are placed in \\epoc32\\include." << endl;
       
   130 	}
       
   131 
       
   132 //
       
   133 // CInstanceMode
       
   134 //
       
   135 
       
   136 class CInstanceMode : public CCompilerMode
       
   137 	{
       
   138 public:
       
   139 	int Process(const TArgsList& aArgs);
       
   140 	void ShowHelp(ostream& aStream);
       
   141 	};
       
   142 
       
   143 int CInstanceMode::Process(const TArgsList& aArgs)
       
   144 	{
       
   145 	TArgsList::const_iterator pArg = aArgs.begin();
       
   146 	if (pArg == aArgs.end())
       
   147 		throw MainArgsErr("Missing CDL file name");
       
   148 
       
   149 	CCdlTkCdlFileParser parser(*pArg);
       
   150 	auto_ptr<CCdlTkInterface> cdl = parser.LoadAndParse(true);
       
   151 
       
   152 	++pArg;
       
   153 	if (pArg == aArgs.end())
       
   154 		throw MainArgsErr("Missing instance name");
       
   155 	CCdlTkInstance inst(*cdl);
       
   156 	inst.SetName(*pArg);
       
   157 	inst.TemplateAllImplementations();
       
   158 
       
   159 	++pArg;
       
   160 	if (pArg != aArgs.end())
       
   161 		{
       
   162 		inst.SetId(CdlTkUtil::ParseInt(*pArg));
       
   163 		++pArg;
       
   164 		}
       
   165 
       
   166 	if (pArg != aArgs.end())
       
   167 		throw MainArgsErr("Too many parameters");
       
   168 
       
   169 	CCdlTkWriteInstance processor(inst);
       
   170 	processor.Process();
       
   171 	
       
   172 	return 0;
       
   173 	}
       
   174 
       
   175 void CInstanceMode::ShowHelp(ostream& aStream)
       
   176 	{
       
   177 	aStream << "CdlCompiler instance <options> <CDL file> <instance name> [<id>]" << endl;
       
   178 	aStream << "  instance mode creates C++ files containing a template customisation instance." << endl;
       
   179 	aStream << "  The customisation instance will implement the interface defined in <CDL file>." << endl;
       
   180 	aStream << "  It and its source files will be called <instance name>." << endl;
       
   181 	aStream << "  It will have an instance id of <id>, if specified. Otherwise," << endl;
       
   182 	aStream << "  the instance id will come from the host DLL." << endl;
       
   183 	}
       
   184 
       
   185 
       
   186 //
       
   187 // CPackageMode
       
   188 //
       
   189 
       
   190 class CPackageMode : public CCompilerMode
       
   191 	{
       
   192 public:
       
   193 	int Process(const TArgsList& aArgs);
       
   194 	void ShowHelp(ostream& aStream);
       
   195 	};
       
   196 
       
   197 int CPackageMode::Process(const TArgsList& aArgs)
       
   198 	{
       
   199 	TArgsList::const_iterator pArg = aArgs.begin();
       
   200 	if (pArg == aArgs.end())
       
   201 		throw MainArgsErr("Missing package CDL file name");
       
   202 
       
   203 	CCdlTkCdlFileParser parser(*pArg);
       
   204 	auto_ptr<CCdlTkInterface> cdl = parser.LoadAndParse(true);
       
   205 
       
   206 	++pArg;
       
   207 	if (pArg == aArgs.end())
       
   208 		throw MainArgsErr("Missing package name");
       
   209 	CCdlTkPackage pckg(*cdl);
       
   210 	pckg.SetName(*pArg);
       
   211 	pckg.TemplateAllImplementations();
       
   212 
       
   213 	++pArg;
       
   214 	if (pArg == aArgs.end())
       
   215 		throw MainArgsErr("Missing package instance id");
       
   216 
       
   217 	if (count_if(pArg->begin(), pArg->end(), CdlTkUtil::IsNumeric) == pArg->size())
       
   218 		{
       
   219 		pckg.SetId(CdlTkUtil::ParseInt(*pArg));
       
   220 		++pArg;
       
   221 		}
       
   222 
       
   223 	for (; pArg != aArgs.end(); ++pArg)
       
   224 		pckg.AddLocalContent(*pArg);
       
   225 
       
   226 	CCdlTkWriteInstance processor(pckg);
       
   227 	processor.Process();
       
   228 
       
   229 	return 0;
       
   230 	}
       
   231 
       
   232 void CPackageMode::ShowHelp(ostream& aStream)
       
   233 	{
       
   234 	aStream << "CdlCompiler package <options> <CDL file> <package name> [<id>] [<instance names>]" << endl;
       
   235 	aStream << "  package mode creates template package instance C++ files." << endl;
       
   236 	aStream << "  The package instance will implement the interface defined in <CDL file>." << endl;
       
   237 	aStream << "  It and its source files will be called <package name>." << endl;
       
   238 	aStream << "  It will have an instance id of <id> if <id> is a number." << endl;
       
   239 	aStream << "  The package contents will be references to the customisation instances <instance names>." << endl;
       
   240 	aStream << "  Note: the package contents will assume that all instances are in the same DLL." << endl;
       
   241 	}
       
   242 
       
   243 
       
   244 //
       
   245 // CDllMode
       
   246 //
       
   247 
       
   248 class CDllMode : public CCompilerMode
       
   249 	{
       
   250 public:
       
   251 	CDllMode();
       
   252 	void ProcessOption(const std::string& aOpt);
       
   253 	int Process(const TArgsList& aArgs);
       
   254 	void ShowHelp(ostream& aStream);
       
   255 private:
       
   256 	CCdlTkDll::CLibraries iLibs;
       
   257 	string iExtraMmp;
       
   258 	int iVersion;
       
   259 	};
       
   260 
       
   261 CDllMode::CDllMode()
       
   262 : iVersion(1)
       
   263 	{
       
   264 	}
       
   265 
       
   266 void CDllMode::ProcessOption(const std::string& aOpt)
       
   267 	{
       
   268 	if (aOpt[1] == 'l')
       
   269 		{
       
   270 		iLibs.push_back(aOpt.substr(2));
       
   271 		}
       
   272 	else if (aOpt[1] == 's')
       
   273 		{
       
   274 		CdlTkUtil::AppendString(iExtraMmp, string("SOURCE "));
       
   275 		CdlTkUtil::AppendString(iExtraMmp, aOpt.substr(2));
       
   276 		CdlTkUtil::AppendString(iExtraMmp, "\n");
       
   277 		}
       
   278 	else if (aOpt[1] == 'e')
       
   279 		{
       
   280 		CdlTkUtil::AppendString(iExtraMmp, aOpt.substr(2));
       
   281 		CdlTkUtil::AppendString(iExtraMmp, "\n");
       
   282 		}
       
   283 	else if(aOpt[1] == 'n')
       
   284 		{
       
   285 		iVersion = CdlTkUtil::ParseInt(aOpt.substr(2));
       
   286 		if(iVersion < 1) iVersion = 1;
       
   287 		}
       
   288 	else
       
   289 		{
       
   290 		CCompilerMode::ProcessOption(aOpt);
       
   291 		}
       
   292 	}
       
   293 
       
   294 int CDllMode::Process(const TArgsList& aArgs)
       
   295 	{
       
   296 	TArgsList::const_iterator pArg = aArgs.begin();
       
   297 	if (pArg == aArgs.end())
       
   298 		throw MainArgsErr("Missing DLL name");
       
   299 
       
   300 	CCdlTkDll dll;
       
   301 	dll.SetName(*pArg);
       
   302 	++pArg;
       
   303 
       
   304 	dll.SetVersion(iVersion);
       
   305 
       
   306 	if (pArg == aArgs.end())
       
   307 		throw MainArgsErr("Missing DLL UID");
       
   308 
       
   309 	dll.SetUid(CdlTkUtil::ParseInt(*pArg));
       
   310 	++pArg;
       
   311 
       
   312 	for (; pArg != aArgs.end(); ++pArg)
       
   313 		{
       
   314 		const string& inst = *pArg;
       
   315 		if (inst[0]!='@')
       
   316 			{
       
   317 			dll.AddInstance(*pArg);
       
   318 			}
       
   319 		else
       
   320 			{
       
   321 			// read instance list from a file
       
   322 			ifstream argFile;
       
   323 			CdlTkUtil::OpenInput(argFile, inst.substr(1));
       
   324 			string line;
       
   325 			while (!argFile.eof())
       
   326 				{
       
   327 				getline(argFile, line);
       
   328 				if (line.length())
       
   329 					dll.AddInstance(line);
       
   330 				}
       
   331 			argFile.close();
       
   332 			}
       
   333 		}
       
   334 
       
   335 	dll.Libraries().insert(dll.Libraries().end(), iLibs.begin(), iLibs.end());
       
   336 	dll.SetExtraMmp(dll.ExtraMmp() + iExtraMmp);
       
   337 
       
   338 	CCdlTkWriteDll processor(dll);
       
   339 	processor.Process();
       
   340 
       
   341 	return 0;
       
   342 	}
       
   343 
       
   344 void CDllMode::ShowHelp(ostream& aStream)
       
   345 	{
       
   346 	aStream << "CdlCompiler dll <options> <dll name> <uid> [<instance names>]" << endl;
       
   347 	aStream << "  dll mode creates C++ and project files to collect together customisation instances in a DLL." << endl;
       
   348 	aStream << "  The DLL and its source files will be called <dll name>." << endl;
       
   349 	aStream << "  It will have a UID of <uid>." << endl;
       
   350 	aStream << "  The DLL will contain customisation instances <instance names>." << endl;
       
   351 	aStream << "  If an instance name starts with @, this will be treated as the name of a file" << endl;
       
   352 	aStream << "  which contains a list of instance names, one per line." << endl;
       
   353 	aStream << "  Options:" << endl;
       
   354 	aStream << "    -l<libName> to add a library to the DLL." << endl;
       
   355 	aStream << "    -s<sourceFileName> to add a source file to the DLL." << endl;
       
   356 	aStream << "    -e<extraMmp> to add more statements to the DLL's MMP file." << endl;
       
   357 	aStream << "    -n<version> to set the DLL version number in format x, defaults to 1 when not specified or invalid." << endl;
       
   358 	aStream << "          Does not accept a minor version number." << endl;
       
   359 	}
       
   360 
       
   361 
       
   362 //
       
   363 // CCompareModeChecker
       
   364 //
       
   365 
       
   366 class CCompareModeChecker : public MCdlTkApiCheckObserver
       
   367 	{
       
   368 public:
       
   369 	CCompareModeChecker(const string& aLeft, const string& aRight);
       
   370 	virtual void StartCheck();
       
   371 	virtual void CheckComplete();
       
   372 	virtual void ApiInBoth(const CCdlTkApi& aApi);
       
   373 	virtual void ApiNotInLeft(const CCdlTkApi& aApi);
       
   374 	virtual void ApiNotInRight(const CCdlTkApi& aApi);
       
   375 
       
   376 private:
       
   377 	int iErrs;
       
   378 	string iLeft;
       
   379 	string iRight;
       
   380 	};
       
   381 
       
   382 CCompareModeChecker::CCompareModeChecker(const string& aLeft, const string& aRight)
       
   383 : iLeft(aLeft), iRight(aRight)
       
   384 	{
       
   385 	}
       
   386 
       
   387 void CCompareModeChecker::StartCheck()
       
   388 	{
       
   389 	iErrs = 0;
       
   390 	}
       
   391 
       
   392 void CCompareModeChecker::CheckComplete()
       
   393 	{
       
   394 	cout << "Check complete, " << iErrs << " differences found" << endl;
       
   395 	}
       
   396 
       
   397 void CCompareModeChecker::ApiInBoth(const CCdlTkApi& /*aApi*/)
       
   398 	{
       
   399 	}
       
   400 
       
   401 void CCompareModeChecker::ApiNotInLeft(const CCdlTkApi& aApi)
       
   402 	{
       
   403 	cout << iRight << ": " << aApi.Name() << aApi.ParamsTypeAndNameList() << " not found in " << iLeft << endl;
       
   404 	iErrs++;
       
   405 	}
       
   406 
       
   407 void CCompareModeChecker::ApiNotInRight(const CCdlTkApi& aApi)
       
   408 	{
       
   409 	cout << iLeft << ": " << aApi.Name() << aApi.ParamsTypeAndNameList() << " not found in " << iRight << endl;
       
   410 	iErrs++;
       
   411 	}
       
   412 
       
   413 
       
   414 //
       
   415 // CCompareMode
       
   416 //
       
   417 
       
   418 class CCompareMode : public CCompilerMode
       
   419 	{
       
   420 public:
       
   421 	int Process(const TArgsList& aArgs);
       
   422 	void ShowHelp(ostream& aStream);
       
   423 	};
       
   424 
       
   425 int CCompareMode::Process(const TArgsList& aArgs)
       
   426 	{
       
   427 	auto_ptr<CCdlTkInterfaceList> cdls(ParseList(aArgs));
       
   428 	if (cdls->size() != 2)
       
   429 		throw MainArgsErr("Exactly 2 CDL files required");
       
   430 	CCompareModeChecker reporter(*aArgs.begin(), *++(aArgs.begin()));
       
   431 	CCdlTkApiChecker checker(*(*cdls)[0], *(*cdls)[1], reporter);
       
   432 	checker.Process();
       
   433 
       
   434 	return 0;
       
   435 	}
       
   436 
       
   437 void CCompareMode::ShowHelp(ostream& aStream)
       
   438 	{
       
   439 	aStream << "CdlCompiler compare <options> <left CDL file> <right CDL file>" << endl;
       
   440 	aStream << "  compare mode reports the difference between two CDL interfaces." << endl;
       
   441 	}
       
   442 
       
   443 
       
   444 //
       
   445 // CCompareMode
       
   446 //
       
   447 
       
   448 class CBigApiTestMode : public CCompilerMode
       
   449 	{
       
   450 public:
       
   451 	int Process(const TArgsList& aArgs);
       
   452 	void ShowHelp(ostream& aStream);
       
   453 	};
       
   454 
       
   455 string MakeApiName(int i)
       
   456 	{
       
   457 	return string("Api")+CdlTkUtil::IntToString(i);
       
   458 	}
       
   459 
       
   460 int CBigApiTestMode::Process(const TArgsList& aArgs)
       
   461 	{
       
   462 	string name = "BigApi";
       
   463 	int size = CdlTkUtil::ParseInt(*aArgs.begin());
       
   464 
       
   465 	// make a CDL interface
       
   466 	CCdlTkInterface iface;
       
   467 	iface.SetFileName(name+".cdl");
       
   468 	CCdlTkInterfaceHeader& header = iface.Header();
       
   469 	header.SetName(name);
       
   470 	header.SetUid(0x0fffffff);
       
   471 	CCdlTkApiList& apiList = iface.ApiList();
       
   472 	for (int ii=0; ii<size; ii++)
       
   473 		{
       
   474 		auto_ptr<CCdlTkFunctionApi> api(new CCdlTkFunctionApi(iface));
       
   475 		api->SetName(MakeApiName(ii));
       
   476 		api->SetReturnType("TInt");
       
   477 		apiList.push_back(api.get());
       
   478 		api.release();
       
   479 		}
       
   480 
       
   481 	// write the CDL file
       
   482 	CCdlTkWriteCdlFile cdlWriter(iface);
       
   483 	cdlWriter.Process();
       
   484 
       
   485 	// make an instance
       
   486 	CCdlTkInstance inst(iface);
       
   487 	inst.SetName(name+"Inst");
       
   488 	inst.TemplateAllImplementations();
       
   489 	CCdlTkImplementations& impls = inst.Impl();
       
   490 	for (CCdlTkImplementations::iterator pImpl = impls.begin(); pImpl != impls.end(); ++pImpl)
       
   491 		{
       
   492 		CCdlTkImplementation& imp = **pImpl;
       
   493 		string defn = imp.Definition();
       
   494 		defn = CdlTkUtil::Replace("//TODO: Implement this function.", "return 0;", defn);
       
   495 		imp.SetDefinition(defn);
       
   496 		}
       
   497 
       
   498 	// write the instance
       
   499 	CCdlTkWriteInstance instWriter(inst);
       
   500 	instWriter.Process();
       
   501 
       
   502 	return 0;
       
   503 	}
       
   504 
       
   505 void CBigApiTestMode::ShowHelp(ostream& /*aStream*/)
       
   506 	{
       
   507 	}
       
   508 
       
   509 
       
   510 //
       
   511 // static functions
       
   512 //
       
   513 
       
   514 bool ProcessOptions(TArgsList::iterator& aArgIter, const TArgsList::iterator& aEnd, CCompilerMode& aMode)
       
   515 	{
       
   516 	while (aArgIter != aEnd && (*aArgIter)[0] == '-')
       
   517 		{
       
   518 		string& arg = *aArgIter;
       
   519 		if (arg.size() < 2)
       
   520 			throw MainArgsErr("bad option \"-\"");
       
   521 		switch (arg[1])
       
   522 			{
       
   523 			case 'p': 
       
   524 				CdlTkUtil::SetOutputPath(arg.substr(2));
       
   525 				break;
       
   526 			case 'v': 
       
   527 				cout << "CdlCompiler version " << KCdlCompilerMajorVersion << "." << KCdlCompilerMinorVersion << endl;
       
   528 				return true;		// exit CdlCompiler
       
   529 			case 'h': 
       
   530 				aMode.ShowHelp(cerr);
       
   531 				return true;		// exit CdlCompiler
       
   532 			default: 
       
   533 				aMode.ProcessOption(arg);
       
   534 				break;
       
   535 			}
       
   536 		++aArgIter;
       
   537 		}
       
   538 	return false;	// continue execution of the CdlCompiler
       
   539 	}
       
   540 
       
   541 auto_ptr<CCdlTkInterfaceList> ParseList(const TArgsList& aFiles)
       
   542 	{
       
   543 	auto_ptr<CCdlTkInterfaceList> ifaceList(new CCdlTkInterfaceList);
       
   544 
       
   545 	for (TArgsList::const_iterator pFile = aFiles.begin(); pFile != aFiles.end(); ++pFile)
       
   546 		{
       
   547 		CCdlTkCdlFileParser parser(*pFile);
       
   548 		auto_ptr<CCdlTkInterface> cdl = parser.LoadAndParse(true);
       
   549 		ifaceList->push_back(cdl.get());
       
   550 		cdl.release();
       
   551 		}
       
   552 
       
   553 	return ifaceList;
       
   554 	}
       
   555 
       
   556 int DoMain(int argc, char* argv[])
       
   557 	{
       
   558 	CdlTkUtil::SetCommandLine(argc, argv);
       
   559 
       
   560 	if (argc < 2)
       
   561 		throw MainArgsErr("Missing mode");
       
   562 
       
   563 	TArgsList args;
       
   564 	copy(argv + 1, argv + argc, back_inserter(args));
       
   565 	TArgsList::iterator pArg = args.begin();
       
   566 
       
   567 	// process mode arg
       
   568 	auto_ptr<CCompilerMode> mode;
       
   569 	if (*pArg == "client")
       
   570 		{
       
   571 		mode = auto_ptr<CCompilerMode>(new CClientMode);
       
   572 		CdlTkUtil::SetOutputPath(CdlTkUtil::CurrentDrive() + "\\epoc32\\include\\");
       
   573 		}
       
   574 	else if (*pArg == "instance")
       
   575 		{
       
   576 		mode = auto_ptr<CCompilerMode>(new CInstanceMode);
       
   577 		}
       
   578 	else if (*pArg == "dll")
       
   579 		{
       
   580 		mode = auto_ptr<CCompilerMode>(new CDllMode);
       
   581 		}
       
   582 	else if (*pArg == "package")
       
   583 		{
       
   584 		mode = auto_ptr<CCompilerMode>(new CPackageMode);
       
   585 		}
       
   586 	else if (*pArg == "compare")
       
   587 		{
       
   588 		mode = auto_ptr<CCompilerMode>(new CCompareMode);
       
   589 		}
       
   590 	else if (*pArg == "BigApiTest")
       
   591 		{
       
   592 		mode = auto_ptr<CCompilerMode>(new CBigApiTestMode);
       
   593 		}
       
   594 	else
       
   595 		throw MainArgsErr(string("Unrecognised mode ") + *pArg);
       
   596 	++pArg;
       
   597 
       
   598 	// process options args
       
   599 	if (ProcessOptions(pArg, args.end(), *mode))
       
   600 		return 0;
       
   601 
       
   602 	// process mode args
       
   603 	return mode->Process(TArgsList(pArg, args.end()));
       
   604 	}
       
   605 
       
   606 int main(int argc, char* argv[])
       
   607 	{
       
   608 #ifdef EXCEPTION_HANDLING
       
   609 	try
       
   610 		{
       
   611 #endif
       
   612 		return DoMain(argc, argv);
       
   613 #ifdef EXCEPTION_HANDLING
       
   614 		}
       
   615 	catch (const CdlCompilerToolkitErr& aErr)
       
   616 		{
       
   617 		aErr.Show(cerr);
       
   618 		}
       
   619 
       
   620 	return 1;
       
   621 #endif
       
   622 	}
       
   623 
       
   624 // End of File