void TKVList::FromAttributes (LPCTSTR szIn) { LPCTSTR cp; LPCTSTR tok; TCHAR keyBuf[128]; TCHAR valueBuf[128]; int count = 0; if ( *szIn != 0) { tok = cp = szIn; do { cp++; if (*cp == 0) //found token { LPCTSTR cp2 = _tcschr (tok, '='); if (cp2) { _tcsncpy (keyBuf, tok, cp2 - tok); keyBuf[cp2 - tok] = 0; tok = cp2 + 1; _tcscpy (valueBuf, tok); Define (keyBuf, valueBuf); count++; } tok = cp + 1; } } while ( !(*cp == 0 && *(cp + 1) == 0) && count < MAXPAIRS); } }
void TKVList::Merge (TKVList &l) { index_t i; for (i = 0; i < l.Count (); i++) Define (l.Key (i), l.Value (i)); }
void Plane::Define(const Vector3& v0, const Vector3& v1, const Vector3& v2) { CHECK_ASSERT(NSG::Distance(v0, v1) > 0.0001f); CHECK_ASSERT(NSG::Distance(v0, v2) > 0.0001f); Vector3 dist1 = v1 - v0; Vector3 dist2 = v2 - v0; Define(Normalize(Cross(dist1, dist2)), v1); }
/*VARIABLES FUNCTION Define: READS AND STORES VARIABLES*/ string VARIABLES::Define(ifstream &Input) { //DECLARE LOCAL VARIABLES string Read_Next(ifstream &Input); string str; int i; char c; const int n = 7; int delim[n] = {9,10,13,32,44,61,124};/*{'\t','\n','?CR?',' ',',','=','|'}*/ //GET VARIABLE NAME (WITHOUT LETTING Read_Next TRY TO REPLACE) str.clear(); while (Input.get(c)) { //Check for comments if(int(c)=='%') { Input.ignore(10001, '\n'); continue; } //Check for deliminators for(i=0;i<n;i++) { if(int(c)==delim[i]) { i=-1; break; } } if(i!=-1) {str += c;break;} } if(int(c)!='$') { //Not a valid variable name (return) Input.putback(c); return(Read_Next(Input)); } str = Read_Next(Input);//NOTE: this allows deliminators between '$' and varaible name str.insert(0, "$"); //FIND VARIABLE TO REDEFINE IT OR FIND UNUSED SLOT VARIABLES *var = this; while(var!=var->next) { if(str.compare(var->symb)==0) {break;} var = var->next; } //STORE SYMBOL AND VALUE var->symb = str; str = Read_Next(Input); i = int(str[0]); if( (i<43)||(i>57)||(i==44)||(i==47) ) {//Check if a number is present Log <<str<<" is not a valid expression for variable "<<var->symb<<endl; exit(0); } var->value = atof(str.c_str()); if(var==var->next) {var->next = new VARIABLES();}//Allocate memory for next variable return(Define(Input)); }
bool Preprocessor::HandleVersion(size_t line_no, Tokenizer & tok){ if (!tok.next_token()){ throw Exception::Error("Bad version"); } Define("__INTERNAL VERSION", tok.get_remaining()); currentData += '\n'; return true; }
void ConstantBuffer::Recreate() { if (constants.Size()) { // Make a copy of the current constants, as they are passed by reference and manipulated by Define() Vector<Constant> srcConstants = constants; Define(usage, srcConstants); Apply(); } }
void TKVList::FromDSN (LPCTSTR szIn) { TCHAR *index[MAXPAIRS]; TCHAR *dsn; TCHAR *cp; int count; int i; TCHAR *tok; if ((dsn = _tcsdup (szIn)) == NULL) return; count = 0; int found = 0; int br = 0; for (tok = cp = dsn; *cp != 0 && count < MAXPAIRS; cp++) switch (*cp) { case ';': // found token if (br == 0) { *cp = 0; index[count++] = tok; tok = cp + 1; } break; case '{': br++; break; case '}': br--; break; } if (tok < cp && *cp == 0 && count < MAXPAIRS) { index[count++] = tok; } for (i = 0; i < count; i++) { LPCTSTR key = index[i]; PTSTR value; if ((value = (PTSTR)_tcschr (key, '=')) != NULL) { *value = 0; value++; } Define (key, value); } free (dsn); }
void TKVList::ReadODBCIni (LPCTSTR section, LPCTSTR names) { TCHAR value[512]; LPCTSTR key; for (key = names; *key; key += _tcslen (key) + 1) { SQLGetPrivateProfileString (section, key, _T(" "), value, NUMCHARS (value), _T("odbc.ini")); if (_tcscmp (value, _T(" "))) Define (key, value); } }
void Frustum::DefineOrtho(float orthoSize, float aspectRatio, float zoom, float nearZ, float farZ, const Matrix3x4& transform) { nearZ = Max(nearZ, 0.0f); farZ = Max(farZ, nearZ); float halfViewSize = orthoSize * 0.5f / zoom; Vector3 near, far; near.z_ = nearZ; far.z_ = farZ; far.y_ = near.y_ = halfViewSize; far.x_ = near.x_ = near.y_ * aspectRatio; Define(near, far, transform); }
bool Preprocessor::HandlePragma(size_t line_no, Tokenizer & tok){ if (!tok.next_token()){ throw Exception::Error("Bad Pragma"); } if (tok == "once"){ std::string name = "___ONCE_INCLUDE " + currentSection + "?" + filedata.name(); if (currentSection == limitSection){ Define(name, ""); currentData += '\n'; } return true; } return false; }
bool DefinePrefable(JSContext* cx, JSObject* obj, Prefable<T>* props) { MOZ_ASSERT(props); MOZ_ASSERT(props->specs); do { // Define if enabled if (props->enabled) { if (!Define(cx, obj, props->specs)) { return false; } } } while ((++props)->specs); return true; }
void Frustum::Define(float fov, float aspectRatio, float zoom, float nearZ, float farZ, const Matrix3x4& transform) { nearZ = Max(nearZ, 0.0f); farZ = Max(farZ, nearZ); float halfViewSize = tanf(fov * M_DEGTORAD_2) / zoom; Vector3 near, far; near.z_ = nearZ; near.y_ = near.z_ * halfViewSize; near.x_ = near.y_ * aspectRatio; far.z_ = farZ; far.y_ = far.z_ * halfViewSize; far.x_ = far.y_ * aspectRatio; Define(near, far, transform); }
void TKVList::ReadFileDSN (LPCTSTR filename, LPCTSTR names) { TCHAR value[512]; LPCTSTR key; WORD len; for (key = names; *key; key += _tcslen (key) + 1) { value[0] = 0; if (SQLReadFileDSN (filename, _T("ODBC"), key, value, NUMCHARS (value), &len)) { Define (key, value); } } }
void Define::visit_module(ast::Module& x) { // Get the existing module-item auto item = _ctx.modules_by_context[&x]; if (!item) return; // Add the module initializer basic block auto last_block = LLVMGetInsertBlock(_ctx.irb); auto block = LLVMAppendBasicBlock(item->initializer, ""); LLVMPositionBuilderAtEnd(_ctx.irb, block); // Define any items that need forward declarations. Define(_ctx, item->scope).run(*x.block); // Move instruction ptr back to where it was (if it was somewhere) if (last_block) { LLVMPositionBuilderAtEnd(_ctx.irb, last_block); } }
bool Texture::EndLoad() { if (loadImages.IsEmpty()) return false; Vector<ImageLevel> initialData; for (size_t i = 0; i < loadImages.Size(); ++i) { for (size_t j = 0; j < loadImages[i]->NumLevels(); ++j) initialData.Push(loadImages[i]->Level(j)); } Image* image = loadImages[0]; bool success = Define(TEX_2D, USAGE_IMMUTABLE, image->Size(), image->Format(), initialData.Size(), &initialData[0]); /// \todo Read a parameter file for the sampling parameters success &= DefineSampler(FILTER_TRILINEAR, ADDRESS_WRAP, ADDRESS_WRAP, ADDRESS_WRAP); loadImages.Clear(); return success; }
void tdf004_cutFlowReport() { // We prepare an input tree to run on auto fileName = "tdf004_cutFlowReport.root"; auto treeName = "myTree"; fill_tree(fileName, treeName); // We read the tree from the file and create a TDataFrame ROOT::Experimental::TDataFrame d(treeName, fileName, {"b1", "b2"}); // ## Define cuts and create the report // Here we define two simple cuts auto cut1 = [](double b1) { return b1 > 25.; }; auto cut2 = [](int b2) { return 0 == b2 % 2; }; // An optional string parameter name can be passed to the Filter method to create a named filter. // Named filters work as usual, but also keep track of how many entries they accept and reject. auto filtered1 = d.Filter(cut1, {"b1"}, "Cut1"); auto filtered2 = d.Filter(cut2, {"b2"}, "Cut2"); auto augmented1 = filtered2.Define("b3", [](double b1, int b2) { return b1 / b2; }); auto cut3 = [](double x) { return x < .5; }; auto filtered3 = augmented1.Filter(cut3, {"b3"}, "Cut3"); // Statistics are retrieved through a call to the Report method: // when Report is called on the main TDataFrame object, it prints stats for all named filters declared up to that // point // when called on a stored chain state (i.e. a chain/graph node), it prints stats for all named filters in the // section // of the chain between the main TDataFrame and that node (included). // Stats are printed in the same order as named filters have been added to the graph, and refer to the latest // event-loop that has been run using the relevant TDataFrame. std::cout << "Cut3 stats:" << std::endl; filtered3.Report(); std::cout << "All stats:" << std::endl; d.Report(); }
bool Preprocessor::HandleInclude(size_t line_no, Tokenizer & tok){ bool issection = false; if (tok.next_token() == "section"){ issection = true; tok.next_token(); } if (tok.get_type() != Tokenizer::Type::String){ throw Exception::Error("Include name must be quoted string; got `" + tok.get_string() + "`."); } MappedFile mfile; std::string section = ""; if (issection){ section = tok.get_string(); trim_ends(section); mfile = filedata; } else{ std::string file = tok; trim_ends(file); size_t pos = file.find_first_of("?"); if (pos != std::string::npos){ section = file.substr(pos + 1); file.erase(file.begin() + pos, file.end()); } else{ if (tok.next_token()){ if (tok == "section"){ if (tok.next_token().get_type() == Tokenizer::Type::String){ section = tok.get_string(); trim_ends(section); } else{ throw Exception::Error("String expected after `section`; got `" + tok.get_string() + "`."); } } else{ throw Exception::Error("Unknown include specifier `" + tok.get_string() + "`. Did you mean to use `section`?"); } } } mfile = MappedFile(file, include_paths); } size_t file_number;// = push_file(filenames, mfile.name()); std::string test_name = "___ONCE_INCLUDE " + section + "?" + mfile.name(); if (Defined(section, test_name)){ currentData.push_back('\n'); return true; } //currentData += "#line 1 " + std::to_string(file_number) + "\n"; defines.push_back(§ions[currentSection].defines); Preprocessor p = Preprocessor(mfile, include_paths, defines, filenames, section); auto newSections = p.Preprocess(); auto& back = *defines.back(); defines.pop_back(); for (auto & def : back){ Define(def.first, def.second); } file_number = push_file(filenames, filedata.name()); currentData += newSections.at(section).data; currentData.push_back('\n'); currentData += "#line " + std::to_string(line_no) + " " + std::to_string(file_number) + "\n"; return true; }
void Plane::Transform(const Matrix4& transform) { Define(transform.Inverse().Transpose() * ToVector4()); }
void Sphere::Define(const Frustum& frustum) { Define(frustum.vertices_, NUM_FRUSTUM_VERTICES); }
Plane::Plane(const Vector3& normal, const Vector3& point) { Define(normal, point); }
Scene( ) { Define( ); }
void BoundingBox::Define(const Frustum& frustum) { Clear(); Define(frustum.vertices_, NUM_FRUSTUM_VERTICES); }
Frustum::Frustum(const Matrix4& VP) : m_(VP) { Define(); }
Plane::Plane(const Vector3& v0, const Vector3& v1, const Vector3& v2) { Define(v0, v1, v2); }
Polyhedron::Polyhedron(const BoundingBox& box) { Define(box); }
//{ CppCheck int CppCheck::ExecuteCppCheck(cbProject* Project) { if ( !DoVersion(_T("cppcheck"), _T("cppcheck_app")) ) return -1; TCppCheckAttribs CppCheckAttribs; wxFile InputFile; CppCheckAttribs.InputFileName = _T("CppCheckInput.txt"); if ( !InputFile.Create(CppCheckAttribs.InputFileName, true) ) { cbMessageBox(_("Failed to create input file 'CppCheckInput.txt' for cppcheck.\nPlease check file/folder access rights."), _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow()); return -1; } for (FilesList::iterator it = Project->GetFilesList().begin(); it != Project->GetFilesList().end(); ++it) { ProjectFile* pf = *it; // filter to avoid including non C/C++ files if ( pf->relativeFilename.EndsWith(FileFilters::C_DOT_EXT) || pf->relativeFilename.EndsWith(FileFilters::CPP_DOT_EXT) || pf->relativeFilename.EndsWith(FileFilters::CC_DOT_EXT) || pf->relativeFilename.EndsWith(FileFilters::CXX_DOT_EXT) || pf->relativeFilename.EndsWith(FileFilters::CPLPL_DOT_EXT) || (FileTypeOf(pf->relativeFilename) == ftHeader) || (FileTypeOf(pf->relativeFilename) == ftTemplateSource) ) { InputFile.Write(pf->relativeFilename + _T("\n")); } } InputFile.Close(); MacrosManager* MacrosMgr = Manager::Get()->GetMacrosManager(); ProjectBuildTarget* Target = Project->GetBuildTarget(Project->GetActiveBuildTarget()); // project include dirs const wxArrayString& IncludeDirs = Project->GetIncludeDirs(); for (unsigned int Dir = 0; Dir < IncludeDirs.GetCount(); ++Dir) { wxString IncludeDir(IncludeDirs[Dir]); if (Target) MacrosMgr->ReplaceMacros(IncludeDir, Target); else MacrosMgr->ReplaceMacros(IncludeDir); CppCheckAttribs.IncludeList += _T("-I\"") + IncludeDir + _T("\" "); } if (Target) { // target include dirs const wxArrayString& targetIncludeDirs = Target->GetIncludeDirs(); for (unsigned int Dir = 0; Dir < targetIncludeDirs.GetCount(); ++Dir) { wxString IncludeDir(targetIncludeDirs[Dir]); MacrosMgr->ReplaceMacros(IncludeDir, Target); CppCheckAttribs.IncludeList += _T("-I\"") + IncludeDir + _T("\" "); } } // project #defines const wxArrayString& Defines = Project->GetCompilerOptions(); for (unsigned int Opt = 0; Opt < Defines.GetCount(); ++Opt) { wxString Define(Defines[Opt]); if (Target) MacrosMgr->ReplaceMacros(Define, Target); else MacrosMgr->ReplaceMacros(Define); if ( Define.StartsWith(_T("-D")) ) CppCheckAttribs.DefineList += Define + _T(" "); } if (Target) { // target #defines const wxArrayString& targetDefines = Target->GetCompilerOptions(); for (unsigned int Opt = 0; Opt < targetDefines.GetCount(); ++Opt) { wxString Define(targetDefines[Opt]); MacrosMgr->ReplaceMacros(Define, Target); if ( Define.StartsWith(_T("-D")) ) CppCheckAttribs.DefineList += Define + _T(" "); } } return DoCppCheckExecute(CppCheckAttribs); }
Polyhedron::Polyhedron(const Frustum& frustum) { Define(frustum); }