From ef3f25ab1c03d37802d9c228a5dab2946b549a3b Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 1 Apr 2022 11:24:15 +1300 Subject: [PATCH] Remove -browse command line option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This option was undocumented. If used it quietly did nothing unless you'd installed the SWILL library before building SWIG, but SWILL is no longer maintained and hasn't seen a release since 2008-04-10. It's clear nobody has used this functionality for some time as the code to support it in SWIG isn't actually valid ISO C++: Modules/browser.cxx: In member function ‘void Browser::show_attributes(Node*)’: Modules/browser.cxx:57:23: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings] 57 | char *trunc = ""; | ^~ Modules/browser.cxx:61:21: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings] 61 | trunc = "..."; | ^~~~~ Closes #2251 --- CHANGES.current | 3 + Source/Makefile.am | 6 +- Source/Modules/browser.cxx | 421 ------------------------------------- Source/Modules/main.cxx | 7 - Source/Modules/swigmod.h | 8 +- configure.ac | 4 - 6 files changed, 7 insertions(+), 442 deletions(-) delete mode 100644 Source/Modules/browser.cxx diff --git a/CHANGES.current b/CHANGES.current index 7ce58028d..99581a84b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2022-04-01: olly + Remove undocumented and non-functional -browse command line option. + 2022-03-26: eltoder [Python] #1684 Use different capsule names with and without -builtin diff --git a/Source/Makefile.am b/Source/Makefile.am index 5cfb88839..095c5d4ea 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -6,8 +6,6 @@ AUTOMAKE_OPTIONS = foreign nostdinc subdir-objects 1.7.2 SOURCE_DIR=$(top_srcdir)/Source BUILD_SOURCE_DIR=$(top_builddir)/Source -SWIG_CXX_DEFS = @SWILL@ - AM_CPPFLAGS = -I$(BUILD_SOURCE_DIR)/Include \ -I$(BUILD_SOURCE_DIR)/CParse \ -I$(SOURCE_DIR)/Include \ @@ -18,7 +16,7 @@ AM_CPPFLAGS = -I$(BUILD_SOURCE_DIR)/Include \ -I$(SOURCE_DIR)/Swig \ -I$(SOURCE_DIR)/Modules -AM_CXXFLAGS = $(SWIG_CXX_DEFS) +AM_CXXFLAGS = AM_YFLAGS = -d @@ -46,7 +44,6 @@ eswig_SOURCES = CParse/cscanner.c \ Doxygen/pydoc.cxx \ Doxygen/pydoc.h \ Modules/allocate.cxx \ - Modules/browser.cxx \ Modules/contract.cxx \ Modules/csharp.cxx \ Modules/d.cxx \ @@ -98,7 +95,6 @@ eswig_SOURCES = CParse/cscanner.c \ Swig/wrapfunc.c bin_PROGRAMS = eswig -eswig_LDADD = @SWIGLIBS@ # Override the link stage to avoid using Libtool CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ diff --git a/Source/Modules/browser.cxx b/Source/Modules/browser.cxx deleted file mode 100644 index 217b40a7e..000000000 --- a/Source/Modules/browser.cxx +++ /dev/null @@ -1,421 +0,0 @@ -/* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 - * (or any later version) of the GNU General Public License. Some additional - * terms also apply to certain portions of SWIG. The full details of the SWIG - * license and copyrights can be found in the LICENSE and COPYRIGHT files - * included with the SWIG source code as distributed by the SWIG developers - * and at http://www.swig.org/legal.html. - * - * browser.cxx - * - * A web-base parse tree browser using SWILL. This is an optional - * feature that's normally disabled. - * ----------------------------------------------------------------------------- */ - -#include "swigmod.h" - -#ifdef SWIG_SWILL -extern "C" { -#include "swill.h" -} static FILE *out = 0; -static Node *view_top = 0; - -class Browser:public Dispatcher { - void show_checkbox(Node *t, Node *n) { - int v = 0; - if (Getmeta(n, "visible")) { - v = 1; - } - if (v) { - Printf(out, "[-] ", n, t, n, n); - } else { - Printf(out, "[+] ", n, t, n, n); - } - } - void show_attributes(Node *obj) { - if (!Getmeta(obj, "visible")) - return; - String *os = NewString(""); - String *k; - Iterator ki; - ki = First(obj); - while (ki.key) { - k = ki.key; - if ((Cmp(k, "nodeType") == 0) || (Cmp(k, "firstChild") == 0) || (Cmp(k, "lastChild") == 0) || - (Cmp(k, "parentNode") == 0) || (Cmp(k, "nextSibling") == 0) || (Cmp(k, "previousSibling") == 0) || (*(Char(k)) == '$')) { - /* Do nothing */ - } else if (Cmp(k, "parms") == 0) { - String *o = NewString(""); - Printf(o, "%s", ParmList_protostr(Getattr(obj, k))); - Replaceall(o, "&", "&"); - Replaceall(o, "<", "<"); - Replaceall(o, ">", ">"); - Printf(os, "? %-12s - %s\n", Getattr(obj, k), k, o); - Delete(o); - } else { - DOH *o; - char *trunc = ""; - if (DohIsString(Getattr(obj, k))) { - o = Str(Getattr(obj, k)); - if (Len(o) > 70) { - trunc = "..."; - } - Replaceall(o, "&", "&"); - Replaceall(o, "<", "<"); - Printf(os, "? %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc); - Delete(o); - } else { - Printf(os, "? %-12s - %p\n", Getattr(obj, k), k, Getattr(obj, k)); - } - } - ki = Next(ki); - } - Printf(out, "
\n%s
\n", Char(os)); - Delete(os); - } - -public: - virtual int emit_one(Node *n) { - char *tag = Char(nodeType(n)); - char *file = Char(Getfile(n)); - int line = Getline(n); - char *name = GetChar(n, "name"); - - show_checkbox(view_top, n); - Printf(out, "%s", n, tag); - if (name) { - Printf(out, " (%s)", name); - } - Printf(out, ". %s:%d\n", file, line); - Printf(out, "
"); - Dispatcher::emit_one(n); - return SWIG_OK; - } - virtual int emit_children(Node *n) { - if (Getmeta(n, "visible")) { - Printf(out, "
\n"); - Dispatcher::emit_children(n); - Printf(out, "
\n"); - } - return SWIG_OK; - } - virtual int defaultHandler(Node *n) { - show_attributes(n); - return SWIG_OK; - } - virtual int top(Node *n) { - show_attributes(n); - emit_children(n); - return SWIG_OK; - } - virtual int includeDirective(Node *n) { - show_attributes(n); - emit_children(n); - return SWIG_OK; - } - virtual int importDirective(Node *n) { - show_attributes(n); - emit_children(n); - return SWIG_OK; - } - - virtual int extendDirective(Node *n) { - show_attributes(n); - emit_children(n); - return SWIG_OK; - } - virtual int classDeclaration(Node *n) { - show_attributes(n); - emit_children(n); - return SWIG_OK; - } - - virtual int templateDeclaration(Node *n) { - show_attributes(n); - emit_children(n); - return SWIG_OK; - } - - virtual int lambdaDeclaration(Node *n) { - show_attributes(n); - emit_children(n); - return SWIG_OK; - } - - virtual int enumDeclaration(Node *n) { - show_attributes(n); - emit_children(n); - return SWIG_OK; - } - virtual int typemapDirective(Node *n) { - show_attributes(n); - emit_children(n); - return SWIG_OK; - } - virtual int namespaceDeclaration(Node *n) { - show_attributes(n); - emit_children(n); - return SWIG_OK; - } - virtual int usingDeclaration(Node *n) { - show_attributes(n); - emit_children(n); - return SWIG_OK; - } - -}; - -static int browser_exit = 0; -static Node *tree_top = 0; -static Browser *browse = 0; - -/* ---------------------------------------------------------------------- - * exit_handler() - Force the browser to exit - * ---------------------------------------------------------------------- */ - -void exit_handler(FILE *f) { - browser_exit = 1; - Printf(f, "Terminated.\n"); -} - -/* ---------------------------------------------------------------------- - * node_handler() - Generate information about a specific node - * ---------------------------------------------------------------------- */ - -static void display(FILE *f, Node *n) { - /* Print standard HTML header */ - - Printf(f, "SWIG-%s\n", Swig_package_version()); - Printf(f, "SWIG-%s
\n", Swig_package_version()); - Printf(f, "[ Exit ]"); - Printf(f, " [ Top ]", tree_top); - if (n != tree_top) { - Printf(f, " [ Up ]", parentNode(n)); - } - Printf(f, " [ Symbols ]"); - Printf(f, "

\n"); - - out = f; - - browse->emit_one(n); - - /* Print standard footer */ - Printf(f, "


\n"); - -} - -void node_handler(FILE *f) { - Node *n = 0; - if (!swill_getargs("p(node)", &n)) { - n = tree_top; - } - view_top = n; - display(f, n); -} - - -/* ---------------------------------------------------------------------- - * hide_handler() - Hide a node - * ---------------------------------------------------------------------- */ - -void hide_handler(FILE *f) { - Node *n = 0; - if (!swill_getargs("p(hn)", &n)) { - n = 0; - } - if (n) { - Delmeta(n, "visible"); - } - node_handler(f); -} - -void show_handler(FILE *f) { - Node *n = 0; - if (!swill_getargs("p(hn)", &n)) { - n = 0; - } - if (n) { - Setmeta(n, "visible", "1"); - } - node_handler(f); -} - -void raw_data(FILE *out, Node *obj) { - if (!obj) - return; - if (DohIsMapping(obj)) { - String *k; - Iterator ki; - String *os = NewString(""); - Printf(os, "Hash {\n"); - ki = First(obj); - while (ki.key) { - k = ki.key; - DOH *o; - const char *trunc = ""; - if (DohIsString(Getattr(obj, k))) { - o = Str(Getattr(obj, k)); - if (Len(o) > 70) { - trunc = "..."; - } - Replaceall(o, "<", "<"); - Printf(os, " ? %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc); - Delete(o); - } else { - Printf(os, " ? %-12s - %p\n", Getattr(obj, k), k, Getattr(obj, k)); - } - ki = Next(ki); - } - Printf(os, "}\n"); - Printf(out, "
\n%s
\n", Char(os)); - Delete(os); - } else if (DohIsString(obj)) { - String *o = Str(obj); - Replaceall(o, "<", "<"); - Printf(out, "
\n%s
\n", Char(o)); - Delete(o); - } else if (DohIsSequence(obj)) { - int i; - String *os = NewString(""); - Printf(os, "List [\n"); - for (i = 0; i < Len(obj); i++) { - DOH *o = Getitem(obj, i); - const char *trunc = ""; - if (DohIsString(o)) { - String *s = Str(o); - if (Len(s) > 70) { - trunc = "..."; - } - Replaceall(o, "<", "<"); - Printf(os, " ? [%d] - \"%(escape)-0.70s%s\"\n", o, i, s, trunc); - Delete(s); - } else { - Printf(os, " ? [%d] - %p\n", o, i, o); - } - } - Printf(os, "\n]\n"); - Printf(out, "
\n%s
\n", Char(os)); - Delete(os); - } -} - -void data_handler(FILE *f) { - DOH *n = 0; - if (!swill_getargs("p(n)", &n)) { - n = 0; - } - Printf(f, "SWIG-%s\n", Swig_package_version()); - Printf(f, "SWIG-%s
\n", Swig_package_version()); - Printf(f, "[ Exit ]"); - Printf(f, " [ Top ]", tree_top); - Printf(f, "

\n"); - if (n) { - raw_data(f, n); - } - /* Print standard footer */ - Printf(f, "


\n"); -} - -void symbol_handler(FILE *f) { - Symtab *sym; - char *name = 0; - - Printf(f, "SWIG-%s\n", Swig_package_version()); - Printf(f, "SWIG-%s
\n", Swig_package_version()); - Printf(f, "[ Exit ]"); - Printf(f, " [ Top ]", tree_top); - Printf(f, " [ Symbols ]"); - Printf(f, "

\n"); - - if (!swill_getargs("p(sym)|s(name)", &sym, &name)) { - sym = Swig_symbol_getscope(""); - name = 0; - } - if (!sym) { - Printf(f, "No symbol table specified!\n"); - return; - } - { - String *q = Swig_symbol_qualifiedscopename(sym); - if (!Len(q)) { - Printf(f, "Symbol table: :: (global)
\n"); - } else { - Printf(f, "Symbol table: %s
\n", q); - } - Delete(q); - } - - fprintf(f, "

\n"); - fprintf(f, "Symbol lookup:
\n"); - fprintf(f, "\n", sym); - fprintf(f, "Submit : \n"); - fprintf(f, "
"); - - if (name) { - Node *n = Swig_symbol_clookup(name, sym); - Printf(f, "Symbol '%s':\n", name); - Printf(f, "
\n"); - if (!n) { - Printf(f, "Not defined!\n"); - } else { - raw_data(f, n); - } - Printf(f, "
\n"); - } - - Printf(f, "

Nested scopes
\n"); - Printf(f, "

\n");
-  {
-    Hash *h;
-    h = firstChild(sym);
-    while (h) {
-      Printf(f, "%s\n", h, Getattr(h, "name"));
-      h = nextSibling(h);
-    }
-  }
-  Printf(f, "
\n"); - - Printf(f, "

Symbol table contents
\n"); - raw_data(f, Getattr(sym, "symtab")); - Printf(f, "


\n"); - -} -#endif - -void Swig_browser(Node *top, int port) { -#ifdef SWIG_SWILL - int sport; - browser_exit = 0; - - /* Initialize the server */ - sport = swill_init(port); - if (sport < 0) { - Printf(stderr, "Couldn't open socket on port %d. Sorry.\n", port); - return; - } - browse = new Browser(); - Setmeta(top, "visible", "1"); - tree_top = top; - - Printf(stderr, "SWIG: Tree browser listening on port %d\n", sport); - - swill_handle("exit.html", exit_handler, 0); - swill_handle("index.html", node_handler, 0); - swill_handle("hide.html", hide_handler, 0); - swill_handle("show.html", show_handler, 0); - swill_handle("data.html", data_handler, 0); - swill_handle("symbol.html", symbol_handler, 0); - swill_netscape("index.html"); - - while (!browser_exit) { - swill_serve(); - } - Printf(stderr, "Browser terminated.\n"); - swill_close(); - delete browse; - return; -#else - (void) top; - (void) port; -#endif -} diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index f412a3eeb..9344a7299 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -194,7 +194,6 @@ static int dump_tags = 0; static int dump_module = 0; static int dump_top = 0; static int dump_xml = 0; -static int browse = 0; static int dump_typedef = 0; static int dump_classes = 0; static int werror = 0; @@ -850,9 +849,6 @@ static void getoptions(int argc, char *argv[]) { } else if (strcmp(argv[i], "-nocontract") == 0) { Swig_mark_arg(i); Swig_contract_mode_set(0); - } else if (strcmp(argv[i], "-browse") == 0) { - browse = 1; - Swig_mark_arg(i); } else if ((strcmp(argv[i], "-debug-typedef") == 0) || (strcmp(argv[i], "-dump_typedef") == 0)) { dump_typedef = 1; Swig_mark_arg(i); @@ -1335,9 +1331,6 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { lang->top(top); - if (browse) { - Swig_browser(top, 0); - } Delete(infile_filename); Delete(basename); } diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 3661a2b61..de6ee48ef 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -430,16 +430,14 @@ extern "C" { void Swig_print_with_location(DOH *object, int count = -1); } +void Swig_default_allocators(Node *n); +void Swig_process_types(Node *n); + /* Contracts */ void Swig_contracts(Node *n); void Swig_contract_mode_set(int flag); int Swig_contract_mode_get(); -/* Browser */ -void Swig_browser(Node *n, int); -void Swig_default_allocators(Node *n); -void Swig_process_types(Node *n); - /* Nested classes */ void Swig_nested_process_classes(Node *n); void Swig_nested_name_unnamed_c_structs(Node *n); diff --git a/configure.ac b/configure.ac index feda58891..2afaf2275 100644 --- a/configure.ac +++ b/configure.ac @@ -460,10 +460,6 @@ AC_SEARCH_LIBS(t_open, nsl) # SVR4 AC_SEARCH_LIBS(gethostbyname, inet) # Sequent AC_SEARCH_LIBS(socket, socket) # SVR4 sockets -AC_CHECK_LIB(swill, swill_init, [SWIGLIBS="-lswill $LIBS" SWILL="-DSWIG_SWILL"]) -AC_SUBST(SWIGLIBS) -AC_SUBST(SWILL) - # check for --with-libm=... AC_SUBST(LIBM) LIBM=-lm