void CPdpManager::SortGroups() { //here is a little hack to sort the groups into the correct order so that they //will save out properly. GroupList gListSort = m_GroupList; sort(gListSort.begin(), gListSort.end()); for (int newIdx = 0; newIdx < (int)gListSort.size(); newIdx++) { if (gListSort[newIdx] != m_GroupList[newIdx]) { int oldIdx = 0; for (oldIdx = 0; oldIdx < (int)m_GroupList.size(); oldIdx++) { if (m_GroupList[oldIdx] == gListSort[newIdx]) { dprintf("%s - old: %d, new: %d\n", m_GroupList[oldIdx].c_str(), oldIdx, newIdx); break; } } assert(oldIdx != gListSort.size()); for (FileListItr itr = m_FileList.begin(); itr != m_FileList.end(); itr++) { if (itr->nGroupInx == oldIdx) { //set the new index to the negative value so it doesn't get re-remapped itr->nGroupInx = -newIdx; } } } } m_GroupList = gListSort; //fix the negative indexes. for (FileListItr itr = m_FileList.begin(); itr != m_FileList.end(); itr++) { if (itr->nGroupInx < 0) itr->nGroupInx = -itr->nGroupInx; } sort(m_FileList.begin(), m_FileList.end(), CPdpManager::SFileCompare); for (FileListItr itr = m_FileList.begin(); itr != m_FileList.end(); itr++) { dprintf(itr->filename.c_str()); dprintf("\n"); } }
/*! Insert Parameters in AST of given scad file form of annotations */ void CommentParser::collectParameters(const char *fulltext, FileModule *root_module) { // Get all groups of parameters GroupList groupList = collectGroups(std::string(fulltext)); int parseTill=getLineToStop(fulltext); // Extract parameters for all literal assignments for (auto &assignment : root_module->scope.assignments) { if (!assignment.expr.get()->isLiteral()) continue; // Only consider literals // get location of assignment node int firstLine = assignment.location().firstLine(); if(firstLine>=parseTill ) continue; // making list to add annotations AnnotationList *annotationList = new AnnotationList(); // Extracting the parameter comment std::string comment = getComment(std::string(fulltext), firstLine); // getting the node for parameter annnotataion shared_ptr<Expression> params = CommentParser::parser(comment.c_str()); if (!params) { params = shared_ptr<Expression>(new Literal(ValuePtr(std::string("")))); } // adding parameter to the list annotationList->push_back(Annotation("Parameter", params)); //extracting the description std::string descr = getDescription(std::string(fulltext), firstLine - 1); if (descr != "") { //creating node for description shared_ptr<Expression> expr(new Literal(ValuePtr(std::string(descr.c_str())))); annotationList->push_back(Annotation("Description", expr)); } // Look for the group to which the given assignment belong int i=0; for (;i<groupList.size() && groupList[i].lineNo<firstLine;i++); i--; if (i >= 0) { //creating node for description shared_ptr<Expression> expr(new Literal(ValuePtr(groupList[i].commentString))); annotationList->push_back(Annotation("Group", expr)); } assignment.addAnnotations(annotationList); } }