/*! 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); } }
void PoolMemoryAllocator::flushPool(__uint16 nBytes) { #ifndef OGDF_MEMORY_POOL_NTS if(nBytes >= sizeof(MemElemEx)) { MemElemPtr pRestHead, pRestTail; int nRest; MemElemExPtr pStart = collectGroups(nBytes, pRestHead, pRestTail, nRest); s_criticalSection->enter(); PoolElement &pe = s_pool[nBytes]; while(pStart != 0) { incVectorSlot(pe); pe.m_currentVector->m_pool[pe.m_index] = MemElemPtr(pStart); pStart = pStart->m_down; } if(pRestHead != 0) { int n = slicesPerBlock(nBytes); pRestTail->m_next = pe.m_restTail; int nTotal = nRest + pe.m_restCount; if(nTotal >= n) { MemElemPtr p = pe.m_restHead; int i = n-nRest; while(--i > 0) p = p->m_next; pe.m_restHead = p->m_next; pe.m_restCount = nTotal-n; incVectorSlot(pe); pe.m_currentVector->m_pool[pe.m_index] = pRestHead; } else { pe.m_restHead = pRestHead; pe.m_restCount = nTotal; } } s_criticalSection->leave(); } else { s_criticalSection->enter(); flushPoolSmall(nBytes); s_criticalSection->leave(); } #endif }