33 #include "MLAttributesParse.h" |
33 #include "MLAttributesParse.h" |
34 #include "MLAttributes.h" |
34 #include "MLAttributes.h" |
35 #include "CodeGenConsts.h" |
35 #include "CodeGenConsts.h" |
36 #include "UsefulDefinitions.h" |
36 #include "UsefulDefinitions.h" |
37 |
37 |
38 #include <akndef.hrh> |
38 #include <AknDef.hrh> |
39 |
39 |
40 #include <fstream> |
40 #include <fstream> |
41 #include <algorithm> |
41 #include <algorithm> |
42 #include <iostream> |
42 #include <iostream> |
43 #include <numeric> // accumulate |
43 #include <numeric> // accumulate |
65 const string KSpace = " "; |
65 const string KSpace = " "; |
66 const string KComma = ","; |
66 const string KComma = ","; |
67 const string KTheWordBlank("blank"); |
67 const string KTheWordBlank("blank"); |
68 const string KParentRelativeMarker("Pp"); |
68 const string KParentRelativeMarker("Pp"); |
69 const string KCellNameJustification("J"); |
69 const string KCellNameJustification("J"); |
70 const string KCompDataFileNameSuffix("compData"); |
70 const string KCompDataFileNameSuffix("compdata"); |
71 const string KAttributesFileNameSuffix("attributes"); |
71 const string KAttributesFileNameSuffix("attributes"); |
72 |
72 |
73 // this is the addressable area for each instance, as the lookup table is 16bit |
73 // this is the addressable area for each instance, as the lookup table is 16bit |
74 const int KAddressableBytecodedData = 0xFFFF; |
74 const int KAddressableBytecodedData = 0xFFFF; |
75 |
75 |
120 |
121 |
121 bool IsSimilar(TFuncType aType, CCdlTkApiParams& aParams) |
122 bool IsSimilar(TFuncType aType, CCdlTkApiParams& aParams) |
122 { |
123 { |
123 if(iType != aType) |
124 if(iType != aType) |
124 return false; |
125 return false; |
125 int size = iParams.size(); |
126 unsigned int size = iParams.size(); |
126 if(size != aParams.size()) |
127 if(size != aParams.size()) |
127 return false; |
128 return false; |
128 for(int ii = 0; ii < size; ii++) |
129 for(unsigned int ii = 0; ii < size; ii++) |
129 { |
130 { |
130 CCdlTkApiParam& thisParam = iParams[ii]; |
131 CCdlTkApiParam& thisParam = iParams[ii]; |
131 CCdlTkApiParam& otherParam = aParams[ii]; |
132 CCdlTkApiParam& otherParam = aParams[ii]; |
132 if(thisParam.Name() != otherParam.Name()) |
133 if(thisParam.Name() != otherParam.Name()) |
133 return false; |
134 return false; |
208 while(next_permutation(pattern.begin(), pattern.end())); |
209 while(next_permutation(pattern.begin(), pattern.end())); |
209 |
210 |
210 for(set< Seq >::iterator pPattern = subPatterns.begin(); pPattern != subPatterns.end(); ++pPattern) |
211 for(set< Seq >::iterator pPattern = subPatterns.begin(); pPattern != subPatterns.end(); ++pPattern) |
211 { |
212 { |
212 CCdlTkApiParams params; |
213 CCdlTkApiParams params; |
213 for(Seq::iterator pParam = pPattern->begin(); pParam != pPattern->end(); ++pParam) |
214 for(Seq::const_iterator pParam = pPattern->begin(); pParam != pPattern->end(); ++pParam) |
214 { |
215 { |
215 int& param = (*pParam); |
216 int param = (*pParam); |
216 string name = paramNames[param]; |
217 string name = paramNames[param]; |
217 params.push_back(CCdlTkApiParam(KTypeInt, name)); |
218 params.push_back(CCdlTkApiParam(KTypeInt, name)); |
218 } |
219 } |
219 AddFunc(SCompDataImplFunc::EWindowLine, params, KTypeWindowComponentLayout, KFuncWindowLine, true); |
220 AddFunc(SCompDataImplFunc::EWindowLine, params, KTypeWindowComponentLayout, KFuncWindowLine, true); |
220 AddFunc(SCompDataImplFunc::ETextLine, params, KTypeTextComponentLayout, KFuncTextLine, true); |
221 AddFunc(SCompDataImplFunc::ETextLine, params, KTypeTextComponentLayout, KFuncTextLine, true); |
372 CMLCompDataSubTableInstOptImpl::CMLCompDataSubTableInstOptImpl( |
373 CMLCompDataSubTableInstOptImpl::CMLCompDataSubTableInstOptImpl( |
373 TMLCompDataTable* aTable, |
374 TMLCompDataTable* aTable, |
374 TMLCompDataTable::TMLCompDataSubTable* aSubTable, |
375 TMLCompDataTable::TMLCompDataSubTable* aSubTable, |
375 CCdlTkImplementation* aImpl) |
376 CCdlTkImplementation* aImpl) |
376 : |
377 : |
|
378 CMLCompDataInstOptImpl(aImpl), |
377 iTable(aTable), |
379 iTable(aTable), |
378 CMLCompDataInstOptImpl(aImpl), |
|
379 iSubTable(aSubTable) |
380 iSubTable(aSubTable) |
380 { |
381 { |
381 } |
382 } |
382 |
383 |
383 CMLCompDataSubTableInstOptImpl::~CMLCompDataSubTableInstOptImpl() |
384 CMLCompDataSubTableInstOptImpl::~CMLCompDataSubTableInstOptImpl() |
479 CMLCompDataInstOpt::CMLCompDataInstOpt(MLCompDataCdlInstanceOpt& aInstances, TMLCompData* aLayout, const string& aInstName, const string& aZoomName, int aZoomLevel, bool aAllParams, bool aNonCompleteInstance) |
480 CMLCompDataInstOpt::CMLCompDataInstOpt(MLCompDataCdlInstanceOpt& aInstances, TMLCompData* aLayout, const string& aInstName, const string& aZoomName, int aZoomLevel, bool aAllParams, bool aNonCompleteInstance) |
480 : |
481 : |
481 iInstances(aInstances), |
482 iInstances(aInstances), |
482 iLayout(aLayout), |
483 iLayout(aLayout), |
483 iName(aInstName), |
484 iName(aInstName), |
484 iZoomName(aZoomName), |
485 iZoomName(aZoomName), |
|
486 iInterface(iInstances.Interface()), |
485 iZoomLevel(aZoomLevel), |
487 iZoomLevel(aZoomLevel), |
486 iInterface(iInstances.Interface()), |
|
487 iAllParams(aAllParams), |
488 iAllParams(aAllParams), |
488 iBaseOffset(0) |
489 iBaseOffset(0) |
489 { |
490 { |
490 string zoomInstName = aInstName; |
491 string zoomInstName = aInstName; |
491 if(aZoomName.length() > 0) |
492 if(aZoomName.length() > 0) |
535 CMLCompDataInstOpt::~CMLCompDataInstOpt() |
536 CMLCompDataInstOpt::~CMLCompDataInstOpt() |
536 { |
537 { |
537 delete iInstance; |
538 delete iInstance; |
538 for (CMLCompDataInstOptImpls::iterator pImpl = iImpls.begin(); pImpl != iImpls.end(); ++pImpl) |
539 for (CMLCompDataInstOptImpls::iterator pImpl = iImpls.begin(); pImpl != iImpls.end(); ++pImpl) |
539 delete *pImpl; |
540 delete *pImpl; |
540 for (pImpl = iTableImpls.begin(); pImpl != iTableImpls.end(); ++pImpl) |
541 for (CMLCompDataInstOptImpls::iterator pImpl = iTableImpls.begin(); pImpl != iTableImpls.end(); ++pImpl) |
541 delete *pImpl; |
542 delete *pImpl; |
542 } |
543 } |
543 |
544 |
544 void CMLCompDataInstOpt::Process(const string& aFirstInstName) |
545 void CMLCompDataInstOpt::Process(const string& aFirstInstName) |
545 { |
546 { |
548 for (TMLCompData::iterator pTab = iLayout->begin(); pTab != iLayout->end(); ++pTab) |
549 for (TMLCompData::iterator pTab = iLayout->begin(); pTab != iLayout->end(); ++pTab) |
549 { |
550 { |
550 ProcessLines(**pTab); |
551 ProcessLines(**pTab); |
551 } |
552 } |
552 |
553 |
553 for (pTab = iLayout->begin(); pTab != iLayout->end(); ++pTab) |
554 for (TMLCompData::iterator pTab = iLayout->begin(); pTab != iLayout->end(); ++pTab) |
554 { |
555 { |
555 ProcessTables(**pTab); |
556 ProcessTables(**pTab); |
556 } |
557 } |
557 |
558 |
558 // update the base offset to include all the data added, including reserving space for the tables |
559 // update the base offset to include all the data added, including reserving space for the tables |
559 UpdateBaseOffset(); |
560 UpdateBaseOffset(); |
560 |
561 |
561 // with the correct base offset, the definitions can be updated |
562 // with the correct base offset, the definitions can be updated |
562 UpdateLineImpls(); |
563 UpdateLineImpls(); |
563 |
564 |
564 for (pTab = iLayout->begin(); pTab != iLayout->end(); ++pTab) |
565 for (TMLCompData::iterator pTab = iLayout->begin(); pTab != iLayout->end(); ++pTab) |
565 { |
566 { |
566 // now that the rest of the data is stable, we can add the tables at the end |
567 // now that the rest of the data is stable, we can add the tables at the end |
567 UpdateTables(**pTab); |
568 UpdateTables(**pTab); |
568 } |
569 } |
569 |
570 |
707 void CMLCompDataInstOpt::UpdateLineImplDefn(CMLCompDataInstOptImpl& aImpl) |
708 void CMLCompDataInstOpt::UpdateLineImplDefn(CMLCompDataInstOptImpl& aImpl) |
708 { |
709 { |
709 if(!CheckByteCodeIndexInRange(aImpl.iByteCodeIndex)) |
710 if(!CheckByteCodeIndexInRange(aImpl.iByteCodeIndex)) |
710 throw GeneralErr(aImpl.iName + " in interface " + iInterface.FileName()); |
711 throw GeneralErr(aImpl.iName + " in interface " + iInterface.FileName()); |
711 // the base offset has been updated, so all definitions must be refreshed |
712 // the base offset has been updated, so all definitions must be refreshed |
712 int adjustedIndex = aImpl.iByteCodeIndex - iBaseOffset; |
713 //int adjustedIndex = aImpl.iByteCodeIndex - iBaseOffset; |
713 aImpl.iImpl->SetDefinition(DefinitionString(aImpl.iByteCodeIndex, aImpl.iName)); |
714 aImpl.iImpl->SetDefinition(DefinitionString(aImpl.iByteCodeIndex, aImpl.iName)); |
714 UpdateParamLimits(aImpl.iName); |
715 UpdateParamLimits(aImpl.iName); |
715 } |
716 } |
716 |
717 |
717 void CMLCompDataInstOpt::UpdateTables(TMLCompDataTable& aTable) |
718 void CMLCompDataInstOpt::UpdateTables(TMLCompDataTable& aTable) |
858 } |
859 } |
859 |
860 |
860 // calculate the number of values |
861 // calculate the number of values |
861 bool needsHeader = line.NeedsOptions() || line.NeedsCols() || line.NeedsRows(); |
862 bool needsHeader = line.NeedsOptions() || line.NeedsCols() || line.NeedsRows(); |
862 unsigned int nextCellFlag = 1; // bit flag for the next cell, note it can get bigger than a char |
863 unsigned int nextCellFlag = 1; // bit flag for the next cell, note it can get bigger than a char |
863 for (cell = 0; cell < aOutputOrder.size(); cell++) |
864 for (unsigned int cell = 0; cell < aOutputOrder.size(); cell++) |
864 { |
865 { |
865 string cellName = aOutputOrder[cell]; |
866 string cellName = aOutputOrder[cell]; |
866 TMLCompDataValues::TCompDataCellType type = TMLCompDataValues::Type(cellName); |
867 TMLCompDataValues::TCompDataCellType type = TMLCompDataValues::Type(cellName); |
867 if(!needsHeader && type == TMLCompDataValues::ECellTypeParamLimit) |
868 if(!needsHeader && type == TMLCompDataValues::ECellTypeParamLimit) |
868 { |
869 { |
908 // also build up the found valid values in case we can't optimize |
909 // also build up the found valid values in case we can't optimize |
909 vector<string> foundValues; |
910 vector<string> foundValues; |
910 |
911 |
911 bool optimizeVarieties = true; |
912 bool optimizeVarieties = true; |
912 bool optimizeCalcs = true; |
913 bool optimizeCalcs = true; |
913 int numCalcs = 0; |
914 unsigned int numCalcs = 0; |
914 int* largestParamLimitPtr = max_element(aParamLimitVarieties.begin(), aParamLimitVarieties.end()); |
915 int* largestParamLimitPtr = max_element(aParamLimitVarieties.begin(), aParamLimitVarieties.end()); |
915 int largestParamLimit = largestParamLimitPtr != aParamLimitVarieties.end() ? *largestParamLimitPtr : 0; |
916 unsigned int largestParamLimit = largestParamLimitPtr != aParamLimitVarieties.end() ? *largestParamLimitPtr : 0; |
916 |
917 |
917 // in the case of there being no calcs at all, we don't want to be optimizing, |
918 // in the case of there being no calcs at all, we don't want to be optimizing, |
918 // in order to avoid wasted flags. |
919 // in order to avoid wasted flags. |
919 if(largestParamLimit == 1) |
920 if(largestParamLimit == 1) |
920 optimizeCalcs = false; |
921 optimizeCalcs = false; |
930 if(!calcs->size()) |
931 if(!calcs->size()) |
931 calcs = &(zoomLevels[EAknUiZoomNormal]); |
932 calcs = &(zoomLevels[EAknUiZoomNormal]); |
932 numCalcs = calcs->size(); |
933 numCalcs = calcs->size(); |
933 string value; |
934 string value; |
934 vector<string> foundCalcs; |
935 vector<string> foundCalcs; |
935 int paramLimit = aParamLimitVarieties[varietyIndex]; |
936 unsigned int paramLimit = aParamLimitVarieties[varietyIndex]; |
936 if(numCalcs == 0) |
937 if(numCalcs == 0) |
937 { |
938 { |
938 if(varietyIndex == 0) |
939 if(varietyIndex == 0) |
939 optimizedValues.push_back(value); |
940 optimizedValues.push_back(value); |
940 if(varietyIndex > 0 && !(optimizedValues[0].empty())) |
941 if(varietyIndex > 0 && !(optimizedValues[0].empty())) |
941 optimizeVarieties = false; |
942 optimizeVarieties = false; |
942 foundCalcs.push_back(value); |
943 foundCalcs.push_back(value); |
943 } |
944 } |
944 else |
945 else |
945 { |
946 { |
946 for(int index = 0; index < numCalcs; index++) |
947 for(unsigned int index = 0; index < numCalcs; index++) |
947 { |
948 { |
948 bool needToCheckIndexValidity = !isColRow || (index < paramLimit); |
949 bool needToCheckIndexValidity = !isColRow || (index < paramLimit); |
949 value = (*calcs)[index]; |
950 value = (*calcs)[index]; |
950 value = aMirrorJustification ? TMLCompDataValues::MirrorJustificationValue(value) : value; |
951 value = aMirrorJustification ? TMLCompDataValues::MirrorJustificationValue(value) : value; |
951 |
952 |
992 { |
993 { |
993 // now that we know the optimized values, fill missing values by repeating the last one. |
994 // now that we know the optimized values, fill missing values by repeating the last one. |
994 // but if we're optimizing the calcs, then we don't want to expand them after all |
995 // but if we're optimizing the calcs, then we don't want to expand them after all |
995 if(!optimizeCalcs) |
996 if(!optimizeCalcs) |
996 { |
997 { |
997 int optimal = optimizedValues.size(); |
998 unsigned int optimal = optimizedValues.size(); |
998 string value = optimal > 0 ? optimizedValues[optimal-1] : string(); |
999 string value = optimal > 0 ? optimizedValues[optimal-1] : string(); |
999 for(; optimal < largestParamLimit; optimal++) |
1000 for(; optimal < largestParamLimit; optimal++) |
1000 { |
1001 { |
1001 optimizedValues.push_back(value); |
1002 optimizedValues.push_back(value); |
1002 } |
1003 } |
1193 SCompDataImplFunc& func = **pFunc; |
1194 SCompDataImplFunc& func = **pFunc; |
1194 if(func.IsSimilar(aType, aParams)) |
1195 if(func.IsSimilar(aType, aParams)) |
1195 return func; |
1196 return func; |
1196 } |
1197 } |
1197 |
1198 |
1198 int count = gTheFuncs.size(); |
1199 int count = gTheCompDataFuncs.size(); |
1199 for (int ii=0; ii<count; ii++) |
1200 for (int ii=0; ii<count; ii++) |
1200 { |
1201 { |
1201 SCompDataImplFunc* func = &gTheFuncs[ii]; |
1202 SCompDataImplFunc* func = &gTheCompDataFuncs[ii]; |
1202 if(func->IsSimilar(aType, aParams)) |
1203 if(func->IsSimilar(aType, aParams)) |
1203 { |
1204 { |
1204 iFuncs.push_back(func); |
1205 iFuncs.push_back(func); |
1205 return *func; |
1206 return *func; |
1206 } |
1207 } |
1207 } |
1208 } |
1208 |
1209 |
1209 throw NotFoundErr("implementation function"); |
1210 throw NotFoundErr("implementation function"); |
1210 return gTheFuncs[0]; |
1211 return gTheCompDataFuncs[0]; |
1211 } |
1212 } |
1212 |
1213 |
1213 void CMLCompDataInstOpt::SetGenericAPI(SCompDataImplFunc::TFuncType aType, const string& aName) |
1214 void CMLCompDataInstOpt::SetGenericAPI(SCompDataImplFunc::TFuncType aType, const string& aName) |
1214 { |
1215 { |
1215 CCdlTkImplementation* impl = iInstance->Impl().Find(aName); |
1216 CCdlTkImplementation* impl = iInstance->Impl().Find(aName); |
1409 int nParams; |
1410 int nParams; |
1410 CountApiParams(impl, nParams); |
1411 CountApiParams(impl, nParams); |
1411 nParams--; // don't count the aLineIndex param |
1412 nParams--; // don't count the aLineIndex param |
1412 SCompDataImplFunc::TFuncType type = SCompDataImplFunc::EWindowTable; |
1413 SCompDataImplFunc::TFuncType type = SCompDataImplFunc::EWindowTable; |
1413 TMLCompDataLine::TComponentType subTableType = aTable[aSub[0]]->iType; |
1414 TMLCompDataLine::TComponentType subTableType = aTable[aSub[0]]->iType; |
1414 switch(subTableType) |
1415 // switch(subTableType) |
1415 { |
1416 // { |
1416 case TMLCompDataLine::ETextComponent: |
1417 // case TMLCompDataLine::ETextComponent: |
1417 { |
1418 // { |
1418 type = SCompDataImplFunc::ETextTable; |
1419 // type = SCompDataImplFunc::ETextTable; |
1419 break; |
1420 // break; |
1420 } |
1421 // } |
|
1422 // } |
|
1423 if ( TMLCompDataLine::ETextComponent == subTableType ) |
|
1424 { |
|
1425 type = SCompDataImplFunc::ETextTable; |
1421 } |
1426 } |
1422 CCdlTkFunctionApi& api = const_cast<CCdlTkFunctionApi&>(impl.Api().AsFunc()); |
1427 CCdlTkFunctionApi& api = const_cast<CCdlTkFunctionApi&>(impl.Api().AsFunc()); |
1423 CCdlTkApiParams& params = api.Params(); |
1428 CCdlTkApiParams& params = api.Params(); |
1424 ValidateRequiredParams( |
1429 ValidateRequiredParams( |
1425 aApiName, |
1430 aApiName, |
1426 params, |
1431 params, |
1427 iAllParams || aSub.iNeedsOption, |
1432 iAllParams || aSub.iNeedsOption, |
1428 iAllParams || aSub.iNeedsCol, |
1433 iAllParams || aSub.iNeedsCol, |
1429 iAllParams || aSub.iNeedsRow); |
1434 iAllParams || aSub.iNeedsRow); |
1430 SCompDataImplFunc& func = AddImplFunc(type, params); |
1435 AddImplFunc(type, params); |
1431 } |
1436 } |
1432 |
1437 |
1433 void CMLCompDataInstOpt::AddParamLimits(TMLCompDataLine& aLine, bool aNeedsOptions) |
1438 void CMLCompDataInstOpt::AddParamLimits(TMLCompDataLine& aLine, bool aNeedsOptions) |
1434 { |
1439 { |
1435 string apiName = MLCompDataToCdl::LineApiName(aLine) ; |
1440 string apiName = MLCompDataToCdl::LineApiName(aLine) ; |
1517 extern const int gIdToIntTableCount; |
1522 extern const int gIdToIntTableCount; |
1518 extern void TranslateValue(string& aValue); |
1523 extern void TranslateValue(string& aValue); |
1519 |
1524 |
1520 void CMLCompDataInstOpt::EncodeValue(vector<char>& aBytes, string aValue) |
1525 void CMLCompDataInstOpt::EncodeValue(vector<char>& aBytes, string aValue) |
1521 { |
1526 { |
1522 int pos = 0; |
1527 string::size_type pos = 0; |
1523 TranslateValue(aValue); |
1528 TranslateValue(aValue); |
1524 if (aValue == "") |
1529 if (aValue == "") |
1525 { |
1530 { |
1526 aBytes.push_back(KByteEmpty); |
1531 aBytes.push_back(KByteEmpty); |
1527 } |
1532 } |
1621 throw MLCompDataCdlInstanceOptArgsErr(); |
1626 throw MLCompDataCdlInstanceOptArgsErr(); |
1622 |
1627 |
1623 // check that the distance between each separator is not a multiple of 2 |
1628 // check that the distance between each separator is not a multiple of 2 |
1624 // i.e. counting the steps between aSeparators ( sep -> xml -> inst -> sep) is 3 steps |
1629 // i.e. counting the steps between aSeparators ( sep -> xml -> inst -> sep) is 3 steps |
1625 // i.e. counting the steps between aSeparators ( sep -> xml -> inst -> xml -> inst -> sep) is 5 steps |
1630 // i.e. counting the steps between aSeparators ( sep -> xml -> inst -> xml -> inst -> sep) is 5 steps |
1626 for(int sep = 0; sep < aSeparators.size() - 1; sep++) |
1631 for(unsigned int sep = 0; sep < aSeparators.size() - 1; sep++) |
1627 { |
1632 { |
1628 int delta = aSeparators[sep+1] - aSeparators[sep]; |
1633 int delta = aSeparators[sep+1] - aSeparators[sep]; |
1629 if (delta%2 == 0) |
1634 if (delta%2 == 0) |
1630 throw MLCompDataCdlInstanceOptArgsErr(); |
1635 throw MLCompDataCdlInstanceOptArgsErr(); |
1631 } |
1636 } |
1657 for (int arg = aSeparators[aSepIndex] + 1; arg < aSeparators[aSepIndex+1]; arg += 2) |
1662 for (int arg = aSeparators[aSepIndex] + 1; arg < aSeparators[aSepIndex+1]; arg += 2) |
1658 { |
1663 { |
1659 string layoutName = aArgs[arg]; |
1664 string layoutName = aArgs[arg]; |
1660 string instName = aArgs[arg+1]; |
1665 string instName = aArgs[arg+1]; |
1661 string attribsName = CdlTkUtil::Replace(KCompDataFileNameSuffix, KAttributesFileNameSuffix, layoutName); |
1666 string attribsName = CdlTkUtil::Replace(KCompDataFileNameSuffix, KAttributesFileNameSuffix, layoutName); |
1662 |
|
1663 auto_ptr<TMLCompDataParseLayout> layoutParse = TMLCompDataParseLayout::Parse(layoutName); |
1667 auto_ptr<TMLCompDataParseLayout> layoutParse = TMLCompDataParseLayout::Parse(layoutName); |
1664 auto_ptr<TMLCompData> layout(layoutParse.get()); |
1668 auto_ptr<TMLCompData> layout(layoutParse.get()); |
1665 layoutParse.release(); |
1669 layoutParse.release(); |
1666 |
|
1667 auto_ptr<TMLAttributesParse> attribsParse = TMLAttributesParse::Parse(attribsName); |
1670 auto_ptr<TMLAttributesParse> attribsParse = TMLAttributesParse::Parse(attribsName); |
1668 auto_ptr<TMLAttributes> attribs(attribsParse.get()); |
1671 auto_ptr<TMLAttributes> attribs(attribsParse.get()); |
1669 attribsParse.release(); |
1672 attribsParse.release(); |
1670 |
1673 |
1671 InstStruct instStruct(instName, layout.get(), attribs.get()); |
1674 InstStruct instStruct(instName, layout.get(), attribs.get()); |
1680 // start with the non-mirrored instances |
1683 // start with the non-mirrored instances |
1681 for(int count = 0; count < 2; count++) |
1684 for(int count = 0; count < 2; count++) |
1682 { |
1685 { |
1683 bool isMirrored = (count != 0); |
1686 bool isMirrored = (count != 0); |
1684 // first iterate through the layouts, we will generate one instance per layout |
1687 // first iterate through the layouts, we will generate one instance per layout |
1685 for(int instIndex = 0; instIndex < aInstances.size(); instIndex++) |
1688 for(unsigned int instIndex = 0; instIndex < aInstances.size(); instIndex++) |
1686 { |
1689 { |
1687 const InstStruct& instStruct = aInstances[instIndex]; |
1690 const InstStruct& instStruct = aInstances[instIndex]; |
1688 string targetInstName = instStruct.iInstName; |
1691 string targetInstName = CdlTkUtil::Replace("\r","",instStruct.iInstName); |
|
1692 targetInstName = CdlTkUtil::Replace("\n","",targetInstName); |
1689 TMLCompData& targetLayout = *(instStruct.iInst); |
1693 TMLCompData& targetLayout = *(instStruct.iInst); |
1690 TMLAttributes& targetAttribs = *(instStruct.iAttribs); |
1694 TMLAttributes& targetAttribs = *(instStruct.iAttribs); |
1691 |
1695 |
1692 bool required = false; |
1696 bool required = false; |
1693 for(CZoomLevelNames::const_iterator pZoomLevel = aZoomLevelNames.begin(); pZoomLevel != aZoomLevelNames.end(); ++pZoomLevel) |
1697 for(CZoomLevelNames::const_iterator pZoomLevel = aZoomLevelNames.begin(); pZoomLevel != aZoomLevelNames.end(); ++pZoomLevel) |
1789 MLCompDataCdlInstanceOpt process(*iface); |
1793 MLCompDataCdlInstanceOpt process(*iface); |
1790 |
1794 |
1791 // the separators divide the layout instances that are aggregated together |
1795 // the separators divide the layout instances that are aggregated together |
1792 vector<int> separators; |
1796 vector<int> separators; |
1793 ProcessSeparators(args, separators); |
1797 ProcessSeparators(args, separators); |
1794 for(int sep = 0; sep < separators.size() - 1; sep++) |
1798 for(unsigned int sep = 0; sep < separators.size() - 1; sep++) |
1795 { |
1799 { |
1796 if(!CheckForUsedInstances(instUsedList, zoomLevelNames, args, separators, sep)) |
1800 if(!CheckForUsedInstances(instUsedList, zoomLevelNames, args, separators, sep)) |
1797 continue; |
1801 continue; |
1798 // start from after the next separator, and continue until before the next one |
1802 // start from after the next separator, and continue until before the next one |
1799 InstList instances; |
1803 InstList instances; |
1876 CCompDatas& compDatas = pZoomLevel->second; |
1879 CCompDatas& compDatas = pZoomLevel->second; |
1877 if(compDatas.size() == 0) |
1880 if(compDatas.size() == 0) |
1878 continue; |
1881 continue; |
1879 CMLCompDataInstOpt* firstInstOpt = compDatas[0]; |
1882 CMLCompDataInstOpt* firstInstOpt = compDatas[0]; |
1880 cout << "processing instances for zoom level: " << firstInstOpt->ZoomName() << endl; |
1883 cout << "processing instances for zoom level: " << firstInstOpt->ZoomName() << endl; |
1881 |
|
1882 string firstInstName = firstInstOpt->Name(); |
1884 string firstInstName = firstInstOpt->Name(); |
1883 for (CCompDatas::iterator pLayout = compDatas.begin(); pLayout != compDatas.end(); ++pLayout) |
1885 for (CCompDatas::iterator pLayout = compDatas.begin(); pLayout != compDatas.end(); ++pLayout) |
1884 (*pLayout)->Process(firstInstName); |
1886 (*pLayout)->Process(firstInstName); |
1885 } |
1887 } |
1886 ProcessCommonImpl(); |
1888 ProcessCommonImpl(); |
1887 } |
1889 } |
1888 |
1890 |
1889 void MLCompDataCdlInstanceOpt::WriteInstances() |
1891 void MLCompDataCdlInstanceOpt::WriteInstances() |
1890 { |
1892 { bool found = false; |
1891 bool found = false; |
|
1892 for(CCompDataZoomLevelDatas::iterator pZoomLevel = iZoomLevelDatas.begin(); pZoomLevel != iZoomLevelDatas.end(); ++pZoomLevel) |
1893 for(CCompDataZoomLevelDatas::iterator pZoomLevel = iZoomLevelDatas.begin(); pZoomLevel != iZoomLevelDatas.end(); ++pZoomLevel) |
1893 { |
1894 { |
1894 CCompDatas& compDatas = pZoomLevel->second; |
1895 CCompDatas& compDatas = pZoomLevel->second; |
1895 if(!found && compDatas.size() > 0) |
1896 if(!found && compDatas.size() > 0) |
1896 { |
1897 { |