From 36be36d6185cf75c91532f9aa50fb2f77bc55465 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 30 Apr 2014 12:00:23 +1200 Subject: [PATCH] Eliminate needless casting away const from string constants --- Source/CParse/parser.y | 16 ++++++++-------- Source/Modules/allegrocl.cxx | 2 +- Source/Modules/allocate.cxx | 4 ++-- Source/Modules/cffi.cxx | 2 +- Source/Modules/chicken.cxx | 12 ++++++------ Source/Modules/clisp.cxx | 2 +- Source/Modules/csharp.cxx | 2 +- Source/Modules/d.cxx | 2 +- Source/Modules/go.cxx | 2 +- Source/Modules/guile.cxx | 6 +++--- Source/Modules/java.cxx | 2 +- Source/Modules/lua.cxx | 2 +- Source/Modules/main.cxx | 10 +++++----- Source/Modules/modula3.cxx | 2 +- Source/Modules/mzscheme.cxx | 4 ++-- Source/Modules/ocaml.cxx | 4 ++-- Source/Modules/octave.cxx | 2 +- Source/Modules/perl5.cxx | 2 +- Source/Modules/php.cxx | 2 +- Source/Modules/pike.cxx | 2 +- Source/Modules/python.cxx | 6 +++--- Source/Modules/r.cxx | 2 +- Source/Modules/ruby.cxx | 4 ++-- Source/Modules/tcl8.cxx | 2 +- Source/Modules/uffi.cxx | 2 +- Source/Swig/cwrap.c | 2 +- 26 files changed, 50 insertions(+), 50 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 0ed438e90..7e7e5633f 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1418,7 +1418,7 @@ static void mark_nodes_as_extend(Node *n) { String *nexcept; } dtype; struct { - char *type; + const char *type; String *filename; int line; } loc; @@ -2002,8 +2002,8 @@ include_directive: includetype options string BEGINFILE { } ; -includetype : INCLUDE { $$.type = (char *) "include"; } - | IMPORT { $$.type = (char *) "import"; ++import_mode;} +includetype : INCLUDE { $$.type = "include"; } + | IMPORT { $$.type = "import"; ++import_mode;} ; /* ------------------------------------------------------------ @@ -4292,7 +4292,7 @@ cpp_namespace_decl : NAMESPACE idcolon LBRACE { | NAMESPACE LBRACE { Hash *h; $1 = Swig_symbol_current(); - h = Swig_symbol_clookup((char *)" ",0); + h = Swig_symbol_clookup(" ",0); if (h && (Strcmp(nodeType(h),"namespace") == 0)) { Swig_symbol_setscope(Getattr(h,"symtab")); } else { @@ -5271,7 +5271,7 @@ notso_direct_declarator : idcolon { SwigType *t; $$ = $1; t = NewStringEmpty(); - SwigType_add_array(t,(char*)""); + SwigType_add_array(t,""); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); @@ -5370,7 +5370,7 @@ direct_declarator : idcolon { SwigType *t; $$ = $1; t = NewStringEmpty(); - SwigType_add_array(t,(char*)""); + SwigType_add_array(t,""); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); @@ -5540,7 +5540,7 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET { SwigType *t; $$ = $1; t = NewStringEmpty(); - SwigType_add_array(t,(char*)""); + SwigType_add_array(t,""); if ($$.type) { SwigType_push(t,$$.type); Delete($$.type); @@ -5563,7 +5563,7 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET { $$.id = 0; $$.parms = 0; $$.have_parms = 0; - SwigType_add_array($$.type,(char*)""); + SwigType_add_array($$.type,""); } | LBRACKET expr RBRACKET { $$.type = NewStringEmpty(); diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 93477057f..c7d9ff21b 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -20,7 +20,7 @@ // #define ALLEGROCL_TYPE_DEBUG // #define ALLEGROCL_CLASS_DEBUG -static const char *usage = (char *) "\ +static const char *usage = "\ Allegro CL Options (available with -allegrocl)\n\ -identifier-converter - \n\ Specifies the type of conversion to do on C identifiers to convert\n\ diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx index d3618634b..dc3820766 100644 --- a/Source/Modules/allocate.cxx +++ b/Source/Modules/allocate.cxx @@ -714,7 +714,7 @@ Allocate(): /* Check if base classes allow smart pointers, but might be hidden */ if (!Getattr(n, "allocate:smartpointer")) { - Node *sp = Swig_symbol_clookup((char *) "operator ->", 0); + Node *sp = Swig_symbol_clookup("operator ->", 0); if (sp) { /* Look for parent */ Node *p = parentNode(sp); @@ -833,7 +833,7 @@ Allocate(): or reference. We're going to chase it to see if another operator->() can be found */ if ((SwigType_check_decl(type, "")) || (SwigType_check_decl(type, "r."))) { - Node *nn = Swig_symbol_clookup((char *) "operator ->", Getattr(sc, "symtab")); + Node *nn = Swig_symbol_clookup("operator ->", Getattr(sc, "symtab")); if (nn) { Delete(base); Delete(type); diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 6b331ad19..a1be00100 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -18,7 +18,7 @@ //#define CFFI_DEBUG //#define CFFI_WRAP_DEBUG -static const char *usage = (char *) "\ +static const char *usage = "\ CFFI Options (available with -cffi)\n\ -generate-typedef - Use defctype to generate shortcuts according to the\n\ typedefs in the input.\n\ diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index 89e583d18..986638cf3 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -15,7 +15,7 @@ #include -static const char *usage = (char *) "\ +static const char *usage = "\ \ CHICKEN Options (available with -chicken)\n\ -closprefix - Prepend to all clos identifiers\n\ @@ -29,7 +29,7 @@ CHICKEN Options (available with -chicken)\n\ \n"; static char *module = 0; -static char *chicken_path = (char *) "chicken"; +static const char *chicken_path = "chicken"; static int num_methods = 0; static File *f_begin = 0; @@ -620,7 +620,7 @@ int CHICKEN::functionWrapper(Node *n) { if (in_class) clos_name = NewString(member_name); else - clos_name = chickenNameMapping(scmname, (char *) ""); + clos_name = chickenNameMapping(scmname, ""); if (!any_specialized_arg) { method_def = NewString(""); @@ -775,7 +775,7 @@ int CHICKEN::variableWrapper(Node *n) { if (in_class) clos_name = NewString(member_name); else - clos_name = chickenNameMapping(scmname, (char *) ""); + clos_name = chickenNameMapping(scmname, ""); Node *class_node = classLookup(t); String *clos_code = Getattr(n, "tmap:varin:closcode"); @@ -942,7 +942,7 @@ int CHICKEN::constantWrapper(Node *n) { if (in_class) clos_name = NewString(member_name); else - clos_name = chickenNameMapping(scmname, (char *) ""); + clos_name = chickenNameMapping(scmname, ""); if (GetFlag(n, "feature:constasvar")) { Printv(clos_methods, "(define ", clos_name, " (", chickenPrimitiveName(scmname), "))\n", NIL); Printv(scm_const_defs, "(set! ", scmname, " (", scmname, "))\n", NIL); @@ -1372,7 +1372,7 @@ void CHICKEN::dispatchFunction(Node *n) { } else if (in_class) clos_name = NewString(member_name); else - clos_name = chickenNameMapping(scmname, (char *) ""); + clos_name = chickenNameMapping(scmname, ""); Iterator f; List *prev = 0; diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx index e7d971faa..7d7c69a50 100644 --- a/Source/Modules/clisp.cxx +++ b/Source/Modules/clisp.cxx @@ -13,7 +13,7 @@ #include "swigmod.h" -static const char *usage = (char *) "\ +static const char *usage = "\ CLISP Options (available with -clisp)\n\ -extern-all - Create clisp definitions for all the functions and\n\ global variables otherwise only definitions for\n\ diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 3e34e7f91..d30bd18c5 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -4303,7 +4303,7 @@ extern "C" Language *swig_csharp(void) { * Static member variables * ----------------------------------------------------------------------------- */ -const char *CSHARP::usage = (char *) "\ +const char *CSHARP::usage = "\ C# Options (available with -csharp)\n\ -dllimport
- Override DllImport attribute name to
\n\ -namespace - Generate wrappers into C# namespace \n\ diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 3387dd755..419828ea1 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -4649,7 +4649,7 @@ extern "C" Language *swig_d(void) { /* ----------------------------------------------------------------------------- * Usage information displayed at the command line. * ----------------------------------------------------------------------------- */ -const char *D::usage = (char *) "\ +const char *D::usage = "\ D Options (available with -d)\n\ -d2 - Generate code for D2/Phobos (default: D1/Tango)\n\ -package - Write generated D modules into package \n\ diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index c2d3948d4..e84109faf 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -5019,7 +5019,7 @@ extern "C" Language *swig_go(void) { * ----------------------------------------------------------------------------- */ // Usage message. -const char * const GO::usage = (char *) "\ +const char * const GO::usage = "\ Go Options (available with -go)\n\ -gccgo - Generate code for gccgo rather than 6g/8g\n\ -go-pkgpath

- Like gccgo -fgo-pkgpath option\n\ diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index 3a82d67d8..a9e51fd1b 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -16,7 +16,7 @@ #include // Note string broken in half for compilers that can't handle long strings -static const char *usage = (char *) "\ +static const char *usage = "\ Guile Options (available with -guile)\n\ -emitsetters - Emit procedures-with-setters for variables\n\ and structure slots.\n\ @@ -1018,7 +1018,7 @@ public: if (in_class) goops_name = NewString(memberfunction_name); else - goops_name = goopsNameMapping(proc_name, (char *) ""); + goops_name = goopsNameMapping(proc_name, ""); String *primitive_name = NewString(""); if (primRenamer) Printv(primitive_name, "primitive:", proc_name, NIL); @@ -1204,7 +1204,7 @@ public: // export wrapper into goops file if (!in_class) { // only if the variable is not part of a class String *class_name = SwigType_typedef_resolve_all(SwigType_base(t)); - String *goops_name = goopsNameMapping(proc_name, (char *) ""); + String *goops_name = goopsNameMapping(proc_name, ""); String *primitive_name = NewString(""); if (primRenamer) Printv(primitive_name, "primitive:", NIL); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index eda3ba7c8..9e16bb422 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -4643,7 +4643,7 @@ extern "C" Language *swig_java(void) { * Static member variables * ----------------------------------------------------------------------------- */ -const char *JAVA::usage = (char *) "\ +const char *JAVA::usage = "\ Java Options (available with -java)\n\ -nopgcpp - Suppress premature garbage collection prevention parameter\n\ -noproxy - Generate the low-level functional interface instead\n\ diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index ad4ba1925..46e21fb91 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -86,7 +86,7 @@ extern "C" you can add new ones here (though for now I have not bothered) NEW LANGUAGE NOTE:END ************************************************/ -static const char *usage = (char *) "\ +static const char *usage = "\ Lua Options (available with -lua)\n\ -elua - Generates LTR compatible wrappers for smaller devices running elua\n\ -eluac - LTR compatible wrappers in \"crass compress\" mode for elua\n\ diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 66e2548dc..833394b9c 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -160,9 +160,9 @@ static String *SwigLib = 0; // Library directory static String *SwigLibWinUnix = 0; // Extra library directory on Windows static int freeze = 0; static String *lang_config = 0; -static char *hpp_extension = (char *) "h"; -static char *cpp_extension = (char *) "cxx"; -static char *depends_extension = (char *) "d"; +static const char *hpp_extension = "h"; +static const char *cpp_extension = "cxx"; +static const char *depends_extension = "d"; static String *outdir = 0; static String *xmlout = 0; static int outcurrentdir = 0; @@ -324,7 +324,7 @@ const String *SWIG_output_directory() { } void SWIG_config_cppext(const char *ext) { - cpp_extension = (char *) ext; + cpp_extension = ext; } List *SWIG_output_files() { @@ -465,7 +465,7 @@ void SWIG_getoptions(int argc, char *argv[]) { Swig_mark_arg(i); } else if (strncmp(argv[i], "-D", 2) == 0) { String *d = NewString(argv[i] + 2); - Replace(d, (char *) "=", (char *) " ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST); + Replace(d, "=", " ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST); Preprocessor_define((DOH *) d, 0); Delete(d); // Create a symbol diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index 4c56d0664..db5d0981b 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -3956,7 +3956,7 @@ extern "C" Language *swig_modula3(void) { * Static member variables * ----------------------------------------------------------------------------- */ -const char *MODULA3::usage = (char *) "\ +const char *MODULA3::usage = "\ Modula 3 Options (available with -modula3)\n\ -generateconst - Generate code for computing numeric values of constants\n\ -generaterename - Generate suggestions for %rename\n\ diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index a147dd9c4..ed9641b30 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -15,7 +15,7 @@ #include -static const char *usage = (char *) "\ +static const char *usage = "\ Mzscheme Options (available with -mzscheme)\n\ -declaremodule - Create extension that declares a module\n\ -dynamic-load ,[library,...] - Do not link with these libraries, dynamic load\n\ @@ -36,7 +36,7 @@ static bool declaremodule = false; static bool noinit = false; static String *load_libraries = NULL; static String *module = 0; -static char *mzscheme_path = (char *) "mzscheme"; +static const char *mzscheme_path = "mzscheme"; static String *init_func_def = 0; static File *f_begin = 0; diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index f60c13ed3..f1ec8a8cf 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -15,7 +15,7 @@ #include -static const char *usage = (char *) "\ +static const char *usage = "\ Ocaml Options (available with -ocaml)\n\ -oldvarnames - Old intermediary method names for variable wrappers\n\ -prefix - Set a prefix to be prepended to all names\n\ @@ -29,7 +29,7 @@ static int const_enum = 0; static int static_member_function = 0; static int generate_sizeof = 0; static String *prefix = 0; -static char *ocaml_path = (char *) "ocaml"; +static const char *ocaml_path = "ocaml"; static bool old_variable_names = false; static String *classname = 0; static String *module = 0; diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 14118972d..103b59194 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -17,7 +17,7 @@ static String *global_name = 0; static String *op_prefix = 0; -static const char *usage = (char *) "\ +static const char *usage = "\ Octave Options (available with -octave)\n\ -globals - Set used to access C global variables [default: 'cvar']\n\ Use '.' to load C global variables into module namespace\n\ diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 28f4a3f3d..ff504d461 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -17,7 +17,7 @@ static int treduce = SWIG_cparse_template_reduce(0); #include -static const char *usage = (char *) "\ +static const char *usage = "\ Perl5 Options (available with -perl5)\n\ -compat - Compatibility mode\n\ -const - Wrap constants as constants and not variables (implies -proxy)\n\ diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index d497302db..86e1274a8 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -42,7 +42,7 @@ #include #include -static const char *usage = (char *) "\ +static const char *usage = "\ PHP Options (available with -php)\n\ -cppext - Change C++ file extension to (default is cpp)\n\ -noproxy - Don't generate proxy classes.\n\ diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx index cdbddc15d..22c5a638b 100644 --- a/Source/Modules/pike.cxx +++ b/Source/Modules/pike.cxx @@ -33,7 +33,7 @@ #include // for isalnum() -static const char *usage = (char *) "\ +static const char *usage = "\ Pike Options (available with -pike)\n\ [no additional options]\n\ \n"; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 13ddbfb61..06c1c4868 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -107,7 +107,7 @@ enum autodoc_t { }; -static const char *usage1 = (char *) "\ +static const char *usage1 = "\ Python Options (available with -python)\n\ -aliasobj0 - Alias obj0 when using fastunpack, needed for some old typemaps \n\ -buildnone - Use Py_BuildValue(" ") to obtain Py_None (default in Windows)\n\ @@ -127,7 +127,7 @@ Python Options (available with -python)\n\ -keyword - Use keyword arguments\n\ -modern - Use modern python features only, without compatibility code\n\ -modernargs - Use \"modern\" args mechanism to pack/unpack the function arguments\n"; -static const char *usage2 = (char *) "\ +static const char *usage2 = "\ -newrepr - Use more informative version of __repr__ in proxy classes (default) \n\ -newvwm - New value wrapper mode, use only when everything else fails \n\ -noaliasobj0 - Don't generate an obj0 alias when using fastunpack (default) \n\ @@ -144,7 +144,7 @@ static const char *usage2 = (char *) "\ -noh - Don't generate the output header file\n\ -nomodern - Don't use modern python features which are not backwards compatible \n\ -nomodernargs - Use classic ParseTuple/CallFunction methods to pack/unpack the function arguments (default) \n"; -static const char *usage3 = (char *) "\ +static const char *usage3 = "\ -noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\ -nooutputtuple - Use a PyList for appending output values (default) \n\ -noproxy - Don't generate proxy classes \n\ diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 0a3fb722b..3befcfbdd 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -205,7 +205,7 @@ static void writeListByLine(List *l, File *out, bool quote = 0) { } -static const char *usage = (char *)"\ +static const char *usage = "\ R Options (available with -r)\n\ -copystruct - Emit R code to copy C structs (on by default)\n\ -cppcast - Enable C++ casting operators (default) \n\ diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 5ff599d54..6aeaae5a1 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -130,7 +130,7 @@ enum autodoc_t { AUTODOC_NONE }; -static const char *usage = (char *) "\ +static const char *usage = "\ Ruby Options (available with -ruby)\n\ -autorename - Enable renaming of classes and methods to follow Ruby coding standards\n\ -cppcast - Enable C++ casting operators (default)\n\ @@ -1111,7 +1111,7 @@ public: /* typedef void *VALUE */ SwigType *value = NewSwigType(T_VOID); SwigType_add_pointer(value); - SwigType_typedef(value, (char *) "VALUE"); + SwigType_typedef(value, "VALUE"); Delete(value); /* Set module name */ diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index e61071167..ac356098b 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -15,7 +15,7 @@ #include "cparse.h" static int treduce = SWIG_cparse_template_reduce(0); -static const char *usage = (char *) "\ +static const char *usage = "\ Tcl 8 Options (available with -tcl)\n\ -itcl - Enable ITcl support\n\ -nosafe - Leave out SafeInit module function.\n\ diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index b0136a361..d56ed3b1f 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -15,7 +15,7 @@ #include "swigmod.h" -static const char *usage = (char *) "\ +static const char *usage = "\ UFFI Options (available with -uffi)\n\ -identifier-converter - \n\ Specifies the type of conversion to do on C identifiers\n\ diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index ec0acfa77..d15c2e12f 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -467,7 +467,7 @@ static String *Swig_cmethod_call(const_String_or_char_ptr name, ParmList *parms, return func; if (!self) - self = (char *) "(this)->"; + self = "(this)->"; Append(func, self); if (SwigType_istemplate(name) && (strncmp(Char(name), "operator ", 9) == 0)) {