void CodeBrowser::LoadScope() { String find = ToUpper((String)~search); Value key = item.GetKey(); int sc = item.GetCursorSc(); item.Clear(); if(!scope.IsCursor()) return; Value x = scope.Get(2); int file = IsNumber(x) ? (int)x : -1; String scope = file < 0 ? String(x) : String(); int q = CodeBase().Find(scope); bool filematch = file >= 0 && MatchCib(GetFileText(GetSourceFilePath(file)), find); bool scopematch = !filematch && MatchCib(scope, find); if(q >= 0) { const Array<CppItem>& n = CodeBase()[q]; VectorMap<String, bool> inherited; if(file < 0) GatherMethods(scope, inherited, false); Index<String> set; for(int i = 0; i < n.GetCount(); i++) { CppItemInfo m; (CppItem&) m = n[i]; if((find.GetCount() && m.uname.StartsWith(find) || filematch && m.file == file || scopematch) && set.Find(m.qitem) < 0) { set.Add(m.qitem); int q = inherited.Find(m.qitem); if(q >= 0) { m.over = true; m.virt = m.virt || inherited[q]; } item.Add(m.qitem, RawToValue(m)); } } } item.Sort(1, sort ? ItemCompareLexical : ItemCompare); if(item.FindSetCursor(key)) item.ScCursor(sc); // clear.Enable(IsSearch()); }
void CPRApplication::PreprocessIncludes(char** saveto, char* sText, char* workdir) { // обработка инклудов ag::list<CPRTokenInfo>* pTok=new ag::list<CPRTokenInfo>; ParseIt(pTok,sText,true,true); ag::list<StartEndStruct> StartEndList; StartEndStruct ses; for(ag::list<CPRTokenInfo>::member p=pTok->head;(p!=NULL)&&(p->data.petCurrType!=petEOF);p=p->next) { if (p->data.sCurrText[0]=='#') { ses.start=p->data.iStartPos; do p=p->next; while (p->data.sCurrText[0]==' '); if (strcmp(p->data.sCurrText,"include")==0) { do p=p->next; while (p->data.sCurrText[0]==' '); int IncludeType = (p->data.sCurrText[0]=='"')?1:( (p->data.sCurrText[0]=='<')?2:-1 ); if (IncludeType==-1) throw "Invalid include directive"; if (IncludeType==1) { do p=p->next; while (p->data.sCurrText[0]==' '); std::string wd=workdir; if (workdir[strlen(workdir)-1]!='/') wd+='/'; std::string sPath; do{ sPath+=p->data.sCurrText; p=p->next;}while ((p->data.sCurrText[0]!='"')&&(p!=NULL)); do p=p->next; while (p->data.sCurrText[0]==' '); if (p==NULL) throw "Second brace is not found"; sPath=wd+sPath; if (debugmode) std::cout<<"Path: "<<sPath<<"\n"; if (debugmode) std::cout<<"Work: "<<wd <<"\n"; char** inc=new char*; ses.end=p->data.iStartPos; Preprocessing(inc,GetFileText((char*)sPath.c_str()),(char*)wd.c_str()); ses.data=inc; StartEndList.add_tail(ses); } if (IncludeType==2) { do p=p->next; while (p->data.sCurrText[0]==' '); char* incpath=getenv("CPROMPTINCLUDES"); if(incpath==NULL) { throw "(FATAL ERROR) Enviromnent variable CPROMPTINCLUDES is not initialized\n"; } std::string wd=incpath; if (incpath[strlen(incpath)-1]!='/') wd+='/'; std::string sPath; do{ sPath+=p->data.sCurrText; p=p->next;}while ((p->data.sCurrText[0]!='>')&&(p!=NULL)); do p=p->next; while (p->data.sCurrText[0]==' '); if (p==NULL) throw "Second brace is not found"; sPath=wd+sPath; if (debugmode) std::cout<<"Path: "<<sPath<<"\n"; if (debugmode) std::cout<<"Work: "<<wd <<"\n"; char** inc=new char*; ses.end=p->data.iStartPos; Preprocessing(inc,GetFileText((char*)sPath.c_str()),(char*)wd.c_str()); ses.data=inc; StartEndList.add_tail(ses); } } } } char* k; std::string res=""; int last=0; for(ag::list<StartEndStruct>::member p=StartEndList.head;(p!=NULL);p=p->next) { k=new char[p->data.start+1]; strncpy(k,sText+last,p->data.start-last); // if (debugmode) std::cout<<": "<<k<<"\n"; k[(p->data.start)-last]=0; res+=k; delete[] k; res+=*(char**)(p->data.data); last=p->data.end; } k=new char[strlen(sText)-last+1]; strncpy(k,sText+last,strlen(sText)-last); // if (debugmode) std::cout<<p->data.start<<' '<<p->data.end<<": "<<k; k[strlen(sText)-last]=0; res+=k; delete[] k; k=new char[res.size()+1]; strcpy(k,res.c_str()); k[res.size()]=0; ((saveto!=NULL)?*saveto:sPText) = k; }