/// <summary>Populates the library from the string library</summary> /// <param name="data">Feedback data</param> /// <returns>Number of objects found</returns> /// <exception cref="Logic::ArgumentNullException">Worker data is null</exception> /// <exception cref="Logic::InvalidOperationException">String library is empty</exception> UINT ScriptObjectLibrary::Enumerate(WorkerData* data) { REQUIRED(data); // Ensure string library exists if (StringLib.Files.empty()) throw InvalidOperationException(HERE, L"String library has not been enumerated"); // Feedback data->SendFeedback(Cons::Heading, ProgressType::Operation, 1, L"Generating script objects from language files"); // Populate Clear(); Populate(data); // DEBUG: Console << "Discovered " << (int)Objects.size() << " script objects..." << ENDL; // Feedback number of conflicts if (Objects.size() - Lookup.size() > 1) // Always 1 less in lookup because old [THIS] intentionally removed data->SendFeedback(Cons::Error, ProgressType::Error, 2, VString(L"Unable to process %d script objects", Objects.size()-Lookup.size()-1)); // Feedback object count data->SendFeedback(ProgressType::Info, 2, VString(L"Loaded %d script objects", Lookup.size())); return Lookup.size(); }
VString PartLineDoubleUp(VString line, VString el, VString er){ unsigned char *pos=line, *lpos; if(!rtmsu(line.endu(), el, el, pos)){ return VString(); } lpos=pos+=el.sz; //el.setu(pos+el.sz, line.endu()-pos-el.sz); if(!rtmsu(line.endu(), er, er, pos)){ return VString(); } return VString(lpos, pos-lpos); }
VString dspacevt(VString &line, int s){ // удаление пробелов и табов s - начало конец вернуть; 1,2,4 unsigned char *ln=line, *to=line.endu(); if(s&1) for(ln; ln<to; ln++){ if(*ln!=' ' && *ln!='\t' ) break; } if(s&2) for(to; ln<to; to--){ if(*(to-1)!=' ' && *(to-1)!='\t') break; } if(s&4) return line=VString(ln, to-ln); return VString(ln, to-ln); }
/// <summary>Extracts column information from a text tag</summary> /// <param name="tag">text tag</param> /// <exception cref="Logic::InvalidOperation">Not a 'text' tag</exception> /// <exception cref="Logic::Language::RichTextException">Invalid tag property</exception> void RichStringParser::SetColumnInfo(const RichTag& tag) { // Ensure tag is 'text' if (tag.Type != TagType::Text) throw InvalidOperationException(HERE, VString(L"Cannot extract column info from a '%s' tag", ::GetString(tag.Type).c_str()) ); // Extract properties direct into output for (const Property& p : tag.Properties) { // Column count if (p.Name == L"cols") { // Verify auto cols = _ttoi(p.Value.c_str()); if (cols < 0 || cols > 3) throw RichTextException(HERE, VString(L"Cannot arrange text in %d columns", cols)); Output.Columns = static_cast<ColumnType>(cols); } // Column width else if (p.Name == L"colwidth") Output.Width = _ttoi(p.Value.c_str()); // Column spacing else if (p.Name == L"colspacing") Output.Spacing = _ttoi(p.Value.c_str()); else // Unrecognised throw RichTextException(HERE, VString(L"Invalid 'text' tag property '%s'", p.Name.c_str())); } }
/// <summary>Commits the document</summary> /// <param name="title">Revision title</param> /// <returns></returns> BOOL ScriptDocument::OnCommitDocument(const wstring& title) { WorkerData data(Operation::LoadSaveDocument); try { // Feedback Console << Cons::UserAction << "Committing script: " << FullPath << ENDL; data.SendFeedback(ProgressType::Operation, 0, VString(L"Committing script '%s'", FullPath.c_str())); // Get project auto proj = ProjectDocument::GetActive(); // Verify document is part of project if (!proj) throw InvalidOperationException(HERE, L"No current project"); else if (!proj->Contains(FullPath)) throw InvalidOperationException(HERE, L"Document is not a member of current project"); // Commit if (proj->Commit(*this, title)) data.SendFeedback(Cons::Success, ProgressType::Succcess, 0, L"Script committed successfully"); else data.SendFeedback(Cons::Error, ProgressType::Failure, 0, L"Script commit aborted"); return TRUE; } catch (ExceptionBase& e) { Console.Log(HERE, e, VString(L"Failed to commit script '%s'", FullPath.c_str())); data.SendFeedback(Cons::Error, ProgressType::Failure, 0, L"Failed to commit script"); return FALSE; } }
/// <summary>Opens a document.</summary> /// <param name="szPathName">path.</param> /// <returns></returns> BOOL ScriptDocument::OnReloadDocument(LPCTSTR szPathName) { WorkerData data(Operation::LoadSaveDocument); try { // Feedback Console << Cons::Heading << "Reloading script: " << Path(szPathName) << ENDL; data.SendFeedback(ProgressType::Operation, 0, VString(L"Reloading script '%s'", szPathName)); // Read/Parse script Script = ScriptFileReader(XFileInfo(szPathName).OpenRead()).ReadFile(szPathName, false); // Feedback data.SendFeedback(ProgressType::Succcess, 0, L"Script reloaded successfully"); return TRUE; } catch (ExceptionBase& e) { // Feedback error data.SendFeedback(Cons::Error, ProgressType::Error, 1, e.Message); // Feedback failure data.SendFeedback(Cons::Error, ProgressType::Failure, 0, L"Failed to reload script"); theApp.ShowError(HERE, e, VString(L"Failed to reload script '%s'", szPathName)); // BEEP! MessageBeep(MB_ICONERROR); return FALSE; } }
/// <summary>Parses the page identifier</summary> /// <param name="pageid">The pageid</param> /// <param name="v">The associated game version</param> /// <returns>Normalised page ID</returns> /// <exception cref="Logic::InvalidValueException">Invalid pageID</exception> UINT LanguageFileReader::ParsePageID(const wstring& pageid, GameVersion& v) { // X2: nnnn if (pageid.length() <= 4) { v = GameVersion::Threat; return _wtoi(pageid.c_str()); } // X3: NNnnnn else if (pageid.length() != 6) throw InvalidValueException(HERE, VString(L"Invalid page ID '%s'", pageid.c_str()) ); // X3R: 30nnnn else if (pageid.compare(0, 2, L"30") == 0) v = GameVersion::Reunion; // X3TC: 35nnnn else if (pageid.compare(0, 2, L"35") == 0) v = GameVersion::TerranConflict; // X3AP: 38nnnn else if (pageid.compare(0, 2, L"38") == 0) v = GameVersion::AlbionPrelude; else throw InvalidValueException(HERE, VString(L"Invalid page ID '%s'", pageid.c_str()) ); // Convert last four digits of page ID return _wtoi(pageid.substr(2).c_str()); }
UListItem* UList<UListItem, options, tstacksize, tblocksize>::OneLine(){ if(!size_used) return VString(); if(data == data_end) return VString(data->data, size_used * sizeof(UListItem)); AddBlock(size_used); UListData<UListItem> *p = data, *d; int pos = 0; while(p != data_end){ memcpy(data_end->data + pos, p->data, p->size_used * sizeof(UListItem)); pos += p->size_used; size_all -= p->size_all; d = p; p = p->next; if(d != (void*)stackdata) free(d); } data = data_end; data->size_used = pos; return data->data; }
/// \brief /// Win32 only: finds the first directory above the passed path that contains a .project file /// /// All other platforms return false. /// /// This function can be used to add the project's directory as a data directory. /// /// \param szDir /// Absolute path that should be tested /// /// \return /// A VString with the project directory of the original directory if no project file present! /// /// \note /// Internally creates a temp buffer on the stack. Do not use it extensively for time critical processes. VBASE_IMPEXP static inline VString FindProjectDir(const char *szDir) { char szBuffer[FS_MAX_PATH]; if(FindProjectDir(szDir, szBuffer)) return VString(szBuffer); return VString(szDir); }
/// <summary>Opens a document template.</summary> /// <param name="docPath">document path.</param> /// <param name="t">template.</param> /// <returns></returns> BOOL ScriptDocument::OnOpenTemplate(Path docPath, const TemplateFile& t) { WorkerData data(Operation::LoadSaveDocument); try { // Feedback Console << Cons::UserAction << "Creating script: " << docPath << " from template: " << Path(t.SubPath) << ENDL; data.SendFeedback(ProgressType::Operation, 0, VString(L"Creating %s '%s'", t.Name.c_str(), docPath.c_str())); // Read/Parse template script AppPath path(t.SubPath); Script = ScriptFileReader(XFileInfo(path).OpenRead()).ReadFile(path, false); // Set properties Script.Name = docPath.RemoveExtension().FileName; Script.Game = PrefsLib.GameDataVersion; Script.Version = 1; Script.Description = L"no description"; // Populate template LineArray lines; wstring date = COleDateTime(time(nullptr)).Format(L"%d/%m/%Y"); for (auto& cmd : Script.Commands.Input) { cmd.Text = cmd.Text.ReplaceAll(L"$NAME$", Script.Name); cmd.Text = cmd.Text.ReplaceAll(L"$DATE$", date); cmd.Text = cmd.Text.ReplaceAll(L"$AUTHOR$", L""); lines.push_back(cmd.Text); } // Create temp scriptFile ScriptFile tmp(Script); tmp.FullPath = docPath; // Compile changes into temporary script ScriptParser parser(tmp, lines, Script.Game); parser.Compile(); // Write to disc ScriptFileWriter w(XFileInfo(docPath).OpenWrite()); w.Write(tmp); w.Close(); // Feedback data.SendFeedback(Cons::Success, ProgressType::Succcess, 0, L"Script created successfully"); return TRUE; } catch (ExceptionBase& e) { // Feedback/Display error data.SendFeedback(Cons::Error, ProgressType::Failure, 0, VString(L"Failed to create %s '%s'", t.Name.c_str(), docPath.c_str())); theApp.ShowError(HERE, e, VString(L"Failed to create %s '%s'", t.Name.c_str(), docPath.c_str())); return FALSE; } }
/// \brief /// Takes an input directory (NULL, "xyz", or "c:\xyz") and makes it an absolute directory by /// taking the current directory into account. /// /// \param szDir /// The input directory. /// /// \return /// Absolute directory (either szDir or szTmp) or an empty VString on failure. /// /// \note /// Internally creates a temp buffer on the stack. Do not use it extensively for time critical processes. VBASE_IMPEXP static inline VString MakeAbsoluteDir(const char *szDir) { char szBuffer[FS_MAX_PATH]; if(IsAbsolutePath(szDir)) return VString(szDir); MakeAbsoluteDir(szDir, szBuffer); return VString(szBuffer); }
/// <summary>Populates the library with all the language files in the 't' subfolder</summary> /// <param name="vfs">The VFS to search</param> /// <param name="lang">The language of strings to search for</param> /// <param name="data">Background worker data</param> /// <returns>Number of files found</returns> UINT StringLibrary::Enumerate(XFileSystem& vfs, GameLanguage lang, WorkerData* data) { list<XFileInfo> results; // Clear previous contents Clear(); // Feedback data->SendFeedback(Cons::Heading, ProgressType::Operation, 1, VString(L"Enumerating %s language files", GetString(lang).c_str())); // Enumerate non-foreign language files for (XFileInfo& f : vfs.Browse(XFolder::Language)) { LanguageFilenameReader fn(f.FullPath.FileName); // Add if language matches or is unspecified if (fn.Valid && (fn.Language == lang || !fn.HasLanguage)) results.push_back(f); } // Read/Store each file for (XFileInfo& f : results) { try { // Feedback data->SendFeedback(ProgressType::Info, 2, VString(L"Reading language file '%s'...", f.FullPath.c_str())); Console << L"Reading language file: " << f.FullPath << L"..."; // Parse language file LanguageFile file = LanguageFileReader(f.OpenRead()).ReadFile(f.FullPath); // check language tag matches filename if (file.Language == lang) { Files.insert(move(file)); Console << Cons::Success << ENDL; } else { // Skip files that turn out to be foreign data->SendFeedback(ProgressType::Warning, 3, VString(L"Skipping %s language file...", GetString(file.Language).c_str()) ); Console << Cons::Bold << Cons::Yellow << L"Skipped" << ENDL; } } catch (ExceptionBase& e) { data->SendFeedback(Cons::Error, ProgressType::Error, 3, GuiString(L"Failed: ") + e.Message); // SkipBroken: Abort/Continue after error if (!PrefsLib.SkipBrokenFiles) throw; } } return Files.size(); }
unsigned int msrand(unsigned int limit=S4GM){ unsigned int u, z=0; u=(unsigned int)time(0); mscrrand.Add(VString((char*)&u, 4)); #ifndef __GNUC__ //__asm{ mov dword ptr [u] , ebp } #endif mscrrand.Add(VString((char*)&u, 4)); mscrrand.Add(VString(mscrrand.cach, 16)); //mscrrand.Add(mscrrand_key); return mscrrand.Rand(limit); }
XBOX::VError VRemoteDebugPilot::BreakpointReached( WAKDebuggerContext_t inContext, int inLineNumber, int inExceptionHandle, char* inURL, int inURLLength, char* inFunction, int inFunctionLength, char* inMessage, int inMessageLength, char* inName, int inNameLength, long inBeginOffset, long inEndOffset ) { VError l_err = VRemoteDebugPilot::Check(inContext); if (!l_err) { return l_err; } bool l_wait; XBOX::VSemaphore* l_sem = new VSemaphore(0); l_err = ContextUpdated(inContext,l_sem,&l_wait); if (!l_err) { if (l_wait) { l_sem->Lock(); VTask::Sleep(2500); delete l_sem; } RemoteDebugPilotMsg_t l_msg; l_msg.type = BREAKPOINT_REACHED_MSG; l_msg.ctx = inContext; l_msg.linenb = inLineNumber; l_msg.srcid = *(intptr_t *)inURL;// we use the URL param to pass sourceId (to not modify interface of server) l_msg.datastr = VString( inFunction, inFunctionLength*2, VTC_UTF_16 ); l_msg.urlstr = VString( inMessage, inMessageLength*2, VTC_UTF_16 ); l_err = Send( l_msg ); } VString l_trace = VString("VRemoteDebugPilot::BreakpointReached ctx activation pb for ctxid="); l_trace.AppendLong8((unsigned long long)inContext); l_trace += " ,ok="; l_trace += (!l_err ? "1" : "0" ); sPrivateLogHandler->Put( (l_err ? WAKDBG_ERROR_LEVEL : WAKDBG_INFO_LEVEL),l_trace); return l_err; }
/// <summary>Loads game data</summary> /// <param name="data">arguments.</param> /// <returns></returns> DWORD WINAPI GameDataWorker::ThreadMain(GameDataWorkerData* data) { try { XFileSystem vfs; HRESULT hr; // Init COM if (FAILED(hr=CoInitialize(NULL))) throw ComException(HERE, hr); // Feedback Console << Cons::UserAction << L"Loading " << VersionString(data->Version) << L" game data from " << data->GameFolder << ENDL; data->SendFeedback(ProgressType::Operation, 0, VString(L"Loading %s game data from '%s'", VersionString(data->Version).c_str(), data->GameFolder.c_str())); // Build VFS. vfs.Enumerate(data->GameFolder, data->Version, data); // language files StringLib.Enumerate(vfs, data->Language, data); // script/game objects ScriptObjectLib.Enumerate(data); GameObjectLib.Enumerate(vfs, data); // Descriptions DescriptionLib.Enumerate(data); // legacy syntax file SyntaxLib.Enumerate(data); // Cleanup data->SendFeedback(Cons::UserAction, ProgressType::Succcess, 0, VString(L"Loaded %s game data successfully", VersionString(data->Version).c_str())); CoUninitialize(); return 0; } catch (ExceptionBase& e) { // Feedback Console.Log(HERE, e); Console << ENDL; data->SendFeedback(Cons::Error, ProgressType::Failure, 0, GuiString(L"Failed to load game data : ") + e.Message); // BEEP! MessageBeep(MB_ICONERROR); // Cleanup CoUninitialize(); return 0; } }
IVDirectory* VSimpleVfs::GetDir(VStringParam in_strDir) { if( in_strDir[0] != '/' ) { V3D_THROW(VIOException, "paths must start with '/', \"" + VString(in_strDir) + "\" is illegal" ); } IVDirectory* pCurrDir = m_pRootDirSP.Get(); std::string pathAndName = in_strDir; std::string::iterator pos = pathAndName.begin(); std::string::iterator substrEnd = pos; const std::string::iterator end(pathAndName.end()); std::string currDirName = "/"; std::string fileName; while((substrEnd = std::find(++pos, end, '/')) != end) { // get current dir name currDirName.assign(pos, substrEnd); // find it in current directory VDirectory::DirIter nextDir = pCurrDir->SubDirs(); VDirectory* tmp = (VDirectory*)&(*nextDir); VCompareFSOName fsoCmp(currDirName); while( nextDir.HasNext() ) { if( fsoCmp(*nextDir) ) break; ++nextDir; } if( !nextDir.HasNext() ) { V3D_THROW(VIOException, "could not find directory \"" + VString(currDirName.c_str()) + "\""); } pCurrDir = &(*nextDir); pos = substrEnd; } fileName.assign(pos, substrEnd); // return dir return pCurrDir; }
/// <summary>Reads the unix style colour code and advances the iterator</summary> /// <param name="pos">position of backslash</param> /// <returns></returns> /// <exception cref="Logic::AlgorithmException">Previously matched colour code is unrecognised</exception> /// <remarks>Advances the iterator to the last character of the tag, so Parse() loop advances correctly to the next character</remarks> Colour RichStringParser::ReadColourCode(CharIterator& pos) { Colour c; // Match colour character switch (pos[4]) { case 'A': c = Colour::Silver; break; case 'B': c = Colour::Blue; break; case 'C': c = Colour::Cyan; break; case 'G': c = Colour::Green; break; case 'O': c = Colour::Orange; break; case 'M': c = Colour::Purple; break; case 'R': c = Colour::Red; break; case 'W': c = Colour::White; break; case 'X': c = Colour::Default; break; case 'Y': c = Colour::Yellow; break; case 'Z': c = Colour::Black; break; default: throw AlgorithmException(HERE, VString(L"Previously matched colour code '%c' is unrecognised", *pos)); } // Consume + return colour pos += 4; return c; }
bool XMacFileSystemNotification::AddChangeToList( XMacChangeData *inData, const std::string& inPosixPath, const std::string& inFileName, bool inIsDirectory, VFileSystemNotifier::EventKind inKind) { // We need to ensure this is actually an event the user is really interested in // hearing about before adding the data to the list. We're just told "there was // a change" by the OS, so it's possible we don't care about this information at all. if (inData->fFilters & inKind) { // The user does care about this, so let's add it to the proper list int index; switch( inKind) { case VFileSystemNotifier::kFileModified: index = 0; break; case VFileSystemNotifier::kFileAdded: index = 1; break; case VFileSystemNotifier::kFileDeleted: index = 2; break; default: xbox_assert( false ); } std::string path( inPosixPath); path += inFileName; if (inIsDirectory) path += "/"; VFilePath filePath( VString( path.c_str(), path.size(), VTC_UTF_8), FPS_POSIX ); // protect access to VChangeData::fData { VTaskLock lock( &fOwner->fMutex); inData->fData[ index ].push_back( filePath ); } return true; } return false; }
VFile* XLinuxLibrary::RetainExecutableFile(const VFilePath &inFilePath) const { //jmo - What are we supposed to retain ? First we try the exact path... if(inFilePath.IsFile()) return new VFile(inFilePath); //jmo - If exact path doesn't work, we assume inFilePath to be part of a bundle // and try to find the corresponding shared object. VFilePath bundlePath=inFilePath; while(!bundlePath.MatchExtension(CVSTR("bundle"), true /*case sensitive*/) && bundlePath.IsValid()) bundlePath=bundlePath.ToParent(); if(!bundlePath.IsValid()) return NULL; VString name; bundlePath.GetFolderName(name, false /*no ext.*/); if(name.IsEmpty()) return NULL; VString soSubPath=CVSTR("Contents/Linux/")+VString(name)+CVSTR(".so"); VFilePath soPath; soPath.FromRelativePath(bundlePath, soSubPath, FPS_POSIX); if(soPath.IsFile()) return new VFile(soPath); return NULL; }
static bool IsTagWithoutClose( const VString &inTag ) { static const char *sList[] = { "!DOCTYPE", "AREA", "BASE", "BASEFONT", "BR", "COL", "FRAME", "HR" "IMG", "INPUT", "ISINDEX", "LINK", "META", "PARAM", }; for (sLONG i = 0; i < sizeof( sList ) / sizeof( const char * ); i++) { if (inTag.EqualTo( VString( sList[ i ] ), false )) return true; } return false; }
VString XLinuxIntlMgr::GetTimeSeparator() const { VString timeSeparator; VString timePattern=GetDateOrTimePattern(SHORT_TIME); bool isQuoted=false; for(int i=0 ; i<timePattern.GetLength() ; i++) { UniChar c=timePattern[i]; if(c=='\'') isQuoted=!isQuoted; if(isQuoted) continue; if(!(c>='A' && c<='Z') && !(c>='a' && c<='z')) { timeSeparator.AppendUniChar(c); break; } } if(timeSeparator.IsEmpty()) return VString(":"); return timeSeparator; }
/// <summary>Custom draws a single sub-item</summary> /// <param name="dc">Device context</param> /// <param name="item">Item data.</param> void ListViewCustomDraw::onDrawSubItem(CDC* dc, ItemData& item) { // Get item data LVItem data(item.Index, item.SubItem, 512, LVIF_IMAGE | LVIF_TEXT); ListView.GetItem(&data); // Draw Icon: CImageList* imgList = ListView.GetImageList(LVSIL_SMALL); if (item.SubItem == 0 && imgList) { CRect icon; // Get icon rectangle ListView.GetSubItemRect(item.Index, 0, LVIR_ICON, icon); // Draw transparent if (!imgList->Draw(dc, data.iImage, icon.TopLeft(), ILD_TRANSPARENT)) throw Win32Exception(HERE, VString(L"Unable to draw icon for item %d", item.Index)); // Create gap betwen icon/label item.Rect.left += 3; } // Draw Text: dc->DrawText(data.pszText, item.Rect, DT_VCENTER|DT_LEFT|DT_END_ELLIPSIS|DT_SINGLELINE); }
/// <summary>Reads a literal or sub-expression</summary> /// <param name="pos">Position of literal or first token of sub-expression</param> /// <returns>Expression tree</returns> /// <exception cref="Logic::AlgorithmException">Attempted to read incorrect type of Token</exception> /// <exception cref="Logic::ExpressionParserException">Syntax error</exception> /// <remarks>Advances the iterator to beyond the end of the literal or sub-expression</remarks> ExpressionParser::ExpressionTree ExpressionParser::ReadValue(TokenIterator& pos) { ExpressionTree expr = nullptr; // Rule: Value = Literal / '(' Expression ')' // Match: Literal if (MatchLiteral(pos)) return ExpressionTree( new LiteralValue(ReadLiteral(pos)) ); // Read: Bracket [nothrow] if (!MatchOperator(pos, L"(")) { // Failed: Unexpected EOF if (pos >= InputEnd) throw ExpressionParserException(HERE, --pos, L"Missing operand"); // Failed: Unexpected token throw ExpressionParserException(HERE, pos, VString(L"Unexpected '%s'", pos->Text.c_str())); } // Read: Expression (may throw) const ScriptToken& open = ReadOperator(pos); expr = ReadExpression(pos); // Adv. then match // Read: Bracket [nothrow] if (MatchOperator(pos, L")")) return ExpressionTree( new BracketedExpression(open, expr, ReadOperator(pos)) ); // Failure: Missing closing bracket if (pos >= InputEnd) throw ExpressionParserException(HERE, --pos, L"Missing closing bracket"); else throw ExpressionParserException(HERE, pos, L"Expected closing bracket"); }
/// <summary>Attempts to matches any operator of a given precedence</summary> /// <param name="pos">Position of operator</param> /// <returns></returns> /// <exception cref="Logic::AlgorithmException">Invalid precendence detected</exception> bool ExpressionParser::MatchOperator(const TokenIterator& pos, UINT precedence) { // Validate position. Ensure operator if (pos >= InputEnd || (pos->Type != TokenType::BinaryOp && pos->Type != TokenType::UnaryOp)) return false; // Precedence table taken from X2 scripting manual switch (precedence) { case 0: return pos->Text == L"OR" || pos->Text == L"||"; case 1: return pos->Text == L"AND" || pos->Text == L"&&"; case 2: return pos->Text == L"|"; case 3: return pos->Text == L"^"; case 4: return pos->Text == L"&"; case 5: return pos->Text == L"==" || pos->Text == L"!="; case 6: return pos->Text == L"<" || pos->Text == L">" || pos->Text == L"<=" || pos->Text == L">="; case 7: return pos->Text == L"+" || pos->Text == L"-"; case 8: return pos->Text == L"*" || pos->Text == L"/" || pos->Text == L"%" || pos->Text == L"MOD"; case 9: return pos->Text == L"~" || pos->Text == L"!" || pos->Text == L"-"; } throw AlgorithmException(HERE, VString(L"Invalid precedence %d", precedence)); }
XBOX::VError VRemoteDebugPilot::BreakpointReached( OpaqueDebuggerContext inContext, int inLineNumber, RemoteDebuggerPauseReason inDebugReason, XBOX::VString& inException, XBOX::VString& inSourceUrl, XBOX::VectorOfVString& inSourceData) { VError err = VE_INVALID_PARAMETER; XBOX::VSemaphore* sem = NULL; VContextDebugInfos debugInfos; debugInfos.fFileName = inSourceUrl; VURL::Decode( debugInfos.fFileName ); VIndex idx = debugInfos.fFileName.FindUniChar( L'/', debugInfos.fFileName.GetLength(), true ); if (idx > 1) { VString tmpStr; debugInfos.fFileName.GetSubString(idx+1,debugInfos.fFileName.GetLength()-idx,tmpStr); debugInfos.fFileName = tmpStr; } debugInfos.fLineNb = inLineNumber+1; debugInfos.fReason = ( inDebugReason == EXCEPTION_RSN ? "exception" : (inDebugReason == BREAKPOINT_RSN ? "breakpoint" : "dbg statement" ) ); debugInfos.fComment = "To Be Completed"; debugInfos.fSourceLine = ( inLineNumber < inSourceData.size() ? inSourceData[inLineNumber] : " NO SOURCE AVAILABLE " ); err = ContextUpdated(inContext,debugInfos,&sem); if (err == VE_OK) { fPendingContextsNumberSem.Unlock(); // if sem not NULL then wait for a browser page granted for debug if (sem) { sem->Lock(); ReleaseRefCountable(&sem); } RemoteDebugPilotMsg_t msg; msg.type = BREAKPOINT_REACHED_MSG; msg.ctx = inContext; msg.linenb = inLineNumber; msg.datavectstr = inSourceData; msg.datastr = inException; msg.urlstr = inSourceUrl; err = Send( msg ); //testAssert(err == VE_OK); fPendingContextsNumberSem.Lock(); } VString trace = VString("VRemoteDebugPilot::BreakpointReached ctx activation pb for ctxid="); trace.AppendLong8((unsigned long long)inContext); trace += " ,ok="; trace += (!err ? "1" : "0" ); sPrivateLogHandler->Put( (err ? WAKDBG_ERROR_LEVEL : WAKDBG_INFO_LEVEL),trace); return err; }
void VRemoteDebugPilot::TreatNewClientMsg(RemoteDebugPilotMsg_t& ioMsg) { XBOX::VError err; switch(fState) { case STARTED_STATE: err = fWS->TreatNewConnection(ioMsg.response); if (!err) { fNeedsAuthentication = ioMsg.needsAuthentication; fState = CONNECTING_STATE; fClientId = VString(""); fPipeStatus = VE_OK; } else { fClientCompletedSemaphore.Unlock(); } break; case STOPPED_STATE: DebugMsg("VRemoteDebugPilot::TreatNewClientMsg NEW_CLIENT SHOULD NOT HAPPEN in state=%d !!!\n",fState); fClientCompletedSemaphore.Unlock(); break; case CONNECTED_STATE: case DISCONNECTING_STATE: case CONNECTING_STATE: DebugMsg("VRemoteDebugPilot::TreatNewClientMsg NEW_CLIENT SHOULD NOT HAPPEN in state=%d !!!\n",fState); xbox_assert(false); break; } fPipeOutSem.Unlock(); }
VString xPL_Eeprom::readString(bool step) { VString s = VString(_addr,VSHelperEeprom::helper); s.load(); if (step) _addr += s.len()+1; return s; }
/// <summary>Identify the windows version</summary> WindowsVersion::WindowsVersion() : Version(OS::Future) { // Prepare ZeroMemory((OSVERSIONINFO*)this, sizeof(OSVERSIONINFO)); dwOSVersionInfoSize = sizeof(OSVERSIONINFO); // Query windows version if (GetVersionEx(this)) { switch (dwMajorVersion) { // [WINDOWS NT 5] Windows 2000 or Windows XP case 5: switch (dwMinorVersion) { case 0: Version = OS::Win2000; break; case 1: Version = OS::WinXP; break; case 2: Version = OS::Server2003; break; } break; // [WINDOWS NT 6] Windows Vista, 7, or newer case 6: switch (dwMinorVersion) { case 0: Version = OS::Vista; break; case 1: Version = OS::Win7; break; default: Version = OS::Future; break; } break; } } // Set name switch (Version) { case OS::Win2000: Name = L"Windows 2000"; break; case OS::WinXP: Name = L"Windows XP"; break; case OS::Server2003: Name = L"Windows Server 2003"; break; case OS::Vista: Name = L"Windows Vista"; break; case OS::Win7: Name = L"Windows 7"; break; case OS::Future: Name = L"Windows Future"; break; } // Set Full name FullName = VString(L"%s %s (v%d.%d)", Name.c_str(), szCSDVersion, dwMajorVersion, dwMinorVersion); // Query architecture SYSTEM_INFO si; GetNativeSystemInfo(&si); switch (si.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_AMD64: Architecture = L"x64"; break; case PROCESSOR_ARCHITECTURE_IA64: Architecture = L"Itanium"; break; case PROCESSOR_ARCHITECTURE_INTEL: Architecture = L"x86"; break; default: case PROCESSOR_ARCHITECTURE_UNKNOWN: Architecture = L"Unknown"; break; } }
/// <summary>Gets the text of the selected suggestion.</summary> /// <returns></returns> /// <exception cref="Logic::InvalidOperationException">No item selected</exception> /// <exception cref="Logic::NotImplementedException">Command selected</exception> wstring SuggestionList::GetSelected() const { // Ensure exists if (GetNextItem(-1, LVNI_SELECTED) == -1) throw InvalidOperationException(HERE, L"No item selected"); // Get selection and format switch (SuggestionType) { case Suggestion::GameObject: return VString(L"{%s}", Content[GetNextItem(-1, LVNI_SELECTED)].Text.c_str()); case Suggestion::ScriptObject: return VString(L"[%s]", Content[GetNextItem(-1, LVNI_SELECTED)].Text.c_str()); case Suggestion::Variable: return VString(L"$%s", Content[GetNextItem(-1, LVNI_SELECTED)].Text.c_str()); case Suggestion::Label: return VString(L"%s:", Content[GetNextItem(-1, LVNI_SELECTED)].Text.c_str()); case Suggestion::Command: return Content[GetNextItem(-1, LVNI_SELECTED)].Text; default: return L"Error"; } }
uint32_t VDirAdapter_Unix::getLength() const { VString strPath = m_strRoot + VString(m_pDirent->d_name); struct stat s; int result = stat(strPath.c_str(), &s); return (result == 0 ? s.st_size : 0); }