/* * processFile - process a specified file */ static void processFile( const char *arg ) { char buff[_MAX_EXT + 5]; char *ext; file_type ftype; unsigned tagcnt; StartFile( arg ); _splitpath2( arg, buff, NULL, NULL, NULL, &ext ); if( fileType == TYPE_NONE ) { ftype = TYPE_C; if( !stricmp( ext, ".for" ) ) { ftype = TYPE_FORTRAN; } else if( !stricmp( ext, ".fi" ) ) { ftype = TYPE_FORTRAN; } else if( !stricmp( ext, ".pas" ) ) { ftype = TYPE_PASCAL; } else if( !stricmp( ext, ".cpp" ) ) { ftype = TYPE_CPLUSPLUS; } else if( !stricmp( ext, ".asm" ) ) { ftype = TYPE_ASM; } } else { ftype = fileType; } tagcnt = 0; if( VerboseFlag ) { printf( "Processing %s", arg ); tagcnt = TagCount; fflush( stdout ); } switch( ftype ) { case TYPE_C: ScanC(); break; case TYPE_CPLUSPLUS: ScanC(); break; case TYPE_FORTRAN: ScanFortran(); break; case TYPE_PASCAL: ScanFortran(); break; case TYPE_ASM: ScanAsm(); break; } if( VerboseFlag ) { printf( ", %u tags.\n", TagCount - tagcnt ); } EndFile(); } /* processFile */
~EventLogManager() { mInstances.clear(); //std::cout << "BEING DESTROYED - LogManager" << std::endl; //std::cout.flush(); if (logFile.is_open()) { //std::cout << "Closing log file" << std::endl; //std::cout.flush(); EndFile(); //Log::logFile.close(); } }
UBYTE GetLine () { BOOL NotGot; do { NotGot = TRUE; LineNo++; fgets (Line, LINELEN, In); if (feof (In)) { EndFile (); if (!MainLoop) return COMMENT; } else NotGot = FALSE; } while (NotGot); if (Debug) printf ("%08lX: %s", Addr, Line); ptr = &Line [0]; SkipWhitespace (); switch (*ptr) { case 0 : case ';' : case '/' : case '\n' : return COMMENT; case '*' : return SETADDR; } if (memcmp (ptr, "ENDIF", 5) == 0) return ENDCOND; return VALID; }
void OpenFile() { //std::cout << "LogManager try to open file to " << sLogFileName << std::endl; if (logFile.is_open()) { logFile << "Change to log file: "<< sLogFileName<< std::endl; TimeTag(); EndFile(); logFile.close(); } //First attempt to create the log file. std::ostringstream filename; filename << "results/logs/" << theApp->getStartTimeString() << "-eventLog"; if (mSide == RED) { filename << "Red"; } else if (mSide == BLUE) { filename << "Blue"; } filename << ".txt"; logFile.open(filename.str().c_str()); //logFile.open(sLogFileName); if (!logFile.is_open()) { std::cout << "could not open file \""<<filename.str()<<"\"" << std::endl; return; } else { //std::cout << "Using file \"delta3d_log.html\" for logging" << std::endl; } //TimeTag(); //logFile << std::endl; logFile.flush(); //std::cout.flush(); }
void WriteNodesFile(GF_List *BNodes, GF_List *NDTs) { FILE *f; u32 i, j; X3DNode *n; X3DField *bf; f = BeginFile(0); fprintf(f, "#include <gpac/scenegraph_vrml.h>\n\n"); fprintf(f, "#ifndef GPAC_DISABLE_X3D\n\n"); //write all tags fprintf(f, "\n\nenum {\n"); for (i=0; i<gf_list_count(BNodes); i++) { n = gf_list_get(BNodes, i); if (i) fprintf(f, ",\n\tTAG_X3D_%s", n->name); else fprintf(f, "\tTAG_X3D_%s = GF_NODE_RANGE_FIRST_X3D", n->name); } fprintf(f, ",\n\tTAG_LastImplementedX3D\n};\n\n"); for (i=0; i<gf_list_count(BNodes); i++) { n = gf_list_get(BNodes, i); if (n->skip_impl) continue; fprintf(f, "typedef struct _tagX3D%s\n{\n", n->name); fprintf(f, "\tBASE_NODE\n"); /*write children field*/ for (j=0; j<gf_list_count(n->Fields); j++) { bf = gf_list_get(n->Fields, j); if (!stricmp(bf->name, "addChildren") || !strcmp(bf->name, "removeChildren")) continue; if (strcmp(bf->type, "eventOut") && !strcmp(bf->name, "children")) { fprintf(f, "\tVRML_CHILDREN\n"); break; } } for (j=0; j<gf_list_count(n->Fields); j++) { bf = gf_list_get(n->Fields, j); if (!strcmp(bf->name, "addChildren") || !strcmp(bf->name, "removeChildren")) continue; if (strcmp(bf->type, "eventOut") && !strcmp(bf->name, "children")) continue; if (strstr(bf->familly, "Node")) { //this is a POINTER to a node if (strstr(bf->familly, "SF")) { fprintf(f, "\tGF_Node *%s;\t/*%s*/\n", bf->name, bf->type); } else { //this is a POINTER to a chain fprintf(f, "\tGF_ChildNodeItem *%s;\t/*%s*/\n", bf->name, bf->type); } } else { fprintf(f, "\t%s %s;\t/*%s*/\n", bf->familly, bf->name, bf->type); } if (!strcmp(bf->type, "eventIn")) fprintf(f, "\tvoid (*on_%s)(GF_Node *pThis, struct _route *route);\t/*eventInHandler*/\n", bf->name); } fprintf(f, "} X_%s;\n\n\n", n->name); } fprintf(f, "#endif /*GPAC_DISABLE_X3D*/\n\n"); EndFile(f, 0); }
int main (int argc, char **argv) { FILE *nodes, *pf; GF_List *XNodes, *NDTs; X3DNode *n; X3DField *bf; u32 nb_nodes, nb_imp; nodes = gf_fopen("templates_X3D.txt", "rt"); if (!nodes) { fprintf(stdout, "cannot open \"templates_X3D.txt\" - aborting\n"); return 0; } XNodes = gf_list_new(); NDTs = gf_list_new(); //all nodes are in the same list but we keep version info ParseTemplateFile(nodes, XNodes, NDTs); gf_fclose(nodes); if (argc>1) { pf = gf_fopen(argv[1], "rt"); if (!pf) fprintf(stdout, "Cannot open profile file %s\n", argv[1]); else { parse_profile(XNodes, pf); gf_fclose(pf); } } //write the nodes def WriteNodesFile(XNodes, NDTs); nodes = BeginFile(1); //write all nodes init stuff WriteNodeCode(XNodes, nodes); WriteNDT(nodes, XNodes, NDTs); fprintf(nodes, "#endif /*GPAC_DISABLE_X3D*/\n\n"); EndFile(nodes, 1); //free NDTs while (gf_list_count(NDTs)) { char *tmp = gf_list_get(NDTs, 0); gf_free(tmp); gf_list_rem(NDTs, 0); } gf_list_del(NDTs); nb_nodes = gf_list_count(XNodes); nb_imp = 0; //free nodes while (gf_list_count(XNodes)) { n = gf_list_get(XNodes, 0); if (!n->skip_impl) nb_imp++; gf_list_rem(XNodes, 0); while (gf_list_count(n->NDT)) { char *tmp = gf_list_get(n->NDT, 0); gf_free(tmp); gf_list_rem(n->NDT, 0); } gf_list_del(n->NDT); while (gf_list_count(n->Fields)) { bf = gf_list_get(n->Fields, 0); gf_free(bf); gf_list_rem(n->Fields, 0); } gf_list_del(n->Fields); gf_free(n); } gf_list_del(XNodes); fprintf(stdout, "Generation done: %d nodes implemented (%d nodes total)\n", nb_imp, nb_nodes); return 0; }
void generateSVGCode_V1(GF_List *svg_elements) { FILE *output; u32 i; /***************************************************/ /***************************************************/ /*************** Creating .h file ******************/ /***************************************************/ /***************************************************/ output = BeginFile(0); fprintf(output, "#include <gpac/scenegraph_svg.h>\n\n\n"); fprintf(output, "/* Definition of SVG element internal tags */\n"); fprintf(output, "/* TAG names are made of \"TAG_SVG\" + SVG element name (with - replaced by _) */\n"); /* write all tags */ fprintf(output, "enum {\n"); for (i=0; i<gf_list_count(svg_elements); i++) { SVGGenElement *elt = (SVGGenElement *)gf_list_get(svg_elements, i); if (i == 0) { fprintf(output, "\tTAG_SVG_%s = GF_NODE_RANGE_FIRST_SVG_SA", elt->implementation_name); } else { fprintf(output, ",\n\tTAG_SVG_%s", elt->implementation_name); } } fprintf(output, ",\n\t/*undefined elements (when parsing) use this tag*/\n\tTAG_SVG_UndefinedElement\n};\n\n"); fprintf(output, "/******************************************\n"); fprintf(output, "* SVG Elements structure definitions *\n"); fprintf(output, "*******************************************/\n"); for (i=0; i<gf_list_count(svg_elements); i++) { SVGGenElement *elt = (SVGGenElement *)gf_list_get(svg_elements, i); generateNode(output, elt); } fprintf(output, "/******************************************\n"); fprintf(output, "* End SVG Elements structure definitions *\n"); fprintf(output, "*******************************************/\n"); EndFile(output, 0); /***************************************************/ /***************************************************/ /*************** Creating .c file ******************/ /***************************************************/ /***************************************************/ output = BeginFile(1); fprintf(output, "#include <gpac/nodes_svg_sa.h>\n\n"); fprintf(output, "#ifndef GPAC_DISABLE_SVG\n\n"); fprintf(output, "#include <gpac/internal/scenegraph_dev.h>\n\n"); fprintf(output, "#ifdef GPAC_ENABLE_SVG_SA\n\n"); for (i=0; i<gf_list_count(svg_elements); i++) { SVGGenElement *elt = (SVGGenElement *)gf_list_get(svg_elements, i); generateNodeImpl(output, elt); } /***************************************************/ /* SVG_SA_Element *gf_svg_sa_create_node(u32 ElementTag) */ /***************************************************/ fprintf(output, "SVG_SA_Element *gf_svg_sa_create_node(u32 ElementTag)\n"); fprintf(output, "{\n"); fprintf(output, "\tswitch (ElementTag) {\n"); for (i=0; i<gf_list_count(svg_elements); i++) { SVGGenElement *elt = (SVGGenElement *)gf_list_get(svg_elements, i); fprintf(output, "\t\tcase TAG_SVG_%s: return (SVG_SA_Element*) gf_svg_new_%s();\n",elt->implementation_name,elt->implementation_name); } fprintf(output, "\t\tdefault: return NULL;\n\t}\n}\n\n"); /***************************************************/ /* void gf_svg_sa_element_del(SVG_SA_Element *elt) */ /***************************************************/ fprintf(output, "void gf_svg_sa_element_del(SVG_SA_Element *elt)\n{\n"); fprintf(output, "\tGF_Node *node = (GF_Node *)elt;\n"); fprintf(output, "\tswitch (node->sgprivate->tag) {\n"); for (i=0; i<gf_list_count(svg_elements); i++) { SVGGenElement *elt = (SVGGenElement *)gf_list_get(svg_elements, i); fprintf(output, "\t\tcase TAG_SVG_%s: gf_svg_sa_%s_del(node); return;\n", elt->implementation_name, elt->implementation_name); } fprintf(output, "\t\tdefault: return;\n\t}\n}\n\n"); /***************************************************/ /* u32 gf_svg_sa_get_attribute_count(SVG_SA_Element *elt) */ /***************************************************/ fprintf(output, "u32 gf_svg_sa_get_attribute_count(GF_Node *node)\n{\n"); fprintf(output, "\tswitch (node->sgprivate->tag) {\n"); for (i=0; i<gf_list_count(svg_elements); i++) { SVGGenElement *elt = (SVGGenElement *)gf_list_get(svg_elements, i); fprintf(output, "\t\tcase TAG_SVG_%s: return %i;\n", elt->implementation_name, elt->nb_atts); } fprintf(output, "\t\tdefault: return 0;\n\t}\n}\n\n"); /***********************************************************************/ /* GF_Err gf_svg_sa_get_attribute_info(GF_Node *node, GF_FieldInfo *info) */ /***********************************************************************/ fprintf(output, "GF_Err gf_svg_sa_get_attribute_info(GF_Node *node, GF_FieldInfo *info)\n{\n"); fprintf(output, "\tswitch (node->sgprivate->tag) {\n"); for (i=0; i<gf_list_count(svg_elements); i++) { SVGGenElement *elt = (SVGGenElement *)gf_list_get(svg_elements, i); fprintf(output, "\t\tcase TAG_SVG_%s: return gf_svg_sa_%s_get_attribute(node, info);\n", elt->implementation_name, elt->implementation_name); } fprintf(output, "\t\tdefault: return GF_BAD_PARAM;\n\t}\n}\n\n"); /****************************************************************/ /* u32 gf_svg_sa_node_type_by_class_name(const char *element_name) */ /****************************************************************/ fprintf(output, "u32 gf_svg_sa_node_type_by_class_name(const char *element_name)\n{\n\tif (!element_name) return TAG_UndefinedNode;\n"); for (i=0; i<gf_list_count(svg_elements); i++) { SVGGenElement *elt = (SVGGenElement *)gf_list_get(svg_elements, i); fprintf(output, "\tif (!stricmp(element_name, \"%s\")) return TAG_SVG_%s;\n", elt->svg_name, elt->implementation_name); } fprintf(output, "\treturn TAG_UndefinedNode;\n}\n\n"); /***************************************************/ /* const char *gf_svg_sa_get_element_name(u32 tag) */ /***************************************************/ fprintf(output, "const char *gf_svg_sa_get_element_name(u32 tag)\n{\n\tswitch(tag) {\n"); for (i=0; i<gf_list_count(svg_elements); i++) { SVGGenElement *elt = (SVGGenElement *)gf_list_get(svg_elements, i); fprintf(output, "\tcase TAG_SVG_%s: return \"%s\";\n", elt->implementation_name, elt->svg_name); } fprintf(output, "\tdefault: return \"UndefinedNode\";\n\t}\n}\n\n"); /***************************************************/ /* const char *gf_svg_sa_get_attribute_index_by_name(u32 tag) */ /***************************************************/ fprintf(output, "s32 gf_svg_sa_get_attribute_index_by_name(GF_Node *node, char *name)\n{\n\tswitch(node->sgprivate->tag) {\n"); for (i=0; i<gf_list_count(svg_elements); i++) { SVGGenElement *elt = (SVGGenElement *)gf_list_get(svg_elements, i); fprintf(output, "\tcase TAG_SVG_%s: return gf_svg_sa_%s_get_attribute_index_from_name(name);\n", elt->implementation_name, elt->implementation_name); } fprintf(output, "\tdefault: return -1;\n\t}\n}\n\n"); /***************************************************/ /* Bool gf_svg_is_element_transformable(u32 tag) */ /***************************************************/ fprintf(output, "Bool gf_svg_is_element_transformable(u32 tag)\n{\n\tswitch(tag) {\n"); for (i=0; i<gf_list_count(svg_elements); i++) { SVGGenElement *elt = (SVGGenElement *)gf_list_get(svg_elements, i); fprintf(output, "\tcase TAG_SVG_%s:", elt->implementation_name); if (elt->has_transform) fprintf(output, "return 1;\n"); else fprintf(output, "return 0;\n"); } fprintf(output, "\tdefault: return 0;\n\t}\n}\n"); fprintf(output, "#endif /*GPAC_ENABLE_SVG_SA*/\n"); fprintf(output, "#endif /*GPAC_DISABLE_SVG*/\n\n"); EndFile(output, 1); generate_laser_tables(svg_elements); }