From 16e70de9ae8262ecfbb40979ad91fe0dcbd5e6bc Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Thu, 12 Jan 2006 17:19:02 +0000 Subject: [PATCH] add the -dump_parse_top and -dump_parse_modules git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8390 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 17 +++++++++++++++-- Source/Modules/main.cxx | 33 +++++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 58d4f9bf2..25052f208 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,19 @@ Version 1.3.28 (unreleased). =========================== +01/12/2006: mmatus + - Add the -dump_parse_module and -dump_parse_top options, + which are similar to -dump_module and -dump_top, but they + dump the node trees just after parsing, showing only the + attributes visible at the parsing stage, and not the added + later in typemap.cxx, allocate.cxx, lang.cxx or elsewhere. + + Besides debugging porpuses, these options are very useful + if you plan to use %rename in an "advance way", since it + shows only and all the node's attributes you can use + inside the match rules. + + 01/12/2006: mmatus - Add predicates to %rename, so, you don't need to remember, for example, how to match a member function. @@ -381,8 +394,8 @@ Version 1.3.28 (unreleased). %rename("%()",match="enumitem", match$parentNode$parentNode$nodeType="class") ""; - Use "swig -dump_module" to see the attribute names you can use to - match an specific case. + Use "swig -dump_parse_module" to see the attribute names you can use to + match a specific case. - 'sourcefmt' and 'targetfmt': sometimes you need to process the 'source' name before comparing, for example diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index edad32cdf..e672fee4b 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -60,6 +60,8 @@ static const char *usage1 = (const char*)"\ -D - Define a symbol (for conditional compilation)\n\ -dump_classes - Display information about the classes found in the interface\n\ -dump_module - Display information on the module node tree avoiding system nodes\n\ + -dump_parse_module - Display information on the module node tree after parsing avoiding system nodes\n\ + -dump_parse_top - Display information on the node tree after parsing including system nodes\n\ -dump_tags - Display information about the tags found in the interface\n\ -dump_top - Display information on the entire node tree including system nodes\n\ -dump_typedef - Display information about the types and typedefs in the interface\n\ @@ -70,11 +72,11 @@ static const char *usage1 = (const char*)"\ -features - Set global features, where is a comma separated list of\n\ features, eg -features directors,autodoc=1\n\ If no explicit value is given to the feature, a default of 1 is used\n\ - -fastdispatch - Enable fast dispatch mode to produce faster overload dispatcher code\n\ - -Fmicrosoft - Display error/warning messages in Microsoft format\n\ "; static const char *usage2 = (const char*)"\ + -fastdispatch - Enable fast dispatch mode to produce faster overload dispatcher code\n\ + -Fmicrosoft - Display error/warning messages in Microsoft format\n\ -Fstandard - Display error/warning messages in commonly used format\n\ -fvirtual - Compile in virtual elimination mode\n\ -help - This output\n\ @@ -100,14 +102,14 @@ static const char *usage2 = (const char*)"\ -noexcept - Do not wrap exception specifiers\n\ -nofastdispatch - Disable fast dispatch mode (default)\n\ -nopreprocess - Skip the preprocessor step\n\ +"; + +static const char *usage3 = (const char*)"\ -notemplatereduce - Disable reduction of the typedefs in templates\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\ -small - Compile in virtual elimination & compact mode\n\ -"; - -static const char *usage3 = (const char*)"\ -swiglib - Report location of SWIG library and exit\n\ -templatereduce - Reduce all the typedefs in templates\n\ -v - Run in verbose mode\n\ @@ -145,8 +147,10 @@ static char *outfile_name = 0; static char *outfile_name_h = 0; static int tm_debug = 0; static int dump_tags = 0; -static int dump_tree = 0; +static int dump_top = 0; static int dump_module = 0; +static int dump_parse_module = 0; +static int dump_parse_top = 0; static int dump_xml = 0; static int browse = 0; static int dump_typedef = 0; @@ -656,11 +660,17 @@ void SWIG_getoptions(int argc, char *argv[]) dump_tags = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i],"-dump_tree") == 0) || (strcmp(argv[i],"-dump_top") == 0)) { - dump_tree = 1; + dump_top = 1; Swig_mark_arg(i); } else if (strcmp(argv[i],"-dump_module") == 0) { dump_module = 1; Swig_mark_arg(i); + } else if (strcmp(argv[i],"-dump_parse_module") == 0) { + dump_parse_module = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i],"-dump_parse_top") == 0) { + dump_parse_top = 1; + Swig_mark_arg(i); } else if (strcmp(argv[i],"-dump_xml") == 0) { dump_xml = 1; Swig_mark_arg(i); @@ -989,6 +999,13 @@ int SWIG_main(int argc, char *argv[], Language *l) { Node *top = Swig_cparse(cpps); + if (dump_parse_top) { + Swig_print_tree(top); + } + if (dump_parse_module) { + Swig_print_tree(Getattr(top,"module")); + } + if (Verbose) { Printf(stdout,"Processing types...\n"); } @@ -1053,7 +1070,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { } } } - if (dump_tree) { + if (dump_top) { Swig_print_tree(top); } if (dump_module) {