static TString FindOutputFile() { TString candidate; if (!out_argument.empty()) { candidate = StripQuotes(out_argument); } else if (!first_object_name.empty()) { candidate = first_object_name; if (!StripSuffix(candidate, TEXT(".obj"))) StripSuffix(candidate, TEXT(".o")); } else { return TString(); } if (PathFileExists(candidate.c_str())) return candidate; // FIXME: we should figure out from the linker's command line // whether the output file is an .exe or .dll TString exe_file = candidate + TEXT(".exe"); if (PathFileExists(exe_file.c_str())) return exe_file; TString dll_file = candidate + TEXT(".dll"); if (PathFileExists(dll_file.c_str())) return dll_file; return TString(); }
bool CSymbolEngine::LoadModuleSymbols( HANDLE hFile, const TString& ImageName, DWORD64 ModBase, DWORD ModSize ) { // Check preconditions if( m_hProcess == NULL ) { _ASSERTE( !_T("Symbol engine is not yet initialized.") ); m_LastError = ERROR_INVALID_FUNCTION; return false; } // In Unicode build, ImageName parameter should be translated to ANSI #ifdef _UNICODE char* pImageName = 0; if( !ImageName.empty() ) { size_t BufSize = 2 * ImageName.length(); pImageName = (char*)_alloca( BufSize + 2 ); size_t res = wcstombs( pImageName, ImageName.c_str(), BufSize ); pImageName[BufSize] = 0; if( res == -1 ) { _ASSERTE( !_T("Module name has bad format.") ); m_LastError = ERROR_INVALID_PARAMETER; return false; } } #else const char* pImageName = ImageName.empty() ? 0 : ImageName.c_str(); #endif //_UNICODE // Load symbols for the module #pragma TODO("replace SymLoadModule64 with SymLoadModuleEx ") DWORD64 rv = SymLoadModule64( m_hProcess, hFile, pImageName, NULL, ModBase, ModSize ); if( rv == 0 ) { m_LastError = GetLastError(); _ASSERTE( !_T("SymLoadModule64() failed.") ); return false; } // Complete return true; }
void CTextEdit::SetText(const TString &text) { if(!text.empty()) { m_strText = text; } }
/***************************************************************************** ** Procedure: CEventFactory::Create ** ** Arguments: 'strCommand' - String from PBX ** ** Returns: Derivative CEventBlock for this PBX command ** ** Description: This function creates a new CEventBlock object ** *****************************************************************************/ CEventBlock* CEventFactory::Create(TString& strData) { // We should have at least one object in our event list _TSP_ASSERT(m_pHead != NULL); // The first element is always the command. TString strCommand = GetNextElem(strData); if (strCommand.empty()) return NULL; // Uppercase the command string CharUpperBuff(&strCommand[0], strCommand.length()); // Convert the command string into its numerical equivelant for // quick lookup. enum CEventBlock::PBXEvent evtType = CEventBlock::Unknown; for (int i = 0; g_StringToEvent[i].pszEvent != NULL; i++) { if (!strCommand.compare(g_StringToEvent[i].pszEvent)) { evtType = g_StringToEvent[i].evtType; break; } } // If the event is unknown, it means we have not completely defined // the interface and have a problem! _TSP_ASSERT (evtType != CEventBlock::Unknown); // Return the event object which encapsulates this command return m_pHead->Create(evtType, strData); }// CEventFactory::Create
int mode_fit(const int argc, const char* argv[]) { ConfigureMalloc(); NCatboostOptions::TPoolLoadParams poolLoadOptions; TString paramsFile; NJson::TJsonValue catBoostFlatJsonOptions; ParseCommandLine(argc, argv, &catBoostFlatJsonOptions, ¶msFile, &poolLoadOptions); NJson::TJsonValue catBoostJsonOptions; NJson::TJsonValue outputOptionsJson; if (!paramsFile.empty()) { CB_ENSURE(NFs::Exists(paramsFile), "Params file does not exists " << paramsFile); TIFStream in(paramsFile); NJson::TJsonValue fromFileParams; CB_ENSURE(NJson::ReadJsonTree(&in, &fromFileParams), "can't parse params file"); NCatboostOptions::PlainJsonToOptions(fromFileParams, &catBoostJsonOptions, &outputOptionsJson); } NCatboostOptions::PlainJsonToOptions(catBoostFlatJsonOptions, &catBoostJsonOptions, &outputOptionsJson); poolLoadOptions.Validate(); auto taskType = NCatboostOptions::GetTaskType(catBoostJsonOptions); THolder<IModelTrainer> modelTrainerHolder; NCatboostOptions::TOutputFilesOptions outputOptions(taskType); outputOptions.Load(outputOptionsJson); const bool isGpuDeviceType = taskType == ETaskType::GPU; if (isGpuDeviceType && TTrainerFactory::Has(ETaskType::GPU)) { modelTrainerHolder = TTrainerFactory::Construct(ETaskType::GPU); } else { CB_ENSURE(!isGpuDeviceType, "GPU Device not found."); modelTrainerHolder = TTrainerFactory::Construct(ETaskType::CPU); } modelTrainerHolder->TrainModel(poolLoadOptions, outputOptions, catBoostJsonOptions); return 0; }
bool CEditLanguageDialog::ExamLanguageText(const TString& strEnum, bool bCheckExist) { bool bRet = false; std::map<TString, std::map<ELanguageType, TString> >& languageMap = CLanguageManager::GetInstance()->GetLanguageMap(); if (strEnum.empty()) { wxMessageBox(_T("enum string Can't be empty!")); } else if (strEnum.find("eLTT_") != 0) { wxMessageBox(_T("enum string should begin with eLTT_")); } else if (!((wxString)strEnum).IsAscii()) { wxMessageBox(_T("enum string should be all ascii!")); } else if (strEnum.find(_T(' '), 0) != 0xFFFFFFFF) { wxMessageBox(_T("enum string can't contain space!")); } else if (bCheckExist && languageMap.find(strEnum) != languageMap.end()) { wxMessageBox(wxString::Format(_T("enum string %s already exists!"), strEnum.c_str())); } else { bRet = true; } return bRet; }
uint32_t CSceneManager::GetSceneFileId(const TString& strFileName) { uint32_t uRet = 0xFFFFFFFF; if (strFileName.length() > 0) { CComponentProject* pProject = CEngineCenter::GetInstance()->GetComponentManager()->GetProject(); TString strFullFileName = strFileName; #ifdef EDITOR_MODE const std::vector<TString>* pFileList = pProject->GetFileList(); for (size_t i = 0; i < pFileList->size(); ++i) { const TString& strFilePath = pFileList->at(i); int pos = strFilePath.rfind(strFileName); if (pos != -1 && strFilePath.length() - pos == strFileName.length()) { strFullFileName = pFileList->at(i); break; } } #endif BEATS_ASSERT(!strFullFileName.empty()); strFullFileName = CStringHelper::GetInstance()->ToLower(strFullFileName); uRet = pProject->GetComponentFileId(strFullFileName); } return uRet; }
TString UniformHLSL::uniformsHeader(ShShaderOutput outputType, const ReferencedSymbols &referencedUniforms) { TString uniforms; for (ReferencedSymbols::const_iterator uniformIt = referencedUniforms.begin(); uniformIt != referencedUniforms.end(); uniformIt++) { const TIntermSymbol &uniform = *uniformIt->second; const TType &type = uniform.getType(); const TString &name = uniform.getSymbol(); int registerIndex = declareUniformAndAssignRegister(type, name); if (outputType == SH_HLSL11_OUTPUT && IsSampler(type.getBasicType())) // Also declare the texture { uniforms += "uniform " + SamplerString(type) + " sampler_" + DecorateUniform(name, type) + ArrayString(type) + " : register(s" + str(registerIndex) + ");\n"; uniforms += "uniform " + TextureString(type) + " texture_" + DecorateUniform(name, type) + ArrayString(type) + " : register(t" + str(registerIndex) + ");\n"; } else { const TStructure *structure = type.getStruct(); const TString &typeName = (structure ? QualifiedStructNameString(*structure, false, false) : TypeString(type)); const TString ®isterString = TString("register(") + UniformRegisterPrefix(type) + str(registerIndex) + ")"; uniforms += "uniform " + typeName + " " + DecorateUniform(name, type) + ArrayString(type) + " : " + registerString + ";\n"; } } return (uniforms.empty() ? "" : ("// Uniforms\n\n" + uniforms)); }
// Like TString::Quote(), but does not quote digits-only string static TString QuoteForHelp(const TString& str) { if (str.empty()) return str.Quote(); for (size_t i = 0; i < str.size(); ++i) { if (!isdigit(str[i])) return str.Quote(); } return str; }
TString UniformHLSL::interfaceBlocksHeader(const ReferencedSymbols &referencedInterfaceBlocks) { TString interfaceBlocks; for (ReferencedSymbols::const_iterator interfaceBlockIt = referencedInterfaceBlocks.begin(); interfaceBlockIt != referencedInterfaceBlocks.end(); interfaceBlockIt++) { const TType &nodeType = interfaceBlockIt->second->getType(); const TInterfaceBlock &interfaceBlock = *nodeType.getInterfaceBlock(); const TFieldList &fieldList = interfaceBlock.fields(); unsigned int arraySize = static_cast<unsigned int>(interfaceBlock.arraySize()); InterfaceBlock activeBlock(interfaceBlock.name().c_str(), arraySize, mInterfaceBlockRegister); for (unsigned int typeIndex = 0; typeIndex < fieldList.size(); typeIndex++) { const TField &field = *fieldList[typeIndex]; const TString &fullFieldName = InterfaceBlockFieldName(interfaceBlock, field); bool isRowMajor = (field.type()->getLayoutQualifier().matrixPacking == EmpRowMajor); GetInterfaceBlockFieldTraverser traverser(&activeBlock.fields, isRowMajor); traverser.traverse(*field.type(), fullFieldName); } mInterfaceBlockRegisterMap[activeBlock.name] = mInterfaceBlockRegister; mInterfaceBlockRegister += std::max(1u, arraySize); BlockLayoutType blockLayoutType = GetBlockLayoutType(interfaceBlock.blockStorage()); SetBlockLayout(&activeBlock, blockLayoutType); if (interfaceBlock.matrixPacking() == EmpRowMajor) { activeBlock.isRowMajorLayout = true; } mActiveInterfaceBlocks.push_back(activeBlock); if (interfaceBlock.hasInstanceName()) { interfaceBlocks += interfaceBlockStructString(interfaceBlock); } if (arraySize > 0) { for (unsigned int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { interfaceBlocks += interfaceBlockString(interfaceBlock, activeBlock.registerIndex + arrayIndex, arrayIndex); } } else { interfaceBlocks += interfaceBlockString(interfaceBlock, activeBlock.registerIndex, GL_INVALID_INDEX); } } return (interfaceBlocks.empty() ? "" : ("// Interface Blocks\n\n" + interfaceBlocks)); }
bool IniFile::LoadFromFile(const TString FileName) { bool result = false; Platform& platform = Platform::GetInstance(); std::list<TString> contents = platform.LoadFromFile(FileName); if (contents.empty() == false) { bool found = false; // Determine the if file is an INI file or property file. Assign FDefaultSection if it is // an INI file. Otherwise FDefaultSection is NULL. for (std::list<TString>::const_iterator iterator = contents.begin(); iterator != contents.end(); iterator++) { TString line = *iterator; if (line[0] == ';') { // Semicolon is a comment so ignore the line. continue; } else { if (line[0] == '[') { found = true; } break; } } if (found == true) { TString sectionName; for (std::list<TString>::const_iterator iterator = contents.begin(); iterator != contents.end(); iterator++) { TString line = *iterator; if (line[0] == ';') { // Semicolon is a comment so ignore the line. continue; } else if (line[0] == '[' && line[line.length() - 1] == ']') { sectionName = line.substr(1, line.size() - 2); } else if (sectionName.empty() == false) { TString name; TString value; if (Helpers::SplitOptionIntoNameValue(line, name, value) == true) { Append(sectionName, name, value); } } } result = true; } } return result; }
void CControl::SetAnimationName( const TString& animationName ) { m_strPressAnimationName = animationName; if (!animationName.empty() && m_pPressAnimation != NULL) { CNodeAnimationData* pData = CNodeAnimationManager::GetInstance()->GetNodeAnimationData(animationName); BEATS_ASSERT(pData != NULL); m_pPressAnimation->SetData(pData); } }
// static TString TIntermTraverser::hash(const TString& name, ShHashFunction64 hashFunction) { if (hashFunction == NULL || name.empty()) return name; khronos_uint64_t number = (*hashFunction)(name.c_str(), name.length()); TStringStream stream; stream << HASHED_NAME_PREFIX << std::hex << number; TString hashedName = stream.str(); return hashedName; }
TString TOutputGLSLBase::hashName(const TString& name) { if (mHashFunction == NULL || name.empty()) return name; NameMap::const_iterator it = mNameMap.find(name.c_str()); if (it != mNameMap.end()) return it->second.c_str(); TString hashedName = TIntermTraverser::hash(name, mHashFunction); mNameMap[name.c_str()] = hashedName.c_str(); return hashedName; }
bool CSceneManager::SwitchSceneAsync(const TString& strFileName, bool UnloadBeforeLoad) { SceneSwithNotify(); BEATS_ASSERT(!strFileName.empty(), "File name can't be empty."); BEATS_ASSERT(m_bSwitchingSceneState == false); uint32_t uFileId = GetSceneFileId(strFileName); BEATS_ASSERT(uFileId != 0xFFFFFFFF); m_pSwitchSceneTask->SetUnloadBeforeLoad(UnloadBeforeLoad); m_pSwitchSceneTask->SetTargetSceneFileId(uFileId); CTaskManager::GetInstance()->AddTask(m_pSwitchSceneTask, true); return true; }
void NDiff::InlineDiff(TVector<TChunk<char>>& chunks, const TStringBuf& left, const TStringBuf& right, const TString& delims) { if (delims.empty()) { InlineDiff<char>(chunks, TConstArrayRef<char>(~left, +left), TConstArrayRef<char>(~right, +right)); return; } TCollection<char> c1(left, delims); TCollection<char> c2(right, delims); TVector<TChunk<ui64>> diff; InlineDiff<ui64>(diff, c1.GetKeys(), c2.GetKeys()); for (const auto& it : diff) { chunks.push_back(TChunk<char>(c1.Remap(it.Left), c2.Remap(it.Right), c1.Remap(it.Common))); } }
const TString& CLanguageManager::GetUtf8Text(ELanguageTextType textid) const { #ifdef EDITOR_MODE const std::vector<SEnumData*>* pEnumDataList = nullptr; CEnumStrGenerator::GetInstance()->GetEnumValueData("ELanguageTextType", pEnumDataList); TString strEnumStr; if (pEnumDataList != nullptr) { for (size_t i = 0; i < pEnumDataList->size(); ++i) { if (pEnumDataList->at(i)->m_value == textid) { strEnumStr = pEnumDataList->at(i)->m_str; break; } } } if (!strEnumStr.empty()) { auto languageIter = m_languageMap.find(strEnumStr); if (languageIter != m_languageMap.end()) { auto realIter = languageIter->second.find(m_currLanguageType); if (realIter != languageIter->second.end()) { return realIter->second; } } } static TString UNKNOWN_STRING; TCHAR szBuffer[64]; _stprintf(szBuffer, "UnknownString: %d", textid); UNKNOWN_STRING = szBuffer; return UNKNOWN_STRING; #else auto iter = m_texts.find(textid); if (iter != m_texts.end()) { return iter->second; } else { static TString UNKNOWN_STRING; TCHAR szBuffer[64]; _stprintf(szBuffer, "UnknownString: %d", textid); UNKNOWN_STRING = szBuffer; return UNKNOWN_STRING; } #endif }
BOOL CALLBACK DlgNew::runProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: SetDefaultButton(IDOK); SendMessage(getParent(), NM_SETDIALOGLANG, (WPARAM)_hWnd, (LPARAM)"CODE"); return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK) { TString str = GetItemText(IDE_CODE_URL); str.trim(); if (str.empty()) { // msgBox(TEXT("请先输入完整信息"), TEXT("提示"), MB_ICONINFORMATION); FocusCtrl(IDE_CODE_URL); break; } // if (str.length() != 7) // { // int ans = msgBox(TEXT("一般CODE都7位的吧,是否重输?"), // TEXT("提醒"), MB_ICONQUESTION | MB_YESNO); // if (ans == IDYES) // { // FocusCtrl(IDE_CODE_URL); // break; // } // } //bool url = IsUrl(str); //用Post str会被释放了 //但Send又会阻塞。。干脆由接收那边释放好了 TCHAR *buffer = new TCHAR[str.length()+1]; lstrcpy(buffer, str.c_str()); ::PostMessage(getParent(),/* url ? NM_URLDOWN : */NM_CODEDOWNLOAD, 0, reinterpret_cast<LPARAM>(buffer)); destroy(); } break; case WM_CLOSE: destroy(); break; } return FALSE; }
TVector<TString> Split(const TString &s_inp, const TString &delimiter, const TString ¬_include) { TString s(s_inp); TVector<TString> out; if(s_inp.empty()) { return out; } size_t pos = 0; std::string acc_token; std::string token; while ((pos = s.find(delimiter)) != std::string::npos) { token = s.substr(0, pos); // cout << "token: " << token << "\n"; if((!not_include.empty()) && (token.find_first_of(not_include) != std::string::npos)) { if(!acc_token.empty()) { acc_token += delimiter; } acc_token += token; // cout << token << " " << acc_token << " 1\n"; } else { if(!acc_token.empty()) { // cout << token << " " << acc_token << " 2\n"; token = acc_token + delimiter + token; acc_token = std::string(); } out.push_back(Trim(token)); } s.erase(0, pos + delimiter.length()); } if(!acc_token.empty()) { // cout << s << " " << acc_token << " 3\n"; s = acc_token + delimiter + s; } out.push_back(Trim(s)); return out; }
/***************************************************************************** ** Procedure: CJTLine::OnSetAgentActivity ** ** Arguments: 'pReq' - Request object representing this SetAgentActivity event ** 'lpBuff' - Our CEventBlock* pointer ** ** Returns: void ** ** Description: This function manages the lineSetAgentActivity processing ** for this service provider. ** *****************************************************************************/ bool CJTLine::OnSetAgentActivity(RTSetAgentActivity* pRequest, LPCVOID /*lpBuff*/) { // Validate the activity itself and either reject it or allow it // to be set into the agent properties. The provider manages the agent // activities itself since the ACD doesn't support the concept. TString strActivity = GetDeviceInfo()->GetAgentActivityById(pRequest->GetActivity()); if (strActivity.empty()) CompleteRequest(pRequest, LINEERR_INVALAGENTACTIVITY); else CompleteRequest(pRequest, 0); // Let the request fall through to the unsolicited handler. return false; }// CJTLine::OnSetAgentActivity
void CEditLanguageDialog::OnRightClickOnGridLabel(wxGridEvent& event) { int nRow = event.GetRow(); int nCol = event.GetCol(); if (nCol == -1) { if (nRow == -1) { } else { wxMenu menu; menu.Append(0, _T("ChangeName")); menu.Append(1, _T("Delete")); int nRet = GetPopupMenuSelectionFromUser(menu, wxDefaultPosition); TString strOldLabel = m_pLanguageGrid->GetRowLabelValue(nRow); switch (nRet) { case 0: { TString strNewName = wxGetTextFromUser(_T("Input the new name please:"), wxGetTextFromUserPromptStr, strOldLabel); if (!strNewName.empty() && strOldLabel != strNewName) { bool bAddSuccess = ExamLanguageText(strNewName, true); if (bAddSuccess) { m_pLanguageGrid->SetRowLabelValue(nRow, strNewName); std::map<TString, std::map<ELanguageType, TString> >& languageMap = CLanguageManager::GetInstance()->GetLanguageMap(); languageMap[strNewName] = languageMap[strOldLabel]; languageMap.erase(strOldLabel); wxMessageBox(_T("更名成功")); } } } break; case 1: RemoveLanguageText(strOldLabel, nRow); break; case wxID_NONE: break; default: BEATS_ASSERT(false, _T("Never reach here!")); break; } } } }
static TString ProcessCommands(const _TCHAR *file) { FILE *fin; #ifdef UNICODE int err = _wfopen_s(&fin, file, L"r,ccs=unicode"); #else int err = fopen_s(&fin, file, "r"); #endif if (err) return TString(file); FILE *fout; auto output_file = TempFile::Create(TEXT(".txt"), true); #ifdef UNICODE err = _wfopen_s(&fout, output_file.data(), L"w,ccs=unicode"); #else err = fopen_s(&fout, output_file.data(), "w"); #endif if (err) { perror("LinkWrapper:ProcessCommands"); exit(err); } _TINT ch = _gettc(fin); while (ch != _TEOF) { while (ch != _TEOF && _istspace(ch)) { _puttc(ch, fout); ch = _gettc(fin); } // FIXME: input files with spaces in them??? (are they quoted???) TString word; while (ch != _TEOF && !_istspace(ch)) { word.push_back(ch); ch = _gettc(fin); } // FIXME: handle comments (starting with ';') auto comment_pos = word.find(TCHAR(';')); assert(comment_pos == -1 && "Found comment in command file"); if (!word.empty()) { auto new_word = ProcessArg(word.data()); _fputts(new_word.data(), fout); } } fclose(fin); fclose(fout); return output_file; }
// static TString TIntermTraverser::hash(const TString& name, ShHashFunction64 hashFunction) { if (hashFunction == NULL || name.empty()) return name; #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wshorten-64-to-32" #endif khronos_uint64_t number = (*hashFunction)(name.c_str(), name.length()); #if defined(__clang__) #pragma clang diagnostic pop #endif TStringStream stream; stream << HASHED_NAME_PREFIX << std::hex << number; TString hashedName = stream.str(); return hashedName; }
TString UniformHLSL::uniformBlocksHeader(const ReferencedSymbols &referencedInterfaceBlocks) { TString interfaceBlocks; for (ReferencedSymbols::const_iterator interfaceBlockIt = referencedInterfaceBlocks.begin(); interfaceBlockIt != referencedInterfaceBlocks.end(); interfaceBlockIt++) { const TType &nodeType = interfaceBlockIt->second->getType(); const TInterfaceBlock &interfaceBlock = *nodeType.getInterfaceBlock(); // nodeType.isInterfaceBlock() == false means the node is a field of a uniform block which // doesn't have instance name, so this block cannot be an array. unsigned int interfaceBlockArraySize = 0u; if (nodeType.isInterfaceBlock() && nodeType.isArray()) { interfaceBlockArraySize = nodeType.getOutermostArraySize(); } unsigned int activeRegister = mUniformBlockRegister; mUniformBlockRegisterMap[interfaceBlock.name().c_str()] = activeRegister; mUniformBlockRegister += std::max(1u, interfaceBlockArraySize); // FIXME: interface block field names if (interfaceBlock.hasInstanceName()) { interfaceBlocks += uniformBlockStructString(interfaceBlock); } if (interfaceBlockArraySize > 0) { for (unsigned int arrayIndex = 0; arrayIndex < interfaceBlockArraySize; arrayIndex++) { interfaceBlocks += uniformBlockString(interfaceBlock, activeRegister + arrayIndex, arrayIndex); } } else { interfaceBlocks += uniformBlockString(interfaceBlock, activeRegister, GL_INVALID_INDEX); } } return (interfaceBlocks.empty() ? "" : ("// Uniform Blocks\n\n" + interfaceBlocks)); }
/* ******************************************************************************** ************** FileSystem::AssureDirectoryPathSlashTerminated ****************** ******************************************************************************** */ TString FileSystem::AssureDirectoryPathSlashTerminated (const TString& dirPath) { if (dirPath.empty ()) { AssertNotReached (); // not sure if this is an error or not. Not sure how code used. // put assert in there to find out... Probably should THROW! // -- LGP 2009-05-12 return TString (&kPathComponentSeperator, &kPathComponentSeperator + 1); } else { //TChar lastChar = dirPath.back (); // try later - or not deendingon other code chnages - but didn;t' workw th gcc 4.5 TChar lastChar = dirPath[dirPath.size () - 1]; if (lastChar == kPathComponentSeperator) { return dirPath; } TString result = dirPath; result += kPathComponentSeperator; return result; } }
static TString ProcessInputFile(const _TCHAR *file) { // If the file name is surrounded by quotes, remove them auto input_file = StripQuotes(TString(file)); // If the file ends something other than .obj, skip it auto dot = PathFindExtension(input_file.c_str()); if (dot == nullptr) { // MSDN says that files without an extension get .obj appended input_file.append(TEXT(".obj")); } else if (_tcsicmp(dot, TEXT(".lib")) == 0) { auto tmp_file = TempFile::Create(TEXT(".lib"), true); auto trap_status = TRaPCOFFLibrary(input_file.c_str(), tmp_file.data()); #if 0 if (trap_status == TRaPStatus::TRAP_ERROR) { perror("LinkWrapper:ProcessInputFile:TRaPCOFFLibrary"); exit(-1); } #endif if (trap_status == TRaPStatus::TRAP_ADDED) return tmp_file; return input_file; } else if (_tcsicmp(dot, TEXT(".obj")) != 0 && _tcsicmp(dot, TEXT(".o")) != 0) // FIXME: create a list of allowed object file extensions (or let TRaPCOFFObject detect object files itself) return input_file; // Run TrapObj.exe <file.obj> <file.obj> // TODO: parallelize this (using WaitForMultipleObjects) // FIXME: output to a temporary file instead, and erase it afterwards // FIXME: Trap.cpp leaks some memory TString output_file = input_file; COFFObject coff_file; if (!coff_file.readFromFile(input_file.c_str())) return output_file; if (coff_file.createTRaPInfo()) { output_file = TempFile::Create(TEXT(".obj"), true); coff_file.writeToFile(output_file.c_str()); } // Mark this input file if it's the first if (first_object_name.empty()) first_object_name = input_file; return output_file; }
bool CSymbolEngine::LoadModuleSymbols( const TString& ImageName, DWORD64 ModBase, DWORD ModSize ) { // Check parameters if( ImageName.empty() ) { _ASSERTE( !_T("Empty module name.") ); m_LastError = ERROR_INVALID_PARAMETER; return false; } // Delegate the work to the more generic function return LoadModuleSymbols( NULL, ImageName, ModBase, ModSize ); }
TString GenericPlatform::GetConfigFileName() { TString result; TString basedir = GetPackageAppDirectory(); if (basedir.empty() == false) { basedir = FilePath::IncludeTrailingSlash(basedir); TString appConfig = basedir + GetAppName() + _T(".cfg"); if (FilePath::FileExists(appConfig) == true) { result = appConfig; } else { result = basedir + _T("package.cfg"); if (FilePath::FileExists(result) == false) { result = _T(""); } } } return result; }
TString UniformHLSL::uniformsHeader(ShShaderOutput outputType, const ReferencedSymbols &referencedUniforms) { TString uniforms; for (ReferencedSymbols::const_iterator uniformIt = referencedUniforms.begin(); uniformIt != referencedUniforms.end(); uniformIt++) { const TIntermSymbol &uniform = *uniformIt->second; const TType &type = uniform.getType(); const TString &name = uniform.getSymbol(); unsigned int registerIndex = declareUniformAndAssignRegister(type, name); if (outputType == SH_HLSL11_OUTPUT && IsSampler(type.getBasicType())) // Also declare the texture { uniforms += "uniform " + SamplerString(type) + " sampler_" + DecorateUniform(name, type) + ArrayString(type) + " : register(s" + str(registerIndex) + ");\n"; uniforms += "uniform " + TextureString(type) + " texture_" + DecorateUniform(name, type) + ArrayString(type) + " : register(t" + str(registerIndex) + ");\n"; } else { const TStructure *structure = type.getStruct(); // If this is a nameless struct, we need to use its full definition, rather than its (empty) name. // TypeString() will invoke defineNameless in this case; qualifier prefixes are unnecessary for // nameless structs in ES, as nameless structs cannot be used anywhere that layout qualifiers are // permitted. const TString &typeName = ((structure && !structure->name().empty()) ? QualifiedStructNameString(*structure, false, false) : TypeString(type)); const TString ®isterString = TString("register(") + UniformRegisterPrefix(type) + str(registerIndex) + ")"; uniforms += "uniform " + typeName + " " + DecorateUniform(name, type) + ArrayString(type) + " : " + registerString + ";\n"; } } return (uniforms.empty() ? "" : ("// Uniforms\n\n" + uniforms)); }
TString UniformHLSL::interfaceBlocksHeader(const ReferencedSymbols &referencedInterfaceBlocks) { TString interfaceBlocks; for (ReferencedSymbols::const_iterator interfaceBlockIt = referencedInterfaceBlocks.begin(); interfaceBlockIt != referencedInterfaceBlocks.end(); interfaceBlockIt++) { const TType &nodeType = interfaceBlockIt->second->getType(); const TInterfaceBlock &interfaceBlock = *nodeType.getInterfaceBlock(); unsigned int arraySize = static_cast<unsigned int>(interfaceBlock.arraySize()); unsigned int activeRegister = mInterfaceBlockRegister; mInterfaceBlockRegisterMap[interfaceBlock.name().c_str()] = activeRegister; mInterfaceBlockRegister += std::max(1u, arraySize); // FIXME: interface block field names if (interfaceBlock.hasInstanceName()) { interfaceBlocks += interfaceBlockStructString(interfaceBlock); } if (arraySize > 0) { for (unsigned int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { interfaceBlocks += interfaceBlockString(interfaceBlock, activeRegister + arrayIndex, arrayIndex); } } else { interfaceBlocks += interfaceBlockString(interfaceBlock, activeRegister, GL_INVALID_INDEX); } } return (interfaceBlocks.empty() ? "" : ("// Interface Blocks\n\n" + interfaceBlocks)); }