⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctcommondoc.cpp

📁 eCos1.31版
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    prpNote.m_strNote = section->note.c_str ();    // show property sheet    if (prsSectionSheet.DoModal () == IDOK)  {    mem_anchor initial_anchor, final_anchor;    mem_address initial_address;    CString strInitialRelativeName = _T("");        if (prpGeneral.m_bFinalAbsolute) // final location is an absolute location      final_anchor = absolute;    else // final location is a relative location      final_anchor = relative;        if (prpRelocation.m_bRelocates) // if the section relocates    {      if (prpRelocation.m_bInitialAbsolute) // initial location is an absolute location      {        initial_anchor = absolute;      }      else // initial location is a relative location      {        strInitialRelativeName = prpRelocation.m_strInitialRelativeName;        initial_anchor = relative;      }      initial_address = prpRelocation.m_dwInitialAddress;    }    else    {      strInitialRelativeName = prpGeneral.m_strFinalRelativeName;      initial_anchor = final_anchor;      initial_address = prpGeneral.m_dwFinalAddress;    }            if (int nErrorCode = MemoryMap.edit_memory_section (CUtils::UnicodeToStdStr(strSelectedSection), CUtils::UnicodeToStdStr(prpGeneral.m_bNameLinkerDefined ? prpGeneral.m_strNameLinker : prpGeneral.m_strNameUser), prpGeneral.m_dwSectionSize, prpGeneral.m_dwAlignment, initial_anchor, CUtils::UnicodeToStdStr(strInitialRelativeName), initial_address, final_anchor, CUtils::UnicodeToStdStr(prpGeneral.m_strFinalRelativeName), prpGeneral.m_dwFinalAddress, prpRelocation.m_bRelocates, false, prpGeneral.m_bNameLinkerDefined, CUtils::UnicodeToStdStr(prpNote.m_strNote)))      ErrorBox (IDS_ERR_MEMMAP_SECTION_MODIFY, IDS_ERR_MEMMAP_BASE + nErrorCode);    else // no errors    {      SetModifiedFlag ();      UpdateAllViews (NULL, MemLayoutChanged);    }  }		}void CConfigToolDoc::OnMLTProperties() {  if (strSelectedRegion != _T(""))    ShowRegionProperties ();  else if (strSelectedSection != _T(""))    ShowSectionProperties ();}// Choose a default Hal.  Do this using clues the installer may have helpfully left behind (PR 18050)// or else if there is only one possible choice, by choosing that one :-)./*void CConfigToolDoc::ChooseDefaultHal(){bool bFound=false;// Has the installer told us?LPCTSTR pszRegPath=_T("SOFTWARE\\Red Hat\\eCos\\1.2.8");HKEY hKey;if(ERROR_SUCCESS==RegOpenKeyEx (HKEY_LOCAL_MACHINE, pszRegPath, 0L, KEY_READ, &hKey)){DWORD dwSizePath=MAX_PATH;CString str;PTCHAR psz=str.GetBuffer(dwSizePath);if(ERROR_SUCCESS==RegQueryValueEx(hKey, _T("Default Architecture"), NULL, NULL, (LPBYTE)psz, &dwSizePath)){str.MakeLower();for(int nItem=0;nItem<ItemCount();nItem++){CConfigItem *pItem=Item(nItem);if(pItem->m_pTarget){CString strTarget(pItem->m_pTarget->Name());strTarget.MakeLower();if(-1!=str.Find(strTarget)){bFound=true;dwSizePath=MAX_PATH;if(ERROR_SUCCESS==::RegQueryValueEx(hKey, _T("Default Build Tools Path"), NULL, NULL, (LPBYTE)psz, &dwSizePath)){pItem->m_pTarget->SetBinDir(psz);for(CConfigItem *pSib=pItem->FirstRadio();pSib;pSib=pSib->NextRadio()){pSib->SetValue((ItemIntegerType) (pSib==pItem));}//                            pItem->EnableAncestors();}break;}}}}RegCloseKey(hKey);}  if(!bFound){  // No - choose the Hal according to toolchain  for(int nItem=0;nItem<ItemCount();nItem++){  CConfigItem *pItem=Item(nItem);  if(pItem->m_pTarget){  CString strTarget(pItem->m_pTarget->Name());  strTarget.MakeLower();  for(int j=0;j<m_arstrToolChainPaths.GetSize();j++){  CString strTools(m_arstrToolChainPaths[j]);  strTools.MakeLower();  if(-1!=strTools.Find(strTarget)){  for(CConfigItem *pSib=pItem->FirstRadio();pSib;pSib=pSib->NextRadio()){  pSib->SetValue((ItemIntegerType) (pSib==pItem));  }  return;  }  }  }  }  }  }*/bool CConfigToolDoc::SetValue (CConfigItem &ti, double dValue, CdlTransaction transaction/*=NULL*/){  ASSERT (ti.Type () == CConfigItem::Double);    // test if the new double value is in range  const CdlValuable valuable = ti.GetCdlValuable();  CdlListValue list_value;  CdlEvalContext context (NULL, ti.GetCdlItem (), ti.GetCdlItem ()->get_property (CdlPropertyId_LegalValues));  valuable->get_legal_values ()->eval (context, list_value);  if (! list_value.is_member (dValue))  {    if (dValue==valuable->get_double_value(CdlValueSource_Current) || IDNO == CUtils::MessageBoxFT (MB_YESNO, _T("%s is not a legal value for %s.\n\nDo you want to use this value anyway?"),      CUtils::DoubleToStr (dValue), ti.Macro ()))      return false;  }    if (! ti.SetValue (dValue,transaction))    return false;    SetModifiedFlag ();  return true;}bool CConfigToolDoc::SetValue(CConfigItem &ti,const CString &strValue, CdlTransaction transaction/*=NULL*/){  // warn the user if a modified memory layout is about to be discarded  if (MemoryMap.map_modified () && (ti.Macro () == _T("CYG_HAL_STARTUP")) &&    (IDCANCEL == CUtils::MessageBoxFT (MB_OKCANCEL, _T("Changes to the current memory layout will be lost."))))    return false;    bool rc=false;  switch(ti.Type()){		case CConfigItem::None:      break;    case CConfigItem::Enum:    case CConfigItem::String:      rc=ti.SetValue(strValue,transaction);      break;    case CConfigItem::Integer:      {        ItemIntegerType n;        rc=CUtils::StrToItemIntegerType(strValue,n) && SetValue(ti,n,transaction);      }      break;    case CConfigItem::Double:      {        double dValue;        rc = CUtils::StrToDouble (strValue, dValue) && SetValue (ti, dValue,transaction);      }      break;    default:      ASSERT(FALSE);      break;        }  if(rc){    SetModifiedFlag();    UpdateAllViews (NULL, CConfigToolDoc::ValueChanged, (CObject *)&ti);  }  return rc;}// Look in registry to match prefixes CYGPKG_HAL_ and CYGHWR_HAL_://bool CConfigToolDoc::GetRunPlatform(CString &strTarget){  CRegKeyEx k1(HKEY_CURRENT_USER,_T("Software\\Red Hat\\eCos\\Platforms"), KEY_READ);  CString strKey;  for(int i=0;k1.QueryKey(i,strKey);i++){    CRegKeyEx k2((HKEY)k1,strKey,KEY_READ);    // Subkeys' names are the target image names [one of which we aim to return]    // Subkeys's values of interest are:    //      Prefix  String    //      Sim     DWORD  [optional]    //      Macro   String     DWORD dwSim=0;    CString strPrefix,strMacro;    k2.QueryValue(_T("Sim"),dwSim);    k2.QueryValue(_T("Prefix"),strPrefix);    k2.QueryValue(_T("Macro"),strMacro);    CConfigItem *pItem=Find(_T("CYGPKG_HAL_")+strMacro);    if(pItem && pItem->IsEnabled()){      // We have found what we are looking for - probably      pItem=Find(_T("CYGHWR_HAL_")+strMacro+_T("_STARTUP"));      if(pItem){        // Two platforms apply - choose this one only if the ram startup attribute fits        if( (dwSim==0) == (0==pItem->StringValue().CompareNoCase(_T("ram"))) ) {          strTarget=strKey;        }      } else {        // Only one platform applies        strTarget=strKey;      }          }  }  return !strTarget.IsEmpty();}bool CConfigToolDoc::SetEnabled(CConfigItem &ti, bool bEnabled, CdlTransaction transaction/*=NULL*/){  const bool bStatus = ti.SetEnabled (bEnabled,transaction);    if (bStatus) {    SetModifiedFlag();    UpdateAllViews (NULL, CConfigToolDoc::ValueChanged, (CObject *) &ti);  }  return bStatus;}void CConfigToolDoc::AddContents (const CdlContainer container, CConfigItem *pParent){    // determine the container contents    const std::vector<CdlNode>& contents = container->get_contents ();  std::vector<CdlNode>::const_iterator node_i;  for (node_i = contents.begin (); node_i != contents.end (); node_i++)  {    const CdlNode node = * node_i;    const CdlPackage pkg = dynamic_cast<CdlPackage> (node);    const CdlComponent comp = dynamic_cast<CdlComponent> (node);    const CdlOption opt = dynamic_cast<CdlOption> (node);    const CdlContainer contnr = dynamic_cast<CdlContainer> (node);        // if the node in the container is a package, component or option    // then it is visible and should be added to the tree    if  (0 != pkg) // the node is a package    {      CConfigItem * pItem = AddItem (pkg, pParent); // add the package      AddContents (pkg, pItem); // add the package contents    }    else if (0 != comp) // the node is a component    {      CConfigItem * pItem = AddItem (comp, pParent); // add the component      AddContents (comp, pItem); // add the component contents    }    else if (0 != opt) // the node is an option      AddItem (opt, pParent); // add the option        else if (0 != contnr) // if the node is a container      AddContents (contnr, pParent); // add the container contents        // ignore nodes of any other class  }}// Three hack functions.const CString CConfigToolDoc::CurrentPlatform(){/*for(int nItem=0;nItem<ItemCount();nItem++){CConfigItem *pItem=Item(nItem);if(pItem->IsEnabled() && !pItem->Platform().IsEmpty()){return pItem->Platform();}}  */  return _T("");}// a trivial CDL parse error handlervoid CConfigToolDoc::CdlParseErrorHandler (std::string message){  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();  pDoc->m_strCdlErrorMessage = message.c_str ();  TRACE (_T("CdlParseError: %s\n"), pDoc->m_strCdlErrorMessage);  CConfigTool::Log (CUtils::StripExtraWhitespace (pDoc->m_strCdlErrorMessage)); // display the message in the output window};// a trivial CDL parse warning handlervoid CConfigToolDoc::CdlParseWarningHandler (std::string message){  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();  pDoc->m_strCdlErrorMessage = message.c_str ();  TRACE (_T("CdlParseWarning: %s\n"), pDoc->m_strCdlErrorMessage);  CConfigTool::Log (CUtils::StripExtraWhitespace (pDoc->m_strCdlErrorMessage)); // display the message in the output window};// a trivial CDL load error handlervoid CConfigToolDoc::CdlLoadErrorHandler (std::string message){  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();  pDoc->m_strCdlErrorMessage = message.c_str ();  TRACE (_T("CdlLoadError: %s\n"), pDoc->m_strCdlErrorMessage);  CConfigTool::Log (CUtils::StripExtraWhitespace (pDoc->m_strCdlErrorMessage)); // display the message in the output window};// a trivial CDL load warning handlervoid CConfigToolDoc::CdlLoadWarningHandler (std::string message){  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();  pDoc->m_strCdlErrorMessage = message.c_str ();  TRACE (_T("CdlLoadWarning: %s\n"), pDoc->m_strCdlErrorMessage);  CConfigTool::Log (CUtils::StripExtraWhitespace (pDoc->m_strCdlErrorMessage)); // display the message in the output window};CdlInferenceCallbackResult CConfigToolDoc::CdlGlobalInferenceHandler(CdlTransaction transaction){  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();  pDoc->m_ConflictsOutcome=NotDone;  // prepare for the case that there are no solutions  CdlInferenceCallbackResult rc=CdlInferenceCallbackResult_Continue;  /*  std::list<CdlConflict>conflicts1(transaction->get_global_conflicts_with_solutions());  const std::vector<CdlConflict>&conflicts2=transaction->get_resolved_conflicts();	for (unsigned int i = 0; i < conflicts2.size (); i++) {		conflicts1.push_back(conflicts2 [i]);	}  if(conflicts1.size()>0){    CFailingRulesDialog dlg(conflicts1,transaction,&pDoc->m_arConflictsOfInterest);    rc=(IDOK==dlg.DoModal())?CdlInferenceCallbackResult_Continue:CdlInferenceCallbackResult_Cancel;    pDoc->m_ConflictsOutcome=(CdlInferenceCallbackResult_Continue==rc)?OK:Cancel;  }  */  const std::list<CdlConflict>& conflicts=pDoc->GetCdlConfig()->get_all_conflicts();    CFailingRulesDialog dlg(conflicts,transaction,&pDoc->m_arConflictsOfInterest);  rc=(IDOK==dlg.DoModal())?CdlInferenceCallbackResult_Continue:CdlInferenceCallbackResult_Cancel;  pDoc->m_ConflictsOutcome=(CdlInferenceCallbackResult_Continue==rc)?OK:Cancel;  return rc;}CdlInferenceCallbackResult CConfigToolDoc::CdlInferenceHandler (CdlTransaction transaction){  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();  CdlInferenceCallbackResult rc=CdlInferenceCallbackResult_Continue;  const std::list<CdlConflict>&conflicts=transaction->get_new_conflicts();  if((pDoc->m_nRuleChecking&Immediate) && conflicts.size()>0){    if(pDoc->m_nRuleChecking&SuggestFixes){      std::list<CdlConflict> s_conflicts;      for (std::list<CdlConflict>::const_iterator conf_i= conflicts.begin (); conf_i != conflicts.end (); conf_i++) { // for each conflict        if((*conf_i)->has_known_solution()){          s_conflicts.push_back(*conf_i);        }      }      if(s_conflicts.size()>0){        CFailingRulesDialog dlg(s_conflicts,transaction);        return(IDOK==dlg.DoModal()?CdlInferenceCallbackResult_Continue:CdlInferenceCallbackResult_Cancel);      }    }     CString strMsg;    if(1==conflicts.size()){      strMsg=(_T("There is 1 unresolved conflict."));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -