From 5b89ab2e6094e68210e7a86f8328a1a1e294db15 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Mon, 22 Nov 2004 01:37:29 +0000 Subject: [PATCH] patch #1069631 to disable cpp git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6766 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/Modules/main.cxx | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/SWIG/Source/Modules/main.cxx b/SWIG/Source/Modules/main.cxx index 52633e5bb..bb89b768a 100644 --- a/SWIG/Source/Modules/main.cxx +++ b/SWIG/Source/Modules/main.cxx @@ -82,6 +82,7 @@ static const char *usage2 = (const char*)"\ -nodirprot - Do not wrap director protected members\n\ -noexcept - Do not wrap exception specifiers\n\ -noextern - Do not generate extern declarations\n\ + -nopreprocess - Skip the preprocessor step\n\ -o - Set name of the output file to \n\ -oh - Set name of the output header file to \n\ -outdir - Set language specific files output directory\n\ @@ -108,6 +109,7 @@ static String *xmlout = 0; static int help = 0; static int checkout = 0; static int cpp_only = 0; +static int no_cpp = 0; static char *outfile_name = 0; static char *outfile_name_h = 0; static int tm_debug = 0; @@ -292,6 +294,9 @@ void SWIG_getoptions(int argc, char *argv[]) } else if (strcmp(argv[i],"-E") == 0) { cpp_only = 1; Swig_mark_arg(i); + } else if (strcmp(argv[i],"-nopreprocess") == 0) { + no_cpp = 1; + Swig_mark_arg(i); } else if ((strcmp(argv[i],"-verbose") == 0) || (strcmp(argv[i],"-v") == 0)) { Verbose = 1; @@ -721,21 +726,26 @@ int SWIG_main(int argc, char *argv[], Language *l) { SWIG_exit (EXIT_FAILURE); } fclose(df); - Printf(fs,"%%include \n"); - if (allkw) { - Printf(fs,"%%include \n"); + if(!no_cpp) { + Printf(fs,"%%include \n"); + if (allkw) { + Printf(fs,"%%include \n"); + } + if (lang_config) { + Printf(fs,"\n%%include <%s>\n", lang_config); + } + Printf(fs,"%%include \"%s\"\n", Swig_last_file()); + for (i = 0; i < Len(libfiles); i++) { + Printf(fs,"\n%%include \"%s\"\n", Getitem(libfiles,i)); + } + Seek(fs,0,SEEK_SET); + cpps = Preprocessor_parse(fs); + } else { + df = Swig_open(input_file); + cpps = NewFileFromFile(df); } - if (lang_config) { - Printf(fs,"\n%%include <%s>\n", lang_config); - } - Printf(fs,"%%include \"%s\"\n", Swig_last_file()); - for (i = 0; i < Len(libfiles); i++) { - Printf(fs,"\n%%include \"%s\"\n", Getitem(libfiles,i)); - } - Seek(fs,0,SEEK_SET); - cpps = Preprocessor_parse(fs); if (Swig_error_count()) { - SWIG_exit(EXIT_FAILURE); + SWIG_exit(EXIT_FAILURE); } if (cpp_only) { Printf(stdout,"%s", cpps);