From c00aaf0f5b0f98f9939fe2e2f58d27567e035add Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Dec 2003 21:48:39 +0000 Subject: [PATCH] Moved non static function declarations from source files into header files git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5602 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 34 +++--------------------------- Source/CParse/util.c | 4 +--- Source/Makefile.am | 7 +----- Source/Modules/contract.cxx | 4 ---- Source/Modules/emit.cxx | 2 -- Source/Modules/main.cxx | 28 +++--------------------- Source/Modules/s-exp.cxx | 9 +++----- Source/Modules/swigmod.h | 31 +++++++++++++++++++-------- Source/Modules/xml.cxx | 9 +++----- Source/Preprocessor/cpp.c | 2 +- Source/Preprocessor/expr.c | 1 + Source/Preprocessor/preprocessor.h | 6 +++--- Source/Swig/swig.h | 22 +++++++++++-------- Source/Swig/typemap.c | 6 +++--- 14 files changed, 57 insertions(+), 108 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 97151e8c8..f2e488b87 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -19,6 +19,7 @@ char cvsroot_parser_y[] = "$Header$"; +#include "swig.h" #include "cparse.h" #include "preprocessor.h" #include @@ -31,28 +32,10 @@ char cvsroot_parser_y[] = "$Header$"; * Externals * ----------------------------------------------------------------------------- */ -extern int yylex(); -extern void yyerror (const char *e); - -/* scanner.cxx */ - -extern int cparse_line; -extern int cparse_start_line; -extern void skip_balanced(int startchar, int endchar); -extern void skip_decl(void); -extern void scanner_check_typedef(void); -extern void scanner_ignore_typedef(void); -extern void scanner_last_id(int); -extern void scanner_clear_rename(void); -extern void start_inline(char *, int); -extern String *scanner_ccode; -extern int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms); -extern Node *Swig_cparse_template_locate(String *name, ParmList *tparms); +int yyparse(); /* NEW Variables */ -extern void generate_all(Node *); - static Node *top = 0; /* Top of the generated parse tree */ static int unnamed = 0; /* Unnamed datatype counter */ static Hash *extendhash = 0; /* Hash table of added methods */ @@ -75,7 +58,7 @@ static int dirprot_mode = 0; * ----------------------------------------------------------------------------- */ /* Called by the parser (yyparse) when an error is found.*/ -void yyerror (const char *e) { +static void yyerror (const char *e) { } static Node *new_node(const String_or_char *tag) { @@ -302,9 +285,6 @@ static String *name_warning(String *name,SwigType *decl) { /* Add declaration list to symbol table */ static int add_only_one = 0; -extern void cparse_normalize_void(Node *); -extern int need_protected(Node *n, int dirprot_mode); - static void add_symbols(Node *n) { String *decl; String *wrn = 0; @@ -791,8 +771,6 @@ static Node *dump_nested(char *parent) { } Node *Swig_cparse(File *f) { - extern void scanner_file(File *); - extern int yyparse(); scanner_file(f); top = 0; yyparse(); @@ -4778,9 +4756,6 @@ empty : ; SwigType *Swig_cparse_type(String *s) { String *ns; - extern void scanner_file(File *); - extern int yyparse(); - extern void scanner_next_token(int); ns = NewStringf("%s;",s); Seek(ns,0,SEEK_SET); scanner_file(ns); @@ -4794,9 +4769,6 @@ SwigType *Swig_cparse_type(String *s) { Parm *Swig_cparse_parm(String *s) { String *ns; - extern void scanner_file(File *); - extern int yyparse(); - extern void scanner_next_token(int); ns = NewStringf("%s;",s); Seek(ns,0,SEEK_SET); scanner_file(ns); diff --git a/Source/CParse/util.c b/Source/CParse/util.c index 18aa99789..78a7aff65 100644 --- a/Source/CParse/util.c +++ b/Source/CParse/util.c @@ -12,8 +12,7 @@ char cvsroot_util_c[] = "$Header$"; #include "swig.h" - -extern SwigType *Swig_cparse_type(String *); +#include "cparse.h" /* ----------------------------------------------------------------------------- * Swig_cparse_replace_descriptor() @@ -94,7 +93,6 @@ void cparse_normalize_void(Node *n) { * Detects when we need to fully register the protected member. * * ----------------------------------------------------------------------------- */ -extern int Swig_need_protected(); int need_protected(Node* n, int dirprot_mode) { diff --git a/Source/Makefile.am b/Source/Makefile.am index 17cda6c10..1de835a03 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -17,12 +17,7 @@ AM_CFLAGS = -I$(BUILD_SOURCE_DIR)/Include \ -I$(SOURCE_DIR)/Swig \ -I$(SOURCE_DIR)/Modules -AM_CXXFLAGS = -I$(BUILD_SOURCE_DIR)/Include \ - -I$(SOURCE_DIR)/Include \ - -I$(SOURCE_DIR)/DOH \ - -I$(SOURCE_DIR)/Preprocessor \ - -I$(SOURCE_DIR)/Swig \ - -I$(SOURCE_DIR)/Modules \ +AM_CXXFLAGS = $(AM_CFLAGS) \ $(SWIG_CXX_DEFS) AM_YFLAGS = -d diff --git a/Source/Modules/contract.cxx b/Source/Modules/contract.cxx index bc2799603..d9732303e 100644 --- a/Source/Modules/contract.cxx +++ b/Source/Modules/contract.cxx @@ -56,10 +56,6 @@ public: virtual int top(Node *n); }; -extern void Swig_contracts(Node *n); -extern void Swig_contract_mode_set(int flag); -extern int Swig_contract_mode_get(); - static int Contract_Mode = 0; /* contract option */ static int InClass = 0; /* Parsing C++ or not */ static int InConstructor = 0; diff --git a/Source/Modules/emit.cxx b/Source/Modules/emit.cxx index 1fc968512..c8868d9ea 100644 --- a/Source/Modules/emit.cxx +++ b/Source/Modules/emit.cxx @@ -16,8 +16,6 @@ char cvsroot_emit_cxx[] = "$Header$"; -extern int Swig_contract_mode_get(); - /* ----------------------------------------------------------------------------- * emit_args() * diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 7e4ba94dd..e7fe8130d 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -25,11 +25,7 @@ char cvsroot_main_cxx[] = "$Header$"; #endif #include "swigwarn.h" - -extern "C" { -#include "preprocessor.h" -} - +#include "cparse.h" #include // Global variables @@ -102,8 +98,7 @@ static String *outdir = 0; // Checks the suffix of a file to see if we should emit extern declarations. // ----------------------------------------------------------------------------- -int -check_suffix(char *name) { +static int check_suffix(char *name) { char *c; if (!name) return 0; c = Swig_file_suffix(name); @@ -123,8 +118,7 @@ check_suffix(char *name) { // Install all command line options as preprocessor symbols // ----------------------------------------------------------------------------- -static void -install_opts(int argc, char *argv[]) { +static void install_opts(int argc, char *argv[]) { int i; int noopt = 0; char *c; @@ -201,16 +195,6 @@ void SWIG_config_cppext(const char *ext) { cpp_extension = (char *) ext; } -extern "C" Node *Swig_cparse(File *); -extern "C" void Swig_cparse_cplusplus(int); -extern "C" void Swig_cparse_debug_templates(int); -extern void Wrapper_virtual_elimination_mode_set(int); -extern void Wrapper_director_protected_mode_set(int); - -extern void Swig_contracts(Node *n); -extern void Swig_contract_mode_set(int flag); -extern int Swig_contract_mode_get(); - int SWIG_main(int argc, char *argv[], Language *l) { int i; char *c; @@ -222,7 +206,6 @@ int SWIG_main(int argc, char *argv[], Language *l) { int tm_debug = 0; char *includefiles[256]; int includecount = 0; - extern int check_suffix(char *); int dump_tags = 0; int dump_tree = 0; int browse = 0; @@ -232,13 +215,8 @@ int SWIG_main(int argc, char *argv[], Language *l) { int depend = 0; int memory_debug = 0; int allkw = 0; - DOH *libfiles = 0; DOH *cpps = 0 ; - extern void Swig_browser(Node *n, int); - extern void Swig_default_allocators(Node *n); - extern void Swig_process_types(Node *n); - /* Initialize the SWIG core */ Swig_init(); diff --git a/Source/Modules/s-exp.cxx b/Source/Modules/s-exp.cxx index bd3970a25..5d332dc29 100644 --- a/Source/Modules/s-exp.cxx +++ b/Source/Modules/s-exp.cxx @@ -406,10 +406,7 @@ public: }; -extern "C" -{ - Language * swig_sexp( void ) - { - return new Sexp(); - } +extern "C" Language * +swig_sexp( void ) { + return new Sexp(); } diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 0360d9c3e..becf2fa1b 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -21,11 +21,8 @@ #include #include -extern "C" { #include "swig.h" -Hash *Preprocessor_define(const String_or_char *str, int swigmacro); -} - +#include "preprocessor.h" #include "swigwarn.h" #define NOT_VIRTUAL 0 @@ -309,11 +306,27 @@ ModuleFactory Swig_find_module(const char *name); /* Utilities */ -extern int is_public(Node* n); -extern int is_private(Node* n); -extern int is_protected(Node* n); -extern int is_member_director(Node* parentnode, Node* member); -extern int is_member_director(Node* member); +int is_public(Node* n); +int is_private(Node* n); +int is_protected(Node* n); +int is_member_director(Node* parentnode, Node* member); +int is_member_director(Node* member); +void Wrapper_virtual_elimination_mode_set(int); +void Wrapper_director_protected_mode_set(int); + + +/* 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); + #endif diff --git a/Source/Modules/xml.cxx b/Source/Modules/xml.cxx index 2832e1a1f..040e86c11 100644 --- a/Source/Modules/xml.cxx +++ b/Source/Modules/xml.cxx @@ -332,10 +332,7 @@ public: }; -extern "C" -{ - Language * swig_xml( void ) - { - return new XML(); - } +extern "C" Language * +swig_xml( void ) { + return new XML(); } diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 188bea058..3890d039a 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -17,6 +17,7 @@ char cvsroot_cpp_c[] = "$Header$"; +#include "swig.h" #include "preprocessor.h" #include @@ -112,7 +113,6 @@ List *Preprocessor_depend(void) { * void Preprocessor_cpp_init() - Initialize the preprocessor * ----------------------------------------------------------------------------- */ void Preprocessor_init() { - extern void Preprocessor_expr_init(void); Hash *s; cpp = NewHash(); s = NewHash(); diff --git a/Source/Preprocessor/expr.c b/Source/Preprocessor/expr.c index 39a54149c..bfd0cb4b5 100644 --- a/Source/Preprocessor/expr.c +++ b/Source/Preprocessor/expr.c @@ -12,6 +12,7 @@ char cvsroot_expr_c[] = "$Header$"; +#include "swig.h" #include "preprocessor.h" static SwigScanner *scan = 0; diff --git a/Source/Preprocessor/preprocessor.h b/Source/Preprocessor/preprocessor.h index eb4f8feda..1be525e1f 100644 --- a/Source/Preprocessor/preprocessor.h +++ b/Source/Preprocessor/preprocessor.h @@ -11,10 +11,9 @@ * $Header$ * ----------------------------------------------------------------------------- */ -#ifndef _PREPROCESSOR_H -#define _PREPROCESSOR_H +#ifndef PREPROCESSOR_H_ +#define PREPROCESSOR_H_ -#include "swig.h" #include "swigwarn.h" #ifdef __cplusplus @@ -30,6 +29,7 @@ extern void Preprocessor_include_all(int); extern void Preprocessor_import_all(int); extern void Preprocessor_ignore_missing(int); extern List *Preprocessor_depend(void); +extern void Preprocessor_expr_init(void); #ifdef __cplusplus } diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 6e97d536c..b11a4a1c5 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -12,14 +12,18 @@ * $Header$ * ----------------------------------------------------------------------------- */ -#ifndef _SWIGCORE_H -#define _SWIGCORE_H +#ifndef SWIGCORE_H_ +#define SWIGCORE_H_ #include #include #include #include +#ifdef __cplusplus +extern "C" { +#endif + #include "doh.h" /* Status codes */ @@ -486,13 +490,13 @@ extern void Swig_typemap_attach_parms(const String_or_char *op, ParmList *parm extern void Swig_fragment_register(String *name, String *section, String *code); extern void Swig_fragment_emit(String *name); - + +/* hacks defined in C++ ! */ +extern int Swig_need_protected(); + +#ifdef __cplusplus +} #endif - - - - - - +#endif diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 6af9224ae..d6bbef748 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -12,9 +12,10 @@ char cvsroot_typemap_c[] = "$Header$"; #include "swig.h" +#include "cparse.h" #include -void replace_embedded_typemap(String *s, Wrapper *f); +static void replace_embedded_typemap(String *s, Wrapper *f); /* ----------------------------------------------------------------------------- * Typemaps are stored in a collection of nested hash tables. Something like @@ -1437,7 +1438,6 @@ static List *split_embedded(String *s) { static void split_var(String *s, String **name, String **value) { char *eq; char *c; - extern Parm *Swig_cparse_parm(String *s); eq = Strstr(s,"="); if (!eq) { @@ -1462,7 +1462,7 @@ static void split_var(String *s, String **name, String **value) { } } -void replace_embedded_typemap(String *s, Wrapper *f) { +static void replace_embedded_typemap(String *s, Wrapper *f) { while (Strstr(s,"$TYPEMAP(")) { /* Gather the argument */