Changeset 277 for trunk/idl-compiler
- Timestamp:
- Mar 27, 2007, 7:58:40 PM (18 years ago)
- Location:
- trunk/idl-compiler
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/idl-compiler/Makefile
r276 r277 28 28 PGOBJECTS = $(OBJDIR)/nom-idl-compiler.o \ 29 29 $(OBJDIR)/token.o \ 30 $(OBJDIR)/open_outfile.o \ 30 31 $(OBJDIR)/typespec_parser.o \ 31 32 $(OBJDIR)/method_parser.o \ -
trunk/idl-compiler/c/nom-idl-compiler.c
r276 r277 55 55 56 56 static gchar* chrOutputDir=""; 57 static gchar* chrOutputName="";58 57 static gboolean fOptionEmitH=FALSE; 59 58 static gboolean fOptionEmitIH=FALSE; … … 67 66 {"emit-ih", 0, 0, G_OPTION_ARG_NONE, &fOptionEmitIH, "Emmit an include header (*.ih)", NULL}, 68 67 {"emit-c", 0, 0, G_OPTION_ARG_NONE, &fOptionEmitC, "Emmit an implementation template (*.c)", NULL}, 69 {"output", 'o', 0, G_OPTION_ARG_FILENAME, &chrOutputName, "Output name. Must not be omitted.", NULL},70 68 {NULL} 71 69 }; … … 480 478 helpCmd[0]=chrExeName; 481 479 482 g_printf("An output filename must always be specified. If the name is an absolute path\n\ 483 it will be used unmodified. Otherwise the output name is built from the given\n\ 484 name and the directory specification.\n\n\ 480 g_printf("The output filename is specified in the IDL file using the 'filestem' keyword.\n\ 485 481 -If no directory is specified the output name is built from the current directory\n\ 486 482 path and the given filename.\n\ … … 533 529 /* Vars for filename building */ 534 530 char* chrOutputFileName=""; 535 char* chrTemp;536 531 537 532 GError *gError = NULL; … … 565 560 } 566 561 567 if(strlen(chrOutputName)==0)568 {569 g_printf("No output file name given.\n\n");570 outputCompilerHelp(gContext, argv[0]);571 }572 562 g_option_context_free(gContext); 573 563 … … 585 575 586 576 587 /*** Create output file name ****/ 588 if(!g_path_is_absolute(chrOutputName)) 589 { 590 if(g_path_is_absolute(chrOutputDir)) 591 chrOutputFileName=g_build_filename(chrOutputDir, chrOutputName, NULL); 592 else 593 { 594 /* Yes this is a memory leak but I don't care */ 595 chrOutputFileName=g_build_filename(g_get_current_dir(), chrOutputDir, chrOutputName, NULL); 596 } 597 } 577 /*** Create output path name ****/ 578 if(g_path_is_absolute(chrOutputDir)) 579 chrOutputFileName=chrOutputDir; 598 580 else 599 chrOutputFileName=chrOutputName; 600 601 /* Add emitter extension */ 602 if(fOptionEmitH) 603 chrTemp=g_strconcat(chrOutputFileName, ".h", NULL); 604 else if(fOptionEmitIH) 605 chrTemp=g_strconcat(chrOutputFileName, ".ih", NULL); 606 else if(fOptionEmitC) 607 chrTemp=g_strconcat(chrOutputFileName, ".c", NULL); 608 g_free(chrOutputFileName); 609 chrOutputFileName=chrTemp; 610 611 g_message("Output file: %s", chrOutputFileName); 581 { 582 /* Yes this is a memory leak but I don't care */ 583 chrOutputFileName=g_build_filename(g_get_current_dir(), chrOutputDir, NULL); 584 } 585 586 g_message("Output path: %s", chrOutputFileName); 587 parseInfo.chrOutfilePath=chrOutputFileName; 612 588 613 589 /* Open input */ … … 622 598 exit(1); 623 599 } 624 625 /* Open output */626 parseInfo.outFile=fopen(chrOutputFileName, "w");627 600 628 601 g_printf("\n"); … … 663 636 664 637 #if 0 665 else if(fOptionEmitIH)666 667 638 else if(fOptionEmitC) 668 639 a++; -
trunk/idl-compiler/h-emitter_c/h_file_emitter.c
r274 r277 38 38 #include <glib.h> 39 39 #include <glib/gprintf.h> 40 41 #define INCL_FILE 40 42 #include "parser.h" 41 43 … … 340 342 { 341 343 PINTERFACE pif=g_ptr_array_index(pLocalPI->pInterfaceArray, a); 344 /* Only interfaces from the file given on the command line */ 342 345 if(!strcmp(pif->chrSourceFileName, pLocalPI->chrRootSourceFile)) 343 346 { 347 gchar* chrTemp; 348 349 chrTemp=g_strconcat(pif->chrFileStem, ".h", NULL); 350 344 351 printInterface(pif); 345 346 emitHFileHeader(pLocalPI, pif); 347 emitParentHeader(pLocalPI, pif); 348 emitClassVersion(pLocalPI, pif); 349 emitClassDataStructs(pLocalPI, pif); 350 emitNewMacro(pLocalPI, pif); 351 emitObjectCheckFunction(pLocalPI, pif); 352 emitNewMethods(pLocalPI, pif); 353 emitParentClassMethods(pLocalPI, pif); 354 emitHFileFooter(pLocalPI, pif); 352 if((pLocalPI->outFile=openOutfile(gScanner, chrTemp))!=NULLHANDLE) 353 { 354 emitHFileHeader(pLocalPI, pif); 355 emitParentHeader(pLocalPI, pif); 356 emitClassVersion(pLocalPI, pif); 357 emitClassDataStructs(pLocalPI, pif); 358 emitNewMacro(pLocalPI, pif); 359 emitObjectCheckFunction(pLocalPI, pif); 360 emitNewMethods(pLocalPI, pif); 361 emitParentClassMethods(pLocalPI, pif); 362 emitHFileFooter(pLocalPI, pif); 363 closeOutfile(pLocalPI->outFile); 364 } 365 g_free(chrTemp); 355 366 } 356 367 } -
trunk/idl-compiler/ih-emitter_c/ih_file_emitter.c
r276 r277 51 51 /* Protective #ifndef for whole file */ 52 52 fprintf(fh, "#ifndef %s_IH\n#define %s_IH\n\n", pif->chrName, pif->chrName); 53 53 /* The *.h of this class conatins some declarations we need */ 54 54 fprintf(fh, "#include \"%s.h\"\n", pif->chrName); 55 55 … … 62 62 FILE* fh=pLocalPI->outFile; 63 63 64 fprintf(fh, "#ifdef __cplusplus\n");65 fprintf(fh, "}\n");66 fprintf(fh, "#endif /* __cplusplus */\n\n");67 64 68 65 fprintf(fh, "\n#endif /* %s_IH */\n", pif->chrName); -
trunk/idl-compiler/include/parser.h
r276 r277 83 83 gboolean fIsInRootFile; 84 84 gchar* chrMetaClass; /* Pointer to metaclass name or NULL*/ 85 char* chrFileStem; /* Holding output filestem */ 85 86 char* chrSourceFileName; /* The preprocessor includes files for us. This is the info 86 87 about the file this interface is defined in. */ 87 char* chrFileStem; /* Holding output filestem */88 88 GPtrArray *pMethodArray; 89 89 GPtrArray *pOverrideArray; … … 111 111 char* chrCurrentSourceFile;/* The preprocessor includes files for us. This is the info 112 112 about their name. */ 113 char* chrOutfilePath; /* This is only the path, no filename */ 113 114 FILE* outFile; /* Output file handle */ 114 115 }PARSEINFO, *PPARSEINFO; … … 182 183 void printInterface(PINTERFACE pif); 183 184 void printAllInterfacec(void); 185 186 #ifdef INCL_FILE 187 FILE* openOutfile(GScanner *gScanner, gchar* chrOutName); 188 void closeOutfile(FILE* pFile); 189 #endif
Note:
See TracChangeset
for help on using the changeset viewer.