void XMLSchemaWriter::writeGroupClassifierDecl (UMLClassifier *c, UMLClassifierList subclasses, QTextStream &XMLschema) { // name of class, subclassing classifiers QString elementTypeName = getElementGroupTypeName(c); // start Writing node but only if it has subclasses? Nah..right now put in empty group XMLschema<<getIndent()<<"<"<<makeSchemaTag("group")<<" name=\""<<elementTypeName<<"\">"<<m_endl; m_indentLevel++; XMLschema<<getIndent()<<"<"<<makeSchemaTag("choice")<<">"<<m_endl; m_indentLevel++; for(UMLClassifier *classifier = subclasses.first(); classifier; classifier = subclasses.next()) { writeAssociationRoleDecl(classifier, "1", XMLschema); } m_indentLevel--; XMLschema<<getIndent()<<"</"<<makeSchemaTag("choice")<<">"<<m_endl; m_indentLevel--; // finish node XMLschema<<getIndent()<<"</"<<makeSchemaTag("group")<<">"<<m_endl; }
void DebugVisitor::visitProject( ProjectAst *node ) { kDebug(9024) << getIndent() << "BEGIN(project)(" << getTokenInfo(node->startToken) << ")"; indent++; DefaultVisitor::visitProject( node ); indent--; kDebug(9024) << getIndent() << "END(project)(" << getTokenInfo(node->endToken) << ")"; }
void DebugVisitor::visitScopeBody( ScopeBodyAst *node ) { kDebug(9024) << getIndent() << "BEGIN(scope_body)(" << getTokenInfo(node->startToken) << ")"; indent++; DefaultVisitor::visitScopeBody( node ); indent--; kDebug(9024) << getIndent() << "END(scope_body)(" << getTokenInfo(node->endToken) << ")"; }
void DebugVisitor::visitVariableAssignment( VariableAssignmentAst *node ) { kDebug(9024) << getIndent() << "BEGIN(variable_assignment)(" << getTokenInfo(node->startToken) << ")"; indent++; DefaultVisitor::visitVariableAssignment( node ); indent--; kDebug(9024) << getIndent() << "END(variable_assignment)(" << getTokenInfo(node->endToken) << ")"; }
void DebugVisitor::visitValueList( ValueListAst *node ) { kDebug(9024) << getIndent() << "BEGIN(value_list)(" << getTokenInfo(node->startToken) << ")"; indent++; DefaultVisitor::visitValueList( node ); indent--; kDebug(9024) << getIndent() << "END(value_list)(" << getTokenInfo(node->endToken) << ")"; }
void DebugVisitor::visitArgumentList( ArgumentListAst *node ) { kDebug(9024) << getIndent() << "BEGIN(arg_list)(" << getTokenInfo(node->startToken) << ")"; indent++; DefaultVisitor::visitArgumentList( node ); indent--; kDebug(9024) << getIndent() << "END(arg_list)(" << getTokenInfo(node->startToken) << ")"; }
void DebugVisitor::visitFunctionArguments( FunctionArgumentsAst *node ) { kDebug(9024) << getIndent() << "BEGIN(function_args)(" << getTokenInfo(node->startToken) << ")"; indent++; DefaultVisitor::visitFunctionArguments( node ); indent--; kDebug(9024) << getIndent() << "END(function_args)(" << getTokenInfo(node->endToken) << ")"; }
void DebugVisitor::visitOrOperator( OrOperatorAst *node ) { kDebug(9024) << getIndent() << "BEGIN(or_op)(" << getTokenInfo(node->startToken) << ")"; indent++; DefaultVisitor::visitOrOperator( node ); indent--; kDebug(9024) << getIndent() << "END(or_op)(" << getTokenInfo(node->endToken) << ")"; }
void DebugVisitor::visitOp( OpAst *node ) { kDebug(9024) << getIndent() << "BEGIN(op)(" << getTokenInfo(node->startToken) << ")"; indent++; kDebug(9024) << getIndent() << "optoken =" << getTokenInfo(node->optoken); DefaultVisitor::visitOp( node ); indent--; kDebug(9024) << getIndent() << "END(op)(" << getTokenInfo(node->endToken) << "))"; }
void DebugVisitor::visitValue( ValueAst *node ) { kDebug(9024) << getIndent() << "BEGIN(value)(" << getTokenInfo(node->startToken) << ")"; indent++; kDebug(9024) << getIndent() << "value=" << getTokenInfo(node->value); DefaultVisitor::visitValue( node ); indent--; kDebug(9024) << getIndent() << "END(value)(" << getTokenInfo(node->endToken) << ")"; }
void DebugVisitor::visitItem( ItemAst *node ) { kDebug(9024) << getIndent() << "BEGIN(item)(" << getTokenInfo(node->startToken) << ")"; indent++; kDebug(9024) << getIndent() << "id=" << getTokenInfo(node->id); DefaultVisitor::visitItem( node ); indent--; kDebug(9024) << getIndent() << "END(item)(" << getTokenInfo(node->endToken) << ")"; }
void DebugVisitor::visitScope( ScopeAst *node ) { kDebug(9024) << getIndent() << "BEGIN(scope)(" << getTokenInfo(node->startToken) << ")"; indent++; visitNode( node->functionArguments ); visitNode( node->orOperator ); visitNode( node->scopeBody ); indent--; kDebug(9024) << getIndent() << "END(scope)(" << getTokenInfo(node->endToken) << ")"; }
void DebugVisitor::visitStatement( StatementAst *node ) { kDebug(9024) << getIndent() << "BEGIN(stmt)(" << getTokenInfo(node->startToken) << ")"; indent++; kDebug(9024) << getIndent() << "isExclam=" << node->isExclam; if( !node->isNewline ) { kDebug(9024) << getIndent() << "id=" << getTokenInfo(node->id); } DefaultVisitor::visitStatement( node ); indent--; kDebug(9024) << getIndent() << "END(stmt)(" << getTokenInfo(node->endToken) << ")"; }
int xmlStructure::dump_attribs_to_stdout ( TiXmlElement* pElement, unsigned int indent ) { if ( !pElement ) return 0; TiXmlAttribute* pAttrib = pElement->FirstAttribute(); int i = 0; int ival; double dval; const char* pIndent = getIndent ( indent ); printf ( "\n" ); while ( pAttrib ) { printf ( "%s%s: value=[%s]", pIndent, pAttrib->Name(), pAttrib->Value() ); if ( pAttrib->QueryIntValue ( &ival ) == TIXML_SUCCESS ) printf ( " int=%d", ival ); if ( pAttrib->QueryDoubleValue ( &dval ) == TIXML_SUCCESS ) printf ( " d=%1.1f", dval ); printf ( "\n" ); i++; pAttrib = pAttrib->Next(); } return i; }
void XMLSchemaWriter::writeAttributeDecl(UMLAttribute *attrib, QTextStream &XMLschema ) { QString documentation = attrib->getDoc(); QString typeName = fixTypeName(attrib->getTypeName()); bool isStatic = attrib->getStatic(); QString initialValue = fixInitialStringDeclValue(attrib->getInitialValue(), typeName); if(!documentation.isEmpty()) writeComment(documentation, XMLschema); XMLschema<<getIndent()<<"<"<<makeSchemaTag("attribute") <<" name=\""<<cleanName(attrib->getName())<<"\"" <<" type=\""<<typeName<<"\""; // default value? if(!initialValue.isEmpty()) { // IF its static, then we use "fixed", otherwise, we use "default" decl. // For the default decl, we _must_ use "optional" decl if(isStatic) XMLschema<<" use=\"required\" fixed=\""<<initialValue<<"\""; else XMLschema<<" use=\"optional\" default=\""<<initialValue<<"\""; } // finish decl XMLschema<<"/>"<<m_endl; }
/// \brief Get the indent of \p Level from \p IndentForLevel. /// /// \p IndentForLevel must contain the indent for the level \c l /// at \p IndentForLevel[l], or a value < 0 if the indent for /// that level is unknown. unsigned UnwrappedLineFormatter::getIndent(ArrayRef<int> IndentForLevel, unsigned Level) { if (IndentForLevel[Level] != -1) return IndentForLevel[Level]; if (Level == 0) return 0; return getIndent(IndentForLevel, Level - 1) + Style.IndentWidth; }
void XMLSchemaWriter::writeElementDecl( const QString &elementName, const QString &elementTypeName, QTextStream &XMLschema) { if(forceDoc()) writeComment(elementName+" is the root element, declared here.", XMLschema); XMLschema<<getIndent()<<"<"<<makeSchemaTag("element") <<" name=\""<<elementName<<"\"" <<" type=\""<<makePackageTag(elementTypeName)<<"\"" <<"/>"<<m_endl; }
void dump_to_stdout(TiXmlNode* pParent, unsigned int indent = 0) { if (!pParent) return; TiXmlNode* pChild; TiXmlText* pText; int t = pParent->Type(); printf("%s", getIndent(indent)); int num; switch (t) { case TiXmlNode::TINYXML_DOCUMENT: printf("Document"); break; case TiXmlNode::TINYXML_ELEMENT: printf("Element [%s]", pParent->Value()); num = dump_attribs_to_stdout(pParent->ToElement(), indent + 1); switch (num) { case 0: printf(" (No attributes)"); break; case 1: printf("%s1 attribute", getIndentAlt(indent)); break; default: printf("%s%d attributes", getIndentAlt(indent), num); break; } break; case TiXmlNode::TINYXML_COMMENT: printf("Comment: [%s]", pParent->Value()); break; case TiXmlNode::TINYXML_UNKNOWN: printf("Unknown"); break; case TiXmlNode::TINYXML_TEXT: pText = pParent->ToText(); printf("Text: [%s]", pText->Value()); break; case TiXmlNode::TINYXML_DECLARATION: printf("Declaration"); break; default: break; } printf("\n"); for (pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) { dump_to_stdout(pChild, indent + 1); } }
void XMLSchemaWriter::writeAttributeGroupDecl (const QString &elementName, UMLAttributeList &attribs, QTextStream &XMLschema ) { if (attribs.count()> 0) { // write a little documentation writeComment("attributes for element "+elementName,XMLschema); // open attribute group XMLschema<<getIndent()<<"<"<<makeSchemaTag("attributeGroup")<<" name=\""<<elementName+"AttribGroupType"<<"\">"<<m_endl; m_indentLevel++; for( UMLAttribute *at=attribs.first(); at; at=attribs.next()) { writeAttributeDecl(at,XMLschema); } m_indentLevel--; // close attrib group node XMLschema<<getIndent()<<"</"<<makeSchemaTag("attributeGroup")<<">"<<m_endl; } }
void TraceManager::print(string msg) { time_t now = time(NULL); char buf[21]; if(!strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S ", localtime(&now))) { strcpy(buf, "xxxx-xx-xx xx:xx:xx "); } const string indent = string(getIndent(GetCurrentThreadId()), ' '); Lock l(cs); try { f->write(buf + indent + msg + "\r\n"); } catch (const FileException&) { // ... } }
void XMLSchemaWriter::writeComment( const QString &comment, QTextStream &XMLschema ) { // in the case we have several line comment.. // NOTE: this part of the method has the problem of adopting UNIX newline, // need to resolve for using with MAC/WinDoze eventually I assume QString indent = getIndent(); XMLschema<<indent<<"<!-- "; if (comment.contains(QRegExp("\n"))) { XMLschema<<m_endl; QStringList lines = QStringList::split( "\n", comment); for(uint i= 0; i < lines.count(); i++) XMLschema<<indent<<" "<<lines[i]<<m_endl; XMLschema<<indent<<"-->"<<m_endl; } else { // this should be more fancy in the future, breaking it up into 80 char // lines so that it doesn't look too bad XMLschema<<comment<<" -->"<<m_endl; } }
void VisualStudioProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation, const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) { const std::string indentString = getIndent(indentation + 2); if (indentation) projectFile << getIndent(indentation + 1) << "<Filter\tName=\"" << dir.name << "\">\n"; for (FileNode::NodeList::const_iterator i = dir.children.begin(); i != dir.children.end(); ++i) { const FileNode *node = *i; if (!node->children.empty()) { writeFileListToProject(*node, projectFile, indentation + 1, duplicate, objPrefix + node->name + '_', filePrefix + node->name + '/'); } else { if (producesObjectFile(node->name)) { std::string name, ext; splitFilename(node->name, name, ext); name += ".o"; std::transform(name.begin(), name.end(), name.begin(), tolower); const bool isDuplicate = (std::find(duplicate.begin(), duplicate.end(), name) != duplicate.end()); if (ext == "asm") { std::string objFileName = "$(IntDir)\\"; if (isDuplicate) objFileName += objPrefix; objFileName += "$(InputName).obj"; const std::string toolLine = indentString + "\t\t<Tool Name=\"VCCustomBuildTool\" CommandLine=\"nasm.exe -f win32 -g -o "" + objFileName + "" "$(InputPath)"
\" Outputs=\"" + objFileName + "\" />\n"; // NASM is not supported for x64, thus we do not need to add additional entries here :-). projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\">\n" << indentString << "\t<FileConfiguration Name=\"Debug|Win32\">\n" << toolLine << indentString << "\t</FileConfiguration>\n" << indentString << "\t<FileConfiguration Name=\"Analysis|Win32\">\n" << toolLine << indentString << "\t</FileConfiguration>\n" << indentString << "\t<FileConfiguration Name=\"Release|Win32\">\n" << toolLine << indentString << "\t</FileConfiguration>\n" << indentString << "</File>\n"; } else { if (isDuplicate) { const std::string toolLine = indentString + "\t\t<Tool Name=\"VCCLCompilerTool\" ObjectFile=\"$(IntDir)\\" + objPrefix + "$(InputName).obj\" XMLDocumentationFileName=\"$(IntDir)\\" + objPrefix + "$(InputName).xdc\" />\n"; projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\">\n" << indentString << "\t<FileConfiguration Name=\"Debug|Win32\">\n" << toolLine << indentString << "\t</FileConfiguration>\n" << indentString << "\t<FileConfiguration Name=\"Analysis|Win32\">\n" << toolLine << indentString << "\t</FileConfiguration>\n" << indentString << "\t<FileConfiguration Name=\"Release|Win32\">\n" << toolLine << indentString << "\t</FileConfiguration>\n" << indentString << "\t<FileConfiguration Name=\"Debug|x64\">\n" << toolLine << indentString << "\t</FileConfiguration>\n" << indentString << "\t<FileConfiguration Name=\"Analysis|x64\">\n" << toolLine << indentString << "\t</FileConfiguration>\n" << indentString << "\t<FileConfiguration Name=\"Release|x64\">\n" << toolLine << indentString << "\t</FileConfiguration>\n" << indentString << "</File>\n"; } else { projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\" />\n"; } } } else { projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\" />\n"; } } } if (indentation) projectFile << getIndent(indentation + 1) << "</Filter>\n"; }
char* indentLeft() { return getIndent(--g_indent, 0); }
char* indentRight() { return getIndent(g_indent++, 1); }
virtual void processInclude( QMake::IncludeAST* a) { kdDebug(9024) << getIndent() << "Include: " << replaceWs(a->projectName) << endl; QMake::ASTVisitor::processInclude(a); }
virtual void enterRealProject( QMake::ProjectAST* p ) { kdDebug(9024) << getIndent() << "--------- Entering Project: " << replaceWs(p->fileName()) << "| LineEnding:" << p->lineEnding() << " --------------" << endl; indent += 4; QMake::ASTVisitor::enterRealProject(p); }
virtual void leaveRealProject( QMake::ProjectAST* p ) { indent -= 4; kdDebug(9024) << getIndent() << "--------- Leaving Project: " << replaceWs(p->fileName()) << " --------------" << endl; QMake::ASTVisitor::leaveRealProject(p); }
virtual void enterFunctionScope( QMake::ProjectAST* p ) { kdDebug(9024) << getIndent() << "--------- Entering FunctionScope: " << replaceWs(p->scopedID) << "(" << replaceWs(p->args) << ")"<< " --------------" << endl; indent += 4; QMake::ASTVisitor::enterFunctionScope(p); }
virtual void leaveFunctionScope( QMake::ProjectAST* p ) { indent -= 4; kdDebug(9024) << getIndent() << "--------- Leaving FunctionScope: " << replaceWs(p->scopedID) << "(" << replaceWs(p->args) << ")"<< " --------------" << endl; QMake::ASTVisitor::leaveFunctionScope(p); }
/* ---- example xml handler */ void* handler (SimpleXmlParser parser, SimpleXmlEvent event, const char* szName, const char* szAttribute, const char* szValue) { static int nDepth= 0; char *tmp; char szHandlerName[32]; char szHandlerAttribute[32]; char *szHandlerValue; //struct socket_data *news; //struct core_data *newc; //struct thread_data *newt; int last_cid=0; szHandlerValue=malloc(32); memset(szHandlerValue,0,32); if (szName != NULL) { trim(szName, szHandlerName); } if (szAttribute != NULL) { trim(szAttribute, szHandlerAttribute); } if (szValue != NULL) { trim(szValue, szHandlerValue); } if (event == ADD_SUBTAG) { fprintf(stderr,"depth: %d, val: %s\n",nDepth,szHandlerName); fprintf(stderr, "%6li: %s add subtag (%s)\n", simpleXmlGetLineNumber(parser), getIndent(nDepth), szHandlerName); nDepth++; } else if (event == ADD_ATTRIBUTE) { // printf("attribute tag:%s %s=%s\n",szHandlerName, szHandlerAttribute, szHandlerValue); fprintf(stderr, "%6li: %s ///add attribute to tag %s ([%s]=[%s])\n", simpleXmlGetLineNumber(parser), getIndent(nDepth), szHandlerName, szHandlerAttribute, szHandlerValue); if ( (!strcmp(szHandlerAttribute,"cache-level")) && (!strcmp(szHandlerValue,"3")) ) { //attribute cache-level=3 detected: new L3 domain fprintf(stderr,"\n* NEW SOCKET *\n"); new_socket(last_sid,last_sid); push_socket_id(last_sid); last_sid++; level=3; } if ( (!strcmp(szHandlerAttribute,"name")) && (!strcmp(szHandlerValue,"SMT")) ) { //attribute cache-level=2 detected: new L2 domain fprintf(stderr,"\n * NEW CORE, Sock %d * \n", last_sid - 1); //uncomment for noSMP: //level=10; //ucomment for SMP: last_cid=pop_core_id(); new_core(0,last_cid,last_sid - 1); } else if ( (!strcmp(szHandlerAttribute,"name")) && (!strcmp(szHandlerValue,"THREAD")) ) { //attribute cache-level=2 detected: new L2 domain fprintf(stderr,"\n* NEW THREAD, Sock %d *\n", last_sid - 1); last_cid=pop_core_id(); new_thread(0,last_cid,last_sid - 1); } if ( (!strcmp(szHandlerAttribute,"level")) && (!strcmp(szHandlerValue,"3")) ) { //no cpu count="2"/SMT/THREAD Routing! level=300; } else if ( (!strcmp(szHandlerAttribute,"level")) && (!strcmp(szHandlerValue,"2")) ) { //attribute cache-level=2 detected: new L2 domain fprintf(stderr,"\n* !NEW LOGICAL CORE %d!, Sock: %d*\n", last_cid,last_sid - 1); //We have "cpu count="2" and SMT/THREAD flag name level=200; } } else if (event == ADD_CONTENT) { fprintf(stderr,"depth: %d, LEVEL %d, context for:[%s] [%s]\n",nDepth,level,szHandlerName, szHandlerValue); if (level==200) { if (!strcmp(szHandlerName,"cpu")) { fprintf(stderr," !ROUTE LEVEL 10: Cores ID processed: %s, SOCKET: %d\n",szHandlerValue, last_sid - 1 ); while ((tmp = strsep(&szHandlerValue, ",")) != NULL) { if (tmp[0] == '\0') break; /* XXX */ trim_spaces(tmp); // comment for no SMP? push_core_id(atoi(tmp)); fprintf(stderr,"\n\n\nHA: [%d]\n\n\n",atoi(tmp)); // uncomment for no SMP: // last_cid=pop_core_id(); // new_core(0,atoi(tmp),last_sid - 1); } // drop level // level=9; } } else if (level==300) { //no cpu count="2"/SMT/THREAD Routing! if (!strcmp(szHandlerName,"cpu")) { fprintf(stderr," !ROUTE LEVEL 10: Cores ID processed: %s, SOCKET: %d\n",szHandlerValue, last_sid - 1 ); while ((tmp = strsep(&szHandlerValue, ",")) != NULL) { if (tmp[0] == '\0') break; /* XXX */ trim_spaces(tmp); // comment for no SMP? push_core_id(atoi(tmp)); fprintf(stderr,"\n\n\nHA: [%d]\n\n\n",atoi(tmp)); // uncomment for no SMP: last_cid=pop_core_id(); new_core(0,atoi(tmp),last_sid - 1); } // drop level // level=9; } } fprintf(stderr, "%6li: %s add content to tag %s (%s)\n", simpleXmlGetLineNumber(parser), getIndent(nDepth), szHandlerName, szHandlerValue); } else if (event == FINISH_ATTRIBUTES) { fprintf(stderr,"finish for:%s\n",szHandlerName); fprintf(stderr, "%6li: %s finish attributes (%s)\n", simpleXmlGetLineNumber(parser), getIndent(nDepth), szHandlerName); } else if (event == FINISH_TAG) { fprintf(stderr,"finish for:%s\n",szHandlerName); fprintf(stderr, "%6li: %s finish tag (%s)\n", simpleXmlGetLineNumber(parser), getIndent(nDepth), szHandlerName); nDepth--; if (level==10) { if (!strcmp(szHandlerName,"cpu")) level=0; } } //list_sockets(); return handler; }