void tScriptState::SetVariable(LPCSTR s, ULONG value)
{
    Variables.SetAt(s, value);

    if (!strcmp(s, "use_indirect"))
        bUseIndirectTx = !!value;
}
Ejemplo n.º 2
0
/*
// The constructor for a graphic record.
*/
ComponentRecord::ComponentRecord( DB_RECORD_NUMBER number, DB_RECORD_TYPE type, DatabasePtr owner, ST_DEV_POSITION far *where )
	: DatabaseRecord( number, type, owner, where )
	, m_pComponentDoc( NULL )
	, m_pInternalData( NULL )
	, m_pLinkedData( NULL )
{
	memset( &record, 0, sizeof(record) );

	if (_GraphicTypeMap.IsEmpty())
	{
		// Initialize graphic type map
		_GraphicTypeMap.SetAt( GRAPHIC_TYPE_CGM,			RGraphicInterface::kCGM );
		_GraphicTypeMap.SetAt( GRAPHIC_TYPE_PS_SQUARE,	RGraphicInterface::kSquare );
		_GraphicTypeMap.SetAt( GRAPHIC_TYPE_PS_ROW,		RGraphicInterface::kRow );
		_GraphicTypeMap.SetAt( GRAPHIC_TYPE_PS_COLUMN,	RGraphicInterface::kColumn );
	}
}
Ejemplo n.º 3
0
void COXAutoComplete::Detach(HWND hWnd)
{
	if (hWnd)
	{
		COXAutoStorage* pStorage;
		if (m_mpStorage.Lookup(hWnd,pStorage))
		{
			m_mpStorage.RemoveKey(hWnd);
			m_mpOptions.RemoveKey(hWnd);
		}
		else
			return;
		//try to find out who else is using this storage,
		//if no one is using, delete it
		COXAutoStorage* pTest=NULL;
		POSITION pos=m_mpStorage.GetStartPosition();

		while (pos)
		{
			HWND hwnd;
			m_mpStorage.GetNextAssoc(pos,hwnd,pTest);
			if (pTest==pStorage)
				return;
		}
		delete pStorage;
		return;
	}

	//detach all storages
	POSITION pos=m_mpStorage.GetStartPosition();
	
	//cannot delete directly because the same storage can be mapped 
	//to different windows
	CMap<COXAutoStorage*,COXAutoStorage*,DWORD,DWORD> mpToDelete;

	while (pos)
	{
		HWND hwnd;
		COXAutoStorage* pStorage=NULL;
		m_mpStorage.GetNextAssoc(pos,hwnd,pStorage);
		mpToDelete.SetAt(pStorage,NULL);	
	}

	//delete all objects
	pos=mpToDelete.GetStartPosition();
	while (pos)
	{
		COXAutoStorage* pStorage;
		DWORD dwNULL;
		mpToDelete.GetNextAssoc(pos,pStorage,dwNULL);
		delete pStorage;

	}

	mpToDelete.RemoveAll();
	m_mpStorage.RemoveAll();
	m_mpOptions.RemoveAll();
}
Ejemplo n.º 4
0
// Create the tray items for the passed document.
void CreateDocumentWorkspace(AcApDocument* pDoc)
{
	// Create the tray items:
	CTrayItem *pTray=new CTrayItem;
	// Create World Tray Item:
	HICON hIcon = (HICON)::LoadImage(_hdllInstance, MAKEINTRESOURCE(IDI_WORLD), IMAGE_ICON, 16, 16, 0);
    int result=pTray->SetIcon(hIcon);
    result=pTray->SetToolTipText(_T("World Icon ToolTip"));
    pTray->Enable(TRUE);
    pTray->SetVisible(TRUE);
	result=pDoc->drawingStatusBar()->Add(pTray);

	// Set this document to map to the first tray item.
	documentTrayMap.SetAt(pDoc,pTray);

    // Create Pie Tray Item:
	pTray=new CTrayItem;
	hIcon = (HICON)::LoadImage(_hdllInstance, MAKEINTRESOURCE(IDI_PIE), IMAGE_ICON, 16, 16, 0);
    result=pTray->SetIcon(hIcon);
    result=pTray->SetToolTipText(_T("Pie Icon ToolTip"));
    pTray->Enable(TRUE);
    pTray->SetVisible(TRUE);
	result=pDoc->drawingStatusBar()->Add(pTray);

    // Create Tree Tray Item:
	pTray=new CTrayItem;
	hIcon = (HICON)::LoadImage(_hdllInstance, MAKEINTRESOURCE(IDI_TREE), IMAGE_ICON, 16, 16, 0);
    result=pTray->SetIcon(hIcon);
    result=pTray->SetToolTipText(_T("Tree Icon ToolTip"));
    pTray->Enable(TRUE);
    pTray->SetVisible(TRUE);
	result=pDoc->drawingStatusBar()->Add(pTray);

	// Create a Pane Item with Text...
	CPaneItem *pPane=new CPaneItem;
	result=pPane->SetToolTipText(_T("Pane Item Tooltip"));
	pPane->Enable(TRUE);
	pPane->SetVisible(TRUE);
	result=pPane->SetStyle(ACSB_POPOUT);
	result=pPane->SetText(_T("Pane Item"));
	result=pPane->SetMinWidth(pDoc->drawingStatusBar()->GetTextWidth(_T("Pane Item")));
	result=pDoc->drawingStatusBar()->Add(pPane);
    
	// Create a Pane Item with an Icon...
	pPane=new CPaneItem;
	result=pPane->SetToolTipText(_T("Pane Icon Item Tooltip"));
	pPane->Enable(TRUE);
	result=pPane->SetStyle(ACSB_POPOUT);
	pPane->SetVisible(TRUE);
	hIcon = (HICON)::LoadImage(_hdllInstance, MAKEINTRESOURCE(IDI_WORLD), IMAGE_ICON, 16, 16, 0);
    result=pPane->SetIcon(hIcon);
	result=pDoc->drawingStatusBar()->Add(pPane);
	
	// Create a status bar menu item...this replaces the default menu item (the small black triangle on the lower right of the doc window).
	CMenuPaneItem *pMenuPane=new CMenuPaneItem;
	result=pDoc->drawingStatusBar()->SetStatusBarMenuItem(pMenuPane);
}
void KeepRxPacket(void *buffer, ULONG serial)
{
    void *p;
    if (QueueOfRxPackets.Lookup(serial, p))
    {
        FailCase("[%s] - packet %d already exists!", __FUNCTION__, serial);
        QueueOfRxPackets.RemoveKey(serial);
    }
    QueueOfRxPackets.SetAt(serial, buffer);
}
Ejemplo n.º 6
0
/******************************************************************************
 Function Name  :   vMapCopy

 Input(s)       :   omDestMap - Destination Map object.
                    omSrcMap - Map object which should be copied.
 Output         :   -
 Functionality  :   Copies a CMap object.
 Member of      :   CMessageAttrib

 Author(s)      :   Ratnadip Choudhury
 Date Created   :   03-05-2002
******************************************************************************/
void CMessageAttrib::vMapCopy(CMap <UINT, UINT, SMsgIDAttr, SMsgIDAttr>&
                              omDestMap,
                              CMap <UINT, UINT, SMsgIDAttr, SMsgIDAttr>& omSrcMap)
{
    UINT unMsgID;
    omDestMap.RemoveAll();
    POSITION psCurrPos = omSrcMap.GetStartPosition();

    while (psCurrPos != NULL)
    {
        omSrcMap.GetNextAssoc(psCurrPos, unMsgID, m_sIDAttrTmp);
        omDestMap.SetAt(unMsgID, m_sIDAttrTmp);
    }
}
Ejemplo n.º 7
0
void CKnownFileList::CopyKnownFileMap(CMap<CCKey,const CCKey&,CKnownFile*,CKnownFile*> &Files_Map)
{
	if (!m_Files_map.IsEmpty())
	{
		POSITION pos = m_Files_map.GetStartPosition();
		while (pos)
		{
			CCKey key;
			CKnownFile* cur_file;
			m_Files_map.GetNextAssoc(pos, key, cur_file);
			Files_Map.SetAt(key, cur_file);
		}
	}
}
// 把选中区域转换为绝对排列字符串
CString CGraphInstrumentList::ConvertSelectAreaToAbsoluteSpreadString(CRect* pSelectAreaIndex)
{
	CString strAbsoluteSpread = "";
	CString strLine, strPoint;
	int iPointNb, iPointNbStart, iPointNbEnd;
	int iLineNb;
	CMap<int, int, CString, CString> oLineNbMap;

	for(int i = pSelectAreaIndex->top; i <= pSelectAreaIndex->bottom; i++)
	{
		// 得到图形区列索引对应的测线号
		iLineNb = GetLineNbByRowIndex(i);
		if(iLineNb > 0)	// 测线有效
		{
			iPointNbStart = GetPointNbByColumnIndex(pSelectAreaIndex->left);	// 得到起始测点
			iPointNbEnd = GetPointNbByColumnIndex(pSelectAreaIndex->right);	// 得到终止测点
			if((iPointNbStart > 0) && (iPointNbEnd > 0))	// 测点有效
			{
				if(iPointNbStart > iPointNbEnd)
				{
					iPointNb = iPointNbStart;
					iPointNbStart = iPointNbEnd;
					iPointNbEnd = iPointNb;
				}
				strPoint.Format("%d-%d", iPointNbStart, iPointNbEnd);	// 测点字符串
				strLine.Format("%d:%s;", iLineNb, strPoint);	// 测线字符串
				oLineNbMap.SetAt(iLineNb, strLine);	// 加入索引表
			}
		}
	}
	POSITION pos = oLineNbMap.GetStartPosition();
	while(NULL != pos)
	{
		oLineNbMap.GetNextAssoc(pos, iLineNb, strLine);
		strAbsoluteSpread = strAbsoluteSpread + strLine;	// 链接测线字符串
	}
	if(strAbsoluteSpread.GetLength() > 0)
	{
		strAbsoluteSpread = strAbsoluteSpread.Left(strAbsoluteSpread.GetLength() - 1);	// 去掉最后一个字符“;”
	}
	oLineNbMap.RemoveAll();
	return strAbsoluteSpread;
}
Ejemplo n.º 9
0
void CSizeableDlg::OnSizeControl(CWnd &stWnd, int cx, int cy, UINT nLocks)
{
	static CMap <CWnd*, CWnd*, WND_SIZE_DATA, WND_SIZE_DATA&> mapWnds;

	if (!IsWindow(stWnd))
		return;

	// check if this window was already measured by us
	WND_SIZE_DATA stSD;
	if (mapWnds.Lookup(&stWnd, stSD))
	{
		CRect stRect = stSD.stFirst;

		if (nLocks & 2)
		{
			stRect.right += cx - stSD.cx_now;
			if (nLocks & 1)
				stRect.left += cx - stSD.cx_now;
		}

		if (nLocks & 8)
		{
			stRect.bottom += cy - stSD.cy_now;
			if (nLocks & 4)
				stRect.top += cy - stSD.cy_now;
		}

		stWnd.MoveWindow(&stRect);
	} else
	{
		// this is a new window
		WND_SIZE_DATA stSD;
		stSD.cx_now = cx;
		stSD.cy_now = cy;

		stWnd.GetWindowRect(&stSD.stFirst);
		ScreenToClient(&stSD.stFirst);

		mapWnds.SetAt(&stWnd, stSD);
	}
}
Ejemplo n.º 10
0
void CDlgSpeedTest::Sort()
{
	CMap<DWORD,DWORD,SpeedTestResult,SpeedTestResult> mapTmp;
	CArray<SpeedTestResult,SpeedTestResult> ayTmp;
	for (int i=0; i<m_ayTestResult.GetCount(); i++)
	{
		SpeedTestResult res = m_ayTestResult.GetAt(i);
		if (!res.m_bError)
		{
			mapTmp.SetAt(res.m_result,res);
		}
		else
			ayTmp.Add(res);
	}
	m_ayTestResult.RemoveAll();
	POSITION pos = mapTmp.GetStartPosition();
	DWORD key;
	SpeedTestResult val;
	while (pos)
	{
		mapTmp.GetNextAssoc(pos,key,val);
		m_ayTestResult.Add(val);
	}
	for (int j=0; j<ayTmp.GetCount(); j++)
	{
		m_ayTestResult.Add(ayTmp.GetAt(j));
	}

	for(int i=0; i<m_cList.GetItemCount(); i++)
	{
		CString str;
		str = m_cList.GetItemText(i,0);
		if (FindRes(str))
		{
			m_cList.DeleteItem(i);
			i--;
		}
	}
	ShowRes();
}
Ejemplo n.º 11
0
int CGrfDoc::DeleteTags(bool WithPrompts)
  {
  Strng_List MyTags;
  GetTagList(MyTags);
  int nTags=MyTags.Length();
  int nTagsMultPgs=0;
  if (nTags>0)
    {
    CMap<LPTSTR, LPTSTR, Strng*, Strng*> MyTagMap;
    MyTagMap.InitHashTable(FindNextPrimeNumber(MyTags.Length()));
    for (Strng *pTag=MyTags.First(); pTag; pTag=MyTags.Next())
      {
      pTag->SetIndex(0);
      MyTagMap.SetAt(pTag->Str(), pTag);
      }

    for (int iTmpl=iGraphTemplate; iTmpl<=iVisioTemplate; iTmpl++)
      {
      if (ScdApp()->TemplateExists(iTmpl))
        {
        POSITION Pos = ScdApp()->Template(iTmpl).GetFirstDocPosition();
        while (Pos)
          {
          CGrfDoc* pOtherDoc = (CGrfDoc*)(ScdApp()->Template(iTmpl).GetNextDoc(Pos));
          if (pOtherDoc!=this)
            {
            Strng *pTag;
            Strng_List OtherTags;
            int NGrfTags = pOtherDoc->GetTagList(OtherTags);
            for (Strng *pOtherTag=OtherTags.First(); pOtherTag; pOtherTag=OtherTags.Next())
              if (MyTagMap.Lookup(pOtherTag->Str(), pTag))
                pTag->SetIndex(pTag->Index()+1);
            }
          }
        }
      }

    for (Strng *pTag=MyTags.First(); pTag; pTag=MyTags.Next())
      {
      if (pTag->Index()>0)
        nTagsMultPgs++;
      }

    int Ret=IDYES;
    if (WithPrompts)
      {
      CString S;
      if (nTagsMultPgs)
        S.Format("Do you want Delete %i Units (%i Units have Multiple References)", nTags-nTagsMultPgs, nTagsMultPgs);
      else
        S.Format("Do you want Delete %i Units", nTags);
      Ret=AfxMessageBox(S, MB_ICONQUESTION|MB_YESNOCANCEL);
      }
    if (Ret==IDCANCEL)
      return -1;
    if (Ret==IDYES)
      {
      Strng_List DelTags;
      int nMdlDeletes=0;
      int nDeletesFailedCnt=0;
      for (Strng *pTag=MyTags.First(); pTag; pTag=MyTags.Next())
        {
        if (pTag->Index()==0)
          {
          DelTags.Append(pTag->Str());
          }
        }

      int RetCode = gs_Exec.DeleteTags(DelTags);
      for (Strng *pTag=DelTags.First(); pTag; pTag=MyTags.Next())
        {
        if (pTag->Index()!=EODT_DONE)
          {
          //dbgpln("Mdl Not Deleted %s", pTag->Str());
          LogError(pTag->Str(), 0, "Model not deleted");
          nDeletesFailedCnt++;
          }
        else
          {
          //dbgpln("Mdl     Deleted %s", pTag->Str());
          nMdlDeletes++;
          }
        }
      if (nDeletesFailedCnt)
        {
        CString S;
        S.Format("%i Units Failed to Delete", nDeletesFailedCnt);
        AfxMessageBox(S, MB_ICONEXCLAMATION|MB_OK);
        }
      }
    }
  return nTags;
  };
Ejemplo n.º 12
0
void CXTPMarkupInputElement::FireTriggers(CXTPMarkupDependencyProperty* pProperty, CXTPMarkupObject* pNewValue)
{
	BOOL bChanged = FALSE;
	int i;

	CMap<CXTPMarkupDependencyProperty*, CXTPMarkupDependencyProperty*, CXTPMarkupObject*, CXTPMarkupObject*> mapOldValues;

	if (m_pActiveTriggers)
	{
		for (i = m_pActiveTriggers->GetCount() - 1; i >= 0; i--)
		{
			CXTPMarkupTrigger* pTrigger = m_pActiveTriggers->GetItem(i);

			if (pTrigger->GetTriggerProperty() == pProperty)
			{
				if (!pTrigger->GetTriggerValue()->IsEqual(pNewValue))
				{
					CXTPMarkupSetterColection* pSetters = pTrigger->GetSetters();

					for (int j = 0; j < pSetters->GetCount(); j++)
					{
						CXTPMarkupSetter* pSetter = pSetters->GetItem(j);
						CXTPMarkupDependencyProperty* pSetterProperty = pSetter->GetSetterProperty();

						CXTPMarkupObject* pOldValue = m_pTriggerProperties->Lookup(pSetterProperty);

						CXTPMarkupObject* pTempValue;
						if (!mapOldValues.Lookup(pSetterProperty, pTempValue))
						{
							MARKUP_ADDREF(pOldValue);
							mapOldValues.SetAt(pSetterProperty, pOldValue);
						}

						m_pTriggerProperties->Set(pSetterProperty, NULL);
					}

					m_pActiveTriggers->Remove(i);
					bChanged = TRUE;
				}
			}
		}
	}

	if (m_pStyleCache)
	{
		bChanged = AddStyleTriggers(m_pStyleCache, pProperty, pNewValue) || bChanged;
	}
	else if (GetType()->GetTypeStyle())
	{
		bChanged = AddStyleTriggers(GetType()->GetTypeStyle(), pProperty, pNewValue) || bChanged;
	}


	if (bChanged)
	{
		if (!m_pTriggerProperties)
			m_pTriggerProperties = new CXTPMarkupProperties(NULL);

		for (i = 0; i < m_pActiveTriggers->GetCount(); i++)
		{
			CXTPMarkupTrigger* pTrigger = m_pActiveTriggers->GetItem(i);

			CXTPMarkupSetterColection* pSetters = pTrigger->GetSetters();

			for (int j = 0; j < pSetters->GetCount(); j++)
			{
				CXTPMarkupSetter* pSetter = pSetters->GetItem(j);

				CXTPMarkupObject* pValue = pSetter->GetSetterValue();

				CXTPMarkupDependencyProperty* pSetterProperty = pSetter->GetSetterProperty();

				CXTPMarkupObject* pOldValue = m_pTriggerProperties->Lookup(pSetterProperty);

				if (!pValue->IsEqual(pOldValue))
				{
					CXTPMarkupObject* pTempValue;
					if (!mapOldValues.Lookup(pSetterProperty, pTempValue))
					{
						MARKUP_ADDREF(pOldValue);
						mapOldValues.SetAt(pSetterProperty, pOldValue);
					}

					pValue->AddRef();
					m_pTriggerProperties->Set(pSetterProperty, pValue);
				}
			}
		}
	}

	POSITION pos = mapOldValues.GetStartPosition();
	while (pos)
	{
		CXTPMarkupDependencyProperty* pProperty;
		CXTPMarkupObject* pOldValue;
		mapOldValues.GetNextAssoc(pos, pProperty, pOldValue);

		CXTPMarkupObject* pNewValue = m_pTriggerProperties->Lookup(pProperty);

		if (!::IsEqual(pNewValue, pOldValue))
		{
			OnPropertyChanged(pProperty, pOldValue, pNewValue);

			if (pProperty->GetFlags() & CXTPMarkupPropertyMetadata::flagInherited)
			{
				RecursePropertyChanged(pProperty, pOldValue, pNewValue);
			}
		}

		MARKUP_RELEASE(pOldValue);
	}
}
Ejemplo n.º 13
0
void CCorruptionBlackBox::VerifiedData(uint32 nStartPos, uint32 nEndPos){
	if (nEndPos - nStartPos >= PARTSIZE){
		ASSERT( false );
		return;
	}
	// convert pos to relative block pos
	uint16 nPart = nStartPos / PARTSIZE;
	uint32 nRelStartPos = nStartPos - nPart*PARTSIZE;
	uint32 nRelEndPos = nEndPos - nPart*PARTSIZE;
	if (nRelEndPos >= PARTSIZE){
		ASSERT( false );
		return;
	}
	if (nPart >= m_aaRecords.GetCount()){
		//ASSERT( false );
		m_aaRecords.SetSize(nPart+1);
	}
	uint32 nDbgVerifiedBytes = 0;
	//uint32 nDbgOldEntries = m_aaRecords[nPart].GetCount();
#ifdef _DEBUG
	CMap<int, int, int, int> mapDebug;
#endif
	for (int i= 0; i < m_aaRecords[nPart].GetCount(); i++){
		if (m_aaRecords[nPart][i].m_BBRStatus == BBR_NONE || m_aaRecords[nPart][i].m_BBRStatus == BBR_VERIFIED){
			if (m_aaRecords[nPart][i].m_nStartPos >= nRelStartPos && m_aaRecords[nPart][i].m_nEndPos <= nRelEndPos){
				nDbgVerifiedBytes +=  (m_aaRecords[nPart][i].m_nEndPos-m_aaRecords[nPart][i].m_nStartPos)+1;
				m_aaRecords[nPart][i].m_BBRStatus = BBR_VERIFIED;
				DEBUG_ONLY(mapDebug.SetAt(m_aaRecords[nPart][i].m_dwIP, 1));
			}
			else if (m_aaRecords[nPart][i].m_nStartPos < nRelStartPos && m_aaRecords[nPart][i].m_nEndPos > nRelEndPos){
			    // need to split it 2*
				uint32 nTmpEndPos1 = m_aaRecords[nPart][i].m_nEndPos;
				uint32 nTmpStartPos1 = nRelEndPos + 1;
				uint32 nTmpStartPos2 = m_aaRecords[nPart][i].m_nStartPos;
				uint32 nTmpEndPos2 = nRelStartPos - 1;
				m_aaRecords[nPart][i].m_nEndPos = nRelEndPos;
				m_aaRecords[nPart][i].m_nStartPos = nRelStartPos;
				m_aaRecords[nPart].Add(CCBBRecord(nTmpStartPos1, nTmpEndPos1, m_aaRecords[nPart][i].m_dwIP, m_aaRecords[nPart][i].m_BBRStatus));
				m_aaRecords[nPart].Add(CCBBRecord(nTmpStartPos2, nTmpEndPos2, m_aaRecords[nPart][i].m_dwIP, m_aaRecords[nPart][i].m_BBRStatus));
				nDbgVerifiedBytes +=  (m_aaRecords[nPart][i].m_nEndPos-m_aaRecords[nPart][i].m_nStartPos)+1;
				m_aaRecords[nPart][i].m_BBRStatus = BBR_VERIFIED;
				DEBUG_ONLY(mapDebug.SetAt(m_aaRecords[nPart][i].m_dwIP, 1));
			}
			else if (m_aaRecords[nPart][i].m_nStartPos >= nRelStartPos && m_aaRecords[nPart][i].m_nStartPos <= nRelEndPos){
				// need to split it
				uint32 nTmpEndPos = m_aaRecords[nPart][i].m_nEndPos;
				uint32 nTmpStartPos = nRelEndPos + 1;
				m_aaRecords[nPart][i].m_nEndPos = nRelEndPos;
				m_aaRecords[nPart].Add(CCBBRecord(nTmpStartPos, nTmpEndPos, m_aaRecords[nPart][i].m_dwIP, m_aaRecords[nPart][i].m_BBRStatus));
				nDbgVerifiedBytes +=  (m_aaRecords[nPart][i].m_nEndPos-m_aaRecords[nPart][i].m_nStartPos)+1;
				m_aaRecords[nPart][i].m_BBRStatus = BBR_VERIFIED;
				DEBUG_ONLY(mapDebug.SetAt(m_aaRecords[nPart][i].m_dwIP, 1));
			}
			else if (m_aaRecords[nPart][i].m_nEndPos >= nRelStartPos && m_aaRecords[nPart][i].m_nEndPos <= nRelEndPos){
				// need to split it
				uint32 nTmpStartPos = m_aaRecords[nPart][i].m_nStartPos;
				uint32 nTmpEndPos = nRelStartPos - 1;
				m_aaRecords[nPart][i].m_nStartPos = nRelStartPos;
				m_aaRecords[nPart].Add(CCBBRecord(nTmpStartPos, nTmpEndPos, m_aaRecords[nPart][i].m_dwIP, m_aaRecords[nPart][i].m_BBRStatus));
				nDbgVerifiedBytes +=  (m_aaRecords[nPart][i].m_nEndPos-m_aaRecords[nPart][i].m_nStartPos)+1;
				m_aaRecords[nPart][i].m_BBRStatus = BBR_VERIFIED;
				DEBUG_ONLY(mapDebug.SetAt(m_aaRecords[nPart][i].m_dwIP, 1));
			}
		}
	}
/*#ifdef _DEBUG
	uint32 nClients = mapDebug.GetCount();
#else
	uint32 nClients = 0;
#endif
	AddDebugLogLine(DLP_DEFAULT, false, _T("Found and marked %u recorded bytes of %u as verified in the CorruptionBlackBox records, %u(%u) records found, %u different clients"), nDbgVerifiedBytes, (nEndPos-nStartPos)+1, m_aaRecords[nPart].GetCount(), nDbgOldEntries, nClients);*/
}
Ejemplo n.º 14
0
CTobCompiler::EToken CTobCompiler::CompilePass1()
{
	EToken r;
	CString str, buf;
	CByteArray* bin = 0;

	for(;;)
	{
		if((r = GetToken(str)) <= 0) return r;
		if(r == SYM_KEY)
		{
			if((r = GetToken(str)) < 0) return r;
			if(r != SYM_TOKEN)
			{
				m_err = "not found keyword after '.'";
				return ERR_NORMAL;
			}
			if(str == "def")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found token after '.def'";
					return ERR_NORMAL;
				}
				if((r = GetToken(buf)) < 0) return r;
				if(r == SYM_BIN)
				{
					bin = new CByteArray;
					if((r = GetBinary(*bin)) < 0) { delete bin; return r; }
				}
				else if(r == SYM_STR)
				{
					if((r = GetString(buf, false)) < 0) return r;
					bin = new CByteArray;
					for(LPCTSTR p = buf; *p; ++p) bin->Add(*(U8*)p);
					if(r == SYM_STRING) bin->Add(0);
				}
				else if(r == SYM_STRING)
				{
					if((r = GetString(buf, true)) < 0) return r;
					bin = new CByteArray;
					for(LPCTSTR p = buf; *p; ++p) bin->Add(*(U8*)p);
					if(r == SYM_STRING) bin->Add(0);
				}
				else
				{
					m_err = "not found '[' or ''' or '\"' after '.def <token>''";
					return ERR_NORMAL;
				}
				m_defbin.SetAt(str, bin);
				bin = 0;
			}
			else if(str == "change")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_STR)
				{
					m_err = "not found ''' after '.change'";
					return ERR_NORMAL;
				}
				if((r = GetString(str, false)) < 0) return r;
				if( str.IsEmpty() || str.GetLength()>2 || str.GetLength() == 2 && (U8)str[0]<0x80)
				{
					m_err = "only one character is allowed after '.change'";
					return ERR_NORMAL;
				}
				U16 c = (U8)str[0];
				if(str.GetLength() == 2) c = (c<<8) + (U8)str[1];
				if((r = GetToken(str)) < 0) return r;
				if(r == SYM_BIN)
				{
					CByteArray tmp;
					if((r = GetBinary(tmp)) < 0) return r;
					buf.Empty();
					int i, n = tmp.GetSize();
					for(i = 0; i < n; ++i)
					{
						U8 b = tmp.GetAt(i);
						if(!b) break;
						buf += (TCHAR)b;
					}
				}
				else if(r == SYM_STR)
				{
					if((r = GetString(buf, false)) < 0) return r;
				}
				else if(r == SYM_STRING)
				{
					if((r = GetString(buf, true)) < 0) return r;
				}
				else
				{
					m_err = "not found ''' or '\"' after '.change <char>'";
					return ERR_NORMAL;
				}
				m_change.SetAt(c, buf);
			}
			else if(str == "bit")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found parameter after '.bit'";
					return ERR_NORMAL;
				}
				int bit = atoi(str);
				if(bit!=8 && bit!=16 && bit!=24 && bit!=32)
				{
					m_err = "only '.bit 8/16/24/32' is available";
					return ERR_NORMAL;
				}
				m_bit_i = bit;
			}
			else if(str == "maxc")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found parameter after '.maxc'";
					return ERR_NORMAL;
				}
				m_maxc = atoi(str);
			}
			else if(str == "maxw")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found parameter after '.maxw'";
					return ERR_NORMAL;
				}
				m_maxw = atoi(str);
			}
			else if(str == "maxs")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found parameter after '.maxs'";
					return ERR_NORMAL;
				}
				m_maxs = atoi(str);
			}
			else
			{
				m_err.Format("unknwon keyword '%s' after '.'", (LPCTSTR)str);
				return ERR_NORMAL;
			}
		}
		else if(r == SYM_BIN)
		{
			if((r = GetBinary(m_bin)) < 0) return r;
		}
		else if(r == SYM_STR)
		{
			if((r = GetString(buf, false)) < 0) return r;
			for(LPCTSTR p=buf;* p; ++p) m_bin.Add(*(U8*)p);
			if(r == SYM_STRING) m_bin.Add(0);
		}
		else if(r == SYM_STRING)
		{
			if((r = GetString(buf, true)) < 0) return r;
			for(LPCTSTR p=buf;* p; ++p) m_bin.Add(*(U8*)p);
			if(r == SYM_STRING) m_bin.Add(0);
		}
		else if(r == SYM_TOKEN)
		{
			if(!m_defbin.Lookup(str, bin))
			{
				m_err.Format("not defined token '%s'", (LPCTSTR)str);
				return ERR_NORMAL;
			}
			m_bin.Append(*bin);
			bin = 0;
		}
		else if(r == SYM_ADDR)
		{
			if((r = GetToken(str)) < 0)
				return r;
			SExpInfo* ti = new SExpInfo(m_bin.GetSize(), m_line);
			if(r == SYM_EXP_BEGIN)
			{
				for(;;)
				{
					if((r = GetToken(buf)) < 0)
					{
						delete ti;
						return r;
					}
					if(r == SYM_TOKEN || r == SYM_NUM)
						ti->m_item.Add(buf);
					else if(r == SYM_ADD)
						ti->m_item.Add("+");
					else if(r == SYM_SUB)
						ti->m_item.Add("-");
					else if(r == SYM_ADDR)
						ti->m_item.Add("@");
					else if(r == SYM_EXP_END)
						break;
					else
					{
						delete ti;
						m_err.Format("found unknown token '%s' in expression", (LPCTSTR)buf);
						return ERR_NORMAL;
					}
				}
			}
			else if(r == SYM_TOKEN)
				ti->m_item.Add(str);
			else
			{
				delete ti;
				m_err = "not found token or expression after '@'";
				return ERR_NORMAL;
			}
			m_exp.Add(ti);
			for(int i = m_bit_i/8; i--;)
				m_bin.Add(0);
		}
		else if(r == SYM_LABEL)
		{
			if((r = GetToken(str)) < 0) return r;
			if(r != SYM_TOKEN)
			{
				m_err = "not found label after '#'";
				return ERR_NORMAL;
			}
			m_label.SetAt(str, m_bin.GetSize());
		}
		else
		{
			m_err = "unknown or bad symbol";
			return ERR_NORMAL;
		}
	}
}