cdlcompilertoolkit/src/CdlTkWriteDll.cpp
changeset 1 b700e12870ca
parent 0 f58d6ec98e88
child 44 8b4f687b7a95
equal deleted inserted replaced
0:f58d6ec98e88 1:b700e12870ca
   134 \n\
   134 \n\
   135 START RESOURCE	 $UID.rss\n\
   135 START RESOURCE	 $UID.rss\n\
   136 TARGET       $UID.rsc\n\
   136 TARGET       $UID.rsc\n\
   137 END\n\
   137 END\n\
   138 START RESOURCE   $UID_cdl_detail.rss\n\
   138 START RESOURCE   $UID_cdl_detail.rss\n\
   139 TARGETPATH       resource\\cdl\n\
   139 TARGETPATH       resource/cdl\n\
   140 END\n\
   140 END\n\
   141 \n\
   141 \n\
   142 $EXTRA";
   142 $EXTRA";
   143 
   143 
   144 const string KMmpSourceLine = "source           $NAME.cpp\n";
   144 const string KMmpSourceLine = "source           $NAME.cpp\n";
   145 const string KMmpLibLine = "library          $NAME\n";
   145 const string KMmpLibLine = "library          $NAME\n";
   146 
   146 
   147 void CCdlTkWriteDll::WriteMmp() const
   147 void CCdlTkWriteDll::WriteMmp() const
   148 	{
   148 	{
   149 	string name = CdlTkUtil::ToLower(CdlTkUtil::OutputPath() + iDll.Name() + ".mmp");
   149 	string name = CdlTkUtil::OutputPath() + CdlTkUtil::ToLower(iDll.Name() + ".mmp");
   150 	ofstream stream;
   150 	ofstream stream;
   151 	CCdlTkFileCleanup tempFile;
   151 	CCdlTkFileCleanup tempFile;
   152 	CdlTkUtil::OpenTempOutput(stream, tempFile);
   152 	CdlTkUtil::OpenTempOutput(stream, tempFile);
   153 
   153 
   154 	string source;
   154 	string source;
   155 	for (CCdlTkDll::CInstances::const_iterator pName = iDll.Instances().begin(); pName != iDll.Instances().end(); ++pName)
   155 	for (CCdlTkDll::CInstances::const_iterator pName = iDll.Instances().begin(); pName != iDll.Instances().end(); ++pName)
   156 		CdlTkUtil::AppendString(source, CdlTkUtil::Replace("$NAME", CdlTkUtil::CorrectFilenameCase(*pName), KMmpSourceLine));
   156 		{
   157 
   157 		string tempPName = CdlTkUtil::Replace("\r", "", *pName);
       
   158 		tempPName = CdlTkUtil::Replace("\n", "", tempPName);
       
   159 
       
   160 		CdlTkUtil::AppendString(source, CdlTkUtil::Replace("$NAME", CdlTkUtil::CorrectFilenameCase(tempPName), KMmpSourceLine));
       
   161 
       
   162 		}
   158 	string libraries;
   163 	string libraries;
   159 	for (CCdlTkDll::CLibraries::const_iterator pLib = iDll.Libraries().begin(); pLib != iDll.Libraries().end(); ++pLib)
   164 	for (CCdlTkDll::CLibraries::const_iterator pLib = iDll.Libraries().begin(); pLib != iDll.Libraries().end(); ++pLib)
   160 		CdlTkUtil::AppendString(libraries, CdlTkUtil::Replace("$NAME", *pLib, KMmpLibLine));
   165 		CdlTkUtil::AppendString(libraries, CdlTkUtil::Replace("$NAME", *pLib, KMmpLibLine));
   161 
   166 
   162 	CdlTkUtil::CReplaceSet mmpSet;
   167 	CdlTkUtil::CReplaceSet mmpSet;
   183 const string KMainCpp = "\
   188 const string KMainCpp = "\
   184 /*\n\
   189 /*\n\
   185 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
   190 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
   186 * All rights reserved.\n\
   191 * All rights reserved.\n\
   187 * This component and the accompanying materials are made available\n\
   192 * This component and the accompanying materials are made available\n\
   188 * under the terms of \"Eclipse Public License v1.0\"\n\
   193 * under the terms of  \"Eclipse Public License v1.0\"\n\
   189 * which accompanies this distribution, and is available\n\
   194 * which accompanies this distribution, and is available\n\
   190 * at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
   195 * at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
   191 *\n\
   196 *\n\
   192 * Initial Contributors:\n\
   197 * Initial Contributors:\n\
   193 * Nokia Corporation - initial contribution.\n\
   198 * Nokia Corporation - initial contribution.\n\
   241 string KMainCppInclude = "#include \"$NAME.h\"\n";
   246 string KMainCppInclude = "#include \"$NAME.h\"\n";
   242 string KMainCppInstance = "\t\tCDL_CUSTOMISATION($CPP_NAME),\n";
   247 string KMainCppInstance = "\t\tCDL_CUSTOMISATION($CPP_NAME),\n";
   243 
   248 
   244 void CCdlTkWriteDll::WriteMainCpp() const
   249 void CCdlTkWriteDll::WriteMainCpp() const
   245 	{
   250 	{
   246 	string name = CdlTkUtil::CorrectFilenameCase(CdlTkUtil::OutputPath() + iDll.Name() + ".cpp");
   251 	string name = CdlTkUtil::OutputPath() + CdlTkUtil::CorrectFilenameCase(iDll.Name() + ".cpp");
   247 	ofstream stream;
   252 	ofstream stream;
   248 	CCdlTkFileCleanup tempFile;
   253 	CCdlTkFileCleanup tempFile;
   249 	CdlTkUtil::OpenTempOutput(stream, tempFile);
   254 	CdlTkUtil::OpenTempOutput(stream, tempFile);
   250 
   255 
   251 	string includes;
   256 	string includes;
   252 	string instances;
   257 	string instances;
   253 	for (CCdlTkDll::CInstances::const_iterator pName = iDll.Instances().begin(); pName != iDll.Instances().end(); ++pName)
   258 	for (CCdlTkDll::CInstances::const_iterator pName = iDll.Instances().begin(); pName != iDll.Instances().end(); ++pName)
   254 		{
   259 		{
   255 		CdlTkUtil::AppendString(includes, CdlTkUtil::Replace("$NAME", CdlTkUtil::ToLower(*pName), KMainCppInclude));
   260 		string tempPName = CdlTkUtil::Replace("\r", "", *pName);
   256 		CdlTkUtil::AppendString(instances, CdlTkUtil::Replace("$CPP_NAME", CdlTkUtil::ToCpp(*pName), KMainCppInstance));
   261 		tempPName = CdlTkUtil::Replace("\n", "", tempPName);
       
   262 
       
   263 		CdlTkUtil::AppendString(includes, CdlTkUtil::Replace("$NAME", CdlTkUtil::ToLower(tempPName), KMainCppInclude));
       
   264 		CdlTkUtil::AppendString(instances, CdlTkUtil::Replace("$CPP_NAME", CdlTkUtil::ToCpp(tempPName), KMainCppInstance));
   257 		}
   265 		}
   258 
   266 
   259 	stringstream majorVer;
   267 	stringstream majorVer;
   260 	majorVer << KCdlCompilerMajorVersion;
   268 	majorVer << KCdlCompilerMajorVersion;
   261 
   269 
   284 const string KInstHeaderBody = "\
   292 const string KInstHeaderBody = "\
   285 /*\n\
   293 /*\n\
   286 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
   294 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
   287 * All rights reserved.\n\
   295 * All rights reserved.\n\
   288 * This component and the accompanying materials are made available\n\
   296 * This component and the accompanying materials are made available\n\
   289 * under the terms of \"Eclipse Public License v1.0\"\n\
   297 * under the terms of  \"Eclipse Public License v1.0\"\n\
   290 * which accompanies this distribution, and is available\n\
   298 * which accompanies this distribution, and is available\n\
   291 * at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
   299 * at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
   292 *\n\
   300 *\n\
   293 * Initial Contributors:\n\
   301 * Initial Contributors:\n\
   294 * Nokia Corporation - initial contribution.\n\
   302 * Nokia Corporation - initial contribution.\n\
   309 
   317 
   310 const string KInstHeaderId = "#define $ID $NUM\n";
   318 const string KInstHeaderId = "#define $ID $NUM\n";
   311 
   319 
   312 void CCdlTkWriteDll::WriteInstanceIdHeader() const
   320 void CCdlTkWriteDll::WriteInstanceIdHeader() const
   313 	{
   321 	{
   314 	string name = CdlTkUtil::ToLower(CdlTkUtil::OutputPath() + KDllInstHeader);
   322 	string name = CdlTkUtil::OutputPath() + CdlTkUtil::ToLower(KDllInstHeader);
   315 	ofstream stream;
   323 	ofstream stream;
   316 	CCdlTkFileCleanup tempFile;
   324 	CCdlTkFileCleanup tempFile;
   317 	CdlTkUtil::OpenTempOutput(stream, tempFile);
   325 	CdlTkUtil::OpenTempOutput(stream, tempFile);
   318 
   326 
   319 	int num = 0;
   327 	int num = 0;
   326 		CdlTkUtil::AppendString(ids, id);
   334 		CdlTkUtil::AppendString(ids, id);
   327 		num++;
   335 		num++;
   328 		}
   336 		}
   329 
   337 
   330 	CdlTkUtil::CReplaceSet headerSet;
   338 	CdlTkUtil::CReplaceSet headerSet;
   331 	headerSet.Add("$DLL_NAME", iDll.Name());
   339 	string dllName = iDll.Name();
       
   340 	dllName = CdlTkUtil::Replace("\r", "", dllName);
       
   341 	dllName = CdlTkUtil::Replace("\n", "", dllName);
       
   342 	headerSet.Add("$DLL_NAME", dllName);
   332 	headerSet.Add("$IDS", ids);
   343 	headerSet.Add("$IDS", ids);
   333 	headerSet.Add("$CMDLINE", CdlTkUtil::CommandLine());
   344 	headerSet.Add("$CMDLINE", CdlTkUtil::CommandLine());
   334 	string header = CdlTkUtil::MultiReplace(headerSet, KInstHeaderBody);
   345 	string header = CdlTkUtil::MultiReplace(headerSet, KInstHeaderBody);
   335 
   346 
   336 	stream << header;
   347 	stream << header;
   342 const string KEComRss = "\
   353 const string KEComRss = "\
   343 /*\n\
   354 /*\n\
   344 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
   355 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
   345 * All rights reserved.\n\
   356 * All rights reserved.\n\
   346 * This component and the accompanying materials are made available\n\
   357 * This component and the accompanying materials are made available\n\
   347 * under the terms of \"Eclipse Public License v1.0\"\n\
   358 * under the terms of  \"Eclipse Public License v1.0\"\n\
   348 * which accompanies this distribution, and is available\n\
   359 * which accompanies this distribution, and is available\n\
   349 * at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
   360 * at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
   350 *\n\
   361 *\n\
   351 * Initial Contributors:\n\
   362 * Initial Contributors:\n\
   352 * Nokia Corporation - initial contribution.\n\
   363 * Nokia Corporation - initial contribution.\n\
   355 *\n\
   366 *\n\
   356 * Description:\n\
   367 * Description:\n\
   357 *\n\
   368 *\n\
   358 */\n\n\
   369 */\n\n\
   359 #include <ecom/registryinfo.rh>\n\
   370 #include <ecom/registryinfo.rh>\n\
   360 #include <cdlecom.hrh>\n\
   371 #include <CdlEcom.hrh>\n\
   361 \n\
   372 \n\
   362 CDL_ECOM_MAIN_REG_WITH_VERSION(0x$DLLUID, $DLLVER)\n";
   373 CDL_ECOM_MAIN_REG_WITH_VERSION(0x$DLLUID, $DLLVER)\n";
   363 
   374 
   364 void CCdlTkWriteDll::WriteEcomRss() const
   375 void CCdlTkWriteDll::WriteEcomRss() const
   365 	{
   376 	{
   366 	string dllUid = CdlTkUtil::IntToHexString(iDll.Uid()).substr(2);
   377 	string dllUid = CdlTkUtil::IntToHexString(iDll.Uid()).substr(2);
   367 	string dllVer = CdlTkUtil::IntToString(iDll.Version());
   378 	string dllVer = CdlTkUtil::IntToString(iDll.Version());
   368 	string name = CdlTkUtil::ToLower(CdlTkUtil::OutputPath() + dllUid + ".rss");
   379 	string name = CdlTkUtil::OutputPath() + CdlTkUtil::ToLower(dllUid + ".rss");
   369 	ofstream stream;
   380 	ofstream stream;
   370 	CCdlTkFileCleanup tempFile;
   381 	CCdlTkFileCleanup tempFile;
   371 	CdlTkUtil::OpenTempOutput(stream, tempFile);
   382 	CdlTkUtil::OpenTempOutput(stream, tempFile);
   372 
   383 
   373 	CdlTkUtil::CReplaceSet rssSet;
   384 	CdlTkUtil::CReplaceSet rssSet;
   396 * Contributors:\n\
   407 * Contributors:\n\
   397 *\n\
   408 *\n\
   398 * Description:\n\
   409 * Description:\n\
   399 *\n\
   410 *\n\
   400 */\n\n\
   411 */\n\n\
   401 #include <cdlecom.rh>\n\
   412 #include <CdlEcom.rh>\n\
   402 #include <cdlecom.hrh>\n\
   413 #include <CdlEcom.hrh>\n\
   403 \n\
   414 \n\
   404 $INCLUDES\
   415 $INCLUDES\
   405 \n\
   416 \n\
   406 CDL_ECOM_REG_DETAIL_START\n\
   417 CDL_ECOM_REG_DETAIL_START\n\
   407 $INSTANCES\
   418 $INSTANCES\
   411 string KDetailRssInstance = "\tCDL_ECOM_DETAIL_IMPL($CPP_NAME)\n";
   422 string KDetailRssInstance = "\tCDL_ECOM_DETAIL_IMPL($CPP_NAME)\n";
   412 
   423 
   413 void CCdlTkWriteDll::WriteEcomDetailRss() const
   424 void CCdlTkWriteDll::WriteEcomDetailRss() const
   414 	{
   425 	{
   415 	string dllUid = CdlTkUtil::IntToHexString(iDll.Uid()).substr(2);
   426 	string dllUid = CdlTkUtil::IntToHexString(iDll.Uid()).substr(2);
   416 	string name = CdlTkUtil::ToLower(CdlTkUtil::OutputPath() + dllUid + "_cdl_detail.rss");
   427 	string name = CdlTkUtil::OutputPath() + CdlTkUtil::ToLower(dllUid + "_cdl_detail.rss");
   417 	ofstream stream;
   428 	ofstream stream;
   418 	CCdlTkFileCleanup tempFile;
   429 	CCdlTkFileCleanup tempFile;
   419 	CdlTkUtil::OpenTempOutput(stream, tempFile);
   430 	CdlTkUtil::OpenTempOutput(stream, tempFile);
   420 
   431 
   421 	string includes;
   432 	string includes;
   422 	string instances;
   433 	string instances;
   423 	CCdlTkDll::CInstances::const_iterator begin = iDll.Instances().begin();
   434 	CCdlTkDll::CInstances::const_iterator begin = iDll.Instances().begin();
   424 	for (CCdlTkDll::CInstances::const_iterator pName = begin; pName != iDll.Instances().end(); ++pName)
   435 	for (CCdlTkDll::CInstances::const_iterator pName = begin; pName != iDll.Instances().end(); ++pName)
   425 		{
   436 		{
       
   437 		string tempPName = CdlTkUtil::Replace("\r", "", *pName);
       
   438 		tempPName = CdlTkUtil::Replace("\n", "", tempPName);
   426 		string instance = (pName != begin) ? "," : "";
   439 		string instance = (pName != begin) ? "," : "";
   427 		instance += CdlTkUtil::Replace("$CPP_NAME", CdlTkUtil::ToCpp(*pName), KDetailRssInstance);
   440 		instance += CdlTkUtil::Replace("$CPP_NAME", CdlTkUtil::ToCpp(tempPName), KDetailRssInstance);
   428 		CdlTkUtil::AppendString(instances, instance);
   441 		CdlTkUtil::AppendString(instances, instance);
   429 		CdlTkUtil::AppendString(includes, CdlTkUtil::Replace("$NAME", CdlTkUtil::ToLower(*pName), KDetailRssInclude));
   442 		CdlTkUtil::AppendString(includes, CdlTkUtil::Replace("$NAME", CdlTkUtil::ToLower(tempPName), KDetailRssInclude));
   430 		}
   443 		}
   431 
   444 
   432 	CdlTkUtil::CReplaceSet rssSet;
   445 	CdlTkUtil::CReplaceSet rssSet;
   433 	rssSet.Add("$INCLUDES", includes);
   446 	rssSet.Add("$INCLUDES", includes);
   434 	rssSet.Add("$INSTANCES", instances);
   447 	rssSet.Add("$INSTANCES", instances);