void LoadTransform( Transformation *trans, TiXmlElement *element, int level ) { for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) { if ( COMPARE( child->Value(), "scale" ) ) { Point3 s(1,1,1); ReadVector( child, s ); trans->Scale(s.x,s.y,s.z); PrintIndent(level); printf(" scale %f %f %f\n",s.x,s.y,s.z); } else if ( COMPARE( child->Value(), "rotate" ) ) { Point3 s(0,0,0); ReadVector( child, s ); s.Normalize(); float a; ReadFloat(child,a,"angle"); trans->Rotate(s,a); PrintIndent(level); printf(" rotate %f degrees around %f %f %f\n", a, s.x, s.y, s.z); } else if ( COMPARE( child->Value(), "translate" ) ) { Point3 t(0,0,0); ReadVector(child,t); trans->Translate(t); PrintIndent(level); printf(" translate %f %f %f\n",t.x,t.y,t.z); } } }
void JsonArrayValue::Print(FILE * stream, int indent, bool indentFirst) { if (indentFirst) { PrintIndent(stream, indent); } ::fprintf(stream, "[\n"); ValuesList::iterator last = values_.end(); --last; for (ValuesList::iterator itr = values_.begin(); itr != values_.end(); ++itr) { if (*itr == 0) { PrintNull(stream, indent + 1); } else { (*itr)->Print(stream, indent + 1, true); } if (itr != last) { ::fprintf(stream, ","); } ::fprintf(stream, "\n"); } PrintIndent(stream, indent); ::fprintf(stream, "]"); }
void JsonObjectValue::Print(FILE * stream, int indent, bool indentFirst) { if (indentFirst) { PrintIndent(stream, indent); } ::fprintf(stream, "{\n"); ValuesList::iterator last = values_.end(); --last; for (ValuesList::iterator itr = values_.begin(); itr != values_.end(); ++itr) { PrintIndent(stream, indent + 1); ::fprintf(stream, "\"%s\" : ", EscapeString(itr->first).c_str()); if (itr->second == 0) { PrintNull(stream, 0); } else { itr->second->Print(stream, indent + 1, false); } if (itr != last) { ::fprintf(stream, ","); } ::fprintf(stream, "\n"); } PrintIndent(stream, indent); ::fprintf(stream, "}"); }
/* in this, the SubName is for the text interface version, the xml_name is for the gui interface, and the SubDesc is for a longer description that will go with the option in GuiLiner */ void OpenSubset(const char *SubName, const char *xml_name, const char *SubDesc, int *IndentLevel, int CommentLevel) { switch(CommentLevel) { case(1): /* short comment, long comment, and nroff --- it's the same */ case(2): case(3): printf("\n **** %s ****\n\n",SubName); return; break; case(4): /* for xml output it's a little more interesting */ PrintIndent(*IndentLevel); printf("<subset>\n"); *IndentLevel += 1; PrintIndent(*IndentLevel); if(strlen(xml_name)>0) { printf("<subset_name>%s</subset_name>\n",xml_name); } else { printf("<subset_name>%s</subset_name>\n",SubName); } PrintIndent(*IndentLevel); printf("<subset_description>%s</subset_description>\n",SubDesc); break; } }
void Scan(const wchar_t*folder, int depth=0) { PrintIndent(depth); wprintf(L"[%s]\n",folder); wchar_t path[0x1000]; swprintf_s(path,sizeof(path)/sizeof(wchar_t),L"%s\\*",folder); WIN32_FIND_DATA data; HANDLE find = FindFirstFile(path,&data); if (find!=NULL) { do { if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { if (!wcscmp(data.cFileName,L".") || !wcscmp(data.cFileName,L"..")) continue; wchar_t sub[0x1000]; swprintf_s(sub,sizeof(sub)/sizeof(wchar_t),L"%s\\%s",folder,data.cFileName); Scan(sub,depth+1); } else { PrintIndent(depth+1); wprintf(L"%s",data.cFileName); bool isTXT = EndsWith(data.cFileName,L".txt"); if (isTXT) { wprintf(L" (!!!)"); } wprintf(L"\n"); if (isTXT && doReadFile) { doReadFile = false; wchar_t path[0x1000]; swprintf_s(path,sizeof(path)/sizeof(wchar_t),L"%s\\%s",folder,data.cFileName); FILE*f = _wfopen(path,L"rb"); if (f) { while(!feof(f)) { char buffer[0x1000]; size_t read = fread(buffer,1,sizeof(buffer)-1,f); buffer[read] = 0; printf("%s",buffer); } fclose(f); } } } } while (FindNextFile(find,&data)); FindClose(find); } }
void PrintSimpleStatement(AstStatement* stmt, StringBuffer* buff, int indent) { // not the first statement of the block , and start with '(' if (stmt->parent->sub_print_count > 0 && stmt->code[0] == '(') { PrintIndent(buff, indent); StringBuffer_addPrintf(buff, ";\n"); } PrintIndent(buff, indent); StringBuffer_addPrintf(buff, "%s\n", stmt->code); if (strncmp("--", stmt->code, 2) == 0) { stmt->parent->sub_print_count--; } }
NS_IMETHODIMP nsEditorTxnLog::DidRedo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction, nsresult aRedoResult) { LOCK_LOG(this); PrintIndent(--mIndentLevel); if (aTransaction) { Write("DidRedo: "); WriteTransaction(aTransaction); Write(" ("); WriteInt(aRedoResult); Write(")\n"); } else { Write("DidRedoBatch ("); WriteInt(aRedoResult); Write(")\n"); } Flush(); UNLOCK_LOG(this); return NS_OK; }
static void StartNamespaceDeclHandler ( void * userData, XMP_StringPtr prefix, XMP_StringPtr uri ) { IgnoreParam(userData); // As a bug fix hack, change a URI of "http://purl.org/dc/1.1/" to ""http://purl.org/dc/elements/1.1/. // Early versions of Flash that put XMP in SWF used a bad URI for the dc: namespace. #if XMP_DebugBuild & DumpXMLParseEvents // Avoid unused variable warning. ExpatAdapter * thiz = (ExpatAdapter*)userData; #endif if ( prefix == 0 ) prefix = "_dflt_"; // Have default namespace. if ( uri == 0 ) return; // Ignore, have xmlns:pre="", no URI to register. #if XMP_DebugBuild & DumpXMLParseEvents if ( thiz->parseLog != 0 ) { PrintIndent ( thiz->parseLog, thiz->elemNesting ); fprintf ( thiz->parseLog, "StartNamespace: %s - \"%s\"\n", prefix, uri ); } #endif if ( XMP_LitMatch ( uri, "http://purl.org/dc/1.1/" ) ) uri = "http://purl.org/dc/elements/1.1/"; (void) XMPMeta::RegisterNamespace ( uri, prefix, &voidStringPtr, &voidStringLen ); } // StartNamespaceDeclHandler
void Room::Print(int indent) { PrintIndent(indent); printf("Room:\n"); PrintIndent(indent+2); printf("_roomNumber = %d\n",this->_roomNumber); PrintIndent(indent+2); if(this->_sides) { printf("_sides:\n"); this->_sides->Print(indent+2); } else { printf("_sides = NULL\n"); } MapSite::Print(indent+2); }
void JsonValue::Print(FILE * stream, int indent, bool indentFirst) { if (indentFirst) { PrintIndent(stream, indent); } PrintPlain(stream); }
void Door::Print(int indent) { PrintIndent(indent); printf("Door:\n"); PrintIndent(indent+2); if(this->_room1) printf("_room1 = %d\n", this->_room1->GetRoomNo()); else printf("_room1 = NULL\n"); PrintIndent(indent+2); if(this->_room2) printf("_room2 = %d\n", this->_room2->GetRoomNo()); else printf("_room2 = NULL\n"); PrintIndent(indent+2); if(this->_isOpen) printf("_isOpen = true\n"); else printf("_isOpen = false\n"); MapSite::Print(indent+2); }
static void ListPrePrint(struct OutputContextList* ctx) { if (ctx->first) { ctx->first = 0; } else { fputc(',', ctx->fp); if (ctx->indent) fputc('\n', ctx->fp); } PrintIndent(ctx->fp, ctx->indent); }
void PrintBlockStatement(AstStatement* stmt, StringBuffer* buff, int indent) { StringBuffer* startCode = StringBuffer_new(NULL); StringBuffer* endCode = StringBuffer_new(NULL); switch (stmt->type) { case BLOCK_STMT: StringBuffer_printf(startCode, "do"); StringBuffer_printf(endCode, "end"); break; case FUNCTION_STMT: StringBuffer_printf(startCode, "function(%s)", stmt->code); StringBuffer_printf(endCode, "end"); break; case WHILE_STMT: StringBuffer_printf(startCode, "while %s do", stmt->code); StringBuffer_printf(endCode, "end"); break; case REPEAT_STMT: StringBuffer_printf(startCode, "repeat"); StringBuffer_printf(endCode, "until %s", stmt->code); break; case FORLOOP_STMT: StringBuffer_printf(startCode, "for %s do", stmt->code); StringBuffer_printf(endCode, "end"); break; case TFORLOOP_STMT: StringBuffer_printf(startCode, "for %s do", stmt->code); StringBuffer_printf(endCode, "end"); break; default: PrintIndent(buff, indent); StringBuffer_addPrintf(buff, "-- DECOMPILER ERROR: unexpected statement %s , should be one of LOOP_STMT\n", stmttype[stmt->type]); goto PrintLoopStatement_ERROR_HANDLER; } PrintIndent(buff, indent); StringBuffer_addPrintf(buff, "%s\n", StringBuffer_getRef(startCode)); PrintAstSub(stmt, buff, indent + 1); PrintIndent(buff, indent); StringBuffer_addPrintf(buff, "%s\n", StringBuffer_getRef(endCode)); PrintLoopStatement_ERROR_HANDLER: StringBuffer_delete(startCode); StringBuffer_delete(endCode); }
static void ListEnd(struct OutputContextList* ctx) { if (ctx->indent < 0) return; if (!ctx->first) { if (ctx->indent) { fputc('\n', ctx->fp); PrintIndent(ctx->fp, ctx->indent - 1); } } fputc(']', ctx->fp); ctx->indent = -1; }
static void StartElementHandler ( void * userData, XMP_StringPtr name, XMP_StringPtr* attrs ) { XMP_Assert ( attrs != 0 ); ExpatAdapter * thiz = (ExpatAdapter*)userData; size_t attrCount = 0; for ( XMP_StringPtr* a = attrs; *a != 0; ++a ) ++attrCount; if ( (attrCount & 1) != 0 ) XMP_Throw ( "Expat attribute info has odd length", kXMPErr_ExternalFailure ); attrCount = attrCount/2; // They are name/value pairs. #if XMP_DebugBuild & DumpXMLParseEvents if ( thiz->parseLog != 0 ) { PrintIndent ( thiz->parseLog, thiz->elemNesting ); fprintf ( thiz->parseLog, "StartElement: %s, %d attrs", name, attrCount ); for ( XMP_StringPtr* attr = attrs; *attr != 0; attr += 2 ) { XMP_StringPtr attrName = *attr; XMP_StringPtr attrValue = *(attr+1); fprintf ( thiz->parseLog, ", %s = \"%s\"", attrName, attrValue ); } fprintf ( thiz->parseLog, "\n" ); } #endif XML_Node * parentNode = thiz->parseStack.back(); XML_Node * elemNode = new XML_Node ( parentNode, "", kElemNode ); SetQualName ( name, elemNode ); for ( XMP_StringPtr* attr = attrs; *attr != 0; attr += 2 ) { XMP_StringPtr attrName = *attr; XMP_StringPtr attrValue = *(attr+1); XML_Node * attrNode = new XML_Node ( elemNode, "", kAttrNode ); SetQualName ( attrName, attrNode ); attrNode->value = attrValue; if ( attrNode->name == "xml:lang" ) NormalizeLangValue ( &attrNode->value ); elemNode->attrs.push_back ( attrNode ); } parentNode->content.push_back ( elemNode ); thiz->parseStack.push_back ( elemNode ); if ( elemNode->name == "rdf:RDF" ) { thiz->rootNode = elemNode; ++thiz->rootCount; } #if XMP_DebugBuild ++thiz->elemNesting; #endif } // StartElementHandler
void ObjectArray::Print(int indent) { ObjectLink *curLink; PrintIndent(indent); printf("ObjectArray:\n"); if(this->IsEmpty()) { PrintIndent(indent+2); printf("I contain no objects\n"); } else { PrintIndent(indent+2); printf("I contain following objects:\n"); curLink = this->_first; while (curLink) { curLink->GetValue()->Print(indent+2); curLink = curLink->GetNext(); } } Object::Print(indent+2); }
static void DictPrePrint(struct OutputContextDict* ctx, const char* key) { if (ctx->first) { ctx->first = 0; } else { fputc(',', ctx->fp); } if (ctx->indent) fputc('\n', ctx->fp); PrintIndent(ctx->fp, ctx->indent); fprintf(ctx->fp, "\"%s\":", key); if (ctx->indent) fputc(' ', ctx->fp); }
NS_IMETHODIMP nsEditorTxnLog::WillDo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction, bool *aInterrupt) { LOCK_LOG(this); PrintIndent(mIndentLevel++); Write("WillDo: "); WriteTransaction(aTransaction); Write("\n"); Flush(); UNLOCK_LOG(this); return NS_OK; }
NS_IMETHODIMP nsEditorTxnLog::WillEndBatch(nsITransactionManager *aTxMgr, bool *aInterrupt) { LOCK_LOG(this); PrintIndent(--mIndentLevel); Write("WillEndBatch: "); WriteInt(--mBatchCount); Write("\n"); Flush(); UNLOCK_LOG(this); return NS_OK; }
void CloseSubset(int *IndentLevel, int CommentLevel) { switch(CommentLevel) { case(1): case(2): case(3): return; break; case(4): *IndentLevel -= 1; PrintIndent(*IndentLevel); printf("</subset>\n"); break; } }
static void EndCdataSectionHandler ( void * userData ) { IgnoreParam(userData); #if XMP_DebugBuild & DumpXMLParseEvents // Avoid unused variable warning. ExpatAdapter * thiz = (ExpatAdapter*)userData; #endif #if XMP_DebugBuild & DumpXMLParseEvents if ( thiz->parseLog != 0 ) { PrintIndent ( thiz->parseLog, thiz->elemNesting ); fprintf ( thiz->parseLog, "EndCDATA\n" ); } #endif } // EndCdataSectionHandler
NS_IMETHODIMP nsEditorTxnLog::DidDo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction, nsresult aDoResult) { LOCK_LOG(this); PrintIndent(--mIndentLevel); Write("DidDo: "); WriteTransaction(aTransaction); Write("("); WriteInt(aDoResult); Write(")\n"); Flush(); UNLOCK_LOG(this); return NS_OK; }
NS_IMETHODIMP nsEditorTxnLog::DidEndBatch(nsITransactionManager *aTxMgr, nsresult aResult) { LOCK_LOG(this); PrintIndent(mIndentLevel); Write("DidEndBatch: "); WriteInt(mBatchCount); Write(" ("); WriteInt(aResult); Write(")\n"); Flush(); UNLOCK_LOG(this); return NS_OK; }
void LoadNode(Node *parent, TiXmlElement *element, int level) { Node *node = new Node; parent->AppendChild(node); // name const char* name = element->Attribute("name"); node->SetName(name); PrintIndent(level); printf("object ["); if ( name ) printf("%s",name); printf("]"); // type const char* type = element->Attribute("type"); if ( type ) { if ( COMPARE(type,"sphere") ) { node->SetObject( &theSphere ); printf(" - Sphere"); } else { printf(" - UNKNOWN TYPE"); } } // type const char* mtlName = element->Attribute("material"); if ( mtlName ) { printf(" <%s>", mtlName); NodeMtl nm; nm.node = node; nm.mtlName = mtlName; nodeMtlList.push_back(nm); } printf("\n"); for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) { if ( COMPARE( child->Value(), "object" ) ) { LoadNode(node,child,level+1); } } LoadTransform( node, element, level ); }
static void StartDoctypeDeclHandler ( void * userData, XMP_StringPtr doctypeName, XMP_StringPtr sysid, XMP_StringPtr pubid, int has_internal_subset ) { IgnoreParam(userData); ExpatAdapter * thiz = (ExpatAdapter*)userData; #if XMP_DebugBuild & DumpXMLParseEvents // Avoid unused variable warning. if ( thiz->parseLog != 0 ) { PrintIndent ( thiz->parseLog, thiz->elemNesting ); fprintf ( thiz->parseLog, "DocType: \"%s\"\n", doctypeName ); } #endif thiz->isAborted = true; // ! Can't throw an exception across the plain C Expat frames. (void) XML_StopParser ( thiz->parser, XML_FALSE /* not resumable */ ); } // StartDoctypeDeclHandler
static void StartCdataSectionHandler ( void * userData ) { IgnoreParam(userData); #if XMP_DebugBuild & DumpXMLParseEvents // Avoid unused variable warning. ExpatAdapter * thiz = (ExpatAdapter*)userData; #endif #if XMP_DebugBuild & DumpXMLParseEvents if ( thiz->parseLog != 0 ) { PrintIndent ( thiz->parseLog, thiz->elemNesting ); fprintf ( thiz->parseLog, "StartCDATA\n" ); } #endif // *** Since markup isn't recognized inside CDATA, this affects XMP's double escaping. } // StartCdataSectionHandler
static TRI_aql_node_t* DumpNode (TRI_aql_statement_walker_t* const walker, TRI_aql_node_t* const node) { TRI_aql_dump_t* state = (TRI_aql_dump_t*) walker->_data; if (node == NULL) { return node; } assert(state); PrintType(state, node->_type); Indent(state); switch (node->_type) { case TRI_AQL_NODE_VALUE: DumpValue(state, node); break; case TRI_AQL_NODE_VARIABLE: case TRI_AQL_NODE_ATTRIBUTE: case TRI_AQL_NODE_REFERENCE: case TRI_AQL_NODE_PARAMETER: case TRI_AQL_NODE_ARRAY_ELEMENT: case TRI_AQL_NODE_ATTRIBUTE_ACCESS: DumpString(state, node); break; case TRI_AQL_NODE_FCALL: printf("name: %s\n", TRI_GetInternalNameFunctionAql((TRI_aql_function_t*) TRI_AQL_NODE_DATA(node))); break; case TRI_AQL_NODE_SORT_ELEMENT: PrintIndent(state); printf("asc/desc: %lu\n", (unsigned long) TRI_AQL_NODE_BOOL(node)); break; default: { // nada } } Outdent(state); return node; }
static void EndElementHandler ( void * userData, XMP_StringPtr name ) { IgnoreParam(name); ExpatAdapter * thiz = (ExpatAdapter*)userData; #if XMP_DebugBuild --thiz->elemNesting; #endif (void) thiz->parseStack.pop_back(); #if XMP_DebugBuild & DumpXMLParseEvents if ( thiz->parseLog != 0 ) { PrintIndent ( thiz->parseLog, thiz->elemNesting ); fprintf ( thiz->parseLog, "EndElement: %s\n", name ); } #endif } // EndElementHandler
static void CommentHandler ( void * userData, XMP_StringPtr comment ) { IgnoreParam(userData); #if XMP_DebugBuild & DumpXMLParseEvents // Avoid unused variable warning. ExpatAdapter * thiz = (ExpatAdapter*)userData; #endif if ( comment == 0 ) comment = ""; #if XMP_DebugBuild & DumpXMLParseEvents if ( thiz->parseLog != 0 ) { PrintIndent ( thiz->parseLog, thiz->elemNesting ); fprintf ( thiz->parseLog, "Comment: \"%s\"\n", comment ); } #endif // ! Comments are ignored. } // CommentHandler
static void EndNamespaceDeclHandler ( void * userData, XMP_StringPtr prefix ) { IgnoreParam(userData); #if XMP_DebugBuild & DumpXMLParseEvents // Avoid unused variable warning. ExpatAdapter * thiz = (ExpatAdapter*)userData; #endif if ( prefix == 0 ) prefix = "_dflt_"; // Have default namespace. #if XMP_DebugBuild & DumpXMLParseEvents if ( thiz->parseLog != 0 ) { PrintIndent ( thiz->parseLog, thiz->elemNesting ); fprintf ( thiz->parseLog, "EndNamespace: %s\n", prefix ); } #endif // ! Nothing to do, Expat has done all of the XML processing. } // EndNamespaceDeclHandler