summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CParse/cparse.h8
-rw-r--r--Source/CParse/cscanner.c43
-rw-r--r--Source/CParse/parser.y141
-rw-r--r--Source/CParse/templ.c2
-rw-r--r--Source/DOH/README12
-rw-r--r--Source/DOH/base.c4
-rw-r--r--Source/DOH/doh.h15
-rw-r--r--Source/DOH/file.c11
-rw-r--r--Source/DOH/hash.c2
-rw-r--r--Source/DOH/list.c2
-rw-r--r--Source/DOH/string.c2
-rw-r--r--Source/Include/swigwarn.h5
-rw-r--r--Source/Modules/allegrocl.cxx394
-rw-r--r--Source/Modules/cffi.cxx51
-rw-r--r--Source/Modules/chicken.cxx41
-rw-r--r--Source/Modules/clisp.cxx13
-rw-r--r--Source/Modules/contract.cxx8
-rw-r--r--Source/Modules/csharp.cxx108
-rw-r--r--Source/Modules/directors.cxx4
-rw-r--r--Source/Modules/guile.cxx41
-rw-r--r--Source/Modules/java.cxx61
-rw-r--r--Source/Modules/lang.cxx79
-rw-r--r--Source/Modules/lua.cxx30
-rw-r--r--Source/Modules/main.cxx200
-rw-r--r--Source/Modules/modula3.cxx50
-rw-r--r--Source/Modules/mzscheme.cxx24
-rw-r--r--[-rwxr-xr-x]Source/Modules/ocaml.cxx35
-rw-r--r--Source/Modules/octave.cxx47
-rw-r--r--Source/Modules/overload.cxx8
-rw-r--r--Source/Modules/perl5.cxx143
-rw-r--r--Source/Modules/php.cxx130
-rw-r--r--Source/Modules/pike.cxx28
-rw-r--r--Source/Modules/python.cxx687
-rw-r--r--Source/Modules/r.cxx36
-rw-r--r--Source/Modules/ruby.cxx93
-rw-r--r--Source/Modules/s-exp.cxx12
-rw-r--r--Source/Modules/swigmain.cxx6
-rw-r--r--Source/Modules/swigmod.h21
-rw-r--r--Source/Modules/tcl8.cxx30
-rw-r--r--Source/Modules/typepass.cxx58
-rw-r--r--Source/Modules/uffi.cxx25
-rw-r--r--Source/Modules/xml.cxx6
-rw-r--r--Source/Preprocessor/cpp.c35
-rw-r--r--Source/Preprocessor/preprocessor.h4
-rw-r--r--Source/README9
-rw-r--r--Source/Swig/cwrap.c53
-rw-r--r--Source/Swig/error.c10
-rw-r--r--Source/Swig/getopt.c2
-rw-r--r--Source/Swig/include.c57
-rw-r--r--Source/Swig/misc.c95
-rw-r--r--Source/Swig/naming.c32
-rw-r--r--Source/Swig/parms.c2
-rw-r--r--Source/Swig/scanner.c25
-rw-r--r--Source/Swig/stype.c8
-rw-r--r--Source/Swig/swig.h137
-rw-r--r--Source/Swig/swigfile.h31
-rw-r--r--Source/Swig/swigopt.h2
-rw-r--r--Source/Swig/swigparm.h2
-rw-r--r--Source/Swig/swigscan.h4
-rw-r--r--Source/Swig/swigtree.h2
-rw-r--r--Source/Swig/swigwrap.h12
-rw-r--r--Source/Swig/symbol.c34
-rw-r--r--Source/Swig/tree.c2
-rw-r--r--Source/Swig/typemap.c30
-rw-r--r--Source/Swig/typeobj.c10
-rw-r--r--Source/Swig/typesys.c15
-rw-r--r--Source/Swig/wrapfunc.c12
67 files changed, 2096 insertions, 1245 deletions
diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h
index 06a901c0d..9be41c60e 100644
--- a/Source/CParse/cparse.h
+++ b/Source/CParse/cparse.h
@@ -34,16 +34,18 @@ extern "C" {
extern void scanner_ignore_typedef(void);
extern void scanner_last_id(int);
extern void scanner_clear_rename(void);
- extern void scanner_set_location(String_or_char *, int line);
+ extern void scanner_set_location(String *file, int line);
+ extern void scanner_set_main_input_file(String *file);
+ extern String *scanner_get_main_input_file();
extern void Swig_cparse_follow_locators(int);
extern void start_inline(char *, int);
extern String *scanner_ccode;
- extern int yylex();
+ extern int yylex(void);
/* parser.y */
extern SwigType *Swig_cparse_type(String *);
extern Node *Swig_cparse(File *);
- extern Hash *Swig_cparse_features();
+ extern Hash *Swig_cparse_features(void);
extern void SWIG_cparse_set_compact_default_args(int defargs);
extern int SWIG_cparse_template_reduce(int treduce);
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index 032c71f7e..8734c7d0e 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -22,7 +22,10 @@ char cvsroot_cscanner_c[] = "$Id$";
static Scanner *scan = 0;
/* Global string containing C code. Used by the parser to grab code blocks */
-DOHString *scanner_ccode = 0;
+String *scanner_ccode = 0;
+
+/* The main file being parsed */
+static String *main_input_file = 0;
/* Error reporting/location information */
int cparse_line = 1;
@@ -261,10 +264,8 @@ int yylook(void) {
while (1) {
if ((tok = Scanner_token(scan)) == 0)
return 0;
- if (tok == SWIG_TOKEN_ERROR) {
- Swig_error(Scanner_file(scan), Scanner_errline(scan), Scanner_errmsg(scan));
- continue;
- }
+ if (tok == SWIG_TOKEN_ERROR)
+ return 0;
cparse_start_line = Scanner_start_line(scan);
cparse_line = Scanner_line(scan);
cparse_file = Scanner_file(scan);
@@ -441,7 +442,7 @@ int yylook(void) {
static int check_typedef = 0;
-void scanner_set_location(String_or_char *file, int line) {
+void scanner_set_location(String *file, int line) {
Scanner_set_location(scan,file,line-1);
}
@@ -467,6 +468,14 @@ void scanner_next_token(int tok) {
next_token = tok;
}
+void scanner_set_main_input_file(String *file) {
+ main_input_file = file;
+}
+
+String *scanner_get_main_input_file() {
+ return main_input_file;
+}
+
/* ----------------------------------------------------------------------------
* int yylex()
*
@@ -690,10 +699,22 @@ int yylex(void) {
termtoken = SWIG_TOKEN_LPAREN;
termvalue = "(";
break;
- } else if (nexttok == SWIG_TOKEN_SEMI) {
+ } else if (nexttok == SWIG_TOKEN_CODEBLOCK) {
+ termtoken = SWIG_TOKEN_CODEBLOCK;
+ termvalue = Char(Scanner_text(scan));
+ break;
+ } else if (nexttok == SWIG_TOKEN_LBRACE) {
+ termtoken = SWIG_TOKEN_LBRACE;
+ termvalue = "{";
+ break;
+ } else if (nexttok == SWIG_TOKEN_SEMI) {
termtoken = SWIG_TOKEN_SEMI;
termvalue = ";";
break;
+ } else if (nexttok == SWIG_TOKEN_STRING) {
+ termtoken = SWIG_TOKEN_STRING;
+ termvalue = Swig_copy_string(Char(Scanner_text(scan)));
+ break;
} else if (nexttok == SWIG_TOKEN_ID) {
if (needspace) {
Append(s," ");
@@ -859,8 +880,14 @@ int yylex(void) {
return (INLINE);
if (strcmp(yytext, "%typemap") == 0)
return (TYPEMAP);
- if (strcmp(yytext, "%feature") == 0)
+ if (strcmp(yytext, "%feature") == 0) {
+ /* The rename_active indicates we don't need the information of the
+ * following function's return type. This applied for %rename, so do
+ * %feature.
+ */
+ rename_active = 1;
return (FEATURE);
+ }
if (strcmp(yytext, "%except") == 0)
return (EXCEPT);
if (strcmp(yytext, "%importfile") == 0)
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 58e0c0c41..0babfbbb8 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -66,7 +66,7 @@ static void yyerror (const char *e) {
(void)e;
}
-static Node *new_node(const String_or_char *tag) {
+static Node *new_node(const_String_or_char_ptr tag) {
Node *n = NewHash();
set_nodeType(n,tag);
Setfile(n,cparse_file);
@@ -203,7 +203,7 @@ static String *yyrename = 0;
static String *resolve_node_scope(String *cname);
-Hash *Swig_cparse_features() {
+Hash *Swig_cparse_features(void) {
static Hash *features_hash = 0;
if (!features_hash) features_hash = NewHash();
return features_hash;
@@ -1002,6 +1002,68 @@ static void add_nested(Nested *n) {
}
}
+/* Strips C-style and C++-style comments from string in-place. */
+static void strip_comments(char *string) {
+ int state = 0; /*
+ * 0 - not in comment
+ * 1 - in c-style comment
+ * 2 - in c++-style comment
+ * 3 - in string
+ * 4 - after reading / not in comments
+ * 5 - after reading * in c-style comments
+ * 6 - after reading \ in strings
+ */
+ char * c = string;
+ while (*c) {
+ switch (state) {
+ case 0:
+ if (*c == '\"')
+ state = 3;
+ else if (*c == '/')
+ state = 4;
+ break;
+ case 1:
+ if (*c == '*')
+ state = 5;
+ *c = ' ';
+ break;
+ case 2:
+ if (*c == '\n')
+ state = 0;
+ else
+ *c = ' ';
+ break;
+ case 3:
+ if (*c == '\"')
+ state = 0;
+ else if (*c == '\\')
+ state = 6;
+ break;
+ case 4:
+ if (*c == '/') {
+ *(c-1) = ' ';
+ *c = ' ';
+ state = 2;
+ } else if (*c == '*') {
+ *(c-1) = ' ';
+ *c = ' ';
+ state = 1;
+ } else
+ state = 0;
+ break;
+ case 5:
+ if (*c == '/')
+ state = 0;
+ *c = ' ';
+ break;
+ case 6:
+ state = 3;
+ break;
+ }
+ ++c;
+ }
+}
+
/* Dump all of the nested class declarations to the inline processor
* However. We need to do a few name replacements and other munging
* first. This function must be called before closing a class! */
@@ -1053,6 +1115,9 @@ static Node *dump_nested(const char *parent) {
ret = retx;
*/
+ /* Strip comments - further code may break in presence of comments. */
+ strip_comments(Char(n->code));
+
/* Make all SWIG created typedef structs/unions/classes unnamed else
redefinition errors occur - nasty hack alert.*/
@@ -1360,7 +1425,7 @@ static void default_arguments(Node *n) {
* Used by the parser to mark subtypes with extra information.
* ----------------------------------------------------------------------------- */
-static void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) {
+static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
while (n) {
Setattr(n, attrname, value);
tag_nodes(firstChild(n), attrname, value);
@@ -1886,14 +1951,19 @@ fragment_directive: FRAGMENT LPAREN fname COMMA kwargs RPAREN HBLOCK {
;
/* ------------------------------------------------------------
- %includefile "filename" [ declarations ]
- %importfile "filename" [ declarations ]
+ %includefile "filename" [option1="xyz", ...] [ declarations ]
+ %importfile "filename" [option1="xyz", ...] [ declarations ]
------------------------------------------------------------ */
include_directive: includetype options string LBRACKET {
$1.filename = Copy(cparse_file);
$1.line = cparse_line;
scanner_set_location(NewString($3),1);
+ if ($2) {
+ String *maininput = Getattr($2, "maininput");
+ if (maininput)
+ scanner_set_main_input_file(NewString(maininput));
+ }
} interface RBRACKET {
String *mname = 0;
$$ = $6;
@@ -2290,21 +2360,25 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr
String *val = $7 ? NewString($7) : NewString("1");
new_feature($3, val, 0, $5.id, $5.type, $5.parms, $6.qualifier);
$$ = 0;
+ scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum RPAREN declarator cpp_const SEMI {
String *val = Len($5) ? NewString($5) : 0;
new_feature($3, val, 0, $7.id, $7.type, $7.parms, $8.qualifier);
$$ = 0;
+ scanner_clear_rename();
}
| FEATURE LPAREN idstring featattr RPAREN declarator cpp_const stringbracesemi {
String *val = $8 ? NewString($8) : NewString("1");
new_feature($3, val, $4, $6.id, $6.type, $6.parms, $7.qualifier);
$$ = 0;
+ scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum featattr RPAREN declarator cpp_const SEMI {
String *val = Len($5) ? NewString($5) : 0;
new_feature($3, val, $6, $8.id, $8.type, $8.parms, $9.qualifier);
$$ = 0;
+ scanner_clear_rename();
}
/* Global feature */
@@ -2312,21 +2386,25 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr
String *val = $5 ? NewString($5) : NewString("1");
new_feature($3, val, 0, 0, 0, 0, 0);
$$ = 0;
+ scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum RPAREN SEMI {
String *val = Len($5) ? NewString($5) : 0;
new_feature($3, val, 0, 0, 0, 0, 0);
$$ = 0;
+ scanner_clear_rename();
}
| FEATURE LPAREN idstring featattr RPAREN stringbracesemi {
String *val = $6 ? NewString($6) : NewString("1");
new_feature($3, val, $4, 0, 0, 0, 0);
$$ = 0;
+ scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum featattr RPAREN SEMI {
String *val = Len($5) ? NewString($5) : 0;
new_feature($3, val, $6, 0, 0, 0, 0);
$$ = 0;
+ scanner_clear_rename();
}
;
@@ -3152,15 +3230,15 @@ cpp_class_decl :
storage_class cpptype idcolon inherit LBRACE {
List *bases = 0;
Node *scope = 0;
- $$ = new_node("class");
- Setline($$,cparse_start_line);
- Setattr($$,"kind",$2);
+ $<node>$ = new_node("class");
+ Setline($<node>$,cparse_start_line);
+ Setattr($<node>$,"kind",$2);
if ($4) {
- Setattr($$,"baselist", Getattr($4,"public"));
- Setattr($$,"protectedbaselist", Getattr($4,"protected"));
- Setattr($$,"privatebaselist", Getattr($4,"private"));
+ Setattr($<node>$,"baselist", Getattr($4,"public"));
+ Setattr($<node>$,"protectedbaselist", Getattr($4,"protected"));
+ Setattr($<node>$,"privatebaselist", Getattr($4,"private"));
}
- Setattr($$,"allows_typedef","1");
+ Setattr($<node>$,"allows_typedef","1");
/* preserve the current scope */
prev_symtab = Swig_symbol_current();
@@ -3189,10 +3267,10 @@ cpp_class_decl :
nscope_inner = 0;
}
}
- Setattr($$,"name",$3);
+ Setattr($<node>$,"name",$3);
Delete(class_rename);
- class_rename = make_name($$,$3,0);
+ class_rename = make_name($<node>$,$3,0);
Classprefix = NewString($3);
/* Deal with inheritance */
if ($4) {
@@ -3256,12 +3334,12 @@ cpp_class_decl :
} else {
max_class_levels *= 2;
}
- class_decl = realloc(class_decl, sizeof(Node*) * max_class_levels);
+ class_decl = (Node**) realloc(class_decl, sizeof(Node*) * max_class_levels);
if (!class_decl) {
Swig_error(cparse_file, cparse_line, "realloc() failed\n");
}
}
- class_decl[class_level++] = $$;
+ class_decl[class_level++] = $<node>$;
inclass = 1;
} cpp_members RBRACE cpp_opt_declarators {
Node *p;
@@ -3384,14 +3462,14 @@ cpp_class_decl :
| storage_class cpptype LBRACE {
String *unnamed;
unnamed = make_unnamed();
- $$ = new_node("class");
- Setline($$,cparse_start_line);
- Setattr($$,"kind",$2);
- Setattr($$,"storage",$1);
- Setattr($$,"unnamed",unnamed);
- Setattr($$,"allows_typedef","1");
+ $<node>$ = new_node("class");
+ Setline($<node>$,cparse_start_line);
+ Setattr($<node>$,"kind",$2);
+ Setattr($<node>$,"storage",$1);
+ Setattr($<node>$,"unnamed",unnamed);
+ Setattr($<node>$,"allows_typedef","1");
Delete(class_rename);
- class_rename = make_name($$,0,0);
+ class_rename = make_name($<node>$,0,0);
if (strcmp($2,"class") == 0) {
cplus_mode = CPLUS_PRIVATE;
} else {
@@ -3405,12 +3483,12 @@ cpp_class_decl :
} else {
max_class_levels *= 2;
}
- class_decl = realloc(class_decl, sizeof(Node*) * max_class_levels);
+ class_decl = (Node**) realloc(class_decl, sizeof(Node*) * max_class_levels);
if (!class_decl) {
Swig_error(cparse_file, cparse_line, "realloc() failed\n");
}
}
- class_decl[class_level++] = $$;
+ class_decl[class_level++] = $<node>$;
inclass = 1;
Classprefix = NewStringEmpty();
Delete(Namespaceprefix);
@@ -5414,7 +5492,18 @@ valexpr : exprnum { $$ = $1; }
| LPAREN expr RPAREN expr %prec CAST {
$$ = $4;
if ($4.type != T_STRING) {
- $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $4.val);
+ switch ($2.type) {
+ case T_FLOAT:
+ case T_DOUBLE:
+ case T_LONGDOUBLE:
+ case T_FLTCPLX:
+ case T_DBLCPLX:
+ $$.val = NewStringf("(%s)%s", $2.val, $4.val); /* SwigType_str and decimal points don't mix! */
+ break;
+ default:
+ $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $4.val);
+ break;
+ }
}
}
| LPAREN expr pointer RPAREN expr %prec CAST {
diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c
index a3e992f83..14886605f 100644
--- a/Source/CParse/templ.c
+++ b/Source/CParse/templ.c
@@ -15,7 +15,7 @@ char cvsroot_templ_c[] = "$Id$";
static int template_debug = 0;
-String *baselists[3];
+const char *baselists[3];
void SwigType_template_init() {
baselists[0] = "baselist";
diff --git a/Source/DOH/README b/Source/DOH/README
index 1e948105c..9a42e8b8b 100644
--- a/Source/DOH/README
+++ b/Source/DOH/README
@@ -92,12 +92,12 @@ DohEncoding(name, fn) Register a format encoding for Printf
Currently Available datatypes
------------------------------
-NewString(char *initial) Strings
-NewHash() Hash
-NewList() List
-NewVoid(void *ptr, void (*del)(void *)) Void
-NewFile(char *file, char *mode) File
-NewCallable(DOH *(*func)(DOH *, DOH *)) Callable object
+NewString(char *initial) Strings
+NewHash() Hash
+NewList() List
+NewVoid(void *ptr, void (*del)(void *)) Void
+NewFile(char *filename, char *mode, List *newfiles) File
+NewCallable(DOH *(*func)(DOH *, DOH *)) Callable object
Odds and ends:
diff --git a/Source/DOH/base.c b/Source/DOH/base.c
index dcb0140e0..15827f328 100644
--- a/Source/DOH/base.c
+++ b/Source/DOH/base.c
@@ -827,7 +827,7 @@ void DohSetfile(DOH *ho, DOH *file) {
/* -----------------------------------------------------------------------------
* DohGetFile()
* ----------------------------------------------------------------------------- */
-DOH *DohGetfile(DOH *ho) {
+DOH *DohGetfile(const DOH *ho) {
DohBase *h = (DohBase *) ho;
DohObjInfo *objinfo;
if (!h)
@@ -854,7 +854,7 @@ void DohSetline(DOH *ho, int l) {
/* -----------------------------------------------------------------------------
* DohGetLine()
* ----------------------------------------------------------------------------- */
-int DohGetline(DOH *ho) {
+int DohGetline(const DOH *ho) {
DohBase *h = (DohBase *) ho;
DohObjInfo *objinfo;
if (!h)
diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h
index 7ab244fab..766e12a34 100644
--- a/Source/DOH/doh.h
+++ b/Source/DOH/doh.h
@@ -144,6 +144,9 @@ typedef void DOH;
#define DOHString_or_char DOH
#define DOHObj_or_char DOH
+typedef const DOHString_or_char * const_String_or_char_ptr;
+typedef const DOHString_or_char * DOHconst_String_or_char_ptr;
+
#define DOH_BEGIN -1
#define DOH_END -2
#define DOH_CUR -3
@@ -234,9 +237,9 @@ extern DohIterator DohNext(DohIterator x);
/* Positional */
-extern int DohGetline(DOH *obj);
+extern int DohGetline(const DOH *obj);
extern void DohSetline(DOH *obj, int line);
-extern DOH *DohGetfile(DOH *obj);
+extern DOH *DohGetfile(const DOH *obj);
extern void DohSetfile(DOH *obj, DOH *file);
/* String Methods */
@@ -271,7 +274,7 @@ extern int DohGetmark(DOH *obj);
* Strings.
* ----------------------------------------------------------------------------- */
-extern DOHString *DohNewStringEmpty();
+extern DOHString *DohNewStringEmpty(void);
extern DOHString *DohNewString(const DOH *c);
extern DOHString *DohNewStringWithSize(const DOH *c, int len);
extern DOHString *DohNewStringf(const DOH *fmt, ...);
@@ -297,7 +300,7 @@ extern char *DohStrchr(const DOHString_or_char *s1, int ch);
* Files
* ----------------------------------------------------------------------------- */
-extern DOHFile *DohNewFile(DOH *file, const char *mode);
+extern DOHFile *DohNewFile(DOH *filename, const char *mode, DOHList *outfiles);
extern DOHFile *DohNewFileFromFile(FILE *f);
extern DOHFile *DohNewFileFromFd(int fd);
extern void DohFileErrorDisplay(DOHString * filename);
@@ -309,14 +312,14 @@ extern int DohCopyto(DOHFile * input, DOHFile * output);
* List
* ----------------------------------------------------------------------------- */
-extern DOHList *DohNewList();
+extern DOHList *DohNewList(void);
extern void DohSortList(DOH *lo, int (*cmp) (const DOH *, const DOH *));
/* -----------------------------------------------------------------------------
* Hash
* ----------------------------------------------------------------------------- */
-extern DOHHash *DohNewHash();
+extern DOHHash *DohNewHash(void);
/* -----------------------------------------------------------------------------
* Void
diff --git a/Source/DOH/file.c b/Source/DOH/file.c
index 8c53978ee..65c2336a4 100644
--- a/Source/DOH/file.c
+++ b/Source/DOH/file.c
@@ -228,15 +228,16 @@ static DohObjInfo DohFileType = {
* NewFile()
*
* Create a new file from a given filename and mode.
+ * If newfiles is non-zero, the filename is added to the list of new files.
* ----------------------------------------------------------------------------- */
-DOH *DohNewFile(DOH *fn, const char *mode) {
+DOH *DohNewFile(DOH *filename, const char *mode, DOHList *newfiles) {
DohFile *f;
FILE *file;
- char *filename;
+ char *filen;
- filename = Char(fn);
- file = fopen(filename, mode);
+ filen = Char(filename);
+ file = fopen(filen, mode);
if (!file)
return 0;
@@ -245,6 +246,8 @@ DOH *DohNewFile(DOH *fn, const char *mode) {
fclose(file);
return 0;
}
+ if (newfiles)
+ Append(newfiles, filename);
f->filep = file;
f->fd = 0;
f->closeondel = 1;
diff --git a/Source/DOH/hash.c b/Source/DOH/hash.c
index 62aef10f2..045de8b5b 100644
--- a/Source/DOH/hash.c
+++ b/Source/DOH/hash.c
@@ -535,7 +535,7 @@ DohObjInfo DohHashType = {
* Create a new hash table.
* ----------------------------------------------------------------------------- */
-DOH *DohNewHash() {
+DOH *DohNewHash(void) {
Hash *h;
int i;
h = (Hash *) DohMalloc(sizeof(Hash));
diff --git a/Source/DOH/list.c b/Source/DOH/list.c
index a45731de1..7a1786299 100644
--- a/Source/DOH/list.c
+++ b/Source/DOH/list.c
@@ -345,7 +345,7 @@ DohObjInfo DohListType = {
#define MAXLISTITEMS 8
-DOH *DohNewList() {
+DOH *DohNewList(void) {
List *l;
int i;
l = (List *) DohMalloc(sizeof(List));
diff --git a/Source/DOH/string.c b/Source/DOH/string.c
index 1498d717a..141cd58e8 100644
--- a/Source/DOH/string.c
+++ b/Source/DOH/string.c
@@ -1056,7 +1056,7 @@ DOHString *DohNewString(const DOH *so) {
* NewStringEmpty() - Create a new string
* ----------------------------------------------------------------------------- */
-DOHString *DohNewStringEmpty() {
+DOHString *DohNewStringEmpty(void) {
int max = INIT_MAXSIZE;
String *str = (String *) DohMalloc(sizeof(String));
str->hashkey = 0;
diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h
index 90d668d6c..41b31d0ea 100644
--- a/Source/Include/swigwarn.h
+++ b/Source/Include/swigwarn.h
@@ -49,6 +49,7 @@
#define WARN_DEPRECATED_NOEXTERN 122
#define WARN_DEPRECATED_NODEFAULT 123
#define WARN_DEPRECATED_TYPEMAP_LANG 124
+#define WARN_DEPRECATED_INPUT_FILE 125
/* -- Preprocessor -- */
@@ -251,8 +252,8 @@
* PHP4 versions of new warnings since existing user interface files can't
* be using them.
*/
-#define WARN_PHP4_MULTIPLE_INHERITANCE 870
-#define WARN_PHP4_UNKNOWN_PRAGMA 871
+#define WARN_PHP_MULTIPLE_INHERITANCE 870
+#define WARN_PHP_UNKNOWN_PRAGMA 871
#define WARN_PHP_MULTIPLE_INHERITANCE 870
#define WARN_PHP_UNKNOWN_PRAGMA 871
diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx
index 217c89b1f..1eb12630c 100644
--- a/Source/Modules/allegrocl.cxx
+++ b/Source/Modules/allegrocl.cxx
@@ -21,7 +21,8 @@ char cvsroot_allegrocl_cxx[] = "$Id$";
static File *f_cl = 0;
String *f_clhead = NewString("");
String *f_clwrap = NewString("(swig-in-package ())\n\n");
-static File *f_cxx;
+static File *f_begin;
+static File *f_runtime;
static File *f_cxx_header = 0;
static File *f_cxx_wrapper = 0;
@@ -34,6 +35,8 @@ static bool CWrap = true; // generate wrapper file for C code by default. most c
static bool Generate_Wrapper = false;
static bool unique_swig_package = false;
+static SwigType *fwdref_ffi_type = NewString("__SWIGACL_FwdReference");
+
static String *current_namespace = NewString("");
static String *current_package = NewString("");
static Hash *defined_namespace_packages = NewHash();
@@ -168,6 +171,7 @@ static String *namespace_of(String *str) {
void add_linked_type(Node *n) {
#ifdef ALLEGROCL_CLASS_DEBUG
Printf(stderr, "Adding linked node of type: %s(%s) %s(%x)\n\n", nodeType(n), Getattr(n, "storage"), Getattr(n, "name"), n);
+ // Swig_print_node(n);
#endif
if (!first_linked_type) {
first_linked_type = n;
@@ -297,7 +301,8 @@ void add_forward_referenced_type(Node *n, int overwrite = 0) {
}
}
-void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, String *name = 0, String *ns = current_namespace) {
+void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
+ String *name = 0, String *ns = current_namespace) {
String *val;
String *ns_list = listify_namespace(ns);
@@ -321,22 +326,34 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, String
/*
For typedefs of the form:
- typedef __xxx { ... } xxx;
+ typedef struct __xxx { ... } xxx;
+
+ behavior differs between C mode and C++ mode.
+ C Mode:
add_defined_foreign_type will be called once via classHandler
- to define the type for 'struct __xxx', and once via typedefHandler
- to associate xxx with 'struct __xxx'.
+ to define the type for 'struct __xxx' and add the mapping from
+ 'struct __xxx' -> 'xxx'
- We create the following type to identifier mappings:
+ It will also be called once via typedefHandler to add the
+ mapping 'xxx' -> 'xxx'
- struct __xxx -> (swig-insert-id "xxx") via classHand
- xxx -> (swig-insert-id "xxx") via typedefHand
+ C++ Mode:
+ add_defined_foreign_type will be called once via classHandler
+ to define the type for 'xxx'. it also adds the mapping from
+ 'xxx' -> 'xxx' and also for 'struct xxx' -> 'xxx'
- and all references to this typedef'd struct will appear in
- generated code as 'xxx'. For non-typedef'd structs, the
- classHand mapping will be
+ In typedefHandler, we again try to add the mapping from
+ 'xxx' -> 'xxx', which already exists. This second mapping
+ is ignored.
- struct __xxx -> (swig-insert-id "__xxx")
+ Both modes:
+
+ All references to this typedef'd struct will appear in
+ generated lisp code as an objectd of type 'xxx'. For
+ non-typedef'd structs, the classHand mapping will be
+
+ struct __xxx -> (swig-insert-id "__xxx")
*/
// Swig_print_node(n);
String *unnamed = Getattr(n, "unnamed");
@@ -466,7 +483,7 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, String
if (!Strcmp(nodeType(n), "cdecl") && !Strcmp(Getattr(n, "storage"), "typedef")) {
SwigType *type = SwigType_strip_qualifiers(Getattr(n, "type"));
#ifdef ALLEGROCL_CLASS_DEBUG
- Printf(stderr, "Examining typedef '%s' for class references.\n", type);
+ Printf(stderr, "Examining typedef '%s' for class references. (%d)\n", type, SwigType_isclass(type));
#endif
if (SwigType_isclass(type)) {
#ifdef ALLEGROCL_CLASS_DEBUG
@@ -585,7 +602,11 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, String
Delete(mangled_name_gen);
Delete(mangled_lname_gen);
} else {
- Swig_warning(WARN_TYPE_REDEFINED, Getfile(n), Getline(n), "Attempting to store a foreign type that exists: %s (%s)\n", k, val);
+ if (!CPlusPlus || Strcmp(Getattr(n,"kind"),"typedef")) {
+ Swig_warning(WARN_TYPE_REDEFINED, Getfile(n), Getline(n),
+ "Attempting to store a foreign type that exists: %s (%s)\n",
+ k, val);
+ }
}
Delete(ns_list);
@@ -605,7 +626,7 @@ void note_implicit_template_instantiation(SwigType *t) {
add_defined_foreign_type(0, 0, t, t, implicit_ns ? implicit_ns : current_namespace);
}
-String *get_ffi_type(SwigType *ty, const String_or_char *name) {
+String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
/* lookup defined foreign type.
if it exists, it will return a form suitable for placing
into lisp code to generate the def-foreign-type name */
@@ -620,7 +641,8 @@ String *get_ffi_type(SwigType *ty, const String_or_char *name) {
#ifdef ALLEGROCL_TYPE_DEBUG
Printf(stderr, "found_type '%s'\n", found_type);
#endif
- return (Strcmp(found_type, "forward-reference") ? Copy(found_type) : NewString(":void"));
+ return (Strcmp(found_type, "forward-reference") ? Copy(found_type) :
+ get_ffi_type(fwdref_ffi_type, ""));
} else {
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
@@ -707,25 +729,40 @@ String *internal_compose_foreign_type(SwigType *ty) {
if (res)
Printf(ffiType, "%s", res);
}
-// while(resolved_type) {
-// // the resolved_type may expand into something like p.NS1::NS2::SomeType
-// // for which get_ffi_type will not find any match (due to the p.).
-// // Printf(stderr, "\n in resolved type loop on '%s'\n", resolved_type);
-// res = get_ffi_type(resolved_type, "");
-// if (res) {
-// Printf(ffiType, "%s", res);
-// break;
-// } else {
-// resolved_type = SwigType_typedef_resolve(resolved_type);
-// }
-// }
+
if (!res) {
- if (Strstr(tok, "struct ")) {
- Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(tok), Getline(tok), "Unable to find definition of '%s', assuming forward reference.\n", tok);
- } else {
- Printf(stderr, "Unable to compose foreign type of: '%s'\n", tok);
+ String *is_struct = 0;
+ String *tok_remove_text = 0;
+ String *tok_name = Copy(tok);
+ String *tok_key = SwigType_str(tok,0);
+ if ((is_struct = Strstr(tok_key, "struct ")) || Strstr(tok_key, "union ")) {
+ tok_remove_text = NewString(is_struct ? "struct " : "union ");
+ }
+
+ /* be more permissive of opaque types. This is the swig way.
+ compiles will notice if these types are ultimately not
+ present. */
+
+ if(tok_remove_text) {
+ Replaceall(tok_name,tok_remove_text,"");
}
- Printf(ffiType, "(* :void)");
+ tok_name = strip_namespaces(tok_name);
+ Delete(tok_remove_text);
+ // Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(tok), Getline(tok), "Unable to find definition of '%s', assuming forward reference.\n", tok);
+
+#ifdef ALLEGROCL_TYPE_DEBUG
+ Printf(stderr, "i-c-f-t: adding forward reference for unknown type '%s'. mapping: %s -> %s\n", tok, tok_key, tok_name);
+#endif
+ Node *nn = NewHash();
+ Setattr(nn,"nodeType","classforward");
+ Setattr(nn,"kind","class");
+ Setattr(nn,"sym:name",tok_name);
+ Setattr(nn,"name",tok_key);
+ Setattr(nn,"allegrocl:package",current_namespace);
+
+ add_forward_referenced_type(nn, 0);
+ // tok_name is dangling here, unused. ouch. why?
+ Printf(ffiType, "%s", get_ffi_type(tok, ""), tok_name);
}
}
}
@@ -733,24 +770,36 @@ String *internal_compose_foreign_type(SwigType *ty) {
return ffiType;
}
-String *compose_foreign_type(SwigType *ty, String *id = 0) {
+String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) {
+
+/* Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0); */
- Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0);
#ifdef ALLEGROCL_TYPE_DEBUG
Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty);
- String *id_ref = SwigType_str(ty, id);
+ // Printf(stderr, "compose_foreign_type: ENTER (%s)(%s)...\n ", ty, (id ? id : 0));
+ /* String *id_ref = SwigType_str(ty, id);
Printf(stderr, "looking up typemap for %s, found '%s'(%x)\n",
id_ref, lookup_res ? Getattr(lookup_res, "code") : 0, lookup_res);
+ if (lookup_res) Swig_print_node(lookup_res);
+ */
#endif
+
/* should we allow named lookups in the typemap here? YES! */
/* unnamed lookups should be found in get_ffi_type, called
by internal_compose_foreign_type(), below. */
+
+ /* I'm reverting to 'no' for the question above. I can no longer
+ remember why I needed it. If a user needed it, I'll find out
+ as soon as they upgrade. Sigh. -mutandiz 9/16/2008. */
+
+/*
if(id && lookup_res) {
#ifdef ALLEGROCL_TYPE_DEBUG
Printf(stderr, "compose_foreign_type: EXIT-1 (%s)\n ", Getattr(lookup_res, "code"));
#endif
return NewString(Getattr(lookup_res, "code"));
}
+*/
SwigType *temp = SwigType_strip_qualifiers(ty);
String *res = internal_compose_foreign_type(temp);
@@ -828,6 +877,10 @@ String *strip_parens(String *string) {
}
int ALLEGROCL::validIdentifier(String *s) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "validIdentifier %s\n", s);
+#endif
+
char *c = Char(s);
bool got_dot = false;
@@ -882,9 +935,8 @@ String *infix_to_prefix(String *val, char split_op, const String *op, String *ty
Printf(result, ")");
Delete(ored);
return part_failed ? 0 : result;
- } else {
- Delete(ored);
}
+ Delete(ored);
return 0;
}
@@ -903,7 +955,7 @@ String *convert_literal(String *literal, String *type, bool try_to_split) {
String *ns = listify_namespace(current_namespace);
// very basic parsing of infix expressions.
- if (try_to_split) {
+ if (try_to_split && SwigType_type(type) != T_STRING) {
if ((res = infix_to_prefix(num, '|', "logior", type)))
return res;
if ((res = infix_to_prefix(num, '&', "logand", type)))
@@ -918,9 +970,20 @@ String *convert_literal(String *literal, String *type, bool try_to_split) {
return res;
if ((res = infix_to_prefix(num, '-', "-", type)))
return res;
+ // if ((res = infix_to_prefix(num, '~', "lognot", type))) return res;
// if( (res = infix_to_prefix(num, '<<', "ash", type)) ) return res;
}
+ // unary complement...
+ if (s[0] == '~' && Len(num) >= 2) {
+ String *id = NewString(++s);
+ String *id_conv = convert_literal(id, type, false);
+ Delete(id);
+ if (id_conv)
+ return NewStringf("(lognot %s)", id_conv);
+ s--;
+ }
+
if (SwigType_type(type) == T_FLOAT || SwigType_type(type) == T_DOUBLE || SwigType_type(type) == T_LONGDOUBLE) {
// Use CL syntax for float literals
String *oldnum = Copy(num);
@@ -954,6 +1017,7 @@ String *convert_literal(String *literal, String *type, bool try_to_split) {
Delete(num);
num = 0;
}
+ Delete(lisp_exp);
} else {
String *id = NewStringf("#.(swig-insert-id \"%s\" %s :type :constant)",
num, ns);
@@ -1083,7 +1147,7 @@ void emit_synonym(Node *synonym) {
of_ltype = lookup_defined_foreign_ltype(of_name);
- // Printf(f_clhead,";; from emit-synonym\n");
+ // Printf(stderr,";; from emit-synonym syn='%s' of_ltype='%s'\n", syn_ltype, of_ltype);
if( of_ltype )
Printf(f_clhead, "(swig-def-synonym-type %s\n %s\n %s)\n", syn_ltype, of_ltype, syn_type);
@@ -1285,7 +1349,6 @@ void emit_typedef(Node *n) {
// leave these in for now. might want to change these to def-foreign-class at some point.
// Printf(f_clhead, ";; %s\n", SwigType_typedef_resolve_all(lisp_type));
- // Swig_print_node(n);
Printf(f_clhead, "(swig-def-foreign-type \"%s\"\n %s)\n", name, lisp_type);
Delete(name);
@@ -1469,6 +1532,7 @@ extern "C" Language *swig_allegrocl(void) {
void ALLEGROCL::main(int argc, char *argv[]) {
int i;
+ Preprocessor_define("SWIGALLEGROCL 1", 0);
SWIG_library_directory("allegrocl");
SWIG_config_file("allegrocl.swg");
@@ -1516,14 +1580,15 @@ void ALLEGROCL::main(int argc, char *argv[]) {
"\tcalled to convert identifiers to symbols.\n"
"\n"
" -[no]cwrap\n"
- "\tTurn on or turn off generation of an intermediate C file when\n" "\tcreating a C interface. By default this is only done for C++ code.\n");
+ "\tTurn on or turn off generation of an intermediate C file when\n" "\tcreating a C interface. By default this is only done for C++ code.\n"
+ " -isolate\n"
+ "Define all SWIG helper functions in a package unique to this module. Avoids redefinition warnings when loading multiple SWIGged modules\n"
+ "into the same running Allegro CL image.\n");
}
}
- Preprocessor_define("SWIGALLEGROCL 1", 0);
-
allow_overloading();
}
@@ -1536,7 +1601,7 @@ int ALLEGROCL::top(Node *n) {
Printf(cl_filename, "%s%s.cl", SWIG_output_directory(), module_name);
- f_cl = NewFile(cl_filename, "w");
+ f_cl = NewFile(cl_filename, "w", SWIG_output_files());
if (!f_cl) {
Printf(stderr, "Unable to open %s for writing\n", cl_filename);
SWIG_exit(EXIT_FAILURE);
@@ -1545,33 +1610,42 @@ int ALLEGROCL::top(Node *n) {
Generate_Wrapper = CPlusPlus || CWrap;
if (Generate_Wrapper) {
- f_cxx = NewFile(cxx_filename, "w");
- if (!f_cxx) {
+ f_begin = NewFile(cxx_filename, "w", SWIG_output_files());
+ if (!f_begin) {
Close(f_cl);
Delete(f_cl);
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
SWIG_exit(EXIT_FAILURE);
}
} else
- f_cxx = NewString("");
+ f_begin = NewString("");
- f_cxx_header = f_cxx;
+ f_runtime = NewString("");
+ f_cxx_header = f_runtime;
f_cxx_wrapper = NewString("");
Swig_register_filebyname("header", f_cxx_header);
Swig_register_filebyname("wrapper", f_cxx_wrapper);
- Swig_register_filebyname("runtime", f_cxx);
+ Swig_register_filebyname("begin", f_begin);
+ Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("lisp", f_clwrap);
Swig_register_filebyname("lisphead", f_cl);
- Printf(f_cl, ";; This is an automatically generated file. Make changes in\n"
- ";; the definition file, not here.\n\n"
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGALLEGROCL\n");
+ Printf(f_runtime, "\n");
+
+ Swig_banner_target_lang(f_cl, ";;");
+
+ Printf(f_cl, "\n"
"(defpackage :%s\n"
" (:use :common-lisp :ff :excl)\n"
" (:export #:*swig-identifier-converter* #:*swig-module-name*\n"
" #:*void* #:*swig-export-list*))\n"
"(in-package :%s)\n\n"
- "(eval-when (compile load eval)\n"
+ "(eval-when (:compile-toplevel :load-toplevel :execute)\n"
" (defparameter *swig-identifier-converter* '%s)\n"
" (defparameter *swig-module-name* :%s))\n\n", swig_package, swig_package, identifier_converter, module_name);
Printf(f_cl, "(defpackage :%s\n" " (:use :common-lisp :%s :ff :excl))\n\n", module_name, swig_package);
@@ -1582,7 +1656,7 @@ int ALLEGROCL::top(Node *n) {
Language::top(n);
- // SwigType_emit_type_table(f_cxx,f_cxx_wrapper);
+ // SwigType_emit_type_table(f_runtime,f_cxx_wrapper);
// Swig_print_tree(n);
#ifdef ALLEGROCL_TYPE_DEBUG
@@ -1605,8 +1679,12 @@ int ALLEGROCL::top(Node *n) {
Delete(f_clhead);
Delete(f_clwrap);
- Close(f_cxx);
- Delete(f_cxx);
+ Dump(f_runtime, f_begin);
+ Printf(f_begin, "%s\n", f_cxx_wrapper);
+
+ Close(f_begin);
+ Delete(f_runtime);
+ Delete(f_begin);
Delete(f_cxx_wrapper);
// Swig_print_tree(n);
@@ -1901,7 +1979,7 @@ int any_varargs(ParmList *pl) {
return 0;
}
-String *get_lisp_type(SwigType *ty, const String_or_char *name) {
+String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) {
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
@@ -2087,7 +2165,9 @@ struct IDargs {
String *arity;
IDargs():name(0), type(0), klass(0), arity(0) {
- } String *full_quoted_str() {
+ }
+
+ String *full_quoted_str() {
String *result = no_others_quoted_str();
if (arity)
Printf(result, " :arity %s", arity);
@@ -2338,41 +2418,24 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
for (p = pl; p; p = nextSibling(p), argnum++, largnum++) {
// SwigType *argtype=Getattr(p, "type");
SwigType *argtype = Swig_cparse_type(Getattr(p, "tmap:ctype"));
+ SwigType *parmtype = Getattr(p,"type");
if (!first) {
Printf(fcl, "\n ");
}
- if (SwigType_isvarargs(argtype)) {
- Printf(stderr, "Function %s (line %d) contains varargs, which is not directly supported. Use %%varargs instead.\n", Getattr(n, "name"), Getline(n));
- } else {
+ /* by default, skip varargs */
+ if (!SwigType_isvarargs(parmtype)) {
String *argname = NewStringf("PARM%d_%s", largnum, Getattr(p, "name"));
- // Swig_print_node(p);
// Printf(stderr,"%s\n", Getattr(p,"tmap:lin"));
String *ffitype = compose_foreign_type(argtype, Getattr(p,"name"));
- String *deref_ffitype;
-
- deref_ffitype = dereference_ffitype(ffitype);
-
-/*
- String *temp = Copy(argtype);
-
- if (SwigType_ispointer(temp)) {
- SwigType_pop(temp);
- deref_ffitype = compose_foreign_type(temp);
- } else {
- deref_ffitype = Copy(ffitype);
- }
-
- Delete(temp);
-*/
- // String *lisptype=get_lisp_type(argtype, argname);
- String *lisptype = get_lisp_type(Getattr(p, "type"), Getattr(p, "name"));
+ String *deref_ffitype = dereference_ffitype(ffitype);
+ String *lisptype = get_lisp_type(parmtype, Getattr(p, "name"));
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "lisptype of '%s' '%s' = '%s'\n",
- Getattr(p, "type"), Getattr(p, "name"), lisptype);
+ Printf(stderr, "lisptype of '%s' '%s' = '%s'\n", parmtype,
+ Getattr(p, "name"), lisptype);
#endif
// while we're walking the parameters, generating LIN
@@ -2403,7 +2466,9 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
first = 0;
}
+ Delete(argname);
Delete(ffitype);
+ Delete(deref_ffitype);
Delete(lisptype);
}
}
@@ -2441,11 +2506,6 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
lclass = lookup_defined_foreign_ltype(cl_t);
isPtrReturn = 1;
}
- // if (SwigType_ispointer(cl_t)) {
- // isPtrReturn = 1;
- // SwigType_pop(cl_t);
- // lclass = lookup_defined_foreign_ltype(cl_t);
- // }
int ff_foreign_ptr = 0;
if (!lclass) {
@@ -2518,6 +2578,11 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
}
int ALLEGROCL::functionWrapper(Node *n) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "functionWrapper %s\n", Getattr(n,"name"));
+ Swig_print_node(n);
+#endif
+
ParmList *parms = CopyParmList(Getattr(n, "parms"));
Wrapper *f = NewWrapper();
@@ -2532,11 +2597,13 @@ int ALLEGROCL::functionWrapper(Node *n) {
Delete(resolved);
if (!is_void_return) {
- String *lresult_init = NewStringf("= (%s)0", raw_return_type);
- Wrapper_add_localv(f, "lresult",
- SwigType_lstr(SwigType_ltype(return_type), "lresult"),
- lresult_init, NIL);
- Delete(lresult_init);
+ String *lresult_init =
+ NewStringf("= (%s)0",
+ SwigType_str(SwigType_strip_qualifiers(return_type),0));
+ Wrapper_add_localv(f, "lresult",
+ SwigType_lstr(SwigType_ltype(return_type), "lresult"),
+ lresult_init, NIL);
+ Delete(lresult_init);
}
// Emit all of the local variables for holding arguments.
emit_parameter_variables(parms, f);
@@ -2632,26 +2699,32 @@ int ALLEGROCL::functionWrapper(Node *n) {
String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
if (!is_void_return && tm) {
- Replaceall(tm, "$result", "lresult");
- Printf(f->code, "%s\n", tm);
- Printf(f->code, " return lresult;\n");
- Delete(tm);
- } else {
- Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(t, 0), name);
+ if (tm) {
+ Replaceall(tm, "$result", "lresult");
+ Printf(f->code, "%s\n", tm);
+ Printf(f->code, " return lresult;\n");
+ Delete(tm);
+ } else {
+ Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number,
+ "Unable to use return type %s in function %s.\n",
+ SwigType_str(t, 0), name);
+ }
}
+
emit_return_variable(n, t, f);
if (CPlusPlus) {
Printf(f->code, " } catch (...) {\n");
if (!is_void_return)
- Printf(f->code, " return (%s)0;\n", raw_return_type);
+ Printf(f->code, " return (%s)0;\n",
+ SwigType_str(SwigType_strip_qualifiers(return_type),0));
Printf(f->code, " }\n");
}
Printf(f->code, "}\n");
/* print this when in C mode? make this a command-line arg? */
if (Generate_Wrapper)
- Wrapper_print(f, f_cxx);
+ Wrapper_print(f, f_cxx_wrapper);
String *f_buffer = NewString("");
@@ -2673,13 +2746,15 @@ int ALLEGROCL::functionWrapper(Node *n) {
}
int ALLEGROCL::namespaceDeclaration(Node *n) {
- // Empty namespaces are not worth DEFPACKAGEing.
- // Swig_print_node(n);
#ifdef ALLEGROCL_DEBUG
Printf(stderr, "namespaceDecl: '%s'(0x%x) (fc=0x%x)\n", Getattr(n, "sym:name"), n, firstChild(n));
#endif
- if (!firstChild(n))
+ /* don't wrap a namespace with no contents. package bloat.
+ also, test-suite/namespace_class.i claims an unnamed namespace
+ is 'private' and should not be wrapped. Complying...
+ */
+ if (Getattr(n,"unnamed") || !firstChild(n))
return SWIG_OK;
String *name = Getattr(n, "sym:name");
@@ -2706,7 +2781,7 @@ int ALLEGROCL::namespaceDeclaration(Node *n) {
int ALLEGROCL::constructorHandler(Node *n) {
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "constructor %s\n", Getattr(n, "name"));
+ Printf(stderr, "constructorHandler %s\n", Getattr(n, "name"));
#endif
// Swig_print_node(n);
Setattr(n, "allegrocl:kind", "constructor");
@@ -2718,7 +2793,7 @@ int ALLEGROCL::constructorHandler(Node *n) {
int ALLEGROCL::destructorHandler(Node *n) {
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "destructor %s\n", Getattr(n, "name"));
+ Printf(stderr, "destructorHandler %s\n", Getattr(n, "name"));
#endif
Setattr(n, "allegrocl:kind", "destructor");
@@ -2729,9 +2804,8 @@ int ALLEGROCL::destructorHandler(Node *n) {
}
int ALLEGROCL::constantWrapper(Node *n) {
-
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "constant %s\n", Getattr(n, "name"));
+ Printf(stderr, "constantWrapper %s\n", Getattr(n, "name"));
#endif
if (Generate_Wrapper) {
@@ -2750,10 +2824,10 @@ int ALLEGROCL::constantWrapper(Node *n) {
}
SwigType_add_qualifier(const_type, "const");
- SwigType_add_qualifier(const_type, "static");
- String *ppcname = NewStringf("ACLppc_%s", Getattr(n, "name"));
- Printf(f_cxx, "static const %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val);
+ String *ppcname = NewStringf("ACLppc_%s", Getattr(n, "sym:name"));
+ // Printf(f_runtime, "static const %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val);
+ Printf(f_runtime, "static %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val);
Setattr(n, "name", ppcname);
SetFlag(n, "feature:immutable");
@@ -2787,6 +2861,10 @@ int ALLEGROCL::constantWrapper(Node *n) {
}
int ALLEGROCL::globalvariableHandler(Node *n) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "globalvariableHandler %s\n", Getattr(n, "name"));
+#endif
+
if (Generate_Wrapper)
return Language::globalvariableHandler(n);
@@ -2806,7 +2884,7 @@ int ALLEGROCL::globalvariableHandler(Node *n) {
ctype = SwigType_str(type, 0);
// EXPORT <SwigType_str> <mangled_name>;
// <SwigType_str> <mangled_name> = <name>;
- // Printf(f_cxx, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name,
+ // Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name,
// ctype, mangled_name, (pointer_added ? "&" : ""), name);
Printf(f_clwrap, "(swig-defvar \"%s\" \"%s\" :type %s)\n",
@@ -2817,7 +2895,7 @@ int ALLEGROCL::globalvariableHandler(Node *n) {
int ALLEGROCL::variableWrapper(Node *n) {
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "variable %s\n", Getattr(n, "name"));
+ Printf(stderr, "variableWrapper %s\n", Getattr(n, "name"));
#endif
Setattr(n, "allegrocl:kind", "variable");
Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name"));
@@ -2842,24 +2920,30 @@ int ALLEGROCL::variableWrapper(Node *n) {
}
ctype = SwigType_str(type, 0);
+
// EXPORT <SwigType_str> <mangled_name>;
// <SwigType_str> <mangled_name> = <name>;
- Printf(f_cxx, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, ctype, mangled_name, (pointer_added ? "&" : ""), name);
+ Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, ctype, mangled_name, (pointer_added ? "&" : ""), name);
Printf(f_cl, "(swig-defvar \"%s\" :type %s)\n", mangled_name, ((SwigType_isconst(type)) ? ":constant" : ":variable"));
/*
- Printf(f_cxx, "// swigtype: %s\n", SwigType_typedef_resolve_all(Getattr(n,"type")));
- Printf(f_cxx, "// vwrap: %s\n", compose_foreign_type(SwigType_strip_qualifiers(Copy(rtype))));
+ Printf(f_runtime, "// swigtype: %s\n", SwigType_typedef_resolve_all(Getattr(n,"type")));
+ Printf(f_runtime, "// vwrap: %s\n", compose_foreign_type(SwigType_strip_qualifiers(Copy(rtype))));
*/
+ Printf(stderr,"***\n");
Delete(mangled_name);
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "DONE variable %s\n", Getattr(n, "name"));
+#endif
+
return SWIG_OK;
}
int ALLEGROCL::memberfunctionHandler(Node *n) {
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "member function %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name"));
+ Printf(stderr, "memberfunctionHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name"));
#endif
Setattr(n, "allegrocl:kind", "member function");
Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name"));
@@ -2870,7 +2954,7 @@ int ALLEGROCL::memberfunctionHandler(Node *n) {
int ALLEGROCL::membervariableHandler(Node *n) {
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "member variable %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name"));
+ Printf(stderr, "membervariableHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name"));
#endif
Setattr(n, "allegrocl:kind", "member variable");
Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name"));
@@ -2880,10 +2964,8 @@ int ALLEGROCL::membervariableHandler(Node *n) {
}
int ALLEGROCL::typedefHandler(Node *n) {
-
#ifdef ALLEGROCL_TYPE_DEBUG
- Printf(stderr, "In typedefHAND\n");
- // Swig_print_node(n);
+ Printf(stderr, "In typedefHandler\n");
#endif
SwigType *typedef_type = Getattr(n,"type");
@@ -2901,9 +2983,7 @@ int ALLEGROCL::typedefHandler(Node *n) {
Printf(stderr, " typedef in class '%s'(%x)\n", Getattr(in_class, "sym:name"), in_class);
#endif
Setattr(n, "allegrocl:typedef:in-class", in_class);
- }
- if (in_class) {
String *class_name = Getattr(in_class, "name");
name = NewStringf("%s__%s", class_name, sym_name);
type_ref = NewStringf("%s::%s", class_name, sym_name);
@@ -2917,14 +2997,19 @@ int ALLEGROCL::typedefHandler(Node *n) {
String *lookup = lookup_defined_foreign_type(typedef_type);
- // Printf(stderr, "** lookup='%s'(%x), ff_type='%s', strstr = '%d'\n", lookup, lookup, ff_type, !Strstr(ff_type,"void"));
+#ifdef ALLEGROCL_TYPE_DEBUG
+ Printf(stderr, "** lookup='%s'(%x), typedef_type='%s', strcmp = '%d' strstr = '%d'\n", lookup, lookup, typedef_type, Strcmp(typedef_type,"void"), Strstr(ff_type,"__SWIGACL_FwdReference"));
+#endif
- if(lookup || (!lookup && !Strstr(ff_type,"void")))
+ if(lookup || (!lookup && Strcmp(typedef_type,"void")) ||
+ (!lookup && Strstr(ff_type,"__SWIGACL_FwdReference"))) {
add_defined_foreign_type(n, 0, type_ref, name);
- else add_forward_referenced_type(n);
+ } else {
+ add_forward_referenced_type(n);
+ }
#ifdef ALLEGROCL_TYPE_DEBUG
- Printf(stderr, "Out typedefHAND\n");
+ Printf(stderr, "Out typedefHandler\n");
#endif
Delete(ff_type);
@@ -2934,22 +3019,33 @@ int ALLEGROCL::typedefHandler(Node *n) {
// forward referenced classes are added specially to defined_foreign_types
int ALLEGROCL::classforwardDeclaration(Node *n) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "classforwardDeclaration %s\n", Getattr(n, "name"));
+#endif
+
add_forward_referenced_type(n);
return SWIG_OK;
}
int ALLEGROCL::classHandler(Node *n) {
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "class %s::%s\n", current_namespace, Getattr(n, "sym:name"));
+ Printf(stderr, "classHandler %s::%s\n", current_namespace, Getattr(n, "sym:name"));
#endif
+ int result;
+
if (Generate_Wrapper)
- return cppClassHandler(n);
+ result = cppClassHandler(n);
else
- return cClassHandler(n);
+ result = cClassHandler(n);
+
+ return result;
}
int ALLEGROCL::cClassHandler(Node *n) {
+#ifdef ALLEGROCL_TYPE_DEBUG
+ Printf(stderr, "In cClassHandler\n");
+#endif
// String *cDeclName = Getattr(n,"classDeclaration:name");
// String *name= Getattr(n, "sym:name");
// String *kind = Getattr(n,"kind");
@@ -2959,22 +3055,21 @@ int ALLEGROCL::cClassHandler(Node *n) {
// Printf(stderr, "Adding %s foreign type\n", name);
String *ns = listify_namespace(current_namespace);
-#ifdef ALLEGROCL_TYPE_DEBUG
- Printf(stderr, "In cClassHAND\n");
-#endif
-
add_defined_foreign_type(n);
Delete(ns);
#ifdef ALLEGROCL_TYPE_DEBUG
- Printf(stderr, "Out cClassHAND\n");
+ Printf(stderr, "Out cClassHandler\n");
#endif
return SWIG_OK;
}
int ALLEGROCL::cppClassHandler(Node *n) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "cppClassHandler %s\n", Getattr(n, "name"));
+#endif
// String *name=Getattr(n, "sym:name");
// String *kind = Getattr(n,"kind");
@@ -3033,6 +3128,9 @@ int ALLEGROCL::cppClassHandler(Node *n) {
// so their types can be added to the linked_type_list.
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"),
Getattr(c, "type"));
+#ifdef ALLEGROCL_CLASS_DEBUG
+ Printf(stderr, "looking at child '%x' of type '%s'\n", c, childType);
+#endif
if (!SwigType_isfunction(childType))
Delete(compose_foreign_type(childType));
@@ -3073,6 +3171,9 @@ int ALLEGROCL::emit_one(Node *n) {
}
int ALLEGROCL::enumDeclaration(Node *n) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "enumDeclaration %s\n", Getattr(n, "name"));
+#endif
if (Getattr(n, "sym:name")) {
add_defined_foreign_type(n);
@@ -3089,21 +3190,34 @@ int ALLEGROCL::enumDeclaration(Node *n) {
int ALLEGROCL::enumvalueDeclaration(Node *n) {
-
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "enumvalueDeclaration %s\n", Getattr(n, "name"));
+#endif
/* print this when in C mode? make this a command-line arg? */
-
if (Generate_Wrapper) {
- String *mangled_name = mangle_name(n, "ACL_ENUM");
-
- Printf(f_cxx, "EXPORT const %s %s = %s;\n", Getattr(n, "type"), mangled_name, Getattr(n, "value"));
+ SwigType *enum_type = Copy(Getattr(n,"type"));
+ String *mangled_name =
+ mangle_name(n, "ACL_ENUM",
+ in_class ? Getattr(in_class,"name") :
+ current_namespace);
+
+ SwigType_add_qualifier(enum_type,"const");
+
+ String *enum_decl = SwigType_str(enum_type, mangled_name);
+ Printf(f_cxx_wrapper, "EXPORT %s;\n", enum_decl);
+ Printf(f_cxx_wrapper, "%s = %s;\n", enum_decl, Getattr(n, "value"));
Delete(mangled_name);
+ Delete(enum_type);
+ Delete(enum_decl);
}
-
return SWIG_OK;
}
int ALLEGROCL::templateDeclaration(Node *n) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "templateDeclaration %s\n", Getattr(n, "name"));
+#endif
String *type = Getattr(n, "templatetype");
diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx
index 736564d1a..0aa933c56 100644
--- a/Source/Modules/cffi.cxx
+++ b/Source/Modules/cffi.cxx
@@ -22,7 +22,8 @@ public:
String *f_clhead;
String *f_clwrap;
bool CWrap; // generate wrapper file for C code?
- File *f_cxx;
+ File *f_begin;
+ File *f_runtime;
File *f_cxx_header;
File *f_cxx_wrapper;
File *f_clos;
@@ -67,6 +68,7 @@ private:
void CFFI::main(int argc, char *argv[]) {
int i;
+ Preprocessor_define("SWIGCFFI 1", 0);
SWIG_library_directory("cffi");
SWIG_config_file("cffi.swg");
generate_typedef_flag = 0;
@@ -119,16 +121,15 @@ int CFFI::top(Node *n) {
Printf(lisp_filename, "%s%s.lisp", SWIG_output_directory(), module);
- File *f_lisp = NewFile(lisp_filename, "w");
- NewFile(lisp_filename, "w");
+ File *f_lisp = NewFile(lisp_filename, "w", SWIG_output_files());
if (!f_lisp) {
FileErrorDisplay(lisp_filename);
SWIG_exit(EXIT_FAILURE);
}
if (CPlusPlus || CWrap) {
- f_cxx = NewFile(cxx_filename, "w");
- if (!f_cxx) {
+ f_begin = NewFile(cxx_filename, "w", SWIG_output_files());
+ if (!f_begin) {
Close(f_lisp);
Delete(f_lisp);
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
@@ -137,7 +138,7 @@ int CFFI::top(Node *n) {
String *clos_filename = NewString("");
Printf(clos_filename, "%s%s-clos.lisp", SWIG_output_directory(), module);
- f_clos = NewFile(clos_filename, "w");
+ f_clos = NewFile(clos_filename, "w", SWIG_output_files());
if (!f_clos) {
Close(f_lisp);
Delete(f_lisp);
@@ -145,22 +146,32 @@ int CFFI::top(Node *n) {
SWIG_exit(EXIT_FAILURE);
}
} else {
- f_cxx = NewString("");
+ f_begin = NewString("");
f_clos = NewString("");
}
- f_cxx_header = f_cxx;
+ f_runtime = NewString("");
+ f_cxx_header = f_runtime;
f_cxx_wrapper = NewString("");
Swig_register_filebyname("header", f_cxx_header);
Swig_register_filebyname("wrapper", f_cxx_wrapper);
- Swig_register_filebyname("runtime", f_cxx);
+ Swig_register_filebyname("begin", f_begin);
+ Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("lisphead", f_clhead);
if (!no_swig_lisp)
Swig_register_filebyname("swiglisp", f_cl);
else
Swig_register_filebyname("swiglisp", f_null);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGCFFI\n");
+ Printf(f_runtime, "\n");
+
+ Swig_banner_target_lang(f_lisp, ";;;");
+
Language::top(n);
Printf(f_lisp, "%s\n", f_clhead);
Printf(f_lisp, "%s\n", f_cl);
@@ -171,8 +182,10 @@ int CFFI::top(Node *n) {
Delete(f_cl);
Delete(f_clhead);
Delete(f_clwrap);
- Close(f_cxx);
- Delete(f_cxx);
+ Dump(f_runtime, f_begin);
+ Close(f_begin);
+ Delete(f_runtime);
+ Delete(f_begin);
Delete(f_cxx_wrapper);
Delete(f_null);
@@ -232,7 +245,7 @@ void CFFI::emit_defmethod(Node *n) {
ParmList *pl = Getattr(n, "parms");
int argnum = 0;
- Node *parent = parentNode(n);
+ Node *parent = getCurrentClass();
bool first = 0;
for (Parm *p = pl; p; p = nextSibling(p), argnum++) {
@@ -287,7 +300,7 @@ void CFFI::emit_initialize_instance(Node *n) {
ParmList *pl = Getattr(n, "parms");
int argnum = 0;
- Node *parent = parentNode(n);
+ Node *parent = getCurrentClass();
for (Parm *p = pl; p; p = nextSibling(p), argnum++) {
String *argname = Getattr(p, "name");
@@ -324,18 +337,18 @@ void CFFI::emit_initialize_instance(Node *n) {
}
void CFFI::emit_setter(Node *n) {
- Node *p = parentNode(n);
+ Node *parent = getCurrentClass();
Printf(f_clos, "(cl:defmethod (cl:setf %s) (arg0 (obj %s))\n (%s (ff-pointer obj) arg0))\n\n",
lispify_name(n, Getattr(n, "name"), "'method"),
- lispify_name(p, lispy_name(Char(Getattr(p, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function"));
+ lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function"));
}
void CFFI::emit_getter(Node *n) {
- Node *p = parentNode(n);
+ Node *parent = getCurrentClass();
Printf(f_clos, "(cl:defmethod %s ((obj %s))\n (%s (ff-pointer obj)))\n\n",
lispify_name(n, Getattr(n, "name"), "'method"),
- lispify_name(p, lispy_name(Char(Getattr(p, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function"));
+ lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function"));
}
int CFFI::memberfunctionHandler(Node *n) {
@@ -455,7 +468,7 @@ int CFFI::functionWrapper(Node *n) {
Printf(f->code, "}\n");
if (CPlusPlus)
- Wrapper_print(f, f_cxx);
+ Wrapper_print(f, f_runtime);
if (CPlusPlus) {
emit_defun(n, wname);
@@ -630,7 +643,7 @@ int CFFI::enumDeclaration(Node *n) {
else {
String *type = Getattr(c, "type");
String *converted_value = convert_literal(value, type);
- Printf(f_cl, "\n\t(%s %s)", slot_name, converted_value);
+ Printf(f_cl, "\n\t(%s #.%s)", slot_name, converted_value);
Delete(converted_value);
}
Delete(value);
diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx
index 2298d2939..12ef4b454 100644
--- a/Source/Modules/chicken.cxx
+++ b/Source/Modules/chicken.cxx
@@ -30,6 +30,7 @@ static char *module = 0;
static char *chicken_path = (char *) "chicken";
static int num_methods = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
@@ -101,12 +102,12 @@ protected:
int isPointer(SwigType *t);
void dispatchFunction(Node *n);
- String *chickenNameMapping(String *, String_or_char *);
+ String *chickenNameMapping(String *, const_String_or_char_ptr );
String *chickenPrimitiveName(String *);
String *runtimeCode();
String *defaultExternalRuntimeFilename();
- String *buildClosFunctionCall(List *types, String_or_char *closname, String_or_char *funcname);
+ String *buildClosFunctionCall(List *types, const_String_or_char_ptr closname, const_String_or_char_ptr funcname);
};
/* -----------------------------------------------------------------------
@@ -188,11 +189,12 @@ int CHICKEN::top(Node *n) {
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -205,6 +207,7 @@ int CHICKEN::top(Node *n) {
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@@ -215,14 +218,16 @@ int CHICKEN::top(Node *n) {
clos_methods = NewString("");
scm_const_defs = NewString("");
- Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n");
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
- Printf(f_runtime, "/* Implementation : CHICKEN */\n\n");
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGCHICKEN\n");
if (no_collection)
Printf(f_runtime, "#define SWIG_CHICKEN_NO_COLLECTION 1\n");
+ Printf(f_runtime, "\n");
+
/* Set module name */
module = Swig_copy_string(Char(Getattr(n, "name")));
scmmodule = NewString(module);
@@ -251,14 +256,14 @@ int CHICKEN::top(Node *n) {
Printf(f_init, "#endif\n");
Printf(chicken_filename, "%s%s.scm", SWIG_output_directory(), module);
- if ((f_scm = NewFile(chicken_filename, "w")) == 0) {
+ if ((f_scm = NewFile(chicken_filename, "w", SWIG_output_files())) == 0) {
FileErrorDisplay(chicken_filename);
SWIG_exit(EXIT_FAILURE);
}
- Printv(f_scm,
- ";; -*- buffer-read-only: t -*- vi: set ro:\n",
- ";; This file was created automatically by SWIG.\n", ";; Don't modify this file, modify the SWIG interface instead.\n", NIL);
+ Swig_banner_target_lang(f_scm, ";;");
+ Printf(f_scm, "\n");
+
if (declare_unit)
Printv(f_scm, "(declare (unit ", scmmodule, "))\n\n", NIL);
Printv(f_scm, "(declare \n",
@@ -307,15 +312,17 @@ int CHICKEN::top(Node *n) {
/* Close all of the files */
Delete(primitive_names);
Delete(scmmodule);
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_sym_size);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -1233,7 +1240,7 @@ int CHICKEN::importDirective(Node *n) {
return Language::importDirective(n);
}
-String *CHICKEN::buildClosFunctionCall(List *types, String_or_char *closname, String_or_char *funcname) {
+String *CHICKEN::buildClosFunctionCall(List *types, const_String_or_char_ptr closname, const_String_or_char_ptr funcname) {
String *method_signature = NewString("");
String *func_args = NewString("");
String *func_call = NewString("");
@@ -1507,7 +1514,7 @@ int CHICKEN::validIdentifier(String *s) {
* If class_name = "" that means the mapping is for a function or
* variable not attached to any class.
* ------------------------------------------------------------ */
-String *CHICKEN::chickenNameMapping(String *name, String_or_char *class_name) {
+String *CHICKEN::chickenNameMapping(String *name, const_String_or_char_ptr class_name) {
String *n = NewString("");
if (Strcmp(class_name, "") == 0) {
diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx
index 823f22e2c..fa73b3a0b 100644
--- a/Source/Modules/clisp.cxx
+++ b/Source/Modules/clisp.cxx
@@ -36,6 +36,7 @@ private:
void CLISP::main(int argc, char *argv[]) {
int i;
+ Preprocessor_define("SWIGCLISP 1", 0);
SWIG_library_directory("clisp");
SWIG_config_file("clisp.swg");
generate_typedef_flag = 0;
@@ -79,20 +80,22 @@ int CLISP::top(Node *n) {
Printf(output_filename, "%s%s.lisp", SWIG_output_directory(), module);
}
- f_cl = NewFile(output_filename, "w+");
+ f_cl = NewFile(output_filename, "w+", SWIG_output_files());
if (!f_cl) {
FileErrorDisplay(output_filename);
SWIG_exit(EXIT_FAILURE);
}
Swig_register_filebyname("header", f_null);
+ Swig_register_filebyname("begin", f_null);
Swig_register_filebyname("runtime", f_null);
Swig_register_filebyname("wrapper", f_null);
- String *header =
- NewStringf
- (";; This is an automatically generated file. \n;;Make changes as you feel are necessary (but remember if you try to regenerate this file, your changes will be lost). \n\n(defpackage :%s\n (:use :common-lisp :ffi)",
- module);
+ String *header = NewString("");
+
+ Swig_banner_target_lang(header, ";;");
+
+ Printf(header, "\n(defpackage :%s\n (:use :common-lisp :ffi)", module);
Language::top(n);
diff --git a/Source/Modules/contract.cxx b/Source/Modules/contract.cxx
index 9bf8decf6..518dc2997 100644
--- a/Source/Modules/contract.cxx
+++ b/Source/Modules/contract.cxx
@@ -46,6 +46,7 @@ public:
int extendDirective(Node *n);
int importDirective(Node *n);
int includeDirective(Node *n);
+ int namespaceDeclaration(Node *n);
int classDeclaration(Node *n);
virtual int top(Node *n);
};
@@ -320,16 +321,23 @@ int Contracts::constructorDeclaration(Node *n) {
int Contracts::externDeclaration(Node *n) {
return emit_children(n);
}
+
int Contracts::extendDirective(Node *n) {
return emit_children(n);
}
+
int Contracts::importDirective(Node *n) {
return emit_children(n);
}
+
int Contracts::includeDirective(Node *n) {
return emit_children(n);
}
+int Contracts::namespaceDeclaration(Node *n) {
+ return emit_children(n);
+}
+
int Contracts::classDeclaration(Node *n) {
int ret = SWIG_OK;
InClass = 1;
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index c802ad3a2..ad6830ec6 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -24,6 +24,7 @@ class CSHARP:public Language {
const String *protected_string;
Hash *swig_types_hash;
+ File *f_begin;
File *f_runtime;
File *f_runtime_h;
File *f_header;
@@ -85,7 +86,7 @@ class CSHARP:public Language {
enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum };
- static Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n) {
+ static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) {
Parm *p = NewParm(type, name);
Setfile(p, Getfile(n));
Setline(p, Getline(n));
@@ -102,6 +103,7 @@ public:
public_string(NewString("public")),
protected_string(NewString("protected")),
swig_types_hash(NULL),
+ f_begin(NULL),
f_runtime(NULL),
f_runtime_h(NULL),
f_header(NULL),
@@ -286,8 +288,8 @@ public:
SWIG_exit(EXIT_FAILURE);
}
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
@@ -297,13 +299,14 @@ public:
Printf(stderr, "Unable to determine outfile_h\n");
SWIG_exit(EXIT_FAILURE);
}
- f_runtime_h = NewFile(outfile_h, "w");
+ f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
if (!f_runtime_h) {
FileErrorDisplay(outfile_h);
SWIG_exit(EXIT_FAILURE);
}
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -313,6 +316,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("director", f_directors);
@@ -358,13 +362,17 @@ public:
if (!dllimport)
dllimport = Copy(module_class_name);
- Swig_banner(f_runtime); // Print the SWIG banner message
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGCSHARP\n");
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
/* Emit initial director header and director code: */
Swig_banner(f_directors_h);
+ Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_class_name);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_class_name);
@@ -376,6 +384,8 @@ public:
Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h));
}
+ Printf(f_runtime, "\n");
+
Swig_name_register((char *) "wrapper", (char *) "CSharp_%f");
if (old_variable_names) {
Swig_name_register((char *) "set", (char *) "set_%v");
@@ -396,7 +406,7 @@ public:
// Generate the intermediary class
{
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), imclass_name);
- File *f_im = NewFile(filen, "w");
+ File *f_im = NewFile(filen, "w", SWIG_output_files());
if (!f_im) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -440,7 +450,7 @@ public:
// Generate the C# module class
{
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), module_class_name);
- File *f_module = NewFile(filen, "w");
+ File *f_module = NewFile(filen, "w", SWIG_output_files());
if (!f_module) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -567,10 +577,11 @@ public:
n_dmethods = 0;
/* Close all of the files */
- Dump(f_header, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
if (directorsEnabled()) {
- Dump(f_directors, f_runtime);
+ Dump(f_directors, f_begin);
Dump(f_directors_h, f_runtime_h);
Printf(f_runtime_h, "\n");
@@ -585,13 +596,14 @@ public:
f_directors_h = NULL;
}
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -601,11 +613,7 @@ public:
void emitBanner(File *f) {
Printf(f, "/* ----------------------------------------------------------------------------\n");
- Printf(f, " * This file was automatically generated by SWIG (http://www.swig.org).\n");
- Printf(f, " * Version %s\n", Swig_package_version());
- Printf(f, " *\n");
- Printf(f, " * Do not make changes to this file unless you know what you are doing--modify\n");
- Printf(f, " * the SWIG interface file instead.\n");
+ Swig_banner_target_lang(f, " *");
Printf(f, " * ----------------------------------------------------------------------------- */\n\n");
}
@@ -1155,7 +1163,7 @@ public:
} else {
// Global enums are defined in their own file
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), symname);
- File *f_enum = NewFile(filen, "w");
+ File *f_enum = NewFile(filen, "w", SWIG_output_files());
if (!f_enum) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -1219,7 +1227,7 @@ public:
if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
// Wrap (non-anonymous) C/C++ enum with a proper C# enum
// Emit the enum item.
- if (!Getattr(n, "_last")) // Only the first enum item has this attribute set
+ if (!GetFlag(n, "firstenumitem"))
Printf(enum_code, ",\n");
Printf(enum_code, " %s", symname);
@@ -1489,6 +1497,7 @@ public:
Node *attributes = NewHash();
const String *pure_baseclass = typemapLookup("csbase", typemap_lookup_type, WARN_NONE, attributes);
bool purebase_replace = GetFlag(attributes, "tmap:csbase:replace") ? true : false;
+ bool purebase_notderived = GetFlag(attributes, "tmap:csbase:notderived") ? true : false;
Delete(attributes);
// C++ inheritance
@@ -1521,17 +1530,22 @@ public:
}
}
- const String *wanted_base = baseclass ? baseclass : pure_baseclass;
bool derived = baseclass && getProxyName(c_baseclassname);
+ if (derived && purebase_notderived)
+ pure_baseclass = empty_string;
+ const String *wanted_base = baseclass ? baseclass : pure_baseclass;
if (purebase_replace) {
wanted_base = pure_baseclass;
derived = false;
Delete(baseclass);
baseclass = NULL;
+ if (purebase_notderived)
+ Swig_error(input_file, line_number, "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, input_file, line_number,
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. Perhaps you need the replace attribute in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
+ "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. "
+ "Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
}
// Pure C# interfaces
@@ -1734,7 +1748,7 @@ public:
}
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), proxy_class_name);
- f_proxy = NewFile(filen, "w");
+ f_proxy = NewFile(filen, "w", SWIG_output_files());
if (!f_proxy) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -1887,6 +1901,7 @@ public:
bool setter_flag = false;
String *pre_code = NewString("");
String *post_code = NewString("");
+ String *terminator_code = NewString("");
if (!proxy_flag)
return;
@@ -2035,6 +2050,14 @@ public:
Printf(post_code, "\n");
Printv(post_code, post, NIL);
}
+ String *terminator = Getattr(p, "tmap:csin:terminator");
+ if (terminator) {
+ substituteClassname(pt, terminator);
+ Replaceall(terminator, "$csinput", arg);
+ if (Len(terminator_code) > 0)
+ Insert(terminator_code, 0, "\n");
+ Insert(terminator_code, 0, terminator);
+ }
Printv(imcall, tm, NIL);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0));
@@ -2060,7 +2083,8 @@ public:
excodeSubstitute(n, tm, "csout", n);
bool is_pre_code = Len(pre_code) > 0;
bool is_post_code = Len(post_code) > 0;
- if (is_pre_code || is_post_code) {
+ bool is_terminator_code = Len(terminator_code) > 0;
+ if (is_pre_code || is_post_code || is_terminator_code) {
Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap
if (is_post_code) {
Insert(tm, 0, "\n try ");
@@ -2072,6 +2096,9 @@ public:
Insert(tm, 0, pre_code);
Insert(tm, 0, "\n");
}
+ if (is_terminator_code) {
+ Printv(tm, "\n", terminator_code, NIL);
+ }
Insert(tm, 0, "{");
Printf(tm, "\n }");
}
@@ -2171,6 +2198,7 @@ public:
Delete(pre_code);
Delete(post_code);
+ Delete(terminator_code);
Delete(function_code);
Delete(return_type);
Delete(imcall);
@@ -2191,6 +2219,7 @@ public:
String *helper_args = NewString("");
String *pre_code = NewString("");
String *post_code = NewString("");
+ String *terminator_code = NewString("");
String *im_return_type = NewString("");
bool feature_director = (parentNode(n) && Swig_directorclass(n));
@@ -2286,6 +2315,14 @@ public:
Printf(post_code, "\n");
Printv(post_code, post, NIL);
}
+ String *terminator = Getattr(p, "tmap:csin:terminator");
+ if (terminator) {
+ substituteClassname(pt, terminator);
+ Replaceall(terminator, "$csinput", arg);
+ if (Len(terminator_code) > 0)
+ Insert(terminator_code, 0, "\n");
+ Insert(terminator_code, 0, terminator);
+ }
cshin = Getattr(p, "tmap:csin:cshin");
if (cshin)
Replaceall(cshin, "$csinput", arg);
@@ -2342,7 +2379,8 @@ public:
bool is_pre_code = Len(pre_code) > 0;
bool is_post_code = Len(post_code) > 0;
- if (is_pre_code || is_post_code) {
+ bool is_terminator_code = Len(terminator_code) > 0;
+ if (is_pre_code || is_post_code || is_terminator_code) {
Printf(helper_code, " {\n");
if (is_pre_code) {
Printv(helper_code, pre_code, "\n", NIL);
@@ -2354,6 +2392,9 @@ public:
} else {
Printv(helper_code, " return ", imcall, ";", NIL);
}
+ if (is_terminator_code) {
+ Printv(helper_code, "\n", terminator_code, NIL);
+ }
Printf(helper_code, "\n }\n");
String *helper_name = NewStringf("%s.SwigConstruct%s(%s)", proxy_class_name, proxy_class_name, helper_args);
String *im_outattributes = Getattr(n, "tmap:imtype:outattributes");
@@ -2372,6 +2413,7 @@ public:
Delete(im_return_type);
Delete(pre_code);
Delete(post_code);
+ Delete(terminator_code);
Delete(construct_tm);
Delete(attributes);
Delete(overloaded_name);
@@ -2489,6 +2531,7 @@ public:
bool setter_flag = false;
String *pre_code = NewString("");
String *post_code = NewString("");
+ String *terminator_code = NewString("");
if (l) {
if (SwigType_type(Getattr(l, "type")) == T_VOID) {
@@ -2593,6 +2636,14 @@ public:
Printf(post_code, "\n");
Printv(post_code, post, NIL);
}
+ String *terminator = Getattr(p, "tmap:csin:terminator");
+ if (terminator) {
+ substituteClassname(pt, terminator);
+ Replaceall(terminator, "$csinput", arg);
+ if (Len(terminator_code) > 0)
+ Insert(terminator_code, 0, "\n");
+ Insert(terminator_code, 0, terminator);
+ }
Printv(imcall, tm, NIL);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0));
@@ -2617,7 +2668,8 @@ public:
excodeSubstitute(n, tm, "csout", n);
bool is_pre_code = Len(pre_code) > 0;
bool is_post_code = Len(post_code) > 0;
- if (is_pre_code || is_post_code) {
+ bool is_terminator_code = Len(terminator_code) > 0;
+ if (is_pre_code || is_post_code || is_terminator_code) {
Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap
if (is_post_code) {
Insert(tm, 0, "\n try ");
@@ -2629,6 +2681,9 @@ public:
Insert(tm, 0, pre_code);
Insert(tm, 0, "\n");
}
+ if (is_terminator_code) {
+ Printv(tm, "\n", terminator_code, NIL);
+ }
Insert(tm, 0, "{");
Printf(tm, "\n }");
}
@@ -2704,6 +2759,7 @@ public:
Delete(pre_code);
Delete(post_code);
+ Delete(terminator_code);
Delete(function_code);
Delete(return_type);
Delete(imcall);
@@ -2918,7 +2974,7 @@ public:
void emitTypeWrapperClass(String *classname, SwigType *type) {
String *swigtype = NewString("");
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), classname);
- File *f_swigtype = NewFile(filen, "w");
+ File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
if (!f_swigtype) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
diff --git a/Source/Modules/directors.cxx b/Source/Modules/directors.cxx
index 4363cd813..158b53502 100644
--- a/Source/Modules/directors.cxx
+++ b/Source/Modules/directors.cxx
@@ -84,7 +84,7 @@ String *Swig_director_declaration(Node *n) {
}
-String *Swig_method_call(String_or_char *name, ParmList *parms) {
+String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) {
String *func;
int i = 0;
int comma = 0;
@@ -128,7 +128,7 @@ String *Swig_method_call(String_or_char *name, ParmList *parms) {
*
*/
-String *Swig_method_decl(SwigType *returntype, SwigType *decl, const String_or_char *id, List *args, int strip, int values) {
+String *Swig_method_decl(SwigType *returntype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values) {
String *result;
List *elements;
String *element = 0, *nextelement;
diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx
index f5f080034..0c72de8d0 100644
--- a/Source/Modules/guile.cxx
+++ b/Source/Modules/guile.cxx
@@ -47,6 +47,7 @@ Guile Options (available with -guile)\n\
-exportprimitive - Add the (export ...) code from scmstub into the\n\
GOOPS file.\n";
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
@@ -174,7 +175,7 @@ public:
}
} else if (strcmp(argv[i], "-procdoc") == 0) {
if (argv[i + 1]) {
- procdoc = NewFile(argv[i + 1], (char *) "w");
+ procdoc = NewFile(argv[i + 1], "w", SWIG_output_files());
if (!procdoc) {
FileErrorDisplay(argv[i + 1]);
SWIG_exit(EXIT_FAILURE);
@@ -299,11 +300,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -311,6 +313,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@@ -322,10 +325,10 @@ public:
goopscode = NewString("");
goopsexport = NewString("");
- Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n");
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
- Printf(f_runtime, "/* Implementation : GUILE */\n\n");
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGGUILE\n");
if (!use_scm_interface) {
if (SwigRuntime == 1)
@@ -358,6 +361,8 @@ public:
Printf(f_runtime, "\n}\n");
}
+ Printf(f_runtime, "\n");
+
Language::top(n);
/* Close module */
@@ -392,14 +397,16 @@ public:
Delete(goopstext);
/* Close all of the files */
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -499,15 +506,15 @@ public:
SWIG_output_directory(),
primitive_name);
Delete(primitive_name);
- File *scmstubfile = NewFile(fname, (char *) "w");
+ File *scmstubfile = NewFile(fname, "w", SWIG_output_files());
if (!scmstubfile) {
FileErrorDisplay(fname);
SWIG_exit(EXIT_FAILURE);
}
Delete(fname);
- Printf(scmstubfile, ";;; -*- buffer-read-only: t -*- vi: set ro: */\n");
- Printf(scmstubfile, ";;; Automatically generated by SWIG; do not edit.\n\n");
+ Swig_banner_target_lang(scmstubfile, ";;;");
+ Printf(scmstubfile, "\n");
if (linkage == GUILE_LSTYLE_SIMPLE || linkage == GUILE_LSTYLE_PASSIVE)
Printf(scmstubfile, "(define-module (%s))\n\n", mod);
Delete(mod);
@@ -530,14 +537,14 @@ public:
String *fname = NewStringf("%s%s.scm", SWIG_output_directory(),
module_name);
- File *goopsfile = NewFile(fname, (char *) "w");
+ File *goopsfile = NewFile(fname, "w", SWIG_output_files());
if (!goopsfile) {
FileErrorDisplay(fname);
SWIG_exit(EXIT_FAILURE);
}
Delete(fname);
- Printf(goopsfile, ";;; -*- buffer-read-only: t -*- vi: set ro: */\n");
- Printf(goopsfile, ";;; Automatically generated by SWIG; do not edit.\n\n");
+ Swig_banner_target_lang(goopsfile, ";;;");
+ Printf(goopsfile, "\n");
Printf(goopsfile, "(define-module (%s))\n", mod);
Printf(goopsfile, "%s\n", goopstext);
Printf(goopsfile, "(use-modules (oop goops) (Swig common))\n");
@@ -1653,7 +1660,7 @@ public:
* If class_name = "" that means the mapping is for a function or
* variable not attached to any class.
* ------------------------------------------------------------ */
- String *goopsNameMapping(String *name, String_or_char *class_name) {
+ String *goopsNameMapping(String *name, const_String_or_char_ptr class_name) {
String *n = NewString("");
if (Strcmp(class_name, "") == 0) {
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index b92fccdfb..50ef506ed 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -24,6 +24,7 @@ class JAVA:public Language {
const String *protected_string;
Hash *swig_types_hash;
+ File *f_begin;
File *f_runtime;
File *f_runtime_h;
File *f_header;
@@ -70,6 +71,7 @@ class JAVA:public Language {
String *imclass_cppcasts_code; //C++ casts up inheritance hierarchies intermediary class code
String *imclass_directors; // Intermediate class director code
String *destructor_call; //C++ destructor call if any
+ String *destructor_throws_clause; //C++ destructor throws clause if any
// Director method stuff:
List *dmethods_seq;
@@ -81,7 +83,7 @@ class JAVA:public Language {
enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum };
- static Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n) {
+ static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) {
Parm *p = NewParm(type, name);
Setfile(p, Getfile(n));
Setline(p, Getline(n));
@@ -98,6 +100,7 @@ public:
public_string(NewString("public")),
protected_string(NewString("protected")),
swig_types_hash(NULL),
+ f_begin(NULL),
f_runtime(NULL),
f_runtime_h(NULL),
f_header(NULL),
@@ -141,6 +144,7 @@ public:
imclass_cppcasts_code(NULL),
imclass_directors(NULL),
destructor_call(NULL),
+ destructor_throws_clause(NULL),
dmethods_seq(NULL),
dmethods_table(NULL),
n_dmethods(0),
@@ -293,8 +297,8 @@ public:
SWIG_exit(EXIT_FAILURE);
}
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
@@ -304,13 +308,14 @@ public:
Printf(stderr, "Unable to determine outfile_h\n");
SWIG_exit(EXIT_FAILURE);
}
- f_runtime_h = NewFile(outfile_h, "w");
+ f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
if (!f_runtime_h) {
FileErrorDisplay(outfile_h);
SWIG_exit(EXIT_FAILURE);
}
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -318,6 +323,7 @@ public:
f_directors = NewString("");
/* Register file targets with the SWIG file handler */
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("runtime", f_runtime);
@@ -365,13 +371,16 @@ public:
jnipackage = NewString("");
package_path = NewString("");
- Swig_banner(f_runtime); // Print the SWIG banner message
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n#define SWIGJAVA\n");
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
/* Emit initial director header and director code: */
Swig_banner(f_directors_h);
+ Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_class_name);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_class_name);
@@ -383,6 +392,8 @@ public:
Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h));
}
+ Printf(f_runtime, "\n");
+
String *wrapper_name = NewString("");
if (Len(package)) {
@@ -420,7 +431,7 @@ public:
// Generate the intermediary class
{
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), imclass_name);
- File *f_im = NewFile(filen, "w");
+ File *f_im = NewFile(filen, "w", SWIG_output_files());
if (!f_im) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -471,7 +482,7 @@ public:
// Generate the Java module class
{
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), module_class_name);
- File *f_module = NewFile(filen, "w");
+ File *f_module = NewFile(filen, "w", SWIG_output_files());
if (!f_module) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -523,7 +534,7 @@ public:
// Generate the Java constants interface
if (Len(module_class_constants_code) != 0) {
String *filen = NewStringf("%s%sConstants.java", SWIG_output_directory(), module_class_name);
- File *f_module = NewFile(filen, "w");
+ File *f_module = NewFile(filen, "w", SWIG_output_files());
if (!f_module) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -660,8 +671,10 @@ public:
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Dump(f_runtime, f_begin);
Delete(f_runtime);
+ Close(f_begin);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -671,11 +684,7 @@ public:
void emitBanner(File *f) {
Printf(f, "/* ----------------------------------------------------------------------------\n");
- Printf(f, " * This file was automatically generated by SWIG (http://www.swig.org).\n");
- Printf(f, " * Version %s\n", Swig_package_version());
- Printf(f, " *\n");
- Printf(f, " * Do not make changes to this file unless you know what you are doing--modify\n");
- Printf(f, " * the SWIG interface file instead.\n");
+ Swig_banner_target_lang(f, " *");
Printf(f, " * ----------------------------------------------------------------------------- */\n\n");
}
@@ -1210,7 +1219,7 @@ public:
} else {
// Global enums are defined in their own file
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), symname);
- File *f_enum = NewFile(filen, "w");
+ File *f_enum = NewFile(filen, "w", SWIG_output_files());
if (!f_enum) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -1274,7 +1283,7 @@ public:
if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
// Wrap (non-anonymous) C/C++ enum with a proper Java enum
// Emit the enum item.
- if (!Getattr(n, "_last")) // Only the first enum item has this attribute set
+ if (!GetFlag(n, "firstenumitem"))
Printf(enum_code, ",\n");
Printf(enum_code, " %s", symname);
if (Getattr(n, "enumvalue")) {
@@ -1558,6 +1567,7 @@ public:
Node *attributes = NewHash();
const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE, attributes);
bool purebase_replace = GetFlag(attributes, "tmap:javabase:replace") ? true : false;
+ bool purebase_notderived = GetFlag(attributes, "tmap:javabase:notderived") ? true : false;
Delete(attributes);
// C++ inheritance
@@ -1591,6 +1601,8 @@ public:
}
bool derived = baseclass && getProxyName(c_baseclassname);
+ if (derived && purebase_notderived)
+ pure_baseclass = empty_string;
const String *wanted_base = baseclass ? baseclass : pure_baseclass;
if (purebase_replace) {
@@ -1598,9 +1610,12 @@ public:
derived = false;
Delete(baseclass);
baseclass = NULL;
+ if (purebase_notderived)
+ Swig_error(input_file, line_number, "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number,
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. Perhaps you need the replace attribute in the javabase typemap?\n", typemap_lookup_type, pure_baseclass);
+ "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. "
+ "Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
}
// Pure Java interfaces
@@ -1654,7 +1669,7 @@ public:
else
Replaceall(destruct, "$jnicall", "throw new UnsupportedOperationException(\"C++ destructor does not have public access\")");
if (*Char(destruct))
- Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "() ", destruct, "\n", NIL);
+ Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "()", destructor_throws_clause, " ", destruct, "\n", NIL);
}
/* Insert directordisconnect typemap, if this class has directors enabled */
@@ -1742,7 +1757,7 @@ public:
}
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), proxy_class_name);
- f_proxy = NewFile(filen, "w");
+ f_proxy = NewFile(filen, "w", SWIG_output_files());
if (!f_proxy) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -1761,6 +1776,7 @@ public:
Clear(proxy_class_code);
destructor_call = NewString("");
+ destructor_throws_clause = NewString("");
proxy_class_constants_code = NewString("");
}
@@ -1819,6 +1835,8 @@ public:
proxy_class_name = NULL;
Delete(destructor_call);
destructor_call = NULL;
+ Delete(destructor_throws_clause);
+ destructor_throws_clause = NULL;
Delete(proxy_class_constants_code);
proxy_class_constants_code = NULL;
}
@@ -2336,6 +2354,7 @@ public:
if (proxy_flag) {
Printv(destructor_call, imclass_name, ".", Swig_name_destroy(symname), "(swigCPtr)", NIL);
+ generateThrowsClause(n, destructor_throws_clause);
}
return SWIG_OK;
}
@@ -2798,7 +2817,7 @@ public:
void emitTypeWrapperClass(String *classname, SwigType *type) {
String *swigtype = NewString("");
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), classname);
- File *f_swigtype = NewFile(filen, "w");
+ File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
if (!f_swigtype) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -2870,7 +2889,7 @@ public:
String *throws_attribute = NewStringf("%s:throws", attribute);
String *throws = Getattr(parameter, throws_attribute);
- if (throws) {
+ if (throws && Len(throws) > 0) {
String *throws_list = Getattr(n, "java:throwslist");
if (!throws_list) {
throws_list = NewList();
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index 6718903d0..38658ce9c 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -61,7 +61,7 @@ static String *AttributeFunctionGet = 0;
static String *AttributeFunctionSet = 0;
static Node *CurrentClass = 0;
int line_number = 0;
-char *input_file = 0;
+String *input_file = 0;
int SmartPointer = 0;
static Hash *classhash;
@@ -352,7 +352,7 @@ int Language::emit_one(Node *n) {
Extend = 1;
line_number = Getline(n);
- input_file = Char(Getfile(n));
+ input_file = Getfile(n);
/*
symtab = Getattr(n,"symtab");
@@ -830,9 +830,8 @@ int Language::cDeclaration(Node *n) {
if (!(directorsEnabled() && ((is_member_director(CurrentClass, n) && need_nonpublic_member(n)) || is_non_virtual_protected_access(n)))) {
return SWIG_NOWRAP;
}
-#if 0
-// I don't see why this is needed - WSF
- /* prevent wrapping the method twice due to overload */
+ // Prevent wrapping protected overloaded director methods more than once -
+ // This bit of code is only needed due to the cDeclaration call in classHandler()
String *wrapname = NewStringf("nonpublic_%s%s", symname, Getattr(n, "sym:overname"));
if (Getattr(CurrentClass, wrapname)) {
Delete(wrapname);
@@ -840,7 +839,6 @@ int Language::cDeclaration(Node *n) {
}
SetFlag(CurrentClass, wrapname);
Delete(wrapname);
-#endif
}
}
@@ -1424,36 +1422,39 @@ int Language::membervariableHandler(Node *n) {
target = NewStringf("%s->%s", pname, name);
Delete(pname);
}
- tm = Swig_typemap_lookup("memberin", n, target, 0);
+ } else {
+ target = NewStringf("$extendgetcall"); // member variable access expanded later
}
+ tm = Swig_typemap_lookup("memberin", n, target, 0);
int flags = Extend | SmartPointer | use_naturalvar_mode(n);
if (is_non_virtual_protected_access(n))
flags = flags | CWRAP_ALL_PROTECTED_ACCESS;
- Swig_MembersetToFunction(n, ClassType, flags);
+ String *call = 0;
+ Swig_MembersetToFunction(n, ClassType, flags, &call);
Setattr(n, "memberset", "1");
- if (!Extend) {
- /* Check for a member in typemap here */
- if (!tm) {
- if (SwigType_isarray(type)) {
- Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0));
- make_set_wrapper = 0;
- }
- } else {
- String *pname0 = Swig_cparm_name(0, 0);
- String *pname1 = Swig_cparm_name(0, 1);
- Replace(tm, "$source", pname1, DOH_REPLACE_ANY);
- Replace(tm, "$target", target, DOH_REPLACE_ANY);
- Replace(tm, "$input", pname1, DOH_REPLACE_ANY);
- Replace(tm, "$self", pname0, DOH_REPLACE_ANY);
- Setattr(n, "wrap:action", tm);
- Delete(tm);
- Delete(pname0);
- Delete(pname1);
+ if (!tm) {
+ if (SwigType_isarray(type)) {
+ Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0));
+ make_set_wrapper = 0;
}
- Delete(target);
+ } else {
+ String *pname0 = Swig_cparm_name(0, 0);
+ String *pname1 = Swig_cparm_name(0, 1);
+ Replace(tm, "$source", pname1, DOH_REPLACE_ANY);
+ Replace(tm, "$target", target, DOH_REPLACE_ANY);
+ Replace(tm, "$input", pname1, DOH_REPLACE_ANY);
+ Replace(tm, "$self", pname0, DOH_REPLACE_ANY);
+ Replace(tm, "$extendgetcall", call, DOH_REPLACE_ANY);
+ Setattr(n, "wrap:action", tm);
+ Delete(tm);
+ Delete(pname0);
+ Delete(pname1);
}
+ Delete(call);
+ Delete(target);
+
if (make_set_wrapper) {
Setattr(n, "sym:name", mrename_set);
functionWrapper(n);
@@ -2476,6 +2477,13 @@ int Language::classHandler(Node *n) {
Node *m = Copy(method);
Setattr(m, "director", "1");
Setattr(m, "parentNode", n);
+ /*
+ * There is a bug that needs fixing still...
+ * This area of code is creating methods which have not been overidden in a derived class (director methods that are protected in the base)
+ * If the method is overloaded, then Swig_overload_dispatch() incorrectly generates a call to the base wrapper, _wrap_xxx method
+ * See director_protected_overloaded.i - Possibly sym:overname needs correcting here.
+ Printf(stdout, "new method: %s::%s(%s)\n", Getattr(parentNode(m), "name"), Getattr(m, "name"), ParmList_str_defaultargs(Getattr(m, "parms")));
+ */
cDeclaration(m);
Delete(m);
}
@@ -2955,14 +2963,9 @@ Node *Language::classLookup(SwigType *s) {
n = Getattr(classtypes, s);
if (!n) {
Symtab *stab = 0;
-// SwigType *lt = SwigType_ltype(s);
-// SwigType *ty1 = SwigType_typedef_resolve_all(lt);
SwigType *ty1 = SwigType_typedef_resolve_all(s);
SwigType *ty2 = SwigType_strip_qualifiers(ty1);
-// Printf(stdout, " stages... ty1: %s ty2: %s\n", ty1, ty2);
-// Delete(lt);
Delete(ty1);
-// lt = 0;
ty1 = 0;
String *base = SwigType_base(ty2);
@@ -2971,6 +2974,12 @@ Node *Language::classLookup(SwigType *s) {
Replaceall(base, "struct ", "");
Replaceall(base, "union ", "");
+ if (strncmp(Char(base), "::", 2) == 0) {
+ String *oldbase = base;
+ base = NewString(Char(base) + 2);
+ Delete(oldbase);
+ }
+
String *prefix = SwigType_prefix(ty2);
/* Do a symbol table search on the base type */
@@ -3044,6 +3053,12 @@ Node *Language::enumLookup(SwigType *s) {
Replaceall(base, "enum ", "");
String *prefix = SwigType_prefix(ty2);
+ if (strncmp(Char(base), "::", 2) == 0) {
+ String *oldbase = base;
+ base = NewString(Char(base) + 2);
+ Delete(oldbase);
+ }
+
/* Look for type in symbol table */
while (!n) {
Hash *nstab;
diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx
index 6113da960..78cd7ce96 100644
--- a/Source/Modules/lua.cxx
+++ b/Source/Modules/lua.cxx
@@ -92,6 +92,7 @@ NEW LANGUAGE NOTE:END ************************************************/
class LUA:public Language {
private:
+ File *f_begin;
File *f_runtime;
File *f_header;
File *f_wrappers;
@@ -132,6 +133,7 @@ public:
* --------------------------------------------------------------------- */
LUA() {
+ f_begin = 0;
f_runtime = 0;
f_header = 0;
f_wrappers = 0;
@@ -213,11 +215,12 @@ public:
String *outfile = Getattr(n, "outfile");
/* Open the output file */
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -226,6 +229,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("initbeforefunc", f_initbeforefunc);
@@ -249,11 +253,17 @@ public:
current=NO_CPP;
/* Standard stuff for the SWIG runtime section */
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGLUA\n");
+
// if (NoInclude) {
// Printf(f_runtime, "#define SWIG_NOINCLUDE\n");
// }
+ Printf(f_runtime, "\n");
+
//String *init_name = NewStringf("%(title)s_Init", module);
//Printf(f_header, "#define SWIG_init %s\n", init_name);
//Printf(f_header, "#define SWIG_name \"%s\"\n", module);
@@ -288,13 +298,14 @@ public:
this basically combines several of the strings together
and then writes it all to a file
NEW LANGUAGE NOTE:END ************************************************/
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Dump(f_initbeforefunc, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Dump(f_initbeforefunc, f_begin);
/* for the Lua code it needs to be properly excaped to be added into the C/C++ code */
EscapeCode(s_luacode);
- Printf(f_runtime, "const char* SWIG_LUACODE=\n \"%s\";\n\n",s_luacode);
- Wrapper_pretty_print(f_init, f_runtime);
+ Printf(f_begin, "const char* SWIG_LUACODE=\n \"%s\";\n\n",s_luacode);
+ Wrapper_pretty_print(f_init, f_begin);
/* Close all of the files */
Delete(s_luacode);
Delete(s_cmd_tab);
@@ -304,8 +315,9 @@ public:
Delete(f_wrappers);
Delete(f_init);
Delete(f_initbeforefunc);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
/* Done */
return SWIG_OK;
diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
index 901ee812e..c824db6f9 100644
--- a/Source/Modules/main.cxx
+++ b/Source/Modules/main.cxx
@@ -117,7 +117,8 @@ static const char *usage3 = (const char *) "\
-fastdispatch -fvirtual \n\
-o <outfile> - Set name of the output file to <outfile>\n\
-oh <headfile> - Set name of the output header file to <headfile>\n\
- -outdir <dir> - Set language specific files output directory <dir>\n\
+ -outcurrentdir - Set default output dir to current dir instead of input file's path\n\
+ -outdir <dir> - Set language specific files output directory to <dir>\n\
-small - Compile in virtual elimination & compact mode\n\
-swiglib - Report location of SWIG library and exit\n\
-templatereduce - Reduce all the typedefs in templates\n\
@@ -153,6 +154,7 @@ static char *cpp_extension = (char *) "cxx";
static char *depends_extension = (char *) "d";
static String *outdir = 0;
static String *xmlout = 0;
+static int outcurrentdir = 0;
static int help = 0;
static int checkout = 0;
static int cpp_only = 0;
@@ -180,14 +182,16 @@ static String *dependencies_target = 0;
static int external_runtime = 0;
static String *external_runtime_name = 0;
enum { STAGE1=1, STAGE2=2, STAGE3=4, STAGE4=8, STAGEOVERFLOW=16 };
+static List *all_output_files = 0;
// -----------------------------------------------------------------------------
-// check_suffix(char *name)
+// check_suffix()
//
// Checks the suffix of a file to see if we should emit extern declarations.
// -----------------------------------------------------------------------------
-static int check_suffix(const char *name) {
+static int check_suffix(String *filename) {
+ const char *name = Char(filename);
const char *c;
if (!name)
return 0;
@@ -281,7 +285,7 @@ static void set_outdir(const String *c_wrapper_file_dir) {
}
/* This function sets the name of the configuration file */
-void SWIG_config_file(const String_or_char *filename) {
+void SWIG_config_file(const_String_or_char_ptr filename) {
lang_config = NewString(filename);
}
@@ -300,6 +304,11 @@ void SWIG_config_cppext(const char *ext) {
cpp_extension = (char *) ext;
}
+List *SWIG_output_files() {
+ assert(all_output_files);
+ return all_output_files;
+}
+
void SWIG_setfeature(const char *cfeature, const char *cvalue) {
Hash *features_hash = Swig_cparse_features();
String *name = NewString("");
@@ -363,13 +372,14 @@ static void SWIG_dump_runtime() {
}
}
- runtime = NewFile(outfile, "w");
+ runtime = NewFile(outfile, "w", SWIG_output_files());
if (!runtime) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
Swig_banner(runtime);
+ Printf(runtime, "\n");
s = Swig_include_sys("swiglabels.swg");
if (!s) {
@@ -688,6 +698,9 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else {
Swig_arg_error();
}
+ } else if (strcmp(argv[i], "-outcurrentdir") == 0) {
+ Swig_mark_arg(i);
+ outcurrentdir = 1;
} else if (strcmp(argv[i], "-Wall") == 0) {
Swig_mark_arg(i);
Swig_warnall();
@@ -867,6 +880,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
}
libfiles = NewList();
+ all_output_files = NewList();
/* Check for SWIG_FEATURES environment variable */
@@ -924,12 +938,13 @@ int SWIG_main(int argc, char *argv[], Language *l) {
// If we made it this far, looks good. go for it....
- input_file = argv[argc - 1];
+ input_file = NewString(argv[argc - 1]);
+ Swig_filename_correct(input_file);
// If the user has requested to check out a file, handle that
if (checkout) {
DOH *s;
- char *outfile = input_file;
+ char *outfile = Char(input_file);
if (outfile_name)
outfile = outfile_name;
@@ -938,30 +953,26 @@ int SWIG_main(int argc, char *argv[], Language *l) {
s = Swig_include(input_file);
if (!s) {
- fprintf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file);
+ Printf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file);
} else {
- FILE *f = fopen(outfile, "r");
+ FILE *f = Swig_open(outfile);
if (f) {
fclose(f);
- fprintf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile);
+ Printf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile);
} else {
- f = fopen(outfile, "w");
- if (!f) {
- fprintf(stderr, "Unable to create file '%s'\n", outfile);
- } else {
- if (Verbose)
- fprintf(stdout, "'%s' checked out from the SWIG library.\n", input_file);
- fputs(Char(s), f);
- fclose(f);
- }
+ File *f_outfile = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_outfile) {
+ FileErrorDisplay(outfile);
+ SWIG_exit(EXIT_FAILURE);
+ } else {
+ if (Verbose)
+ Printf(stdout, "'%s' checked out from the SWIG library.\n", outfile);
+ Printv(f_outfile, s, NIL);
+ Close(f_outfile);
+ }
}
}
} else {
- // Check the suffix for a .c file. If so, we're going to
- // declare everything we see as "extern"
-
- ForceExtern = check_suffix(input_file);
-
// Run the preprocessor
if (Verbose)
printf("Preprocessing...\n");
@@ -971,17 +982,22 @@ int SWIG_main(int argc, char *argv[], Language *l) {
String *fs = NewString("");
FILE *df = Swig_open(input_file);
if (!df) {
- char *cfile = Char(input_file);
- if (cfile && cfile[0] == '-') {
- Printf(stderr, "Unable to find option or file '%s', ", input_file);
- Printf(stderr, "use 'swig -help' for more information.\n");
+ df = Swig_include_open(input_file);
+ if (!df) {
+ char *cfile = Char(input_file);
+ if (cfile && cfile[0] == '-') {
+ Printf(stderr, "Unable to find option or file '%s', ", input_file);
+ Printf(stderr, "use 'swig -help' for more information.\n");
+ } else {
+ Printf(stderr, "Unable to find file '%s'.\n", input_file);
+ }
+ SWIG_exit(EXIT_FAILURE);
} else {
- Printf(stderr, "Unable to find file '%s'.\n", input_file);
+ Swig_warning(WARN_DEPRECATED_INPUT_FILE, "SWIG", 1, "Use of the include path to find the input file is deprecated and will not work with ccache. Please include the path when specifying the input file.\n"); // so that behaviour is like c/c++ compilers
}
- SWIG_exit(EXIT_FAILURE);
}
- fclose(df);
if (!no_cpp) {
+ fclose(df);
Printf(fs, "%%include <swig.swg>\n");
if (allkw) {
Printf(fs, "%%include <allkw.swg>\n");
@@ -989,7 +1005,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (lang_config) {
Printf(fs, "\n%%include <%s>\n", lang_config);
}
- Printf(fs, "%%include \"%s\"\n", Swig_last_file());
+ Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_last_file());
for (i = 0; i < Len(libfiles); i++) {
Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i));
}
@@ -997,8 +1013,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
cpps = Preprocessor_parse(fs);
Delete(fs);
} else {
- df = Swig_open(input_file);
- cpps = NewFileFromFile(df);
+ cpps = Swig_read_file(df);
+ fclose(df);
}
if (Swig_error_count()) {
SWIG_exit(EXIT_FAILURE);
@@ -1008,47 +1024,55 @@ int SWIG_main(int argc, char *argv[], Language *l) {
SWIG_exit(EXIT_SUCCESS);
}
if (depend) {
- String *outfile;
- if (!outfile_name) {
- if (CPlusPlus || lang->cplus_runtime_mode()) {
- outfile = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), cpp_extension);
+ if (!no_cpp) {
+ String *outfile;
+
+ char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(input_file): Char(input_file));
+ if (!outfile_name) {
+ if (CPlusPlus || lang->cplus_runtime_mode()) {
+ outfile = NewStringf("%s_wrap.%s", basename, cpp_extension);
+ } else {
+ outfile = NewStringf("%s_wrap.c", basename);
+ }
} else {
- outfile = NewStringf("%s_wrap.c", Swig_file_basename(input_file));
+ outfile = NewString(outfile_name);
}
- } else {
- outfile = NewString(outfile_name);
- }
- if (dependencies_file && Len(dependencies_file) != 0) {
- f_dependencies_file = NewFile(dependencies_file, "w");
- if (!f_dependencies_file) {
- FileErrorDisplay(dependencies_file);
- SWIG_exit(EXIT_FAILURE);
+ if (dependencies_file && Len(dependencies_file) != 0) {
+ f_dependencies_file = NewFile(dependencies_file, "w", SWIG_output_files());
+ if (!f_dependencies_file) {
+ FileErrorDisplay(dependencies_file);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ } else if (!depend_only) {
+ String *filename = NewStringf("%s_wrap.%s", basename, depends_extension);
+ f_dependencies_file = NewFile(filename, "w", SWIG_output_files());
+ if (!f_dependencies_file) {
+ FileErrorDisplay(filename);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ } else
+ f_dependencies_file = stdout;
+ if (dependencies_target) {
+ Printf(f_dependencies_file, "%s: ", dependencies_target);
+ } else {
+ Printf(f_dependencies_file, "%s: ", outfile);
}
- } else if (!depend_only) {
- String *filename = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), depends_extension);
- f_dependencies_file = NewFile(filename, "w");
- if (!f_dependencies_file) {
- FileErrorDisplay(filename);
- SWIG_exit(EXIT_FAILURE);
+ List *files = Preprocessor_depend();
+ for (int i = 0; i < Len(files); i++) {
+ if ((depend != 2) || ((depend == 2) && (Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) != 0))) {
+ Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
+ }
}
- } else
- f_dependencies_file = stdout;
- if (dependencies_target) {
- Printf(f_dependencies_file, "%s: ", dependencies_target);
+ Printf(f_dependencies_file, "\n");
+ if (f_dependencies_file != stdout)
+ Close(f_dependencies_file);
+ if (depend_only)
+ SWIG_exit(EXIT_SUCCESS);
} else {
- Printf(f_dependencies_file, "%s: ", outfile);
- }
- List *files = Preprocessor_depend();
- for (int i = 0; i < Len(files); i++) {
- if ((depend != 2) || ((depend == 2) && (Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) != 0))) {
- Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
- }
+ Printf(stderr, "Cannot generate dependencies with -nopreprocess\n");
+ // Actually we could but it would be inefficient when just generating dependencies, as it would be done after Swig_cparse
+ SWIG_exit(EXIT_FAILURE);
}
- Printf(f_dependencies_file, "\n");
- if (f_dependencies_file != stdout)
- Close(f_dependencies_file);
- if (depend_only)
- SWIG_exit(EXIT_SUCCESS);
}
Seek(cpps, 0, SEEK_SET);
}
@@ -1126,22 +1150,30 @@ int SWIG_main(int argc, char *argv[], Language *l) {
}
if (top) {
if (!Getattr(top, "name")) {
- Printf(stderr, "*** No module name specified using %%module or -module.\n");
+ Printf(stderr, "No module name specified using %%module or -module.\n");
SWIG_exit(EXIT_FAILURE);
} else {
/* Set some filename information on the object */
- Setattr(top, "infile", input_file);
+ String *infile = scanner_get_main_input_file();
+ if (!infile) {
+ Printf(stderr, "Missing input file in preprocessed output.\n");
+ SWIG_exit(EXIT_FAILURE);
+ }
+ Setattr(top, "infile", infile); // Note: if nopreprocess then infile is the original input file, otherwise input_file
+ Setattr(top, "inputfile", input_file);
+
+ char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(infile): Char(infile));
if (!outfile_name) {
if (CPlusPlus || lang->cplus_runtime_mode()) {
- Setattr(top, "outfile", NewStringf("%s_wrap.%s", Swig_file_basename(input_file), cpp_extension));
+ Setattr(top, "outfile", NewStringf("%s_wrap.%s", basename, cpp_extension));
} else {
- Setattr(top, "outfile", NewStringf("%s_wrap.c", Swig_file_basename(input_file)));
+ Setattr(top, "outfile", NewStringf("%s_wrap.c", basename));
}
} else {
Setattr(top, "outfile", outfile_name);
}
if (!outfile_name_h) {
- Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", Swig_file_basename(input_file), hpp_extension));
+ Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", basename, hpp_extension));
} else {
Setattr(top, "outfile_h", outfile_name_h);
}
@@ -1149,7 +1181,12 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (Swig_contract_mode_get()) {
Swig_contracts(top);
}
+
+ // Check the suffix for a c/c++ file. If so, we're going to declare everything we see as "extern"
+ ForceExtern = check_suffix(input_file);
+
lang->top(top);
+
if (browse) {
Swig_browser(top, 0);
}
@@ -1173,6 +1210,21 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (memory_debug)
DohMemoryDebug();
+ char *outfiles = getenv("CCACHE_OUTFILES");
+ if (outfiles) {
+ File *f_outfiles = NewFile(outfiles, "w", 0);
+ if (!f_outfiles) {
+ Printf(stderr, "Failed to write list of output files to the filename '%s' specified in CCACHE_OUTFILES environment variable - ", outfiles);
+ FileErrorDisplay(outfiles);
+ SWIG_exit(EXIT_FAILURE);
+ } else {
+ int i;
+ for (i = 0; i < Len(all_output_files); i++)
+ Printf(f_outfiles, "%s\n", Getitem(all_output_files, i));
+ Close(f_outfiles);
+ }
+ }
+
// Deletes
Delete(libfiles);
Preprocessor_delete();
diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx
index 6cb24d39a..b3568c0bf 100644
--- a/Source/Modules/modula3.cxx
+++ b/Source/Modules/modula3.cxx
@@ -127,7 +127,7 @@ char cvsroot_modula3_cxx[] = "$Id$";
#include <limits.h> // for INT_MAX
#include <ctype.h>
-const char usageArgDir[] = "m3wrapargdir typemap expect values: in, out, inout\n";
+#define USAGE_ARG_DIR "m3wrapargdir typemap expect values: in, out, inout\n"
class MODULA3:public Language {
public:
@@ -172,6 +172,7 @@ private:
const String *empty_string;
Hash *swig_types_hash;
+ File *f_begin;
File *f_runtime;
File *f_header;
File *f_wrappers;
@@ -237,6 +238,7 @@ public:
MODULA3():
empty_string(NewString("")),
swig_types_hash(NULL),
+ f_begin(NULL),
f_runtime(NULL),
f_header(NULL),
f_wrappers(NULL),
@@ -374,7 +376,7 @@ MODULA3():
} else if (Strcmp(dir, "out") == 0) {
return false;
} else {
- printf(usageArgDir);
+ printf("%s", USAGE_ARG_DIR);
return false;
}
}
@@ -386,7 +388,7 @@ MODULA3():
} else if ((Strcmp(dir, "out") == 0) || (Strcmp(dir, "inout") == 0)) {
return true;
} else {
- printf(usageArgDir);
+ printf("%s", USAGE_ARG_DIR);
return false;
}
}
@@ -542,7 +544,7 @@ MODULA3():
* ----------------------------------------------------------------------------- */
File *openWriteFile(String *name) {
- File *file = NewFile(name, "w");
+ File *file = NewFile(name, "w", SWIG_output_files());
if (!file) {
FileErrorDisplay(name);
SWIG_exit(EXIT_FAILURE);
@@ -902,11 +904,12 @@ MODULA3():
/* Initialize all of the output files */
outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -916,6 +919,7 @@ MODULA3():
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@@ -956,7 +960,11 @@ MODULA3():
module_imports = NewString("");
upcasts_code = NewString("");
- Swig_banner(f_runtime); // Print the SWIG banner message
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGMODULA3\n");
+ Printf(f_runtime, "\n");
Swig_name_register((char *) "wrapper", (char *) "Modula3_%f");
if (old_variable_names) {
@@ -1143,14 +1151,16 @@ MODULA3():
typemapfilename = NULL;
/* Close all of the files */
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -1159,14 +1169,9 @@ MODULA3():
* ----------------------------------------------------------------------------- */
void emitBanner(File *f) {
- Printf(f, "\
-(*******************************************************************************\n\
- * This file was automatically generated by SWIG (http://www.swig.org/).\n\
- * Version %s\n\
- *\n\
- * Do not make changes to this file unless you know what you are doing --\n\
- * modify the SWIG interface file instead.\n\
- *******************************************************************************)\n\n", Swig_package_version());
+ Printf(f, "(*******************************************************************************\n");
+ Swig_banner_target_lang(f, " *");
+ Printf(f, "*******************************************************************************)\n\n");
}
/* ----------------------------------------------------------------------
@@ -2382,7 +2387,7 @@ MODULA3():
}
String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), proxy_class_name);
- f_proxy = NewFile(filen, "w");
+ f_proxy = NewFile(filen, "w", SWIG_output_files());
if (!f_proxy) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -3174,8 +3179,7 @@ MODULA3():
Clear(result_m3wraptype);
Printv(result_m3wraptype, tm, NIL);
} else {
- Swig_warning(WARN_MODULA3_TYPEMAP_MULTIPLE_RETURN,
- input_file, line_number,
+ Swig_warning(WARN_MODULA3_TYPEMAP_MULTIPLE_RETURN, input_file, line_number,
"Typemap m3wrapargdir set to 'out' for %s implies a RETURN value, but the routine %s has already one.\nUse %%multiretval feature.\n",
SwigType_str(Getattr(p, "type"), 0), raw_name);
}
@@ -3762,7 +3766,7 @@ MODULA3():
void emitTypeWrapperClass(String *classname, SwigType *type) {
String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), classname);
- File *f_swigtype = NewFile(filen, "w");
+ File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
if (!f_swigtype) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx
index 78d4a4b65..28dd8ecd2 100644
--- a/Source/Modules/mzscheme.cxx
+++ b/Source/Modules/mzscheme.cxx
@@ -39,6 +39,7 @@ static String *module = 0;
static char *mzscheme_path = (char *) "mzscheme";
static String *init_func_def = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
@@ -129,11 +130,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -141,13 +143,17 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
init_func_def = NewString("");
Swig_register_filebyname("init", init_func_def);
- Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n");
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGMZSCHEME\n");
+ Printf(f_runtime, "\n");
module = Getattr(n, "name");
@@ -186,14 +192,16 @@ public:
}
/* Close all of the files */
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
index 0d0f4c7f2..8a797759c 100755..100644
--- a/Source/Modules/ocaml.cxx
+++ b/Source/Modules/ocaml.cxx
@@ -38,6 +38,7 @@ static Hash *seen_enumvalues = 0;
static Hash *seen_constructors = 0;
static File *f_header = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_wrappers = 0;
static File *f_directors = 0;
@@ -214,11 +215,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -247,6 +249,7 @@ public:
Swig_register_filebyname("init", init_func_def);
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("mli", f_mlibody);
Swig_register_filebyname("ml", f_mlbody);
@@ -262,7 +265,10 @@ public:
Swig_name_register("get", "%v__get__");
}
- Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n");
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGOCAML\n");
Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module);
/* Module name */
Printf(f_mlbody, "let module_name = \"%s\"\n", module);
@@ -276,12 +282,12 @@ public:
Printf(f_int_to_enum, "let int_to_enum x y =\n" " match (x : c_enum_type) with\n" " `unknown -> C_enum (`Int y)\n");
- Swig_banner(f_runtime);
-
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
}
+ Printf(f_runtime, "\n");
+
/* Produce the enum_to_int and int_to_enum functions */
Printf(f_enumtypes_type, "open Swig\n" "type c_enum_type = [ \n `unknown\n");
@@ -293,12 +299,12 @@ public:
Printv(mlifile, module, ".mli", NIL);
String *mlfilen = NewStringf("%s%s", SWIG_output_directory(), mlfile);
- if ((f_mlout = NewFile(mlfilen, "w")) == 0) {
+ if ((f_mlout = NewFile(mlfilen, "w", SWIG_output_files())) == 0) {
FileErrorDisplay(mlfilen);
SWIG_exit(EXIT_FAILURE);
}
String *mlifilen = NewStringf("%s%s", SWIG_output_directory(), mlifile);
- if ((f_mliout = NewFile(mlifilen, "w")) == 0) {
+ if ((f_mliout = NewFile(mlifilen, "w", SWIG_output_files())) == 0) {
FileErrorDisplay(mlifilen);
SWIG_exit(EXIT_FAILURE);
}
@@ -322,16 +328,18 @@ public:
SwigType_emit_type_table(f_runtime, f_wrappers);
/* Close all of the files */
+ Dump(f_runtime, f_begin);
Dump(f_directors_h, f_header);
- Dump(f_header, f_runtime);
+ Dump(f_header, f_begin);
Dump(f_directors, f_wrappers);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
Dump(f_enumtypes_type, f_mlout);
Dump(f_enumtypes_value, f_mlout);
@@ -1619,11 +1627,6 @@ public:
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, "c_result", w);
Setattr(n, "type", type);
- if (tm == 0) {
- String *name = NewString("c_result");
- tm = Swig_typemap_search("directorout", return_type, name, NULL);
- Delete(name);
- }
if (tm != 0) {
Replaceall(tm, "$input", "swig_result");
/* TODO check this */
diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx
index d582e8a6c..55ffe8cbb 100644
--- a/Source/Modules/octave.cxx
+++ b/Source/Modules/octave.cxx
@@ -18,6 +18,7 @@ Octave Options (available with -octave)\n\
class OCTAVE:public Language {
private:
+ File *f_begin;
File *f_runtime;
File *f_header;
File *f_doc;
@@ -37,9 +38,16 @@ private:
Hash *docs;
public:
- OCTAVE():f_runtime(0), f_header(0), f_doc(0), f_wrappers(0),
+ OCTAVE():f_begin(0), f_runtime(0), f_header(0), f_doc(0), f_wrappers(0),
f_init(0), f_initbeforefunc(0), f_directors(0), f_directors_h(0),
s_global_tab(0), s_members_tab(0), class_name(0) {
+ /* Add code to manage protected constructors and directors */
+ director_prot_ctor_code = NewString("");
+ Printv(director_prot_ctor_code,
+ "if ( $comparison ) { /* subclassed */\n",
+ " $director_new \n",
+ "} else {\n", " error(\"accessing abstract class or protected constructor\"); \n", " SWIG_fail;\n", "}\n", NIL);
+
enable_cplus_runtime_mode();
allow_overloading();
director_multiple_inheritance = 1;
@@ -87,11 +95,12 @@ public:
String *module = Getattr(n, "name");
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_header = NewString("");
f_doc = NewString("");
f_wrappers = NewString("");
@@ -100,6 +109,7 @@ public:
f_directors_h = NewString("");
f_directors = NewString("");
s_global_tab = NewString("");
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("doc", f_doc);
@@ -108,11 +118,16 @@ public:
Swig_register_filebyname("initbeforefunc", f_initbeforefunc);
Swig_register_filebyname("director", f_directors);
Swig_register_filebyname("director_h", f_directors_h);
- Swig_banner(f_runtime);
+
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGOCTAVE\n");
Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module);
Printf(f_runtime, "#define SWIG_name %s\n", module);
if (directorsEnabled()) {
+ Printf(f_runtime, "#define SWIG_DIRECTORS\n");
Swig_banner(f_directors_h);
if (dirprot_mode()) {
// Printf(f_directors_h, "#include <map>\n");
@@ -120,6 +135,7 @@ public:
}
}
+ Printf(f_runtime, "\n");
Printf(s_global_tab, "\nstatic const struct swig_octave_member swig_globals[] = {\n");
Printf(f_init, "static void SWIG_init_user(octave_swig_type* module_ns)\n{\n");
@@ -143,15 +159,16 @@ public:
Printv(f_wrappers, s_global_tab, NIL);
SwigType_emit_type_table(f_runtime, f_wrappers);
- Dump(f_header, f_runtime);
- Dump(f_doc, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_doc, f_begin);
if (directorsEnabled()) {
- Dump(f_directors_h, f_runtime);
- Dump(f_directors, f_runtime);
+ Dump(f_directors_h, f_begin);
+ Dump(f_directors, f_begin);
}
- Dump(f_wrappers, f_runtime);
- Dump(f_initbeforefunc, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_wrappers, f_begin);
+ Dump(f_initbeforefunc, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(s_global_tab);
Delete(f_initbeforefunc);
@@ -161,8 +178,9 @@ public:
Delete(f_header);
Delete(f_directors);
Delete(f_directors_h);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -1287,11 +1305,6 @@ public:
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, "result", w);
Setattr(n, "type", type);
- if (tm == 0) {
- String *name = NewString("result");
- tm = Swig_typemap_search("directorout", return_type, name, NULL);
- Delete(name);
- }
if (tm != 0) {
char temp[24];
sprintf(temp, "out(%d)", idx);
diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx
index d16913885..511e55004 100644
--- a/Source/Modules/overload.cxx
+++ b/Source/Modules/overload.cxx
@@ -316,7 +316,7 @@ static bool print_typecheck(String *f, int j, Parm *pj) {
* ReplaceFormat()
* ----------------------------------------------------------------------------- */
-static String *ReplaceFormat(const String_or_char *fmt, int j) {
+static String *ReplaceFormat(const_String_or_char_ptr fmt, int j) {
String *lfmt = NewString(fmt);
char buf[50];
sprintf(buf, "%d", j);
@@ -352,7 +352,7 @@ static String *ReplaceFormat(const String_or_char *fmt, int j) {
/*
Cast dispatch mechanism.
*/
-String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *maxargs) {
+String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *maxargs) {
int i, j;
*maxargs = 1;
@@ -536,7 +536,7 @@ String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *max
/*
Fast dispatch mechanism, provided by Salvador Fandi~no Garc'ia (#930586).
*/
-String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *maxargs) {
+String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *maxargs) {
int i, j;
*maxargs = 1;
@@ -695,7 +695,7 @@ String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *max
return f;
}
-String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs) {
+String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxargs) {
if (fast_dispatch_mode || GetFlag(n, "feature:fastdispatch")) {
return Swig_overload_dispatch_fast(n, fmt, maxargs);
diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx
index 2e714efe5..eace179a7 100644
--- a/Source/Modules/perl5.cxx
+++ b/Source/Modules/perl5.cxx
@@ -78,6 +78,7 @@ static String *command_tab = 0;
static String *constant_tab = 0;
static String *variable_tab = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
@@ -100,6 +101,8 @@ static int have_constructor = 0;
static int have_destructor = 0;
static int have_data_members = 0;
static String *class_name = 0; /* Name of the class (what Perl thinks it is) */
+static String *real_classname = 0; /* Real name of C/C++ class */
+static String *fullclassname = 0;
static String *pcode = 0; /* Perl code associated with each class */
/* static String *blessedmembers = 0; *//* Member data associated with each class */
@@ -205,6 +208,7 @@ public:
}
Preprocessor_define("SWIGPERL 1", 0);
+ // SWIGPERL5 is deprecated, and no longer documented.
Preprocessor_define("SWIGPERL5 1", 0);
SWIG_typemap_lang("perl5");
SWIG_config_file("perl5.swg");
@@ -220,11 +224,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -232,6 +237,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@@ -250,11 +256,12 @@ public:
constant_tab = NewString("static swig_constant_info swig_constants[] = {\n");
variable_tab = NewString("static swig_variable_info swig_variables[] = {\n");
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+ Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGPERL\n");
Printf(f_runtime, "#define SWIG_CASTRANK_MODE\n");
-
+ Printf(f_runtime, "\n");
// Is the imported module in another package? (IOW, does it use the
// %module(package="name") option and it's different than the package
@@ -313,7 +320,7 @@ public:
pmfile = NewStringf("%s.pm", m);
}
String *filen = NewStringf("%s%s", SWIG_output_directory(), pmfile);
- if ((f_pm = NewFile(filen, "w")) == 0) {
+ if ((f_pm = NewFile(filen, "w", SWIG_output_files())) == 0) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
}
@@ -330,10 +337,7 @@ public:
Delete(boot_name);
}
- Printf(f_pm, "# This file was automatically generated by SWIG (http://www.swig.org).\n");
- Printf(f_pm, "# Version %s\n", Swig_package_version());
- Printf(f_pm, "#\n");
- Printf(f_pm, "# Don't modify this file, modify the SWIG interface instead.\n");
+ Swig_banner_target_lang(f_pm, "#");
Printf(f_pm, "\n");
Printf(f_pm, "package %s;\n", module);
@@ -522,14 +526,16 @@ public:
Delete(underscore_module);
/* Close all of the files */
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -556,7 +562,6 @@ public:
String *iname = Getattr(n, "sym:name");
SwigType *d = Getattr(n, "type");
ParmList *l = Getattr(n, "parms");
- ParmList *outer = Getattr(n, "perl5:implicits");
String *overname = 0;
Parm *p;
@@ -566,7 +571,7 @@ public:
String *tm;
String *cleanup, *outarg;
int num_saved = 0;
- int num_arguments, num_required, num_implicits;
+ int num_arguments, num_required;
int varargs = 0;
if (Getattr(n, "sym:overloaded")) {
@@ -588,19 +593,6 @@ public:
Printv(f->def, "XS(", wname, ") {\n", "{\n", /* scope to destroy C++ objects before croaking */
NIL);
- num_implicits = 0;
- if (outer) {
- Parm *tmp = outer;
- Parm *tail;
- while(tmp) {
- tail = tmp;
- num_implicits++;
- tmp = nextSibling(tmp);
- }
- /* link the outer with inner parms */
- set_nextSibling(tail, l);
- }
-
emit_parameter_variables(l, f);
emit_attach_parmmaps(l, f);
Setattr(n, "wrap:parms", l);
@@ -613,29 +605,13 @@ public:
/* Check the number of arguments */
if (!varargs) {
- Printf(f->code, " if ((items < %d) || (items > %d)) {\n",
- num_required + num_implicits, num_arguments + num_implicits);
+ Printf(f->code, " if ((items < %d) || (items > %d)) {\n", num_required, num_arguments);
} else {
- Printf(f->code, " if (items < %d) {\n",
- num_required + num_implicits);
+ Printf(f->code, " if (items < %d) {\n", num_required);
}
- Printf(f->code, " SWIG_croak(\"Usage: %s\");\n", usage_func(Char(iname), d, outer, l));
+ Printf(f->code, " SWIG_croak(\"Usage: %s\");\n", usage_func(Char(iname), d, l));
Printf(f->code, "}\n");
- if (num_implicits) {
- /* TODO: support implicits of types other than SVs */
- Parm *p = outer;
- for(i = 0; i < num_implicits; i++) {
- String *pname = Getattr(p, "name");
- String *pinit = SwigType_str(Getattr(p, "type"), pname);
- Wrapper_add_local(f, pname, pinit);
- Delete(pinit);
- Printf(f->code, "%s = ST(%d);\n", pname, i++);
- p = nextSibling(p);
- }
- if (l)
- Printf(f->code, "ax += %d;\n", num_implicits);
- }
/* Write code to extract parameters. */
i = 0;
for (i = 0, p = l; i < num_arguments; i++) {
@@ -748,9 +724,6 @@ public:
Wrapper_add_localv(f, "_saved", "SV *", temp, NIL);
}
- if (num_implicits && l)
- Printf(f->code, "ax -= %d;\n", num_implicits);
-
/* Now write code to make the function call */
Swig_director_emit_dynamic_cast(n, f);
@@ -797,11 +770,6 @@ public:
Printf(f->code, "%s\n", tm);
}
- if (blessed && Equal(nodeType(n), "constructor")) {
- Append(f->code,
- "if (SvOK(ST(0))) sv_bless(ST(0), gv_stashsv(proto, 0));\n");
- }
-
Printv(f->code, "XSRETURN(argvi);\n", "fail:\n", cleanup, "SWIG_croak_null();\n" "}\n" "}\n", NIL);
/* Add the dXSARGS last */
@@ -833,10 +801,6 @@ public:
Printv(df->def, "XS(", dname, ") {\n", NIL);
Wrapper_add_local(df, "dXSARGS", "dXSARGS");
- if (num_implicits) {
- Printf(df->code, "ax += %d;\n", num_implicits);
- Printf(df->code, "items -= %d;\n", num_implicits);
- }
Printv(df->code, dispatch, "\n", NIL);
Printf(df->code, "croak(\"No matching function for overloaded '%s'\");\n", iname);
Printf(df->code, "XSRETURN(0);\n");
@@ -1073,7 +1037,7 @@ public:
/* ------------------------------------------------------------
* usage_func()
* ------------------------------------------------------------ */
- char *usage_func(char *iname, SwigType *, ParmList *il, ParmList *l) {
+ char *usage_func(char *iname, SwigType *, ParmList *l) {
static String *temp = 0;
Parm *p;
int i;
@@ -1083,17 +1047,13 @@ public:
Clear(temp);
Printf(temp, "%s(", iname);
- i = 0;
- /* Print implicit parameters */
- for(p = il; p; p = nextSibling(p))
- Printv(temp, (i > 0 ? "," : ""), Getattr(p, "name"), NIL);
- /* Now go through and print normal parameters */
+ /* Now go through and print parameters */
p = l;
+ i = 0;
while (p != 0) {
SwigType *pt = Getattr(p, "type");
String *pn = Getattr(p, "name");
if (!checkAttribute(p,"tmap:in:numinputs","0")) {
- if (i > 0) Append(temp, ",");
/* If parameter has been named, use that. Otherwise, just print a type */
if (SwigType_type(pt) != T_VOID) {
if (Len(pn) > 0) {
@@ -1103,8 +1063,16 @@ public:
}
}
i++;
+ p = nextSibling(p);
+ if (p)
+ if (!checkAttribute(p,"tmap:in:numinputs","0"))
+ Putc(',', temp);
+ } else {
+ p = nextSibling(p);
+ if (p)
+ if ((i > 0) && (!checkAttribute(p,"tmap:in:numinputs","0")))
+ Putc(',', temp);
}
- p = nextSibling(p);
}
Printf(temp, ");");
return Char(temp);
@@ -1177,8 +1145,9 @@ public:
/* Do some work on the class name */
if (verbose > 0) {
+ String *modulename = Getattr(clsmodule, "name");
fprintf(stdout, "setclassname: Found sym:name: %s\n", Char(symname));
- fprintf(stdout, "setclassname: Found module: %s\n", Char(clsmodule));
+ fprintf(stdout, "setclassname: Found module: %s\n", Char(modulename));
fprintf(stdout, "setclassname: No package found\n");
}
@@ -1222,8 +1191,6 @@ public:
* ------------------------------------------------------------ */
virtual int classHandler(Node *n) {
- String *name = 0; /* Real name of C/C++ class */
- String *fullclassname = 0;
if (blessed) {
have_constructor = 0;
@@ -1243,7 +1210,7 @@ public:
} else {
fullclassname = NewString(class_name);
}
- name = Getattr(n, "name");
+ real_classname = Getattr(n, "name");
pcode = NewString("");
// blessedmembers = NewString("");
}
@@ -1255,7 +1222,7 @@ public:
/* Finish the rest of the class */
if (blessed) {
/* Generate a client-data entry */
- SwigType *ct = NewStringf("p.%s", name);
+ SwigType *ct = NewStringf("p.%s", real_classname);
Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", SwigType_manglestr(ct), ", (void*) \"", fullclassname, "\");\n", NIL);
SwigType_remember(ct);
Delete(ct);
@@ -1528,15 +1495,6 @@ public:
String *symname = Getattr(n, "sym:name");
- {
- String *type = NewString("SV");
- SwigType_add_pointer(type);
- Parm *p = NewParm(type, "proto");
- Delete(type);
- Setattr(n, "perl5:implicits", p);
- Delete(p);
- }
-
member_func = 1;
Language::constructorHandler(n);
@@ -1548,16 +1506,17 @@ public:
Delete(plaction);
Printv(pcode, plcode, NIL);
} else {
- /* Emit a blessed constructor */
- String *cname = Swig_name_construct(symname);
- char *pname;
- /* override Class->Class to be Class->new */
- if (Cmp(symname, class_name) == 0)
- pname = "new";
- else
- pname = Char(cname);
- Printf(pcode, "*%s = *%s::%s;\n", pname, cmodule, cname);
- Delete(cname);
+ if ((Cmp(symname, class_name) == 0)) {
+ /* Emit a blessed constructor */
+ Printf(pcode, "sub new {\n");
+ } else {
+ /* Constructor doesn't match classname so we'll just use the normal name */
+ Printv(pcode, "sub ", Swig_name_construct(symname), " () {\n", NIL);
+ }
+
+ Printv(pcode,
+ tab4, "my $pkg = shift;\n",
+ tab4, "my $self = ", cmodule, "::", Swig_name_construct(symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL);
have_constructor = 1;
}
@@ -1670,7 +1629,7 @@ public:
} else if (Strcmp(code, "include") == 0) {
/* Include a file into the .pm file */
if (value) {
- FILE *f = Swig_open(value);
+ FILE *f = Swig_include_open(value);
if (!f) {
Printf(stderr, "%s : Line %d. Unable to locate file %s\n", input_file, line_number, value);
} else {
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index 9369c2489..ee69c1864 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -2,9 +2,9 @@
* See the LICENSE file for information on copyright, usage and redistribution
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
*
- * php4.cxx
+ * php.cxx
*
- * Php language module for SWIG.
+ * PHP language module for SWIG.
* -----------------------------------------------------------------------------
*/
@@ -40,7 +40,7 @@
* (may need to add more WARN_PHP_xxx codes...)
*/
-char cvsroot_php4_cxx[] = "$Id$";
+char cvsroot_php_cxx[] = "$Id$";
#include "swigmod.h"
@@ -48,13 +48,13 @@ char cvsroot_php4_cxx[] = "$Id$";
#include <errno.h>
static const char *usage = (char *) "\
-PHP Options (available with -php5)\n\
+PHP Options (available with -php)\n\
-cppext - cpp file extension (default to .cpp)\n\
-noproxy - Don't generate proxy classes.\n\
- -prefix <prefix> - Prepend <prefix> to all class names in PHP5 wrappers\n\
+ -prefix <prefix> - Prepend <prefix> to all class names in PHP wrappers\n\
\n";
-/* The original class wrappers for PHP4 store the pointer to the C++ class in
+/* The original class wrappers for PHP stored the pointer to the C++ class in
* the object property _cPtr. If we use the same name for the member variable
* which we put the pointer to the C++ class in, then the flat function
* wrappers will automatically pull it out without any changes being required.
@@ -71,6 +71,7 @@ static String *prefix = 0;
static String *shadow_classname = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_h = 0;
static File *f_phpcode = 0;
@@ -141,7 +142,7 @@ void SwigPHP_emit_resource_registrations() {
Printf(s_wrappers, "/* NEW Destructor style */\nstatic ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key);
// write out body
- if ((class_node != NOTCLASS)) {
+ if (class_node != NOTCLASS) {
String *destructor = Getattr(class_node, "destructor");
human_name = Getattr(class_node, "sym:name");
if (!human_name)
@@ -172,12 +173,9 @@ void SwigPHP_emit_resource_registrations() {
}
}
-class PHP:public Language {
- int php_version;
-
+class PHP : public Language {
public:
- PHP(int php_version_):php_version(php_version_) {
- }
+ PHP() { }
/* Test to see if a type corresponds to something wrapped with a shadow class. */
@@ -242,8 +240,9 @@ public:
}
Preprocessor_define("SWIGPHP 1", 0);
+ // SWIGPHP5 is deprecated, and no longer documented.
Preprocessor_define("SWIGPHP5 1", 0);
- SWIG_typemap_lang("php4");
+ SWIG_typemap_lang("php");
SWIG_config_file("php.swg");
allow_overloading();
}
@@ -261,13 +260,12 @@ public:
String *outfile = Getattr(n, "outfile");
/* main output file */
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
-
- Swig_banner(f_runtime);
+ f_runtime = NewString("");
/* sections of the output file */
s_init = NewString("/* init section */\n");
@@ -286,6 +284,7 @@ public:
s_phpclasses = NewString("/* PHP Proxy Classes */\n");
/* Register file targets with the SWIG file handler */
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", s_init);
Swig_register_filebyname("rinit", r_init);
@@ -294,6 +293,12 @@ public:
Swig_register_filebyname("header", s_header);
Swig_register_filebyname("wrapper", s_wrappers);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGPHP\n");
+ Printf(f_runtime, "\n");
+
/* Set the module name */
module = Copy(Getattr(n, "name"));
cap_module = NewStringf("%(upper)s", module);
@@ -305,7 +310,7 @@ public:
Printv(filen, SWIG_output_directory(), module, ".php", NIL);
phpfilename = NewString(filen);
- f_phpcode = NewFile(filen, "w");
+ f_phpcode = NewFile(filen, "w", SWIG_output_files());
if (!f_phpcode) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -315,6 +320,7 @@ public:
Swig_banner(f_phpcode);
+ Printf(f_phpcode, "\n");
Printf(f_phpcode, "// Try to load our extension if it's not already loaded.\n");
Printf(f_phpcode, "if (!extension_loaded(\"%s\")) {\n", module);
Printf(f_phpcode, " if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {\n");
@@ -384,7 +390,7 @@ public:
/* Create the .h file too */
filen = NewStringEmpty();
Printv(filen, SWIG_output_directory(), "php_", module, ".h", NIL);
- f_h = NewFile(filen, "w");
+ f_h = NewFile(filen, "w", SWIG_output_files());
if (!f_h) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -392,7 +398,7 @@ public:
Swig_banner(f_h);
- Printf(f_h, "\n\n");
+ Printf(f_h, "\n");
Printf(f_h, "#ifndef PHP_%s_H\n", cap_module);
Printf(f_h, "#define PHP_%s_H\n\n", cap_module);
Printf(f_h, "extern zend_module_entry %s_module_entry;\n", module);
@@ -521,16 +527,19 @@ public:
Printf(s_wrappers, "/* end wrapper section */\n");
Printf(s_vdecl, "/* end vdecl subsection */\n");
- Printv(f_runtime, s_header, s_vdecl, s_wrappers, NIL);
- Printv(f_runtime, all_cs_entry, "\n\n", s_entry, "{NULL, NULL, NULL}\n};\n\n", NIL);
- Printv(f_runtime, s_init, NIL);
+ Dump(f_runtime, f_begin);
+ Printv(f_begin, s_header, s_vdecl, s_wrappers, NIL);
+ Printv(f_begin, all_cs_entry, "\n\n", s_entry, "{NULL, NULL, NULL}\n};\n\n", NIL);
+ Printv(f_begin, s_init, NIL);
Delete(s_header);
Delete(s_wrappers);
Delete(s_init);
Delete(s_vdecl);
Delete(all_cs_entry);
Delete(s_entry);
- Close(f_runtime);
+ Close(f_begin);
+ Delete(f_runtime);
+ Delete(f_begin);
Printf(f_phpcode, "%s\n%s\n", pragma_incl, pragma_code);
if (s_fakeoowrappers) {
@@ -589,7 +598,7 @@ public:
Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n");
Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname);
- Printv(f->code, "zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());\n", NIL);
+ Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n", NIL);
Printv(f->code, "}\n", NIL);
Wrapper_print(f, s_wrappers);
@@ -710,7 +719,7 @@ public:
Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n");
}
- /* Now convert from php to C variables */
+ /* Now convert from PHP to C variables */
// At this point, argcount if used is the number of deliberately passed args
// not including this_ptr even if it is used.
// It means error messages may be out by argbase with error
@@ -845,7 +854,7 @@ public:
/* Error handling code */
Printf(f->code, "fail:\n");
Printv(f->code, cleanup, NIL);
- Printv(f->code, "zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());", NIL);
+ Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
Printf(f->code, "}\n");
@@ -861,7 +870,7 @@ public:
Delete(wname);
wname = NULL;
- if (!(shadow && php_version == 5)) {
+ if (!shadow) {
DelWrapper(f);
return SWIG_OK;
}
@@ -1104,7 +1113,8 @@ public:
case T_LONG: {
char *p;
errno = 0;
- (void) strtol(Char(value), &p, 0);
+ unsigned int n = strtol(Char(value), &p, 0);
+ (void) n;
if (errno || *p) {
Clear(value);
Append(value, "?");
@@ -1117,7 +1127,8 @@ public:
case T_ULONG: {
char *p;
errno = 0;
- (void) strtoul(Char(value), &p, 0);
+ unsigned int n = strtoul(Char(value), &p, 0);
+ (void) n;
if (errno || *p) {
Clear(value);
Append(value, "?");
@@ -1358,16 +1369,26 @@ public:
Printf(output, "\n");
// If it's a member function or a class constructor...
if (wrapperType == memberfn || (newobject && current_class)) {
- Printf(output, "\tfunction %s(%s) {\n", methodname, args);
// We don't need this code if the wrapped class has a copy ctor
// since the flat function new_CLASSNAME will handle it for us.
if (newobject && !Getattr(current_class, "allocate:copy_constructor")) {
+ const char * arg0;
+ if (max_num_of_arguments > 0) {
+ arg0 = Char(arg_names[0]);
+ } else {
+ arg0 = "res";
+ Delete(args);
+ args = NewString("$res=null");
+ }
SwigType *t = Getattr(current_class, "classtype");
String *mangled_type = SwigType_manglestr(SwigType_ltype(t));
- Printf(s_oowrappers, "\t\tif (is_resource($%s) && get_resource_type($%s) == \"_p%s\") {\n", arg_names[0], arg_names[0], mangled_type);
- Printf(s_oowrappers, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg_names[0]);
- Printf(s_oowrappers, "\t\t\treturn;\n");
- Printf(s_oowrappers, "\t\t}\n");
+ Printf(output, "\tfunction %s(%s) {\n", methodname, args);
+ Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) == \"_p%s\") {\n", arg0, arg0, mangled_type);
+ Printf(output, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg0);
+ Printf(output, "\t\t\treturn;\n");
+ Printf(output, "\t\t}\n");
+ } else {
+ Printf(output, "\tfunction %s(%s) {\n", methodname, args);
}
} else {
Printf(output, "\tstatic function %s(%s) {\n", methodname, args);
@@ -1480,8 +1501,7 @@ public:
Replaceall(tm, "$symname", iname);
Printf(f_c->code, "%s\n", tm);
} else {
- Printf(stderr,"%s: Line %d, Unable to link with type %s\n",
- input_file, line_number, SwigType_str(t, 0));
+ Printf(stderr,"%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0));
}
*/
/* Now generate C -> PHP sync blocks */
@@ -1493,8 +1513,7 @@ public:
Replaceall(tm, "$symname", iname);
Printf(f_php->code, "%s\n", tm);
} else {
- Printf(stderr,"%s: Line %d, Unable to link with type %s\n",
- input_file, line_number, SwigType_str(t, 0));
+ Printf(stderr,"%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0));
}
}
*/
@@ -1525,7 +1544,7 @@ public:
Printf(s_cinit, "%s\n", tm);
}
- if (shadow && php_version == 5) {
+ if (shadow) {
String *enumvalue = GetChar(n, "enumvalue");
String *set_to = iname;
@@ -1567,8 +1586,8 @@ public:
*
* Pragma directive.
*
- * %pragma(php4) code="String" # Includes a string in the .php file
- * %pragma(php4) include="file.pl" # Includes a file in the .php file
+ * %pragma(php) code="String" # Includes a string in the .php file
+ * %pragma(php) include="file.pl" # Includes a file in the .php file
*/
virtual int pragmaDirective(Node *n) {
@@ -1577,7 +1596,7 @@ public:
String *type = Getattr(n, "name");
String *value = Getattr(n, "value");
- if (Strcmp(lang, "php4") == 0) {
+ if (Strcmp(lang, "php") == 0 || Strcmp(lang, "php4") == 0) {
if (Strcmp(type, "code") == 0) {
if (value) {
Printf(pragma_code, "%s\n", value);
@@ -1815,7 +1834,7 @@ public:
String *iname = Getattr(n, "sym:name");
/* A temporary(!) hack for static member variables.
- * Php currently supports class functions, but not class variables.
+ * PHP currently supports class functions, but not class variables.
* Until it does, we convert a class variable to a class function
* that returns the current value of the variable. E.g.
*
@@ -1824,7 +1843,7 @@ public:
* static int ncount;
* };
*
- * would be available in php as Example::ncount()
+ * would be available in PHP as Example::ncount()
*/
// If the variable is const, then it's wrapped as a constant with set/get
@@ -1923,7 +1942,7 @@ public:
return NewStringEmpty();
}
- String *PhpTypeFromTypemap(char *op, Node *n, String_or_char *lname) {
+ String *PhpTypeFromTypemap(char *op, Node *n, const_String_or_char_ptr lname) {
String *tms = Swig_typemap_lookup(op, n, lname, 0);
if (!tms)
return 0;
@@ -1999,7 +2018,6 @@ public:
Wrapper_print(f, s_wrappers);
return SWIG_OK;
-
}
/* ------------------------------------------------------------
@@ -2007,7 +2025,7 @@ public:
* ------------------------------------------------------------ */
virtual int memberconstantHandler(Node *n) {
- wrapping_member_constant = Getattr(n, "name");
+ wrapping_member_constant = Getattr(n, "sym:name");
Language::memberconstantHandler(n);
wrapping_member_constant = NULL;
return SWIG_OK;
@@ -2015,10 +2033,6 @@ public:
}; /* class PHP */
-/* -----------------------------------------------------------------------------
- * swig_php() - Instantiate module
- * ----------------------------------------------------------------------------- */
-
static PHP *maininstance = 0;
// We use this function to be able to write out zend_register_list_destructor_ex
@@ -2045,8 +2059,12 @@ extern "C" void typetrace(SwigType *ty, String *mangled, String *clientdata) {
(*r_prevtracefunc) (ty, mangled, (String *) clientdata);
}
-static Language *new_swig_php(int php_version) {
- maininstance = new PHP(php_version);
+/* -----------------------------------------------------------------------------
+ * new_swig_php() - Instantiate module
+ * ----------------------------------------------------------------------------- */
+
+static Language *new_swig_php() {
+ maininstance = new PHP;
if (!r_prevtracefunc) {
r_prevtracefunc = SwigType_remember_trace(typetrace);
} else {
@@ -2063,6 +2081,6 @@ extern "C" Language *swig_php4(void) {
return NULL; // To avoid compiler warnings.
}
-extern "C" Language *swig_php5(void) {
- return new_swig_php(5);
+extern "C" Language *swig_php(void) {
+ return new_swig_php();
}
diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx
index 30f9b3d74..98f63056c 100644
--- a/Source/Modules/pike.cxx
+++ b/Source/Modules/pike.cxx
@@ -39,6 +39,7 @@ Pike Options (available with -pike)\n\
class PIKE:public Language {
private:
+ File *f_begin;
File *f_runtime;
File *f_header;
File *f_wrappers;
@@ -69,6 +70,7 @@ public:
* --------------------------------------------------------------------- */
PIKE() {
+ f_begin = 0;
f_runtime = 0;
f_header = 0;
f_wrappers = 0;
@@ -123,11 +125,12 @@ public:
String *outfile = Getattr(n, "outfile");
/* Open the output file */
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_classInit = NewString("");
f_header = NewString("");
@@ -136,12 +139,17 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("classInit", f_classInit);
/* Standard stuff for the SWIG runtime section */
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGPIKE\n");
+ Printf(f_runtime, "\n");
Printf(f_header, "#define SWIG_init pike_module_init\n");
Printf(f_header, "#define SWIG_name \"%s\"\n\n", module);
@@ -161,17 +169,19 @@ public:
SwigType_emit_type_table(f_runtime, f_wrappers);
/* Close all of the files */
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Delete(f_classInit);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
/* Done */
return SWIG_OK;
@@ -221,7 +231,7 @@ public:
* name (i.e. "enum_test").
* ------------------------------------------------------------ */
- String *strip(const DOHString_or_char *name) {
+ String *strip(const DOHconst_String_or_char_ptr name) {
String *s = Copy(name);
if (Strncmp(name, PrefixPlusUnderscore, Len(PrefixPlusUnderscore)) != 0) {
return s;
@@ -234,7 +244,7 @@ public:
* add_method()
* ------------------------------------------------------------ */
- void add_method(const DOHString_or_char *name, const DOHString_or_char *function, const DOHString_or_char *description) {
+ void add_method(const DOHconst_String_or_char_ptr name, const DOHconst_String_or_char_ptr function, const DOHconst_String_or_char_ptr description) {
String *rename = NULL;
switch (current) {
case NO_CPP:
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index ddd23d1f3..73f280e6b 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -10,11 +10,8 @@
char cvsroot_python_cxx[] = "$Id$";
#include "swigmod.h"
-#define ctab2 " "
-#define ctab4 " "
-#define ctab8 " "
-
#include "cparse.h"
+
static int treduce = SWIG_cparse_template_reduce(0);
#include <ctype.h>
@@ -31,6 +28,7 @@ static int shadow = 1;
static int use_kw = 0;
static int director_method_index = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_runtime_h = 0;
static File *f_header = 0;
@@ -49,10 +47,11 @@ static String *shadow_indent = 0;
static int in_class = 0;
static int classic = 0;
static int modern = 0;
-static int apply = 0;
static int new_repr = 1;
static int no_header_file = 0;
+static int py3 = 0;
+
/* C++ Support + Shadow Classes */
static int have_constructor;
@@ -96,7 +95,6 @@ enum autodoc_t {
static const char *usage1 = (char *) "\
Python Options (available with -python)\n\
-aliasobj0 - Alias obj0 when using fastunpack, needed for some old typemaps \n\
- -apply - Use apply() in proxy classes\n\
-buildnone - Use Py_BuildValue(" ") to obtain Py_None (default in Windows)\n\
-castmode - Enable the casting mode, which allows implicit cast between types in python\n\
-classic - Use classic classes only\n\
@@ -148,6 +146,8 @@ static const char *usage3 = (char *) "\
-O - Enable all the optimization options: \n\
-modern -fastdispatch -dirvtable -nosafecstrings -fvirtual -noproxydel \n\
-fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone \n\
+ -py3 - Generate code with Python 3 specific features:\n\
+ Function annotation \n\
\n";
class PYTHON:public Language {
@@ -259,9 +259,6 @@ public:
} else if ((strcmp(argv[i], "-shadow") == 0) || ((strcmp(argv[i], "-proxy") == 0))) {
shadow = 1;
Swig_mark_arg(i);
- } else if (strcmp(argv[i], "-apply") == 0) {
- apply = 1;
- Swig_mark_arg(i);
} else if ((strcmp(argv[i], "-new_repr") == 0) || (strcmp(argv[i], "-newrepr") == 0)) {
new_repr = 1;
Swig_mark_arg(i);
@@ -284,7 +281,6 @@ public:
} else if (strcmp(argv[i], "-classic") == 0) {
classic = 1;
modernargs = 0;
- apply = 1;
modern = 0;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-cppcast") == 0) {
@@ -390,7 +386,6 @@ public:
proxydel = 0;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-modern") == 0) {
- apply = 0;
classic = 0;
modern = 1;
modernargs = 1;
@@ -408,7 +403,6 @@ public:
no_header_file = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-O") == 0) {
- apply = 0;
classic = 0;
modern = 1;
dirvtable = 1;
@@ -429,8 +423,17 @@ public:
fputs(usage1, stdout);
fputs(usage2, stdout);
fputs(usage3, stdout);
- }
+ } else if (strcmp(argv[i], "-py3") == 0) {
+ py3 = 1;
+ Swig_mark_arg(i);
+ }
+
}
+ } /* for */
+
+ if (py3) {
+ /* force disable features that not compatible with Python 3.x */
+ classic = 0;
}
if (cppcast) {
@@ -511,15 +514,21 @@ public:
String *outfile = Getattr(n, "outfile");
String *outfile_h = !no_header_file ? Getattr(n, "outfile_h") : 0;
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
+ f_init = NewString("");
+ f_header = NewString("");
+ f_wrappers = NewString("");
+ f_directors_h = NewString("");
+ f_directors = NewString("");
if (directorsEnabled()) {
if (!no_header_file) {
- f_runtime_h = NewFile(outfile_h, "w");
+ f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
if (!f_runtime_h) {
FileErrorDisplay(outfile_h);
SWIG_exit(EXIT_FAILURE);
@@ -529,15 +538,10 @@ public:
}
}
- f_init = NewString("");
- f_header = NewString("");
- f_wrappers = NewString("");
- f_directors_h = NewString("");
- f_directors = NewString("");
-
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("director", f_directors);
@@ -546,8 +550,9 @@ public:
const_code = NewString("");
methods = NewString("");
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+ Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGPYTHON\n");
if (directorsEnabled()) {
@@ -599,6 +604,8 @@ public:
Printf(f_runtime, "#define SWIG_PYTHON_CLASSIC\n");
}
+ Printf(f_runtime, "\n");
+
Printf(f_header, "#if (PY_VERSION_HEX <= 0x02000000)\n");
Printf(f_header, "# if !defined(SWIG_PYTHON_CLASSIC)\n");
Printf(f_header, "# error \"This python version requires swig to be run with the '-classic' option\"\n");
@@ -637,6 +644,7 @@ public:
if (directorsEnabled()) {
Swig_banner(f_directors_h);
+ Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module);
if (dirprot_mode()) {
@@ -660,7 +668,7 @@ public:
module = interface;
else
Insert(module, 0, "_");
- if ((f_shadow_py = NewFile(filen, "w")) == 0) {
+ if ((f_shadow_py = NewFile(filen, "w", SWIG_output_files())) == 0) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
}
@@ -674,10 +682,7 @@ public:
Swig_register_filebyname("shadow", f_shadow);
Swig_register_filebyname("python", f_shadow);
- Printf(f_shadow, "# This file was automatically generated by SWIG (http://www.swig.org).\n");
- Printf(f_shadow, "# Version %s\n", Swig_package_version());
- Printf(f_shadow, "#\n");
- Printf(f_shadow, "# Don't modify this file, modify the SWIG interface instead.\n");
+ Swig_banner_target_lang(f_shadow, "#");
if (!modern) {
Printv(f_shadow, "# This file is compatible with both classic and new-style classes.\n", NIL);
@@ -691,6 +696,13 @@ public:
Printv(f_shadow, "\nfrom sys import version_info\n", NULL);
+ if(fastproxy)
+ {
+ Printv(f_shadow, "if version_info >= (3,0,0):\n", NULL);
+ Printf(f_shadow, tab4 "new_instancemethod = lambda func, inst, cls: %s.SWIG_PyInstanceMethod_New(func)\n", module);
+ Printv(f_shadow, "else:\n", NULL);
+ Printv(f_shadow, tab4, "from new import instancemethod as new_instancemethod\n", NULL);
+ }
/* Import the C-extension module. This should be a relative import,
* since the shadow module may also have been imported by a relative
* import, and there is thus no guarantee that the C-extension is on
@@ -704,12 +716,19 @@ public:
Printv(f_shadow, tab4, "def swig_import_helper():\n", NULL);
Printv(f_shadow, tab8, "from os.path import dirname\n", NULL);
Printv(f_shadow, tab8, "import imp\n", NULL);
+ Printv(f_shadow, tab8, "fp = None\n", NULL);
Printv(f_shadow, tab8, "try:\n", NULL);
Printf(f_shadow, tab4 tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module);
- Printf(f_shadow, tab4 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module);
- Printv(f_shadow, tab8, "finally:\n", NULL);
- Printv(f_shadow, tab4 tab8, "if fp is not None: fp.close()\n", NULL);
- Printv(f_shadow, tab8, "return _mod\n", NULL);
+ Printf(f_shadow, tab8 "except ImportError:\n");
+ /* At here, the module may already loaded, so simply import it. */
+ Printf(f_shadow, tab4 tab8 "import %s\n", module);
+ Printf(f_shadow, tab4 tab8 "return %s\n", module);
+ Printv(f_shadow, tab8 "if fp is not None:\n", NULL);
+ Printv(f_shadow, tab4 tab8 "try:\n", NULL);
+ Printf(f_shadow, tab8 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module);
+ Printv(f_shadow, tab4 tab8, "finally:\n", NULL);
+ Printv(f_shadow, tab8 tab8, "fp.close()\n", NULL);
+ Printv(f_shadow, tab8 tab8, "return _mod\n", NULL);
Printf(f_shadow, tab4 "%s = swig_import_helper()\n", module);
Printv(f_shadow, tab4, "del swig_import_helper\n", NULL);
Printv(f_shadow, "else:\n", NULL);
@@ -719,11 +738,9 @@ public:
* module. */
Printv(f_shadow, "del version_info\n", NULL);
- Printv(f_shadow, "import new\n", NULL);
- Printv(f_shadow, "new_instancemethod = new.instancemethod\n", NULL);
if (modern || !classic) {
Printv(f_shadow, "try:\n", tab4, "_swig_property = property\n", "except NameError:\n", tab4, "pass # Python < 2.2 doesn't have 'property'.\n", NULL);
- }
+ }
/* if (!modern) */
/* always needed, a class can be forced to be no-modern, such as an exception */
{
@@ -731,7 +748,7 @@ public:
Printv(f_shadow,
"def _swig_setattr_nondynamic(self,class_type,name,value,static=1):\n",
tab4, "if (name == \"thisown\"): return self.this.own(value)\n",
- tab4, "if (name == \"this\"):\n", tab4, tab4, "if type(value).__name__ == 'PySwigObject':\n", tab4, tab8, "self.__dict__[name] = value\n",
+ tab4, "if (name == \"this\"):\n", tab4, tab4, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n",
#ifdef USE_THISOWN
tab4, tab8, "if hasattr(value,\"thisown\"): self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n",
#endif
@@ -750,7 +767,7 @@ public:
"def _swig_getattr(self,class_type,name):\n",
tab4, "if (name == \"thisown\"): return self.this.own()\n",
tab4, "method = class_type.__swig_getmethods__.get(name,None)\n",
- tab4, "if method: return method(self)\n", tab4, "raise AttributeError,name\n\n", NIL);
+ tab4, "if method: return method(self)\n", tab4, "raise AttributeError(name)\n\n", NIL);
Printv(f_shadow,
"def _swig_repr(self):\n",
@@ -758,11 +775,17 @@ public:
tab4, "except: strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);
if (!classic) {
+ /* Usage of types.ObjectType is deprecated.
+ * But don't sure wether this would broken old Python?
+ */
Printv(f_shadow,
- "import types\n",
+// "import types\n",
"try:\n",
- " _object = types.ObjectType\n",
- " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n", "del types\n", "\n\n", NIL);
+// " _object = types.ObjectType\n",
+ " _object = object\n",
+ " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n",
+// "del types\n",
+ "\n\n", NIL);
}
}
if (modern) {
@@ -788,7 +811,11 @@ public:
}
- Printf(f_header, "#define SWIG_init init%s\n\n", module);
+ Printf(f_header, "#if PY_VERSION_HEX >= 0x03000000\n");
+ Printf(f_header, "# define SWIG_init PyInit_%s\n\n", module);
+ Printf(f_header, "#else\n");
+ Printf(f_header, "# define SWIG_init init%s\n\n", module);
+ Printf(f_header, "#endif\n");
Printf(f_header, "#define SWIG_name \"%s\"\n", module);
Printf(f_wrappers, "#ifdef __cplusplus\n");
@@ -797,6 +824,9 @@ public:
Append(const_code, "static swig_const_info swig_const_table[] = {\n");
Append(methods, "static PyMethodDef SwigMethods[] = {\n");
+ /* the method exported for replacement of new.instancemethod in Python 3 */
+ add_pyinstancemethod_new();
+
/* emit code */
Language::top(n);
@@ -815,6 +845,12 @@ public:
Append(const_code, "{0, 0, 0, 0.0, 0, 0}};\n");
Printf(f_wrappers, "%s\n", const_code);
initialize_threads(f_init);
+
+ Printf(f_init, "#if PY_VERSION_HEX >= 0x03000000\n");
+ Printf(f_init, " return m;\n");
+ Printf(f_init, "#else\n");
+ Printf(f_init, " return;\n");
+ Printf(f_init, "#endif\n");
Printf(f_init, "}\n");
Printf(f_wrappers, "#ifdef __cplusplus\n");
@@ -822,10 +858,6 @@ public:
Printf(f_wrappers, "#endif\n");
if (shadow) {
- /*
- Printf(f_shadow_imports,"\nimport %s\n", module);
- Printv(f_shadow_py, f_shadow_imports, "\n",NIL);
- */
Printv(f_shadow_py, f_shadow, "\n", NIL);
Printv(f_shadow_py, f_shadow_stubs, "\n", NIL);
@@ -834,19 +866,20 @@ public:
}
/* Close all of the files */
- Dump(f_header, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
if (directorsEnabled()) {
Dump(f_directors_h, f_runtime_h);
Printf(f_runtime_h, "\n");
Printf(f_runtime_h, "#endif\n");
- if (f_runtime_h != f_runtime)
+ if (f_runtime_h != f_begin)
Close(f_runtime_h);
- Dump(f_directors, f_runtime);
+ Dump(f_directors, f_begin);
}
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
@@ -854,11 +887,25 @@ public:
Delete(f_directors);
Delete(f_directors_h);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
+
+ /* ------------------------------------------------------------
+ * Emit the wrapper for PyInstanceMethod_New to MethodDef array.
+ * This wrapper is used to implement -fastproxy,
+ * as a replacement of new.instancemethod in Python 3.
+ * ------------------------------------------------------------ */
+ int add_pyinstancemethod_new()
+ {
+ String* name = NewString("SWIG_PyInstanceMethod_New");
+ Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, NULL},\n", name, name);
+ Delete(name);
+ return 0;
+ }
/* ------------------------------------------------------------
* importDirective()
@@ -890,7 +937,11 @@ public:
if (!options || (!Getattr(options, "noshadow") && !Getattr(options, "noproxy"))) {
Printf(import, "_%s\n", modname);
if (!Strstr(f_shadow_imports, import)) {
- Printf(f_shadow, "import %s\n", modname);
+ if (pkg && (!package || Strcmp(pkg, package) != 0)) {
+ Printf(f_shadow, "import %s.%s\n", pkg, modname);
+ } else {
+ Printf(f_shadow, "import %s\n", modname);
+ }
Printv(f_shadow_imports, import, NULL);
}
}
@@ -902,31 +953,25 @@ public:
return Language::importDirective(n);
}
-
/* ------------------------------------------------------------
- * emitFuncCallHelper()
- * Write the shadow code to call a function in the extension
- * module. Takes into account the -apply flag and whether
- * to use keyword args or not.
+ * funcCall()
+ * Emit shadow code to call a function in the extension
+ * module. Using proper argument and calling style for
+ * given node n.
* ------------------------------------------------------------ */
+ String *funcCall(String *name, String *parms) {
+ String *str = NewString("");
- String *funcCallHelper(String *name, int kw) {
- String *str;
-
- str = NewString("");
- if (apply) {
- Printv(str, "apply(", module, ".", name, ", args", (kw ? ", kwargs" : ""), ")", NIL);
- } else {
- Printv(str, module, ".", name, "(*args", (kw ? ", **kwargs" : ""), ")", NIL);
- }
+ Printv(str, module, ".", name, "(", parms, ")", NIL);
return str;
- }
+ }
+
/* ------------------------------------------------------------
* pythoncode() - Output python code into the shadow file
* ------------------------------------------------------------ */
- String *pythoncode(String *code, const String *indent) {
+ String *pythoncode(String *code, const_String_or_char_ptr indent) {
String *out = NewString("");
String *temp;
char *t;
@@ -1088,29 +1133,84 @@ public:
return doc;
}
+ /* -----------------------------------------------------------------------------
+ * makeParameterName()
+ * Note: the generated name should consist with that in kwnames[]
+ *
+ * Inputs:
+ * n - Node
+ * p - parameter node
+ * arg_num - parameter argument number
+ * Return:
+ * arg - a unique parameter name
+ * ----------------------------------------------------------------------------- */
+
+ String *makeParameterName(ParmList *plist, Parm *p, int arg_num) {
+ String *arg = 0;
+ String *pn = Swig_name_make(p, 0, Getattr(p, "name"), 0, 0);
+ // Use C parameter name unless it is a duplicate or an empty parameter name
+ int count = 0;
+ if ( SwigType_isvarargs(Getattr(p, "type")) ) {
+ return NewString("*args");
+ }
+ while (plist) {
+ if ((Cmp(pn, Getattr(plist, "name")) == 0))
+ count++;
+ plist = nextSibling(plist);
+ }
+ arg = (!pn || !Len(pn) || (count > 1)) ? NewStringf("arg%d", arg_num) : Copy(pn);
+ return arg;
+ }
+
+
/* ------------------------------------------------------------
* make_autodocParmList()
* Generate the documentation for the function parameters
+ * Parameters:
+ * func_annotation: Function annotation support
* ------------------------------------------------------------ */
- String *make_autodocParmList(Node *n, bool showTypes) {
+ String *make_autodocParmList(Node *n, bool showTypes, bool calling=false, bool func_annotation=false) {
+
+
String *doc = NewString("");
String *pdocs = Copy(Getattr(n, "feature:pdocs"));
ParmList *plist = CopyParmList(Getattr(n, "parms"));
Parm *p;
Parm *pnext;
- Node *lookup;
+ Node *lookup;
+
+
int lines = 0;
+ int arg_num = 0;
const int maxwidth = 50;
+ if(calling)
+ func_annotation = false;
+
if (pdocs)
Append(pdocs, "\n");
-
Swig_typemap_attach_parms("in", plist, 0);
Swig_typemap_attach_parms("doc", plist, 0);
-
+
+ if (Strcmp(ParmList_protostr(plist), "void")==0) {
+ //No parameters actually
+ return doc;
+ }
+
for (p = plist; p; p = pnext) {
+
+ String *tm = Getattr(p, "tmap:in");
+ if (tm) {
+ pnext = Getattr(p, "tmap:in:next");
+ if (checkAttribute(p, "tmap:in:numinputs", "0")) {
+ continue;
+ }
+ } else {
+ pnext = nextSibling(p);
+ }
+
String *name = 0;
String *type = 0;
String *value = 0;
@@ -1127,12 +1227,14 @@ public:
type = type ? type : Getattr(p, "type");
value = value ? value : Getattr(p, "value");
- String *tm = Getattr(p, "tmap:in");
- if (tm) {
- pnext = Getattr(p, "tmap:in:next");
- } else {
- pnext = nextSibling(p);
- }
+ name = makeParameterName(plist, p, arg_num);
+ // Reset it for convinient in further use. (mainly for makeParameterName())
+ // Since the plist is created by CopyParmList,
+ // we can hope that the set would have no side effect
+ Setattr(p, "name", name);
+
+ arg_num++;
+
if (Len(doc)) {
// add a comma to the previous one if any
@@ -1144,39 +1246,40 @@ public:
lines += 1;
}
}
+
+ type = SwigType_base(type);
+ lookup = Swig_symbol_clookup(type, 0);
+ if (lookup)
+ type = Getattr(lookup, "sym:name");
+
// Do the param type too?
- if (showTypes) {
- type = SwigType_base(type);
- lookup = Swig_symbol_clookup(type, 0);
- if (lookup)
- type = Getattr(lookup, "sym:name");
- Printf(doc, "%s ", type);
- }
-
- if (name) {
- Append(doc, name);
- if (pdoc) {
- if (!pdocs)
- pdocs = NewString("Parameters:\n");
- Printf(pdocs, " %s\n", pdoc);
- }
- } else {
- Append(doc, "?");
+ if (showTypes)
+ Printf(doc, "%s ", type);
+
+
+ Append(doc, name);
+ if (pdoc) {
+ if (!pdocs)
+ pdocs = NewString("Parameters:\n");
+ Printf(pdocs, " %s\n", pdoc);
}
- if (value) {
- if (Strcmp(value, "NULL") == 0)
- value = NewString("None");
- else if (Strcmp(value, "true") == 0 || Strcmp(value, "TRUE") == 0)
- value = NewString("True");
- else if (Strcmp(value, "false") == 0 || Strcmp(value, "FALSE") == 0)
- value = NewString("False");
+ // Write the function annoation
+ if (func_annotation)
+ Printf(doc, " : '%s'", type);
+
+ // Write default value
+ if (value && !calling) {
+ String* pv = pyvalue(value, Getattr(p, "type"));
+ if (pv)
+ value = pv;
else {
lookup = Swig_symbol_clookup(value, 0);
- if (lookup)
+ if (lookup) {
value = Getattr(lookup, "sym:name");
+ }
}
- Printf(doc, "=%s", value);
+ Printf(doc, " = %s", value);
}
}
if (pdocs)
@@ -1254,9 +1357,9 @@ public:
String *str = Getattr(n, "feature:docstring");
if (str == NULL || Len(str) == 0) {
if (CPlusPlus) {
- Printf(doc, "Proxy of C++ %s class", class_name);
+ Printf(doc, "Proxy of C++ %s class", real_classname);
} else {
- Printf(doc, "Proxy of C %s struct", class_name);
+ Printf(doc, "Proxy of C %s struct", real_classname);
}
}
}
@@ -1314,6 +1417,132 @@ public:
return doc;
}
+
+ /* ------------------------------------------------------------
+ * pyvalue()
+ * Check if string v can be a Python value literal,
+ * (eg. number or string), or translate it to a Python literal.
+ * ------------------------------------------------------------ */
+ String* pyvalue(String *v, SwigType *t)
+ {
+ if (v && Len(v)>0) {
+ char fc = (Char(v))[0];
+ if (('0'<=fc && fc<='9') || '\''==fc || '"'==fc) {
+ /* number or string (or maybe NULL pointer)*/
+ if (SwigType_ispointer(t) && Strcmp(v, "0")==0)
+ return NewString("None");
+ else
+ return v;
+ }
+ if (Strcmp(v, "true")==0 || Strcmp(v, "FALSE")==0)
+ return NewString("True");
+ if (Strcmp(v, "false")==0 || Strcmp(v, "FALSE")==0)
+ return NewString("False");
+ if (Strcmp(v, "NULL")==0)
+ return NewString("None");
+ }
+ return 0;
+ }
+ /* ------------------------------------------------------------
+ * is_primitive_defaultargs()
+ * Check if all the default args have primitive type.
+ * (So we can generate proper parameter list with default
+ * values..)
+ * ------------------------------------------------------------ */
+ bool is_primitive_defaultargs(Node *n)
+ {
+ ParmList *plist = CopyParmList(Getattr(n, "parms"));
+ Parm *p;
+ Parm *pnext;
+
+ Swig_typemap_attach_parms("in", plist, 0);
+ for (p = plist; p; p = pnext) {
+ String *tm = Getattr(p, "tmap:in");
+ if (tm) {
+ pnext = Getattr(p, "tmap:in:next");
+ if (checkAttribute(p, "tmap:in:numinputs", "0")) {
+ continue;
+ }
+ } else {
+ pnext = nextSibling(p);
+ }
+ String *type = Getattr(p, "type");
+ String *value = Getattr(p, "value");
+ if (!pyvalue(value, type))
+ return false;
+ }
+ return true;
+ }
+
+
+ /* ------------------------------------------------------------
+ * is_real_overloaded()
+ * Check if the function is overloaded, but not just have some
+ * siblings generated due to the original function have
+ * default arguments.
+ * ------------------------------------------------------------ */
+ bool is_real_overloaded(Node *n)
+ {
+ Node *h = Getattr(n, "sym:overloaded");
+ Node *i;
+ if (!h)
+ return false;
+
+ i = Getattr(h, "sym:nextSibling");
+ while (i) {
+ Node *nn = Getattr(i, "defaultargs");
+ if (nn != h) {
+ /* Check if overloaded function has defaultargs and
+ * pointed to the first overloaded. */
+ return true;
+ }
+ i = Getattr(i, "sym:nextSibling");
+ }
+
+ return false;
+ }
+
+ /* ------------------------------------------------------------
+ * make_pyParmList()
+ * Generate parameter list for Python functions or methods,
+ * reuse make_autodocParmList() to do so.
+ * ------------------------------------------------------------ */
+ String* make_pyParmList(Node *n, bool in_class, bool is_calling, int kw)
+ {
+ /* Get the original function for a defaultargs copy,
+ * see default_arguments() in parser.y. */
+ Node *nn = Getattr(n, "defaultargs");
+ if (nn) n = nn;
+
+ /* For overloaded function, just use *args */
+ if (is_real_overloaded(n) ||
+ GetFlag(n, "feature:compactdefaultargs") ||
+ !is_primitive_defaultargs(n))
+ {
+ String *parms = NewString("");
+ if(in_class)
+ Printf(parms, "self, ");
+ Printf(parms, "*args");
+ if (kw)
+ Printf(parms, ", **kwargs");
+ return parms;
+ }
+
+ bool funcanno = py3 ? true : false;
+ String *params = NewString("");
+ String *_params = make_autodocParmList(n, false, is_calling, funcanno);
+
+ if (in_class)
+ {
+ Printf(params, "self");
+ if(Len(_params) > 0)
+ Printf(params, ", ");
+ }
+
+ Printv(params, _params, NULL);
+
+ return params;
+ }
/* ------------------------------------------------------------
* have_pythonprepend()
@@ -1379,6 +1608,40 @@ public:
return have_pythonappend(n) || have_pythonprepend(n) || have_docstring(n);
}
+
+ /* ------------------------------------------------------------
+ * returnTypeAnnotation()
+ * Helper function for constructing the function annotation
+ * of the returning type, return a empty string for Python 2.x
+ * ------------------------------------------------------------ */
+ String* returnTypeAnnotation(Node *n)
+ {
+ String *ret=0;
+ Parm *p = Getattr(n, "parms");
+ String *tm;
+ /* Try to guess the returning type by argout typemap,
+ * however the result may not accurate. */
+ while (p) {
+ if ((tm=Getattr(p, "tmap:argout:match_type"))) {
+ tm = SwigType_str(tm, 0);
+ if (ret)
+ Printv(ret, ", ", tm, NULL);
+ else
+ ret = tm;
+ p = Getattr(p, "tmap:argout:next");
+ } else {
+ p = nextSibling(p);
+ }
+ }
+ /* If no argout typemap, then get the returning type from
+ * the function prototype. */
+ if (!ret) {
+ ret = Getattr(n, "type");
+ if (ret) ret = SwigType_str(ret, 0);
+ }
+ return (ret && py3) ? NewStringf(" -> \"%s\" ", ret)
+ : NewString("");
+ }
/* ------------------------------------------------------------
* emitFunctionShadowHelper()
@@ -1388,24 +1651,26 @@ public:
* ------------------------------------------------------------ */
void emitFunctionShadowHelper(Node *n, File *f_dest, String *name, int kw) {
- if (Getattr(n, "feature:python:callback") || !have_addtofunc(n)) {
- /* If there is no addtofunc directive then just assign from the extension module */
- Printv(f_dest, name, " = ", module, ".", name, "\n", NIL);
+ String *parms = make_pyParmList(n, false, false, kw);
+ String *callParms = make_pyParmList(n, false, true, kw);
+ /* Make a wrapper function to insert the code into */
+ Printv(f_dest, "\ndef ", name, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
+ if (have_docstring(n))
+ Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab4), "\n", NIL);
+ if (have_pythonprepend(n))
+ Printv(f_dest, pythoncode(pythonprepend(n), " "), "\n", NIL);
+ if (have_pythonappend(n)) {
+ Printv(f_dest, " val = ", funcCall(name, callParms), "\n", NIL);
+ Printv(f_dest, pythoncode(pythonappend(n), " "), "\n", NIL);
+ Printv(f_dest, " return val\n", NIL);
} else {
- /* Otherwise make a wrapper function to insert the code into */
- Printv(f_dest, "\ndef ", name, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL);
- if (have_docstring(n))
- Printv(f_dest, ctab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL);
- if (have_pythonprepend(n))
- Printv(f_dest, ctab4, pythonprepend(n), "\n", NIL);
- if (have_pythonappend(n)) {
- Printv(f_dest, ctab4, "val = ", funcCallHelper(name, kw), "\n", NIL);
- Printv(f_dest, ctab4, pythonappend(n), "\n", NIL);
- Printv(f_dest, ctab4, "return val\n", NIL);
- } else {
- Printv(f_dest, ctab4, "return ", funcCallHelper(name, kw), "\n", NIL);
- }
+ Printv(f_dest, " return ", funcCall(name, callParms), "\n", NIL);
}
+
+ if (Getattr(n, "feature:python:callback") || !have_addtofunc(n)) {
+ /* If there is no addtofunc directive then just assign from the extension module (for speed up) */
+ Printv(f_dest, name, " = ", module, ".", name, "\n", NIL);
+ }
}
@@ -1474,7 +1739,6 @@ public:
/* Last node in overloaded chain */
int maxargs;
- int allow_thread = threads_enable(n);
String *tmp = NewString("");
String *dispatch;
@@ -1497,8 +1761,6 @@ public:
Wrapper_add_local(f, "argc", "int argc");
Printf(tmp, "PyObject *argv[%d]", maxargs + 1);
Wrapper_add_local(f, "argv", tmp);
- if (allow_thread)
- thread_begin_block(n, f->code);
if (!fastunpack) {
Wrapper_add_local(f, "ii", "int ii");
@@ -1515,19 +1777,8 @@ public:
Replaceall(dispatch, "$args", "self,args");
- if (allow_thread) {
- String *ret = NewStringEmpty();
- thread_end_block(n, ret);
- Append(ret, "return ");
- Replaceall(dispatch, "return ", ret);
- Delete(ret);
- }
-
Printv(f->code, dispatch, "\n", NIL);
- if (allow_thread)
- thread_end_block(n, f->code);
-
if (GetFlag(n, "feature:python:maybecall")) {
Append(f->code, "fail:\n");
Append(f->code, "Py_INCREF(Py_NotImplemented);\n");
@@ -1634,8 +1885,6 @@ public:
kwargs = NewString("");
int allow_thread = threads_enable(n);
- if (allow_thread)
- thread_begin_block(n, f->code);
Wrapper_add_local(f, "resultobj", "PyObject *resultobj = 0");
@@ -1806,7 +2055,7 @@ public:
/* finish argument marshalling */
Append(kwargs, " NULL }");
if (allow_kwargs) {
- Printv(f->locals, ctab4, "char * kwnames[] = ", kwargs, ";\n", NIL);
+ Printv(f->locals, " char * kwnames[] = ", kwargs, ";\n", NIL);
}
if (use_parse || allow_kwargs || !modernargs) {
@@ -2066,8 +2315,6 @@ public:
}
}
- if (allow_thread)
- thread_end_block(n, f->code);
Append(f->code, " return resultobj;\n");
/* Error handling code */
@@ -2076,9 +2323,7 @@ public:
if (need_cleanup) {
Printv(f->code, cleanup, NIL);
}
- if (allow_thread)
- thread_end_block(n, f->code);
- Printv(f->code, ctab4, "return NULL;\n", NIL);
+ Printv(f->code, " return NULL;\n", NIL);
if (funpack) {
@@ -2210,9 +2455,9 @@ public:
} else {
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0));
}
- Printv(setf->code, ctab4, "return 0;\n", NULL);
+ Printv(setf->code, " return 0;\n", NULL);
Append(setf->code, "fail:\n");
- Printv(setf->code, ctab4, "return 1;\n", NULL);
+ Printv(setf->code, " return 1;\n", NULL);
} else {
/* Is a readonly variable. Issue an error */
if (CPlusPlus) {
@@ -2220,7 +2465,7 @@ public:
} else {
Printf(setf->def, "SWIGINTERN int %s(PyObject *_val SWIGUNUSED) {", varsetname);
}
- Printv(setf->code, ctab4, "SWIG_Error(SWIG_AttributeError,\"Variable ", iname, " is read-only.\");\n", ctab4, "return 1;\n", NIL);
+ Printv(setf->code, " SWIG_Error(SWIG_AttributeError,\"Variable ", iname, " is read-only.\");\n", " return 1;\n", NIL);
}
Append(setf->code, "}\n");
@@ -2488,7 +2733,7 @@ public:
Printf(f_directors_h, " PyObject *swig_get_method(size_t method_index, const char *method_name) const {\n");
Printf(f_directors_h, " PyObject *method = vtable[method_index];\n");
Printf(f_directors_h, " if (!method) {\n");
- Printf(f_directors_h, " swig::PyObject_var name = PyString_FromString(method_name);\n");
+ Printf(f_directors_h, " swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);\n");
Printf(f_directors_h, " method = PyObject_GetAttr(swig_get_self(), name);\n");
Printf(f_directors_h, " if (method == NULL) {\n");
Printf(f_directors_h, " std::string msg = \"Method in class %s doesn't exist, undefined \";\n", classname);
@@ -2500,7 +2745,7 @@ public:
Printf(f_directors_h, " return method;\n");
Printf(f_directors_h, " }\n");
Printf(f_directors_h, "private:\n");
- Printf(f_directors_h, " mutable swig::PyObject_var vtable[%d];\n", director_method_index);
+ Printf(f_directors_h, " mutable swig::SwigVar_PyObject vtable[%d];\n", director_method_index);
Printf(f_directors_h, "#endif\n\n");
}
@@ -2612,7 +2857,12 @@ public:
b = First(baselist);
while (b.item) {
String *bname = Getattr(b.item, "python:proxy");
- if (!bname || GetFlag(b.item, "feature:ignore")) {
+ bool ignore = GetFlag(b.item, "feature:ignore") ? true : false;
+ if (!bname || ignore) {
+ if (!bname && !ignore) {
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, input_file, line_number,
+ "Base class '%s' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %%import directive.\n", SwigType_namestr(Getattr(b.item, "name")));
+ }
b = Next(b);
continue;
}
@@ -2623,6 +2873,16 @@ public:
}
}
}
+
+ /* dealing with abstract base class */
+ String *abcs = Getattr(n, "feature:python:abc");
+ if (py3 && abcs) {
+ if (Len(base_class)) {
+ Putc(',', base_class);
+ }
+ Printv(base_class, abcs, NIL);
+ }
+
Printv(f_shadow, "class ", class_name, NIL);
if (Len(base_class)) {
@@ -2631,6 +2891,9 @@ public:
if (!classic) {
Printf(f_shadow, modern ? "(object)" : "(_object)");
}
+ if (GetFlag(n, "feature:exceptionclass") ) {
+ Printf(f_shadow, "(Exception)");
+ }
}
Printf(f_shadow, ":\n");
if (have_docstring(n)) {
@@ -2699,20 +2962,20 @@ public:
SwigType_add_pointer(realct);
SwigType_remember(realct);
Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL);
- Printv(f_wrappers, ctab4, "PyObject *obj;\n", NIL);
+ Printv(f_wrappers, " PyObject *obj;\n", NIL);
if (modernargs) {
if (fastunpack) {
- Printv(f_wrappers, ctab4, "if (!SWIG_Python_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL);
+ Printv(f_wrappers, " if (!SWIG_Python_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL);
} else {
- Printv(f_wrappers, ctab4, "if (!PyArg_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL);
+ Printv(f_wrappers, " if (!PyArg_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL);
}
} else {
- Printv(f_wrappers, ctab4, "if (!PyArg_ParseTuple(args,(char*)\"O:swigregister\", &obj)) return NULL;\n", NIL);
+ Printv(f_wrappers, " if (!PyArg_ParseTuple(args,(char*)\"O:swigregister\", &obj)) return NULL;\n", NIL);
}
Printv(f_wrappers,
- ctab4, "SWIG_TypeNewClientData(SWIGTYPE", SwigType_manglestr(ct), ", SWIG_NewClientData(obj));\n",
- ctab4, "return SWIG_Py_Void();\n", "}\n\n", NIL);
+ " SWIG_TypeNewClientData(SWIGTYPE", SwigType_manglestr(ct), ", SWIG_NewClientData(obj));\n",
+ " return SWIG_Py_Void();\n", "}\n\n", NIL);
String *cname = NewStringf("%s_swigregister", class_name);
add_method(cname, cname, 0);
Delete(smart);
@@ -2721,11 +2984,11 @@ public:
Delete(realct);
}
if (!have_constructor) {
- Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError, \"No constructor defined\"\n", NIL);
+ Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"No constructor defined\")\n", NIL);
} else if (fastinit) {
Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL);
- Printv(f_wrappers, ctab4, "return SWIG_Python_InitShadowInstance(args);\n", "}\n\n", NIL);
+ Printv(f_wrappers, " return SWIG_Python_InitShadowInstance(args);\n", "}\n\n", NIL);
String *cname = NewStringf("%s_swiginit", class_name);
add_method(cname, cname, 0);
Delete(cname);
@@ -2834,27 +3097,29 @@ public:
Delete(pycode);
fproxy = 0;
} else {
+ String *parms = make_pyParmList(n, true, false, allow_kwargs);
+ String *callParms = make_pyParmList(n, true, true, allow_kwargs);
if (!have_addtofunc(n)) {
if (!fastproxy || olddefs) {
- Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL);
- Printv(f_shadow, " return ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n", NIL);
+ Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL);
+ Printv(f_shadow, " return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL);
}
} else {
- Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL);
+ Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL);
Printv(f_shadow, "\n", NIL);
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL);
if (have_pythonprepend(n)) {
fproxy = 0;
- Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
}
if (have_pythonappend(n)) {
fproxy = 0;
- Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n", NIL);
- Printv(f_shadow, tab8, pythonappend(n), "\n", NIL);
+ Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL);
Printv(f_shadow, tab8, "return val\n\n", NIL);
} else {
- Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n\n", NIL);
+ Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL);
}
}
}
@@ -2887,17 +3152,19 @@ public:
if (shadow) {
if (!classic && !Getattr(n, "feature:python:callback") && have_addtofunc(n)) {
int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0;
- Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL);
+ String *parms = make_pyParmList(n, false, false, kw);
+ String *callParms = make_pyParmList(n, false, true, kw);
+ Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL);
if (have_pythonprepend(n))
- Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
if (have_pythonappend(n)) {
- Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n", NIL);
- Printv(f_shadow, tab8, pythonappend(n), "\n", NIL);
+ Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL);
Printv(f_shadow, tab8, "return val\n\n", NIL);
} else {
- Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n\n", NIL);
+ Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL);
}
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", symname, ")\n", NIL);
@@ -2969,8 +3236,8 @@ public:
handled_as_init = (Strcmp(nname, sname) == 0) || (Strcmp(nname, cname) == 0);
Delete(cname);
}
-
- if (!have_constructor && handled_as_init) {
+
+ if (!have_constructor && handled_as_init) {
if (Getattr(n, "feature:shadow")) {
String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4);
String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(symname));
@@ -2984,27 +3251,34 @@ public:
String *classname = Swig_class_name(parent);
String *rclassname = Swig_class_name(getCurrentClass());
assert(rclassname);
- if (use_director) {
+
+ String *parms = make_pyParmList(n, true, false, allow_kwargs);
+ /* Pass 'self' only if using director */
+ String *callParms = make_pyParmList(n, false, true, allow_kwargs);
+
+ if (use_director) {
+ Insert(callParms, 0, "_self, ");
Printv(pass_self, tab8, NIL);
Printf(pass_self, "if self.__class__ == %s:\n", classname);
- Printv(pass_self, tab8, tab4, "args = (None,) + args\n", tab8, "else:\n", tab8, tab4, "args = (self,) + args\n", NIL);
+ //Printv(pass_self, tab8, tab4, "args = (None,) + args\n", tab8, "else:\n", tab8, tab4, "args = (self,) + args\n", NIL);
+ Printv(pass_self, tab8, tab4, "_self = None\n", tab8, "else:\n", tab8, tab4, "_self = self\n", NIL);
}
- Printv(f_shadow, tab4, "def __init__(self, *args", (allow_kwargs ? ", **kwargs" : ""), "): \n", NIL);
+ Printv(f_shadow, tab4, "def __init__(", parms, ")", returnTypeAnnotation(n), ": \n", NIL);
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL);
if (have_pythonprepend(n))
- Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
Printv(f_shadow, pass_self, NIL);
if (fastinit) {
- Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL);
+ Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(symname), callParms), ")\n", NIL);
} else {
Printv(f_shadow,
- tab8, "this = ", funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n",
+ tab8, "this = ", funcCall(Swig_name_construct(symname), callParms), "\n",
tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", NIL);
}
if (have_pythonappend(n))
- Printv(f_shadow, tab8, pythonappend(n), "\n\n", NIL);
+ Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n\n", NIL);
Delete(pass_self);
}
have_constructor = 1;
@@ -3020,18 +3294,20 @@ public:
Printv(f_shadow_stubs, pycode, "\n", NIL);
Delete(pycode);
} else {
+ String *parms = make_pyParmList(n, true, false, allow_kwargs);
+ String *callParms = make_pyParmList(n, true, true, allow_kwargs);
- Printv(f_shadow_stubs, "\ndef ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL);
+ Printv(f_shadow_stubs, "\ndef ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
if (have_docstring(n))
Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL);
if (have_pythonprepend(n))
- Printv(f_shadow_stubs, tab4, pythonprepend(n), "\n", NIL);
- Printv(f_shadow_stubs, tab4, "val = ", funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL);
+ Printv(f_shadow_stubs, pythoncode(pythonprepend(n), tab4), "\n", NIL);
+ Printv(f_shadow_stubs, tab4, "val = ", funcCall(Swig_name_construct(symname), callParms), "\n", NIL);
#ifdef USE_THISOWN
Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL);
#endif
if (have_pythonappend(n))
- Printv(f_shadow_stubs, tab4, pythonappend(n), "\n", NIL);
+ Printv(f_shadow_stubs, pythoncode(pythonappend(n), tab4), "\n", NIL);
Printv(f_shadow_stubs, tab4, "return val\n", NIL);
}
}
@@ -3073,7 +3349,7 @@ public:
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL);
if (have_pythonprepend(n))
- Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
#ifdef USE_THISOWN
Printv(f_shadow, tab8, "try:\n", NIL);
Printv(f_shadow, tab8, tab4, "if self.thisown: ", module, ".", Swig_name_destroy(symname), "(self)\n", NIL);
@@ -3081,7 +3357,7 @@ public:
#else
#endif
if (have_pythonappend(n))
- Printv(f_shadow, tab8, pythonappend(n), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL);
Printv(f_shadow, tab8, "pass\n", NIL);
Printv(f_shadow, "\n", NIL);
}
@@ -3469,8 +3745,8 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
Replaceall(tm, "$input", input);
Delete(input);
Replaceall(tm, "$owner", "0");
- /* Wrapper_add_localv(w, source, "swig::PyObject_var", source, "= 0", NIL); */
- Printv(wrap_args, "swig::PyObject_var ", source, ";\n", NIL);
+ /* Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL); */
+ Printv(wrap_args, "swig::SwigVar_PyObject ", source, ";\n", NIL);
Printv(wrap_args, tm, "\n", NIL);
Printv(arglist, "(PyObject *)", source, NIL);
@@ -3526,7 +3802,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
if (target) {
String *director = NewStringf("director_%s", mangle);
Wrapper_add_localv(w, director, "Swig::Director *", director, "= 0", NIL);
- Wrapper_add_localv(w, source, "swig::PyObject_var", source, "= 0", NIL);
+ Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL);
Printf(wrap_args, "%s = SWIG_DIRECTOR_CAST(%s);\n", director, nonconst);
Printf(wrap_args, "if (!%s) {\n", director);
Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle);
@@ -3537,7 +3813,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
Delete(director);
Printv(arglist, source, NIL);
} else {
- Wrapper_add_localv(w, source, "swig::PyObject_var", source, "= 0", NIL);
+ Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL);
Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle);
//Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE_p_%s, 0);\n",
// source, nonconst, base);
@@ -3562,10 +3838,8 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
int allow_thread = threads_enable(n);
- if (allow_thread)
- thread_begin_block(n, w->code);
-
if (allow_thread) {
+ thread_begin_block(n, w->code);
Append(w->code, "{\n");
}
@@ -3588,33 +3862,33 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
Append(w->code, "PyObject* method = swig_get_method(swig_method_index, swig_method_name);\n");
if (Len(parse_args) > 0) {
if (use_parse || !modernargs) {
- Printf(w->code, "swig::PyObject_var result = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", parse_args, arglist);
+ Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", parse_args, arglist);
} else {
- Printf(w->code, "swig::PyObject_var result = PyObject_CallFunctionObjArgs(method %s, NULL);\n", arglist);
+ Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunctionObjArgs(method %s, NULL);\n", arglist);
}
} else {
if (modernargs) {
- Append(w->code, "swig::PyObject_var args = PyTuple_New(0);\n");
- Append(w->code, "swig::PyObject_var result = PyObject_Call(method, (PyObject*) args, NULL);\n");
+ Append(w->code, "swig::SwigVar_PyObject args = PyTuple_New(0);\n");
+ Append(w->code, "swig::SwigVar_PyObject result = PyObject_Call(method, (PyObject*) args, NULL);\n");
} else {
- Printf(w->code, "swig::PyObject_var result = PyObject_CallFunction(method, NULL, NULL);\n");
+ Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunction(method, NULL, NULL);\n");
}
}
Append(w->code, "#else\n");
if (Len(parse_args) > 0) {
if (use_parse || !modernargs) {
- Printf(w->code, "swig::PyObject_var result = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n",
+ Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n",
pyname, parse_args, arglist);
- } else {
- Printf(w->code, "swig::PyObject_var swig_method_name = PyString_FromString((char *)\"%s\");\n", pyname);
- Printf(w->code, "swig::PyObject_var result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", arglist);
+ } else {
+ Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname);
+ Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", arglist);
}
} else {
if (!modernargs) {
- Printf(w->code, "swig::PyObject_var result = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", pyname);
+ Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", pyname);
} else {
- Printf(w->code, "swig::PyObject_var swig_method_name = PyString_FromString((char *)\"%s\");\n", pyname);
- Append(w->code, "swig::PyObject_var result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n");
+ Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname);
+ Append(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n");
}
}
Append(w->code, "#endif\n");
@@ -3675,11 +3949,6 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, "result", w);
Setattr(n, "type", type);
- if (tm == 0) {
- String *name = NewString("result");
- tm = Swig_typemap_search("directorout", return_type, name, NULL);
- Delete(name);
- }
if (tm != 0) {
if (outputs > 1) {
Printf(w->code, "output = PyTuple_GetItem(result, %d);\n", idx++);
diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx
index 49d3ecc89..8e9aa557d 100644
--- a/Source/Modules/r.cxx
+++ b/Source/Modules/r.cxx
@@ -424,6 +424,7 @@ protected:
String *sfile;
String *f_init;
String *s_classes;
+ String *f_begin;
String *f_runtime;
String *f_wrapper;
String *s_header;
@@ -487,6 +488,7 @@ R::R() :
sfile(0),
f_init(0),
s_classes(0),
+ f_begin(0),
f_runtime(0),
f_wrapper(0),
s_header(0),
@@ -767,6 +769,7 @@ void R::init() {
sfile = NewString("");
f_init = NewString("");
s_header = NewString("");
+ f_begin = NewString("");
f_runtime = NewString("");
f_wrapper = NewString("");
s_classes = NewString("");
@@ -811,16 +814,22 @@ int R::top(Node *n) {
Swig_register_filebyname("sinit", s_init);
Swig_register_filebyname("sinitroutine", s_init_routine);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("header", s_header);
Swig_register_filebyname("wrapper", f_wrapper);
Swig_register_filebyname("s", sfile);
-
Swig_register_filebyname("sclasses", s_classes);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGR\n");
+ Printf(f_runtime, "\n");
- Printf(s_init, "# This is an automatically generated file by the R module for SWIG.\n\n");
+
+ Swig_banner_target_lang(s_init, "#");
outputCommandLineArguments(s_init);
Printf(f_wrapper, "#ifdef __cplusplus\n");
@@ -858,7 +867,9 @@ int R::top(Node *n) {
Delete(f_init);
Delete(s_header);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -878,7 +889,7 @@ int R::DumpCode(Node *n) {
Printf(stderr, "Writing S code to %s\n", output_filename);
#endif
- File *scode = NewFile(output_filename, "w");
+ File *scode = NewFile(output_filename, "w", SWIG_output_files());
if (!scode) {
FileErrorDisplay(output_filename);
SWIG_exit(EXIT_FAILURE);
@@ -893,25 +904,16 @@ int R::DumpCode(Node *n) {
Close(scode);
// Delete(scode);
String *outfile = Getattr(n,"outfile");
- File *runtime = NewFile(outfile,"w");
+ File *runtime = NewFile(outfile,"w", SWIG_output_files());
if (!runtime) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
- Swig_banner(runtime);
-
-
- Printf(runtime, "/* Runtime */\n");
+ Printf(runtime, "%s", f_begin);
Printf(runtime, "%s\n", f_runtime);
-
- Printf(runtime, "/* Header */\n");
Printf(runtime, "%s\n", s_header);
-
- Printf(runtime, "/* Wrapper */\n");
Printf(runtime, "%s\n", f_wrapper);
-
- Printf(runtime, "/* Init code */\n");
Printf(runtime, "%s\n", f_init);
Close(runtime);
@@ -920,7 +922,7 @@ int R::DumpCode(Node *n) {
if(outputNamespaceInfo) {
output_filename = NewString("");
Printf(output_filename, "%sNAMESPACE", SWIG_output_directory());
- File *ns = NewFile(output_filename, "w");
+ File *ns = NewFile(output_filename, "w", SWIG_output_files());
if (!ns) {
FileErrorDisplay(output_filename);
SWIG_exit(EXIT_FAILURE);
@@ -2574,9 +2576,9 @@ String * R::runtimeCode() {
void R::main(int argc, char *argv[]) {
bool cppcast = true;
init();
+ Preprocessor_define("SWIGR 1", 0);
SWIG_library_directory("r");
SWIG_config_file("r.swg");
- Preprocessor_define("SWIGR 1", 0);
debugMode = false;
copyStruct = true;
memoryProfile = false;
@@ -2659,7 +2661,7 @@ int R::outputCommandLineArguments(File *out)
if(Argc < 1 || !Argv || !Argv[0])
return(-1);
- Printf(out, "## Generated via the command line invocation:\n##\t");
+ Printf(out, "\n## Generated via the command line invocation:\n##\t");
for(int i = 0; i < Argc ; i++) {
Printf(out, " %s", Argv[i]);
}
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index ad448d34e..8d5ab4fae 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -30,7 +30,7 @@ public:
/**
* The C variable name used in the SWIG-generated wrapper code to refer to
- * this class; usually it is of the form "cClassName.klass", where cClassName
+ * this class; usually it is of the form "SwigClassXXX.klass", where SwigClassXXX
* is a swig_class struct instance and klass is a member of that struct.
*/
String *vname;
@@ -39,7 +39,7 @@ public:
* The C variable name used in the SWIG-generated wrapper code to refer to
* the module that implements this class's methods (when we're trying to
* support C++ multiple inheritance). Usually it is of the form
- * "cClassName.mImpl", where cClassName is a swig_class struct instance
+ * "SwigClassClassName.mImpl", where SwigClassXXX is a swig_class struct instance
* and mImpl is a member of that struct.
*/
String *mImpl;
@@ -78,7 +78,7 @@ public:
Delete(temp);
}
- void set_name(const String_or_char *cn, const String_or_char *rn, const String_or_char *valn) {
+ void set_name(const_String_or_char_ptr cn, const_String_or_char_ptr rn, const_String_or_char_ptr valn) {
/* Original C/C++ class (or struct) name */
Clear(cname);
Append(cname, cn);
@@ -93,18 +93,18 @@ public:
/* Variable name for the VALUE that refers to the Ruby Class object */
Clear(vname);
- Printf(vname, "c%s.klass", name);
+ Printf(vname, "SwigClass%s.klass", name);
/* Variable name for the VALUE that refers to the Ruby Class object */
Clear(mImpl);
- Printf(mImpl, "c%s.mImpl", name);
+ Printf(mImpl, "SwigClass%s.mImpl", name);
/* Prefix */
Clear(prefix);
Printv(prefix, (rn ? rn : cn), "_", NIL);
}
- char *strip(const String_or_char *s) {
+ char *strip(const_String_or_char_ptr s) {
Clear(temp);
Append(temp, s);
if (Strncmp(s, prefix, Len(prefix)) == 0) {
@@ -158,6 +158,7 @@ private:
File *f_directors;
File *f_directors_h;
File *f_directors_helpers;
+ File *f_begin;
File *f_runtime;
File *f_runtime_h;
File *f_header;
@@ -762,6 +763,7 @@ public:
classes = 0;
klass = 0;
special_methods = 0;
+ f_begin = 0;
f_runtime = 0;
f_header = 0;
f_wrappers = 0;
@@ -992,35 +994,37 @@ public:
SWIG_exit(EXIT_FAILURE);
}
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
+ f_init = NewString("");
+ f_header = NewString("");
+ f_wrappers = NewString("");
+ f_directors_h = NewString("");
+ f_directors = NewString("");
+ f_directors_helpers = NewString("");
+ f_initbeforefunc = NewString("");
+
if (directorsEnabled()) {
if (!outfile_h) {
Printf(stderr, "Unable to determine outfile_h\n");
SWIG_exit(EXIT_FAILURE);
}
- f_runtime_h = NewFile(outfile_h, "w");
+ f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
if (!f_runtime_h) {
FileErrorDisplay(outfile_h);
SWIG_exit(EXIT_FAILURE);
}
}
- f_init = NewString("");
- f_header = NewString("");
- f_wrappers = NewString("");
- f_directors_h = NewString("");
- f_directors = NewString("");
- f_directors_helpers = NewString("");
- f_initbeforefunc = NewString("");
-
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("director", f_directors);
@@ -1035,14 +1039,17 @@ public:
registerMagicMethods();
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+ Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGRUBY\n");
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
}
+ Printf(f_runtime, "\n");
+
/* typedef void *VALUE */
SwigType *value = NewSwigType(T_VOID);
SwigType_add_pointer(value);
@@ -1058,6 +1065,7 @@ public:
Replaceall(module_macro, "::", "__");
Swig_banner(f_directors_h);
+ Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_macro);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_macro);
Printf(f_directors_h, "namespace Swig {\n");
@@ -1110,27 +1118,29 @@ public:
SwigType_emit_type_table(f_runtime, f_wrappers);
/* Close all of the files */
- Dump(f_header, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
if (directorsEnabled()) {
- Dump(f_directors_helpers, f_runtime);
- Dump(f_directors, f_runtime);
+ Dump(f_directors_helpers, f_begin);
+ Dump(f_directors, f_begin);
Dump(f_directors_h, f_runtime_h);
Printf(f_runtime_h, "\n");
Printf(f_runtime_h, "#endif\n");
Close(f_runtime_h);
}
- Dump(f_wrappers, f_runtime);
- Dump(f_initbeforefunc, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_wrappers, f_begin);
+ Dump(f_initbeforefunc, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Delete(f_initbeforefunc);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -1226,7 +1236,7 @@ public:
/**
* Process the comma-separated list of aliases (if any).
*/
- void defineAliases(Node *n, const String_or_char *iname) {
+ void defineAliases(Node *n, const_String_or_char_ptr iname) {
String *aliasv = Getattr(n, "feature:alias");
if (aliasv) {
List *aliases = Split(aliasv, ',', INT_MAX);
@@ -1260,7 +1270,7 @@ public:
* as another instance of the same class.
* --------------------------------------------------------------------- */
- void create_command(Node *n, const String_or_char *iname) {
+ void create_command(Node *n, const_String_or_char_ptr iname) {
String *alloc_func = Swig_name_wrapper(iname);
String *wname = Swig_name_wrapper(iname);
@@ -2392,9 +2402,9 @@ public:
void handleMarkFuncDirective(Node *n) {
String *markfunc = Getattr(n, "feature:markfunc");
if (markfunc) {
- Printf(klass->init, "c%s.mark = (void (*)(void *)) %s;\n", klass->name, markfunc);
+ Printf(klass->init, "SwigClass%s.mark = (void (*)(void *)) %s;\n", klass->name, markfunc);
} else {
- Printf(klass->init, "c%s.mark = 0;\n", klass->name);
+ Printf(klass->init, "SwigClass%s.mark = 0;\n", klass->name);
}
}
@@ -2404,10 +2414,10 @@ public:
void handleFreeFuncDirective(Node *n) {
String *freefunc = Getattr(n, "feature:freefunc");
if (freefunc) {
- Printf(klass->init, "c%s.destroy = (void (*)(void *)) %s;\n", klass->name, freefunc);
+ Printf(klass->init, "SwigClass%s.destroy = (void (*)(void *)) %s;\n", klass->name, freefunc);
} else {
if (klass->destructor_defined) {
- Printf(klass->init, "c%s.destroy = (void (*)(void *)) free_%s;\n", klass->name, klass->mname);
+ Printf(klass->init, "SwigClass%s.destroy = (void (*)(void *)) free_%s;\n", klass->name, klass->mname);
}
}
}
@@ -2418,9 +2428,9 @@ public:
void handleTrackDirective(Node *n) {
int trackObjects = GetFlag(n, "feature:trackobjects");
if (trackObjects) {
- Printf(klass->init, "c%s.trackObjects = 1;\n", klass->name);
+ Printf(klass->init, "SwigClass%s.trackObjects = 1;\n", klass->name);
} else {
- Printf(klass->init, "c%s.trackObjects = 0;\n", klass->name);
+ Printf(klass->init, "SwigClass%s.trackObjects = 0;\n", klass->name);
}
}
@@ -2445,7 +2455,7 @@ public:
Clear(klass->type);
Printv(klass->type, Getattr(n, "classtype"), NIL);
- Printv(f_wrappers, "swig_class c", valid_name, ";\n\n", NIL);
+ Printv(f_wrappers, "swig_class SwigClass", valid_name, ";\n\n", NIL);
Printv(klass->init, "\n", tab4, NIL);
if (!useGlobalModule) {
@@ -2463,7 +2473,7 @@ public:
SwigType_add_pointer(tt);
SwigType_remember(tt);
String *tm = SwigType_manglestr(tt);
- Printf(klass->init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) &c%s);\n", tm, valid_name);
+ Printf(klass->init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) &SwigClass%s);\n", tm, valid_name);
Delete(tm);
Delete(tt);
Delete(valid_name);
@@ -2564,7 +2574,7 @@ public:
/* First wrap the allocate method */
current = CONSTRUCTOR_ALLOCATE;
- Swig_name_register((String_or_char *) "construct", (String_or_char *) "%c_allocate");
+ Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate");
Language::constructorHandler(n);
@@ -2599,7 +2609,7 @@ public:
Delete(docs);
current = CONSTRUCTOR_INITIALIZE;
- Swig_name_register((String_or_char *) "construct", (String_or_char *) "new_%c");
+ Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "new_%c");
Language::constructorHandler(n);
/* Restore original parameter list */
@@ -2607,7 +2617,7 @@ public:
Swig_restore(n);
/* Done */
- Swig_name_unregister((String_or_char *) "construct");
+ Swig_name_unregister((const_String_or_char_ptr ) "construct");
current = NO_CPP;
klass->constructor_defined = 1;
return SWIG_OK;
@@ -2621,7 +2631,7 @@ public:
/* First wrap the allocate method */
current = CONSTRUCTOR_ALLOCATE;
- Swig_name_register((String_or_char *) "construct", (String_or_char *) "%c_allocate");
+ Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate");
return Language::copyconstructorHandler(n);
}
@@ -3235,11 +3245,6 @@ public:
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, "result", w);
Setattr(n, "type", type);
- if (tm == 0) {
- String *name = NewString("result");
- tm = Swig_typemap_search("directorout", return_type, name, NULL);
- Delete(name);
- }
if (tm != 0) {
if (outputs > 1 && !asvoid ) {
Printf(w->code, "output = rb_ary_entry(result, %d);\n", idx++);
diff --git a/Source/Modules/s-exp.cxx b/Source/Modules/s-exp.cxx
index b89b3097f..90791ec70 100644
--- a/Source/Modules/s-exp.cxx
+++ b/Source/Modules/s-exp.cxx
@@ -29,6 +29,9 @@ public:
}
virtual void main(int argc, char *argv[]) {
+ // Add a symbol to the parser for conditional compilation
+ Preprocessor_define("SWIGSEXP 1", 0);
+
SWIG_typemap_lang("sexp");
for (int iX = 0; iX < argc; iX++) {
if (strcmp(argv[iX], "-typemaplang") == 0) {
@@ -42,9 +45,6 @@ public:
fputs(usage, stdout);
}
}
-
- // Add a symbol to the parser for conditional compilation
- Preprocessor_define("SWIGSEXP 1", 0);
}
DOHHash *print_circle_hash;
@@ -59,7 +59,7 @@ public:
String *outfile = Getattr(n, "outfile");
Replaceall(outfile, "_wrap.cxx", ".lisp");
Replaceall(outfile, "_wrap.c", ".lisp");
- out = NewFile(outfile, "w");
+ out = NewFile(outfile, "w", SWIG_output_files());
if (!out) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
@@ -68,10 +68,14 @@ public:
String *f_sink = NewString("");
Swig_register_filebyname("header", f_sink);
Swig_register_filebyname("wrapper", f_sink);
+ Swig_register_filebyname("begin", f_sink);
Swig_register_filebyname("runtime", f_sink);
Swig_register_filebyname("init", f_sink);
+ Swig_banner_target_lang(out, ";;;");
+
Language::top(n);
+ Printf(out, "\n");
Printf(out, ";;; Lisp parse tree produced by SWIG\n");
print_circle_hash = DohNewHash();
print_circle_count = 0;
diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx
index b2d9bf575..4800201ca 100644
--- a/Source/Modules/swigmain.cxx
+++ b/Source/Modules/swigmain.cxx
@@ -32,8 +32,8 @@ extern "C" {
Language *swig_modula3(void);
Language *swig_mzscheme(void);
Language *swig_java(void);
+ Language *swig_php(void);
Language *swig_php4(void);
- Language *swig_php5(void);
Language *swig_ocaml(void);
Language *swig_octave(void);
Language *swig_pike(void);
@@ -76,9 +76,9 @@ static swig_module modules[] = {
{"-octave", swig_octave, "Octave"},
{"-perl", swig_perl5, "Perl"},
{"-perl5", swig_perl5, 0},
- {"-php", swig_php5, 0},
+ {"-php", swig_php, "PHP"},
{"-php4", swig_php4, 0},
- {"-php5", swig_php5, "PHP5"},
+ {"-php5", swig_php, 0},
{"-pike", swig_pike, "Pike"},
{"-python", swig_python, "Python"},
{"-r", swig_r, "R (aka GNU S)"},
diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h
index 5835c6362..8dec8d0af 100644
--- a/Source/Modules/swigmod.h
+++ b/Source/Modules/swigmod.h
@@ -26,7 +26,7 @@ typedef int bool;
#define PLAIN_VIRTUAL 1
#define PURE_VIRTUAL 2
-extern char *input_file;
+extern String *input_file;
extern int line_number;
extern int start_line;
extern int CPlusPlus; // C++ mode
@@ -114,8 +114,8 @@ protected:
class Language:public Dispatcher {
public:
- Language ();
- virtual ~ Language ();
+ Language();
+ virtual ~Language();
virtual int emit_one(Node *n);
/* Parse command line options */
@@ -313,10 +313,13 @@ int SWIG_main(int, char **, Language *);
void emit_parameter_variables(ParmList *l, Wrapper *f);
void emit_return_variable(Node *n, SwigType *rt, Wrapper *f);
void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */
-void SWIG_config_file(const String_or_char *);
+void SWIG_config_file(const_String_or_char_ptr );
const String *SWIG_output_directory();
void SWIG_config_cppext(const char *ext);
+/* get the list of generated files */
+List *SWIG_output_files();
+
void SWIG_library_directory(const char *);
int emit_num_arguments(ParmList *);
int emit_num_required(ParmList *);
@@ -326,17 +329,17 @@ void emit_mark_varargs(ParmList *l);
String *emit_action(Node *n);
int emit_action_code(Node *n, String *wrappercode, String *action);
void Swig_overload_check(Node *n);
-String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *);
-String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *);
-String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *);
+String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *);
+String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *);
+String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *);
SwigType *cplus_value_type(SwigType *t);
/* directors.cxx start */
String *Swig_csuperclass_call(String *base, String *method, ParmList *l);
String *Swig_class_declaration(Node *n, String *name);
String *Swig_class_name(Node *n);
-String *Swig_method_call(String_or_char *name, ParmList *parms);
-String *Swig_method_decl(SwigType *rtype, SwigType *decl, const String_or_char *id, List *args, int strip, int values);
+String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms);
+String *Swig_method_decl(SwigType *rtype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values);
String *Swig_director_declaration(Node *n);
void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f);
/* directors.cxx end */
diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx
index 09bd266c3..015ac5e45 100644
--- a/Source/Modules/tcl8.cxx
+++ b/Source/Modules/tcl8.cxx
@@ -46,6 +46,7 @@ static int nosafe = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
static File *f_init = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
@@ -121,6 +122,7 @@ public:
}
Preprocessor_define("SWIGTCL 1", 0);
+ // SWIGTCL8 is deprecated, and no longer documented.
Preprocessor_define("SWIGTCL8 1", 0);
SWIG_typemap_lang("tcl8");
SWIG_config_file("tcl8.swg");
@@ -136,11 +138,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -148,6 +151,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@@ -158,7 +162,11 @@ public:
methods_tab = NewString("");
const_tab = NewString("");
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGTCL\n");
+ Printf(f_runtime, "\n");
/* Set the module name, namespace, and prefix */
@@ -177,7 +185,7 @@ public:
Insert(module, 0, "_");
- if ((f_shadow = NewFile(filen, "w")) == 0) {
+ if ((f_shadow = NewFile(filen, "w", SWIG_output_files())) == 0) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
}
@@ -186,10 +194,7 @@ public:
Swig_register_filebyname("shadow", f_shadow);
Swig_register_filebyname("itcl", f_shadow);
- Printf(f_shadow, "# This file was automatically generated by SWIG (http://www.swig.org).\n");
- Printf(f_shadow, "# Version %s\n", Swig_package_version());
- Printf(f_shadow, "#\n");
- Printf(f_shadow, "# Don't modify this file, modify the SWIG interface instead.\n");
+ Swig_banner_target_lang(f_shadow, "#");
Printv(f_shadow, "\npackage require Itcl\n\n", NIL);
Delete(filen);
@@ -244,12 +249,15 @@ public:
}
/* Close all of the files */
- Printv(f_runtime, f_header, f_wrappers, NIL);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Printv(f_begin, f_header, f_wrappers, NIL);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
+ Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
index d663aed6e..9b42bc1a3 100644
--- a/Source/Modules/typepass.cxx
+++ b/Source/Modules/typepass.cxx
@@ -730,6 +730,49 @@ class TypePass:private Dispatcher {
}
Setattr(n, "enumtype", enumtype);
+ // This block of code is for dealing with %ignore on an enum item where the target language
+ // attempts to use the C enum value in the target language itself and expects the previous enum value
+ // to be one more than the previous value... the previous enum item might not exist if it is ignored!
+ // - It sets the first non-ignored enum item with the "firstenumitem" attribute.
+ // - It adds an enumvalue attribute if the previous enum item is ignored
+ {
+ Node *c;
+ int count = 0;
+ String *previous = 0;
+ bool previous_ignored = false;
+ bool firstenumitem = false;
+ for (c = firstChild(n); c; c = nextSibling(c)) {
+ assert(strcmp(Char(nodeType(c)), "enumitem") == 0);
+
+ bool reset;
+ String *enumvalue = Getattr(c, "enumvalue");
+ if (GetFlag(c, "feature:ignore")) {
+ reset = enumvalue ? true : false;
+ previous_ignored = true;
+ } else {
+ if (!enumvalue && previous_ignored) {
+ if (previous)
+ Setattr(c, "enumvalue", NewStringf("(%s) + %d", previous, count+1));
+ else
+ Setattr(c, "enumvalue", NewStringf("%d", count));
+ SetFlag(c, "virtenumvalue"); // identify enumvalue as virtual, ie not from the parsed source
+ }
+ if (!firstenumitem) {
+ SetFlag(c, "firstenumitem");
+ firstenumitem = true;
+ }
+ reset = true;
+ previous_ignored = false;
+ }
+ if (reset) {
+ previous = enumvalue ? enumvalue : Getattr(c, "name");
+ count = 0;
+ } else {
+ count++;
+ }
+ }
+ }
+
emit_children(n);
return SWIG_OK;
}
@@ -753,13 +796,16 @@ class TypePass:private Dispatcher {
Setattr(n, "value", new_value);
Delete(new_value);
}
- // Make up an enumvalue if one was not specified in the parsed code
- if (Getattr(n, "_last") && !Getattr(n, "enumvalue")) { // Only the first enum item has _last set
- Setattr(n, "enumvalueex", "0");
- }
Node *next = nextSibling(n);
- if (next && !Getattr(next, "enumvalue")) {
- Setattr(next, "enumvalueex", NewStringf("%s + 1", Getattr(n, "sym:name")));
+
+ // Make up an enumvalue if one was not specified in the parsed code (not designed to be used on enum items and %ignore - enumvalue will be set instead)
+ if (!GetFlag(n, "feature:ignore")) {
+ if (Getattr(n, "_last") && !Getattr(n, "enumvalue")) { // Only the first enum item has _last set (Note: first non-ignored enum item has firstenumitem set)
+ Setattr(n, "enumvalueex", "0");
+ }
+ if (next && !Getattr(next, "enumvalue")) {
+ Setattr(next, "enumvalueex", NewStringf("%s + 1", Getattr(n, "sym:name")));
+ }
}
return SWIG_OK;
diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx
index 7a94b77bb..d3f8401f0 100644
--- a/Source/Modules/uffi.cxx
+++ b/Source/Modules/uffi.cxx
@@ -26,7 +26,6 @@ public:
};
static File *f_cl = 0;
-static File *f_null = 0;
static struct {
int count;
@@ -132,7 +131,7 @@ static void add_defined_foreign_type(String *type) {
}
-static String *get_ffi_type(SwigType *ty, const String_or_char *name) {
+static String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
@@ -168,7 +167,7 @@ static String *get_ffi_type(SwigType *ty, const String_or_char *name) {
return 0;
}
-static String *get_lisp_type(SwigType *ty, const String_or_char *name) {
+static String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) {
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
@@ -181,6 +180,7 @@ static String *get_lisp_type(SwigType *ty, const String_or_char *name) {
void UFFI::main(int argc, char *argv[]) {
int i;
+ Preprocessor_define("SWIGUFFI 1", 0);
SWIG_library_directory("uffi");
SWIG_config_file("uffi.swg");
@@ -225,31 +225,26 @@ void UFFI::main(int argc, char *argv[]) {
int UFFI::top(Node *n) {
String *module = Getattr(n, "name");
String *output_filename = NewString("");
- String *devnull = NewString("/dev/null");
-
- f_null = NewFile(devnull, "w+");
- if (!f_null) {
- FileErrorDisplay(devnull);
- SWIG_exit(EXIT_FAILURE);
- }
- Delete(devnull);
-
+ File *f_null = NewString("");
Printf(output_filename, "%s%s.cl", SWIG_output_directory(), module);
- f_cl = NewFile(output_filename, "w");
+ f_cl = NewFile(output_filename, "w", SWIG_output_files());
if (!f_cl) {
FileErrorDisplay(output_filename);
SWIG_exit(EXIT_FAILURE);
}
Swig_register_filebyname("header", f_null);
+ Swig_register_filebyname("begin", f_null);
Swig_register_filebyname("runtime", f_null);
Swig_register_filebyname("wrapper", f_cl);
- Printf(f_cl,
- ";; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: %s -*-\n;; This is an automatically generated file. Make changes in\n;; the definition file, not here.\n\n(defpackage :%s\n (:use :common-lisp :uffi))\n\n(in-package :%s)\n",
+ Swig_banner_target_lang(f_cl, ";;");
+
+ Printf(f_cl, "\n"
+ ";; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: %s -*-\n\n(defpackage :%s\n (:use :common-lisp :uffi))\n\n(in-package :%s)\n",
module, module, module);
Printf(f_cl, "(eval-when (compile load eval)\n (defparameter *swig-identifier-converter* '%s))\n", identifier_converter);
diff --git a/Source/Modules/xml.cxx b/Source/Modules/xml.cxx
index c74b48d7c..2edd01cf0 100644
--- a/Source/Modules/xml.cxx
+++ b/Source/Modules/xml.cxx
@@ -47,7 +47,7 @@ public:
iX++;
Swig_mark_arg(iX);
String *outfile = NewString(argv[iX]);
- out = NewFile(outfile, "w");
+ out = NewFile(outfile, "w", SWIG_output_files());
if (!out) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
@@ -82,7 +82,7 @@ public:
Replaceall(outfile, ".cxx", ".xml");
Replaceall(outfile, ".cpp", ".xml");
Replaceall(outfile, ".c", ".xml");
- out = NewFile(outfile, "w");
+ out = NewFile(outfile, "w", SWIG_output_files());
if (!out) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
@@ -301,7 +301,7 @@ void Swig_print_xml(DOH *obj, String *filename) {
if (!filename) {
out = stdout;
} else {
- out = NewFile(filename, "w");
+ out = NewFile(filename, "w", SWIG_output_files());
if (!out) {
FileErrorDisplay(filename);
SWIG_exit(EXIT_FAILURE);
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index c04f95f00..81646171a 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -74,7 +74,7 @@ static void copy_location(const DOH *s1, DOH *s2) {
Setline(s2, Getline((DOH *) s1));
}
-static String *cpp_include(String_or_char *fn, int sysfile) {
+static String *cpp_include(const_String_or_char_ptr fn, int sysfile) {
String *s = sysfile ? Swig_include_sys(fn) : Swig_include(fn);
if (s && single_include) {
String *file = Getfile(s);
@@ -85,7 +85,8 @@ static String *cpp_include(String_or_char *fn, int sysfile) {
Setattr(included_files, file, file);
}
if (!s) {
- Seek(fn, 0, SEEK_SET);
+ /* XXX(bhy) may not need the seek */
+ /* Seek(fn, 0, SEEK_SET); */
if (ignore_missing) {
Swig_warning(WARN_PP_MISSING_FILE, Getfile(fn), Getline(fn), "Unable to find '%s'\n", fn);
} else {
@@ -261,8 +262,9 @@ void Preprocessor_error_as_warning(int a) {
* ----------------------------------------------------------------------------- */
-String_or_char *Macro_vararg_name(String_or_char *str, String_or_char *line) {
- String_or_char *argname, *varargname;
+String *Macro_vararg_name(const_String_or_char_ptr str, const_String_or_char_ptr line) {
+ String *argname;
+ String *varargname;
char *s, *dots;
argname = Copy(str);
@@ -288,24 +290,24 @@ String_or_char *Macro_vararg_name(String_or_char *str, String_or_char *line) {
return varargname;
}
-Hash *Preprocessor_define(const String_or_char *_str, int swigmacro) {
+Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
String *macroname = 0, *argstr = 0, *macrovalue = 0, *file = 0, *s = 0;
Hash *macro = 0, *symbols = 0, *m1;
List *arglist = 0;
int c, line;
int varargs = 0;
- String_or_char *str = (String_or_char *) _str;
+ String *str;
assert(cpp);
- assert(str);
+ assert(_str);
/* First make sure that string is actually a string */
- if (DohCheck(str)) {
- s = Copy(str);
- copy_location(str, s);
+ if (DohCheck(_str)) {
+ s = Copy(_str);
+ copy_location(_str, s);
str = s;
} else {
- str = NewString((char *) str);
+ str = NewString((char *) _str);
}
Seek(str, 0, SEEK_SET);
line = Getline(str);
@@ -532,7 +534,7 @@ macro_error:
*
* Undefines a macro.
* ----------------------------------------------------------------------------- */
-void Preprocessor_undef(const String_or_char *str) {
+void Preprocessor_undef(const_String_or_char_ptr str) {
Hash *symbols;
assert(cpp);
symbols = Getattr(cpp, kpp_symbols);
@@ -650,14 +652,7 @@ static String *get_filename(String *str, int *sysfile) {
if (isspace(c))
Ungetc(c, str);
}
-#if defined(_WIN32) || defined(MACSWIG)
- /* accept Unix path separator on non-Unix systems */
- Replaceall(fn, "/", SWIG_FILE_DELIMITER);
-#endif
-#if defined(__CYGWIN__)
- /* accept Windows path separator in addition to Unix path separator */
- Replaceall(fn, "\\", SWIG_FILE_DELIMITER);
-#endif
+ Swig_filename_correct(fn);
Seek(fn, 0, SEEK_SET);
return fn;
}
diff --git a/Source/Preprocessor/preprocessor.h b/Source/Preprocessor/preprocessor.h
index 4f7ff8804..3579eede2 100644
--- a/Source/Preprocessor/preprocessor.h
+++ b/Source/Preprocessor/preprocessor.h
@@ -19,8 +19,8 @@ extern "C" {
#endif
extern int Preprocessor_expr(String *s, int *error);
extern char *Preprocessor_expr_error(void);
- extern Hash *Preprocessor_define(const String_or_char *str, int swigmacro);
- extern void Preprocessor_undef(const String_or_char *name);
+ extern Hash *Preprocessor_define(const_String_or_char_ptr str, int swigmacro);
+ extern void Preprocessor_undef(const_String_or_char_ptr name);
extern void Preprocessor_init(void);
extern void Preprocessor_delete(void);
extern String *Preprocessor_parse(String *s);
diff --git a/Source/README b/Source/README
index 8d910e405..814ec45bd 100644
--- a/Source/README
+++ b/Source/README
@@ -1,9 +1,5 @@
SWIG Source directory
-This directory currently contains a mix of legacy SWIG1.1 code and
-recent development work. As a result, it's still a little messy.
-Here is a rough breakdown of the directories:
-
Source/DOH - A core set of basic datatypes including
strings, lists, hashes, and files. Used
extensively by the rest of SWIG.
@@ -16,8 +12,9 @@ Here is a rough breakdown of the directories:
Source/Modules - Language modules.
+ Source/Include - Include files.
-The following directories may be in CVS, but are largely deprecated:
+Historic directories which may be in CVS, but have been removed:
Source/Modules1.1 - Old SWIG-1.1 modules. Empty.
@@ -26,5 +23,3 @@ The following directories may be in CVS, but are largely deprecated:
Source/SWIG1.1 - Old SWIG1.1 core. Completely empty now.
-
-
diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c
index 18920ecc2..7c6837a2b 100644
--- a/Source/Swig/cwrap.c
+++ b/Source/Swig/cwrap.c
@@ -45,7 +45,7 @@ String *Swig_cparm_name(Parm *p, int i) {
* and user defined types to pointers.
* ----------------------------------------------------------------------------- */
-static String *Swig_clocal(SwigType *t, const String_or_char *name, const String_or_char *value) {
+static String *Swig_clocal(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr value) {
String *decl;
decl = NewStringEmpty();
@@ -147,7 +147,7 @@ String *Swig_wrapped_member_var_type(SwigType *t, int varcref) {
}
-static String *Swig_wrapped_var_deref(SwigType *t, String_or_char *name, int varcref) {
+static String *Swig_wrapped_var_deref(SwigType *t, const_String_or_char_ptr name, int varcref) {
if (SwigType_isclass(t)) {
if (varcref) {
if (cparse_cplusplus) {
@@ -163,7 +163,7 @@ static String *Swig_wrapped_var_deref(SwigType *t, String_or_char *name, int var
}
}
-static String *Swig_wrapped_var_assign(SwigType *t, const String_or_char *name, int varcref) {
+static String *Swig_wrapped_var_assign(SwigType *t, const_String_or_char_ptr name, int varcref) {
if (SwigType_isclass(t)) {
if (varcref) {
return NewStringf("%s", name);
@@ -251,7 +251,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
* function call.
* ----------------------------------------------------------------------------- */
-String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl) {
+String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr decl) {
String *fcall;
fcall = NewStringEmpty();
@@ -260,10 +260,9 @@ String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_ch
break;
case T_REFERENCE:
{
- String *str = SwigType_str(t, "_result_ref");
- Printf(fcall, "{\n");
- Printf(fcall, "%s = ", str);
- Delete(str);
+ String *lstr = SwigType_lstr(t, 0);
+ Printf(fcall, "%s = (%s) &", name, lstr);
+ Delete(lstr);
}
break;
case T_USER:
@@ -290,12 +289,6 @@ String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_ch
Append(fcall, ";");
}
- if (SwigType_type(t) == T_REFERENCE) {
- String *lstr = SwigType_lstr(t, 0);
- Printf(fcall, "\n%s = (%s) &_result_ref;\n", name, lstr);
- Append(fcall, "}");
- Delete(lstr);
- }
return fcall;
}
@@ -309,7 +302,7 @@ String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_ch
*
* ----------------------------------------------------------------------------- */
-String *Swig_cfunction_call(String_or_char *name, ParmList *parms) {
+String *Swig_cfunction_call(const_String_or_char_ptr name, ParmList *parms) {
String *func;
int i = 0;
int comma = 0;
@@ -376,7 +369,7 @@ String *Swig_cfunction_call(String_or_char *name, ParmList *parms) {
* set to "(*this)->" or some similar sequence.
* ----------------------------------------------------------------------------- */
-static String *Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self, String *explicit_qualifier, SwigType *director_type) {
+static String *Swig_cmethod_call(const_String_or_char_ptr name, ParmList *parms, const_String_or_char_ptr self, String *explicit_qualifier, SwigType *director_type) {
String *func, *nname;
int i = 0;
Parm *p = parms;
@@ -468,7 +461,7 @@ static String *Swig_cmethod_call(String_or_char *name, ParmList *parms, String_o
* calloc(1,sizeof(name));
* ----------------------------------------------------------------------------- */
-String *Swig_cconstructor_call(String_or_char *name) {
+String *Swig_cconstructor_call(const_String_or_char_ptr name) {
DOH *func;
func = NewStringEmpty();
@@ -487,7 +480,7 @@ String *Swig_cconstructor_call(String_or_char *name) {
*
* ----------------------------------------------------------------------------- */
-String *Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int skip_self) {
+String *Swig_cppconstructor_base_call(const_String_or_char_ptr name, ParmList *parms, int skip_self) {
String *func;
String *nname;
int i = 0;
@@ -532,15 +525,15 @@ String *Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int
return func;
}
-String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms) {
+String *Swig_cppconstructor_call(const_String_or_char_ptr name, ParmList *parms) {
return Swig_cppconstructor_base_call(name, parms, 0);
}
-String *Swig_cppconstructor_nodirector_call(String_or_char *name, ParmList *parms) {
+String *Swig_cppconstructor_nodirector_call(const_String_or_char_ptr name, ParmList *parms) {
return Swig_cppconstructor_base_call(name, parms, 1);
}
-String *Swig_cppconstructor_director_call(String_or_char *name, ParmList *parms) {
+String *Swig_cppconstructor_director_call(const_String_or_char_ptr name, ParmList *parms) {
return Swig_cppconstructor_base_call(name, parms, 0);
}
@@ -683,7 +676,7 @@ String *Swig_cppdestructor_call(Node *n) {
*
* ----------------------------------------------------------------------------- */
-String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self, int varcref) {
+String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, String *self, int varcref) {
String *func;
String *pname0 = Swig_cparm_name(0, 0);
String *pname1 = Swig_cparm_name(0, 1);
@@ -718,7 +711,7 @@ String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_cha
*
* ----------------------------------------------------------------------------- */
-String *Swig_cmemberget_call(const String_or_char *name, SwigType *t, String_or_char *self, int varcref) {
+String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref) {
String *func;
String *call;
String *pname0 = Swig_cparm_name(0, 0);
@@ -1210,7 +1203,7 @@ int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags)
* This function creates a C wrapper for setting a structure member.
* ----------------------------------------------------------------------------- */
-int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
+int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **call) {
String *name;
ParmList *parms;
Parm *p;
@@ -1258,23 +1251,21 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
Delete(p);
if (flags & CWRAP_EXTEND) {
- String *call;
String *cres;
String *code = Getattr(n, "code");
if (code) {
/* I don't think this ever gets run - WSF */
Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, "self");
}
- call = Swig_cfunction_call(mangled, parms);
- cres = NewStringf("%s;", call);
+ *call = Swig_cfunction_call(mangled, parms);
+ cres = NewStringf("%s;", *call);
Setattr(n, "wrap:action", cres);
- Delete(call);
Delete(cres);
} else {
- String *call = Swig_cmemberset_call(name, type, self, varcref);
- String *cres = NewStringf("%s;", call);
+ String *cres;
+ *call = Swig_cmemberset_call(name, type, self, varcref);
+ cres = NewStringf("%s;", *call);
Setattr(n, "wrap:action", cres);
- Delete(call);
Delete(cres);
}
Setattr(n, "type", void_type);
diff --git a/Source/Swig/error.c b/Source/Swig/error.c
index 1eaba1f17..156fe06a7 100644
--- a/Source/Swig/error.c
+++ b/Source/Swig/error.c
@@ -50,7 +50,7 @@ static char wrn_nnum_fmt[64];
static char err_line_fmt[64];
static char err_eof_fmt[64];
-static String *format_filename(const String_or_char *filename);
+static String *format_filename(const_String_or_char_ptr filename);
/* -----------------------------------------------------------------------------
* Swig_warning()
@@ -58,7 +58,7 @@ static String *format_filename(const String_or_char *filename);
* Issue a warning message
* ----------------------------------------------------------------------------- */
-void Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt, ...) {
+void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const char *fmt, ...) {
String *out;
char *msg;
int wrn = 1;
@@ -121,7 +121,7 @@ void Swig_warning(int wnum, const String_or_char *filename, int line, const char
* Issue an error message
* ----------------------------------------------------------------------------- */
-void Swig_error(const String_or_char *filename, int line, const char *fmt, ...) {
+void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...) {
va_list ap;
String *formatted_filename = NULL;
@@ -170,7 +170,7 @@ void Swig_error_silent(int s) {
* Takes a comma separate list of warning numbers and puts in the filter.
* ----------------------------------------------------------------------------- */
-void Swig_warnfilter(const String_or_char *wlist, int add) {
+void Swig_warnfilter(const_String_or_char_ptr wlist, int add) {
char *c;
char *cw;
String *s;
@@ -268,7 +268,7 @@ void Swig_error_msg_format(ErrorMessageFormat format) {
*
* Remove double backslashes in Windows filename paths for display
* ----------------------------------------------------------------------------- */
-static String *format_filename(const String_or_char *filename) {
+static String *format_filename(const_String_or_char_ptr filename) {
String *formatted_filename = NewString(filename);
#if defined(_WIN32)
Replaceall(formatted_filename, "\\\\", "\\");
diff --git a/Source/Swig/getopt.c b/Source/Swig/getopt.c
index 87b0f7c9d..cbd051d9f 100644
--- a/Source/Swig/getopt.c
+++ b/Source/Swig/getopt.c
@@ -100,7 +100,7 @@ void Swig_check_options(int check_input) {
* Generates a generic error message and exits.
* ----------------------------------------------------------------------------- */
-void Swig_arg_error() {
+void Swig_arg_error(void) {
Printf(stderr, "SWIG : Unable to parse command line options.\n");
Printf(stderr, "Use 'swig -help' for available options.\n");
exit(1);
diff --git a/Source/Swig/include.c b/Source/Swig/include.c
index 3f47be15b..f42eb5d45 100644
--- a/Source/Swig/include.c
+++ b/Source/Swig/include.c
@@ -33,7 +33,7 @@ int Swig_get_push_dir(void) {
* Adds a directory to the SWIG search path.
* ----------------------------------------------------------------------------- */
-List *Swig_add_directory(const String_or_char *dirname) {
+List *Swig_add_directory(const_String_or_char_ptr dirname) {
String *adirname;
if (!directories)
directories = NewList();
@@ -53,7 +53,7 @@ List *Swig_add_directory(const String_or_char *dirname) {
* the preprocessor to grab files in the same directory as other included files.
* ----------------------------------------------------------------------------- */
-void Swig_push_directory(const String_or_char *dirname) {
+void Swig_push_directory(const_String_or_char_ptr dirname) {
String *pdirname;
if (!Swig_get_push_dir())
return;
@@ -73,7 +73,7 @@ void Swig_push_directory(const String_or_char *dirname) {
* the preprocessor.
* ----------------------------------------------------------------------------- */
-void Swig_pop_directory() {
+void Swig_pop_directory(void) {
if (!Swig_get_push_dir())
return;
if (!pdirectories)
@@ -87,13 +87,13 @@ void Swig_pop_directory() {
* Returns the full pathname of the last file opened.
* ----------------------------------------------------------------------------- */
-String *Swig_last_file() {
+String *Swig_last_file(void) {
assert(lastpath);
return lastpath;
}
/* -----------------------------------------------------------------------------
- * Swig_search_path()
+ * Swig_search_path_any()
*
* Returns a list of the current search paths.
* ----------------------------------------------------------------------------- */
@@ -151,10 +151,11 @@ List *Swig_search_path() {
/* -----------------------------------------------------------------------------
* Swig_open()
*
- * Looks for a file and open it. Returns an open FILE * on success.
+ * open a file, optionally looking for it in the include path. Returns an open
+ * FILE * on success.
* ----------------------------------------------------------------------------- */
-static FILE *Swig_open_any(const String_or_char *name, int sysfile) {
+static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_include_path) {
FILE *f;
String *filename;
List *spath = 0;
@@ -169,7 +170,7 @@ static FILE *Swig_open_any(const String_or_char *name, int sysfile) {
filename = NewString(cname);
assert(filename);
f = fopen(Char(filename), "r");
- if (!f) {
+ if (!f && use_include_path) {
spath = Swig_search_path_any(sysfile);
ilen = Len(spath);
for (i = 0; i < ilen; i++) {
@@ -182,19 +183,21 @@ static FILE *Swig_open_any(const String_or_char *name, int sysfile) {
Delete(spath);
}
if (f) {
-#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
- Replaceall(filename, "\\\\", "\\"); /* remove double '\' in case any already present */
- Replaceall(filename, "\\", "\\\\");
-#endif
Delete(lastpath);
- lastpath = Copy(filename);
+ lastpath = Swig_filename_escape(filename);
}
Delete(filename);
return f;
}
-FILE *Swig_open(const String_or_char *name) {
- return Swig_open_any(name, 0);
+/* Open a file - searching the include paths to find it */
+FILE *Swig_include_open(const_String_or_char_ptr name) {
+ return Swig_open_file(name, 0, 1);
+}
+
+/* Open a file - does not use include paths to find it */
+FILE *Swig_open(const_String_or_char_ptr name) {
+ return Swig_open_file(name, 0, 0);
}
@@ -230,12 +233,12 @@ String *Swig_read_file(FILE *f) {
* Opens a file and returns it as a string.
* ----------------------------------------------------------------------------- */
-static String *Swig_include_any(const String_or_char *name, int sysfile) {
+static String *Swig_include_any(const_String_or_char_ptr name, int sysfile) {
FILE *f;
String *str;
String *file;
- f = Swig_open_any(name, sysfile);
+ f = Swig_open_file(name, sysfile, 1);
if (!f)
return 0;
str = Swig_read_file(f);
@@ -248,11 +251,11 @@ static String *Swig_include_any(const String_or_char *name, int sysfile) {
return str;
}
-String *Swig_include(const String_or_char *name) {
+String *Swig_include(const_String_or_char_ptr name) {
return Swig_include_any(name, 0);
}
-String *Swig_include_sys(const String_or_char *name) {
+String *Swig_include_sys(const_String_or_char_ptr name) {
return Swig_include_any(name, 1);
}
@@ -262,10 +265,10 @@ String *Swig_include_sys(const String_or_char *name) {
* Copies the contents of a file into another file
* ----------------------------------------------------------------------------- */
-int Swig_insert_file(const String_or_char *filename, File *outfile) {
+int Swig_insert_file(const_String_or_char_ptr filename, File *outfile) {
char buffer[4096];
int nbytes;
- FILE *f = Swig_open(filename);
+ FILE *f = Swig_include_open(filename);
if (!f)
return -1;
@@ -286,7 +289,7 @@ int Swig_insert_file(const String_or_char *filename, File *outfile) {
static Hash *named_files = 0;
-void Swig_register_filebyname(const String_or_char *filename, File *outfile) {
+void Swig_register_filebyname(const_String_or_char_ptr filename, File *outfile) {
if (!named_files)
named_files = NewHash();
Setattr(named_files, filename, outfile);
@@ -298,7 +301,7 @@ void Swig_register_filebyname(const String_or_char *filename, File *outfile) {
* Get a named file
* ----------------------------------------------------------------------------- */
-File *Swig_filebyname(const String_or_char *filename) {
+File *Swig_filebyname(const_String_or_char_ptr filename) {
if (!named_files)
return 0;
return Getattr(named_files, filename);
@@ -310,7 +313,7 @@ File *Swig_filebyname(const String_or_char *filename) {
* Returns the suffix of a file
* ----------------------------------------------------------------------------- */
-char *Swig_file_suffix(const String_or_char *filename) {
+char *Swig_file_suffix(const_String_or_char_ptr filename) {
char *d;
char *c = Char(filename);
int len = Len(filename);
@@ -332,7 +335,7 @@ char *Swig_file_suffix(const String_or_char *filename) {
* Returns the filename with no suffix attached.
* ----------------------------------------------------------------------------- */
-char *Swig_file_basename(const String_or_char *filename) {
+char *Swig_file_basename(const_String_or_char_ptr filename) {
static char tmp[1024];
char *c;
strcpy(tmp, Char(filename));
@@ -346,7 +349,7 @@ char *Swig_file_basename(const String_or_char *filename) {
*
* Return the file with any leading path stripped off
* ----------------------------------------------------------------------------- */
-char *Swig_file_filename(const String_or_char *filename) {
+char *Swig_file_filename(const_String_or_char_ptr filename) {
static char tmp[1024];
const char *delim = SWIG_FILE_DELIMITER;
char *c;
@@ -364,7 +367,7 @@ char *Swig_file_filename(const String_or_char *filename) {
*
* Return the name of the directory associated with a file
* ----------------------------------------------------------------------------- */
-char *Swig_file_dirname(const String_or_char *filename) {
+char *Swig_file_dirname(const_String_or_char_ptr filename) {
static char tmp[1024];
const char *delim = SWIG_FILE_DELIMITER;
char *c;
diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
index d29250517..050e5357a 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -54,7 +54,7 @@ const char *Swig_package_version(void) {
/* -----------------------------------------------------------------------------
* Swig_banner()
*
- * Emits the SWIG identifying banner.
+ * Emits the SWIG identifying banner for the C/C++ wrapper file.
* ----------------------------------------------------------------------------- */
void Swig_banner(File *f) {
@@ -67,11 +67,25 @@ void Swig_banner(File *f) {
* changes to this file unless you know what you are doing--modify the SWIG \n\
* interface file instead. \n", Swig_package_version());
/* String too long for ISO compliance */
- Printf(f, " * ----------------------------------------------------------------------------- */\n\n");
+ Printf(f, " * ----------------------------------------------------------------------------- */\n");
}
/* -----------------------------------------------------------------------------
+ * Swig_banner_target_lang()
+ *
+ * Emits a SWIG identifying banner in the target language
+ * ----------------------------------------------------------------------------- */
+
+void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar) {
+ Printf(f, "%s This file was automatically generated by SWIG (http://www.swig.org).\n", commentchar);
+ Printf(f, "%s Version %s\n", commentchar, Swig_package_version());
+ Printf(f, "%s\n", commentchar);
+ Printf(f, "%s Do not make changes to this file unless you know what you are doing--modify\n", commentchar);
+ Printf(f, "%s the SWIG interface file instead.\n", commentchar);
+}
+
+/* -----------------------------------------------------------------------------
* Swig_strip_c_comments()
*
* Return a new string with C comments stripped from the input string. Null is
@@ -118,6 +132,39 @@ String *Swig_strip_c_comments(const String *s) {
/* -----------------------------------------------------------------------------
+ * Swig_filename_correct()
+ *
+ * Corrects filenames on non-unix systems
+ * ----------------------------------------------------------------------------- */
+
+void Swig_filename_correct(String *filename) {
+ (void)filename;
+#if defined(_WIN32) || defined(MACSWIG)
+ /* accept Unix path separator on non-Unix systems */
+ Replaceall(filename, "/", SWIG_FILE_DELIMITER);
+#endif
+#if defined(__CYGWIN__)
+ /* accept Windows path separator in addition to Unix path separator */
+ Replaceall(filename, "\\", SWIG_FILE_DELIMITER);
+#endif
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_filename_escape()
+ *
+ * Escapes backslashes in filename - for Windows
+ * ----------------------------------------------------------------------------- */
+
+String *Swig_filename_escape(String *filename) {
+ String *adjusted_filename = Copy(filename);
+#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
+ Replaceall(adjusted_filename, "\\\\", "\\"); /* remove double '\' in case any already present */
+ Replaceall(adjusted_filename, "\\", "\\\\");
+#endif
+ return adjusted_filename;
+}
+
+/* -----------------------------------------------------------------------------
* Swig_string_escape()
*
* Takes a string object and produces a string with escape codes added to it.
@@ -604,7 +651,7 @@ String *Swig_string_emangle(String *s) {
* In this case, "A::B". Returns NULL if there is no base.
* ----------------------------------------------------------------------------- */
-void Swig_scopename_split(String *s, String **rprefix, String **rlast) {
+void Swig_scopename_split(const String *s, String **rprefix, String **rlast) {
char *tmp = Char(s);
char *c = tmp;
char *cc = c;
@@ -658,7 +705,7 @@ void Swig_scopename_split(String *s, String **rprefix, String **rlast) {
}
-String *Swig_scopename_prefix(String *s) {
+String *Swig_scopename_prefix(const String *s) {
char *tmp = Char(s);
char *c = tmp;
char *cc = c;
@@ -710,7 +757,7 @@ String *Swig_scopename_prefix(String *s) {
* case, "C".
* ----------------------------------------------------------------------------- */
-String *Swig_scopename_last(String *s) {
+String *Swig_scopename_last(const String *s) {
char *tmp = Char(s);
char *c = tmp;
char *cc = c;
@@ -754,7 +801,7 @@ String *Swig_scopename_last(String *s) {
* In this case, "A". Returns NULL if there is no base.
* ----------------------------------------------------------------------------- */
-String *Swig_scopename_first(String *s) {
+String *Swig_scopename_first(const String *s) {
char *tmp = Char(s);
char *c = tmp;
char *co = 0;
@@ -804,7 +851,7 @@ String *Swig_scopename_first(String *s) {
* In this case, "B::C". Returns NULL if there is no suffix.
* ----------------------------------------------------------------------------- */
-String *Swig_scopename_suffix(String *s) {
+String *Swig_scopename_suffix(const String *s) {
char *tmp = Char(s);
char *c = tmp;
char *co = 0;
@@ -848,7 +895,7 @@ String *Swig_scopename_suffix(String *s) {
* Checks to see if a name is qualified with a scope name
* ----------------------------------------------------------------------------- */
-int Swig_scopename_check(String *s) {
+int Swig_scopename_check(const String *s) {
char *c = Char(s);
char *co = strstr(c, "operator ");
@@ -927,6 +974,37 @@ String *Swig_string_command(String *s) {
/* -----------------------------------------------------------------------------
+ * Swig_string_strip()
+ *
+ * Strip given prefix from identifiers
+ *
+ * Printf(stderr,"%(strip:[wx])s","wxHello") -> Hello
+ * ----------------------------------------------------------------------------- */
+
+String *Swig_string_strip(String *s) {
+ String *ns;
+ if (!Len(s)) {
+ ns = NewString(s);
+ } else {
+ const char *cs = Char(s);
+ const char *ce = Strchr(cs, ']');
+ if (*cs != '[' || ce == NULL) {
+ ns = NewString(s);
+ } else {
+ String *fmt = NewStringf("%%.%ds", ce-cs-1);
+ String *prefix = NewStringf(fmt, cs+1);
+ if (0 == Strncmp(ce+1, prefix, Len(prefix))) {
+ ns = NewString(ce+1+Len(prefix));
+ } else {
+ ns = NewString(ce+1);
+ }
+ }
+ }
+ return ns;
+}
+
+
+/* -----------------------------------------------------------------------------
* Swig_string_rxspencer()
*
* Executes a regexp substitution via the RxSpencer library. For example:
@@ -1053,6 +1131,7 @@ void Swig_init() {
DohEncoding("command", Swig_string_command);
DohEncoding("rxspencer", Swig_string_rxspencer);
DohEncoding("schemify", Swig_string_schemify);
+ DohEncoding("strip", Swig_string_strip);
/* aliases for the case encoders */
DohEncoding("uppercase", Swig_string_upper);
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index f34a24612..013ce5929 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -27,13 +27,13 @@ static Hash *naming_hash = 0;
* Register a new naming format.
* ----------------------------------------------------------------------------- */
-void Swig_name_register(const String_or_char *method, const String_or_char *format) {
+void Swig_name_register(const_String_or_char_ptr method, const_String_or_char_ptr format) {
if (!naming_hash)
naming_hash = NewHash();
Setattr(naming_hash, method, format);
}
-void Swig_name_unregister(const String_or_char *method) {
+void Swig_name_unregister(const_String_or_char_ptr method) {
if (naming_hash) {
Delattr(naming_hash, method);
}
@@ -127,7 +127,7 @@ static int name_mangle(String *r) {
* Converts all of the non-identifier characters of a string to underscores.
* ----------------------------------------------------------------------------- */
-String *Swig_name_mangle(const String_or_char *s) {
+String *Swig_name_mangle(const_String_or_char_ptr s) {
#if 0
String *r = NewString(s);
name_mangle(r);
@@ -143,7 +143,7 @@ String *Swig_name_mangle(const String_or_char *s) {
* Returns the name of a wrapper function.
* ----------------------------------------------------------------------------- */
-String *Swig_name_wrapper(const String_or_char *fname) {
+String *Swig_name_wrapper(const_String_or_char_ptr fname) {
String *r;
String *f;
@@ -168,7 +168,7 @@ String *Swig_name_wrapper(const String_or_char *fname) {
* Returns the name of a class method.
* ----------------------------------------------------------------------------- */
-String *Swig_name_member(const String_or_char *classname, const String_or_char *mname) {
+String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname) {
String *r;
String *f;
String *rclassname;
@@ -201,7 +201,7 @@ String *Swig_name_member(const String_or_char *classname, const String_or_char *
* Returns the name of the accessor function used to get a variable.
* ----------------------------------------------------------------------------- */
-String *Swig_name_get(const String_or_char *vname) {
+String *Swig_name_get(const_String_or_char_ptr vname) {
String *r;
String *f;
@@ -229,7 +229,7 @@ String *Swig_name_get(const String_or_char *vname) {
* Returns the name of the accessor function used to set a variable.
* ----------------------------------------------------------------------------- */
-String *Swig_name_set(const String_or_char *vname) {
+String *Swig_name_set(const_String_or_char_ptr vname) {
String *r;
String *f;
@@ -253,7 +253,7 @@ String *Swig_name_set(const String_or_char *vname) {
* Returns the name of the accessor function used to create an object.
* ----------------------------------------------------------------------------- */
-String *Swig_name_construct(const String_or_char *classname) {
+String *Swig_name_construct(const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
@@ -286,7 +286,7 @@ String *Swig_name_construct(const String_or_char *classname) {
* Returns the name of the accessor function used to copy an object.
* ----------------------------------------------------------------------------- */
-String *Swig_name_copyconstructor(const String_or_char *classname) {
+String *Swig_name_copyconstructor(const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
@@ -319,7 +319,7 @@ String *Swig_name_copyconstructor(const String_or_char *classname) {
* Returns the name of the accessor function used to destroy an object.
* ----------------------------------------------------------------------------- */
-String *Swig_name_destroy(const String_or_char *classname) {
+String *Swig_name_destroy(const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
@@ -351,7 +351,7 @@ String *Swig_name_destroy(const String_or_char *classname) {
* Returns the name of the accessor function used to disown an object.
* ----------------------------------------------------------------------------- */
-String *Swig_name_disown(const String_or_char *classname) {
+String *Swig_name_disown(const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
@@ -600,7 +600,7 @@ static void merge_features(Hash *features, Node *n) {
* ----------------------------------------------------------------------------- */
static
-void features_get(Hash *features, String *tname, SwigType *decl, SwigType *ncdecl, Node *node) {
+void features_get(Hash *features, const String *tname, SwigType *decl, SwigType *ncdecl, Node *node) {
Node *n = Getattr(features, tname);
#ifdef SWIG_DEBUG
Printf(stdout, " features_get: %s\n", tname);
@@ -655,7 +655,7 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
}
#ifdef SWIG_DEBUG
- Printf(stdout, "Swig_features_get: %s %s %s\n", prefix, name, decl);
+ Printf(stdout, "Swig_features_get: '%s' '%s' '%s'\n", prefix, name, decl);
#endif
/* Global features */
@@ -727,12 +727,12 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
* concatenating the feature name plus ':' plus the attribute name.
* ----------------------------------------------------------------------------- */
-void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value, Hash *featureattribs) {
+void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *decl, const_String_or_char_ptr featurename, String *value, Hash *featureattribs) {
Hash *n;
Hash *fhash;
#ifdef SWIG_DEBUG
- Printf(stdout, "Swig_feature_set: %s %s %s %s\n", name, decl, featurename, value);
+ Printf(stdout, "Swig_feature_set: '%s' '%s' '%s' '%s'\n", name, decl, featurename, value);
#endif
n = Getattr(features, name);
@@ -1436,7 +1436,7 @@ static String *apply_rename(String *newname, int fullname, String *prefix, Strin
*
* ----------------------------------------------------------------------------- */
-String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType *decl, String *oldname) {
+String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname) {
String *nname = 0;
String *result = 0;
String *name = NewString(cname);
diff --git a/Source/Swig/parms.c b/Source/Swig/parms.c
index baa1dfbf3..9b58f5fcb 100644
--- a/Source/Swig/parms.c
+++ b/Source/Swig/parms.c
@@ -17,7 +17,7 @@ char cvsroot_parms_c[] = "$Id$";
* Create a new parameter from datatype 'type' and name 'name'.
* ------------------------------------------------------------------------ */
-Parm *NewParm(SwigType *type, const String_or_char *name) {
+Parm *NewParm(SwigType *type, const_String_or_char_ptr name) {
Parm *p = NewHash();
set_nodeType(p, "parm");
if (type) {
diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
index 06e78db37..53f1ad4a0 100644
--- a/Source/Swig/scanner.c
+++ b/Source/Swig/scanner.c
@@ -15,6 +15,9 @@ char cvsroot_scanner_c[] = "$Id$";
#include "swig.h"
#include <ctype.h>
+extern String *cparse_file;
+extern int cparse_start_line;
+
struct Scanner {
String *text; /* Current token value */
List *scanobjs; /* Objects being scanned */
@@ -36,7 +39,7 @@ struct Scanner {
* Create a new scanner object
* ----------------------------------------------------------------------------- */
-Scanner *NewScanner() {
+Scanner *NewScanner(void) {
Scanner *s;
s = (Scanner *) malloc(sizeof(Scanner));
s->line = 1;
@@ -115,11 +118,11 @@ void Scanner_push(Scanner * s, String *txt) {
* call to Scanner_token().
* ----------------------------------------------------------------------------- */
-void Scanner_pushtoken(Scanner * s, int nt, const String_or_char *val) {
+void Scanner_pushtoken(Scanner * s, int nt, const_String_or_char_ptr val) {
assert(s);
assert((nt >= 0) && (nt < SWIG_MAXTOKENS));
s->nexttoken = nt;
- if (val != s->text) {
+ if ( Char(val) != Char(s->text) ) {
Clear(s->text);
Append(s->text,val);
}
@@ -209,7 +212,7 @@ static char nextchar(Scanner * s) {
* Sets error information on the scanner.
* ----------------------------------------------------------------------------- */
-static void set_error(Scanner *s, int line, String_or_char *msg) {
+static void set_error(Scanner *s, int line, const_String_or_char_ptr msg) {
s->error_line = line;
s->error = NewString(msg);
}
@@ -536,7 +539,7 @@ static int look(Scanner * s) {
break;
case 10: /* C++ style comment */
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line,"Unterminated comment");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n");
return SWIG_TOKEN_ERROR;
}
if (c == '\n') {
@@ -548,7 +551,7 @@ static int look(Scanner * s) {
break;
case 11: /* C style comment block */
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line,"Unterminated comment");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n");
return SWIG_TOKEN_ERROR;
}
if (c == '*') {
@@ -559,7 +562,7 @@ static int look(Scanner * s) {
break;
case 12: /* Still in C style comment */
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line,"Unterminated comment");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n");
return SWIG_TOKEN_ERROR;
}
if (c == '*') {
@@ -573,7 +576,7 @@ static int look(Scanner * s) {
case 2: /* Processing a string */
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line, "Unterminated string");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated string\n");
return SWIG_TOKEN_ERROR;
}
if (c == '\"') {
@@ -656,7 +659,7 @@ static int look(Scanner * s) {
case 40: /* Process an include block */
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line,"Unterminated code block");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated block\n");
return SWIG_TOKEN_ERROR;
}
if (c == '%')
@@ -933,7 +936,7 @@ static int look(Scanner * s) {
/* A character constant */
case 9:
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line,"Unterminated character constant");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n");
return SWIG_TOKEN_ERROR;
}
if (c == '\'') {
@@ -1048,7 +1051,7 @@ static int look(Scanner * s) {
/* Reverse string */
case 900:
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line,"Unterminated character constant");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n");
return SWIG_TOKEN_ERROR;
}
if (c == '`') {
diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c
index 5ffd28eec..8a7700bec 100644
--- a/Source/Swig/stype.c
+++ b/Source/Swig/stype.c
@@ -537,7 +537,7 @@ String *SwigType_namestr(const SwigType *t) {
* Create a C string representation of a datatype.
* ----------------------------------------------------------------------------- */
-String *SwigType_str(SwigType *s, const String_or_char *id) {
+String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
String *result;
String *element = 0, *nextelement;
List *elements;
@@ -732,7 +732,7 @@ SwigType *SwigType_ltype(SwigType *s) {
* with an equivalent assignable version.
* -------------------------------------------------------------------- */
-String *SwigType_lstr(SwigType *s, const String_or_char *id) {
+String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id) {
String *result;
SwigType *tc;
@@ -749,7 +749,7 @@ String *SwigType_lstr(SwigType *s, const String_or_char *id) {
* datatype printed by str().
* ----------------------------------------------------------------------------- */
-String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
+String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
String *result, *cast;
String *element = 0, *nextelement;
SwigType *td, *rs, *tc = 0;
@@ -892,7 +892,7 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
* Casts a variable from the real type to the local datatype.
* ----------------------------------------------------------------------------- */
-String *SwigType_lcaststr(SwigType *s, const String_or_char *name) {
+String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr name) {
String *result;
result = NewStringEmpty();
diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
index 451de86c4..2b2c797c9 100644
--- a/Source/Swig/swig.h
+++ b/Source/Swig/swig.h
@@ -110,15 +110,15 @@ extern "C" {
extern SwigType *NewSwigType(int typecode);
extern SwigType *SwigType_del_element(SwigType *t);
extern SwigType *SwigType_add_pointer(SwigType *t);
- extern SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *qual);
+ extern SwigType *SwigType_add_memberpointer(SwigType *t, const_String_or_char_ptr qual);
extern SwigType *SwigType_del_memberpointer(SwigType *t);
extern SwigType *SwigType_del_pointer(SwigType *t);
- extern SwigType *SwigType_add_array(SwigType *t, const String_or_char *size);
+ extern SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size);
extern SwigType *SwigType_del_array(SwigType *t);
extern SwigType *SwigType_pop_arrays(SwigType *t);
extern SwigType *SwigType_add_reference(SwigType *t);
extern SwigType *SwigType_del_reference(SwigType *t);
- extern SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual);
+ extern SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual);
extern SwigType *SwigType_del_qualifier(SwigType *t);
extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms);
@@ -129,10 +129,10 @@ extern "C" {
extern void SwigType_push(SwigType *t, SwigType *s);
extern List *SwigType_parmlist(const SwigType *p);
extern String *SwigType_parm(String *p);
- extern String *SwigType_str(SwigType *s, const String_or_char *id);
- extern String *SwigType_lstr(SwigType *s, const String_or_char *id);
- extern String *SwigType_rcaststr(SwigType *s, const String_or_char *id);
- extern String *SwigType_lcaststr(SwigType *s, const String_or_char *id);
+ extern String *SwigType_str(SwigType *s, const_String_or_char_ptr id);
+ extern String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id);
+ extern String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr id);
+ extern String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_manglestr(SwigType *t);
extern SwigType *SwigType_ltype(SwigType *t);
extern int SwigType_ispointer(SwigType *t);
@@ -151,7 +151,7 @@ extern "C" {
extern int SwigType_isvarargs(const SwigType *t);
extern int SwigType_istemplate(const SwigType *t);
extern int SwigType_isenum(SwigType *t);
- extern int SwigType_check_decl(SwigType *t, const String_or_char *decl);
+ extern int SwigType_check_decl(SwigType *t, const_String_or_char_ptr decl);
extern SwigType *SwigType_strip_qualifiers(SwigType *t);
extern SwigType *SwigType_functionpointer_decompose(SwigType *t);
extern String *SwigType_base(const SwigType *t);
@@ -162,7 +162,7 @@ extern "C" {
extern String *SwigType_prefix(const SwigType *t);
extern int SwigType_array_ndim(SwigType *t);
extern String *SwigType_array_getdim(SwigType *t, int n);
- extern void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep);
+ extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep);
extern SwigType *SwigType_array_type(SwigType *t);
extern String *SwigType_default(SwigType *t);
extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
@@ -173,27 +173,27 @@ extern "C" {
/* --- Type-system managment --- */
extern void SwigType_typesystem_init(void);
- extern int SwigType_typedef(SwigType *type, String_or_char *name);
- extern int SwigType_typedef_class(String_or_char *name);
- extern int SwigType_typedef_using(String_or_char *qname);
+ extern int SwigType_typedef(SwigType *type, const_String_or_char_ptr name);
+ extern int SwigType_typedef_class(const_String_or_char_ptr name);
+ extern int SwigType_typedef_using(const_String_or_char_ptr qname);
extern void SwigType_inherit(String *subclass, String *baseclass, String *cast, String *conversioncode);
extern int SwigType_issubtype(SwigType *subtype, SwigType *basetype);
extern void SwigType_scope_alias(String *aliasname, Typetab *t);
extern void SwigType_using_scope(Typetab *t);
- extern void SwigType_new_scope(const String_or_char *name);
+ extern void SwigType_new_scope(const_String_or_char_ptr name);
extern void SwigType_inherit_scope(Typetab *scope);
extern Typetab *SwigType_pop_scope(void);
extern Typetab *SwigType_set_scope(Typetab *h);
extern void SwigType_print_scope(Typetab *t);
- extern SwigType *SwigType_typedef_resolve(SwigType *t);
+ extern SwigType *SwigType_typedef_resolve(const SwigType *t);
extern SwigType *SwigType_typedef_resolve_all(SwigType *t);
extern SwigType *SwigType_typedef_qualified(SwigType *t);
extern int SwigType_istypedef(SwigType *t);
extern int SwigType_isclass(SwigType *t);
extern void SwigType_attach_symtab(Symtab *syms);
extern void SwigType_remember(SwigType *t);
- extern void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata);
- extern void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata);
+ extern void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata);
+ extern void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata);
extern void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *);
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
extern int SwigType_type(SwigType *t);
@@ -201,25 +201,25 @@ extern "C" {
/* --- Symbol table module --- */
extern void Swig_symbol_init(void);
- extern void Swig_symbol_setscopename(const String_or_char *name);
+ extern void Swig_symbol_setscopename(const_String_or_char_ptr name);
extern String *Swig_symbol_getscopename(void);
extern String *Swig_symbol_qualifiedscopename(Symtab *symtab);
extern Symtab *Swig_symbol_newscope(void);
extern Symtab *Swig_symbol_setscope(Symtab *);
- extern Symtab *Swig_symbol_getscope(const String_or_char *symname);
+ extern Symtab *Swig_symbol_getscope(const_String_or_char_ptr symname);
extern Symtab *Swig_symbol_current(void);
extern Symtab *Swig_symbol_popscope(void);
- extern Node *Swig_symbol_add(String_or_char *symname, Node *node);
- extern void Swig_symbol_cadd(String_or_char *symname, Node *node);
- extern Node *Swig_symbol_clookup(String_or_char *symname, Symtab *tab);
- extern Node *Swig_symbol_clookup_check(String_or_char *symname, Symtab *tab, int (*check) (Node *));
- extern Symtab *Swig_symbol_cscope(String_or_char *symname, Symtab *tab);
- extern Node *Swig_symbol_clookup_local(String_or_char *symname, Symtab *tab);
- extern Node *Swig_symbol_clookup_local_check(String_or_char *symname, Symtab *tab, int (*check) (Node *));
+ extern Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *node);
+ extern void Swig_symbol_cadd(const_String_or_char_ptr symname, Node *node);
+ extern Node *Swig_symbol_clookup(const_String_or_char_ptr symname, Symtab *tab);
+ extern Node *Swig_symbol_clookup_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *));
+ extern Symtab *Swig_symbol_cscope(const_String_or_char_ptr symname, Symtab *tab);
+ extern Node *Swig_symbol_clookup_local(const_String_or_char_ptr symname, Symtab *tab);
+ extern Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *));
extern String *Swig_symbol_qualified(Node *node);
extern Node *Swig_symbol_isoverloaded(Node *node);
extern void Swig_symbol_remove(Node *node);
- extern void Swig_symbol_alias(String_or_char *aliasname, Symtab *tab);
+ extern void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *tab);
extern void Swig_symbol_inherit(Symtab *tab);
extern SwigType *Swig_symbol_type_qualify(const SwigType *ty, Symtab *tab);
extern String *Swig_symbol_string_qualify(String *s, Symtab *tab);
@@ -246,17 +246,17 @@ extern int ParmList_is_compactdefargs(ParmList *p);
/* --- Naming functions --- */
- extern void Swig_name_register(const String_or_char *method, const String_or_char *format);
- extern void Swig_name_unregister(const String_or_char *method);
- extern String *Swig_name_mangle(const String_or_char *s);
- extern String *Swig_name_wrapper(const String_or_char *fname);
- extern String *Swig_name_member(const String_or_char *classname, const String_or_char *mname);
- extern String *Swig_name_get(const String_or_char *vname);
- extern String *Swig_name_set(const String_or_char *vname);
- extern String *Swig_name_construct(const String_or_char *classname);
- extern String *Swig_name_copyconstructor(const String_or_char *classname);
- extern String *Swig_name_destroy(const String_or_char *classname);
- extern String *Swig_name_disown(const String_or_char *classname);
+ extern void Swig_name_register(const_String_or_char_ptr method, const_String_or_char_ptr format);
+ extern void Swig_name_unregister(const_String_or_char_ptr method);
+ extern String *Swig_name_mangle(const_String_or_char_ptr s);
+ extern String *Swig_name_wrapper(const_String_or_char_ptr fname);
+ extern String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname);
+ extern String *Swig_name_get(const_String_or_char_ptr vname);
+ extern String *Swig_name_set(const_String_or_char_ptr vname);
+ extern String *Swig_name_construct(const_String_or_char_ptr classname);
+ extern String *Swig_name_copyconstructor(const_String_or_char_ptr classname);
+ extern String *Swig_name_destroy(const_String_or_char_ptr classname);
+ extern String *Swig_name_disown(const_String_or_char_ptr classname);
extern void Swig_naming_init(void);
extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn);
@@ -267,33 +267,36 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern int Swig_need_name_warning(Node *n);
extern int Swig_need_redefined_warn(Node *a, Node *b, int InClass);
- extern String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType *decl, String *oldname);
+ extern String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname);
extern String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl);
extern String *Swig_name_decl(Node *n);
extern String *Swig_name_fulldecl(Node *n);
/* --- parameterized rename functions --- */
- extern void Swig_name_object_set(Hash *namehash, String_or_char *name, SwigType *decl, DOH *object);
- extern DOH *Swig_name_object_get(Hash *namehash, String_or_char *prefix, String_or_char *name, SwigType *decl);
+ extern void Swig_name_object_set(Hash *namehash, String *name, SwigType *decl, DOH *object);
+ extern DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType *decl);
extern void Swig_name_object_inherit(Hash *namehash, String *base, String *derived);
- extern void Swig_features_get(Hash *features, String_or_char *prefix, String_or_char *name, SwigType *decl, Node *n);
- extern void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value, Hash *featureattribs);
+ extern void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl, Node *n);
+ extern void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *decl, const_String_or_char_ptr featurename, String *value, Hash *featureattribs);
/* --- Misc --- */
extern char *Swig_copy_string(const char *c);
extern void Swig_set_fakeversion(const char *version);
extern const char *Swig_package_version(void);
extern void Swig_banner(File *f);
+ extern void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar);
extern String *Swig_strip_c_comments(const String *s);
+ extern String *Swig_filename_escape(String *filename);
+ extern void Swig_filename_correct(String *filename);
extern String *Swig_string_escape(String *s);
extern String *Swig_string_mangle(const String *s);
- extern void Swig_scopename_split(String *s, String **prefix, String **last);
- extern String *Swig_scopename_prefix(String *s);
- extern String *Swig_scopename_last(String *s);
- extern String *Swig_scopename_first(String *s);
- extern String *Swig_scopename_suffix(String *s);
- extern int Swig_scopename_check(String *s);
+ extern void Swig_scopename_split(const String *s, String **prefix, String **last);
+ extern String *Swig_scopename_prefix(const String *s);
+ extern String *Swig_scopename_last(const String *s);
+ extern String *Swig_scopename_first(const String *s);
+ extern String *Swig_scopename_suffix(const String *s);
+ extern int Swig_scopename_check(const String *s);
extern String *Swig_string_lower(String *s);
extern String *Swig_string_upper(String *s);
extern String *Swig_string_title(String *s);
@@ -308,11 +311,11 @@ extern int ParmList_is_compactdefargs(ParmList *p);
typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat;
- extern void Swig_warning(int num, const String_or_char *filename, int line, const char *fmt, ...);
- extern void Swig_error(const String_or_char *filename, int line, const char *fmt, ...);
+ extern void Swig_warning(int num, const_String_or_char_ptr filename, int line, const char *fmt, ...);
+ extern void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...);
extern int Swig_error_count(void);
extern void Swig_error_silent(int s);
- extern void Swig_warnfilter(const String_or_char *wlist, int val);
+ extern void Swig_warnfilter(const_String_or_char_ptr wlist, int val);
extern void Swig_warnall(void);
extern int Swig_warn_count(void);
extern void Swig_error_msg_format(ErrorMessageFormat format);
@@ -321,17 +324,17 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern String *Swig_cparm_name(Parm *p, int i);
extern String *Swig_wrapped_var_type(SwigType *t, int varcref);
extern int Swig_cargs(Wrapper *w, ParmList *l);
- extern String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl);
+ extern String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr decl);
- extern String *Swig_cfunction_call(String_or_char *name, ParmList *parms);
- extern String *Swig_cconstructor_call(String_or_char *name);
- extern String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms);
+ extern String *Swig_cfunction_call(const_String_or_char_ptr name, ParmList *parms);
+ extern String *Swig_cconstructor_call(const_String_or_char_ptr name);
+ extern String *Swig_cppconstructor_call(const_String_or_char_ptr name, ParmList *parms);
extern String *Swig_unref_call(Node *n);
extern String *Swig_ref_call(Node *n, const String *lname);
extern String *Swig_cdestructor_call(Node *n);
extern String *Swig_cppdestructor_call(Node *n);
- extern String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self, int varcref);
- extern String *Swig_cmemberget_call(const String_or_char *name, SwigType *t, String_or_char *self, int varcref);
+ extern String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, String *self, int varcref);
+ extern String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref);
extern int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self);
@@ -340,7 +343,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director);
extern int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags);
extern int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags);
- extern int Swig_MembersetToFunction(Node *n, String *classname, int flags);
+ extern int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **call);
extern int Swig_MembergetToFunction(Node *n, String *classname, int flags);
extern int Swig_VargetToFunction(Node *n, int flags);
extern int Swig_VarsetToFunction(Node *n, int flags);
@@ -360,22 +363,22 @@ extern int ParmList_is_compactdefargs(ParmList *p);
/* --- Legacy Typemap API (somewhat simplified, ha!) --- */
extern void Swig_typemap_init(void);
- extern void Swig_typemap_register(const String_or_char *op, ParmList *pattern, String_or_char *code, ParmList *locals, ParmList *kwargs);
- extern int Swig_typemap_copy(const String_or_char *op, ParmList *srcpattern, ParmList *pattern);
- extern void Swig_typemap_clear(const String_or_char *op, ParmList *pattern);
+ extern void Swig_typemap_register(const_String_or_char_ptr op, ParmList *pattern, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs);
+ extern int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcpattern, ParmList *pattern);
+ extern void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *pattern);
extern int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat);
extern void Swig_typemap_clear_apply(ParmList *pattern);
extern void Swig_typemap_debug(void);
- extern Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, const String_or_char *pname, SwigType **matchtype);
- extern Hash *Swig_typemap_search_multi(const String_or_char *op, ParmList *parms, int *nmatch);
- extern String *Swig_typemap_lookup(const String_or_char *op, Node *n, const String_or_char *lname, Wrapper *f);
- extern String *Swig_typemap_lookup_out(const String_or_char *op, Node *n, const String_or_char *lname, Wrapper *f, String *actioncode);
- extern void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p);
+ extern Hash *Swig_typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr pname, SwigType **matchtype);
+ extern Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch);
+ extern String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f);
+ extern String *Swig_typemap_lookup_out(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode);
+ extern void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p);
extern void Swig_typemap_new_scope(void);
extern Hash *Swig_typemap_pop_scope(void);
- extern void Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f);
+ extern void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wrapper *f);
/* --- Code fragment support --- */
diff --git a/Source/Swig/swigfile.h b/Source/Swig/swigfile.h
index c945fb1ac..92c7945e6 100644
--- a/Source/Swig/swigfile.h
+++ b/Source/Swig/swigfile.h
@@ -9,24 +9,25 @@
/* $Id: swig.h 9603 2006-12-05 21:47:01Z beazley $ */
-extern List *Swig_add_directory(const String_or_char *dirname);
-extern void Swig_push_directory(const String_or_char *dirname);
-extern void Swig_pop_directory();
-extern String *Swig_last_file();
-extern List *Swig_search_path();
-extern FILE *Swig_open(const String_or_char *name);
+extern List *Swig_add_directory(const_String_or_char_ptr dirname);
+extern void Swig_push_directory(const_String_or_char_ptr dirname);
+extern void Swig_pop_directory(void);
+extern String *Swig_last_file(void);
+extern List *Swig_search_path(void);
+extern FILE *Swig_include_open(const_String_or_char_ptr name);
+extern FILE *Swig_open(const_String_or_char_ptr name);
extern String *Swig_read_file(FILE *f);
-extern String *Swig_include(const String_or_char *name);
-extern String *Swig_include_sys(const String_or_char *name);
-extern int Swig_insert_file(const String_or_char *name, File *outfile);
+extern String *Swig_include(const_String_or_char_ptr name);
+extern String *Swig_include_sys(const_String_or_char_ptr name);
+extern int Swig_insert_file(const_String_or_char_ptr name, File *outfile);
extern void Swig_set_push_dir(int dopush);
extern int Swig_get_push_dir(void);
-extern void Swig_register_filebyname(const String_or_char *filename, File *outfile);
-extern File *Swig_filebyname(const String_or_char *filename);
-extern char *Swig_file_suffix(const String_or_char *filename);
-extern char *Swig_file_basename(const String_or_char *filename);
-extern char *Swig_file_filename(const String_or_char *filename);
-extern char *Swig_file_dirname(const String_or_char *filename);
+extern void Swig_register_filebyname(const_String_or_char_ptr filename, File *outfile);
+extern File *Swig_filebyname(const_String_or_char_ptr filename);
+extern char *Swig_file_suffix(const_String_or_char_ptr filename);
+extern char *Swig_file_basename(const_String_or_char_ptr filename);
+extern char *Swig_file_filename(const_String_or_char_ptr filename);
+extern char *Swig_file_dirname(const_String_or_char_ptr filename);
/* Delimiter used in accessing files and directories */
diff --git a/Source/Swig/swigopt.h b/Source/Swig/swigopt.h
index 428d90dce..11eb5ba99 100644
--- a/Source/Swig/swigopt.h
+++ b/Source/Swig/swigopt.h
@@ -13,4 +13,4 @@
extern void Swig_mark_arg(int n);
extern int Swig_check_marked(int n);
extern void Swig_check_options(int check_input);
- extern void Swig_arg_error();
+ extern void Swig_arg_error(void);
diff --git a/Source/Swig/swigparm.h b/Source/Swig/swigparm.h
index 529438bae..49ae7992e 100644
--- a/Source/Swig/swigparm.h
+++ b/Source/Swig/swigparm.h
@@ -11,7 +11,7 @@
/* $Id: swig.h 9629 2006-12-30 18:27:47Z beazley $ */
/* Individual parameters */
-extern Parm *NewParm(SwigType *type, const String_or_char *name);
+extern Parm *NewParm(SwigType *type, const_String_or_char_ptr name);
extern Parm *CopyParm(Parm *p);
/* Parameter lists */
diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h
index 2486286a9..3403098df 100644
--- a/Source/Swig/swigscan.h
+++ b/Source/Swig/swigscan.h
@@ -11,11 +11,11 @@
typedef struct Scanner Scanner;
-extern Scanner *NewScanner();
+extern Scanner *NewScanner(void);
extern void DelScanner(Scanner *);
extern void Scanner_clear(Scanner *);
extern void Scanner_push(Scanner *, String *);
-extern void Scanner_pushtoken(Scanner *, int, const String_or_char *value);
+extern void Scanner_pushtoken(Scanner *, int, const_String_or_char_ptr value);
extern int Scanner_token(Scanner *);
extern String *Scanner_text(Scanner *);
extern void Scanner_skip_line(Scanner *);
diff --git a/Source/Swig/swigtree.h b/Source/Swig/swigtree.h
index 2e5c4da36..5b43006a9 100644
--- a/Source/Swig/swigtree.h
+++ b/Source/Swig/swigtree.h
@@ -31,7 +31,7 @@
/* Utility functions */
-extern int checkAttribute(Node *obj, const String_or_char *name, const String_or_char *value);
+extern int checkAttribute(Node *obj, const_String_or_char_ptr name, const_String_or_char_ptr value);
extern void appendChild(Node *node, Node *child);
extern void prependChild(Node *node, Node *child);
extern void removeNode(Node *node);
diff --git a/Source/Swig/swigwrap.h b/Source/Swig/swigwrap.h
index 25eeb6f7f..0dcf88059 100644
--- a/Source/Swig/swigwrap.h
+++ b/Source/Swig/swigwrap.h
@@ -16,14 +16,14 @@ typedef struct Wrapper {
String *code;
} Wrapper;
-extern Wrapper *NewWrapper();
+extern Wrapper *NewWrapper(void);
extern void DelWrapper(Wrapper *w);
extern void Wrapper_compact_print_mode_set(int flag);
extern void Wrapper_pretty_print(String *str, File *f);
extern void Wrapper_compact_print(String *str, File *f);
extern void Wrapper_print(Wrapper *w, File *f);
-extern int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl);
-extern int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...);
-extern int Wrapper_check_local(Wrapper *w, const String_or_char *name);
-extern char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl);
-extern char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...);
+extern int Wrapper_add_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl);
+extern int Wrapper_add_localv(Wrapper *w, const_String_or_char_ptr name, ...);
+extern int Wrapper_check_local(Wrapper *w, const_String_or_char_ptr name);
+extern char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl);
+extern char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...);
diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c
index c9691fa54..055af854f 100644
--- a/Source/Swig/symbol.c
+++ b/Source/Swig/symbol.c
@@ -220,7 +220,7 @@ void Swig_symbol_init() {
* Set the C scopename of the current symbol table.
* ----------------------------------------------------------------------------- */
-void Swig_symbol_setscopename(const String_or_char *name) {
+void Swig_symbol_setscopename(const_String_or_char_ptr name) {
String *qname;
/* assert(!Getattr(current_symtab,"name")); */
Setattr(current_symtab, "name", name);
@@ -250,10 +250,10 @@ String *Swig_symbol_getscopename() {
* Given a fully qualified C scopename, this function returns a symbol table
* ----------------------------------------------------------------------------- */
-Symtab *Swig_symbol_getscope(const String_or_char *name) {
+Symtab *Swig_symbol_getscope(const_String_or_char_ptr name) {
if (!symtabs)
return 0;
- if (Equal("::", (String_or_char *) name))
+ if (Equal("::", (const_String_or_char_ptr ) name))
name = "";
return Getattr(symtabs, name);
}
@@ -373,7 +373,7 @@ Symtab *Swig_symbol_current() {
* Makes an alias for a symbol in the global symbol table.
* ----------------------------------------------------------------------------- */
-void Swig_symbol_alias(String_or_char *aliasname, Symtab *s) {
+void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *s) {
String *qname = Swig_symbol_qualifiedscopename(current_symtab);
if (qname) {
Printf(qname, "::%s", aliasname);
@@ -421,7 +421,7 @@ void Swig_symbol_inherit(Symtab *s) {
* Adds a node to the C symbol table only.
* ----------------------------------------------------------------------------- */
-void Swig_symbol_cadd(String_or_char *name, Node *n) {
+void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) {
Node *append = 0;
Node *cn;
@@ -594,7 +594,7 @@ void Swig_symbol_cadd(String_or_char *name, Node *n) {
* for namespace support, type resolution, and other issues.
* ----------------------------------------------------------------------------- */
-Node *Swig_symbol_add(String_or_char *symname, Node *n) {
+Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *n) {
Hash *c, *cn, *cl = 0;
SwigType *decl, *ndecl;
String *cstorage, *nstorage;
@@ -827,7 +827,7 @@ Node *Swig_symbol_add(String_or_char *symname, Node *n) {
* verifying that a class hierarchy implements all pure virtual methods.
* ----------------------------------------------------------------------------- */
-static Node *_symbol_lookup(String *name, Symtab *symtab, int (*check) (Node *n)) {
+static Node *_symbol_lookup(const String *name, Symtab *symtab, int (*check) (Node *n)) {
Node *n;
List *inherit;
Hash *sym = Getattr(symtab, "csymtab");
@@ -890,7 +890,7 @@ static Node *_symbol_lookup(String *name, Symtab *symtab, int (*check) (Node *n)
return 0;
}
-static Node *symbol_lookup(String_or_char *name, Symtab *symtab, int (*check) (Node *n)) {
+static Node *symbol_lookup(const_String_or_char_ptr name, Symtab *symtab, int (*check) (Node *n)) {
Node *n = 0;
if (DohCheck(name)) {
n = _symbol_lookup(name, symtab, check);
@@ -908,7 +908,7 @@ static Node *symbol_lookup(String_or_char *name, Symtab *symtab, int (*check) (N
* symbol_lookup_qualified()
* ----------------------------------------------------------------------------- */
-static Node *symbol_lookup_qualified(String_or_char *name, Symtab *symtab, String *prefix, int local, int (*checkfunc) (Node *n)) {
+static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symtab, const String *prefix, int local, int (*checkfunc) (Node *n)) {
/* This is a little funky, we search by fully qualified names */
if (!symtab)
@@ -928,6 +928,7 @@ static Node *symbol_lookup_qualified(String_or_char *name, Symtab *symtab, Strin
/* Make qualified name of current scope */
String *qalloc = 0;
String *qname = Swig_symbol_qualifiedscopename(symtab);
+ const String *cqname;
if (qname) {
if (Len(qname)) {
if (prefix && Len(prefix)) {
@@ -937,10 +938,11 @@ static Node *symbol_lookup_qualified(String_or_char *name, Symtab *symtab, Strin
Append(qname, prefix);
}
qalloc = qname;
+ cqname = qname;
} else {
- qname = prefix;
+ cqname = prefix;
}
- st = Getattr(symtabs, qname);
+ st = Getattr(symtabs, cqname);
/* Found a scope match */
if (st) {
if (!name) {
@@ -974,7 +976,7 @@ static Node *symbol_lookup_qualified(String_or_char *name, Symtab *symtab, Strin
* to get the real node.
* ----------------------------------------------------------------------------- */
-Node *Swig_symbol_clookup(String_or_char *name, Symtab *n) {
+Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) {
Hash *hsym = 0;
Node *s = 0;
@@ -1046,7 +1048,7 @@ Node *Swig_symbol_clookup(String_or_char *name, Symtab *n) {
* inheritance hierarchy.
* ----------------------------------------------------------------------------- */
-Node *Swig_symbol_clookup_check(String_or_char *name, Symtab *n, int (*checkfunc) (Node *n)) {
+Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *n)) {
Hash *hsym = 0;
Node *s = 0;
@@ -1110,7 +1112,7 @@ Node *Swig_symbol_clookup_check(String_or_char *name, Symtab *n, int (*checkfunc
* Swig_symbol_clookup_local()
* ----------------------------------------------------------------------------- */
-Node *Swig_symbol_clookup_local(String_or_char *name, Symtab *n) {
+Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) {
Hash *h, *hsym;
Node *s = 0;
@@ -1158,7 +1160,7 @@ Node *Swig_symbol_clookup_local(String_or_char *name, Symtab *n) {
* Swig_symbol_clookup_local_check()
* ----------------------------------------------------------------------------- */
-Node *Swig_symbol_clookup_local_check(String_or_char *name, Symtab *n, int (*checkfunc) (Node *)) {
+Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *)) {
Hash *h, *hsym;
Node *s = 0;
@@ -1209,7 +1211,7 @@ Node *Swig_symbol_clookup_local_check(String_or_char *name, Symtab *n, int (*che
* Look up a scope name.
* ----------------------------------------------------------------------------- */
-Symtab *Swig_symbol_cscope(String_or_char *name, Symtab *symtab) {
+Symtab *Swig_symbol_cscope(const_String_or_char_ptr name, Symtab *symtab) {
char *cname = Char(name);
if (strncmp(cname, "::", 2) == 0)
return symbol_lookup_qualified(0, global_scope, name, 0, 0);
diff --git a/Source/Swig/tree.c b/Source/Swig/tree.c
index 61dca8353..14d231afa 100644
--- a/Source/Swig/tree.c
+++ b/Source/Swig/tree.c
@@ -229,7 +229,7 @@ Node *copyNode(Node *n) {
* checkAttribute()
* ----------------------------------------------------------------------------- */
-int checkAttribute(Node *n, const String_or_char *name, const String_or_char *value) {
+int checkAttribute(Node *n, const_String_or_char_ptr name, const_String_or_char_ptr value) {
String *v = Getattr(n, name);
return v ? Equal(v, value) : 0;
}
diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c
index 6cbeb67ea..401a99801 100644
--- a/Source/Swig/typemap.c
+++ b/Source/Swig/typemap.c
@@ -107,7 +107,7 @@ void Swig_typemap_init() {
tm_scope = 0;
}
-static String *tmop_name(const String_or_char *op) {
+static String *tmop_name(const_String_or_char_ptr op) {
static Hash *names = 0;
String *s;
/* Due to "interesting" object-identity semantics of DOH,
@@ -164,7 +164,7 @@ Hash *Swig_typemap_pop_scope() {
* Add a new multi-valued typemap
* ----------------------------------------------------------------------------- */
-void Swig_typemap_register(const String_or_char *op, ParmList *parms, String_or_char *code, ParmList *locals, ParmList *kwargs) {
+void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs) {
Hash *tm;
Hash *tm1;
Hash *tm2;
@@ -270,7 +270,7 @@ void Swig_typemap_register(const String_or_char *op, ParmList *parms, String_or_
* Retrieve typemap information from current scope.
* ----------------------------------------------------------------------------- */
-static Hash *Swig_typemap_get(SwigType *type, String_or_char *name, int scope) {
+static Hash *Swig_typemap_get(SwigType *type, const_String_or_char_ptr name, int scope) {
Hash *tm, *tm1;
/* See if this type has been seen before */
if ((scope < 0) || (scope > tm_scope))
@@ -292,7 +292,7 @@ static Hash *Swig_typemap_get(SwigType *type, String_or_char *name, int scope) {
* Copy a typemap
* ----------------------------------------------------------------------------- */
-int Swig_typemap_copy(const String_or_char *op, ParmList *srcparms, ParmList *parms) {
+int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList *parms) {
Hash *tm = 0;
String *tmop;
Parm *p;
@@ -347,7 +347,7 @@ int Swig_typemap_copy(const String_or_char *op, ParmList *srcparms, ParmList *pa
* Delete a multi-valued typemap
* ----------------------------------------------------------------------------- */
-void Swig_typemap_clear(const String_or_char *op, ParmList *parms) {
+void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) {
SwigType *type;
String *name;
Parm *p;
@@ -590,7 +590,7 @@ static SwigType *strip_arrays(SwigType *type) {
* that includes a 'code' attribute.
* ----------------------------------------------------------------------------- */
-Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, const String_or_char *name, SwigType **matchtype) {
+Hash *Swig_typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr name, SwigType **matchtype) {
Hash *result = 0, *tm, *tm1, *tma;
Hash *backup = 0;
SwigType *noarrays = 0;
@@ -737,7 +737,7 @@ ret_result:
* Search for a multi-valued typemap.
* ----------------------------------------------------------------------------- */
-Hash *Swig_typemap_search_multi(const String_or_char *op, ParmList *parms, int *nmatch) {
+Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch) {
SwigType *type;
SwigType *mtype = 0;
String *name;
@@ -1173,7 +1173,7 @@ static void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) {
* $1 in the out typemap will be replaced by the code in actioncode.
* ----------------------------------------------------------------------------- */
-static String *Swig_typemap_lookup_impl(const String_or_char *op, Node *node, const String_or_char *lname, Wrapper *f, String *actioncode) {
+static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) {
SwigType *type;
SwigType *mtype = 0;
String *pname;
@@ -1384,13 +1384,13 @@ static String *Swig_typemap_lookup_impl(const String_or_char *op, Node *node, co
return s;
}
-String *Swig_typemap_lookup_out(const String_or_char *op, Node *node, const String_or_char *lname, Wrapper *f, String *actioncode) {
+String *Swig_typemap_lookup_out(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) {
assert(actioncode);
assert(Cmp(op, "out") == 0);
return Swig_typemap_lookup_impl(op, node, lname, f, actioncode);
}
-String *Swig_typemap_lookup(const String_or_char *op, Node *node, const String_or_char *lname, Wrapper *f) {
+String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f) {
return Swig_typemap_lookup_impl(op, node, lname, f, 0);
}
@@ -1406,7 +1406,7 @@ String *Swig_typemap_lookup(const String_or_char *op, Node *node, const String_o
* A new attribute called "tmap:in:foo" with value "xyz" is attached to p.
* ----------------------------------------------------------------------------- */
-void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p) {
+void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p) {
String *temp = NewStringEmpty();
Parm *kw = Getattr(tm, "kwargs");
while (kw) {
@@ -1438,7 +1438,7 @@ void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p) {
* attribute, print that warning message.
* ----------------------------------------------------------------------------- */
-static void Swig_typemap_warn(const String_or_char *op, Parm *p) {
+static void Swig_typemap_warn(const_String_or_char_ptr op, Parm *p) {
String *temp = NewStringf("%s:warning", op);
String *w = Getattr(p, tmop_name(temp));
Delete(temp);
@@ -1447,7 +1447,7 @@ static void Swig_typemap_warn(const String_or_char *op, Parm *p) {
}
}
-static void Swig_typemap_emit_code_fragments(const String_or_char *op, Parm *p) {
+static void Swig_typemap_emit_code_fragments(const_String_or_char_ptr op, Parm *p) {
String *temp = NewStringf("%s:fragment", op);
String *f = Getattr(p, tmop_name(temp));
if (f) {
@@ -1467,7 +1467,7 @@ static void Swig_typemap_emit_code_fragments(const String_or_char *op, Parm *p)
* given typemap type
* ----------------------------------------------------------------------------- */
-String *Swig_typemap_get_option(Hash *tm, String *name) {
+String *Swig_typemap_get_option(Hash *tm, const_String_or_char_ptr name) {
Parm *kw = Getattr(tm, "kwargs");
while (kw) {
String *kname = Getattr(kw, "name");
@@ -1479,7 +1479,7 @@ String *Swig_typemap_get_option(Hash *tm, String *name) {
return 0;
}
-void Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f) {
+void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wrapper *f) {
Parm *p, *firstp;
Hash *tm;
int nmatch = 0;
diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c
index 18d1b2304..8ff31bc0b 100644
--- a/Source/Swig/typeobj.c
+++ b/Source/Swig/typeobj.c
@@ -110,7 +110,7 @@ char cvsroot_typeobj_c[] = "$Id$";
* ----------------------------------------------------------------------------- */
#ifdef NEW
-SwigType *NewSwigType(const String_or_char *initial) {
+SwigType *NewSwigType(const_String_or_char_ptr initial) {
return NewString(initial);
}
@@ -419,7 +419,7 @@ int SwigType_isreference(SwigType *t) {
* stored in exactly the same way as "q(const volatile)".
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
+SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) {
char temp[256], newq[256];
int sz, added = 0;
char *q, *cqual;
@@ -537,7 +537,7 @@ SwigType *SwigType_functionpointer_decompose(SwigType *t) {
* Add, remove, and test for C++ pointer to members.
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *name) {
+SwigType *SwigType_add_memberpointer(SwigType *t, const_String_or_char_ptr name) {
String *temp = NewStringf("m(%s).", name);
Insert(t, 0, temp);
Delete(temp);
@@ -579,7 +579,7 @@ int SwigType_ismemberpointer(SwigType *t) {
* SwigType_pop_arrays() - Remove all arrays
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_add_array(SwigType *t, const String_or_char *size) {
+SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size) {
char temp[512];
strcpy(temp, "a(");
strcat(temp, Char(size));
@@ -673,7 +673,7 @@ String *SwigType_array_getdim(SwigType *t, int n) {
}
/* Replace nth array dimension */
-void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep) {
+void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) {
String *result = 0;
char temp;
char *start;
diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c
index a9e2898bd..2562e12f8 100644
--- a/Source/Swig/typesys.c
+++ b/Source/Swig/typesys.c
@@ -163,7 +163,7 @@ void SwigType_typesystem_init() {
* already defined.
* ----------------------------------------------------------------------------- */
-int SwigType_typedef(SwigType *type, String_or_char *name) {
+int SwigType_typedef(SwigType *type, const_String_or_char_ptr name) {
if (Getattr(current_typetab, name))
return -1; /* Already defined */
if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */
@@ -193,7 +193,7 @@ int SwigType_typedef(SwigType *type, String_or_char *name) {
* Defines a class in the current scope.
* ----------------------------------------------------------------------------- */
-int SwigType_typedef_class(String_or_char *name) {
+int SwigType_typedef_class(const_String_or_char_ptr name) {
String *cname;
/* Printf(stdout,"class : '%s'\n", name); */
if (Getattr(current_typetab, name))
@@ -232,7 +232,7 @@ String *SwigType_scope_name(Typetab *ttab) {
* Creates a new scope
* ----------------------------------------------------------------------------- */
-void SwigType_new_scope(const String_or_char *name) {
+void SwigType_new_scope(const_String_or_char_ptr name) {
Typetab *s;
Hash *ttab;
String *qname;
@@ -539,7 +539,7 @@ static SwigType *typedef_resolve(Typetab *s, String *base) {
* ----------------------------------------------------------------------------- */
/* #define SWIG_DEBUG */
-SwigType *SwigType_typedef_resolve(SwigType *t) {
+SwigType *SwigType_typedef_resolve(const SwigType *t) {
String *base;
String *type = 0;
String *r = 0;
@@ -840,6 +840,7 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
*
* Given a type declaration, this function tries to fully qualify it according to
* typedef scope rules.
+ * Inconsistency to be fixed: ::Foo returns ::Foo, whereas ::Foo * returns Foo *
* ----------------------------------------------------------------------------- */
SwigType *SwigType_typedef_qualified(SwigType *t) {
@@ -1071,7 +1072,7 @@ int SwigType_istypedef(SwigType *t) {
* Name is a qualified name like A::B.
* ----------------------------------------------------------------------------- */
-int SwigType_typedef_using(String_or_char *name) {
+int SwigType_typedef_using(const_String_or_char_ptr name) {
String *base;
String *td;
String *prefix;
@@ -1415,7 +1416,7 @@ static Hash *r_remembered = 0; /* Hash of types we remembered already */
static void (*r_tracefunc) (SwigType *t, String *mangled, String *clientdata) = 0;
-void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata) {
+void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata) {
if (!r_mangleddata) {
r_mangleddata = NewHash();
}
@@ -1423,7 +1424,7 @@ void SwigType_remember_mangleddata(String *mangled, const String_or_char *client
}
-void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata) {
+void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata) {
String *mt;
SwigType *lt;
Hash *h;
diff --git a/Source/Swig/wrapfunc.c b/Source/Swig/wrapfunc.c
index 3778066ce..11518bfc2 100644
--- a/Source/Swig/wrapfunc.c
+++ b/Source/Swig/wrapfunc.c
@@ -23,7 +23,7 @@ static int Max_line_size = 128;
* Create a new wrapper function object.
* ----------------------------------------------------------------------------- */
-Wrapper *NewWrapper() {
+Wrapper *NewWrapper(void) {
Wrapper *w;
w = (Wrapper *) malloc(sizeof(Wrapper));
w->localh = NewHash();
@@ -406,7 +406,7 @@ void Wrapper_print(Wrapper *w, File *f) {
* present (which may or may not be okay to the caller).
* ----------------------------------------------------------------------------- */
-int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) {
+int Wrapper_add_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl) {
/* See if the local has already been declared */
if (Getattr(w->localh, name)) {
return -1;
@@ -424,7 +424,7 @@ int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_ch
* to manually construct the 'decl' string before calling.
* ----------------------------------------------------------------------------- */
-int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) {
+int Wrapper_add_localv(Wrapper *w, const_String_or_char_ptr name, ...) {
va_list ap;
int ret;
String *decl;
@@ -451,7 +451,7 @@ int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) {
* Check to see if a local name has already been declared
* ----------------------------------------------------------------------------- */
-int Wrapper_check_local(Wrapper *w, const String_or_char *name) {
+int Wrapper_check_local(Wrapper *w, const_String_or_char_ptr name) {
if (Getattr(w->localh, name)) {
return 1;
}
@@ -465,7 +465,7 @@ int Wrapper_check_local(Wrapper *w, const String_or_char *name) {
* used. Returns the name that was actually selected.
* ----------------------------------------------------------------------------- */
-char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) {
+char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl) {
int i;
String *nname = NewString(name);
String *ndecl = NewString(decl);
@@ -496,7 +496,7 @@ char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_
* to manually construct the 'decl' string before calling.
* ----------------------------------------------------------------------------- */
-char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...) {
+char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...) {
va_list ap;
char *ret;
String *decl;