Merge trunk rev 13025 (swig-2.0.6) into gsoc2008-maciekd
Conflicts: Doc/Manual/chapters Examples/Makefile.in Examples/test-suite/dynamic_cast.i Lib/exception.i Makefile.in Source/Include/swigwarn.h Source/Modules/swigmain.cxx Source/Swig/swig.h Tools/config/config.guess Tools/config/config.sub configure.in From: William S Fulton <wsf@fultondesigns.co.uk> git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@13036 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
e0067ea998
2152 changed files with 99389 additions and 53536 deletions
|
|
@ -1,14 +1,16 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* cparse.h
|
||||
*
|
||||
* SWIG parser module.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef SWIG_CPARSE_H_
|
||||
#define SWIG_CPARSE_H_
|
||||
|
||||
|
|
@ -34,16 +36,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);
|
||||
|
||||
|
|
@ -51,7 +55,7 @@ extern "C" {
|
|||
extern void Swig_cparse_replace_descriptor(String *s);
|
||||
extern void cparse_normalize_void(Node *);
|
||||
extern Parm *Swig_cparse_parm(String *s);
|
||||
extern ParmList *Swig_cparse_parms(String *s);
|
||||
extern ParmList *Swig_cparse_parms(String *s, Node *file_line_node);
|
||||
|
||||
|
||||
/* templ.c */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* scanner.c
|
||||
*
|
||||
|
|
@ -22,7 +26,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;
|
||||
|
|
@ -38,8 +45,6 @@ static int num_brace = 0;
|
|||
static int last_brace = 0;
|
||||
static int last_id = 0;
|
||||
static int rename_active = 0;
|
||||
static int expanding_macro = 0;
|
||||
static int follow_locators = 0;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_cparse_cplusplus()
|
||||
|
|
@ -49,101 +54,6 @@ void Swig_cparse_cplusplus(int v) {
|
|||
cparse_cplusplus = v;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* locator()
|
||||
*
|
||||
* Support for locator strings. These are strings of the form
|
||||
* @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They
|
||||
* are primarily used for macro line number reporting
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
typedef struct Locator {
|
||||
String *filename;
|
||||
int line_number;
|
||||
struct Locator *next;
|
||||
} Locator;
|
||||
|
||||
static Locator *locs = 0;
|
||||
|
||||
/* we just use the locator to mark when active/deactive the linecounting */
|
||||
|
||||
static void scanner_locator(String *loc) {
|
||||
if (!follow_locators) {
|
||||
if (Equal(loc, "/*@SWIG@*/")) {
|
||||
/* End locator. */
|
||||
if (expanding_macro)
|
||||
--expanding_macro;
|
||||
} else {
|
||||
/* Begin locator. */
|
||||
++expanding_macro;
|
||||
}
|
||||
/* Freeze line number processing in Scanner */
|
||||
Scanner_freeze_line(scan,expanding_macro);
|
||||
} else {
|
||||
int c;
|
||||
Locator *l;
|
||||
Seek(loc, 7, SEEK_SET);
|
||||
c = Getc(loc);
|
||||
if (c == '@') {
|
||||
/* Empty locator. We pop the last location off */
|
||||
if (locs) {
|
||||
Scanner_set_location(scan,locs->filename,locs->line_number);
|
||||
cparse_file = locs->filename;
|
||||
cparse_line = locs->line_number;
|
||||
l = locs->next;
|
||||
free(locs);
|
||||
locs = l;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* We're going to push a new location */
|
||||
l = (Locator *) malloc(sizeof(Locator));
|
||||
l->filename = cparse_file;
|
||||
l->line_number = cparse_line;
|
||||
l->next = locs;
|
||||
locs = l;
|
||||
|
||||
/* Now, parse the new location out of the locator string */
|
||||
{
|
||||
String *fn = NewStringEmpty();
|
||||
/* Putc(c, fn); */
|
||||
|
||||
while ((c = Getc(loc)) != EOF) {
|
||||
if ((c == '@') || (c == ','))
|
||||
break;
|
||||
Putc(c, fn);
|
||||
}
|
||||
cparse_file = Swig_copy_string(Char(fn));
|
||||
Clear(fn);
|
||||
cparse_line = 1;
|
||||
/* Get the line number */
|
||||
while ((c = Getc(loc)) != EOF) {
|
||||
if ((c == '@') || (c == ','))
|
||||
break;
|
||||
Putc(c, fn);
|
||||
}
|
||||
cparse_line = atoi(Char(fn));
|
||||
Clear(fn);
|
||||
|
||||
/* Get the rest of it */
|
||||
while ((c = Getc(loc)) != EOF) {
|
||||
if (c == '@')
|
||||
break;
|
||||
Putc(c, fn);
|
||||
}
|
||||
/* Printf(stderr,"location: %s:%d\n",cparse_file,cparse_line); */
|
||||
Scanner_set_location(scan,cparse_file,cparse_line);
|
||||
Delete(fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Swig_cparse_follow_locators(int v) {
|
||||
follow_locators = v;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* scanner_init()
|
||||
*
|
||||
|
|
@ -254,17 +164,15 @@ void skip_decl(void) {
|
|||
* Lexical scanner.
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
int yylook(void) {
|
||||
static int yylook(void) {
|
||||
|
||||
int tok = 0;
|
||||
|
||||
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);
|
||||
|
|
@ -409,6 +317,9 @@ int yylook(void) {
|
|||
case SWIG_TOKEN_FLOAT:
|
||||
return NUM_FLOAT;
|
||||
|
||||
case SWIG_TOKEN_BOOL:
|
||||
return NUM_BOOL;
|
||||
|
||||
case SWIG_TOKEN_POUND:
|
||||
Scanner_skip_line(scan);
|
||||
yylval.id = Swig_copy_string(Char(Scanner_text(scan)));
|
||||
|
|
@ -423,8 +334,8 @@ int yylook(void) {
|
|||
{
|
||||
String *cmt = Scanner_text(scan);
|
||||
char *loc = Char(cmt);
|
||||
if ((strncmp(loc,"/*@SWIG@",6) == 0) && (loc[Len(cmt)-3] == '@')) {
|
||||
scanner_locator(cmt);
|
||||
if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) {
|
||||
Scanner_locator(scan, cmt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -441,7 +352,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 +378,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()
|
||||
*
|
||||
|
|
@ -490,7 +409,7 @@ int yylex(void) {
|
|||
|
||||
l = yylook();
|
||||
|
||||
/* Printf(stdout, "%s:%d:::%d: '%s'\n", cparse_file, cparse_line, l, Scanner_text(scan)); */
|
||||
/* Swig_diagnostic(cparse_file, cparse_line, ":::%d: '%s'\n", l, Scanner_text(scan)); */
|
||||
|
||||
if (l == NONID) {
|
||||
last_id = 1;
|
||||
|
|
@ -516,6 +435,7 @@ int yylex(void) {
|
|||
case NUM_UNSIGNED:
|
||||
case NUM_LONGLONG:
|
||||
case NUM_ULONGLONG:
|
||||
case NUM_BOOL:
|
||||
if (l == NUM_INT)
|
||||
yylval.dtype.type = T_INT;
|
||||
if (l == NUM_FLOAT)
|
||||
|
|
@ -530,6 +450,8 @@ int yylex(void) {
|
|||
yylval.dtype.type = T_LONGLONG;
|
||||
if (l == NUM_ULONGLONG)
|
||||
yylval.dtype.type = T_ULONGLONG;
|
||||
if (l == NUM_BOOL)
|
||||
yylval.dtype.type = T_BOOL;
|
||||
yylval.dtype.val = NewString(Scanner_text(scan));
|
||||
yylval.dtype.bitfield = 0;
|
||||
yylval.dtype.throws = 0;
|
||||
|
|
@ -690,10 +612,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," ");
|
||||
|
|
@ -760,7 +694,7 @@ int yylex(void) {
|
|||
if (strcmp(yytext, "typename") == 0)
|
||||
return (TYPENAME);
|
||||
if (strcmp(yytext, "template") == 0) {
|
||||
yylval.ivalue = cparse_line;
|
||||
yylval.intvalue = cparse_line;
|
||||
return (TEMPLATE);
|
||||
}
|
||||
if (strcmp(yytext, "delete") == 0) {
|
||||
|
|
@ -802,7 +736,7 @@ int yylex(void) {
|
|||
return (SIZEOF);
|
||||
|
||||
if (strcmp(yytext, "typedef") == 0) {
|
||||
yylval.ivalue = 0;
|
||||
yylval.intvalue = 0;
|
||||
return (TYPEDEF);
|
||||
}
|
||||
|
||||
|
|
@ -833,6 +767,10 @@ int yylex(void) {
|
|||
}
|
||||
if (strcmp(yytext, "%includefile") == 0)
|
||||
return (INCLUDE);
|
||||
if (strcmp(yytext, "%beginfile") == 0)
|
||||
return (BEGINFILE);
|
||||
if (strcmp(yytext, "%endoffile") == 0)
|
||||
return (ENDOFFILE);
|
||||
if (strcmp(yytext, "%val") == 0) {
|
||||
Swig_warning(WARN_DEPRECATED_VAL, cparse_file, cparse_line, "%%val directive deprecated (ignored).\n");
|
||||
return (yylex());
|
||||
|
|
@ -844,7 +782,7 @@ int yylex(void) {
|
|||
if (strcmp(yytext, "%constant") == 0)
|
||||
return (CONSTANT);
|
||||
if (strcmp(yytext, "%typedef") == 0) {
|
||||
yylval.ivalue = 1;
|
||||
yylval.intvalue = 1;
|
||||
return (TYPEDEF);
|
||||
}
|
||||
if (strcmp(yytext, "%native") == 0)
|
||||
|
|
@ -859,8 +797,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)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* templ.c
|
||||
*
|
||||
|
|
@ -15,7 +19,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";
|
||||
|
|
@ -167,18 +171,21 @@ static int cparse_template_expand(Node *n, String *tname, String *rname, String
|
|||
add_parms(Getattr(n, "throws"), cpatchlist, typelist);
|
||||
} else if (Equal(nodeType, "destructor")) {
|
||||
String *name = Getattr(n, "name");
|
||||
if (name && strchr(Char(name), '<')) {
|
||||
Append(patchlist, Getattr(n, "name"));
|
||||
} else {
|
||||
Append(name, templateargs);
|
||||
if (name) {
|
||||
if (strchr(Char(name), '<'))
|
||||
Append(patchlist, Getattr(n, "name"));
|
||||
else
|
||||
Append(name, templateargs);
|
||||
}
|
||||
name = Getattr(n, "sym:name");
|
||||
if (name && strchr(Char(name), '<')) {
|
||||
String *sn = Copy(tname);
|
||||
Setattr(n, "sym:name", sn);
|
||||
Delete(sn);
|
||||
} else {
|
||||
Replace(name, tname, rname, DOH_REPLACE_ANY);
|
||||
if (name) {
|
||||
if (strchr(Char(name), '<')) {
|
||||
String *sn = Copy(tname);
|
||||
Setattr(n, "sym:name", sn);
|
||||
Delete(sn);
|
||||
} else {
|
||||
Replace(name, tname, rname, DOH_REPLACE_ANY);
|
||||
}
|
||||
}
|
||||
/* Setattr(n,"sym:name",name); */
|
||||
Append(cpatchlist, Getattr(n, "code"));
|
||||
|
|
@ -259,7 +266,7 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab
|
|||
/* Look for partial specialization matching */
|
||||
if (Getattr(n, "partialargs")) {
|
||||
Parm *p, *tp;
|
||||
ParmList *ptargs = SwigType_function_parms(Getattr(n, "partialargs"));
|
||||
ParmList *ptargs = SwigType_function_parms(Getattr(n, "partialargs"), n);
|
||||
p = ptargs;
|
||||
tp = tparms;
|
||||
while (p && tp) {
|
||||
|
|
@ -281,13 +288,13 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab
|
|||
Delete(ptargs);
|
||||
}
|
||||
|
||||
if (0) {
|
||||
/*
|
||||
Parm *p = tparms;
|
||||
while (p) {
|
||||
Printf(stdout, "tparm: '%s' '%s' '%s'\n", Getattr(p, "name"), Getattr(p, "type"), Getattr(p, "value"));
|
||||
p = nextSibling(p);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/* Printf(stdout,"targs = '%s'\n", templateargs);
|
||||
Printf(stdout,"rname = '%s'\n", rname);
|
||||
|
|
@ -419,6 +426,70 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab
|
|||
return 0;
|
||||
}
|
||||
|
||||
typedef enum { ExactNoMatch = -2, PartiallySpecializedNoMatch = -1, PartiallySpecializedMatch = 1, ExactMatch = 2 } EMatch;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* does_parm_match()
|
||||
*
|
||||
* Template argument deduction - check if a template type matches a partially specialized
|
||||
* template parameter type. Typedef reduce 'partial_parm_type' to see if it matches 'type'.
|
||||
*
|
||||
* type - template parameter type to match against
|
||||
* partial_parm_type - partially specialized template type - a possible match
|
||||
* partial_parm_type_base - base type of partial_parm_type
|
||||
* tscope - template scope
|
||||
* specialization_priority - (output) contains a value indicating how good the match is
|
||||
* (higher is better) only set if return is set to PartiallySpecializedMatch or ExactMatch.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static EMatch does_parm_match(SwigType *type, SwigType *partial_parm_type, const char *partial_parm_type_base, Symtab *tscope, int *specialization_priority) {
|
||||
static const int EXACT_MATCH_PRIORITY = 99999; /* a number bigger than the length of any conceivable type */
|
||||
int matches;
|
||||
int substitutions;
|
||||
EMatch match;
|
||||
SwigType *ty = Swig_symbol_typedef_reduce(type, tscope);
|
||||
String *base = SwigType_base(ty);
|
||||
SwigType *t = Copy(partial_parm_type);
|
||||
substitutions = Replaceid(t, partial_parm_type_base, base); /* eg: Replaceid("p.$1", "$1", "int") returns t="p.int" */
|
||||
matches = Equal(ty, t);
|
||||
*specialization_priority = -1;
|
||||
if (substitutions == 1) {
|
||||
/* we have a non-explicit specialized parameter (in partial_parm_type) because a substitution for $1, $2... etc has taken place */
|
||||
SwigType *tt = Copy(partial_parm_type);
|
||||
int len;
|
||||
/*
|
||||
check for match to partial specialization type, for example, all of the following could match the type in the %template:
|
||||
template <typename T> struct XX {};
|
||||
template <typename T> struct XX<T &> {}; // r.$1
|
||||
template <typename T> struct XX<T const&> {}; // r.q(const).$1
|
||||
template <typename T> struct XX<T *const&> {}; // r.q(const).p.$1
|
||||
%template(XXX) XX<int *const&>; // r.q(const).p.int
|
||||
|
||||
where type="r.q(const).p.int" will match either of tt="r.", tt="r.q(const)" tt="r.q(const).p"
|
||||
*/
|
||||
Replaceid(tt, partial_parm_type_base, ""); /* remove the $1, $2 etc, eg tt="p.$1" => "p." */
|
||||
len = Len(tt);
|
||||
if (Strncmp(tt, ty, len) == 0) {
|
||||
match = PartiallySpecializedMatch;
|
||||
*specialization_priority = len;
|
||||
} else {
|
||||
match = PartiallySpecializedNoMatch;
|
||||
}
|
||||
Delete(tt);
|
||||
} else {
|
||||
match = matches ? ExactMatch : ExactNoMatch;
|
||||
if (matches)
|
||||
*specialization_priority = EXACT_MATCH_PRIORITY; /* exact matches always take precedence */
|
||||
}
|
||||
/*
|
||||
Printf(stdout, " does_parm_match %2d %5d [%s] [%s]\n", match, *specialization_priority, type, partial_parm_type);
|
||||
*/
|
||||
Delete(t);
|
||||
Delete(base);
|
||||
Delete(ty);
|
||||
return match;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* template_locate()
|
||||
*
|
||||
|
|
@ -426,175 +497,294 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) {
|
||||
Node *n;
|
||||
String *tname, *rname = 0;
|
||||
Node *n = 0;
|
||||
String *tname = 0;
|
||||
Node *templ;
|
||||
List *mpartials = 0;
|
||||
Symtab *primary_scope = 0;
|
||||
List *possiblepartials = 0;
|
||||
Parm *p;
|
||||
Parm *parms;
|
||||
Parm *parms = 0;
|
||||
Parm *targs;
|
||||
ParmList *expandedparms;
|
||||
int *priorities_matrix = 0;
|
||||
int max_possible_partials = 0;
|
||||
int posslen = 0;
|
||||
|
||||
tname = Copy(name);
|
||||
parms = CopyParmList(tparms);
|
||||
|
||||
/* Search for generic template */
|
||||
/* Search for primary (unspecialized) template */
|
||||
templ = Swig_symbol_clookup(name, 0);
|
||||
|
||||
/* Add default values from generic template */
|
||||
if (templ) {
|
||||
Symtab *tsdecl = Getattr(templ, "sym:symtab");
|
||||
if (template_debug) {
|
||||
tname = Copy(name);
|
||||
SwigType_add_template(tname, tparms);
|
||||
Printf(stdout, "\n");
|
||||
Swig_diagnostic(cparse_file, cparse_line, "template_debug: Searching for match to: '%s'\n", tname);
|
||||
Delete(tname);
|
||||
tname = 0;
|
||||
}
|
||||
|
||||
if (templ) {
|
||||
tname = Copy(name);
|
||||
parms = CopyParmList(tparms);
|
||||
|
||||
/* All template specializations must be in the primary template's scope, store the symbol table for this scope for specialization lookups */
|
||||
primary_scope = Getattr(templ, "sym:symtab");
|
||||
|
||||
/* Add default values from primary template */
|
||||
targs = Getattr(templ, "templateparms");
|
||||
expandedparms = Swig_symbol_template_defargs(parms, targs, tscope, tsdecl);
|
||||
} else {
|
||||
expandedparms = parms;
|
||||
}
|
||||
expandedparms = Swig_symbol_template_defargs(parms, targs, tscope, primary_scope);
|
||||
|
||||
|
||||
/* reduce the typedef */
|
||||
p = expandedparms;
|
||||
while (p) {
|
||||
SwigType *ty = Getattr(p, "type");
|
||||
if (ty) {
|
||||
SwigType *nt = Swig_symbol_type_qualify(ty, tscope);
|
||||
Setattr(p, "type", nt);
|
||||
Delete(nt);
|
||||
}
|
||||
p = nextSibling(p);
|
||||
}
|
||||
|
||||
SwigType_add_template(tname, expandedparms);
|
||||
|
||||
if (template_debug) {
|
||||
Printf(stdout, "\n%s:%d: template_debug: Searching for %s\n", cparse_file, cparse_line, tname);
|
||||
}
|
||||
|
||||
/* Search for an exact specialization.
|
||||
Example: template<> class name<int> { ... } */
|
||||
{
|
||||
if (template_debug) {
|
||||
Printf(stdout, " searching: '%s' (exact specialization)\n", tname);
|
||||
}
|
||||
n = Swig_symbol_clookup_local(tname, 0);
|
||||
if (!n) {
|
||||
SwigType *rname = Swig_symbol_typedef_reduce(tname, tscope);
|
||||
if (!Equal(rname, tname)) {
|
||||
if (template_debug) {
|
||||
Printf(stdout, " searching: '%s' (exact specialization)\n", rname);
|
||||
}
|
||||
n = Swig_symbol_clookup_local(rname, 0);
|
||||
/* reduce the typedef */
|
||||
p = expandedparms;
|
||||
while (p) {
|
||||
SwigType *ty = Getattr(p, "type");
|
||||
if (ty) {
|
||||
SwigType *nt = Swig_symbol_type_qualify(ty, tscope);
|
||||
Setattr(p, "type", nt);
|
||||
Delete(nt);
|
||||
}
|
||||
Delete(rname);
|
||||
p = nextSibling(p);
|
||||
}
|
||||
if (n) {
|
||||
Node *tn;
|
||||
String *nodeType = nodeType(n);
|
||||
if (Equal(nodeType, "template"))
|
||||
goto success;
|
||||
tn = Getattr(n, "template");
|
||||
if (tn) {
|
||||
n = tn;
|
||||
goto success; /* Previously wrapped by a template return that */
|
||||
SwigType_add_template(tname, expandedparms);
|
||||
|
||||
/* Search for an explicit (exact) specialization. Example: template<> class name<int> { ... } */
|
||||
{
|
||||
if (template_debug) {
|
||||
Printf(stdout, " searching for : '%s' (explicit specialization)\n", tname);
|
||||
}
|
||||
Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, nodeType(n));
|
||||
Delete(tname);
|
||||
Delete(parms);
|
||||
return 0; /* Found a match, but it's not a template of any kind. */
|
||||
}
|
||||
}
|
||||
|
||||
/* Search for partial specialization.
|
||||
Example: template<typename T> class name<T *> { ... } */
|
||||
|
||||
/* Generate reduced template name (stripped of extraneous pointers, etc.) */
|
||||
|
||||
rname = NewStringf("%s<(", name);
|
||||
p = parms;
|
||||
while (p) {
|
||||
String *t;
|
||||
t = Getattr(p, "type");
|
||||
if (!t)
|
||||
t = Getattr(p, "value");
|
||||
if (t) {
|
||||
String *ty = Swig_symbol_typedef_reduce(t, tscope);
|
||||
String *tb = SwigType_base(ty);
|
||||
String *td = SwigType_default(ty);
|
||||
Replaceid(td, "enum SWIGTYPE", tb);
|
||||
Replaceid(td, "SWIGTYPE", tb);
|
||||
Append(rname, td);
|
||||
Delete(tb);
|
||||
Delete(ty);
|
||||
Delete(td);
|
||||
}
|
||||
p = nextSibling(p);
|
||||
if (p) {
|
||||
Append(rname, ",");
|
||||
}
|
||||
}
|
||||
Append(rname, ")>");
|
||||
|
||||
mpartials = NewList();
|
||||
if (templ) {
|
||||
/* First, we search using an exact type prototype */
|
||||
Parm *p;
|
||||
char tmp[32];
|
||||
int i;
|
||||
List *partials;
|
||||
String *ss;
|
||||
Iterator pi;
|
||||
|
||||
partials = Getattr(templ, "partials");
|
||||
if (partials) {
|
||||
for (pi = First(partials); pi.item; pi = Next(pi)) {
|
||||
ss = Copy(pi.item);
|
||||
p = parms;
|
||||
i = 1;
|
||||
while (p) {
|
||||
String *t, *tn;
|
||||
sprintf(tmp, "$%d", i);
|
||||
t = Getattr(p, "type");
|
||||
if (!t)
|
||||
t = Getattr(p, "value");
|
||||
if (t) {
|
||||
String *ty = Swig_symbol_typedef_reduce(t, tscope);
|
||||
tn = SwigType_base(ty);
|
||||
Replaceid(ss, tmp, tn);
|
||||
Delete(tn);
|
||||
Delete(ty);
|
||||
n = Swig_symbol_clookup_local(tname, primary_scope);
|
||||
if (!n) {
|
||||
SwigType *rname = Swig_symbol_typedef_reduce(tname, tscope);
|
||||
if (!Equal(rname, tname)) {
|
||||
if (template_debug) {
|
||||
Printf(stdout, " searching for : '%s' (explicit specialization with typedef reduction)\n", rname);
|
||||
}
|
||||
i++;
|
||||
p = nextSibling(p);
|
||||
n = Swig_symbol_clookup_local(rname, primary_scope);
|
||||
}
|
||||
if (template_debug) {
|
||||
Printf(stdout, " searching: '%s' (partial specialization - %s)\n", ss, pi.item);
|
||||
}
|
||||
if ((Equal(ss, tname)) || (Equal(ss, rname))) {
|
||||
Append(mpartials, pi.item);
|
||||
}
|
||||
Delete(ss);
|
||||
Delete(rname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (template_debug) {
|
||||
Printf(stdout, " Matched partials: %s\n", mpartials);
|
||||
}
|
||||
|
||||
if (Len(mpartials)) {
|
||||
String *s = Getitem(mpartials, 0);
|
||||
n = Swig_symbol_clookup_local(s, 0);
|
||||
if (Len(mpartials) > 1) {
|
||||
if (n) {
|
||||
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, cparse_file, cparse_line, "Instantiation of template '%s' is ambiguous,\n", SwigType_namestr(tname));
|
||||
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, Getfile(n), Getline(n), " instantiation '%s' is used.\n", SwigType_namestr(Getattr(n, "name")));
|
||||
Node *tn;
|
||||
String *nodeType = nodeType(n);
|
||||
if (Equal(nodeType, "template")) {
|
||||
if (template_debug) {
|
||||
Printf(stdout, " explicit specialization found: '%s'\n", Getattr(n, "name"));
|
||||
}
|
||||
goto success;
|
||||
}
|
||||
tn = Getattr(n, "template");
|
||||
if (tn) {
|
||||
if (template_debug) {
|
||||
Printf(stdout, " previous instantiation found: '%s'\n", Getattr(n, "name"));
|
||||
}
|
||||
n = tn;
|
||||
goto success; /* Previously wrapped by a template instantiation */
|
||||
}
|
||||
Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, nodeType(n));
|
||||
Delete(tname);
|
||||
Delete(parms);
|
||||
return 0; /* Found a match, but it's not a template of any kind. */
|
||||
}
|
||||
}
|
||||
|
||||
/* Search for partial specializations.
|
||||
* Example: template<typename T> class name<T *> { ... }
|
||||
|
||||
* There are 3 types of template arguments:
|
||||
* (1) Template type arguments
|
||||
* (2) Template non type arguments
|
||||
* (3) Template template arguments
|
||||
* only (1) is really supported for partial specializations
|
||||
*/
|
||||
|
||||
/* Rank each template parameter against the desired template parameters then build a matrix of best matches */
|
||||
possiblepartials = NewList();
|
||||
{
|
||||
char tmp[32];
|
||||
List *partials;
|
||||
|
||||
partials = Getattr(templ, "partials"); /* note that these partial specializations do not include explicit specializations */
|
||||
if (partials) {
|
||||
Iterator pi;
|
||||
int parms_len = ParmList_len(parms);
|
||||
int *priorities_row;
|
||||
max_possible_partials = Len(partials);
|
||||
priorities_matrix = (int *)malloc(sizeof(int) * max_possible_partials * parms_len); /* slightly wasteful allocation for max possible matches */
|
||||
priorities_row = priorities_matrix;
|
||||
for (pi = First(partials); pi.item; pi = Next(pi)) {
|
||||
Parm *p = parms;
|
||||
int all_parameters_match = 1;
|
||||
int i = 1;
|
||||
Parm *partialparms = Getattr(pi.item, "partialparms");
|
||||
Parm *pp = partialparms;
|
||||
String *templcsymname = Getattr(pi.item, "templcsymname");
|
||||
if (template_debug) {
|
||||
Printf(stdout, " checking match: '%s' (partial specialization)\n", templcsymname);
|
||||
}
|
||||
if (ParmList_len(partialparms) == parms_len) {
|
||||
while (p && pp) {
|
||||
SwigType *t;
|
||||
sprintf(tmp, "$%d", i);
|
||||
t = Getattr(p, "type");
|
||||
if (!t)
|
||||
t = Getattr(p, "value");
|
||||
if (t) {
|
||||
EMatch match = does_parm_match(t, Getattr(pp, "type"), tmp, tscope, priorities_row + i - 1);
|
||||
if (match < (int)PartiallySpecializedMatch) {
|
||||
all_parameters_match = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
p = nextSibling(p);
|
||||
pp = nextSibling(pp);
|
||||
}
|
||||
if (all_parameters_match) {
|
||||
Append(possiblepartials, pi.item);
|
||||
priorities_row += parms_len;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
posslen = Len(possiblepartials);
|
||||
if (template_debug) {
|
||||
int i;
|
||||
if (posslen == 0)
|
||||
Printf(stdout, " matched partials: NONE\n");
|
||||
else if (posslen == 1)
|
||||
Printf(stdout, " chosen partial: '%s'\n", Getattr(Getitem(possiblepartials, 0), "templcsymname"));
|
||||
else {
|
||||
Printf(stdout, " possibly matched partials:\n");
|
||||
for (i = 0; i < posslen; i++) {
|
||||
Printf(stdout, " '%s'\n", Getattr(Getitem(possiblepartials, i), "templcsymname"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (posslen > 1) {
|
||||
/* Now go through all the possibly matched partial specialization templates and look for a non-ambiguous match.
|
||||
* Exact matches rank the highest and deduced parameters are ranked by how specialized they are, eg looking for
|
||||
* a match to const int *, the following rank (highest to lowest):
|
||||
* const int * (exact match)
|
||||
* const T *
|
||||
* T *
|
||||
* T
|
||||
*
|
||||
* An ambiguous example when attempting to match as either specialization could match: %template() X<int *, double *>;
|
||||
* template<typename T1, typename T2> X class {}; // primary template
|
||||
* template<typename T1> X<T1, double *> class {}; // specialization (1)
|
||||
* template<typename T2> X<int *, T2> class {}; // specialization (2)
|
||||
*/
|
||||
if (template_debug) {
|
||||
int row, col;
|
||||
int parms_len = ParmList_len(parms);
|
||||
Printf(stdout, " parameter priorities matrix (%d parms):\n", parms_len);
|
||||
for (row = 0; row < posslen; row++) {
|
||||
int *priorities_row = priorities_matrix + row*parms_len;
|
||||
Printf(stdout, " ");
|
||||
for (col = 0; col < parms_len; col++) {
|
||||
Printf(stdout, "%5d ", priorities_row[col]);
|
||||
}
|
||||
Printf(stdout, "\n");
|
||||
}
|
||||
}
|
||||
{
|
||||
int row, col;
|
||||
int parms_len = ParmList_len(parms);
|
||||
/* Printf(stdout, " parameter priorities inverse matrix (%d parms):\n", parms_len); */
|
||||
for (col = 0; col < parms_len; col++) {
|
||||
int *priorities_col = priorities_matrix + col;
|
||||
int maxpriority = -1;
|
||||
/*
|
||||
Printf(stdout, "max_possible_partials: %d col:%d\n", max_possible_partials, col);
|
||||
Printf(stdout, " ");
|
||||
*/
|
||||
/* determine the highest rank for this nth parameter */
|
||||
for (row = 0; row < posslen; row++) {
|
||||
int *element_ptr = priorities_col + row*parms_len;
|
||||
int priority = *element_ptr;
|
||||
if (priority > maxpriority)
|
||||
maxpriority = priority;
|
||||
/* Printf(stdout, "%5d ", priority); */
|
||||
}
|
||||
/* Printf(stdout, "\n"); */
|
||||
/* flag all the parameters which equal the highest rank */
|
||||
for (row = 0; row < posslen; row++) {
|
||||
int *element_ptr = priorities_col + row*parms_len;
|
||||
int priority = *element_ptr;
|
||||
*element_ptr = (priority >= maxpriority) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
int row, col;
|
||||
int parms_len = ParmList_len(parms);
|
||||
Iterator pi = First(possiblepartials);
|
||||
Node *chosenpartials = NewList();
|
||||
if (template_debug)
|
||||
Printf(stdout, " priority flags matrix:\n");
|
||||
for (row = 0; row < posslen; row++) {
|
||||
int *priorities_row = priorities_matrix + row*parms_len;
|
||||
int highest_count = 0; /* count of highest priority parameters */
|
||||
for (col = 0; col < parms_len; col++) {
|
||||
highest_count += priorities_row[col];
|
||||
}
|
||||
if (template_debug) {
|
||||
Printf(stdout, " ");
|
||||
for (col = 0; col < parms_len; col++) {
|
||||
Printf(stdout, "%5d ", priorities_row[col]);
|
||||
}
|
||||
Printf(stdout, "\n");
|
||||
}
|
||||
if (highest_count == parms_len) {
|
||||
Append(chosenpartials, pi.item);
|
||||
}
|
||||
pi = Next(pi);
|
||||
}
|
||||
if (Len(chosenpartials) > 0) {
|
||||
/* one or more best match found */
|
||||
Delete(possiblepartials);
|
||||
possiblepartials = chosenpartials;
|
||||
posslen = Len(possiblepartials);
|
||||
} else {
|
||||
/* no best match found */
|
||||
Delete(chosenpartials);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (posslen > 0) {
|
||||
String *s = Getattr(Getitem(possiblepartials, 0), "templcsymname");
|
||||
n = Swig_symbol_clookup_local(s, primary_scope);
|
||||
if (posslen > 1) {
|
||||
int i;
|
||||
if (n) {
|
||||
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, cparse_file, cparse_line, "Instantiation of template '%s' is ambiguous,\n", SwigType_namestr(tname));
|
||||
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, Getfile(n), Getline(n), " instantiation '%s' used,\n", SwigType_namestr(Getattr(n, "name")));
|
||||
}
|
||||
for (i = 1; i < posslen; i++) {
|
||||
String *templcsymname = Getattr(Getitem(possiblepartials, i), "templcsymname");
|
||||
Node *ignored_node = Swig_symbol_clookup_local(templcsymname, primary_scope);
|
||||
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, Getfile(ignored_node), Getline(ignored_node), " instantiation '%s' ignored.\n", SwigType_namestr(Getattr(ignored_node, "name")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!n) {
|
||||
if (template_debug) {
|
||||
Printf(stdout, " chosen primary template: '%s'\n", Getattr(templ, "name"));
|
||||
}
|
||||
n = templ;
|
||||
}
|
||||
} else {
|
||||
if (template_debug) {
|
||||
Printf(stdout, " primary template not found\n");
|
||||
}
|
||||
/* Give up if primary (unspecialized) template not found as specializations will only exist if there is a primary template */
|
||||
n = 0;
|
||||
}
|
||||
|
||||
if (!n) {
|
||||
n = templ;
|
||||
}
|
||||
if (!n) {
|
||||
Swig_error(cparse_file, cparse_line, "Template '%s' undefined.\n", name);
|
||||
} else if (n) {
|
||||
|
|
@ -606,13 +796,16 @@ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) {
|
|||
}
|
||||
success:
|
||||
Delete(tname);
|
||||
Delete(rname);
|
||||
Delete(mpartials);
|
||||
Delete(possiblepartials);
|
||||
if ((template_debug) && (n)) {
|
||||
/*
|
||||
Printf(stdout, "Node: %p\n", n);
|
||||
Swig_print_node(n);
|
||||
*/
|
||||
Printf(stdout, " chosen template:'%s'\n", Getattr(n, "name"));
|
||||
}
|
||||
Delete(parms);
|
||||
free(priorities_matrix);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* util.c
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* base.c
|
||||
*
|
||||
* This file contains the function entry points for dispatching methods on
|
||||
* DOH objects. A number of small utility functions are also included.
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 1999-2000. The University of Chicago
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_base_c[] = "$Id$";
|
||||
|
|
@ -28,12 +30,15 @@ void DohDelete(DOH *obj) {
|
|||
|
||||
if (!obj)
|
||||
return;
|
||||
#if SWIG_DEBUG_DELETE
|
||||
if (!DohCheck(b)) {
|
||||
#if SWIG_DEBUG_DELETE
|
||||
fputs("DOH: Fatal error. Attempt to delete a non-doh object.\n", stderr);
|
||||
abort();
|
||||
}
|
||||
#else
|
||||
assert(0);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (b->flag_intern)
|
||||
return;
|
||||
assert(b->refcount > 0);
|
||||
|
|
@ -60,6 +65,15 @@ DOH *DohCopy(const DOH *obj) {
|
|||
|
||||
if (!obj)
|
||||
return 0;
|
||||
if (!DohCheck(b)) {
|
||||
#if SWIG_DEBUG_DELETE
|
||||
fputs("DOH: Fatal error. Attempt to copy a non-doh object.\n", stderr);
|
||||
abort();
|
||||
#else
|
||||
assert(0);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
objinfo = b->type;
|
||||
if (objinfo->doh_copy) {
|
||||
DohBase *bc = (DohBase *) (objinfo->doh_copy) (b);
|
||||
|
|
@ -245,7 +259,7 @@ int DohEqual(const DOH *obj1, const DOH *obj2) {
|
|||
|
||||
if (!b1info) {
|
||||
return obj1 == obj2;
|
||||
} else if ((b1info == b2info)) {
|
||||
} else if (b1info == b2info) {
|
||||
return b1info->doh_equal ? (b1info->doh_equal) (b1, b2) : (b1info->doh_cmp ? (b1info->doh_cmp) (b1, b2) == 0 : (b1 == b2));
|
||||
} else {
|
||||
return 0;
|
||||
|
|
@ -631,7 +645,7 @@ int DohRead(DOH *obj, void *buffer, int length) {
|
|||
* DohWrite()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int DohWrite(DOH *obj, void *buffer, int length) {
|
||||
int DohWrite(DOH *obj, const void *buffer, int length) {
|
||||
DohBase *b = (DohBase *) obj;
|
||||
DohObjInfo *objinfo;
|
||||
if (DohCheck(obj)) {
|
||||
|
|
@ -827,7 +841,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 +868,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)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* doh.h
|
||||
*
|
||||
* This file describes of the externally visible functions in DOH.
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 1999-2000. The University of Chicago
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
*
|
||||
* $Id$
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef _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
|
||||
|
|
@ -218,7 +221,7 @@ extern int DohDelslice(DOH *obj, int sindex, int eindex);
|
|||
|
||||
/* File methods */
|
||||
|
||||
extern int DohWrite(DOHFile * obj, void *buffer, int length);
|
||||
extern int DohWrite(DOHFile * obj, const void *buffer, int length);
|
||||
extern int DohRead(DOHFile * obj, void *buffer, int length);
|
||||
extern int DohSeek(DOHFile * obj, long offset, int whence);
|
||||
extern long DohTell(DOHFile * obj);
|
||||
|
|
@ -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 */
|
||||
|
|
@ -264,6 +267,8 @@ extern int DohIsSequence(const DOH *obj);
|
|||
extern int DohIsString(const DOH *obj);
|
||||
extern int DohIsFile(const DOH *obj);
|
||||
|
||||
extern void DohSetMaxHashExpand(int count);
|
||||
extern int DohGetMaxHashExpand(void);
|
||||
extern void DohSetmark(DOH *obj, int x);
|
||||
extern int DohGetmark(DOH *obj);
|
||||
|
||||
|
|
@ -271,10 +276,10 @@ extern int DohGetmark(DOH *obj);
|
|||
* Strings.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
extern DOHString *DohNewStringEmpty();
|
||||
extern DOHString *DohNewString(const DOH *c);
|
||||
extern DOHString *DohNewStringWithSize(const DOH *c, int len);
|
||||
extern DOHString *DohNewStringf(const DOH *fmt, ...);
|
||||
extern DOHString *DohNewStringEmpty(void);
|
||||
extern DOHString *DohNewString(const DOHString_or_char *c);
|
||||
extern DOHString *DohNewStringWithSize(const DOHString_or_char *c, int len);
|
||||
extern DOHString *DohNewStringf(const DOHString_or_char *fmt, ...);
|
||||
|
||||
extern int DohStrcmp(const DOHString_or_char *s1, const DOHString_or_char *s2);
|
||||
extern int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n);
|
||||
|
|
@ -289,6 +294,7 @@ extern char *DohStrchr(const DOHString_or_char *s1, int ch);
|
|||
#define DOH_REPLACE_FIRST 0x08
|
||||
#define DOH_REPLACE_ID_BEGIN 0x10
|
||||
#define DOH_REPLACE_ID_END 0x20
|
||||
#define DOH_REPLACE_NUMBER_END 0x40
|
||||
|
||||
#define Replaceall(s,t,r) DohReplace(s,t,r,DOH_REPLACE_ANY)
|
||||
#define Replaceid(s,t,r) DohReplace(s,t,r,DOH_REPLACE_ID)
|
||||
|
|
@ -297,7 +303,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 +315,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
|
||||
|
|
@ -421,6 +427,8 @@ extern void DohMemoryDebug(void);
|
|||
#define SplitLines DohSplitLines
|
||||
#define Setmark DohSetmark
|
||||
#define Getmark DohGetmark
|
||||
#define SetMaxHashExpand DohSetMaxHashExpand
|
||||
#define GetMaxHashExpand DohGetMaxHashExpand
|
||||
#define None DohNone
|
||||
#define Call DohCall
|
||||
#define First DohFirst
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* dohint.h
|
||||
*
|
||||
* This file describes internally managed objects.
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 1999-2000. The University of Chicago
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
*
|
||||
* $Id$
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef _DOHINT_H
|
||||
|
|
@ -44,7 +43,7 @@ typedef struct {
|
|||
/* File methods */
|
||||
typedef struct {
|
||||
int (*doh_read) (DOH *obj, void *buffer, int nbytes); /* Read bytes */
|
||||
int (*doh_write) (DOH *obj, void *buffer, int nbytes); /* Write bytes */
|
||||
int (*doh_write) (DOH *obj, const void *buffer, int nbytes); /* Write bytes */
|
||||
int (*doh_putc) (DOH *obj, int ch); /* Put character */
|
||||
int (*doh_getc) (DOH *obj); /* Get character */
|
||||
int (*doh_ungetc) (DOH *obj, int ch); /* Unget character */
|
||||
|
|
@ -55,7 +54,7 @@ typedef struct {
|
|||
|
||||
/* String methods */
|
||||
typedef struct {
|
||||
int (*doh_replace) (DOH *obj, DOH *old, DOH *rep, int flags);
|
||||
int (*doh_replace) (DOH *obj, const DOHString_or_char *old, const DOHString_or_char *rep, int flags);
|
||||
void (*doh_chop) (DOH *obj);
|
||||
} DohStringMethods;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* file.c
|
||||
*
|
||||
* This file implements a file-like object that can be built around an
|
||||
* ordinary FILE * or integer file descriptor.
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 1999-2000. The University of Chicago
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_file_c[] = "$Id$";
|
||||
|
|
@ -65,7 +67,7 @@ static int File_read(DOH *fo, void *buffer, int len) {
|
|||
* File_write()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int File_write(DOH *fo, void *buffer, int len) {
|
||||
static int File_write(DOH *fo, const void *buffer, int len) {
|
||||
DohFile *f = (DohFile *) ObjData(fo);
|
||||
if (f->filep) {
|
||||
int ret = (int) fwrite(buffer, 1, len, f->filep);
|
||||
|
|
@ -228,15 +230,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 +248,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;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* fio.c
|
||||
*
|
||||
* This file implements a number of standard I/O operations included
|
||||
* formatted output, readline, and splitting.
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 1999-2000. The University of Chicago
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_fio_c[] = "$Id$";
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* hash.c
|
||||
*
|
||||
* Implements a simple hash table object.
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 1999-2000. The University of Chicago
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_hash_c[] = "$Id$";
|
||||
|
|
@ -40,6 +42,7 @@ typedef struct KeyValue {
|
|||
} KeyValue;
|
||||
|
||||
static KeyValue *root = 0;
|
||||
static int max_expand = 1;
|
||||
|
||||
/* Find or create a key in the interned key table */
|
||||
static DOH *find_key(DOH *doh_c) {
|
||||
|
|
@ -112,12 +115,11 @@ static void DelHash(DOH *ho) {
|
|||
int i;
|
||||
|
||||
for (i = 0; i < h->hashsize; i++) {
|
||||
if ((n = h->hashtable[i])) {
|
||||
while (n) {
|
||||
next = n->next;
|
||||
DelNode(n);
|
||||
n = next;
|
||||
}
|
||||
n = h->hashtable[i];
|
||||
while (n) {
|
||||
next = n->next;
|
||||
DelNode(n);
|
||||
n = next;
|
||||
}
|
||||
}
|
||||
DohFree(h->hashtable);
|
||||
|
|
@ -138,12 +140,11 @@ static void Hash_clear(DOH *ho) {
|
|||
int i;
|
||||
|
||||
for (i = 0; i < h->hashsize; i++) {
|
||||
if ((n = h->hashtable[i])) {
|
||||
while (n) {
|
||||
next = n->next;
|
||||
DelNode(n);
|
||||
n = next;
|
||||
}
|
||||
n = h->hashtable[i];
|
||||
while (n) {
|
||||
next = n->next;
|
||||
DelNode(n);
|
||||
n = next;
|
||||
}
|
||||
h->hashtable[i] = 0;
|
||||
}
|
||||
|
|
@ -362,7 +363,7 @@ static DohIterator Hash_nextiter(DohIterator iter) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Hash_keys(DOH *)
|
||||
* Hash_keys()
|
||||
*
|
||||
* Return a list of keys
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -378,6 +379,26 @@ static DOH *Hash_keys(DOH *so) {
|
|||
return keys;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DohSetMaxHashExpand()
|
||||
*
|
||||
* Controls how many Hash objects are displayed in full in Hash_str
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void DohSetMaxHashExpand(int count) {
|
||||
max_expand = count;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DohGetMaxHashExpand()
|
||||
*
|
||||
* Returns how many Hash objects are displayed in full in Hash_str
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int DohGetMaxHashExpand(void) {
|
||||
return max_expand;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Hash_str()
|
||||
*
|
||||
|
|
@ -388,7 +409,8 @@ static DOH *Hash_str(DOH *ho) {
|
|||
int i, j;
|
||||
HashNode *n;
|
||||
DOH *s;
|
||||
static int indent = 4;
|
||||
static int expanded = 0;
|
||||
static const char *tab = " ";
|
||||
Hash *h = (Hash *) ObjData(ho);
|
||||
|
||||
s = NewStringEmpty();
|
||||
|
|
@ -396,22 +418,35 @@ static DOH *Hash_str(DOH *ho) {
|
|||
Printf(s, "Hash(0x%x)", ho);
|
||||
return s;
|
||||
}
|
||||
if (expanded >= max_expand) {
|
||||
/* replace each hash attribute with a '.' */
|
||||
Printf(s, "Hash(0x%x) {", ho);
|
||||
for (i = 0; i < h->hashsize; i++) {
|
||||
n = h->hashtable[i];
|
||||
while (n) {
|
||||
Putc('.', s);
|
||||
n = n->next;
|
||||
}
|
||||
}
|
||||
Putc('}', s);
|
||||
return s;
|
||||
}
|
||||
ObjSetMark(ho, 1);
|
||||
Printf(s, "Hash {\n");
|
||||
Printf(s, "Hash(0x%x) {\n", ho);
|
||||
for (i = 0; i < h->hashsize; i++) {
|
||||
n = h->hashtable[i];
|
||||
while (n) {
|
||||
for (j = 0; j < indent; j++)
|
||||
Putc(' ', s);
|
||||
indent += 4;
|
||||
for (j = 0; j < expanded + 1; j++)
|
||||
Printf(s, tab);
|
||||
expanded += 1;
|
||||
Printf(s, "'%s' : %s, \n", n->key, n->object);
|
||||
indent -= 4;
|
||||
expanded -= 1;
|
||||
n = n->next;
|
||||
}
|
||||
}
|
||||
for (j = 0; j < (indent - 4); j++)
|
||||
Putc(' ', s);
|
||||
Printf(s, "}\n");
|
||||
for (j = 0; j < expanded; j++)
|
||||
Printf(s, tab);
|
||||
Printf(s, "}");
|
||||
ObjSetMark(ho, 0);
|
||||
return s;
|
||||
}
|
||||
|
|
@ -454,11 +489,10 @@ static DOH *CopyHash(DOH *ho) {
|
|||
|
||||
nho = DohObjMalloc(&DohHashType, nh);
|
||||
for (i = 0; i < h->hashsize; i++) {
|
||||
if ((n = h->hashtable[i])) {
|
||||
while (n) {
|
||||
Hash_setattr(nho, n->key, n->object);
|
||||
n = n->next;
|
||||
}
|
||||
n = h->hashtable[i];
|
||||
while (n) {
|
||||
Hash_setattr(nho, n->key, n->object);
|
||||
n = n->next;
|
||||
}
|
||||
}
|
||||
return nho;
|
||||
|
|
@ -538,7 +572,7 @@ DohObjInfo DohHashType = {
|
|||
* Create a new hash table.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
DOH *DohNewHash() {
|
||||
DOH *DohNewHash(void) {
|
||||
Hash *h;
|
||||
int i;
|
||||
h = (Hash *) DohMalloc(sizeof(Hash));
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* list.c
|
||||
*
|
||||
* Implements a simple list object.
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 1999-2000. The University of Chicago
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_list_c[] = "$Id$";
|
||||
|
|
@ -250,7 +252,7 @@ static DOH *List_str(DOH *lo) {
|
|||
if ((i + 1) < l->nitems)
|
||||
Printf(s, ", ");
|
||||
}
|
||||
Printf(s, " ]\n");
|
||||
Printf(s, " ]");
|
||||
ObjSetMark(lo, 0);
|
||||
return s;
|
||||
}
|
||||
|
|
@ -345,7 +347,7 @@ DohObjInfo DohListType = {
|
|||
|
||||
#define MAXLISTITEMS 8
|
||||
|
||||
DOH *DohNewList() {
|
||||
DOH *DohNewList(void) {
|
||||
List *l;
|
||||
int i;
|
||||
l = (List *) DohMalloc(sizeof(List));
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* memory.c
|
||||
*
|
||||
* This file implements all of DOH's memory management including allocation
|
||||
* of objects and checking of objects.
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 1999-2000. The University of Chicago
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_memory_c[] = "$Id$";
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* string.c
|
||||
*
|
||||
* Implements a string object that supports both sequence operations and
|
||||
* file semantics.
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 1999-2000. The University of Chicago
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_string_c[] = "$Id$";
|
||||
|
|
@ -27,7 +29,7 @@ typedef struct String {
|
|||
} String;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void *String_data() - Return as a 'void *'
|
||||
* String_data() - Return as a 'void *'
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void *String_data(DOH *so) {
|
||||
|
|
@ -42,7 +44,7 @@ static void *String_data(DOH *so) {
|
|||
*/
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_dump() - Serialize a string onto out
|
||||
* String_dump() - Serialize a string onto out
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_dump(DOH *so, DOH *out) {
|
||||
|
|
@ -103,7 +105,7 @@ static int String_len(DOH *so) {
|
|||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_cmp() - Compare two strings
|
||||
* String_cmp() - Compare two strings
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_cmp(DOH *so1, DOH *so2) {
|
||||
|
|
@ -135,7 +137,7 @@ static int String_cmp(DOH *so1, DOH *so2) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_equal() - Say if two string are equal
|
||||
* String_equal() - Say if two string are equal
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_equal(DOH *so1, DOH *so2) {
|
||||
|
|
@ -172,7 +174,7 @@ static int String_equal(DOH *so1, DOH *so2) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_hash() - Compute string hash value
|
||||
* String_hash() - Compute string hash value
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_hash(DOH *so) {
|
||||
|
|
@ -201,10 +203,10 @@ static int String_hash(DOH *so) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DohString_append(String *s, const char *newstr) - Append to s
|
||||
* DohString_append() - Append to s
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void DohString_append(DOH *so, DOH *str) {
|
||||
static void DohString_append(DOH *so, const DOHString_or_char *str) {
|
||||
int oldlen, newlen, newmaxsize, l, sp;
|
||||
char *tc;
|
||||
String *s = (String *) ObjData(so);
|
||||
|
|
@ -249,7 +251,7 @@ void DohString_append(DOH *so, DOH *str) {
|
|||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void String_clear() - Clear a string
|
||||
* String_clear() - Clear a string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void String_clear(DOH *so) {
|
||||
|
|
@ -262,12 +264,11 @@ static void String_clear(DOH *so) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void String_insert() - Insert a string
|
||||
* String_insert() - Insert a string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_insert(DOH *so, int pos, DOH *str) {
|
||||
String *s;
|
||||
char *nstr;
|
||||
int len;
|
||||
char *data;
|
||||
|
||||
|
|
@ -287,7 +288,6 @@ static int String_insert(DOH *so, int pos, DOH *str) {
|
|||
data = (char *) (str);
|
||||
len = (int) strlen(data);
|
||||
}
|
||||
nstr = s->str;
|
||||
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
|
|
@ -318,7 +318,7 @@ static int String_insert(DOH *so, int pos, DOH *str) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_delitem() - Delete a character
|
||||
* String_delitem() - Delete a character
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_delitem(DOH *so, int pos) {
|
||||
|
|
@ -344,7 +344,7 @@ static int String_delitem(DOH *so, int pos) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_delslice() - Delete a range
|
||||
* String_delslice() - Delete a range
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_delslice(DOH *so, int sindex, int eindex) {
|
||||
|
|
@ -382,7 +382,7 @@ static int String_delslice(DOH *so, int sindex, int eindex) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DOH *String_str() - Returns a string (used by printing commands)
|
||||
* String_str() - Returns a string (used by printing commands)
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static DOH *String_str(DOH *so) {
|
||||
|
|
@ -392,7 +392,7 @@ static DOH *String_str(DOH *so) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_read() - Read data from a string
|
||||
* String_read() - Read data from a string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_read(DOH *so, void *buffer, int len) {
|
||||
|
|
@ -415,9 +415,9 @@ static int String_read(DOH *so, void *buffer, int len) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_write() - Write data to a string
|
||||
* String_write() - Write data to a string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
static int String_write(DOH *so, void *buffer, int len) {
|
||||
static int String_write(DOH *so, const void *buffer, int len) {
|
||||
int newlen;
|
||||
String *s = (String *) ObjData(so);
|
||||
s->hashkey = -1;
|
||||
|
|
@ -439,7 +439,7 @@ static int String_write(DOH *so, void *buffer, int len) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_seek() - Seek to a new position
|
||||
* String_seek() - Seek to a new position
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_seek(DOH *so, long offset, int whence) {
|
||||
|
|
@ -496,7 +496,7 @@ static int String_seek(DOH *so, long offset, int whence) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* long String_tell() - Return current position
|
||||
* String_tell() - Return current position
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static long String_tell(DOH *so) {
|
||||
|
|
@ -505,7 +505,7 @@ static long String_tell(DOH *so) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_putc()
|
||||
* String_putc()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_putc(DOH *so, int ch) {
|
||||
|
|
@ -536,7 +536,7 @@ static int String_putc(DOH *so, int ch) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_getc()
|
||||
* String_getc()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_getc(DOH *so) {
|
||||
|
|
@ -552,7 +552,7 @@ static int String_getc(DOH *so) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_ungetc()
|
||||
* String_ungetc()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_ungetc(DOH *so, int ch) {
|
||||
|
|
@ -567,12 +567,6 @@ static int String_ungetc(DOH *so, int ch) {
|
|||
return ch;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* replace_simple(String *str, char *token, char *rep, int flags, int count)
|
||||
*
|
||||
* Replaces count non-overlapping occurrences of token with rep in a string.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static char *end_quote(char *s) {
|
||||
char *qs;
|
||||
char qc;
|
||||
|
|
@ -657,6 +651,27 @@ static char *match_identifier_end(char *base, char *s, char *token, int tokenlen
|
|||
return 0;
|
||||
}
|
||||
|
||||
static char *match_number_end(char *base, char *s, char *token, int tokenlen) {
|
||||
(void) base;
|
||||
while (s) {
|
||||
s = strstr(s, token);
|
||||
if (!s)
|
||||
return 0;
|
||||
if (isdigit((int) *(s + tokenlen))) {
|
||||
s += tokenlen;
|
||||
continue;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* replace_simple()
|
||||
*
|
||||
* Replaces count non-overlapping occurrences of token with rep in a string.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int replace_simple(String *str, char *token, char *rep, int flags, int count, char *(*match) (char *, char *, char *, int)) {
|
||||
int tokenlen; /* Length of the token */
|
||||
int replen; /* Length of the replacement */
|
||||
|
|
@ -883,10 +898,10 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_replace()
|
||||
* String_replace()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_replace(DOH *stro, DOH *token, DOH *rep, int flags) {
|
||||
static int String_replace(DOH *stro, const DOHString_or_char *token, const DOHString_or_char *rep, int flags) {
|
||||
int count = -1;
|
||||
String *str = (String *) ObjData(stro);
|
||||
|
||||
|
|
@ -899,13 +914,15 @@ static int String_replace(DOH *stro, DOH *token, DOH *rep, int flags) {
|
|||
return replace_simple(str, Char(token), Char(rep), flags, count, match_identifier_begin);
|
||||
} else if (flags & DOH_REPLACE_ID) {
|
||||
return replace_simple(str, Char(token), Char(rep), flags, count, match_identifier);
|
||||
} else if (flags & DOH_REPLACE_NUMBER_END) {
|
||||
return replace_simple(str, Char(token), Char(rep), flags, count, match_number_end);
|
||||
} else {
|
||||
return replace_simple(str, Char(token), Char(rep), flags, count, match_simple);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void String_chop(DOH *str)
|
||||
* String_chop()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void String_chop(DOH *so) {
|
||||
|
|
@ -1010,10 +1027,10 @@ DohObjInfo DohStringType = {
|
|||
#define INIT_MAXSIZE 16
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* NewString(const char *c) - Create a new string
|
||||
* NewString() - Create a new string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
DOHString *DohNewString(const DOH *so) {
|
||||
DOHString *DohNewString(const DOHString_or_char *so) {
|
||||
int l = 0, max;
|
||||
String *str;
|
||||
char *s;
|
||||
|
|
@ -1056,7 +1073,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;
|
||||
|
|
@ -1071,10 +1088,10 @@ DOHString *DohNewStringEmpty() {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* NewStringWithSize(const char *c, int len) - Create a new string
|
||||
* NewStringWithSize() - Create a new string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
DOHString *DohNewStringWithSize(const DOH *so, int len) {
|
||||
DOHString *DohNewStringWithSize(const DOHString_or_char *so, int len) {
|
||||
int l = 0, max;
|
||||
String *str;
|
||||
char *s;
|
||||
|
|
@ -1109,12 +1126,12 @@ DOHString *DohNewStringWithSize(const DOH *so, int len) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* NewStringf(DOH *fmt, ...)
|
||||
* NewStringf()
|
||||
*
|
||||
* Create a new string from a list of objects.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
DOHString *DohNewStringf(const DOH *fmt, ...) {
|
||||
DOHString *DohNewStringf(const DOHString_or_char *fmt, ...) {
|
||||
va_list ap;
|
||||
DOH *r;
|
||||
va_start(ap, fmt);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* void.c
|
||||
*
|
||||
* Implements a "void" object that is really just a DOH container around
|
||||
* an arbitrary C object represented as a void *.
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 1999-2000. The University of Chicago
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_void_c[] = "$Id$";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* swigwarn.h
|
||||
*
|
||||
|
|
@ -16,8 +20,6 @@
|
|||
* numbers in this file.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef SWIGWARN_H_
|
||||
#define SWIGWARN_H_
|
||||
|
||||
|
|
@ -49,6 +51,7 @@
|
|||
#define WARN_DEPRECATED_NOEXTERN 122
|
||||
#define WARN_DEPRECATED_NODEFAULT 123
|
||||
#define WARN_DEPRECATED_TYPEMAP_LANG 124
|
||||
#define WARN_DEPRECATED_INPUT_FILE 125
|
||||
|
||||
/* -- Preprocessor -- */
|
||||
|
||||
|
|
@ -57,6 +60,7 @@
|
|||
#define WARN_PP_INCLUDEALL_IMPORTALL 203
|
||||
#define WARN_PP_CPP_WARNING 204
|
||||
#define WARN_PP_CPP_ERROR 205
|
||||
#define WARN_PP_UNEXPECTED_TOKENS 206
|
||||
|
||||
/* -- C/C++ Parser -- */
|
||||
|
||||
|
|
@ -71,7 +75,7 @@
|
|||
#define WARN_PARSE_PRIVATE_INHERIT 309
|
||||
#define WARN_PARSE_TEMPLATE_REPEAT 310
|
||||
#define WARN_PARSE_TEMPLATE_PARTIAL 311
|
||||
#define WARN_PARSE_NESTED_CLASS 312
|
||||
#define WARN_PARSE_UNNAMED_NESTED_CLASS 312
|
||||
#define WARN_PARSE_UNDEFINED_EXTERN 313
|
||||
#define WARN_PARSE_KEYWORD 314
|
||||
#define WARN_PARSE_USING_UNDEF 315
|
||||
|
|
@ -83,6 +87,8 @@
|
|||
#define WARN_PARSE_BUILTIN_NAME 321
|
||||
#define WARN_PARSE_REDUNDANT 322
|
||||
#define WARN_PARSE_REC_INHERITANCE 323
|
||||
#define WARN_PARSE_NESTED_TEMPLATE 324
|
||||
#define WARN_PARSE_NAMED_NESTED_CLASS 325
|
||||
|
||||
#define WARN_IGNORE_OPERATOR_NEW 350 /* new */
|
||||
#define WARN_IGNORE_OPERATOR_DELETE 351 /* delete */
|
||||
|
|
@ -188,14 +194,43 @@
|
|||
#define WARN_LANG_DIRECTOR_ABSTRACT 517
|
||||
#define WARN_LANG_PORTABILITY_FILENAME 518
|
||||
#define WARN_LANG_TEMPLATE_METHOD_IGNORE 519
|
||||
#define WARN_LANG_SMARTPTR_MISSING 520
|
||||
#define WARN_LANG_ILLEGAL_DESTRUCTOR 521
|
||||
|
||||
/* -- Reserved (600-799) -- */
|
||||
|
||||
/* -- Language module specific warnings (800 - 999) -- */
|
||||
/* -- Language module specific warnings (700 - 899) -- */
|
||||
|
||||
/* Feel free to claim any number in this space that's not currently being used. Just make sure you
|
||||
add an entry here */
|
||||
|
||||
#define WARN_D_TYPEMAP_CTYPE_UNDEF 700
|
||||
#define WARN_D_TYPEMAP_IMTYPE_UNDEF 701
|
||||
#define WARN_D_TYPEMAP_DTYPE_UNDEF 702
|
||||
#define WARN_D_MULTIPLE_INHERITANCE 703
|
||||
#define WARN_D_TYPEMAP_CLASSMOD_UNDEF 704
|
||||
#define WARN_D_TYPEMAP_DBODY_UNDEF 705
|
||||
#define WARN_D_TYPEMAP_DOUT_UNDEF 706
|
||||
#define WARN_D_TYPEMAP_DIN_UNDEF 707
|
||||
#define WARN_D_TYPEMAP_DDIRECTORIN_UNDEF 708
|
||||
#define WARN_D_TYPEMAP_DCONSTRUCTOR_UNDEF 709
|
||||
#define WARN_D_EXCODE_MISSING 710
|
||||
#define WARN_D_CANTHROW_MISSING 711
|
||||
#define WARN_D_NO_DIRECTORCONNECT_ATTR 712
|
||||
#define WARN_D_NAME_COLLISION 713
|
||||
|
||||
/* please leave 700-719 free for D */
|
||||
|
||||
#define WARN_C_TYPEMAP_CTYPE_UNDEF 720
|
||||
|
||||
/* please leave 720-739 free for C */
|
||||
|
||||
|
||||
#define WARN_RUBY_WRONG_NAME 801
|
||||
#define WARN_RUBY_MULTIPLE_INHERITANCE 802
|
||||
|
||||
/* please leave 800-809 free for Ruby */
|
||||
|
||||
#define WARN_JAVA_TYPEMAP_JNI_UNDEF 810
|
||||
#define WARN_JAVA_TYPEMAP_JTYPE_UNDEF 811
|
||||
#define WARN_JAVA_TYPEMAP_JSTYPE_UNDEF 812
|
||||
|
|
@ -247,17 +282,16 @@
|
|||
|
||||
/* please leave 850-869 free for Modula 3 */
|
||||
|
||||
#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_PUBLIC_BASE 872
|
||||
|
||||
/* please leave 870-889 free for Php */
|
||||
/* please leave 870-889 free for PHP */
|
||||
|
||||
#define WARN_C_TYPEMAP_CTYPE_UNDEF 890
|
||||
#define WARN_GO_NAME_CONFLICT 890
|
||||
|
||||
/* please leave 890-909 free for C */
|
||||
/* please leave 890-899 free for Go */
|
||||
|
||||
|
||||
/* Feel free to claim any number in this space that's not currently being used. Just make sure you
|
||||
add an entry here */
|
||||
/* -- User defined warnings (900 - 999) -- */
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ BUILD_SOURCE_DIR=$(top_builddir)/Source
|
|||
|
||||
SWIG_CXX_DEFS = @SWILL@
|
||||
|
||||
AM_CFLAGS = -I$(BUILD_SOURCE_DIR)/Include \
|
||||
AM_CPPFLAGS = -I$(BUILD_SOURCE_DIR)/Include \
|
||||
-I$(BUILD_SOURCE_DIR)/CParse \
|
||||
-I$(SOURCE_DIR)/Include \
|
||||
-I$(SOURCE_DIR)/DOH \
|
||||
|
|
@ -17,8 +17,7 @@ AM_CFLAGS = -I$(BUILD_SOURCE_DIR)/Include \
|
|||
-I$(SOURCE_DIR)/Swig \
|
||||
-I$(SOURCE_DIR)/Modules
|
||||
|
||||
AM_CXXFLAGS = $(AM_CFLAGS) \
|
||||
$(SWIG_CXX_DEFS)
|
||||
AM_CXXFLAGS = $(SWIG_CXX_DEFS)
|
||||
|
||||
AM_YFLAGS = -d
|
||||
|
||||
|
|
@ -44,8 +43,10 @@ eswig_SOURCES = CParse/cscanner.c \
|
|||
Modules/contract.cxx \
|
||||
Modules/c.cxx \
|
||||
Modules/csharp.cxx \
|
||||
Modules/d.cxx \
|
||||
Modules/directors.cxx \
|
||||
Modules/emit.cxx \
|
||||
Modules/go.cxx \
|
||||
Modules/guile.cxx \
|
||||
Modules/java.cxx \
|
||||
Modules/lang.cxx \
|
||||
|
|
@ -58,7 +59,7 @@ eswig_SOURCES = CParse/cscanner.c \
|
|||
Modules/octave.cxx \
|
||||
Modules/overload.cxx \
|
||||
Modules/perl5.cxx \
|
||||
Modules/php4.cxx \
|
||||
Modules/php.cxx \
|
||||
Modules/pike.cxx \
|
||||
Modules/python.cxx \
|
||||
Modules/r.cxx \
|
||||
|
|
@ -88,7 +89,6 @@ eswig_SOURCES = CParse/cscanner.c \
|
|||
Swig/typeobj.c \
|
||||
Swig/typemap.c \
|
||||
Swig/typesys.c \
|
||||
Swig/warn.c \
|
||||
Swig/wrapfunc.c
|
||||
|
||||
bin_PROGRAMS = eswig
|
||||
|
|
@ -107,6 +107,9 @@ clean-local:
|
|||
rm -f $(top_builddir)/swig@EXEEXT@
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
|
||||
distclean-local:
|
||||
rm -f $(top_builddir)/Source/Include/swigconfig.h
|
||||
rm -f $(top_builddir)/Source/Include/stamp-h1
|
||||
|
||||
# Beautify the code.
|
||||
# Note that this works well on C code, but does some odd joining of lines for C++ code.
|
||||
|
|
@ -114,7 +117,7 @@ clean-local:
|
|||
# swig executable as a way of checking before and after the 'beautifying'.
|
||||
# Single files can be beautified with the beautify-file target, eg: 'make beautify-file INDENTFILE=chosenfile.c'
|
||||
|
||||
SWIGTYPEDEFS=-T File -T DohObjInfo -T Parm -T Language -T List -T Typetab -T ModuleFactory -T ErrorMessageFormat -T Symtab -T Hash -T String -T DohBase -T Node -T String_or_char -T SwigType -T Dispatcher -T Wrapper -T DohStringMethods -T DohFileMethods -T DohListMethods -T DohHashMethods -T DOH -T DohIterator -T ParmList -T FILE -T HashNode -T DOHString_or_char
|
||||
SWIGTYPEDEFS=-T bool -T File -T DohObjInfo -T Parm -T Language -T List -T Typetab -T ModuleFactory -T ErrorMessageFormat -T Symtab -T Hash -T String -T DohBase -T Node -T String_or_char -T SwigType -T Dispatcher -T Wrapper -T DohStringMethods -T DohFileMethods -T DohListMethods -T DohHashMethods -T DOH -T DohIterator -T ParmList -T FILE -T HashNode -T DOHString_or_char
|
||||
INDENTBAKSDIR=../IndentBaks
|
||||
|
||||
beautify:
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* allocate.cxx
|
||||
*
|
||||
|
|
@ -212,7 +216,7 @@ class Allocate:public Dispatcher {
|
|||
|
||||
if (!most_base_covariant_type) {
|
||||
// Eliminate the derived virtual method.
|
||||
if (virtual_elimination_mode)
|
||||
if (virtual_elimination_mode && !is_member_director(n))
|
||||
if (both_have_public_access)
|
||||
if (!is_non_public_base(inclass, b))
|
||||
if (!Swig_symbol_isoverloaded(n)) {
|
||||
|
|
@ -382,10 +386,6 @@ class Allocate:public Dispatcher {
|
|||
}
|
||||
|
||||
Node *c = firstChild(cls);
|
||||
String *kind = Getattr(cls, "kind");
|
||||
int mode = PUBLIC;
|
||||
if (kind && (Strcmp(kind, "class") == 0))
|
||||
mode = PRIVATE;
|
||||
|
||||
while (c) {
|
||||
if (Getattr(c, "error") || GetFlag(c, "feature:ignore")) {
|
||||
|
|
@ -453,13 +453,6 @@ class Allocate:public Dispatcher {
|
|||
}
|
||||
}
|
||||
|
||||
if (Strcmp(nodeType(c), "access") == 0) {
|
||||
kind = Getattr(c, "kind");
|
||||
if (Strcmp(kind, "public") == 0)
|
||||
mode = PUBLIC;
|
||||
else
|
||||
mode = PRIVATE;
|
||||
}
|
||||
c = nextSibling(c);
|
||||
}
|
||||
/* Look for methods in base classes */
|
||||
|
|
@ -518,7 +511,7 @@ class Allocate:public Dispatcher {
|
|||
*/
|
||||
String *scatchlist = Getattr(n, "feature:catches");
|
||||
if (scatchlist) {
|
||||
catchlist = Swig_cparse_parms(scatchlist);
|
||||
catchlist = Swig_cparse_parms(scatchlist, n);
|
||||
if (catchlist) {
|
||||
Setattr(n, "catchlist", catchlist);
|
||||
mark_exception_classes(catchlist);
|
||||
|
|
@ -527,8 +520,7 @@ class Allocate:public Dispatcher {
|
|||
}
|
||||
ParmList *throws = Getattr(n, "throws");
|
||||
if (throws) {
|
||||
/* if there is no an explicit catchlist,
|
||||
we catch everything in the throwlist */
|
||||
/* if there is no explicit catchlist, we catch everything in the throws list */
|
||||
if (!catchlist) {
|
||||
Setattr(n, "catchlist", throws);
|
||||
}
|
||||
|
|
@ -821,9 +813,12 @@ Allocate():
|
|||
int isconst = 0;
|
||||
Delete(SwigType_pop(type));
|
||||
if (SwigType_isconst(type)) {
|
||||
isconst = 1;
|
||||
isconst = !Getattr(inclass, "allocate:smartpointermutable");
|
||||
Setattr(inclass, "allocate:smartpointerconst", "1");
|
||||
}
|
||||
else {
|
||||
Setattr(inclass, "allocate:smartpointermutable", "1");
|
||||
}
|
||||
List *methods = smart_pointer_methods(sc, 0, isconst);
|
||||
Setattr(inclass, "allocate:smartpointer", methods);
|
||||
Setattr(inclass, "allocate:smartpointerbase", base);
|
||||
|
|
@ -831,7 +826,6 @@ Allocate():
|
|||
/* Hmmm. The return value is not a pointer. If the type is a value
|
||||
or reference. We're going to chase it to see if another operator->()
|
||||
can be found */
|
||||
|
||||
if ((SwigType_check_decl(type, "")) || (SwigType_check_decl(type, "r."))) {
|
||||
Node *nn = Swig_symbol_clookup((char *) "operator ->", Getattr(sc, "symtab"));
|
||||
if (nn) {
|
||||
|
|
@ -942,6 +936,9 @@ Allocate():
|
|||
} else if (cplus_mode == PROTECTED) {
|
||||
Setattr(inclass, "allocate:default_base_destructor", "1");
|
||||
}
|
||||
} else {
|
||||
Setattr(inclass, "allocate:has_destructor", "1");
|
||||
Setattr(inclass, "allocate:default_destructor", "1");
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* browser.cxx
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* cffi.cxx
|
||||
*
|
||||
|
|
@ -16,13 +20,27 @@ char cvsroot_cffi_cxx[] = "$Id$";
|
|||
//#define CFFI_DEBUG
|
||||
//#define CFFI_WRAP_DEBUG
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
CFFI Options (available with -cffi)\n\
|
||||
-generate-typedef - Use defctype to generate shortcuts according to the\n\
|
||||
typedefs in the input.\n\
|
||||
-[no]cwrap - Turn on or turn off generation of an intermediate C\n\
|
||||
file when creating a C interface. By default this is\n\
|
||||
only done for C++ code.\n\
|
||||
-[no]swig-lisp - Turn on or off generation of code for helper lisp\n\
|
||||
macro, functions, etc. which SWIG uses while\n\
|
||||
generating wrappers. These macros, functions may still\n\
|
||||
be used by generated wrapper code.\n\
|
||||
";
|
||||
|
||||
class CFFI:public Language {
|
||||
public:
|
||||
String *f_cl;
|
||||
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 +85,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;
|
||||
|
|
@ -74,17 +93,7 @@ void CFFI::main(int argc, char *argv[]) {
|
|||
CWrap = false;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!Strcmp(argv[i], "-help")) {
|
||||
Printf(stdout, "cffi Options (available with -cffi)\n");
|
||||
Printf(stdout,
|
||||
" -generate-typedef\n"
|
||||
"\tIf this option is given then defctype will be used to generate\n"
|
||||
"\tshortcuts according to the typedefs in the input.\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"
|
||||
" -[no]swig-lisp\n"
|
||||
"\tTurns on or off generation of code for helper lisp macro, functions,\n"
|
||||
"\tetc. which SWIG uses while generating wrappers. These macros, functions\n" "\tmay still be used by generated wrapper code.\n");
|
||||
Printf(stdout, "%s\n", usage);
|
||||
} else if (!strcmp(argv[i], "-cwrap")) {
|
||||
CWrap = true;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -119,16 +128,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 +145,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 +153,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 +189,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 +252,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 +307,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 +344,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) {
|
||||
|
|
@ -441,7 +461,7 @@ int CFFI::functionWrapper(Node *n) {
|
|||
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
String *result_convert = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
|
||||
String *result_convert = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode);
|
||||
Replaceall(result_convert, "$result", "lresult");
|
||||
Printf(f->code, "%s\n", result_convert);
|
||||
if(!is_void_return) Printf(f->code, " return lresult;\n");
|
||||
|
|
@ -455,7 +475,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);
|
||||
|
|
@ -605,12 +625,12 @@ int CFFI::enumDeclaration(Node *n) {
|
|||
slot_name_keywords = true;
|
||||
|
||||
//Registering the enum name to the cin and cout typemaps
|
||||
Parm *pattern = NewParm(name, NULL);
|
||||
Parm *pattern = NewParm(name, NULL, n);
|
||||
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
|
||||
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
|
||||
Delete(pattern);
|
||||
//Registering with the kind, i.e., enum
|
||||
pattern = NewParm(NewStringf("enum %s", name), NULL);
|
||||
pattern = NewParm(NewStringf("enum %s", name), NULL, n);
|
||||
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
|
||||
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
|
||||
Delete(pattern);
|
||||
|
|
@ -630,7 +650,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);
|
||||
|
|
@ -675,7 +695,7 @@ void CFFI::emit_class(Node *n) {
|
|||
Printf(f_clos, "\n(cl:defclass %s%s", lisp_name, supers);
|
||||
Printf(f_clos, "\n ((ff-pointer :reader ff-pointer)))\n\n");
|
||||
|
||||
Parm *pattern = NewParm(Getattr(n, "name"), NULL);
|
||||
Parm *pattern = NewParm(Getattr(n, "name"), NULL, n);
|
||||
|
||||
Swig_typemap_register("lispclass", pattern, lisp_name, NULL, NULL);
|
||||
SwigType_add_pointer(Getattr(pattern, "type"));
|
||||
|
|
@ -745,7 +765,7 @@ void CFFI::emit_class(Node *n) {
|
|||
Delete(supers);
|
||||
// Delete(ns_list);
|
||||
|
||||
// Parm *pattern = NewParm(name,NULL);
|
||||
// Parm *pattern = NewParm(name, NULL, n);
|
||||
// Swig_typemap_register("cin",pattern,lisp_name,NULL,NULL);
|
||||
//Swig_typemap_register("cout",pattern,lisp_name,NULL,NULL);
|
||||
//Delete(pattern);
|
||||
|
|
@ -774,12 +794,12 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
|
|||
|
||||
//Register the struct/union name to the cin and cout typemaps
|
||||
|
||||
Parm *pattern = NewParm(name, NULL);
|
||||
Parm *pattern = NewParm(name, NULL, n);
|
||||
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
|
||||
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
|
||||
Delete(pattern);
|
||||
//Registering with the kind, i.e., struct or union
|
||||
pattern = NewParm(NewStringf("%s %s", kind, name), NULL);
|
||||
pattern = NewParm(NewStringf("%s %s", kind, name), NULL, n);
|
||||
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
|
||||
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
|
||||
Delete(pattern);
|
||||
|
|
@ -806,21 +826,24 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
|
|||
// Getattr(c, "type"));
|
||||
// SWIG_exit(EXIT_FAILURE);
|
||||
} else {
|
||||
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"),
|
||||
Getattr(c, "type"));
|
||||
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), Getattr(c, "type"));
|
||||
|
||||
Hash *typemap = Swig_typemap_search("cin", childType, "", 0);
|
||||
String *typespec = NewString("");
|
||||
if (typemap) {
|
||||
typespec = NewString(Getattr(typemap, "code"));
|
||||
}
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", childType);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("cin", node, "", 0);
|
||||
|
||||
String *typespec = tm ? NewString(tm) : NewString("");
|
||||
|
||||
String *slot_name = lispify_name(c, Getattr(c, "sym:name"), "'slotname");
|
||||
if (Strcmp(slot_name, "t") == 0 || Strcmp(slot_name, "T") == 0)
|
||||
slot_name = NewStringf("t_var");
|
||||
slot_name = NewStringf("t_var");
|
||||
|
||||
Printf(f_cl, "\n\t(%s %s)", slot_name, typespec);
|
||||
|
||||
Delete(node);
|
||||
Delete(childType);
|
||||
Delete(typespec);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* chicken.cxx
|
||||
*
|
||||
|
|
@ -13,23 +17,24 @@ char cvsroot_chicken_cxx[] = "$Id$";
|
|||
|
||||
#include <ctype.h>
|
||||
|
||||
static const char *chicken_usage = (char *) "\
|
||||
static const char *usage = (char *) "\
|
||||
\
|
||||
CHICKEN Options (available with -chicken)\n\
|
||||
-proxy - Export TinyCLOS class definitions\n\
|
||||
-closprefix <prefix> - Prepend <prefix> to all clos identifiers\n\
|
||||
-useclassprefix - Prepend the class name to all clos identifiers\n\
|
||||
-unhideprimitive - Unhide the primitive: symbols\n\
|
||||
-nounit - Do not (declare (unit ...)) in scheme file\n\
|
||||
-noclosuses - Do not (declare (uses ...)) in scheme file\n\
|
||||
-nocollection - Do not register pointers with chicken garbage\n\
|
||||
collector and export destructors\n\
|
||||
-nounit - Do not (declare (unit ...)) in scheme file\n\
|
||||
-proxy - Export TinyCLOS class definitions\n\
|
||||
-unhideprimitive - Unhide the primitive: symbols\n\
|
||||
-useclassprefix - Prepend the class name to all clos identifiers\n\
|
||||
\n";
|
||||
|
||||
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 +106,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);
|
||||
};
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
|
|
@ -132,7 +137,7 @@ void CHICKEN::main(int argc, char *argv[]) {
|
|||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(chicken_usage, stdout);
|
||||
fputs(usage, stdout);
|
||||
SWIG_exit(0);
|
||||
} else if (strcmp(argv[i], "-proxy") == 0) {
|
||||
clos = 1;
|
||||
|
|
@ -188,11 +193,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 +211,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 +222,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 +260,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 +316,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;
|
||||
}
|
||||
|
||||
|
|
@ -329,7 +340,6 @@ int CHICKEN::functionWrapper(Node *n) {
|
|||
Parm *p;
|
||||
int i;
|
||||
String *wname;
|
||||
String *source;
|
||||
Wrapper *f;
|
||||
String *mangle = NewString("");
|
||||
String *get_pointers;
|
||||
|
|
@ -398,8 +408,6 @@ int CHICKEN::functionWrapper(Node *n) {
|
|||
SwigType *pt = Getattr(p, "type");
|
||||
String *ln = Getattr(p, "lname");
|
||||
|
||||
source = NewStringf("scm%d", i + 1);
|
||||
|
||||
Printf(f->def, ", C_word scm%d", i + 1);
|
||||
Printf(declfunc, ",C_word");
|
||||
|
||||
|
|
@ -407,6 +415,7 @@ int CHICKEN::functionWrapper(Node *n) {
|
|||
if ((tm = Getattr(p, "tmap:in"))) {
|
||||
String *parse = Getattr(p, "tmap:in:parse");
|
||||
if (!parse) {
|
||||
String *source = NewStringf("scm%d", i + 1);
|
||||
Replaceall(tm, "$source", source);
|
||||
Replaceall(tm, "$target", ln);
|
||||
Replaceall(tm, "$input", source);
|
||||
|
|
@ -445,20 +454,15 @@ int CHICKEN::functionWrapper(Node *n) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
Delete(source);
|
||||
}
|
||||
|
||||
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
|
||||
break;
|
||||
}
|
||||
|
||||
Delete(source);
|
||||
p = nextSibling(p);
|
||||
}
|
||||
|
||||
/* finish argument marshalling */
|
||||
|
|
@ -529,8 +533,8 @@ int CHICKEN::functionWrapper(Node *n) {
|
|||
String *actioncode = emit_action(n);
|
||||
|
||||
/* Return the function value */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "resultobj");
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
|
|
@ -557,15 +561,15 @@ int CHICKEN::functionWrapper(Node *n) {
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -673,16 +677,13 @@ int CHICKEN::variableWrapper(Node *n) {
|
|||
String *wname = NewString("");
|
||||
String *mangle = NewString("");
|
||||
String *tm;
|
||||
String *tm2 = NewString("");;
|
||||
String *tm2 = NewString("");
|
||||
String *argnum = NewString("0");
|
||||
String *arg = NewString("argv[0]");
|
||||
Wrapper *f;
|
||||
String *overname = 0;
|
||||
String *scmname;
|
||||
|
||||
int num_required;
|
||||
int num_arguments;
|
||||
|
||||
scmname = NewString(iname);
|
||||
Replaceall(scmname, "_", "-");
|
||||
|
||||
|
|
@ -701,10 +702,6 @@ int CHICKEN::variableWrapper(Node *n) {
|
|||
emit_attach_parmmaps(l, f);
|
||||
Setattr(n, "wrap:parms", l);
|
||||
|
||||
/* Get number of required and total arguments */
|
||||
num_arguments = emit_num_arguments(l);
|
||||
num_required = emit_num_required(l);
|
||||
|
||||
// evaluation function names
|
||||
Append(wname, Swig_name_wrapper(iname));
|
||||
if (overname) {
|
||||
|
|
@ -841,9 +838,6 @@ int CHICKEN::constantWrapper(Node *n) {
|
|||
String *rvalue;
|
||||
SwigType *nctype;
|
||||
|
||||
int num_required;
|
||||
int num_arguments;
|
||||
|
||||
scmname = NewString(iname);
|
||||
Replaceall(scmname, "_", "-");
|
||||
|
||||
|
|
@ -869,9 +863,10 @@ int CHICKEN::constantWrapper(Node *n) {
|
|||
Delete(SwigType_pop(nctype));
|
||||
}
|
||||
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
if (SwigType_type(nctype) == T_STRING) {
|
||||
rvalue = NewStringf("\"%s\"", value);
|
||||
} else if (SwigType_type(nctype) == T_CHAR) {
|
||||
} else if (SwigType_type(nctype) == T_CHAR && !is_enum_item) {
|
||||
rvalue = NewStringf("\'%s\'", value);
|
||||
} else {
|
||||
rvalue = NewString(value);
|
||||
|
|
@ -899,10 +894,6 @@ int CHICKEN::constantWrapper(Node *n) {
|
|||
emit_attach_parmmaps(l, f);
|
||||
Setattr(n, "wrap:parms", l);
|
||||
|
||||
/* Get number of required and total arguments */
|
||||
num_arguments = emit_num_arguments(l);
|
||||
num_required = emit_num_required(l);
|
||||
|
||||
// evaluation function names
|
||||
|
||||
// Check for interrupts
|
||||
|
|
@ -1148,9 +1139,9 @@ int CHICKEN::membervariableHandler(Node *n) {
|
|||
|
||||
//String *getfunc = NewStringf("%s-%s-get", short_class_name, proc);
|
||||
//String *setfunc = NewStringf("%s-%s-set", short_class_name, proc);
|
||||
String *getfunc = Swig_name_get(Swig_name_member(c_class_name, iname));
|
||||
String *getfunc = Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, c_class_name, iname));
|
||||
Replaceall(getfunc, "_", "-");
|
||||
String *setfunc = Swig_name_set(Swig_name_member(c_class_name, iname));
|
||||
String *setfunc = Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, c_class_name, iname));
|
||||
Replaceall(setfunc, "_", "-");
|
||||
|
||||
Printv(clos_class_defines, " (list '", proc, " ':swig-virtual ':swig-get ", chickenPrimitiveName(getfunc), NIL);
|
||||
|
|
@ -1197,7 +1188,7 @@ int CHICKEN::constructorHandler(Node *n) {
|
|||
has_constructor_args = 1;
|
||||
|
||||
String *iname = Getattr(n, "sym:name");
|
||||
constructor_name = Swig_name_construct(iname);
|
||||
constructor_name = Swig_name_construct(NSPACE_TODO, iname);
|
||||
Replaceall(constructor_name, "_", "-");
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1240,7 +1231,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("");
|
||||
|
|
@ -1378,12 +1369,10 @@ void CHICKEN::dispatchFunction(Node *n) {
|
|||
SortList(flist, compareTypeLists);
|
||||
|
||||
String *clos_name;
|
||||
int construct = 0;
|
||||
if (have_constructor && !has_constructor_args) {
|
||||
has_constructor_args = 1;
|
||||
constructor_dispatch = NewStringf("%s@SWIG@new@dispatch", short_class_name);
|
||||
clos_name = Copy(constructor_dispatch);
|
||||
construct = 1;
|
||||
Printf(clos_methods, "(declare (hide %s))\n", clos_name);
|
||||
} else if (in_class)
|
||||
clos_name = NewString(member_name);
|
||||
|
|
@ -1510,11 +1499,11 @@ int CHICKEN::validIdentifier(String *s) {
|
|||
/* ------------------------------------------------------------
|
||||
* closNameMapping()
|
||||
* Maps the identifier from C++ to the CLOS based on command
|
||||
* line paramaters and such.
|
||||
* line parameters and such.
|
||||
* 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) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* clisp.cxx
|
||||
*
|
||||
|
|
@ -11,6 +15,15 @@ char cvsroot_clisp_cxx[] = "$Id$";
|
|||
|
||||
#include "swigmod.h"
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
CLISP Options (available with -clisp)\n\
|
||||
-extern-all - Create clisp definitions for all the functions and\n\
|
||||
global variables otherwise only definitions for\n\
|
||||
externed functions and variables are created.\n\
|
||||
-generate-typedef - Use def-c-type to generate shortcuts according to the\n\
|
||||
typedefs in the input.\n\
|
||||
";
|
||||
|
||||
class CLISP:public Language {
|
||||
public:
|
||||
File *f_cl;
|
||||
|
|
@ -25,7 +38,7 @@ public:
|
|||
virtual int typedefHandler(Node *n);
|
||||
List *entries;
|
||||
private:
|
||||
String *get_ffi_type(SwigType *ty);
|
||||
String *get_ffi_type(Node *n, SwigType *ty);
|
||||
String *convert_literal(String *num_param, String *type);
|
||||
String *strip_parens(String *string);
|
||||
int extern_all_flag;
|
||||
|
|
@ -36,6 +49,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;
|
||||
|
|
@ -43,15 +57,7 @@ void CLISP::main(int argc, char *argv[]) {
|
|||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!strcmp(argv[i], "-help")) {
|
||||
Printf(stdout, "clisp Options (available with -clisp)\n");
|
||||
Printf(stdout,
|
||||
" -extern-all\n"
|
||||
"\t If this option is given then clisp definitions for all the functions\n"
|
||||
"and global variables will be created otherwise only definitions for \n"
|
||||
"externed functions and variables are created.\n"
|
||||
" -generate-typedef\n"
|
||||
"\t If this option is given then def-c-type will be used to generate shortcuts\n"
|
||||
"according to the typedefs in the input.\n");
|
||||
Printf(stdout, "%s\n", usage);
|
||||
} else if ((Strcmp(argv[i], "-extern-all") == 0)) {
|
||||
extern_all_flag = 1;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -79,20 +85,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);
|
||||
|
||||
|
|
@ -164,7 +172,7 @@ int CLISP::functionWrapper(Node *n) {
|
|||
String *argname = Getattr(p, "name");
|
||||
// SwigType *argtype;
|
||||
|
||||
String *ffitype = get_ffi_type(Getattr(p, "type"));
|
||||
String *ffitype = get_ffi_type(n, Getattr(p, "type"));
|
||||
|
||||
int tempargname = 0;
|
||||
|
||||
|
|
@ -187,7 +195,7 @@ int CLISP::functionWrapper(Node *n) {
|
|||
if (ParmList_len(pl) != 0) {
|
||||
Printf(f_cl, ")\n"); /* finish arg list */
|
||||
}
|
||||
String *ffitype = get_ffi_type(Getattr(n, "type"));
|
||||
String *ffitype = get_ffi_type(n, Getattr(n, "type"));
|
||||
if (Strcmp(ffitype, "NIL")) { //when return type is not nil
|
||||
Printf(f_cl, "\t(:return-type %s)\n", ffitype);
|
||||
}
|
||||
|
|
@ -219,7 +227,7 @@ int CLISP::variableWrapper(Node *n) {
|
|||
return SWIG_OK;
|
||||
|
||||
String *var_name = Getattr(n, "sym:name");
|
||||
String *lisp_type = get_ffi_type(Getattr(n, "type"));
|
||||
String *lisp_type = get_ffi_type(n, Getattr(n, "type"));
|
||||
Printf(f_cl, "\n(ffi:def-c-var %s\n (:name \"%s\")\n (:type %s)\n", var_name, var_name, lisp_type);
|
||||
Printf(f_cl, "\t(:library +library-name+))\n");
|
||||
Append(entries, var_name);
|
||||
|
|
@ -231,7 +239,7 @@ int CLISP::variableWrapper(Node *n) {
|
|||
int CLISP::typedefHandler(Node *n) {
|
||||
if (generate_typedef_flag) {
|
||||
is_function = 0;
|
||||
Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(Getattr(n, "type")));
|
||||
Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(n, Getattr(n, "type")));
|
||||
}
|
||||
|
||||
return Language::typedefHandler(n);
|
||||
|
|
@ -286,16 +294,18 @@ int CLISP::classDeclaration(Node *n) {
|
|||
}
|
||||
|
||||
String *temp = Copy(Getattr(c, "decl"));
|
||||
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
|
||||
String *lisp_type = get_ffi_type(temp);
|
||||
Delete(temp);
|
||||
if (temp) {
|
||||
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
|
||||
String *lisp_type = get_ffi_type(n, temp);
|
||||
Delete(temp);
|
||||
|
||||
String *slot_name = Getattr(c, "sym:name");
|
||||
Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
|
||||
String *slot_name = Getattr(c, "sym:name");
|
||||
Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
|
||||
|
||||
Append(entries, NewStringf("%s-%s", name, slot_name));
|
||||
Append(entries, NewStringf("%s-%s", name, slot_name));
|
||||
|
||||
Delete(lisp_type);
|
||||
Delete(lisp_type);
|
||||
}
|
||||
}
|
||||
|
||||
Printf(f_cl, ")\n");
|
||||
|
|
@ -368,15 +378,20 @@ String *CLISP::convert_literal(String *num_param, String *type) {
|
|||
return res;
|
||||
}
|
||||
|
||||
String *CLISP::get_ffi_type(SwigType *ty) {
|
||||
Hash *typemap = Swig_typemap_search("in", ty, "", 0);
|
||||
if (typemap) {
|
||||
String *typespec = Getattr(typemap, "code");
|
||||
return NewString(typespec);
|
||||
String *CLISP::get_ffi_type(Node *n, SwigType *ty) {
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", ty);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("in", node, "", 0);
|
||||
Delete(node);
|
||||
|
||||
if (tm) {
|
||||
return NewString(tm);
|
||||
} else if (SwigType_ispointer(ty)) {
|
||||
SwigType *cp = Copy(ty);
|
||||
SwigType_del_pointer(cp);
|
||||
String *inner_type = get_ffi_type(cp);
|
||||
String *inner_type = get_ffi_type(n, cp);
|
||||
|
||||
if (SwigType_isfunction(cp)) {
|
||||
return inner_type;
|
||||
|
|
@ -406,12 +421,12 @@ String *CLISP::get_ffi_type(SwigType *ty) {
|
|||
Delete(array_dim);
|
||||
SwigType_del_array(cp);
|
||||
SwigType_add_pointer(cp);
|
||||
String *str = get_ffi_type(cp);
|
||||
String *str = get_ffi_type(n, cp);
|
||||
Delete(cp);
|
||||
return str;
|
||||
} else {
|
||||
SwigType_pop_arrays(cp);
|
||||
String *inner_type = get_ffi_type(cp);
|
||||
String *inner_type = get_ffi_type(n, cp);
|
||||
Delete(cp);
|
||||
|
||||
int ndim = SwigType_array_ndim(ty);
|
||||
|
|
@ -444,7 +459,7 @@ String *CLISP::get_ffi_type(SwigType *ty) {
|
|||
SwigType *cp = Copy(ty);
|
||||
SwigType *fn = SwigType_pop_function(cp);
|
||||
String *args = NewString("");
|
||||
ParmList *pl = SwigType_function_parms(fn);
|
||||
ParmList *pl = SwigType_function_parms(fn, n);
|
||||
if (ParmList_len(pl) != 0) {
|
||||
Printf(args, "(:arguments ");
|
||||
}
|
||||
|
|
@ -452,7 +467,7 @@ String *CLISP::get_ffi_type(SwigType *ty) {
|
|||
for (Parm *p = pl; p; p = nextSibling(p), argnum++) {
|
||||
String *argname = Getattr(p, "name");
|
||||
SwigType *argtype = Getattr(p, "type");
|
||||
String *ffitype = get_ffi_type(argtype);
|
||||
String *ffitype = get_ffi_type(n, argtype);
|
||||
|
||||
int tempargname = 0;
|
||||
|
||||
|
|
@ -472,7 +487,7 @@ String *CLISP::get_ffi_type(SwigType *ty) {
|
|||
if (ParmList_len(pl) != 0) {
|
||||
Printf(args, ")\n"); /* finish arg list */
|
||||
}
|
||||
String *ffitype = get_ffi_type(cp);
|
||||
String *ffitype = get_ffi_type(n, cp);
|
||||
String *str = NewStringf("(ffi:c-function %s \t\t\t\t(:return-type %s))", args, ffitype);
|
||||
Delete(fn);
|
||||
Delete(args);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* contract.cxx
|
||||
*
|
||||
|
|
@ -46,6 +50,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);
|
||||
};
|
||||
|
|
@ -208,7 +213,7 @@ String *Contracts::make_expression(String *s, Node *n) {
|
|||
for (ei = First(list_assert); ei.item; ei = Next(ei)) {
|
||||
expr = ei.item;
|
||||
if (Len(expr)) {
|
||||
Replaceid(expr, Getattr(n, "name"), "result");
|
||||
Replaceid(expr, Getattr(n, "name"), Swig_cresult_name());
|
||||
if (Len(str_assert))
|
||||
Append(str_assert, "&&");
|
||||
Printf(str_assert, "(%s)", expr);
|
||||
|
|
@ -320,16 +325,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;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
4686
Source/Modules/d.cxx
Normal file
4686
Source/Modules/d.cxx
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* directors.cxx
|
||||
*
|
||||
|
|
@ -84,7 +88,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 +132,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;
|
||||
|
|
@ -286,3 +290,29 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f) {
|
|||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Swig_director_parms_fixup()
|
||||
*
|
||||
* For each parameter in the C++ member function, copy the parameter name
|
||||
* to its "lname"; this ensures that Swig_typemap_attach_parms() will do
|
||||
* the right thing when it sees strings like "$1" in "directorin" typemaps.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
void Swig_director_parms_fixup(ParmList *parms) {
|
||||
Parm *p;
|
||||
int i;
|
||||
for (i = 0, p = parms; p; p = nextSibling(p), ++i) {
|
||||
String *arg = Getattr(p, "name");
|
||||
String *lname = 0;
|
||||
|
||||
if (!arg && !Equal(Getattr(p, "type"), "void")) {
|
||||
lname = NewStringf("arg%d", i);
|
||||
Setattr(p, "name", lname);
|
||||
} else
|
||||
lname = Copy(arg);
|
||||
|
||||
Setattr(p, "lname", lname);
|
||||
Delete(lname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* emit.cxx
|
||||
*
|
||||
|
|
@ -28,11 +32,11 @@ void emit_return_variable(Node *n, SwigType *rt, Wrapper *f) {
|
|||
SwigType *vt = cplus_value_type(rt);
|
||||
SwigType *tt = vt ? vt : rt;
|
||||
SwigType *lt = SwigType_ltype(tt);
|
||||
String *lstr = SwigType_str(lt, "result");
|
||||
String *lstr = SwigType_str(lt, Swig_cresult_name());
|
||||
if (SwigType_ispointer(lt)) {
|
||||
Wrapper_add_localv(f, "result", lstr, "= 0", NULL);
|
||||
Wrapper_add_localv(f, Swig_cresult_name(), lstr, "= 0", NULL);
|
||||
} else {
|
||||
Wrapper_add_local(f, "result", lstr);
|
||||
Wrapper_add_local(f, Swig_cresult_name(), lstr);
|
||||
}
|
||||
if (vt) {
|
||||
Delete(vt);
|
||||
|
|
@ -200,7 +204,7 @@ void emit_attach_parmmaps(ParmList *l, Wrapper *f) {
|
|||
* emit_num_arguments()
|
||||
*
|
||||
* Calculate the total number of arguments. This function is safe for use
|
||||
* with multi-valued typemaps which may change the number of arguments in
|
||||
* with multi-argument typemaps which may change the number of arguments in
|
||||
* strange ways.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
|
@ -232,7 +236,7 @@ int emit_num_arguments(ParmList *parms) {
|
|||
* emit_num_required()
|
||||
*
|
||||
* Computes the number of required arguments. This function is safe for
|
||||
* use with multi-valued typemaps and knows how to skip over everything
|
||||
* use with multi-argument typemaps and knows how to skip over everything
|
||||
* properly. Note that parameters with default values are counted unless
|
||||
* the compact default args option is on.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -398,7 +402,6 @@ String *emit_action(Node *n) {
|
|||
String *tm;
|
||||
String *action;
|
||||
String *wrap;
|
||||
SwigType *rt;
|
||||
ParmList *catchlist = Getattr(n, "catchlist");
|
||||
|
||||
/* Look for fragments */
|
||||
|
|
@ -436,9 +439,6 @@ String *emit_action(Node *n) {
|
|||
action = Getattr(n, "wrap:action");
|
||||
assert(action != 0);
|
||||
|
||||
/* Get the return type */
|
||||
rt = Getattr(n, "type");
|
||||
|
||||
/* Emit contract code (if any) */
|
||||
if (Swig_contract_mode_get()) {
|
||||
/* Preassertion */
|
||||
|
|
@ -458,37 +458,45 @@ String *emit_action(Node *n) {
|
|||
Printf(eaction, "try {\n");
|
||||
}
|
||||
|
||||
String *preaction = Getattr(n, "wrap:preaction");
|
||||
if (preaction)
|
||||
Printv(eaction, preaction, NIL);
|
||||
|
||||
Printv(eaction, action, NIL);
|
||||
|
||||
String *postaction = Getattr(n, "wrap:postaction");
|
||||
if (postaction)
|
||||
Printv(eaction, postaction, NIL);
|
||||
|
||||
if (catchlist) {
|
||||
int unknown_catch = 0;
|
||||
Printf(eaction, "}\n");
|
||||
for (Parm *ep = catchlist; ep; ep = nextSibling(ep)) {
|
||||
String *em = Swig_typemap_lookup("throws", ep, "_e", 0);
|
||||
if (em) {
|
||||
SwigType *et = Getattr(ep, "type");
|
||||
SwigType *etr = SwigType_typedef_resolve_all(et);
|
||||
if (SwigType_isreference(etr) || SwigType_ispointer(etr) || SwigType_isarray(etr)) {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "_e"));
|
||||
} else if (SwigType_isvarargs(etr)) {
|
||||
Printf(eaction, "catch(...) {");
|
||||
} else {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "&_e"));
|
||||
}
|
||||
Printv(eaction, em, "\n", NIL);
|
||||
Printf(eaction, "}\n");
|
||||
SwigType *et = Getattr(ep, "type");
|
||||
SwigType *etr = SwigType_typedef_resolve_all(et);
|
||||
if (SwigType_isreference(etr) || SwigType_ispointer(etr) || SwigType_isarray(etr)) {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "_e"));
|
||||
} else if (SwigType_isvarargs(etr)) {
|
||||
Printf(eaction, "catch(...) {");
|
||||
} else {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "&_e"));
|
||||
}
|
||||
Printv(eaction, em, "\n", NIL);
|
||||
Printf(eaction, "}\n");
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_THROW, Getfile(n), Getline(n), "No 'throws' typemap defined for exception type '%s'\n", SwigType_str(Getattr(ep, "type"), 0));
|
||||
unknown_catch = 1;
|
||||
unknown_catch = 1;
|
||||
}
|
||||
}
|
||||
if (unknown_catch) {
|
||||
Printf(eaction, "catch(...) { throw; }\n");
|
||||
Printf(eaction, "catch(...) { throw; }\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Look for except typemap (Deprecated) */
|
||||
tm = Swig_typemap_lookup("except", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("except", n, Swig_cresult_name(), 0);
|
||||
if (tm) {
|
||||
Setattr(n, "feature:except", tm);
|
||||
tm = 0;
|
||||
|
|
|
|||
4864
Source/Modules/go.cxx
Normal file
4864
Source/Modules/go.cxx
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* guile.cxx
|
||||
*
|
||||
|
|
@ -14,19 +18,15 @@ char cvsroot_guile_cxx[] = "$Id$";
|
|||
#include <ctype.h>
|
||||
|
||||
// Note string broken in half for compilers that can't handle long strings
|
||||
static const char *guile_usage = (char *) "\
|
||||
static const char *usage = (char *) "\
|
||||
Guile Options (available with -guile)\n\
|
||||
-prefix <name> - Use <name> as prefix [default \"gswig_\"]\n\
|
||||
-package <name> - Set the path of the module to <name>\n\
|
||||
(default NULL)\n\
|
||||
-emitsetters - Emit procedures-with-setters for variables\n\
|
||||
and structure slots.\n\
|
||||
-onlysetters - Don't emit traditional getter and setter\n\
|
||||
procedures for structure slots,\n\
|
||||
only emit procedures-with-setters.\n\
|
||||
-procdoc <file> - Output procedure documentation to <file>\n\
|
||||
-procdocformat <format> - Output procedure documentation in <format>;\n\
|
||||
one of `guile-1.4', `plain', `texinfo'\n\
|
||||
-emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\
|
||||
-exportprimitive - Add the (export ...) code from scmstub into the\n\
|
||||
GOOPS file.\n\
|
||||
-gh - Use the gh_ Guile API. (Guile <= 1.8) \n\
|
||||
-goopsprefix <prefix> - Prepend <prefix> to all goops identifiers\n\
|
||||
-linkage <lstyle> - Use linkage protocol <lstyle> (default `simple')\n\
|
||||
Use `module' for native Guile module linking\n\
|
||||
(requires Guile >= 1.5.0). Use `passive' for\n\
|
||||
|
|
@ -34,19 +34,25 @@ Guile Options (available with -guile)\n\
|
|||
`ltdlmod' for Guile's old dynamic module\n\
|
||||
convention (Guile <= 1.4), or `hobbit' for hobbit\n\
|
||||
modules.\n\
|
||||
-scmstub - Output Scheme file with module declaration and\n\
|
||||
exports; only with `passive' and `simple' linkage\n\
|
||||
-gh - Use the gh_ Guile API. (Guile <= 1.8) \n\
|
||||
-scm - Use the scm Guile API. (Guile >= 1.6, default) \n\
|
||||
-onlysetters - Don't emit traditional getter and setter\n\
|
||||
procedures for structure slots,\n\
|
||||
only emit procedures-with-setters.\n\
|
||||
-package <name> - Set the path of the module to <name>\n\
|
||||
(default NULL)\n\
|
||||
-prefix <name> - Use <name> as prefix [default \"gswig_\"]\n\
|
||||
-procdoc <file> - Output procedure documentation to <file>\n\
|
||||
-procdocformat <format> - Output procedure documentation in <format>;\n\
|
||||
one of `guile-1.4', `plain', `texinfo'\n\
|
||||
-proxy - Export GOOPS class definitions\n\
|
||||
-emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\
|
||||
-primsuffix <suffix> - Name appended to primitive module when exporting\n\
|
||||
GOOPS classes. (default = \"primitive\")\n\
|
||||
-goopsprefix <prefix> - Prepend <prefix> to all goops identifiers\n\
|
||||
-scm - Use the scm Guile API. (Guile >= 1.6, default) \n\
|
||||
-scmstub - Output Scheme file with module declaration and\n\
|
||||
exports; only with `passive' and `simple' linkage\n\
|
||||
-useclassprefix - Prepend the class name to all goops identifiers\n\
|
||||
-exportprimitive - Add the (export ...) code from scmstub into the\n\
|
||||
GOOPS file.\n";
|
||||
\n";
|
||||
|
||||
static File *f_begin = 0;
|
||||
static File *f_runtime = 0;
|
||||
static File *f_header = 0;
|
||||
static File *f_wrappers = 0;
|
||||
|
|
@ -109,7 +115,7 @@ static String *memberfunction_name = 0;
|
|||
|
||||
extern "C" {
|
||||
static int has_classname(Node *class_node) {
|
||||
return Getattr(class_node, "guile:goopsclassname") != NULL;
|
||||
return Getattr(class_node, "guile:goopsclassname") ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +136,7 @@ public:
|
|||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(guile_usage, stdout);
|
||||
fputs(usage, stdout);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
|
|
@ -174,7 +180,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);
|
||||
|
|
@ -249,7 +255,7 @@ public:
|
|||
}
|
||||
|
||||
// set default value for primsuffix
|
||||
if (primsuffix == NULL)
|
||||
if (!primsuffix)
|
||||
primsuffix = NewString("primitive");
|
||||
|
||||
//goops support can only be enabled if passive or module linkage is used
|
||||
|
|
@ -299,11 +305,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 +318,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 +330,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 +366,8 @@ public:
|
|||
Printf(f_runtime, "\n}\n");
|
||||
}
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
Language::top(n);
|
||||
|
||||
/* Close module */
|
||||
|
|
@ -392,14 +402,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 +511,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 +542,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");
|
||||
|
|
@ -617,7 +629,7 @@ public:
|
|||
if (maybe_delimiter && Len(output) > 0 && Len(tm) > 0) {
|
||||
Printv(output, maybe_delimiter, NIL);
|
||||
}
|
||||
const String *pn = (name == NULL) ? (const String *) Getattr(p, "name") : name;
|
||||
const String *pn = !name ? (const String *) Getattr(p, "name") : name;
|
||||
String *pt = Getattr(p, "type");
|
||||
Replaceall(tm, "$name", pn); // legacy for $parmname
|
||||
Replaceall(tm, "$type", SwigType_str(pt, 0));
|
||||
|
|
@ -646,7 +658,7 @@ public:
|
|||
Parm *p;
|
||||
String *proc_name = 0;
|
||||
char source[256];
|
||||
Wrapper *f = NewWrapper();;
|
||||
Wrapper *f = NewWrapper();
|
||||
String *cleanup = NewString("");
|
||||
String *outarg = NewString("");
|
||||
String *signature = NewString("");
|
||||
|
|
@ -770,7 +782,7 @@ public:
|
|||
if (strcmp("void", Char(pt)) != 0) {
|
||||
Node *class_node = Swig_symbol_clookup_check(pb, Getattr(n, "sym:symtab"),
|
||||
has_classname);
|
||||
String *goopsclassname = (class_node == NULL) ? NULL : Getattr(class_node, "guile:goopsclassname");
|
||||
String *goopsclassname = !class_node ? NULL : Getattr(class_node, "guile:goopsclassname");
|
||||
/* do input conversion */
|
||||
if (goopsclassname) {
|
||||
Printv(method_signature, " (", argname, " ", goopsclassname, ")", NIL);
|
||||
|
|
@ -870,10 +882,10 @@ public:
|
|||
Printv(actioncode, tab4, "gh_allow_ints();\n", NIL);
|
||||
|
||||
// Now have return value, figure out what to do with it.
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$result", "gswig_result");
|
||||
Replaceall(tm, "$target", "gswig_result");
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
if (GetFlag(n, "feature:new"))
|
||||
Replaceall(tm, "$owner", "1");
|
||||
else
|
||||
|
|
@ -910,14 +922,14 @@ public:
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
}
|
||||
// Free any memory allocated by the function being wrapped..
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
|
@ -1381,9 +1393,10 @@ public:
|
|||
}
|
||||
// See if there's a typemap
|
||||
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
if (SwigType_type(nctype) == T_STRING) {
|
||||
rvalue = NewStringf("\"%s\"", value);
|
||||
} else if (SwigType_type(nctype) == T_CHAR) {
|
||||
} else if (SwigType_type(nctype) == T_CHAR && !is_enum_item) {
|
||||
rvalue = NewStringf("\'%s\'", value);
|
||||
} else {
|
||||
rvalue = NewString(value);
|
||||
|
|
@ -1400,16 +1413,18 @@ public:
|
|||
}
|
||||
{
|
||||
/* Hack alert: will cleanup later -- Dave */
|
||||
Node *n = NewHash();
|
||||
Setattr(n, "name", var_name);
|
||||
Setattr(n, "sym:name", iname);
|
||||
Setattr(n, "type", nctype);
|
||||
SetFlag(n, "feature:immutable");
|
||||
Node *nn = NewHash();
|
||||
Setfile(nn, Getfile(n));
|
||||
Setline(nn, Getline(n));
|
||||
Setattr(nn, "name", var_name);
|
||||
Setattr(nn, "sym:name", iname);
|
||||
Setattr(nn, "type", nctype);
|
||||
SetFlag(nn, "feature:immutable");
|
||||
if (constasvar) {
|
||||
SetFlag(n, "feature:constasvar");
|
||||
SetFlag(nn, "feature:constasvar");
|
||||
}
|
||||
variableWrapper(n);
|
||||
Delete(n);
|
||||
variableWrapper(nn);
|
||||
Delete(nn);
|
||||
}
|
||||
Delete(var_name);
|
||||
Delete(nctype);
|
||||
|
|
@ -1649,11 +1664,11 @@ public:
|
|||
/* ------------------------------------------------------------
|
||||
* goopsNameMapping()
|
||||
* Maps the identifier from C++ to the GOOPS based * on command
|
||||
* line paramaters and such.
|
||||
* line parameters and such.
|
||||
* 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) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* lua.cxx
|
||||
*
|
||||
|
|
@ -36,8 +40,8 @@
|
|||
* ver009
|
||||
class support: ok for basic types, but methods still TDB
|
||||
(code is VERY messed up & needs to be cleaned)
|
||||
|
||||
|
||||
* ver010
|
||||
Added support for embedded Lua. Try swig -lua -help for more information
|
||||
*/
|
||||
|
||||
char cvsroot_lua_cxx[] = "$Id$";
|
||||
|
|
@ -78,10 +82,16 @@ void display_mapping(DOH *d) {
|
|||
(though for now I have not bothered)
|
||||
NEW LANGUAGE NOTE:END ************************************************/
|
||||
static const char *usage = (char *) "\
|
||||
Lua Options (available with -lua)\n\
|
||||
(coming soon.)\n\n";
|
||||
|
||||
Lua Options (available with -lua)\n\
|
||||
-elua - Generates LTR compatible wrappers for smaller devices running elua\n\
|
||||
-eluac - LTR compatible wrappers in \"crass compress\" mode for elua\n\
|
||||
-nomoduleglobal - Do not register the module name as a global variable \n\
|
||||
but return the module table from calls to require.\n\
|
||||
\n";
|
||||
|
||||
static int nomoduleglobal = 0;
|
||||
static int elua_ltr = 0;
|
||||
static int eluac_ltr = 0;
|
||||
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
To add a new language, you need to derive your class from
|
||||
|
|
@ -92,6 +102,7 @@ NEW LANGUAGE NOTE:END ************************************************/
|
|||
class LUA:public Language {
|
||||
private:
|
||||
|
||||
File *f_begin;
|
||||
File *f_runtime;
|
||||
File *f_header;
|
||||
File *f_wrappers;
|
||||
|
|
@ -104,6 +115,9 @@ private:
|
|||
String *s_methods_tab; // table of class methods
|
||||
String *s_attr_tab; // table of class atributes
|
||||
String *s_luacode; // luacode to be called during init
|
||||
String *s_dot_get; // table of variable 'get' functions
|
||||
String *s_dot_set; // table of variable 'set' functions
|
||||
String *s_vars_meta_tab; // metatable for variables
|
||||
|
||||
int have_constructor;
|
||||
int have_destructor;
|
||||
|
|
@ -132,6 +146,7 @@ public:
|
|||
* --------------------------------------------------------------------- */
|
||||
|
||||
LUA() {
|
||||
f_begin = 0;
|
||||
f_runtime = 0;
|
||||
f_header = 0;
|
||||
f_wrappers = 0;
|
||||
|
|
@ -164,7 +179,16 @@ public:
|
|||
for (int i = 1; i < argc; i++) {
|
||||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) { // usage flags
|
||||
fputs(usage, stderr);
|
||||
fputs(usage, stdout);
|
||||
} else if (strcmp(argv[i], "-nomoduleglobal") == 0) {
|
||||
nomoduleglobal = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if(strcmp(argv[i], "-elua") == 0) {
|
||||
elua_ltr = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if(strcmp(argv[i], "-eluac") == 0) {
|
||||
eluac_ltr = 1;
|
||||
Swig_mark_arg(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -213,11 +237,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 +251,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);
|
||||
|
|
@ -242,6 +268,10 @@ public:
|
|||
s_var_tab = NewString("");
|
||||
// s_methods_tab = NewString("");
|
||||
s_const_tab = NewString("");
|
||||
|
||||
s_dot_get = NewString("");
|
||||
s_dot_set = NewString("");
|
||||
s_vars_meta_tab = NewString("");
|
||||
|
||||
s_luacode = NewString("");
|
||||
Swig_register_filebyname("luacode", s_luacode);
|
||||
|
|
@ -249,11 +279,30 @@ 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 (elua_ltr)
|
||||
Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUA\n");
|
||||
else if (eluac_ltr)
|
||||
Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUAC\n");
|
||||
else
|
||||
Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA\n");
|
||||
|
||||
if (nomoduleglobal) {
|
||||
Printf(f_runtime, "#define SWIG_LUA_NO_MODULE_GLOBAL\n");
|
||||
} else {
|
||||
Printf(f_runtime, "#define SWIG_LUA_MODULE_GLOBAL\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);
|
||||
|
|
@ -262,12 +311,31 @@ public:
|
|||
Printf(f_header, "#define SWIG_name \"%s\"\n", module);
|
||||
Printf(f_header, "#define SWIG_init luaopen_%s\n", module);
|
||||
Printf(f_header, "#define SWIG_init_user luaopen_%s_user\n\n", module);
|
||||
Printf(f_header, "#define SWIG_LUACODE luaopen_%s_luacode\n\n", module);
|
||||
Printf(f_header, "#define SWIG_LUACODE luaopen_%s_luacode\n", module);
|
||||
|
||||
Printf(s_cmd_tab, "\nstatic const struct luaL_reg swig_commands[] = {\n");
|
||||
Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n");
|
||||
Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
if (elua_ltr || eluac_ltr)
|
||||
Printf(f_header, "#define swig_commands %s_map\n\n", module);
|
||||
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
Printf(s_cmd_tab, "\n#define MIN_OPT_LEVEL 2\n#include \"lrodefs.h\"\n");
|
||||
Printf(s_cmd_tab, "#include \"lrotable.h\"\n");
|
||||
Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_constants[];\n");
|
||||
if (elua_ltr)
|
||||
Printf(s_cmd_tab, "const LUA_REG_TYPE mt[];\n");
|
||||
|
||||
Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_commands[] = {\n");
|
||||
Printf(s_const_tab, "\nconst LUA_REG_TYPE swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
if (elua_ltr) {
|
||||
Printf(s_dot_get, "\nconst LUA_REG_TYPE dot_get[] = {\n");
|
||||
Printf(s_dot_set, "\nconst LUA_REG_TYPE dot_set[] = {\n");
|
||||
}
|
||||
} else {
|
||||
Printf(s_cmd_tab, "\nstatic const struct luaL_Reg swig_commands[] = {\n");
|
||||
Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n");
|
||||
Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
}
|
||||
|
||||
/* %init code inclusion, effectively in the SWIG_init function */
|
||||
Printf(f_init, "void SWIG_init_user(lua_State* L)\n{\n");
|
||||
|
|
@ -278,23 +346,52 @@ public:
|
|||
Printf(f_wrappers, "#ifdef __cplusplus\n}\n#endif\n");
|
||||
|
||||
// Done. Close up the module & write to the wrappers
|
||||
Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL);
|
||||
Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL);
|
||||
Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"const\"), LROVAL(swig_constants)},\n", NIL);
|
||||
if (elua_ltr)
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"__metatable\"), LROVAL(mt)},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL);
|
||||
} else {
|
||||
Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL);
|
||||
Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL);
|
||||
}
|
||||
|
||||
if (elua_ltr) {
|
||||
/* Generate the metatable */
|
||||
Printf(s_vars_meta_tab, "\nconst LUA_REG_TYPE mt[] = {\n");
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__index\"), LFUNCVAL(SWIG_Lua_module_get)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__newindex\"), LFUNCVAL(SWIG_Lua_module_set)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".get\"), LROVAL(dot_get)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".set\"), LROVAL(dot_set)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
|
||||
Printv(s_dot_get, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
Printv(s_dot_set, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
}
|
||||
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
/* Final close up of wrappers */
|
||||
Printv(f_wrappers, s_cmd_tab, s_dot_get, s_dot_set, s_vars_meta_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
} else {
|
||||
Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
}
|
||||
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
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 +401,12 @@ public:
|
|||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Delete(f_initbeforefunc);
|
||||
Close(f_runtime);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
Delete(s_dot_get);
|
||||
Delete(s_dot_set);
|
||||
Delete(s_vars_meta_tab);
|
||||
|
||||
/* Done */
|
||||
return SWIG_OK;
|
||||
|
|
@ -429,10 +530,8 @@ public:
|
|||
String *argument_check = NewString("");
|
||||
String *argument_parse = NewString("");
|
||||
String *checkfn = NULL;
|
||||
// String *numoutputs=NULL;
|
||||
char source[64];
|
||||
//Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",name,num_required,num_arguments);
|
||||
Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",name,num_required+args_to_ignore,num_arguments+args_to_ignore);
|
||||
Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",Swig_name_str(n),num_required+args_to_ignore,num_arguments+args_to_ignore);
|
||||
|
||||
for (i = 0, p = l; i < num_arguments; i++) {
|
||||
|
||||
|
|
@ -468,7 +567,7 @@ public:
|
|||
} else {
|
||||
Printf(argument_check, "if(lua_gettop(L)>=%s && !%s(L,%s))", source, checkfn, source);
|
||||
}
|
||||
Printf(argument_check, " SWIG_fail_arg(\"%s\",%s,\"%s\");\n", name, source, SwigType_str(pt, 0));
|
||||
Printf(argument_check, " SWIG_fail_arg(\"%s\",%s,\"%s\");\n", Swig_name_str(n), source, SwigType_str(pt, 0));
|
||||
}
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
lua states the number of arguments passed to a function using the fn
|
||||
|
|
@ -490,8 +589,6 @@ public:
|
|||
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
|
||||
break;
|
||||
}
|
||||
|
||||
p = nextSibling(p);
|
||||
}
|
||||
|
||||
// add all argcheck code
|
||||
|
|
@ -540,7 +637,7 @@ public:
|
|||
// }
|
||||
// else returnval++;
|
||||
Replaceall(tm, "$source", Getattr(p, "lname"));
|
||||
Replaceall(tm, "$target", "result");
|
||||
Replaceall(tm, "$target", Swig_cresult_name());
|
||||
Replaceall(tm, "$arg", Getattr(p, "emit:input"));
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:input"));
|
||||
Printv(outarg, tm, "\n", NIL);
|
||||
|
|
@ -561,7 +658,7 @@ public:
|
|||
this is because there is a typemap for void
|
||||
NEW LANGUAGE NOTE:END ************************************************/
|
||||
// Return value if necessary
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
// managing the number of returning variables
|
||||
// if (numoutputs=Getattr(tm,"numoutputs")){
|
||||
// int i=GetInt(tm,"numoutputs");
|
||||
|
|
@ -569,7 +666,7 @@ public:
|
|||
// returnval+=GetInt(tm,"numoutputs");
|
||||
// }
|
||||
// else returnval++;
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
Replaceall(tm, "$owner", "1");
|
||||
} else {
|
||||
|
|
@ -590,15 +687,15 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -617,7 +714,7 @@ public:
|
|||
|
||||
/* Substitute the function name */
|
||||
Replaceall(f->code, "$symname", iname);
|
||||
Replaceall(f->code, "$result", "result");
|
||||
Replaceall(f->code, "$result", Swig_cresult_name());
|
||||
|
||||
/* Dump the function out */
|
||||
/* in Lua we will not emit the destructor as a wrappered function,
|
||||
|
|
@ -638,9 +735,13 @@ public:
|
|||
/* Now register the function with the interpreter. */
|
||||
if (!Getattr(n, "sym:overloaded")) {
|
||||
// add_method(n, iname, wname, description);
|
||||
if (current==NO_CPP || current==STATIC_FUNC) // emit normal fns & static fns
|
||||
Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
if (current==NO_CPP || current==STATIC_FUNC) { // emit normal fns & static fns
|
||||
if(elua_ltr || eluac_ltr)
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "\")", ", LFUNCVAL(", Swig_name_wrapper(iname), ")", "},\n", NIL);
|
||||
else
|
||||
Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
// Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
}
|
||||
} else {
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
dispatchFunction(n);
|
||||
|
|
@ -704,7 +805,9 @@ public:
|
|||
sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up
|
||||
String *protoTypes = NewString("");
|
||||
do {
|
||||
Printf(protoTypes, "\n\" %s(%s)\\n\"", SwigType_str(Getattr(sibl, "name"), 0), ParmList_protostr(Getattr(sibl, "wrap:parms")));
|
||||
String *fulldecl = Swig_name_decl(sibl);
|
||||
Printf(protoTypes, "\n\" %s\\n\"", fulldecl);
|
||||
Delete(fulldecl);
|
||||
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
|
||||
Printf(f->code, "lua_pushstring(L,\"Wrong arguments for overloaded function '%s'\\n\"\n"
|
||||
"\" Possible C/C++ prototypes are:\\n\"%s);\n",symname,protoTypes);
|
||||
|
|
@ -744,10 +847,10 @@ public:
|
|||
current=NO_CPP;
|
||||
// normally SWIG will generate 2 wrappers, a get and a set
|
||||
// but in certain scenarios (immutable, or if its arrays), it will not
|
||||
String *getName = Swig_name_wrapper(Swig_name_get(iname));
|
||||
String *getName = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, iname));
|
||||
String *setName = 0;
|
||||
// checking whether it can be set to or not appears to be a very error prone issue
|
||||
// I refered to the Language::variableWrapper() to find this out
|
||||
// I referred to the Language::variableWrapper() to find this out
|
||||
bool assignable=is_assignable(n) ? true : false;
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *tm = Swig_typemap_lookup("globalin", n, iname, 0);
|
||||
|
|
@ -756,14 +859,23 @@ public:
|
|||
Delete(tm);
|
||||
|
||||
if (assignable) {
|
||||
setName = Swig_name_wrapper(Swig_name_set(iname));
|
||||
setName = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, iname));
|
||||
} else {
|
||||
// how about calling a 'this is not settable' error message?
|
||||
setName = NewString("SWIG_Lua_set_immutable"); // error message
|
||||
//setName = NewString("0");
|
||||
}
|
||||
|
||||
// register the variable
|
||||
Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName);
|
||||
if (elua_ltr) {
|
||||
Printf(s_dot_get, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, getName);
|
||||
Printf(s_dot_set, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, setName);
|
||||
} else if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_get", "\")", ", LFUNCVAL(", getName, ")", "},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_set", "\")", ", LFUNCVAL(", setName, ")", "},\n", NIL);
|
||||
} else {
|
||||
Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName);
|
||||
}
|
||||
Delete(getName);
|
||||
Delete(setName);
|
||||
return result;
|
||||
|
|
@ -776,7 +888,6 @@ public:
|
|||
// REPORT("constantWrapper", n);
|
||||
String *name = Getattr(n, "name");
|
||||
String *iname = Getattr(n, "sym:name");
|
||||
//String *nsname = !nspace ? Copy(iname) : NewStringf("%s::%s",ns_name,iname);
|
||||
String *nsname = Copy(iname);
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *rawval = Getattr(n, "rawval");
|
||||
|
|
@ -785,7 +896,6 @@ public:
|
|||
|
||||
if (!addSymbol(iname, n))
|
||||
return SWIG_ERROR;
|
||||
//if (nspace) Setattr(n,"sym:name",nsname);
|
||||
|
||||
/* Special hook for member pointer */
|
||||
if (SwigType_type(type) == T_MPOINTER) {
|
||||
|
|
@ -799,7 +909,7 @@ public:
|
|||
Replaceall(tm, "$target", name);
|
||||
Replaceall(tm, "$value", value);
|
||||
Replaceall(tm, "$nsname", nsname);
|
||||
Printf(s_const_tab, "%s,\n", tm);
|
||||
Printf(s_const_tab, " %s,\n", tm);
|
||||
} else if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
|
||||
Replaceall(tm, "$source", value);
|
||||
Replaceall(tm, "$target", name);
|
||||
|
|
@ -877,7 +987,7 @@ public:
|
|||
real_classname = Getattr(n, "name");
|
||||
mangled_classname = Swig_name_mangle(real_classname);
|
||||
|
||||
// not sure exactly how this workswhat this works,
|
||||
// not sure exactly how this works,
|
||||
// but tcl has a static hashtable of all classes emitted and then only emits code for them once.
|
||||
// this fixes issues in test suites: template_default2 & template_specialization
|
||||
|
||||
|
|
@ -907,7 +1017,7 @@ public:
|
|||
String *wrap_class = NewStringf("&_wrap_class_%s", mangled_classname);
|
||||
SwigType_remember_clientdata(t, wrap_class);
|
||||
|
||||
String *rt = Copy(Getattr(n, "classtype"));
|
||||
String *rt = Copy(getClassType());
|
||||
SwigType_add_pointer(rt);
|
||||
|
||||
// Register the class structure with the type checker
|
||||
|
|
@ -939,7 +1049,7 @@ public:
|
|||
Delete(s_attr_tab);
|
||||
|
||||
// Handle inheritance
|
||||
// note: with the idea of class hireachied spread over multiple modules
|
||||
// note: with the idea of class hierarchies spread over multiple modules
|
||||
// cf test-suite: imports.i
|
||||
// it is not possible to just add the pointers to the base classes to the code
|
||||
// (as sometimes these classes are not present)
|
||||
|
|
@ -983,7 +1093,17 @@ public:
|
|||
Printv(f_wrappers, "static swig_lua_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
|
||||
|
||||
if (have_constructor) {
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(constructor_name)));
|
||||
if (elua_ltr) {
|
||||
Printf(s_cmd_tab, " {LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", class_name, \
|
||||
Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
} else if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "new_", class_name, "\")", ", LFUNCVAL(", \
|
||||
Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)), ")", "},\n", NIL);
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
} else {
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
}
|
||||
Delete(constructor_name);
|
||||
constructor_name = 0;
|
||||
} else {
|
||||
|
|
@ -991,7 +1111,12 @@ public:
|
|||
}
|
||||
|
||||
if (have_destructor) {
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "free_", class_name, "\")", ", LFUNCVAL(", "swig_delete_", class_name, ")", "},\n", NIL);
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
} else {
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
}
|
||||
} else {
|
||||
Printf(f_wrappers, ",0");
|
||||
}
|
||||
|
|
@ -1029,7 +1154,7 @@ public:
|
|||
current = NO_CPP;
|
||||
|
||||
realname = iname ? iname : name;
|
||||
rname = Swig_name_wrapper(Swig_name_member(class_name, realname));
|
||||
rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
Printv(s_methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL);
|
||||
}
|
||||
|
|
@ -1049,14 +1174,20 @@ public:
|
|||
current = MEMBER_VAR;
|
||||
Language::membervariableHandler(n);
|
||||
current = NO_CPP;
|
||||
gname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
|
||||
gname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
if (!GetFlag(n, "feature:immutable")) {
|
||||
sname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
|
||||
sname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
} else {
|
||||
//sname = NewString("0");
|
||||
sname = NewString("SWIG_Lua_set_immutable"); // error message
|
||||
}
|
||||
Printf(s_attr_tab,"%s{ \"%s\", %s, %s},\n",tab4,symname,gname,sname);
|
||||
if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_get", "\")", \
|
||||
", LFUNCVAL(", gname, ")", "},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_set", "\")", \
|
||||
", LFUNCVAL(", sname, ")", "},\n", NIL);
|
||||
}
|
||||
Delete(gname);
|
||||
Delete(sname);
|
||||
return SWIG_OK;
|
||||
|
|
@ -1101,7 +1232,6 @@ public:
|
|||
virtual int staticmemberfunctionHandler(Node *n) {
|
||||
current = STATIC_FUNC;
|
||||
return Language::staticmemberfunctionHandler(n);
|
||||
current = NO_CPP;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
|
|
@ -1123,7 +1253,6 @@ public:
|
|||
// REPORT("staticmembervariableHandler",n);
|
||||
current = STATIC_VAR;
|
||||
return Language::staticmembervariableHandler(n);
|
||||
current = NO_CPP;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
|
|
@ -1139,9 +1268,7 @@ public:
|
|||
*/
|
||||
String *runtimeCode() {
|
||||
String *s = NewString("");
|
||||
const char *filenames[] = { "luarun.swg", 0
|
||||
}
|
||||
; // must be 0 termiated
|
||||
const char *filenames[] = { "luarun.swg", 0 } ; // must be 0 terminated
|
||||
String *sfile;
|
||||
for (int i = 0; filenames[i] != 0; i++) {
|
||||
sfile = Swig_include_sys(filenames[i]);
|
||||
|
|
@ -1152,7 +1279,6 @@ public:
|
|||
Delete(sfile);
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* main.cxx
|
||||
*
|
||||
|
|
@ -25,7 +29,7 @@ char cvsroot_main_cxx[] = "$Id$";
|
|||
|
||||
// Global variables
|
||||
|
||||
Language *lang; // Language method
|
||||
static Language *lang = 0; // Language method
|
||||
int CPlusPlus = 0;
|
||||
int Extend = 0; // Extend flag
|
||||
int ForceExtern = 0; // Force extern mode
|
||||
|
|
@ -33,7 +37,7 @@ int GenerateDefault = 1; // Generate default constructors
|
|||
int Verbose = 0;
|
||||
int AddExtern = 0;
|
||||
int NoExcept = 0;
|
||||
int SwigRuntime = 0; // 0 = no option, 1 = -c or -runtime, 2 = -noruntime
|
||||
int SwigRuntime = 0; // 0 = no option, 1 = -runtime, 2 = -noruntime
|
||||
|
||||
/* Suppress warning messages for private inheritance, preprocessor evaluation etc...
|
||||
WARN_PP_EVALUATION 202
|
||||
|
|
@ -62,11 +66,17 @@ static const char *usage1 = (const char *) "\
|
|||
-copyright - Display copyright notices\n\
|
||||
-debug-classes - Display information about the classes found in the interface\n\
|
||||
-debug-module <n>- Display module parse tree at stages 1-4, <n> is a csv list of stages\n\
|
||||
-debug-symtabs - Display symbol tables information\n\
|
||||
-debug-symbols - Display target language symbols in the symbol tables\n\
|
||||
-debug-csymbols - Display C symbols in the symbol tables\n\
|
||||
-debug-lsymbols - Display target language layer symbols\n\
|
||||
-debug-tags - Display information about the tags found in the interface\n\
|
||||
-debug-template - Display information for debugging templates\n\
|
||||
-debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages\n\
|
||||
-debug-typedef - Display information about the types and typedefs in the interface\n\
|
||||
-debug-typemap - Display information for debugging typemaps\n\
|
||||
-debug-typemap - Display typemap debugging information\n\
|
||||
-debug-tmsearch - Display typemap search debugging information\n\
|
||||
-debug-tmused - Display typemaps used debugging information\n\
|
||||
-directors - Turn on director mode for all the classes, mainly for testing\n\
|
||||
-dirprot - Turn on wrapping of protected members for director classes (default)\n\
|
||||
-D<symbol> - Define a symbol <symbol> (for conditional compilation)\n\
|
||||
|
|
@ -117,7 +127,9 @@ 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\
|
||||
-pcreversion - Display PCRE version information\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\
|
||||
|
|
@ -143,9 +155,9 @@ is equivalent to: \n\
|
|||
\n";
|
||||
|
||||
// Local variables
|
||||
static String *LangSubDir = 0; // Target language library subdirectory
|
||||
static char *SwigLib = 0; // Library directory
|
||||
static String *SwigLibWin = 0; // Extra Library directory for Windows
|
||||
static String *LangSubDir = 0; // Target language library subdirectory
|
||||
static String *SwigLib = 0; // Library directory
|
||||
static String *SwigLibWinUnix = 0; // Extra library directory on Windows
|
||||
static int freeze = 0;
|
||||
static String *lang_config = 0;
|
||||
static char *hpp_extension = (char *) "h";
|
||||
|
|
@ -153,13 +165,18 @@ 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;
|
||||
static int no_cpp = 0;
|
||||
static char *outfile_name = 0;
|
||||
static char *outfile_name_h = 0;
|
||||
static String *outfile_name = 0;
|
||||
static String *outfile_name_h = 0;
|
||||
static int tm_debug = 0;
|
||||
static int dump_symtabs = 0;
|
||||
static int dump_symbols = 0;
|
||||
static int dump_csymbols = 0;
|
||||
static int dump_lang_symbols = 0;
|
||||
static int dump_tags = 0;
|
||||
static int dump_module = 0;
|
||||
static int dump_top = 0;
|
||||
|
|
@ -172,22 +189,23 @@ static int depend = 0;
|
|||
static int depend_only = 0;
|
||||
static int memory_debug = 0;
|
||||
static int allkw = 0;
|
||||
static DOH *libfiles = 0;
|
||||
static DOH *cpps = 0;
|
||||
static String *dependencies_file = 0;
|
||||
static File *f_dependencies_file = 0;
|
||||
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 *libfiles = 0;
|
||||
static List *all_output_files = 0;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// check_suffix(char *name)
|
||||
//
|
||||
// Checks the suffix of a file to see if we should emit extern declarations.
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 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;
|
||||
|
|
@ -199,10 +217,11 @@ static int check_suffix(const char *name) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// install_opts(int argc, char *argv[])
|
||||
// Install all command line options as preprocessor symbols
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* install_opts()
|
||||
*
|
||||
* Install all command line options as preprocessor symbols
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void install_opts(int argc, char *argv[]) {
|
||||
int i;
|
||||
|
|
@ -238,11 +257,12 @@ static void install_opts(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// decode_numbers_list(String *numlist)
|
||||
// Decode comma separated list into a binary number of the inputs or'd together
|
||||
// eg list="1,4" will return (2^0 || 2^3) = 0x1001
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* decode_numbers_list()
|
||||
*
|
||||
* Decode comma separated list into a binary number of the inputs or'd together
|
||||
* eg list="1,4" will return (2^0 || 2^3) = 0x1001
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static unsigned int decode_numbers_list(String *numlist) {
|
||||
unsigned int decoded_number = 0;
|
||||
|
|
@ -262,26 +282,29 @@ static unsigned int decode_numbers_list(String *numlist) {
|
|||
return decoded_number;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Sets the output directory for language specific (proxy) files if not set and
|
||||
// adds trailing file separator if necessary.
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Sets the output directory for language specific (proxy) files if not set and
|
||||
* corrects the directory name and adds trailing file separator if necessary.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void set_outdir(const String *c_wrapper_file_dir) {
|
||||
static void configure_outdir(const String *c_wrapper_file_dir) {
|
||||
|
||||
// Add file delimiter if not present in output directory name
|
||||
if (outdir && Len(outdir) != 0) {
|
||||
// Use the C wrapper file's directory if the output directory has not been set by user
|
||||
if (!outdir || Len(outdir) == 0)
|
||||
outdir = NewString(c_wrapper_file_dir);
|
||||
|
||||
Swig_filename_correct(outdir);
|
||||
|
||||
// Add trailing file delimiter if not present in output directory name
|
||||
if (Len(outdir) > 0) {
|
||||
const char *outd = Char(outdir);
|
||||
if (strcmp(outd + strlen(outd) - strlen(SWIG_FILE_DELIMITER), SWIG_FILE_DELIMITER) != 0)
|
||||
Printv(outdir, SWIG_FILE_DELIMITER, NIL);
|
||||
}
|
||||
// Use the C wrapper file's directory if the output directory has not been set by user
|
||||
if (!outdir)
|
||||
outdir = NewString(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 +323,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 +391,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) {
|
||||
|
|
@ -389,13 +418,6 @@ static void SWIG_dump_runtime() {
|
|||
Printf(runtime, "%s", s);
|
||||
Delete(s);
|
||||
|
||||
s = Swig_include_sys("swigerrors.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigerrors.swg'\n");
|
||||
Close(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
s = Swig_include_sys("swigrun.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigrun.swg'\n");
|
||||
|
|
@ -487,17 +509,23 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-nodirprot") == 0) {
|
||||
Wrapper_director_protected_mode_set(0);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-pcreversion") == 0) {
|
||||
String *version = Swig_pcre_version();
|
||||
Printf(stdout, "%s\n", version);
|
||||
Delete(version);
|
||||
Swig_mark_arg(i);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-small") == 0) {
|
||||
Wrapper_compact_print_mode_set(1);
|
||||
Wrapper_virtual_elimination_mode_set(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-runtime") == 0) {
|
||||
} else if (strcmp(argv[i], "-runtime") == 0) { // Used to also accept -c. removed in swig-1.3.36
|
||||
Swig_mark_arg(i);
|
||||
Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-c, -runtime, -noruntime command line options are deprecated.\n");
|
||||
Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-runtime, -noruntime command line options are deprecated.\n");
|
||||
SwigRuntime = 1;
|
||||
} else if ((strcmp(argv[i], "-c") == 0) || (strcmp(argv[i], "-noruntime") == 0)) {
|
||||
} else if (strcmp(argv[i], "-noruntime") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-c, -runtime, -noruntime command line options are deprecated.\n");
|
||||
Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-runtime, -noruntime command line options are deprecated.\n");
|
||||
SwigRuntime = 2;
|
||||
} else if (strcmp(argv[i], "-external-runtime") == 0) {
|
||||
external_runtime = 1;
|
||||
|
|
@ -546,23 +574,24 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
Swig_cparse_follow_locators(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-swiglib") == 0) {
|
||||
if (SwigLibWin)
|
||||
printf("%s\n", Char(SwigLibWin));
|
||||
printf("%s\n", SwigLib);
|
||||
Printf(stdout, "%s\n", SwigLib);
|
||||
if (SwigLibWinUnix)
|
||||
Printf(stdout, "%s\n", SwigLibWinUnix);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-o") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
outfile_name = Swig_copy_string(argv[i + 1]);
|
||||
outfile_name = NewString(argv[i + 1]);
|
||||
Swig_filename_correct(outfile_name);
|
||||
if (!outfile_name_h || !dependencies_file) {
|
||||
char *ext = strrchr(outfile_name, '.');
|
||||
String *basename = ext ? NewStringWithSize(outfile_name, ext - outfile_name) : NewString(outfile_name);
|
||||
char *ext = strrchr(Char(outfile_name), '.');
|
||||
String *basename = ext ? NewStringWithSize(Char(outfile_name), Char(ext) - Char(outfile_name)) : NewString(outfile_name);
|
||||
if (!dependencies_file) {
|
||||
dependencies_file = NewStringf("%s.%s", basename, depends_extension);
|
||||
}
|
||||
if (!outfile_name_h) {
|
||||
Printf(basename, ".%s", hpp_extension);
|
||||
outfile_name_h = Swig_copy_string(Char(basename));
|
||||
outfile_name_h = NewString(basename);
|
||||
}
|
||||
Delete(basename);
|
||||
}
|
||||
|
|
@ -574,7 +603,8 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-oh") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
outfile_name_h = Swig_copy_string(argv[i + 1]);
|
||||
outfile_name_h = NewString(argv[i + 1]);
|
||||
Swig_filename_correct(outfile_name_h);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
|
|
@ -592,7 +622,14 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-version") == 0) {
|
||||
fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version());
|
||||
fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM);
|
||||
fprintf(stdout, "Please see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT);
|
||||
fprintf(stdout, "\nConfigured options: %cpcre\n",
|
||||
#ifdef HAVE_PCRE
|
||||
'+'
|
||||
#else
|
||||
'-'
|
||||
#endif
|
||||
);
|
||||
fprintf(stdout, "\nPlease see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-copyright") == 0) {
|
||||
fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version());
|
||||
|
|
@ -639,6 +676,12 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if ((strcmp(argv[i], "-debug-typemap") == 0) || (strcmp(argv[i], "-debug_typemap") == 0) || (strcmp(argv[i], "-tm_debug") == 0)) {
|
||||
tm_debug = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-debug-tmsearch") == 0) {
|
||||
Swig_typemap_search_debug_set();
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-debug-tmused") == 0) {
|
||||
Swig_typemap_used_debug_set();
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-module") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
|
|
@ -688,6 +731,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();
|
||||
|
|
@ -703,6 +749,18 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strncmp(argv[i], "-w", 2) == 0) {
|
||||
Swig_mark_arg(i);
|
||||
Swig_warnfilter(argv[i] + 2, 1);
|
||||
} else if (strcmp(argv[i], "-debug-symtabs") == 0) {
|
||||
dump_symtabs = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-debug-symbols") == 0) {
|
||||
dump_symbols = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-debug-csymbols") == 0) {
|
||||
dump_csymbols = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-debug-lsymbols") == 0) {
|
||||
dump_lang_symbols = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if ((strcmp(argv[i], "-debug-tags") == 0) || (strcmp(argv[i], "-dump_tags") == 0)) {
|
||||
dump_tags = 1;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -798,7 +856,6 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
|
||||
int SWIG_main(int argc, char *argv[], Language *l) {
|
||||
char *c;
|
||||
extern void Swig_print_xml(Node *obj, String *filename);
|
||||
|
||||
/* Initialize the SWIG core */
|
||||
Swig_init();
|
||||
|
|
@ -816,12 +873,6 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
|
||||
Preprocessor_define((DOH *) "SWIG 1", 0);
|
||||
Preprocessor_define((DOH *) "__STDC__", 0);
|
||||
#ifdef MACSWIG
|
||||
Preprocessor_define((DOH *) "SWIGMAC 1", 0);
|
||||
#endif
|
||||
#ifdef SWIGWIN32
|
||||
Preprocessor_define((DOH *) "SWIGWIN32 1", 0);
|
||||
#endif
|
||||
|
||||
// Set the SWIG version value in format 0xAABBCC from package version expected to be in format A.B.C
|
||||
String *package_version = NewString(PACKAGE_VERSION); /* Note that the fakeversion has not been set at this point */
|
||||
|
|
@ -856,17 +907,21 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
char *p;
|
||||
if (!(GetModuleFileName(0, buf, MAX_PATH) == 0 || (p = strrchr(buf, '\\')) == 0)) {
|
||||
*(p + 1) = '\0';
|
||||
SwigLibWin = NewStringf("%sLib", buf); // Native windows installation path
|
||||
SwigLib = NewStringf("%sLib", buf); // Native windows installation path
|
||||
} else {
|
||||
SwigLib = NewStringf(""); // Unexpected error
|
||||
}
|
||||
SwigLib = Swig_copy_string(SWIG_LIB_WIN_UNIX); // Unix installation path using a drive letter (for msys/mingw)
|
||||
if (Len(SWIG_LIB_WIN_UNIX) > 0)
|
||||
SwigLibWinUnix = NewString(SWIG_LIB_WIN_UNIX); // Unix installation path using a drive letter (for msys/mingw)
|
||||
#else
|
||||
SwigLib = Swig_copy_string(SWIG_LIB);
|
||||
SwigLib = NewString(SWIG_LIB);
|
||||
#endif
|
||||
} else {
|
||||
SwigLib = Swig_copy_string(c);
|
||||
SwigLib = NewString(c);
|
||||
}
|
||||
|
||||
libfiles = NewList();
|
||||
all_output_files = NewList();
|
||||
|
||||
/* Check for SWIG_FEATURES environment variable */
|
||||
|
||||
|
|
@ -894,9 +949,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
String *rl = NewString("");
|
||||
Printf(rl, ".%sswig_lib%s%s", SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER, LangSubDir);
|
||||
Swig_add_directory(rl);
|
||||
if (SwigLibWin) {
|
||||
if (SwigLibWinUnix) {
|
||||
rl = NewString("");
|
||||
Printf(rl, "%s%s%s", SwigLibWin, SWIG_FILE_DELIMITER, LangSubDir);
|
||||
Printf(rl, "%s%s%s", SwigLibWinUnix, SWIG_FILE_DELIMITER, LangSubDir);
|
||||
Swig_add_directory(rl);
|
||||
}
|
||||
rl = NewString("");
|
||||
|
|
@ -905,13 +960,13 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
|
||||
Swig_add_directory((String *) "." SWIG_FILE_DELIMITER "swig_lib");
|
||||
if (SwigLibWin)
|
||||
Swig_add_directory((String *) SwigLibWin);
|
||||
Swig_add_directory((String *) SwigLib);
|
||||
if (SwigLibWinUnix)
|
||||
Swig_add_directory((String *) SwigLibWinUnix);
|
||||
Swig_add_directory(SwigLib);
|
||||
|
||||
if (Verbose) {
|
||||
printf("LangSubDir: %s\n", Char(LangSubDir));
|
||||
printf("Search paths:\n");
|
||||
Printf(stdout, "Language subdirectory: %s\n", LangSubDir);
|
||||
Printf(stdout, "Search paths:\n");
|
||||
List *sp = Swig_search_path();
|
||||
Iterator s;
|
||||
for (s = First(sp); s.item; s = Next(s)) {
|
||||
|
|
@ -924,64 +979,66 @@ 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;
|
||||
String *outfile = input_file;
|
||||
if (outfile_name)
|
||||
outfile = outfile_name;
|
||||
|
||||
if (Verbose)
|
||||
printf("Handling checkout...\n");
|
||||
Printf(stdout, "Handling checkout...\n");
|
||||
|
||||
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");
|
||||
Printf(stdout, "Preprocessing...\n");
|
||||
|
||||
{
|
||||
int i;
|
||||
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,16 +1046,16 @@ 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_filename_escape(Swig_last_file()));
|
||||
for (i = 0; i < Len(libfiles); i++) {
|
||||
Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i));
|
||||
Printf(fs, "\n%%include \"%s\"\n", Swig_filename_escape(Getitem(libfiles, i)));
|
||||
}
|
||||
Seek(fs, 0, SEEK_SET);
|
||||
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 +1065,60 @@ 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;
|
||||
File *f_dependencies_file = 0;
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
List *files = Preprocessor_depend();
|
||||
for (int i = 0; i < Len(files); i++) {
|
||||
int use_file = 1;
|
||||
if (depend == 2) {
|
||||
if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWinUnix && (Strncmp(Getitem(files, i), SwigLibWinUnix, Len(SwigLibWinUnix)) == 0)))
|
||||
use_file = 0;
|
||||
}
|
||||
if (use_file)
|
||||
Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
|
||||
}
|
||||
Printf(f_dependencies_file, "\n");
|
||||
if (f_dependencies_file != stdout)
|
||||
Close(f_dependencies_file);
|
||||
if (depend_only)
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else {
|
||||
outfile = NewString(outfile_name);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
} else
|
||||
f_dependencies_file = stdout;
|
||||
if (dependencies_target) {
|
||||
Printf(f_dependencies_file, "%s: ", dependencies_target);
|
||||
} 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(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);
|
||||
}
|
||||
|
|
@ -1118,7 +1188,20 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
|
||||
if (dump_typedef) {
|
||||
SwigType_print_scope(0);
|
||||
SwigType_print_scope();
|
||||
}
|
||||
|
||||
if (dump_symtabs) {
|
||||
Swig_symbol_print_tables(Swig_symbol_global_scope());
|
||||
Swig_symbol_print_tables_summary();
|
||||
}
|
||||
|
||||
if (dump_symbols) {
|
||||
Swig_symbol_print_symbols();
|
||||
}
|
||||
|
||||
if (dump_csymbols) {
|
||||
Swig_symbol_print_csymbols();
|
||||
}
|
||||
|
||||
if (dump_tags) {
|
||||
|
|
@ -1126,35 +1209,51 @@ 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);
|
||||
}
|
||||
set_outdir(Swig_file_dirname(Getattr(top, "outfile")));
|
||||
configure_outdir(Swig_file_dirname(Getattr(top, "outfile")));
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dump_lang_symbols) {
|
||||
lang->dumpSymbols();
|
||||
}
|
||||
if (dump_top & STAGE4) {
|
||||
Printf(stdout, "debug-top stage 4\n");
|
||||
Swig_print_tree(top);
|
||||
|
|
@ -1164,6 +1263,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
Swig_print_tree(Getattr(top, "module"));
|
||||
}
|
||||
if (dump_xml && top) {
|
||||
delete lang;
|
||||
lang = 0;
|
||||
Swig_print_xml(top, xmlout);
|
||||
}
|
||||
Delete(top);
|
||||
|
|
@ -1173,6 +1274,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();
|
||||
|
|
@ -1183,14 +1299,17 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
if ((werror) && (Swig_warn_count())) {
|
||||
return Swig_warn_count();
|
||||
}
|
||||
|
||||
delete lang;
|
||||
|
||||
return Swig_error_count();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// SWIG_exit(int exit_code)
|
||||
//
|
||||
// Cleanup and either freeze or exit
|
||||
// --------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SWIG_exit()
|
||||
*
|
||||
* Cleanup and either freeze or exit
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void SWIG_exit(int exit_code) {
|
||||
while (freeze) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* modula3.cxx
|
||||
*
|
||||
|
|
@ -81,7 +85,7 @@ char cvsroot_modula3_cxx[] = "$Id$";
|
|||
that assign special purposes to the array types.
|
||||
- Can one interpret $n_basetype as the identifier matched with SWIGTYPE ?
|
||||
|
||||
Swig's odds:
|
||||
SWIG's odds:
|
||||
- arguments of type (Node *) for SWIG functions
|
||||
should be most often better (const Node *):
|
||||
Swig_symbol_qualified, Getattr, nodeType, parentNode
|
||||
|
|
@ -127,7 +131,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 +176,7 @@ private:
|
|||
const String *empty_string;
|
||||
|
||||
Hash *swig_types_hash;
|
||||
File *f_begin;
|
||||
File *f_runtime;
|
||||
File *f_header;
|
||||
File *f_wrappers;
|
||||
|
|
@ -237,6 +242,7 @@ public:
|
|||
MODULA3():
|
||||
empty_string(NewString("")),
|
||||
swig_types_hash(NULL),
|
||||
f_begin(NULL),
|
||||
f_runtime(NULL),
|
||||
f_header(NULL),
|
||||
f_wrappers(NULL),
|
||||
|
|
@ -374,7 +380,7 @@ MODULA3():
|
|||
} else if (Strcmp(dir, "out") == 0) {
|
||||
return false;
|
||||
} else {
|
||||
printf(usageArgDir);
|
||||
printf("%s", USAGE_ARG_DIR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -386,7 +392,7 @@ MODULA3():
|
|||
} else if ((Strcmp(dir, "out") == 0) || (Strcmp(dir, "inout") == 0)) {
|
||||
return true;
|
||||
} else {
|
||||
printf(usageArgDir);
|
||||
printf("%s", USAGE_ARG_DIR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -472,9 +478,9 @@ MODULA3():
|
|||
cap = true;
|
||||
} else {
|
||||
if (cap) {
|
||||
m3sym[i] = toupper(c);
|
||||
m3sym[i] = (char)toupper(c);
|
||||
} else {
|
||||
m3sym[i] = tolower(c);
|
||||
m3sym[i] = (char)tolower(c);
|
||||
}
|
||||
cap = false;
|
||||
}
|
||||
|
|
@ -542,7 +548,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 +908,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 +923,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,12 +964,16 @@ MODULA3():
|
|||
module_imports = NewString("");
|
||||
upcasts_code = NewString("");
|
||||
|
||||
Swig_banner(f_runtime); // Print the SWIG banner message
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Swig_name_register((char *) "wrapper", (char *) "Modula3_%f");
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGMODULA3\n");
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
Swig_name_register("wrapper", "Modula3_%f");
|
||||
if (old_variable_names) {
|
||||
Swig_name_register((char *) "set", (char *) "set_%v");
|
||||
Swig_name_register((char *) "get", (char *) "get_%v");
|
||||
Swig_name_register("set", "set_%n%v");
|
||||
Swig_name_register("get", "get_%n%v");
|
||||
}
|
||||
|
||||
Printf(f_wrappers, "\n#ifdef __cplusplus\n");
|
||||
|
|
@ -1143,14 +1155,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 +1173,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");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
|
@ -1187,7 +1196,7 @@ MODULA3():
|
|||
Swig_restore(n);
|
||||
native_function_flag = false;
|
||||
} else {
|
||||
Printf(stderr, "%s : Line %d. No return type for %%native method %s.\n", input_file, line_number, Getattr(n, "wrap:name"));
|
||||
Swig_error(input_file, line_number, "No return type for %%native method %s.\n", Getattr(n, "wrap:name"));
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
@ -1315,7 +1324,7 @@ MODULA3():
|
|||
Parm *p;
|
||||
attachParameterNames(n, "tmap:name", "c:wrapname", "m3arg%d");
|
||||
bool gencomma = false;
|
||||
for (p = skipIgnored(l, "in"); p != NULL; p = skipIgnored(p, "in")) {
|
||||
for (p = skipIgnored(l, "in"); p; p = skipIgnored(p, "in")) {
|
||||
|
||||
String *arg = Getattr(p, "c:wrapname");
|
||||
{
|
||||
|
|
@ -1399,7 +1408,7 @@ MODULA3():
|
|||
|
||||
// Get any Modula 3 exception classes in the throws typemap
|
||||
ParmList *throw_parm_list = NULL;
|
||||
if ((throw_parm_list = Getattr(n, "throws"))) {
|
||||
if ((throw_parm_list = Getattr(n, "catchlist"))) {
|
||||
Swig_typemap_attach_parms("throws", throw_parm_list, f);
|
||||
Parm *p;
|
||||
for (p = throw_parm_list; p; p = nextSibling(p)) {
|
||||
|
|
@ -1413,7 +1422,7 @@ MODULA3():
|
|||
|
||||
// below based on Swig_VargetToFunction()
|
||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
||||
Setattr(n, "wrap:action", NewStringf("result = (%s) %s;", SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
}
|
||||
|
||||
Setattr(n, "wrap:name", wname);
|
||||
|
|
@ -1428,9 +1437,9 @@ MODULA3():
|
|||
|
||||
/* Return value if necessary */
|
||||
String *tm;
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
addThrows(throws_hash, "out", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Replaceall(tm, "$target", "cresult"); /* deprecated */
|
||||
Replaceall(tm, "$result", "cresult");
|
||||
Printf(f->code, "%s", tm);
|
||||
|
|
@ -1450,19 +1459,19 @@ MODULA3():
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
String *tm = Swig_typemap_lookup("newfree", n, "result", 0);
|
||||
String *tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0);
|
||||
if (tm != NIL) {
|
||||
addThrows(throws_hash, "newfree", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if (!native_function_flag) {
|
||||
String *tm = Swig_typemap_lookup("ret", n, "result", 0);
|
||||
String *tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0);
|
||||
if (tm != NIL) {
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
|
@ -1536,7 +1545,7 @@ MODULA3():
|
|||
Parm *p;
|
||||
writeArgState state;
|
||||
attachParameterNames(n, "tmap:rawinname", "modula3:rawname", "arg%d");
|
||||
for (p = skipIgnored(l, "m3rawintype"); p != NULL; p = skipIgnored(p, "m3rawintype")) {
|
||||
for (p = skipIgnored(l, "m3rawintype"); p; p = skipIgnored(p, "m3rawintype")) {
|
||||
|
||||
/* Get argument passing mode, should be one of VALUE, VAR, READONLY */
|
||||
String *mode = Getattr(p, "tmap:m3rawinmode");
|
||||
|
|
@ -1919,7 +1928,7 @@ MODULA3():
|
|||
} else if (Strcmp(code, "unsafe") == 0) {
|
||||
unsafe_module = true;
|
||||
} else if (Strcmp(code, "library") == 0) {
|
||||
if (targetlibrary != NULL) {
|
||||
if (targetlibrary) {
|
||||
Delete(targetlibrary);
|
||||
}
|
||||
targetlibrary = Copy(strvalue);
|
||||
|
|
@ -2200,7 +2209,7 @@ MODULA3():
|
|||
String *c_baseclass = NULL;
|
||||
String *baseclass = NULL;
|
||||
String *c_baseclassname = NULL;
|
||||
String *classDeclarationName = Getattr(n, "classDeclaration:name");
|
||||
String *name = Getattr(n, "name");
|
||||
|
||||
/* Deal with inheritance */
|
||||
List *baselist = Getattr(n, "bases");
|
||||
|
|
@ -2213,10 +2222,9 @@ MODULA3():
|
|||
}
|
||||
base = Next(base);
|
||||
if (base.item != NIL) {
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
|
||||
line_number,
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
|
||||
classDeclarationName, Getattr(base.item, "name"));
|
||||
name, Getattr(base.item, "name"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2225,23 +2233,22 @@ MODULA3():
|
|||
baseclass = NewString("");
|
||||
|
||||
// Inheritance from pure Modula 3 classes
|
||||
const String *pure_baseclass = typemapLookup("m3base", classDeclarationName, WARN_NONE);
|
||||
const String *pure_baseclass = typemapLookup(n, "m3base", name, WARN_NONE);
|
||||
if (hasContent(pure_baseclass) && hasContent(baseclass)) {
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
|
||||
line_number,
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", classDeclarationName, pure_baseclass);
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", name, pure_baseclass);
|
||||
}
|
||||
// Pure Modula 3 interfaces
|
||||
const String *pure_interfaces = typemapLookup(derived ? "m3interfaces_derived" : "m3interfaces",
|
||||
classDeclarationName, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup(n, derived ? "m3interfaces_derived" : "m3interfaces",
|
||||
name, WARN_NONE);
|
||||
|
||||
// Start writing the proxy class
|
||||
Printv(proxy_class_def, typemapLookup("m3imports", classDeclarationName, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup("m3classmodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3imports", name, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup(n, "m3classmodifiers", name, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
" class $m3classname", // Class name and bases
|
||||
(derived || *Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", baseclass, pure_baseclass, ((derived || *Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
|
||||
", " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", // Member variables for memory handling
|
||||
derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup("m3ptrconstructormodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", name, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
" $m3classname(IntPtr cPtr, bool cMemoryOwn) ", // Constructor used for wrapping pointers
|
||||
derived ?
|
||||
": base($imclassname.$m3classnameTo$baseclass(cPtr), cMemoryOwn) {\n"
|
||||
|
|
@ -2257,20 +2264,20 @@ MODULA3():
|
|||
Node *attributes = NewHash();
|
||||
String *destruct_methodname = NULL;
|
||||
if (derived) {
|
||||
tm = typemapLookup("m3destruct_derived", classDeclarationName, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "m3destruct_derived", name, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:m3destruct_derived:methodname");
|
||||
} else {
|
||||
tm = typemapLookup("m3destruct", classDeclarationName, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "m3destruct", name, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:m3destruct:methodname");
|
||||
}
|
||||
if (!destruct_methodname) {
|
||||
Swig_error(input_file, line_number, "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
|
||||
Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
|
||||
}
|
||||
// Emit the Finalize and Dispose methods
|
||||
if (tm) {
|
||||
// Finalize method
|
||||
if (*Char(destructor_call)) {
|
||||
Printv(proxy_class_def, typemapLookup("m3finalize", classDeclarationName, WARN_NONE), NIL);
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3finalize", name, WARN_NONE), NIL);
|
||||
}
|
||||
// Dispose method
|
||||
Printv(destruct, tm, NIL);
|
||||
|
|
@ -2285,8 +2292,8 @@ MODULA3():
|
|||
Delete(destruct);
|
||||
|
||||
// Emit various other methods
|
||||
Printv(proxy_class_def, typemapLookup("m3getcptr", classDeclarationName, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup("m3code", classDeclarationName, WARN_NONE), // extra Modula 3 code
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3getcptr", name, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup(n, "m3code", name, WARN_NONE), // extra Modula 3 code
|
||||
"\n", NIL);
|
||||
|
||||
// Substitute various strings into the above template
|
||||
|
|
@ -2382,7 +2389,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);
|
||||
|
|
@ -2457,8 +2464,7 @@ MODULA3():
|
|||
Append(baseclassname, Getattr(base.item, "sym:name"));
|
||||
base = Next(base);
|
||||
if (base.item != NIL) {
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
|
||||
line_number,
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
|
||||
proxy_class_name, Getattr(base.item, "name"));
|
||||
}
|
||||
|
|
@ -2611,7 +2617,7 @@ MODULA3():
|
|||
|
||||
if (proxy_flag) {
|
||||
String *overloaded_name = getOverloadedName(n);
|
||||
String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name);
|
||||
String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name);
|
||||
Setattr(n, "proxyfuncname", Getattr(n, "sym:name"));
|
||||
Setattr(n, "imfuncname", intermediary_function_name);
|
||||
proxyClassFunctionHandler(n);
|
||||
|
|
@ -2632,7 +2638,7 @@ MODULA3():
|
|||
|
||||
if (proxy_flag) {
|
||||
String *overloaded_name = getOverloadedName(n);
|
||||
String *intermediary_function_name = Swig_name_member(proxy_class_name, overloaded_name);
|
||||
String *intermediary_function_name = Swig_name_member(NSPACE_TODO, proxy_class_name, overloaded_name);
|
||||
Setattr(n, "proxyfuncname", Getattr(n, "sym:name"));
|
||||
Setattr(n, "imfuncname", intermediary_function_name);
|
||||
proxyClassFunctionHandler(n);
|
||||
|
|
@ -2690,7 +2696,7 @@ MODULA3():
|
|||
|
||||
if (proxy_flag && wrapping_member_flag && !enum_constant_flag) {
|
||||
// Properties
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name)))
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, proxy_class_name, variable_name)))
|
||||
== 0);
|
||||
}
|
||||
|
||||
|
|
@ -2835,7 +2841,7 @@ MODULA3():
|
|||
String *imcall = NewString("");
|
||||
|
||||
Printf(proxy_class_code, " %s %s(", Getattr(n, "feature:modula3:methodmodifiers"), proxy_class_name);
|
||||
Printv(imcall, " : this(", m3raw_name, ".", Swig_name_construct(overloaded_name), "(", NIL);
|
||||
Printv(imcall, " : this(", m3raw_name, ".", Swig_name_construct(NSPACE_TODO, overloaded_name), "(", NIL);
|
||||
|
||||
/* Attach the non-standard typemaps to the parameter list */
|
||||
Swig_typemap_attach_parms("in", l, NULL);
|
||||
|
|
@ -2926,7 +2932,7 @@ MODULA3():
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
|
||||
if (proxy_flag) {
|
||||
Printv(destructor_call, m3raw_name, ".", Swig_name_destroy(symname), "(swigCPtr)", NIL);
|
||||
Printv(destructor_call, m3raw_name, ".", Swig_name_destroy(NSPACE_TODO, symname), "(swigCPtr)", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -3174,8 +3180,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);
|
||||
}
|
||||
|
|
@ -3192,7 +3197,7 @@ MODULA3():
|
|||
writeArg(return_variables, state, NIL, NIL, NIL, NIL);
|
||||
|
||||
if (multiretval) {
|
||||
Printv(result_name, "result", NIL);
|
||||
Printv(result_name, Swig_cresult_name(), NIL);
|
||||
Printf(result_m3wraptype, "%sResult", func_name);
|
||||
m3wrap_intf.enterBlock(blocktype);
|
||||
Printf(m3wrap_intf.f, "%s =\nRECORD\n%sEND;\n", result_m3wraptype, return_variables);
|
||||
|
|
@ -3450,7 +3455,7 @@ MODULA3():
|
|||
if ((hasContent(outcheck) || hasContent(storeout)
|
||||
|| hasContent(cleanup)) && (!hasContent(result_name))
|
||||
&& (return_raw == NIL)) {
|
||||
Printv(result_name, "result", NIL);
|
||||
Printv(result_name, Swig_cresult_name(), NIL);
|
||||
Printf(local_variables, "%s: %s;\n", result_name, result_m3wraptype);
|
||||
}
|
||||
|
||||
|
|
@ -3577,17 +3582,28 @@ MODULA3():
|
|||
Delete(throws_hash);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* replaceSpecialVariables()
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) {
|
||||
(void)method;
|
||||
SwigType *type = Getattr(parm, "type");
|
||||
substituteClassname(type, tm);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* substituteClassname()
|
||||
*
|
||||
* Substitute $m3classname with the proxy class name for classes/structs/unions that SWIG knows about.
|
||||
* Substitute the special variable $m3classname with the proxy class name for classes/structs/unions
|
||||
* that SWIG knows about.
|
||||
* Otherwise use the $descriptor name for the Modula 3 class name. Note that the $&m3classname substitution
|
||||
* is the same as a $&descriptor substitution, ie one pointer added to descriptor name.
|
||||
* Inputs:
|
||||
* pt - parameter type
|
||||
* tm - m3wraptype typemap
|
||||
* tm - typemap contents that might contain the special variable to be replaced
|
||||
* Outputs:
|
||||
* tm - m3wraptype typemap with $m3classname substitution
|
||||
* tm - typemap contents complete with the special variable substitution
|
||||
* Return:
|
||||
* substitution_performed - flag indicating if a substitution was performed
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -3761,8 +3777,12 @@ MODULA3():
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void emitTypeWrapperClass(String *classname, SwigType *type) {
|
||||
Node *n = NewHash();
|
||||
Setfile(n, input_file);
|
||||
Setline(n, line_number);
|
||||
|
||||
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);
|
||||
|
|
@ -3773,19 +3793,19 @@ MODULA3():
|
|||
emitBanner(f_swigtype);
|
||||
|
||||
// Pure Modula 3 baseclass and interfaces
|
||||
const String *pure_baseclass = typemapLookup("m3base", type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup("m3interfaces", type, WARN_NONE);
|
||||
const String *pure_baseclass = typemapLookup(n, "m3base", type, WARN_NONE);
|
||||
const String *pure_interfaces = typemapLookup(n, "m3interfaces", type, WARN_NONE);
|
||||
|
||||
// Emit the class
|
||||
Printv(swigtype, typemapLookup("m3imports", type, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup("m3classmodifiers", type, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
Printv(swigtype, typemapLookup(n, "m3imports", type, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup(n, "m3classmodifiers", type, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
" class $m3classname", // Class name and bases
|
||||
*Char(pure_baseclass) ? " : " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces
|
||||
" : " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", "\n", " ", typemapLookup("m3ptrconstructormodifiers", type, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
" : " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", type, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
" $m3classname(IntPtr cPtr, bool bFutureUse) {\n", // Constructor used for wrapping pointers
|
||||
" swigCPtr = cPtr;\n", " }\n", "\n", " protected $m3classname() {\n", // Default constructor
|
||||
" swigCPtr = IntPtr.Zero;\n", " }\n", typemapLookup("m3getcptr", type, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup("m3code", type, WARN_NONE), // extra Modula 3 code
|
||||
" swigCPtr = IntPtr.Zero;\n", " }\n", typemapLookup(n, "m3getcptr", type, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup(n, "m3code", type, WARN_NONE), // extra Modula 3 code
|
||||
"}\n", "\n", NIL);
|
||||
|
||||
Replaceall(swigtype, "$m3classname", classname);
|
||||
|
|
@ -3798,25 +3818,29 @@ MODULA3():
|
|||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* typemapLookup()
|
||||
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
|
||||
* tmap_method - typemap method name
|
||||
* type - typemap type to lookup
|
||||
* warning - warning number to issue if no typemaps found
|
||||
* typemap_attributes - the typemap attributes are attached to this node and will
|
||||
* also be used for temporary storage if non null
|
||||
* return is never NULL, unlike Swig_typemap_lookup()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) {
|
||||
String *tm = NULL;
|
||||
const String *code = NULL;
|
||||
|
||||
if ((tm = Swig_typemap_search(op, type, NULL, NULL))) {
|
||||
code = Getattr(tm, "code");
|
||||
if (typemap_attributes)
|
||||
Swig_typemap_attach_kwargs(tm, op, typemap_attributes);
|
||||
}
|
||||
|
||||
if (!code) {
|
||||
code = empty_string;
|
||||
const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) {
|
||||
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
|
||||
Setattr(node, "type", type);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0);
|
||||
if (!tm) {
|
||||
tm = empty_string;
|
||||
if (warning != WARN_NONE)
|
||||
Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type);
|
||||
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0));
|
||||
}
|
||||
|
||||
return code ? code : empty_string;
|
||||
if (!typemap_attributes)
|
||||
Delete(node);
|
||||
return tm;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -3951,10 +3975,10 @@ extern "C" Language *swig_modula3(void) {
|
|||
|
||||
const char *MODULA3::usage = (char *) "\
|
||||
Modula 3 Options (available with -modula3)\n\
|
||||
-generateconst <file> - generate code for computing numeric values of constants\n\
|
||||
-generaterename <file> - generate suggestions for %rename\n\
|
||||
-generatetypemap <file> - generate templates for some basic typemaps\n\
|
||||
-oldvarnames - old intermediary method names for variable wrappers\n\
|
||||
-generateconst <file> - Generate code for computing numeric values of constants\n\
|
||||
-generaterename <file> - Generate suggestions for %rename\n\
|
||||
-generatetypemap <file> - Generate templates for some basic typemaps\n\
|
||||
-oldvarnames - Old intermediary method names for variable wrappers\n\
|
||||
\n";
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* module.cxx
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* mzscheme.cxx
|
||||
*
|
||||
|
|
@ -15,12 +19,12 @@ char cvsroot_mzscheme_cxx[] = "$Id$";
|
|||
|
||||
static const char *usage = (char *) "\
|
||||
Mzscheme Options (available with -mzscheme)\n\
|
||||
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
|
||||
-declaremodule - Create extension that declares a module\n\
|
||||
-noinit - Do not emit scheme_initialize, scheme_reload,\n\
|
||||
scheme_module_name functions\n\
|
||||
-dynamic-load <library>,[library,...] - Do not link with these libraries, dynamic load\n\
|
||||
them\n\
|
||||
-noinit - Do not emit scheme_initialize, scheme_reload,\n\
|
||||
scheme_module_name functions\n\
|
||||
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
|
||||
";
|
||||
|
||||
static String *fieldnames_tab = 0;
|
||||
|
|
@ -39,6 +43,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 +134,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 +147,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 +196,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;
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +240,6 @@ public:
|
|||
String *outarg = NewString("");
|
||||
String *build = NewString("");
|
||||
String *tm;
|
||||
int argout_set = 0;
|
||||
int i = 0;
|
||||
int numargs;
|
||||
int numreq;
|
||||
|
|
@ -239,7 +250,7 @@ public:
|
|||
ParmList *parms = Getattr(n, "parms");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *name = NewString("caller");
|
||||
Setattr(n, "wrap:action", Swig_cresult(type, "result", Swig_cfunction_call(name, parms)));
|
||||
Setattr(n, "wrap:action", Swig_cresult(type, Swig_cresult_name(), Swig_cfunction_call(name, parms)));
|
||||
}
|
||||
// PATCH DLOPEN
|
||||
|
||||
|
|
@ -369,7 +380,6 @@ public:
|
|||
Replaceall(tm, "$input", Getattr(p, "emit:input"));
|
||||
Printv(outarg, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:argout:next");
|
||||
argout_set = 1;
|
||||
} else {
|
||||
p = nextSibling(p);
|
||||
}
|
||||
|
|
@ -393,8 +403,8 @@ public:
|
|||
String *actioncode = emit_action(n);
|
||||
|
||||
// Now have return value, figure out what to do with it.
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "values[0]");
|
||||
Replaceall(tm, "$result", "values[0]");
|
||||
if (GetFlag(n, "feature:new"))
|
||||
|
|
@ -416,15 +426,15 @@ public:
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
}
|
||||
// Free any memory allocated by the function being wrapped..
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
|
@ -502,7 +512,7 @@ public:
|
|||
|
||||
String *proc_name = NewString("");
|
||||
String *tm;
|
||||
String *tm2 = NewString("");;
|
||||
String *tm2 = NewString("");
|
||||
String *argnum = NewString("0");
|
||||
String *arg = NewString("argv[0]");
|
||||
Wrapper *f;
|
||||
|
|
@ -627,9 +637,10 @@ public:
|
|||
// Create variable and assign it a value
|
||||
|
||||
Printf(f_header, "static %s = ", SwigType_lstr(type, var_name));
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
if ((SwigType_type(type) == T_STRING)) {
|
||||
Printf(f_header, "\"%s\";\n", value);
|
||||
} else if (SwigType_type(type) == T_CHAR) {
|
||||
} else if (SwigType_type(type) == T_CHAR && !is_enum_item) {
|
||||
Printf(f_header, "\'%s\';\n", value);
|
||||
} else {
|
||||
Printf(f_header, "%s;\n", value);
|
||||
|
|
@ -639,13 +650,15 @@ public:
|
|||
|
||||
{
|
||||
/* Hack alert: will cleanup later -- Dave */
|
||||
Node *n = NewHash();
|
||||
Setattr(n, "name", var_name);
|
||||
Setattr(n, "sym:name", iname);
|
||||
Setattr(n, "type", type);
|
||||
SetFlag(n, "feature:immutable");
|
||||
variableWrapper(n);
|
||||
Delete(n);
|
||||
Node *nn = NewHash();
|
||||
Setfile(nn, Getfile(n));
|
||||
Setline(nn, Getline(n));
|
||||
Setattr(nn, "name", var_name);
|
||||
Setattr(nn, "sym:name", iname);
|
||||
Setattr(nn, "type", type);
|
||||
SetFlag(nn, "feature:immutable");
|
||||
variableWrapper(nn);
|
||||
Delete(nn);
|
||||
}
|
||||
}
|
||||
Delete(proc_name);
|
||||
|
|
@ -668,7 +681,7 @@ public:
|
|||
String *mangled_classname = 0;
|
||||
String *real_classname = 0;
|
||||
String *scm_structname = NewString("");
|
||||
SwigType *ctype_ptr = NewStringf("p.%s", Getattr(n, "classtype"));
|
||||
SwigType *ctype_ptr = NewStringf("p.%s", getClassType());
|
||||
|
||||
SwigType *t = NewStringf("p.%s", Getattr(n, "name"));
|
||||
swigtype_ptr = SwigType_manglestr(t);
|
||||
|
|
@ -754,7 +767,7 @@ public:
|
|||
Printv(access_mem, "(ptr)->", name, NIL);
|
||||
if ((SwigType_type(type) == T_USER) && (!is_a_pointer(type))) {
|
||||
Printv(convert_tab, tab4, "fields[i++] = ", NIL);
|
||||
Printv(convert_tab, "_swig_convert_struct_", swigtype, "((", SwigType_str(ctype_ptr, ""), ")&((ptr)->", name, "));\n", NIL);
|
||||
Printv(convert_tab, "_swig_convert_struct_", swigtype, "((", SwigType_str(ctype_ptr, 0), ")&((ptr)->", name, "));\n", NIL);
|
||||
} else if ((tm = Swig_typemap_lookup("varout", n, access_mem, 0))) {
|
||||
Replaceall(tm, "$result", "fields[i++]");
|
||||
Printv(convert_tab, tm, "\n", NIL);
|
||||
|
|
|
|||
215
Source/Modules/ocaml.cxx
Executable file → Normal file
215
Source/Modules/ocaml.cxx
Executable file → Normal file
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* ocaml.cxx
|
||||
*
|
||||
|
|
@ -13,11 +17,13 @@ char cvsroot_ocaml_cxx[] = "$Id$";
|
|||
|
||||
#include <ctype.h>
|
||||
|
||||
static const char *usage = (char *)
|
||||
("Ocaml Options (available with -ocaml)\n"
|
||||
"-prefix <name> - Set a prefix <name> to be prepended to all names\n"
|
||||
"-where - Emit library location\n"
|
||||
"-suffix <name> - Change .cxx to something else\n" "-oldvarnames - old intermediary method names for variable wrappers\n" "\n");
|
||||
static const char *usage = (char *) "\
|
||||
Ocaml Options (available with -ocaml)\n\
|
||||
-oldvarnames - Old intermediary method names for variable wrappers\n\
|
||||
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
|
||||
-suffix <name> - Change .cxx to something else\n\
|
||||
-where - Emit library location\n\
|
||||
\n";
|
||||
|
||||
static int classmode = 0;
|
||||
static int in_constructor = 0, in_destructor = 0, in_copyconst = 0;
|
||||
|
|
@ -31,13 +37,14 @@ static String *classname = 0;
|
|||
static String *module = 0;
|
||||
static String *init_func_def = 0;
|
||||
static String *f_classtemplate = 0;
|
||||
static String *name_qualifier = 0;
|
||||
static SwigType *name_qualifier_type = 0;
|
||||
|
||||
static Hash *seen_enums = 0;
|
||||
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 +221,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 +255,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);
|
||||
|
|
@ -258,11 +267,14 @@ public:
|
|||
Swig_register_filebyname("class_ctors", f_class_ctors);
|
||||
|
||||
if (old_variable_names) {
|
||||
Swig_name_register("set", "%v__set__");
|
||||
Swig_name_register("get", "%v__get__");
|
||||
Swig_name_register("set", "%n%v__set__");
|
||||
Swig_name_register("get", "%n%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 +288,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 +305,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 +334,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);
|
||||
|
|
@ -431,7 +445,6 @@ public:
|
|||
String *outarg = NewString("");
|
||||
String *build = NewString("");
|
||||
String *tm;
|
||||
int argout_set = 0;
|
||||
int i = 0;
|
||||
int numargs;
|
||||
int numreq;
|
||||
|
|
@ -594,7 +607,6 @@ public:
|
|||
Replaceall(tm, "$ntype", normalizeTemplatedClassName(Getattr(p, "type")));
|
||||
Printv(outarg, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:argout:next");
|
||||
argout_set = 1;
|
||||
} else {
|
||||
p = nextSibling(p);
|
||||
}
|
||||
|
|
@ -645,7 +657,7 @@ public:
|
|||
Swig_director_emit_dynamic_cast(n, f);
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", "swig_result");
|
||||
Replaceall(tm, "$target", "rv");
|
||||
Replaceall(tm, "$result", "rv");
|
||||
|
|
@ -665,15 +677,15 @@ public:
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", "swig_result");
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
}
|
||||
// Free any memory allocated by the function being wrapped..
|
||||
|
||||
if ((tm = Swig_typemap_lookup("swig_result", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("swig_result", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
|
@ -766,7 +778,7 @@ public:
|
|||
|
||||
String *proc_name = NewString("");
|
||||
String *tm;
|
||||
String *tm2 = NewString("");;
|
||||
String *tm2 = NewString("");
|
||||
String *argnum = NewString("0");
|
||||
String *arg = NewString("SWIG_Field(args,0)");
|
||||
Wrapper *f;
|
||||
|
|
@ -867,9 +879,8 @@ public:
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual int staticmemberfunctionHandler(Node *n) {
|
||||
int rv;
|
||||
static_member_function = 1;
|
||||
rv = Language::staticmemberfunctionHandler(n);
|
||||
Language::staticmemberfunctionHandler(n);
|
||||
static_member_function = 0;
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -886,12 +897,12 @@ public:
|
|||
String *name = Getattr(n, "feature:symname");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *value = Getattr(n, "value");
|
||||
String *qvalue = Getattr(n, "qualified:value");
|
||||
SwigType *qname = Getattr(n, "qualified:name");
|
||||
String *rvalue = NewString("");
|
||||
String *temp = 0;
|
||||
|
||||
if (qvalue)
|
||||
value = qvalue;
|
||||
if (qname)
|
||||
value = qname;
|
||||
|
||||
if (!name) {
|
||||
name = mangleNameForCaml(Getattr(n, "name"));
|
||||
|
|
@ -916,9 +927,10 @@ public:
|
|||
// Create variable and assign it a value
|
||||
|
||||
Printf(f_header, "static %s = ", SwigType_lstr(type, name));
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
if ((SwigType_type(type) == T_STRING)) {
|
||||
Printf(f_header, "\"%s\";\n", value);
|
||||
} else if (SwigType_type(type) == T_CHAR) {
|
||||
} else if (SwigType_type(type) == T_CHAR && !is_enum_item) {
|
||||
Printf(f_header, "\'%s\';\n", value);
|
||||
} else {
|
||||
Printf(f_header, "%s;\n", value);
|
||||
|
|
@ -1216,20 +1228,18 @@ public:
|
|||
return out;
|
||||
}
|
||||
|
||||
String *fully_qualify_enum_name(Node *n, String *name) {
|
||||
SwigType *fully_qualified_enum_type(Node *n) {
|
||||
Node *parent = 0;
|
||||
String *qualification = NewString("");
|
||||
String *fully_qualified_name = NewString("");
|
||||
String *parent_type = 0;
|
||||
String *normalized_name;
|
||||
|
||||
parent = parentNode(n);
|
||||
while (parent) {
|
||||
parent_type = nodeType(parent);
|
||||
if (Getattr(parent, "name")) {
|
||||
String *parent_copy = NewStringf("%s::", Getattr(parent, "name"));
|
||||
if (!Cmp(parent_type, "class") || !Cmp(parent_type, "namespace"))
|
||||
Insert(qualification, 0, parent_copy);
|
||||
if (Cmp(parent_type, "class") == 0 || Cmp(parent_type, "namespace") == 0)
|
||||
Insert(fully_qualified_name, 0, parent_copy);
|
||||
Delete(parent_copy);
|
||||
}
|
||||
if (!Cmp(parent_type, "class"))
|
||||
|
|
@ -1237,25 +1247,18 @@ public:
|
|||
parent = parentNode(parent);
|
||||
}
|
||||
|
||||
Printf(fully_qualified_name, "%s%s", qualification, name);
|
||||
|
||||
normalized_name = normalizeTemplatedClassName(fully_qualified_name);
|
||||
if (!strncmp(Char(normalized_name), "enum ", 5)) {
|
||||
Insert(normalized_name, 5, qualification);
|
||||
}
|
||||
|
||||
return normalized_name;
|
||||
return fully_qualified_name;
|
||||
}
|
||||
|
||||
/* Benedikt Grundmann inspired --> Enum wrap styles */
|
||||
|
||||
int enumvalueDeclaration(Node *n) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *qvalue = 0;
|
||||
SwigType *qtype = 0;
|
||||
|
||||
if (name_qualifier) {
|
||||
qvalue = Copy(name_qualifier);
|
||||
Printv(qvalue, name, NIL);
|
||||
if (name_qualifier_type) {
|
||||
qtype = Copy(name_qualifier_type);
|
||||
Printv(qtype, name, NIL);
|
||||
}
|
||||
|
||||
if (const_enum && name && !Getattr(seen_enumvalues, name)) {
|
||||
|
|
@ -1263,10 +1266,10 @@ public:
|
|||
SetFlag(n, "feature:immutable");
|
||||
Setattr(n, "feature:enumvalue", "1"); // this does not appear to be used
|
||||
|
||||
if (qvalue)
|
||||
Setattr(n, "qualified:value", qvalue);
|
||||
if (qtype)
|
||||
Setattr(n, "qualified:name", SwigType_namestr(qtype));
|
||||
|
||||
String *evname = SwigType_manglestr(qvalue);
|
||||
String *evname = SwigType_manglestr(qtype);
|
||||
Insert(evname, 0, "SWIG_ENUM_");
|
||||
|
||||
Setattr(n, "feature:enumvname", name);
|
||||
|
|
@ -1292,56 +1295,50 @@ public:
|
|||
* which means looking up and registering by typedef and enum name. */
|
||||
int enumDeclaration(Node *n) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *oname = name ? NewString(name) : NULL;
|
||||
/* name is now fully qualified */
|
||||
String *fully_qualified_name = NewString(name);
|
||||
bool seen_enum = false;
|
||||
if (name_qualifier)
|
||||
Delete(name_qualifier);
|
||||
char *strip_position;
|
||||
name_qualifier = fully_qualify_enum_name(n, NewString(""));
|
||||
if (name) {
|
||||
String *oname = NewString(name);
|
||||
/* name is now fully qualified */
|
||||
String *fully_qualified_name = NewString(name);
|
||||
bool seen_enum = false;
|
||||
if (name_qualifier_type)
|
||||
Delete(name_qualifier_type);
|
||||
char *strip_position;
|
||||
name_qualifier_type = fully_qualified_enum_type(n);
|
||||
|
||||
/* Recent changes have distrubed enum and template naming again.
|
||||
* Will try to keep it consistent by can't guarantee much given
|
||||
* that these things move around a lot.
|
||||
*
|
||||
* I need to figure out a way to isolate this module better.
|
||||
*/
|
||||
if (oname) {
|
||||
strip_position = strstr(Char(oname), "::");
|
||||
|
||||
while (strip_position) {
|
||||
strip_position += 2;
|
||||
oname = NewString(strip_position);
|
||||
strip_position = strstr(Char(oname), "::");
|
||||
}
|
||||
}
|
||||
|
||||
seen_enum = oname ? (Getattr(seen_enums, fully_qualified_name) ? true : false) : false;
|
||||
|
||||
if (oname && !seen_enum) {
|
||||
const_enum = true;
|
||||
Printf(f_enum_to_int, "| `%s -> (match y with\n", oname);
|
||||
Printf(f_int_to_enum, "| `%s -> C_enum (\n", oname);
|
||||
/* * * * A note about enum name resolution * * * *
|
||||
* This code should now work, but I think we can do a bit better.
|
||||
* The problem I'm having is that swig isn't very precise about
|
||||
* typedef name resolution. My opinion is that SwigType_typedef
|
||||
* resolve_all should *always* return the enum tag if one exists,
|
||||
* rather than the admittedly friendlier enclosing typedef.
|
||||
*
|
||||
* This would make one of the cases below unnecessary.
|
||||
* * * */
|
||||
Printf(f_mlbody, "let _ = Callback.register \"%s_marker\" (`%s)\n", fully_qualified_name, oname);
|
||||
if (!strncmp(Char(fully_qualified_name), "enum ", 5)) {
|
||||
String *fq_noenum = NewString(Char(fully_qualified_name) + 5);
|
||||
Printf(f_mlbody,
|
||||
"let _ = Callback.register \"%s_marker\" (`%s)\n" "let _ = Callback.register \"%s_marker\" (`%s)\n", fq_noenum, oname, fq_noenum, name);
|
||||
strip_position += 2;
|
||||
oname = NewString(strip_position);
|
||||
strip_position = strstr(Char(oname), "::");
|
||||
}
|
||||
|
||||
Printf(f_enumtypes_type, "| `%s\n", oname);
|
||||
Insert(fully_qualified_name, 0, "enum ");
|
||||
Setattr(seen_enums, fully_qualified_name, n);
|
||||
seen_enum = (Getattr(seen_enums, fully_qualified_name) ? true : false);
|
||||
|
||||
if (!seen_enum) {
|
||||
const_enum = true;
|
||||
Printf(f_enum_to_int, "| `%s -> (match y with\n", oname);
|
||||
Printf(f_int_to_enum, "| `%s -> C_enum (\n", oname);
|
||||
/* * * * A note about enum name resolution * * * *
|
||||
* This code should now work, but I think we can do a bit better.
|
||||
* The problem I'm having is that swig isn't very precise about
|
||||
* typedef name resolution. My opinion is that SwigType_typedef
|
||||
* resolve_all should *always* return the enum tag if one exists,
|
||||
* rather than the admittedly friendlier enclosing typedef.
|
||||
*
|
||||
* This would make one of the cases below unnecessary.
|
||||
* * * */
|
||||
Printf(f_mlbody, "let _ = Callback.register \"%s_marker\" (`%s)\n", fully_qualified_name, oname);
|
||||
if (!strncmp(Char(fully_qualified_name), "enum ", 5)) {
|
||||
String *fq_noenum = NewString(Char(fully_qualified_name) + 5);
|
||||
Printf(f_mlbody,
|
||||
"let _ = Callback.register \"%s_marker\" (`%s)\n" "let _ = Callback.register \"%s_marker\" (`%s)\n", fq_noenum, oname, fq_noenum, name);
|
||||
}
|
||||
|
||||
Printf(f_enumtypes_type, "| `%s\n", oname);
|
||||
Insert(fully_qualified_name, 0, "enum ");
|
||||
Setattr(seen_enums, fully_qualified_name, n);
|
||||
}
|
||||
}
|
||||
|
||||
int ret = Language::enumDeclaration(n);
|
||||
|
|
@ -1390,6 +1387,7 @@ public:
|
|||
String *name;
|
||||
String *classname;
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
|
|
@ -1473,6 +1471,8 @@ public:
|
|||
/* attach typemaps to arguments (C/C++ -> Ocaml) */
|
||||
String *arglist = NewString("");
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
Swig_typemap_attach_parms("in", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
Swig_typemap_attach_parms("directorargout", l, w);
|
||||
|
|
@ -1501,6 +1501,7 @@ public:
|
|||
|
||||
Putc(',', arglist);
|
||||
if ((tm = Getattr(p, "tmap:directorin")) != 0) {
|
||||
Setattr(p, "emit:directorinput", pname);
|
||||
Replaceall(tm, "$input", pname);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
if (Len(tm) == 0)
|
||||
|
|
@ -1588,12 +1589,12 @@ public:
|
|||
"swig_result = caml_swig_alloc(1,C_list);\n" "SWIG_Store_field(swig_result,0,args);\n" "args = swig_result;\n" "swig_result = Val_unit;\n", 0);
|
||||
Printf(w->code, "swig_result = " "callback3(*caml_named_value(\"swig_runmethod\")," "swig_get_self(),copy_string(\"%s\"),args);\n", Getattr(n, "name"));
|
||||
/* exception handling */
|
||||
tm = Swig_typemap_lookup("director:except", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
|
||||
if (!tm) {
|
||||
tm = Getattr(n, "feature:director:except");
|
||||
}
|
||||
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
||||
Printf(w->code, "if (result == NULL) {\n");
|
||||
Printf(w->code, "if (!%s) {\n", Swig_cresult_name());
|
||||
Printf(w->code, " CAML_VALUE error = *caml_named_value(\"director_except\");\n");
|
||||
Replaceall(tm, "$error", "error");
|
||||
Printv(w->code, Str(tm), "\n", NIL);
|
||||
|
|
@ -1625,11 +1626,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 */
|
||||
|
|
@ -1645,8 +1641,8 @@ public:
|
|||
/* marshal outputs */
|
||||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
Replaceall(tm, "$input", "swig_result");
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Replaceall(tm, "$result", "swig_result");
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
|
|
@ -1699,6 +1695,7 @@ public:
|
|||
/* emit the director method */
|
||||
if (status == SWIG_OK) {
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
@ -1730,7 +1727,7 @@ public:
|
|||
ParmList *superparms = Getattr(n, "parms");
|
||||
ParmList *parms = CopyParmList(superparms);
|
||||
String *type = NewString("CAML_VALUE");
|
||||
p = NewParm(type, NewString("self"));
|
||||
p = NewParm(type, NewString("self"), n);
|
||||
q = Copy(p);
|
||||
set_nextSibling(q, superparms);
|
||||
set_nextSibling(p, parms);
|
||||
|
|
@ -1783,7 +1780,7 @@ public:
|
|||
ParmList *superparms = Getattr(n, "parms");
|
||||
ParmList *parms = CopyParmList(superparms);
|
||||
String *type = NewString("CAML_VALUE");
|
||||
p = NewParm(type, NewString("self"));
|
||||
p = NewParm(type, NewString("self"), n);
|
||||
q = Copy(p);
|
||||
set_nextSibling(p, parms);
|
||||
parms = p;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* octave.cxx
|
||||
*
|
||||
|
|
@ -11,13 +15,23 @@ char cvsroot_octave_cxx[] = "$Id$";
|
|||
|
||||
#include "swigmod.h"
|
||||
|
||||
static bool global_load = true;
|
||||
static String *global_name = 0;
|
||||
static String *op_prefix = 0;
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
Octave Options (available with -octave)\n\
|
||||
(none yet)\n\n";
|
||||
-global - Load all symbols into the global namespace [default]\n\
|
||||
-globals <name> - Set <name> used to access C global variables [default: 'cvar']\n\
|
||||
- Use '.' to load C global variables into module namespace\n\
|
||||
-noglobal - Do not load all symbols into the global namespace\n\
|
||||
-opprefix <str> - Prefix <str> for global operator functions [default: 'op_']\n\
|
||||
\n";
|
||||
|
||||
|
||||
class OCTAVE:public Language {
|
||||
private:
|
||||
File *f_begin;
|
||||
File *f_runtime;
|
||||
File *f_header;
|
||||
File *f_doc;
|
||||
|
|
@ -37,9 +51,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;
|
||||
|
|
@ -51,11 +72,40 @@ public:
|
|||
for (int i = 1; i < argc; i++) {
|
||||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(usage, stderr);
|
||||
}
|
||||
fputs(usage, stdout);
|
||||
} else if (strcmp(argv[i], "-global") == 0) {
|
||||
global_load = true;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-noglobal") == 0) {
|
||||
global_load = false;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-globals") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
global_name = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
} else if (strcmp(argv[i], "-opprefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
op_prefix = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!global_name)
|
||||
global_name = NewString("cvar");
|
||||
if (!op_prefix)
|
||||
op_prefix = NewString("op_");
|
||||
|
||||
SWIG_library_directory("octave");
|
||||
Preprocessor_define("SWIGOCTAVE 1", 0);
|
||||
SWIG_config_file("octave.swg");
|
||||
|
|
@ -87,11 +137,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 +151,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 +160,22 @@ 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);
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIG_global_load %s\n", global_load ? "true" : "false");
|
||||
Printf(f_runtime, "#define SWIG_global_name \"%s\"\n", global_name);
|
||||
Printf(f_runtime, "#define SWIG_op_prefix \"%s\"\n", op_prefix);
|
||||
Printf(f_runtime, "#define SWIG_atexit_func swig_atexit_%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 +183,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 +207,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 +226,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;
|
||||
}
|
||||
|
|
@ -319,86 +385,139 @@ public:
|
|||
return conv ? "SWIG_POINTER_IMPLICIT_CONV" : "0";
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* addMissingParameterNames()
|
||||
* For functions that have not had nameless parameters set in the Language class.
|
||||
*
|
||||
* Inputs:
|
||||
* plist - entire parameter list
|
||||
* arg_offset - argument number for first parameter
|
||||
* Side effects:
|
||||
* The "lname" attribute in each parameter in plist will be contain a parameter name
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void addMissingParameterNames(ParmList *plist, int arg_offset) {
|
||||
Parm *p = plist;
|
||||
int i = arg_offset;
|
||||
while (p) {
|
||||
if (!Getattr(p, "lname")) {
|
||||
String *pname = Swig_cparm_name(p, i);
|
||||
Delete(pname);
|
||||
}
|
||||
i++;
|
||||
p = nextSibling(p);
|
||||
}
|
||||
}
|
||||
|
||||
void make_autodocParmList(Node *n, String *decl_str, String *args_str) {
|
||||
String *pdocs = Copy(Getattr(n, "feature:pdocs"));
|
||||
String *pdocs = 0;
|
||||
ParmList *plist = CopyParmList(Getattr(n, "parms"));
|
||||
Parm *p;
|
||||
Parm *pnext;
|
||||
Node *lookup;
|
||||
int start_arg_num = is_wrapping_class() ? 1 : 0;
|
||||
|
||||
if (pdocs)
|
||||
Append(pdocs, "\n");
|
||||
addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms
|
||||
|
||||
Swig_typemap_attach_parms("in", plist, 0);
|
||||
Swig_typemap_attach_parms("doc", 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 *name = 0;
|
||||
String *type = 0;
|
||||
String *value = 0;
|
||||
String *ptype = 0;
|
||||
String *pdoc = Getattr(p, "tmap:doc");
|
||||
if (pdoc) {
|
||||
name = Getattr(p, "tmap:doc:name");
|
||||
type = Getattr(p, "tmap:doc:type");
|
||||
value = Getattr(p, "tmap:doc:value");
|
||||
ptype = Getattr(p, "tmap:doc:pytype");
|
||||
}
|
||||
|
||||
// Note: the generated name should be consistent with that in kwnames[]
|
||||
name = name ? name : Getattr(p, "name");
|
||||
name = name ? name : Getattr(p, "lname");
|
||||
name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword
|
||||
|
||||
type = type ? type : Getattr(p, "type");
|
||||
value = value ? value : Getattr(p, "value");
|
||||
|
||||
if (SwigType_isvarargs(type))
|
||||
break;
|
||||
|
||||
String *tex_name = NewString("");
|
||||
if (name)
|
||||
Printf(tex_name, "@var{%s}", name);
|
||||
else
|
||||
Printf(tex_name, "@var{?}");
|
||||
|
||||
String *tm = Getattr(p, "tmap:in");
|
||||
if (tm) {
|
||||
pnext = Getattr(p, "tmap:in:next");
|
||||
} else {
|
||||
pnext = nextSibling(p);
|
||||
}
|
||||
|
||||
if (Len(decl_str))
|
||||
Append(decl_str, ", ");
|
||||
Append(decl_str, tex_name);
|
||||
|
||||
if (value) {
|
||||
if (Strcmp(value, "NULL") == 0)
|
||||
value = NewString("nil");
|
||||
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");
|
||||
else {
|
||||
lookup = Swig_symbol_clookup(value, 0);
|
||||
String *new_value = convertValue(value, Getattr(p, "type"));
|
||||
if (new_value) {
|
||||
value = new_value;
|
||||
} else {
|
||||
Node *lookup = Swig_symbol_clookup(value, 0);
|
||||
if (lookup)
|
||||
value = Getattr(lookup, "sym:name");
|
||||
}
|
||||
Printf(decl_str, " = %s", value);
|
||||
}
|
||||
|
||||
if (type) {
|
||||
String *type_str = NewString("");
|
||||
type = SwigType_base(type);
|
||||
lookup = Swig_symbol_clookup(type, 0);
|
||||
if (lookup)
|
||||
type = Getattr(lookup, "sym:name");
|
||||
Printf(type_str, "%s is of type %s. ", tex_name, type);
|
||||
Append(args_str, type_str);
|
||||
Delete(type_str);
|
||||
}
|
||||
Node *nn = classLookup(Getattr(p, "type"));
|
||||
String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
|
||||
Printf(args_str, "%s is of type %s. ", tex_name, type_str);
|
||||
|
||||
Delete(type_str);
|
||||
Delete(tex_name);
|
||||
Delete(name);
|
||||
}
|
||||
if (pdocs)
|
||||
Setattr(n, "feature:pdocs", pdocs);
|
||||
Delete(plist);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* convertValue()
|
||||
* Check if string v can be an Octave value literal,
|
||||
* (eg. number or string), or translate it to an Octave literal.
|
||||
* ------------------------------------------------------------ */
|
||||
String *convertValue(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, "NULL") == 0)
|
||||
return SwigType_ispointer(t) ? NewString("nil") : NewString("0");
|
||||
else if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
|
||||
return NewString("true");
|
||||
else if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("false");
|
||||
if (Strcmp(v, "true") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("true");
|
||||
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("false");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int functionWrapper(Node *n) {
|
||||
Wrapper *f = NewWrapper();
|
||||
Parm *p;
|
||||
|
|
@ -577,8 +696,8 @@ public:
|
|||
Wrapper_add_local(f, "_outv", "octave_value _outv");
|
||||
|
||||
// Return the function value
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "_outv");
|
||||
Replaceall(tm, "$result", "_outv");
|
||||
|
||||
|
|
@ -599,14 +718,14 @@ public:
|
|||
Printv(f->code, cleanup, NIL);
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$result", "_outv");
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
|
|
@ -678,8 +797,8 @@ public:
|
|||
Wrapper *getf = NewWrapper();
|
||||
Wrapper *setf = NewWrapper();
|
||||
|
||||
String *getname = Swig_name_get(iname);
|
||||
String *setname = Swig_name_set(iname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, iname);
|
||||
String *setname = Swig_name_set(NSPACE_TODO, iname);
|
||||
|
||||
Printf(setf->def, "static octave_value_list _wrap_%s(const octave_value_list& args,int nargout) {", setname);
|
||||
Printf(setf->def, "if (!SWIG_check_num_args(\"%s_set\",args.length(),1,1,0)) return octave_value_list();", iname);
|
||||
|
|
@ -737,6 +856,7 @@ public:
|
|||
SwigType *type = Getattr(n, "type");
|
||||
String *rawval = Getattr(n, "rawval");
|
||||
String *value = rawval ? rawval : Getattr(n, "value");
|
||||
String *cppvalue = Getattr(n, "cppvalue");
|
||||
String *tm;
|
||||
|
||||
if (!addSymbol(iname, n))
|
||||
|
|
@ -752,7 +872,7 @@ public:
|
|||
if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
|
||||
Replaceall(tm, "$source", value);
|
||||
Replaceall(tm, "$target", name);
|
||||
Replaceall(tm, "$value", value);
|
||||
Replaceall(tm, "$value", cppvalue ? cppvalue : value);
|
||||
Replaceall(tm, "$nsname", iname);
|
||||
Printf(f_init, "%s\n", tm);
|
||||
} else {
|
||||
|
|
@ -814,18 +934,23 @@ public:
|
|||
|
||||
int use_director = Swig_directorclass(n);
|
||||
if (use_director) {
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *cname = Swig_name_disown(nspace, class_name);
|
||||
String *wcname = Swig_name_wrapper(cname);
|
||||
String *disown_shadow = NewString("");
|
||||
Printf(disown_shadow, "static octave_value_list _wrap_disown_%s_shadow " "(const octave_value_list& args, int nargout) {\n", class_name);
|
||||
Printf(disown_shadow, "static octave_value_list %s_shadow " "(const octave_value_list& args, int nargout) {\n", wcname);
|
||||
Printf(disown_shadow, " if (args.length()!=1) {\n");
|
||||
Printf(disown_shadow, " error(\"disown takes no arguments\");\n");
|
||||
Printf(disown_shadow, " return octave_value_list();\n");
|
||||
Printf(disown_shadow, " }\n");
|
||||
Printf(disown_shadow, " _wrap_disown_%s (args, nargout);\n", class_name);
|
||||
Printf(disown_shadow, " %s (args, nargout);\n", wcname);
|
||||
Printf(disown_shadow, " return args;\n");
|
||||
Printf(disown_shadow, "}\n");
|
||||
Printv(f_wrappers, disown_shadow, NIL);
|
||||
Delete(disown_shadow);
|
||||
Printf(s_members_tab, "{\"__disown\",_wrap_disown_%s_shadow,0,0,0,0},\n", class_name);
|
||||
Printf(s_members_tab, "{\"__disown\",%s_shadow,0,0,0,0},\n", wcname);
|
||||
Delete(wcname);
|
||||
Delete(cname);
|
||||
}
|
||||
|
||||
Printf(s_members_tab, "{0,0,0,0}\n};\n");
|
||||
|
|
@ -859,7 +984,8 @@ public:
|
|||
Printv(f_wrappers, "static swig_octave_class _wrap_class_", class_name, " = {\"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
|
||||
Printv(f_wrappers, Swig_directorclass(n) ? "1," : "0,", NIL);
|
||||
if (have_constructor) {
|
||||
String *cname = Swig_name_construct(constructor_name);
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *cname = Swig_name_construct(nspace, constructor_name);
|
||||
String *wcname = Swig_name_wrapper(cname);
|
||||
String *tname = texinfo_name(n);
|
||||
Printf(f_wrappers, "%s,%s,", wcname, tname);
|
||||
|
|
@ -868,9 +994,14 @@ public:
|
|||
Delete(cname);
|
||||
} else
|
||||
Printv(f_wrappers, "0,0,", NIL);
|
||||
if (have_destructor)
|
||||
Printv(f_wrappers, "_wrap_delete_", class_name, ",", NIL);
|
||||
else
|
||||
if (have_destructor) {
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *cname = Swig_name_destroy(nspace, class_name);
|
||||
String *wcname = Swig_name_wrapper(cname);
|
||||
Printf(f_wrappers, "%s,", wcname);
|
||||
Delete(wcname);
|
||||
Delete(cname);
|
||||
} else
|
||||
Printv(f_wrappers, "0", ",", NIL);
|
||||
Printf(f_wrappers, "swig_%s_members,swig_%s_base_names,swig_%s_base };\n\n", class_name, class_name, class_name);
|
||||
|
||||
|
|
@ -892,16 +1023,21 @@ public:
|
|||
String *name = Getattr(n, "name");
|
||||
String *iname = GetChar(n, "sym:name");
|
||||
String *realname = iname ? iname : name;
|
||||
String *rname = Swig_name_wrapper(Swig_name_member(class_name, realname));
|
||||
String *wname = Getattr(n, "wrap:name");
|
||||
assert(wname);
|
||||
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
String *tname = texinfo_name(n);
|
||||
String *rname = Copy(wname);
|
||||
bool overloaded = !!Getattr(n, "sym:overloaded");
|
||||
if (overloaded)
|
||||
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
|
||||
Printf(s_members_tab, "{\"%s\",%s,0,0,0,%s},\n",
|
||||
realname, rname, tname);
|
||||
Delete(rname);
|
||||
Delete(tname);
|
||||
}
|
||||
|
||||
Delete(rname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -913,9 +1049,9 @@ public:
|
|||
assert(s_members_tab);
|
||||
assert(class_name);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
String *setname = GetFlag(n, "feature:immutable") ?
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
assert(s_members_tab);
|
||||
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,0,0},\n", symname, getname, setname);
|
||||
|
|
@ -937,7 +1073,7 @@ public:
|
|||
String *name = NewString("self");
|
||||
String *type = NewString("void");
|
||||
SwigType_add_pointer(type);
|
||||
self = NewParm(type, name);
|
||||
self = NewParm(type, name, n);
|
||||
Delete(type);
|
||||
Delete(name);
|
||||
Setattr(self, "lname", "self_obj");
|
||||
|
|
@ -949,12 +1085,12 @@ public:
|
|||
Delete(self);
|
||||
}
|
||||
|
||||
return Language::constructorHandler(n);;
|
||||
return Language::constructorHandler(n);
|
||||
}
|
||||
|
||||
virtual int destructorHandler(Node *n) {
|
||||
have_destructor = 1;
|
||||
return Language::destructorHandler(n);;
|
||||
return Language::destructorHandler(n);
|
||||
}
|
||||
|
||||
virtual int staticmemberfunctionHandler(Node *n) {
|
||||
|
|
@ -965,16 +1101,21 @@ public:
|
|||
String *name = Getattr(n, "name");
|
||||
String *iname = GetChar(n, "sym:name");
|
||||
String *realname = iname ? iname : name;
|
||||
String *rname = Swig_name_wrapper(Swig_name_member(class_name, realname));
|
||||
String *wname = Getattr(n, "wrap:name");
|
||||
assert(wname);
|
||||
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
String *tname = texinfo_name(n);
|
||||
String *rname = Copy(wname);
|
||||
bool overloaded = !!Getattr(n, "sym:overloaded");
|
||||
if (overloaded)
|
||||
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
|
||||
Printf(s_members_tab, "{\"%s\",%s,0,0,1,%s},\n",
|
||||
realname, rname, tname);
|
||||
Delete(rname);
|
||||
Delete(tname);
|
||||
}
|
||||
|
||||
Delete(rname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -991,9 +1132,9 @@ public:
|
|||
assert(s_members_tab);
|
||||
assert(class_name);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
String *setname = GetFlag(n, "feature:immutable") ?
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
assert(s_members_tab);
|
||||
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,1,0},\n", symname, getname, setname);
|
||||
|
|
@ -1032,7 +1173,7 @@ public:
|
|||
ParmList *parms = CopyParmList(superparms);
|
||||
String *type = NewString("void");
|
||||
SwigType_add_pointer(type);
|
||||
p = NewParm(type, NewString("self"));
|
||||
p = NewParm(type, NewString("self"), n);
|
||||
set_nextSibling(p, parms);
|
||||
parms = p;
|
||||
|
||||
|
|
@ -1090,6 +1231,7 @@ public:
|
|||
String *name;
|
||||
String *classname;
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
|
|
@ -1206,6 +1348,8 @@ public:
|
|||
// attach typemaps to arguments (C/C++ -> Python)
|
||||
String *parse_args = NewString("");
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
Swig_typemap_attach_parms("in", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
Swig_typemap_attach_parms("directorargout", l, w);
|
||||
|
|
@ -1219,8 +1363,7 @@ public:
|
|||
// build argument list and type conversion string
|
||||
idx = 0;
|
||||
p = l;
|
||||
int use_parse = 0;
|
||||
while (p != NULL) {
|
||||
while (p) {
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
|
|
@ -1236,14 +1379,15 @@ public:
|
|||
if ((tm = Getattr(p, "tmap:directorin")) != 0) {
|
||||
String *parse = Getattr(p, "tmap:directorin:parse");
|
||||
if (!parse) {
|
||||
Setattr(p, "emit:directorinput", "tmpv");
|
||||
Replaceall(tm, "$input", "tmpv");
|
||||
Replaceall(tm, "$owner", "0");
|
||||
Printv(wrap_args, tm, "\n", NIL);
|
||||
Printf(wrap_args, "args.append(tmpv);\n");
|
||||
Putc('O', parse_args);
|
||||
} else {
|
||||
use_parse = 1;
|
||||
Append(parse_args, parse);
|
||||
Setattr(p, "emit:directorinput", pname);
|
||||
Replaceall(tm, "$input", pname);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
if (Len(tm) == 0)
|
||||
|
|
@ -1285,13 +1429,8 @@ public:
|
|||
Printf(w->code, "}\n");
|
||||
|
||||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "result", w);
|
||||
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), 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);
|
||||
|
|
@ -1318,8 +1457,8 @@ public:
|
|||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
char temp[24];
|
||||
sprintf(temp, "out(%d)", idx);
|
||||
Replaceall(tm, "$input", temp);
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Replaceall(tm, "$result", temp);
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
|
|
@ -1363,6 +1502,7 @@ public:
|
|||
// emit the director method
|
||||
if (status == SWIG_OK) {
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* overload.cxx
|
||||
*
|
||||
|
|
@ -55,7 +59,7 @@ void Wrapper_cast_dispatch_mode_set(int flag) {
|
|||
* languages ignore the first method parsed.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
||||
List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
||||
Overloaded nodes[MAX_OVERLOAD];
|
||||
int nnodes = 0;
|
||||
Node *o = Getattr(n, "sym:overloaded");
|
||||
|
|
@ -223,13 +227,16 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored. Non-const method %s at %s:%d used.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore"))
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored. Method %s at %s:%d used.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
|
|
@ -238,13 +245,16 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored. Non-const method %s at %s:%d used.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore"))
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored. Method %s at %s:%d used.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
|
|
@ -258,15 +268,16 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s is shadowed by %s at %s:%d.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
|
||||
Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
"Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore"))
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored. Method %s at %s:%d used.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
|
||||
Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
|
|
@ -316,7 +327,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 +363,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;
|
||||
|
|
@ -378,16 +389,11 @@ String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *max
|
|||
int num_arguments = emit_num_arguments(pi);
|
||||
if (num_arguments > *maxargs)
|
||||
*maxargs = num_arguments;
|
||||
int varargs = emit_isvarargs(pi);
|
||||
|
||||
if (!varargs) {
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
Printf(f, "SWIG_TypeRank _ranki = 0;\n");
|
||||
Printf(f, "SWIG_TypeRank _rankm = 0;\n");
|
||||
|
|
@ -536,7 +542,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;
|
||||
|
|
@ -557,16 +563,11 @@ String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *max
|
|||
int num_arguments = emit_num_arguments(pi);
|
||||
if (num_arguments > *maxargs)
|
||||
*maxargs = num_arguments;
|
||||
int varargs = emit_isvarargs(pi);
|
||||
|
||||
if (!varargs) {
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
|
||||
/* create a list with the wrappers that collide with the
|
||||
|
|
@ -695,7 +696,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);
|
||||
|
|
@ -718,18 +719,17 @@ String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs)
|
|||
Parm *pi = Getattr(ni, "wrap:parms");
|
||||
int num_required = emit_num_required(pi);
|
||||
int num_arguments = emit_num_arguments(pi);
|
||||
if (GetFlag(n, "wrap:this")) {
|
||||
num_required++;
|
||||
num_arguments++;
|
||||
}
|
||||
if (num_arguments > *maxargs)
|
||||
*maxargs = num_arguments;
|
||||
int varargs = emit_isvarargs(pi);
|
||||
|
||||
if (!varargs) {
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
|
||||
if (num_arguments) {
|
||||
|
|
@ -751,7 +751,7 @@ String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs)
|
|||
Printf(f, "}\n");
|
||||
Delete(lfmt);
|
||||
}
|
||||
if (print_typecheck(f, j, pj)) {
|
||||
if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj)) {
|
||||
Printf(f, "if (_v) {\n");
|
||||
num_braces++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
||||
* vim:expandtab:shiftwidth=2:tabstop=8:smarttab:
|
||||
*/
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* perl5.cxx
|
||||
*
|
||||
|
|
@ -21,14 +21,15 @@ static int treduce = SWIG_cparse_template_reduce(0);
|
|||
|
||||
static const char *usage = (char *) "\
|
||||
Perl5 Options (available with -perl5)\n\
|
||||
-static - Omit code related to dynamic loading\n\
|
||||
-nopm - Do not generate the .pm file\n\
|
||||
-proxy - Create proxy classes\n\
|
||||
-noproxy - Don't create proxy classes\n\
|
||||
-compat - Compatibility mode\n\
|
||||
-const - Wrap constants as constants and not variables (implies -proxy)\n\
|
||||
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
|
||||
-cppcast - Enable C++ casting operators\n\
|
||||
-compat - Compatibility mode\n\n";
|
||||
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
|
||||
-nopm - Do not generate the .pm file\n\
|
||||
-noproxy - Don't create proxy classes\n\
|
||||
-proxy - Create proxy classes\n\
|
||||
-static - Omit code related to dynamic loading\n\
|
||||
\n";
|
||||
|
||||
static int compat = 0;
|
||||
|
||||
|
|
@ -78,6 +79,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;
|
||||
|
|
@ -207,6 +209,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");
|
||||
|
|
@ -222,11 +225,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("");
|
||||
|
|
@ -234,6 +238,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);
|
||||
|
||||
|
|
@ -252,11 +257,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
|
||||
|
|
@ -303,7 +309,7 @@ public:
|
|||
if (no_pmfile) {
|
||||
f_pm = NewString(0);
|
||||
} else {
|
||||
if (pmfile == NULL) {
|
||||
if (!pmfile) {
|
||||
char *m = Char(module) + Len(module);
|
||||
while (m != Char(module)) {
|
||||
if (*m == ':') {
|
||||
|
|
@ -315,7 +321,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);
|
||||
}
|
||||
|
|
@ -332,10 +338,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);
|
||||
|
|
@ -524,14 +527,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;
|
||||
}
|
||||
|
||||
|
|
@ -725,9 +730,9 @@ public:
|
|||
Swig_director_emit_dynamic_cast(n, f);
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
SwigType *t = Getattr(n, "type");
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "ST(argvi)");
|
||||
Replaceall(tm, "$result", "ST(argvi)");
|
||||
if (is_shadow(t)) {
|
||||
|
|
@ -755,14 +760,14 @@ public:
|
|||
Printv(f->code, cleanup, NIL);
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -787,7 +792,7 @@ public:
|
|||
} else if (!Getattr(n, "sym:nextSibling")) {
|
||||
/* Generate overloaded dispatch function */
|
||||
int maxargs;
|
||||
String *dispatch = Swig_overload_dispatch_cast(n, "++PL_markstack_ptr; SWIG_CALLXS(%s); return;", &maxargs);
|
||||
String *dispatch = Swig_overload_dispatch_cast(n, "PUSHMARK(MARK); SWIG_CALLXS(%s); return;", &maxargs);
|
||||
|
||||
/* Generate a dispatch wrapper for all overloaded functions */
|
||||
|
||||
|
|
@ -836,8 +841,8 @@ public:
|
|||
SwigType *t = Getattr(n, "type");
|
||||
Wrapper *getf, *setf;
|
||||
String *tm;
|
||||
String *getname = Swig_name_get(iname);
|
||||
String *setname = Swig_name_set(iname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, iname);
|
||||
String *setname = Swig_name_set(NSPACE_TODO, iname);
|
||||
|
||||
String *get_name = Swig_name_wrapper(getname);
|
||||
String *set_name = Swig_name_wrapper(setname);
|
||||
|
|
@ -1141,8 +1146,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");
|
||||
}
|
||||
|
||||
|
|
@ -1427,12 +1433,12 @@ public:
|
|||
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *plcode = perlcode(Getattr(n, "feature:shadow"), 0);
|
||||
String *plaction = NewStringf("%s::%s", cmodule, Swig_name_member(class_name, symname));
|
||||
String *plaction = NewStringf("%s::%s", cmodule, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
Replaceall(plcode, "$action", plaction);
|
||||
Delete(plaction);
|
||||
Printv(pcode, plcode, NIL);
|
||||
} else {
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL);
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL);
|
||||
}
|
||||
}
|
||||
return SWIG_OK;
|
||||
|
|
@ -1457,8 +1463,8 @@ public:
|
|||
|
||||
if (blessed) {
|
||||
|
||||
Printv(pcode, "*swig_", symname, "_get = *", cmodule, "::", Swig_name_get(Swig_name_member(class_name, symname)), ";\n", NIL);
|
||||
Printv(pcode, "*swig_", symname, "_set = *", cmodule, "::", Swig_name_set(Swig_name_member(class_name, symname)), ";\n", NIL);
|
||||
Printv(pcode, "*swig_", symname, "_get = *", cmodule, "::", Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)), ";\n", NIL);
|
||||
Printv(pcode, "*swig_", symname, "_set = *", cmodule, "::", Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)), ";\n", NIL);
|
||||
|
||||
/* Now we need to generate a little Perl code for this */
|
||||
|
||||
|
|
@ -1496,7 +1502,7 @@ public:
|
|||
if ((blessed) && (!Getattr(n, "sym:nextSibling"))) {
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *plcode = perlcode(Getattr(n, "feature:shadow"), 0);
|
||||
String *plaction = NewStringf("%s::%s", module, Swig_name_member(class_name, symname));
|
||||
String *plaction = NewStringf("%s::%s", module, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
Replaceall(plcode, "$action", plaction);
|
||||
Delete(plaction);
|
||||
Printv(pcode, plcode, NIL);
|
||||
|
|
@ -1506,12 +1512,12 @@ public:
|
|||
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, "sub ", Swig_name_construct(NSPACE_TODO, 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);
|
||||
tab4, "my $self = ", cmodule, "::", Swig_name_construct(NSPACE_TODO, symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL);
|
||||
|
||||
have_constructor = 1;
|
||||
}
|
||||
|
|
@ -1531,7 +1537,7 @@ public:
|
|||
if (blessed) {
|
||||
if (Getattr(n, "feature:shadow")) {
|
||||
String *plcode = perlcode(Getattr(n, "feature:shadow"), 0);
|
||||
String *plaction = NewStringf("%s::%s", module, Swig_name_member(class_name, symname));
|
||||
String *plaction = NewStringf("%s::%s", module, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
Replaceall(plcode, "$action", plaction);
|
||||
Delete(plaction);
|
||||
Printv(pcode, plcode, NIL);
|
||||
|
|
@ -1543,7 +1549,7 @@ public:
|
|||
tab4, "return unless defined $self;\n",
|
||||
tab4, "delete $ITERATORS{$self};\n",
|
||||
tab4, "if (exists $OWNER{$self}) {\n",
|
||||
tab8, cmodule, "::", Swig_name_destroy(symname), "($self);\n", tab8, "delete $OWNER{$self};\n", tab4, "}\n}\n\n", NIL);
|
||||
tab8, cmodule, "::", Swig_name_destroy(NSPACE_TODO, symname), "($self);\n", tab8, "delete $OWNER{$self};\n", tab4, "}\n}\n\n", NIL);
|
||||
have_destructor = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1561,7 +1567,7 @@ public:
|
|||
member_func = 0;
|
||||
if ((blessed) && (!Getattr(n, "sym:nextSibling"))) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL);
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1574,7 +1580,7 @@ public:
|
|||
Language::staticmembervariableHandler(n);
|
||||
if (blessed) {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL);
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1593,7 +1599,7 @@ public:
|
|||
blessed = oldblessed;
|
||||
|
||||
if (blessed) {
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(class_name, symname), ";\n", NIL);
|
||||
Printv(pcode, "*", symname, " = *", cmodule, "::", Swig_name_member(NSPACE_TODO, class_name, symname), ";\n", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1624,9 +1630,9 @@ 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);
|
||||
Swig_error(input_file, line_number, "Unable to locate file %s\n", value);
|
||||
} else {
|
||||
char buffer[4096];
|
||||
while (fgets(buffer, 4095, f)) {
|
||||
|
|
@ -1636,7 +1642,7 @@ public:
|
|||
fclose(f);
|
||||
}
|
||||
} else {
|
||||
Printf(stderr, "%s : Line %d. Unrecognized pragma.\n", input_file, line_number);
|
||||
Swig_error(input_file, line_number, "Unrecognized pragma.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* pike.cxx
|
||||
*
|
||||
|
|
@ -33,12 +37,13 @@ char cvsroot_pike_cxx[] = "$Id$";
|
|||
|
||||
static const char *usage = (char *) "\
|
||||
Pike Options (available with -pike)\n\
|
||||
[None]\n\
|
||||
[no additional options]\n\
|
||||
\n";
|
||||
|
||||
class PIKE:public Language {
|
||||
private:
|
||||
|
||||
File *f_begin;
|
||||
File *f_runtime;
|
||||
File *f_header;
|
||||
File *f_wrappers;
|
||||
|
|
@ -69,6 +74,7 @@ public:
|
|||
* --------------------------------------------------------------------- */
|
||||
|
||||
PIKE() {
|
||||
f_begin = 0;
|
||||
f_runtime = 0;
|
||||
f_header = 0;
|
||||
f_wrappers = 0;
|
||||
|
|
@ -123,11 +129,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,19 +143,24 @@ 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);
|
||||
|
||||
/* Change naming scheme for constructors and destructors */
|
||||
Swig_name_register("construct", "%c_create");
|
||||
Swig_name_register("destroy", "%c_destroy");
|
||||
Swig_name_register("construct", "%n%c_create");
|
||||
Swig_name_register("destroy", "%n%c_destroy");
|
||||
|
||||
/* Current wrap type */
|
||||
current = NO_CPP;
|
||||
|
|
@ -161,17 +173,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 +235,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 +248,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:
|
||||
|
|
@ -407,15 +421,15 @@ public:
|
|||
|
||||
/* Return the function value */
|
||||
if (current == CONSTRUCTOR) {
|
||||
Printv(actioncode, "THIS = (void *) result;\n", NIL);
|
||||
Printv(actioncode, "THIS = (void *) ", Swig_cresult_name(), ";\n", NIL);
|
||||
Printv(description, ", tVoid", NIL);
|
||||
} else if (current == DESTRUCTOR) {
|
||||
Printv(description, ", tVoid", NIL);
|
||||
} else {
|
||||
Printv(description, ", ", NIL);
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
actioncode = 0;
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "resultobj");
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
|
|
@ -446,15 +460,15 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -564,12 +578,16 @@ public:
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *value = Getattr(n, "value");
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
|
||||
/* Special hook for member pointer */
|
||||
if (SwigType_type(type) == T_MPOINTER) {
|
||||
/* Special hook for member pointer */
|
||||
String *wname = Swig_name_wrapper(symname);
|
||||
Printf(f_header, "static %s = %s;\n", SwigType_str(type, wname), value);
|
||||
value = wname;
|
||||
} else if (SwigType_type(type) == T_CHAR && is_enum_item) {
|
||||
type = NewSwigType(T_INT);
|
||||
Setattr(n, "type", type);
|
||||
}
|
||||
|
||||
/* Perform constant typemap substitution */
|
||||
|
|
@ -752,7 +770,7 @@ public:
|
|||
/* Create a function to set the values of the (mutable) variables */
|
||||
if (need_setter) {
|
||||
Wrapper *wrapper = NewWrapper();
|
||||
String *setter = Swig_name_member(getClassPrefix(), (char *) "`->=");
|
||||
String *setter = Swig_name_member(NSPACE_TODO, getClassPrefix(), "`->=");
|
||||
String *wname = Swig_name_wrapper(setter);
|
||||
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
|
||||
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");
|
||||
|
|
@ -761,7 +779,7 @@ public:
|
|||
while (i.item) {
|
||||
if (!GetFlag(i.item, "feature:immutable")) {
|
||||
name = Getattr(i.item, "name");
|
||||
funcname = Swig_name_wrapper(Swig_name_set(Swig_name_member(getClassPrefix(), name)));
|
||||
funcname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, getClassPrefix(), name)));
|
||||
Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name);
|
||||
Printf(wrapper->code, "%s(args);\n", funcname);
|
||||
Printf(wrapper->code, "return;\n");
|
||||
|
|
@ -791,7 +809,7 @@ public:
|
|||
|
||||
/* Create a function to get the values of the (mutable) variables */
|
||||
Wrapper *wrapper = NewWrapper();
|
||||
String *getter = Swig_name_member(getClassPrefix(), (char *) "`->");
|
||||
String *getter = Swig_name_member(NSPACE_TODO, getClassPrefix(), "`->");
|
||||
String *wname = Swig_name_wrapper(getter);
|
||||
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
|
||||
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");
|
||||
|
|
@ -799,7 +817,7 @@ public:
|
|||
i = First(membervariables);
|
||||
while (i.item) {
|
||||
name = Getattr(i.item, "name");
|
||||
funcname = Swig_name_wrapper(Swig_name_get(Swig_name_member(getClassPrefix(), name)));
|
||||
funcname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, getClassPrefix(), name)));
|
||||
Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name);
|
||||
Printf(wrapper->code, "%s(args);\n", funcname);
|
||||
Printf(wrapper->code, "return;\n");
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* s-exp.cxx
|
||||
*
|
||||
|
|
@ -29,6 +33,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 +49,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 +63,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 +72,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;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
*
|
||||
* Simplified Wrapper and Interface Generator (SWIG)
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* swigmain.cxx
|
||||
*
|
||||
* Simplified Wrapper and Interface Generator (SWIG)
|
||||
*
|
||||
* This file is the main entry point to SWIG. It collects the command
|
||||
* line options, registers built-in language modules, and instantiates
|
||||
* a module for code generation. If adding new language modules
|
||||
|
|
@ -32,8 +36,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);
|
||||
|
|
@ -48,6 +52,8 @@ extern "C" {
|
|||
Language *swig_uffi(void);
|
||||
Language *swig_r(void);
|
||||
Language *swig_c(void);
|
||||
Language *swig_go(void);
|
||||
Language *swig_d(void);
|
||||
}
|
||||
|
||||
struct swig_module {
|
||||
|
|
@ -67,6 +73,8 @@ static swig_module modules[] = {
|
|||
{"-clisp", swig_clisp, "CLISP"},
|
||||
{"-cffi", swig_cffi, "CFFI"},
|
||||
{"-csharp", swig_csharp, "C#"},
|
||||
{"-d", swig_d, "D"},
|
||||
{"-go", swig_go, "Go"},
|
||||
{"-guile", swig_guile, "Guile"},
|
||||
{"-java", swig_java, "Java"},
|
||||
{"-lua", swig_lua, "Lua"},
|
||||
|
|
@ -76,9 +84,9 @@ static swig_module modules[] = {
|
|||
{"-octave", swig_octave, "Octave"},
|
||||
{"-perl", swig_perl5, "Perl"},
|
||||
{"-perl5", swig_perl5, 0},
|
||||
{"-php", swig_php4, 0},
|
||||
{"-php4", swig_php4, "PHP4"},
|
||||
{"-php5", swig_php5, "PHP5"},
|
||||
{"-php", swig_php, "PHP"},
|
||||
{"-php4", swig_php4, 0},
|
||||
{"-php5", swig_php, 0},
|
||||
{"-pike", swig_pike, "Pike"},
|
||||
{"-python", swig_python, "Python"},
|
||||
{"-r", swig_r, "R (aka GNU S)"},
|
||||
|
|
@ -198,7 +206,8 @@ int main(int margc, char **margv) {
|
|||
dl = (fac) ();
|
||||
}
|
||||
}
|
||||
|
||||
int res = SWIG_main(argc, argv, dl);
|
||||
delete dl;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* swigmod.h
|
||||
*
|
||||
* Main header file for SWIG modules.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef SWIG_SWIGMOD_H_
|
||||
#define SWIG_SWIGMOD_H_
|
||||
|
||||
|
|
@ -26,7 +28,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 +116,8 @@ protected:
|
|||
|
||||
class Language:public Dispatcher {
|
||||
public:
|
||||
Language ();
|
||||
virtual ~ Language ();
|
||||
Language();
|
||||
virtual ~Language();
|
||||
virtual int emit_one(Node *n);
|
||||
|
||||
/* Parse command line options */
|
||||
|
|
@ -208,14 +210,16 @@ public:
|
|||
|
||||
/* Miscellaneous */
|
||||
virtual int validIdentifier(String *s); /* valid identifier? */
|
||||
virtual int addSymbol(const String *s, const Node *n); /* Add symbol */
|
||||
virtual Node *symbolLookup(String *s); /* Symbol lookup */
|
||||
virtual Node *classLookup(SwigType *s); /* Class lookup */
|
||||
virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */
|
||||
virtual void dumpSymbols();
|
||||
virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
|
||||
virtual Node *classLookup(const SwigType *s); /* Class lookup */
|
||||
virtual Node *enumLookup(SwigType *s); /* Enum lookup */
|
||||
virtual int abstractClassTest(Node *n); /* Is class really abstract? */
|
||||
virtual int is_assignable(Node *n); /* Is variable assignable? */
|
||||
virtual String *runtimeCode(); /* returns the language specific runtime code */
|
||||
virtual String *defaultExternalRuntimeFilename(); /* the default filename for the external runtime */
|
||||
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm); /* Language specific special variable substitutions for $typemap() */
|
||||
|
||||
/* Runtime is C++ based, so extern "C" header section */
|
||||
void enable_cplus_runtime_mode();
|
||||
|
|
@ -250,6 +254,9 @@ public:
|
|||
/* Set overload variable templates argc and argv */
|
||||
void setOverloadResolutionTemplates(String *argc, String *argv);
|
||||
|
||||
/* Language instance is a singleton - get instance */
|
||||
static Language* instance();
|
||||
|
||||
protected:
|
||||
/* Allow multiple-input typemaps */
|
||||
void allow_multiple_input(int val = 1);
|
||||
|
|
@ -258,7 +265,7 @@ protected:
|
|||
void allow_overloading(int val = 1);
|
||||
|
||||
/* Wrapping class query */
|
||||
int is_wrapping_class();
|
||||
int is_wrapping_class() const;
|
||||
|
||||
/* Return the node for the current class */
|
||||
Node *getCurrentClass() const;
|
||||
|
|
@ -266,6 +273,9 @@ protected:
|
|||
/* Return C++ mode */
|
||||
int getCPlusMode() const;
|
||||
|
||||
/* Return the namespace for the class/enum - the nspace feature */
|
||||
String *getNSpace() const;
|
||||
|
||||
/* Return the real name of the current class */
|
||||
String *getClassName() const;
|
||||
|
||||
|
|
@ -300,22 +310,27 @@ protected:
|
|||
int director_language;
|
||||
|
||||
private:
|
||||
Hash *symbols;
|
||||
Hash *symtabs; /* symbol tables */
|
||||
Hash *classtypes;
|
||||
Hash *enumtypes;
|
||||
int overloading;
|
||||
int multiinput;
|
||||
int cplus_runtime;
|
||||
int directors;
|
||||
static Language *this_;
|
||||
};
|
||||
|
||||
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);
|
||||
void Swig_print_xml(Node *obj, String *filename);
|
||||
|
||||
/* get the list of generated files */
|
||||
List *SWIG_output_files();
|
||||
|
||||
void SWIG_library_directory(const char *);
|
||||
int emit_num_arguments(ParmList *);
|
||||
|
|
@ -326,25 +341,29 @@ 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 *);
|
||||
List *Swig_overload_rank(Node *n, bool script_lang_wrapping);
|
||||
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);
|
||||
void Swig_director_parms_fixup(ParmList *parms);
|
||||
/* directors.cxx end */
|
||||
|
||||
extern "C" {
|
||||
void SWIG_typemap_lang(const char *);
|
||||
typedef Language *(*ModuleFactory) (void);
|
||||
} void Swig_register_module(const char *name, ModuleFactory fac);
|
||||
}
|
||||
|
||||
void Swig_register_module(const char *name, ModuleFactory fac);
|
||||
ModuleFactory Swig_find_module(const char *name);
|
||||
|
||||
/* Utilities */
|
||||
|
|
@ -362,9 +381,15 @@ void Wrapper_fast_dispatch_mode_set(int);
|
|||
void Wrapper_cast_dispatch_mode_set(int);
|
||||
void Wrapper_naturalvar_mode_set(int);
|
||||
|
||||
|
||||
void clean_overloaded(Node *n);
|
||||
|
||||
extern "C" {
|
||||
const char *Swig_to_string(DOH *object, int count = -1);
|
||||
const char *Swig_to_string_with_location(DOH *object, int count = -1);
|
||||
void Swig_print(DOH *object, int count = -1);
|
||||
void Swig_print_with_location(DOH *object, int count = -1);
|
||||
}
|
||||
|
||||
/* Contracts */
|
||||
|
||||
void Swig_contracts(Node *n);
|
||||
|
|
@ -377,5 +402,4 @@ void Swig_browser(Node *n, int);
|
|||
void Swig_default_allocators(Node *n);
|
||||
void Swig_process_types(Node *n);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* tcl8.cxx
|
||||
*
|
||||
|
|
@ -28,7 +32,7 @@ static String *methods_tab = 0; /* Methods table */
|
|||
static String *attr_tab = 0; /* Attribute table */
|
||||
static String *prefix = 0;
|
||||
static String *module = 0;
|
||||
static int nspace = 0;
|
||||
static int namespace_option = 0;
|
||||
static String *init_name = 0;
|
||||
static String *ns_name = 0;
|
||||
static int have_constructor;
|
||||
|
|
@ -46,6 +50,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;
|
||||
|
||||
|
||||
|
|
@ -96,7 +101,7 @@ public:
|
|||
i++;
|
||||
}
|
||||
} else if (strcmp(argv[i], "-namespace") == 0) {
|
||||
nspace = 1;
|
||||
namespace_option = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-itcl") == 0) {
|
||||
itcl = 1;
|
||||
|
|
@ -121,6 +126,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 +142,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 +155,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 +166,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 +189,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 +198,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);
|
||||
|
|
@ -199,7 +208,7 @@ public:
|
|||
|
||||
Printf(f_header, "#define SWIG_init %s\n", init_name);
|
||||
Printf(f_header, "#define SWIG_name \"%s\"\n", module);
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Printf(f_header, "#define SWIG_prefix \"%s::\"\n", ns_name);
|
||||
Printf(f_header, "#define SWIG_namespace \"%s\"\n\n", ns_name);
|
||||
} else {
|
||||
|
|
@ -244,12 +253,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;
|
||||
}
|
||||
|
||||
|
|
@ -448,8 +460,8 @@ public:
|
|||
/* Need to redo all of this code (eventually) */
|
||||
|
||||
/* Return value if necessary */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
#ifdef SWIG_USE_RESULTOBJ
|
||||
Replaceall(tm, "$target", "resultobj");
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
|
|
@ -476,14 +488,14 @@ public:
|
|||
|
||||
/* Look for any remaining cleanup */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
#ifdef SWIG_USE_RESULTOBJ
|
||||
|
|
@ -519,7 +531,19 @@ public:
|
|||
Printf(df->code, "Tcl_Obj *CONST *argv = objv+1;\n");
|
||||
Printf(df->code, "int argc = objc-1;\n");
|
||||
Printv(df->code, dispatch, "\n", NIL);
|
||||
Printf(df->code, "Tcl_SetResult(interp,(char *) \"No matching function for overloaded '%s'\", TCL_STATIC);\n", iname);
|
||||
Node *sibl = n;
|
||||
while (Getattr(sibl, "sym:previousSibling"))
|
||||
sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up
|
||||
String *protoTypes = NewString("");
|
||||
do {
|
||||
String *fulldecl = Swig_name_decl(sibl);
|
||||
Printf(protoTypes, "\n\" %s\\n\"", fulldecl);
|
||||
Delete(fulldecl);
|
||||
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
|
||||
Printf(df->code, "Tcl_SetResult(interp,(char *) "
|
||||
"\"Wrong number or type of arguments for overloaded function '%s'.\\n\""
|
||||
"\n\" Possible C/C++ prototypes are:\\n\"%s, TCL_STATIC);\n", iname, protoTypes);
|
||||
Delete(protoTypes);
|
||||
Printf(df->code, "return TCL_ERROR;\n");
|
||||
Printv(df->code, "}\n", NIL);
|
||||
Wrapper_print(df, f_wrappers);
|
||||
|
|
@ -561,7 +585,7 @@ public:
|
|||
/* Create a function for getting a variable */
|
||||
int addfail = 0;
|
||||
getf = NewWrapper();
|
||||
String *getname = Swig_name_get(iname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, iname);
|
||||
String *getfname = Swig_name_wrapper(getname);
|
||||
Setattr(n, "wrap:name", getfname);
|
||||
Printv(getf->def, "SWIGINTERN const char *", getfname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2, int flags) {", NIL);
|
||||
|
|
@ -593,7 +617,7 @@ public:
|
|||
/* Try to create a function setting a variable */
|
||||
if (is_assignable(n)) {
|
||||
setf = NewWrapper();
|
||||
setname = Swig_name_set(iname);
|
||||
setname = Swig_name_set(NSPACE_TODO, iname);
|
||||
setfname = Swig_name_wrapper(setname);
|
||||
Setattr(n, "wrap:name", setfname);
|
||||
if (setf) {
|
||||
|
|
@ -658,7 +682,7 @@ public:
|
|||
virtual int constantWrapper(Node *n) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *iname = Getattr(n, "sym:name");
|
||||
String *nsname = !nspace ? Copy(iname) : NewStringf("%s::%s", ns_name, iname);
|
||||
String *nsname = !namespace_option ? Copy(iname) : NewStringf("%s::%s", ns_name, iname);
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *rawval = Getattr(n, "rawval");
|
||||
String *value = rawval ? rawval : Getattr(n, "value");
|
||||
|
|
@ -666,7 +690,7 @@ public:
|
|||
|
||||
if (!addSymbol(iname, n))
|
||||
return SWIG_ERROR;
|
||||
if (nspace)
|
||||
if (namespace_option)
|
||||
Setattr(n, "sym:name", nsname);
|
||||
|
||||
/* Special hook for member pointer */
|
||||
|
|
@ -771,10 +795,7 @@ public:
|
|||
String *wrap_class = NewStringf("&_wrap_class_%s", mangled_classname);
|
||||
SwigType_remember_clientdata(t, wrap_class);
|
||||
|
||||
// t = Copy(Getattr(n,"classtype"));
|
||||
// SwigType_add_pointer(t);
|
||||
|
||||
String *rt = Copy(Getattr(n, "classtype"));
|
||||
String *rt = Copy(getClassType());
|
||||
SwigType_add_pointer(rt);
|
||||
|
||||
// Register the class structure with the type checker
|
||||
|
|
@ -857,7 +878,7 @@ public:
|
|||
Printv(ptrclass, attributes, NIL);
|
||||
|
||||
// base class swig_getset was being called for complex inheritance trees
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
|
||||
Printv(ptrclass, " protected method ", class_name, "_swig_getset {var name1 name2 op} {\n", NIL);
|
||||
|
||||
|
|
@ -923,13 +944,13 @@ public:
|
|||
Printv(f_shadow, " constructor { } {\n", NIL);
|
||||
Printv(f_shadow, " # This constructor will fail if called directly\n", NIL);
|
||||
Printv(f_shadow, " if { [info class] == \"::", class_name, "\" } {\n", NIL);
|
||||
Printv(f_shadow, " error \"No constructor for class ", class_name, "\"\n", NIL);
|
||||
Printv(f_shadow, " error \"No constructor for class ", class_name, (Getattr(n, "abstract") ? " - class is abstract" : ""), "\"\n", NIL);
|
||||
Printv(f_shadow, " }\n", NIL);
|
||||
Printv(f_shadow, " }\n", NIL);
|
||||
}
|
||||
|
||||
Printv(f_shadow, "}\n\n", NIL);
|
||||
};
|
||||
}
|
||||
|
||||
Printv(f_wrappers, "static swig_class *swig_", mangled_classname, "_bases[] = {", base_class, "0};\n", NIL);
|
||||
Printv(f_wrappers, "static const char * swig_", mangled_classname, "_base_names[] = {", base_class_names, "0};\n", NIL);
|
||||
|
|
@ -939,7 +960,7 @@ public:
|
|||
Printv(f_wrappers, "static swig_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
|
||||
|
||||
if (have_constructor) {
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(constructor_name)));
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
Delete(constructor_name);
|
||||
constructor_name = 0;
|
||||
} else {
|
||||
|
|
@ -977,7 +998,7 @@ public:
|
|||
Language::memberfunctionHandler(n);
|
||||
|
||||
realname = iname ? iname : name;
|
||||
rname = Swig_name_wrapper(Swig_name_member(class_name, realname));
|
||||
rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
Printv(methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL);
|
||||
}
|
||||
|
|
@ -1010,7 +1031,7 @@ public:
|
|||
|
||||
if (Len(dv) > 0) {
|
||||
String *defval = NewString(dv);
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Insert(defval, 0, "::");
|
||||
Insert(defval, 0, ns_name);
|
||||
}
|
||||
|
|
@ -1028,7 +1049,7 @@ public:
|
|||
}
|
||||
Printv(imethods, "] ", NIL);
|
||||
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Printv(imethods, "{ ", ns_name, "::", class_name, "_", realname, " $swigobj", NIL);
|
||||
} else {
|
||||
Printv(imethods, "{ ", class_name, "_", realname, " $swigobj", NIL);
|
||||
|
|
@ -1070,11 +1091,11 @@ public:
|
|||
|
||||
Language::membervariableHandler(n);
|
||||
Printv(attr_tab, tab4, "{ \"-", symname, "\",", NIL);
|
||||
rname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
|
||||
rname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
Printv(attr_tab, rname, ", ", NIL);
|
||||
Delete(rname);
|
||||
if (!GetFlag(n, "feature:immutable")) {
|
||||
rname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
|
||||
rname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
Printv(attr_tab, rname, "},\n", NIL);
|
||||
Delete(rname);
|
||||
} else {
|
||||
|
|
@ -1156,7 +1177,7 @@ public:
|
|||
// Call to constructor wrapper and parent Ptr class
|
||||
// [BRE] add -namespace/-prefix support
|
||||
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Printv(constructor, " ", realname, "Ptr::constructor [", ns_name, "::new_", realname, NIL);
|
||||
} else {
|
||||
Printv(constructor, " ", realname, "Ptr::constructor [new_", realname, NIL);
|
||||
|
|
@ -1223,7 +1244,7 @@ public:
|
|||
if (!temp)
|
||||
temp = NewString("");
|
||||
Clear(temp);
|
||||
if (nspace) {
|
||||
if (namespace_option) {
|
||||
Printf(temp, "%s::%s ", ns_name, iname);
|
||||
} else {
|
||||
Printf(temp, "%s ", iname);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* typepass.cxx
|
||||
*
|
||||
|
|
@ -32,6 +36,7 @@ class TypePass:private Dispatcher {
|
|||
Node *module;
|
||||
int importmode;
|
||||
String *nsname;
|
||||
String *nssymname;
|
||||
Hash *classhash;
|
||||
List *normalize;
|
||||
|
||||
|
|
@ -170,10 +175,10 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
}
|
||||
if (Strcmp(nodeType(bcls), "classforward") != 0) {
|
||||
Swig_error(Getfile(cls), Getline(cls), "'%s' does not have a valid base class.\n", Getattr(cls, "name"));
|
||||
Swig_error(Getfile(bcls), Getline(bcls), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
|
||||
Swig_error(Getfile(bname), Getline(bname), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
|
||||
Swig_error(Getfile(bcls), Getline(bcls), "See definition of '%s'.\n", SwigType_namestr(bname));
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(cls), Getline(cls), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bname), Getline(bname), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bcls), Getline(bcls), "Only forward declaration '%s' was found.\n", SwigType_namestr(bname));
|
||||
clsforward = 1;
|
||||
}
|
||||
|
|
@ -184,7 +189,7 @@ class TypePass:private Dispatcher {
|
|||
ilist = alist = NewList();
|
||||
Append(ilist, bcls);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Base class '%s' undefined.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "'%s' must be defined before it is used as a base class.\n", SwigType_namestr(bname));
|
||||
}
|
||||
}
|
||||
|
|
@ -197,10 +202,9 @@ class TypePass:private Dispatcher {
|
|||
if (!bcls) {
|
||||
if (!clsforward) {
|
||||
if (ispublic && !Getmeta(bname, "already_warned")) {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
|
||||
if (Strchr(bname, '<')) {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Maybe you forgot to instantiate '%s' using %%template.\n",
|
||||
SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Maybe you forgot to instantiate '%s' using %%template.\n", SwigType_namestr(bname));
|
||||
}
|
||||
Setmeta(bname, "already_warned", "1");
|
||||
}
|
||||
|
|
@ -226,6 +230,42 @@ class TypePass:private Dispatcher {
|
|||
Node *bclass = n; /* Getattr(n,"class"); */
|
||||
Hash *scopes = Getattr(bclass, "typescope");
|
||||
SwigType_inherit(clsname, bname, cast, 0);
|
||||
String *smartptr = Getattr(first, "feature:smartptr");
|
||||
if (smartptr) {
|
||||
SwigType *smart = 0;
|
||||
SwigType *spt = Swig_cparse_type(smartptr);
|
||||
if (spt) {
|
||||
smart = SwigType_typedef_resolve_all(spt);
|
||||
Delete(spt);
|
||||
/* Record a (fake) inheritance relationship between smart pointer
|
||||
and smart pointer to base class, so that smart pointer upcasts
|
||||
are automatically generated. */
|
||||
SwigType *bsmart = Copy(smart);
|
||||
SwigType *rclsname = SwigType_typedef_resolve_all(clsname);
|
||||
SwigType *rbname = SwigType_typedef_resolve_all(bname);
|
||||
Replaceall(bsmart, rclsname, rbname);
|
||||
Delete(rclsname);
|
||||
Delete(rbname);
|
||||
String *smartnamestr = SwigType_namestr(smart);
|
||||
String *bsmartnamestr = SwigType_namestr(bsmart);
|
||||
/* construct casting code */
|
||||
String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr);
|
||||
Delete(bsmartnamestr);
|
||||
Delete(smartnamestr);
|
||||
/* setup inheritance relationship between smart pointer templates */
|
||||
SwigType_inherit(smart, bsmart, 0, convcode);
|
||||
if (!GetFlag(bclass, "feature:smartptr"))
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name")));
|
||||
Delete(convcode);
|
||||
Delete(bsmart);
|
||||
Delete(smart);
|
||||
} else {
|
||||
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname));
|
||||
}
|
||||
} else {
|
||||
if (GetFlag(bclass, "feature:smartptr"))
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name")));
|
||||
}
|
||||
if (!importmode) {
|
||||
String *btype = Copy(bname);
|
||||
SwigType_add_pointer(btype);
|
||||
|
|
@ -239,7 +279,7 @@ class TypePass:private Dispatcher {
|
|||
Symtab *st = Getattr(cls, "symtab");
|
||||
Symtab *bst = Getattr(bclass, "symtab");
|
||||
if (st == bst) {
|
||||
Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", Getattr(cls, "name"));
|
||||
Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", SwigType_namestr(Getattr(cls, "name")));
|
||||
continue;
|
||||
}
|
||||
Symtab *s = Swig_symbol_current();
|
||||
|
|
@ -292,6 +332,7 @@ class TypePass:private Dispatcher {
|
|||
inclass = 0;
|
||||
normalize = 0;
|
||||
nsname = 0;
|
||||
nssymname = 0;
|
||||
classhash = Getattr(n, "classes");
|
||||
emit_children(n);
|
||||
normalize_list();
|
||||
|
|
@ -358,20 +399,27 @@ class TypePass:private Dispatcher {
|
|||
String *nname = 0;
|
||||
String *fname = 0;
|
||||
String *scopename = 0;
|
||||
String *template_default_expanded = 0;
|
||||
|
||||
normalize = NewList();
|
||||
|
||||
if (name) {
|
||||
if (SwigType_istemplate(name)) {
|
||||
// We need to fully resolve the name to make templates work correctly */
|
||||
// We need to fully resolve the name and expand default template parameters to make templates work correctly */
|
||||
Node *cn;
|
||||
fname = SwigType_typedef_resolve_all(name);
|
||||
if (Strcmp(fname, name) != 0 && (cn = Swig_symbol_clookup_local(fname, 0))) {
|
||||
SwigType *resolved_name = SwigType_typedef_resolve_all(name);
|
||||
SwigType *deftype_name = Swig_symbol_template_deftype(resolved_name, 0);
|
||||
fname = Copy(resolved_name);
|
||||
if (!Equal(resolved_name, deftype_name))
|
||||
template_default_expanded = Copy(deftype_name);
|
||||
if (!Equal(fname, name) && (cn = Swig_symbol_clookup_local(fname, 0))) {
|
||||
if ((n == cn)
|
||||
|| (Strcmp(nodeType(cn), "template") == 0)
|
||||
|| (Getattr(cn, "feature:onlychildren") != 0)
|
||||
|| (Getattr(n, "feature:onlychildren") != 0)) {
|
||||
Swig_symbol_cadd(fname, n);
|
||||
if (template_default_expanded)
|
||||
Swig_symbol_cadd(template_default_expanded, n);
|
||||
SwigType_typedef_class(fname);
|
||||
scopename = Copy(fname);
|
||||
} else {
|
||||
|
|
@ -384,6 +432,8 @@ class TypePass:private Dispatcher {
|
|||
SwigType_typedef_class(fname);
|
||||
scopename = Copy(fname);
|
||||
}
|
||||
Delete(deftype_name);
|
||||
Delete(resolved_name);
|
||||
} else {
|
||||
if ((CPlusPlus) || (unnamed)) {
|
||||
SwigType_typedef_class(name);
|
||||
|
|
@ -403,7 +453,7 @@ class TypePass:private Dispatcher {
|
|||
SwigType_typedef(unnamed, tdname);
|
||||
}
|
||||
|
||||
if (nsname) {
|
||||
if (nsname && name) {
|
||||
nname = NewStringf("%s::%s", nsname, name);
|
||||
String *tdname = Getattr(n, "tdname");
|
||||
if (tdname) {
|
||||
|
|
@ -411,6 +461,10 @@ class TypePass:private Dispatcher {
|
|||
Setattr(n, "tdname", tdname);
|
||||
}
|
||||
}
|
||||
if (nssymname) {
|
||||
if (GetFlag(n, "feature:nspace"))
|
||||
Setattr(n, "sym:nspace", nssymname);
|
||||
}
|
||||
SwigType_new_scope(scopename);
|
||||
SwigType_attach_symtab(Getattr(n, "symtab"));
|
||||
|
||||
|
|
@ -429,6 +483,13 @@ class TypePass:private Dispatcher {
|
|||
Delete(ts);
|
||||
Setattr(n, "module", module);
|
||||
|
||||
// When a fully qualified templated type with default parameters is used in the parsed code,
|
||||
// the following additional symbols and scopes are needed for successful lookups
|
||||
if (template_default_expanded) {
|
||||
Swig_symbol_alias(template_default_expanded, Getattr(n, "symtab"));
|
||||
SwigType_scope_alias(template_default_expanded, Getattr(n, "typescope"));
|
||||
}
|
||||
|
||||
/* Normalize deferred types */
|
||||
{
|
||||
normal_node *nn = new normal_node();
|
||||
|
|
@ -448,6 +509,7 @@ class TypePass:private Dispatcher {
|
|||
Setattr(n, "name", nname);
|
||||
Delete(nname);
|
||||
}
|
||||
Delete(fname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -477,18 +539,10 @@ class TypePass:private Dispatcher {
|
|||
|
||||
virtual int classforwardDeclaration(Node *n) {
|
||||
|
||||
/* Temporary hack. Can't do inside a class because it breaks
|
||||
C nested structure wrapping */
|
||||
|
||||
/* Can't do inside a C struct because it breaks C nested structure wrapping */
|
||||
if ((!inclass) || (CPlusPlus)) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *nname;
|
||||
SwigType_typedef_class(name);
|
||||
if (nsname) {
|
||||
nname = NewStringf("%s::%s", nsname, name);
|
||||
Setattr(n, "name", nname);
|
||||
}
|
||||
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -531,7 +585,9 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
}
|
||||
String *oldnsname = nsname;
|
||||
String *oldnssymname = nssymname;
|
||||
nsname = Swig_symbol_qualified(Getattr(n, "symtab"));
|
||||
nssymname = Swig_symbol_qualified_language_scopename(Getattr(n, "symtab"));
|
||||
symtab = Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||
emit_children(n);
|
||||
Swig_symbol_setscope(symtab);
|
||||
|
|
@ -553,6 +609,8 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
normalize = olist;
|
||||
|
||||
Delete(nssymname);
|
||||
nssymname = oldnssymname;
|
||||
Delete(nsname);
|
||||
nsname = oldnsname;
|
||||
return SWIG_OK;
|
||||
|
|
@ -730,6 +788,54 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
Setattr(n, "enumtype", enumtype);
|
||||
|
||||
if (nssymname) {
|
||||
if (GetFlag(n, "feature:nspace"))
|
||||
Setattr(n, "sym:nspace", nssymname);
|
||||
}
|
||||
|
||||
// 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") || !Getattr(c, "sym:name")) {
|
||||
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;
|
||||
}
|
||||
|
|
@ -745,21 +851,28 @@ class TypePass:private Dispatcher {
|
|||
value = name;
|
||||
if (Strcmp(value, name) == 0) {
|
||||
String *new_value;
|
||||
if (((nsname) || (inclass)) && cparse_cplusplus) {
|
||||
if ((nsname || inclass) && cparse_cplusplus) {
|
||||
new_value = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value);
|
||||
} else {
|
||||
new_value = NewString(value);
|
||||
}
|
||||
if ((nsname || inclass) && !cparse_cplusplus) {
|
||||
String *cppvalue = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value);
|
||||
Setattr(n, "cppvalue", cppvalue); /* for target languages that always generate C++ code even when wrapping C code */
|
||||
}
|
||||
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;
|
||||
|
|
@ -895,6 +1008,7 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
Node *nn = copyNode(c);
|
||||
Delattr(nn, "access"); // access might be different from the method in the base class
|
||||
Setattr(nn, "access", Getattr(n, "access"));
|
||||
if (!Getattr(nn, "sym:name"))
|
||||
Setattr(nn, "sym:name", symname);
|
||||
|
||||
|
|
@ -957,11 +1071,11 @@ class TypePass:private Dispatcher {
|
|||
* which is hacked. */
|
||||
if (Getattr(n, "sym:overloaded"))
|
||||
{
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
show_overloaded(n);
|
||||
#endif
|
||||
int cnt = 0;
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
Node *debugnode = n;
|
||||
show_overloaded(n);
|
||||
#endif
|
||||
if (!firstChild(n)) {
|
||||
// Remove from overloaded list ('using' node does not actually end up adding in any methods)
|
||||
Node *ps = Getattr(n, "sym:previousSibling");
|
||||
|
|
@ -1008,14 +1122,16 @@ show_overloaded(n);
|
|||
Setattr(ns, "sym:previousSibling", pp);
|
||||
Setattr(pp, "sym:nextSibling", ns);
|
||||
}
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
debugnode = firstoverloaded;
|
||||
#endif
|
||||
}
|
||||
Delattr(n, "sym:previousSibling");
|
||||
Delattr(n, "sym:nextSibling");
|
||||
Delattr(n, "sym:overloaded");
|
||||
Delattr(n, "sym:overname");
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
show_overloaded(debugnode);
|
||||
show_overloaded(debugnode);
|
||||
#endif
|
||||
clean_overloaded(n); // Needed?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* uffi.cxx
|
||||
*
|
||||
|
|
@ -13,6 +17,17 @@ char cvsroot_uffi_cxx[] = "$Id$";
|
|||
|
||||
#include "swigmod.h"
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
UFFI Options (available with -uffi)\n\
|
||||
-identifier-converter <type or funcname> - \n\
|
||||
Specifies the type of conversion to do on C identifiers\n\
|
||||
to convert them to symbols. There are two built-in\n\
|
||||
converters: 'null' and 'lispify'. The default is\n\
|
||||
'null'. If you supply a name other than one of the\n\
|
||||
built-ins, then a function by that name will be\n\
|
||||
called to convert identifiers to symbols.\n\
|
||||
";
|
||||
|
||||
class UFFI:public Language {
|
||||
public:
|
||||
|
||||
|
|
@ -26,7 +41,6 @@ public:
|
|||
};
|
||||
|
||||
static File *f_cl = 0;
|
||||
static File *f_null = 0;
|
||||
|
||||
static struct {
|
||||
int count;
|
||||
|
|
@ -132,11 +146,17 @@ static void add_defined_foreign_type(String *type) {
|
|||
}
|
||||
|
||||
|
||||
static String *get_ffi_type(SwigType *ty, const String_or_char *name) {
|
||||
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
|
||||
if (typemap) {
|
||||
String *typespec = Getattr(typemap, "code");
|
||||
return NewString(typespec);
|
||||
static String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", ty);
|
||||
Setattr(node, "name", name);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("ffitype", node, "", 0);
|
||||
Delete(node);
|
||||
|
||||
if (tm) {
|
||||
return NewString(tm);
|
||||
} else {
|
||||
SwigType *tr = SwigType_typedef_resolve_all(ty);
|
||||
char *type_reduced = Char(tr);
|
||||
|
|
@ -168,19 +188,22 @@ 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) {
|
||||
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
|
||||
if (typemap) {
|
||||
String *typespec = Getattr(typemap, "code");
|
||||
return NewString(typespec);
|
||||
} else {
|
||||
return NewString("");
|
||||
}
|
||||
static String *get_lisp_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", ty);
|
||||
Setattr(node, "name", name);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup("lisptype", node, "", 0);
|
||||
Delete(node);
|
||||
|
||||
return tm ? NewString(tm) : NewString("");
|
||||
}
|
||||
|
||||
void UFFI::main(int argc, char *argv[]) {
|
||||
int i;
|
||||
|
||||
Preprocessor_define("SWIGUFFI 1", 0);
|
||||
SWIG_library_directory("uffi");
|
||||
SWIG_config_file("uffi.swg");
|
||||
|
||||
|
|
@ -210,14 +233,7 @@ void UFFI::main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
if (!strcmp(argv[i], "-help")) {
|
||||
fprintf(stdout, "UFFI Options (available with -uffi)\n");
|
||||
fprintf(stdout,
|
||||
" -identifier-converter <type or funcname>\n"
|
||||
"\tSpecifies the type of conversion to do on C identifiers to convert\n"
|
||||
"\tthem to symbols. There are two built-in converters: 'null' and\n"
|
||||
"\t 'lispify'. The default is 'null'. If you supply a name other\n"
|
||||
"\tthan one of the built-ins, then a function by that name will be\n"
|
||||
"\tcalled to convert identifiers to symbols.\n");
|
||||
Printf(stdout, "%s\n", usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -225,31 +241,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);
|
||||
|
||||
|
|
@ -267,7 +278,8 @@ int UFFI::functionWrapper(Node *n) {
|
|||
String *funcname = Getattr(n, "sym:name");
|
||||
ParmList *pl = Getattr(n, "parms");
|
||||
Parm *p;
|
||||
int argnum = 0, first = 1, varargs = 0;
|
||||
int argnum = 0, first = 1;
|
||||
// int varargs = 0;
|
||||
|
||||
//Language::functionWrapper(n);
|
||||
|
||||
|
|
@ -280,13 +292,13 @@ int UFFI::functionWrapper(Node *n) {
|
|||
Printf(f_cl, ":void");
|
||||
} else if (any_varargs(pl)) {
|
||||
Printf(f_cl, "#| varargs |#");
|
||||
varargs = 1;
|
||||
// varargs = 1;
|
||||
} else {
|
||||
for (p = pl; p; p = nextSibling(p), argnum++) {
|
||||
String *argname = Getattr(p, "name");
|
||||
SwigType *argtype = Getattr(p, "type");
|
||||
String *ffitype = get_ffi_type(argtype, argname);
|
||||
String *lisptype = get_lisp_type(argtype, argname);
|
||||
String *ffitype = get_ffi_type(n, argtype, argname);
|
||||
String *lisptype = get_lisp_type(n, argtype, argname);
|
||||
int tempargname = 0;
|
||||
|
||||
if (!argname) {
|
||||
|
|
@ -312,7 +324,7 @@ int UFFI::functionWrapper(Node *n) {
|
|||
//" :strings-convert t\n"
|
||||
//" :call-direct %s\n"
|
||||
//" :optimize-for-space t"
|
||||
")\n", get_ffi_type(Getattr(n, "type"), "result")
|
||||
")\n", get_ffi_type(n, Getattr(n, "type"), Swig_cresult_name())
|
||||
//,varargs ? "nil" : "t"
|
||||
);
|
||||
|
||||
|
|
@ -366,7 +378,7 @@ int UFFI::classHandler(Node *n) {
|
|||
|
||||
|
||||
/* Printf(stdout, "Converting %s in %s\n", type, name); */
|
||||
lisp_type = get_ffi_type(type, Getattr(c, "sym:name"));
|
||||
lisp_type = get_ffi_type(n, type, Getattr(c, "sym:name"));
|
||||
|
||||
Printf(f_cl, " (#.(%s \"%s\" :type :slot) %s)\n", identifier_converter, Getattr(c, "sym:name"), lisp_type);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* utils.cxx
|
||||
*
|
||||
|
|
@ -53,7 +57,12 @@ int is_member_director(Node *member) {
|
|||
int is_non_virtual_protected_access(Node *n) {
|
||||
int result = 0;
|
||||
if (Swig_director_mode() && Swig_director_protected_mode() && Swig_all_protected_mode() && is_protected(n) && !checkAttribute(n, "storage", "virtual")) {
|
||||
if (is_member_director_helper(Getattr(n, "parentNode"), n))
|
||||
Node *parentNode = Getattr(n, "parentNode");
|
||||
// When vtable is empty, the director class does not get emitted, so a check for an empty vtable should be done.
|
||||
// However, vtable is set in Language and so is not yet set when methods in Typepass call clean_overloaded()
|
||||
// which calls is_non_virtual_protected_access. So commented out below.
|
||||
// Moving the director vtable creation into into Typepass should solve this problem.
|
||||
if (is_member_director_helper(parentNode, n) /* && Getattr(parentNode, "vtable")*/)
|
||||
result = 1;
|
||||
}
|
||||
return result;
|
||||
|
|
@ -96,3 +105,116 @@ void clean_overloaded(Node *n) {
|
|||
Delattr(n, "sym:overloaded");
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_set_max_hash_expand()
|
||||
*
|
||||
* Controls how many Hash objects are displayed when displaying nested Hash objects.
|
||||
* Makes DohSetMaxHashExpand an externally callable function (for debugger).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_set_max_hash_expand(int count) {
|
||||
SetMaxHashExpand(count);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_get_max_hash_expand()
|
||||
*
|
||||
* Returns how many Hash objects are displayed when displaying nested Hash objects.
|
||||
* Makes DohGetMaxHashExpand an externally callable function (for debugger).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_get_max_hash_expand() {
|
||||
return GetMaxHashExpand();
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_doh_string()
|
||||
*
|
||||
* DOH version of Swig_to_string()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *Swig_to_doh_string(DOH *object, int count) {
|
||||
int old_count = Swig_get_max_hash_expand();
|
||||
if (count >= 0)
|
||||
Swig_set_max_hash_expand(count);
|
||||
|
||||
String *debug_string = object ? NewStringf("%s", object) : NewString("NULL");
|
||||
|
||||
Swig_set_max_hash_expand(old_count);
|
||||
return debug_string;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_doh_string_with_location()
|
||||
*
|
||||
* DOH version of Swig_to_string_with_location()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *Swig_to_doh_string_with_location(DOH *object, int count) {
|
||||
int old_count = Swig_get_max_hash_expand();
|
||||
if (count >= 0)
|
||||
Swig_set_max_hash_expand(count);
|
||||
|
||||
String *debug_string = Swig_stringify_with_location(object);
|
||||
|
||||
Swig_set_max_hash_expand(old_count);
|
||||
return debug_string;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_string()
|
||||
*
|
||||
* Swig debug - return C string representation of any DOH type.
|
||||
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
|
||||
* Note: leaks memory.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const char *Swig_to_string(DOH *object, int count) {
|
||||
return Char(Swig_to_doh_string(object, count));
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_string_with_location()
|
||||
*
|
||||
* Swig debug - return C string representation of any DOH type, within [] brackets
|
||||
* for Hash and List types, prefixed by line and file information.
|
||||
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
|
||||
* Note: leaks memory.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const char *Swig_to_string_with_location(DOH *object, int count) {
|
||||
return Char(Swig_to_doh_string_with_location(object, count));
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_print()
|
||||
*
|
||||
* Swig debug - display string representation of any DOH type.
|
||||
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_print(DOH *object, int count) {
|
||||
String *output = Swig_to_doh_string(object, count);
|
||||
Printf(stdout, "%s\n", output);
|
||||
Delete(output);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_string_with_location()
|
||||
*
|
||||
* Swig debug - display string representation of any DOH type, within [] brackets
|
||||
* for Hash and List types, prefixed by line and file information.
|
||||
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_print_with_location(DOH *object, int count) {
|
||||
String *output = Swig_to_doh_string_with_location(object, count);
|
||||
Printf(stdout, "%s\n", output);
|
||||
Delete(output);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* xml.cxx
|
||||
*
|
||||
|
|
@ -47,7 +51,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 +86,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);
|
||||
|
|
@ -140,6 +144,8 @@ public:
|
|||
Xml_print_kwargs(Getattr(obj, k));
|
||||
} else if (Cmp(k, "parms") == 0 || Cmp(k, "pattern") == 0) {
|
||||
Xml_print_parmlist(Getattr(obj, k));
|
||||
} else if (Cmp(k, "catchlist") == 0) {
|
||||
Xml_print_parmlist(Getattr(obj, k), "catchlist");
|
||||
} else {
|
||||
DOH *o;
|
||||
print_indent(0);
|
||||
|
|
@ -194,10 +200,10 @@ public:
|
|||
}
|
||||
|
||||
|
||||
void Xml_print_parmlist(ParmList *p) {
|
||||
void Xml_print_parmlist(ParmList *p, const char* markup = "parmlist") {
|
||||
|
||||
print_indent(0);
|
||||
Printf(out, "<parmlist id=\"%ld\" addr=\"%x\" >\n", ++id, p);
|
||||
Printf(out, "<%s id=\"%ld\" addr=\"%x\" >\n", markup, ++id, p);
|
||||
indent_level += 4;
|
||||
while (p) {
|
||||
print_indent(0);
|
||||
|
|
@ -209,7 +215,7 @@ public:
|
|||
}
|
||||
indent_level -= 4;
|
||||
print_indent(0);
|
||||
Printf(out, "</parmlist >\n");
|
||||
Printf(out, "</%s >\n", markup);
|
||||
}
|
||||
|
||||
void Xml_print_baselist(List *p) {
|
||||
|
|
@ -301,7 +307,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);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* expr.c
|
||||
*
|
||||
|
|
@ -294,16 +298,16 @@ int Preprocessor_expr(DOH *s, int *error) {
|
|||
stack[sp++].op = EXPR_OP;
|
||||
stack[sp].op = EXPR_TOP;
|
||||
stack[sp].svalue = 0;
|
||||
} else if ((token == SWIG_TOKEN_LPAREN)) {
|
||||
} else if (token == SWIG_TOKEN_LPAREN) {
|
||||
stack[sp++].op = EXPR_GROUP;
|
||||
stack[sp].op = EXPR_TOP;
|
||||
stack[sp].value = 0;
|
||||
stack[sp].svalue = 0;
|
||||
} else if (token == SWIG_TOKEN_ENDLINE) {
|
||||
} else if ((token == SWIG_TOKEN_STRING)) {
|
||||
} else if (token == SWIG_TOKEN_STRING) {
|
||||
stack[sp].svalue = NewString(Scanner_text(scan));
|
||||
stack[sp].op = EXPR_VALUE;
|
||||
} else if ((token == SWIG_TOKEN_ID)) {
|
||||
} else if (token == SWIG_TOKEN_ID) {
|
||||
stack[sp].value = 0;
|
||||
stack[sp].svalue = 0;
|
||||
stack[sp].op = EXPR_VALUE;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* preprocessor.h
|
||||
*
|
||||
* SWIG preprocessor module.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef SWIG_PREPROCESSOR_H_
|
||||
#define SWIG_PREPROCESSOR_H_
|
||||
|
||||
|
|
@ -19,8 +21,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);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* cwrap.c
|
||||
*
|
||||
|
|
@ -13,6 +17,7 @@ char cvsroot_cwrap_c[] = "$Id$";
|
|||
#include "swig.h"
|
||||
|
||||
extern int cparse_cplusplus;
|
||||
static const char *cresult_variable_name = "result";
|
||||
|
||||
static Parm *nonvoid_parms(Parm *p) {
|
||||
if (p) {
|
||||
|
|
@ -24,7 +29,28 @@ static Parm *nonvoid_parms(Parm *p) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_parm_name()
|
||||
* Swig_cresult_name_set()
|
||||
*
|
||||
* Change the name of the variable used to hold the return value from C/C++ wrapper functions
|
||||
* from the default "result".
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_cresult_name_set(const char *new_name) {
|
||||
cresult_variable_name = new_name;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_cresult_name()
|
||||
*
|
||||
* Get the name of the variable used to hold the return value from C/C++ wrapper functions
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const char *Swig_cresult_name(void) {
|
||||
return cresult_variable_name;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_cparm_name()
|
||||
*
|
||||
* Generates a name for the ith argument in an argument list
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -45,7 +71,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 +173,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 +189,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);
|
||||
|
|
@ -195,7 +221,11 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
|
|||
String *type = Getattr(p, "type");
|
||||
/* default values only emitted if in compact default args mode */
|
||||
String *pvalue = (compactdefargs) ? Getattr(p, "value") : 0;
|
||||
SwigType *altty = SwigType_alttype(type, 0);
|
||||
|
||||
/* When using compactdefaultargs, the code generated initialises a variable via a constructor call that accepts the
|
||||
* default value as a parameter. The default constructor is not called and therefore SwigValueWrapper is not needed. */
|
||||
SwigType *altty = pvalue ? 0 : SwigType_alttype(type, 0);
|
||||
|
||||
int tycode = SwigType_type(type);
|
||||
if (tycode == T_REFERENCE) {
|
||||
if (pvalue) {
|
||||
|
|
@ -208,7 +238,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
|
|||
SwigType_del_reference(tvalue);
|
||||
tycode = SwigType_type(tvalue);
|
||||
if (tycode != T_USER) {
|
||||
/* plain primitive type, we copy the the def value */
|
||||
/* plain primitive type, we copy the def value */
|
||||
String *lstr = SwigType_lstr(tvalue, defname);
|
||||
defvalue = NewStringf("%s = %s", lstr, qvalue);
|
||||
Delete(lstr);
|
||||
|
|
@ -251,7 +281,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 +290,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 +319,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 +332,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 +399,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 +491,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 +510,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;
|
||||
|
|
@ -513,7 +536,8 @@ String *Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int
|
|||
pname = Swig_cparm_name(p, i);
|
||||
i++;
|
||||
} else {
|
||||
if ((pname = Getattr(p, "value")))
|
||||
pname = Getattr(p, "value");
|
||||
if (pname)
|
||||
pname = Copy(pname);
|
||||
else
|
||||
pname = Copy(Getattr(p, "name"));
|
||||
|
|
@ -531,20 +555,20 @@ 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);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_rflag_search()
|
||||
* recursive_flag_search()
|
||||
*
|
||||
* This function searches for the class attribute 'attr' in the class
|
||||
* 'n' or recursively in its bases.
|
||||
|
|
@ -565,7 +589,7 @@ String *Swig_cppconstructor_director_call(String_or_char *name, ParmList *parms)
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* #define SWIG_FAST_REC_SEARCH 1 */
|
||||
String *Swig_rflag_search(Node *n, const String *attr, const String *noattr) {
|
||||
static String *recursive_flag_search(Node *n, const String *attr, const String *noattr) {
|
||||
String *f = 0;
|
||||
n = Swig_methodclass(n);
|
||||
if (GetFlag(n, noattr)) {
|
||||
|
|
@ -579,7 +603,7 @@ String *Swig_rflag_search(Node *n, const String *attr, const String *noattr) {
|
|||
if (bl) {
|
||||
Iterator bi;
|
||||
for (bi = First(bl); bi.item; bi = Next(bi)) {
|
||||
f = Swig_rflag_search(bi.item, attr, noattr);
|
||||
f = recursive_flag_search(bi.item, attr, noattr);
|
||||
if (f) {
|
||||
#ifdef SWIG_FAST_REC_SEARCH
|
||||
SetFlagAttr(n, attr, f);
|
||||
|
|
@ -598,12 +622,11 @@ String *Swig_rflag_search(Node *n, const String *attr, const String *noattr) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_unref_call()
|
||||
*
|
||||
* find the unref call, if any.
|
||||
* Find the "feature:unref" call, if any.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_unref_call(Node *n) {
|
||||
Node *cn = Swig_methodclass(n);
|
||||
String *unref = Swig_rflag_search(cn, "feature:unref", "feature:nounref");
|
||||
String *unref = recursive_flag_search(n, "feature:unref", "feature:nounref");
|
||||
if (unref) {
|
||||
String *pname = Swig_cparm_name(0, 0);
|
||||
unref = NewString(unref);
|
||||
|
|
@ -617,12 +640,11 @@ String *Swig_unref_call(Node *n) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_ref_call()
|
||||
*
|
||||
* find the ref call, if any.
|
||||
* Find the "feature:ref" call, if any.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_ref_call(Node *n, const String *lname) {
|
||||
Node *cn = Swig_methodclass(n);
|
||||
String *ref = Swig_rflag_search(cn, "feature:ref", "feature:noref");
|
||||
String *ref = recursive_flag_search(n, "feature:ref", "feature:noref");
|
||||
if (ref) {
|
||||
ref = NewString(ref);
|
||||
Replaceall(ref, "$this", lname);
|
||||
|
|
@ -640,7 +662,8 @@ String *Swig_ref_call(Node *n, const String *lname) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_cdestructor_call(Node *n) {
|
||||
String *unref = Swig_unref_call(n);
|
||||
Node *cn = Swig_methodclass(n);
|
||||
String *unref = Swig_unref_call(cn);
|
||||
|
||||
if (unref) {
|
||||
return unref;
|
||||
|
|
@ -662,7 +685,8 @@ String *Swig_cdestructor_call(Node *n) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_cppdestructor_call(Node *n) {
|
||||
String *unref = Swig_unref_call(n);
|
||||
Node *cn = Swig_methodclass(n);
|
||||
String *unref = Swig_unref_call(cn);
|
||||
if (unref) {
|
||||
return unref;
|
||||
} else {
|
||||
|
|
@ -682,7 +706,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);
|
||||
|
|
@ -717,7 +741,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);
|
||||
|
|
@ -780,16 +804,35 @@ int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parm
|
|||
* Converts a C++ method node to a function accessor function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director) {
|
||||
String *name, *qualifier;
|
||||
int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director) {
|
||||
String *name;
|
||||
ParmList *parms;
|
||||
SwigType *type;
|
||||
Parm *p;
|
||||
String *self = 0;
|
||||
|
||||
/* If smart pointer, change self dereferencing */
|
||||
int is_smart_pointer_overload = 0;
|
||||
String *qualifier = Getattr(n, "qualifier");
|
||||
|
||||
/* If smart pointer without const overload or mutable method, change self dereferencing */
|
||||
if (flags & CWRAP_SMART_POINTER) {
|
||||
self = NewString("(*this)->");
|
||||
if (flags & CWRAP_SMART_POINTER_OVERLOAD) {
|
||||
if (qualifier && strncmp(Char(qualifier), "q(const)", 8) == 0) {
|
||||
self = NewString("(*(this))->");
|
||||
is_smart_pointer_overload = 1;
|
||||
}
|
||||
else if (Cmp(Getattr(n, "storage"), "static") == 0) {
|
||||
String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname;
|
||||
String *ctname = SwigType_namestr(cname);
|
||||
self = NewStringf("(*(%s const *)this)->", ctname);
|
||||
is_smart_pointer_overload = 1;
|
||||
Delete(ctname);
|
||||
}
|
||||
else {
|
||||
self = NewString("(*this)->");
|
||||
}
|
||||
} else {
|
||||
self = NewString("(*this)->");
|
||||
}
|
||||
}
|
||||
|
||||
/* If node is a member template expansion, we don't allow added code */
|
||||
|
|
@ -797,7 +840,6 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc
|
|||
flags &= ~(CWRAP_EXTEND);
|
||||
|
||||
name = Getattr(n, "name");
|
||||
qualifier = Getattr(n, "qualifier");
|
||||
parms = CopyParmList(nonvoid_parms(Getattr(n, "parms")));
|
||||
|
||||
type = NewString(classname);
|
||||
|
|
@ -805,7 +847,7 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc
|
|||
SwigType_push(type, qualifier);
|
||||
}
|
||||
SwigType_add_pointer(type);
|
||||
p = NewParm(type, "self");
|
||||
p = NewParm(type, "self", n);
|
||||
Setattr(p, "self", "1");
|
||||
Setattr(p, "hidden","1");
|
||||
/*
|
||||
|
|
@ -828,7 +870,7 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc
|
|||
These two lines just transfer the ownership of the 'this' pointer
|
||||
from the input to the output wrapping object.
|
||||
|
||||
This happens in python, but may also happens in other target
|
||||
This happens in python, but may also happen in other target
|
||||
languages.
|
||||
*/
|
||||
if (GetFlag(n, "feature:self:disown")) {
|
||||
|
|
@ -860,7 +902,7 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc
|
|||
}
|
||||
|
||||
call = Swig_cmethod_call(explicitcall_name ? explicitcall_name : name, p, self, explicit_qualifier, director_type);
|
||||
cres = Swig_cresult(Getattr(n, "type"), "result", call);
|
||||
cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call);
|
||||
|
||||
if (pure_virtual && is_director && (flags & CWRAP_DIRECTOR_TWO_CALLS)) {
|
||||
String *qualifier = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), "qname"));
|
||||
|
|
@ -873,7 +915,7 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc
|
|||
/* Create two method calls, one to call the explicit method, the other a normal polymorphic function call */
|
||||
String *cres_both_calls = NewStringf("");
|
||||
String *call_extra = Swig_cmethod_call(name, p, self, 0, director_type);
|
||||
String *cres_extra = Swig_cresult(Getattr(n, "type"), "result", call_extra);
|
||||
String *cres_extra = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call_extra);
|
||||
Printv(cres_both_calls, "if (upcall) {\n", cres, "\n", "} else {", cres_extra, "\n}", NIL);
|
||||
Setattr(n, "wrap:action", cres_both_calls);
|
||||
Delete(cres_extra);
|
||||
|
|
@ -894,7 +936,7 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc
|
|||
String *defaultargs = Getattr(n, "defaultargs");
|
||||
String *code = Getattr(n, "code");
|
||||
String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname;
|
||||
String *membername = Swig_name_member(cname, name);
|
||||
String *membername = Swig_name_member(nspace, cname, name);
|
||||
String *mangled = Swig_name_mangle(membername);
|
||||
int is_smart_pointer = flags & CWRAP_SMART_POINTER;
|
||||
|
||||
|
|
@ -919,10 +961,18 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc
|
|||
|
||||
if (Cmp(Getattr(n, "storage"), "static") != 0) {
|
||||
String *pname = Swig_cparm_name(pp, i);
|
||||
String *ctname = SwigType_namestr(cname);
|
||||
String *fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname);
|
||||
String *ctname = SwigType_namestr(cname);
|
||||
String *fadd = 0;
|
||||
if (is_smart_pointer_overload) {
|
||||
String *nclassname = SwigType_namestr(classname);
|
||||
fadd = NewStringf("(%s const *)((%s const *)%s)->operator ->()", ctname, nclassname, pname);
|
||||
Delete(nclassname);
|
||||
}
|
||||
else {
|
||||
fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname);
|
||||
}
|
||||
Append(func, fadd);
|
||||
Delete(ctname);
|
||||
Delete(ctname);
|
||||
Delete(fadd);
|
||||
Delete(pname);
|
||||
pp = nextSibling(pp);
|
||||
|
|
@ -946,12 +996,12 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc
|
|||
}
|
||||
}
|
||||
Append(func, ")");
|
||||
cres = Swig_cresult(Getattr(n, "type"), "result", func);
|
||||
cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), func);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(cres);
|
||||
} else {
|
||||
String *call = Swig_cfunction_call(mangled, p);
|
||||
String *cres = Swig_cresult(Getattr(n, "type"), "result", call);
|
||||
String *cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(call);
|
||||
Delete(cres);
|
||||
|
|
@ -1007,16 +1057,14 @@ Node *Swig_directormap(Node *module, String *type) {
|
|||
* This function creates a C wrapper for a C constructor function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags) {
|
||||
int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags) {
|
||||
ParmList *parms;
|
||||
Parm *prefix_args;
|
||||
Parm *p;
|
||||
ParmList *directorparms;
|
||||
SwigType *type;
|
||||
Node *classNode;
|
||||
int use_director;
|
||||
|
||||
classNode = Swig_methodclass(n);
|
||||
use_director = Swig_directorclass(n);
|
||||
|
||||
parms = CopyParmList(nonvoid_parms(Getattr(n, "parms")));
|
||||
|
|
@ -1047,7 +1095,7 @@ int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparis
|
|||
String *cres;
|
||||
String *defaultargs = Getattr(n, "defaultargs");
|
||||
String *code = Getattr(n, "code");
|
||||
String *membername = Swig_name_construct(classname);
|
||||
String *membername = Swig_name_construct(nspace, classname);
|
||||
String *mangled = Swig_name_mangle(membername);
|
||||
|
||||
/* Check if the constructor is overloaded. If so, and it has code attached, we append an extra suffix
|
||||
|
|
@ -1063,7 +1111,7 @@ int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparis
|
|||
}
|
||||
|
||||
call = Swig_cfunction_call(mangled, parms);
|
||||
cres = Swig_cresult(type, "result", call);
|
||||
cres = Swig_cresult(type, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
|
|
@ -1094,7 +1142,7 @@ int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparis
|
|||
* implemented in the target language, calls to those methods will
|
||||
* generate Swig::DirectorPureVirtualException exceptions.
|
||||
*/
|
||||
String *cres = Swig_cresult(type, "result", director_call);
|
||||
String *cres = Swig_cresult(type, Swig_cresult_name(), director_call);
|
||||
Append(action, cres);
|
||||
Delete(cres);
|
||||
} else {
|
||||
|
|
@ -1109,11 +1157,11 @@ int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparis
|
|||
Append(action, director_ctor);
|
||||
Replaceall(action, "$comparison", tmp_none_comparison);
|
||||
|
||||
cres = Swig_cresult(type, "result", director_call);
|
||||
cres = Swig_cresult(type, Swig_cresult_name(), director_call);
|
||||
Replaceall(action, "$director_new", cres);
|
||||
Delete(cres);
|
||||
|
||||
cres = Swig_cresult(type, "result", nodirector_call);
|
||||
cres = Swig_cresult(type, Swig_cresult_name(), nodirector_call);
|
||||
Replaceall(action, "$nondirector_new", cres);
|
||||
Delete(cres);
|
||||
}
|
||||
|
|
@ -1123,14 +1171,14 @@ int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparis
|
|||
Delete(directorname);
|
||||
} else {
|
||||
String *call = Swig_cppconstructor_call(classname, parms);
|
||||
String *cres = Swig_cresult(type, "result", call);
|
||||
String *cres = Swig_cresult(type, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
}
|
||||
} else {
|
||||
String *call = Swig_cconstructor_call(classname);
|
||||
String *cres = Swig_cresult(type, "result", call);
|
||||
String *cres = Swig_cresult(type, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
|
|
@ -1151,13 +1199,13 @@ int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparis
|
|||
* This function creates a C wrapper for a destructor function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags) {
|
||||
int Swig_DestructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int cplus, int flags) {
|
||||
SwigType *type;
|
||||
Parm *p;
|
||||
|
||||
type = NewString(classname);
|
||||
SwigType_add_pointer(type);
|
||||
p = NewParm(type, "self");
|
||||
p = NewParm(type, "self", n);
|
||||
Setattr(p, "self", "1");
|
||||
Setattr(p, "hidden", "1");
|
||||
Setattr(p, "wrap:disown", "1");
|
||||
|
|
@ -1168,7 +1216,7 @@ int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags)
|
|||
String *cres;
|
||||
String *call;
|
||||
String *membername, *mangled, *code;
|
||||
membername = Swig_name_destroy(classname);
|
||||
membername = Swig_name_destroy(nspace, classname);
|
||||
mangled = Swig_name_mangle(membername);
|
||||
code = Getattr(n, "code");
|
||||
if (code) {
|
||||
|
|
@ -1217,10 +1265,7 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
SwigType *ty;
|
||||
SwigType *type;
|
||||
SwigType *void_type = NewString("void");
|
||||
String *membername;
|
||||
String *mangled;
|
||||
String *self = 0;
|
||||
String *sname;
|
||||
|
||||
int varcref = flags & CWRAP_NATURAL_VAR;
|
||||
|
||||
|
|
@ -1234,19 +1279,15 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
name = Getattr(n, "name");
|
||||
type = Getattr(n, "type");
|
||||
|
||||
sname = Swig_name_set(name);
|
||||
membername = Swig_name_member(classname, sname);
|
||||
mangled = Swig_name_mangle(membername);
|
||||
|
||||
t = NewString(classname);
|
||||
SwigType_add_pointer(t);
|
||||
parms = NewParm(t, "self");
|
||||
parms = NewParm(t, "self", n);
|
||||
Setattr(parms, "self", "1");
|
||||
Setattr(parms, "hidden","1");
|
||||
Delete(t);
|
||||
|
||||
ty = Swig_wrapped_member_var_type(type, varcref);
|
||||
p = NewParm(ty, name);
|
||||
p = NewParm(ty, name, n);
|
||||
Setattr(parms, "hidden", "1");
|
||||
set_nextSibling(parms, p);
|
||||
|
||||
|
|
@ -1260,6 +1301,11 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
String *call;
|
||||
String *cres;
|
||||
String *code = Getattr(n, "code");
|
||||
|
||||
String *sname = Swig_name_set(0, name);
|
||||
String *membername = Swig_name_member(0, classname, sname);
|
||||
String *mangled = Swig_name_mangle(membername);
|
||||
|
||||
if (code) {
|
||||
/* I don't think this ever gets run - WSF */
|
||||
Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, "self");
|
||||
|
|
@ -1267,8 +1313,12 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
call = Swig_cfunction_call(mangled, parms);
|
||||
cres = NewStringf("%s;", call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(call);
|
||||
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
Delete(mangled);
|
||||
Delete(membername);
|
||||
Delete(sname);
|
||||
} else {
|
||||
String *call = Swig_cmemberset_call(name, type, self, varcref);
|
||||
String *cres = NewStringf("%s;", call);
|
||||
|
|
@ -1281,9 +1331,6 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
Delete(parms);
|
||||
Delete(ty);
|
||||
Delete(void_type);
|
||||
Delete(membername);
|
||||
Delete(sname);
|
||||
Delete(mangled);
|
||||
Delete(self);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1300,10 +1347,7 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
SwigType *t;
|
||||
SwigType *ty;
|
||||
SwigType *type;
|
||||
String *membername;
|
||||
String *mangled;
|
||||
String *self = 0;
|
||||
String *gname;
|
||||
|
||||
int varcref = flags & CWRAP_NATURAL_VAR;
|
||||
|
||||
|
|
@ -1312,6 +1356,10 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
Node *sn = Getattr(n, "cplus:staticbase");
|
||||
String *base = Getattr(sn, "name");
|
||||
self = NewStringf("%s::", base);
|
||||
} else if (flags & CWRAP_SMART_POINTER_OVERLOAD) {
|
||||
String *nclassname = SwigType_namestr(classname);
|
||||
self = NewStringf("(*(%s const *)this)->", nclassname);
|
||||
Delete(nclassname);
|
||||
} else {
|
||||
self = NewString("(*this)->");
|
||||
}
|
||||
|
|
@ -1323,13 +1371,9 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
name = Getattr(n, "name");
|
||||
type = Getattr(n, "type");
|
||||
|
||||
gname = Swig_name_get(name);
|
||||
membername = Swig_name_member(classname, gname);
|
||||
mangled = Swig_name_mangle(membername);
|
||||
|
||||
t = NewString(classname);
|
||||
SwigType_add_pointer(t);
|
||||
parms = NewParm(t, "self");
|
||||
parms = NewParm(t, "self", n);
|
||||
Setattr(parms, "self", "1");
|
||||
Setattr(parms, "hidden","1");
|
||||
Delete(t);
|
||||
|
|
@ -1338,20 +1382,28 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
if (flags & CWRAP_EXTEND) {
|
||||
String *call;
|
||||
String *cres;
|
||||
|
||||
String *code = Getattr(n, "code");
|
||||
|
||||
String *gname = Swig_name_get(0, name);
|
||||
String *membername = Swig_name_member(0, classname, gname);
|
||||
String *mangled = Swig_name_mangle(membername);
|
||||
|
||||
if (code) {
|
||||
/* I don't think this ever gets run - WSF */
|
||||
Swig_add_extension_code(n, mangled, parms, ty, code, cparse_cplusplus, "self");
|
||||
}
|
||||
call = Swig_cfunction_call(mangled, parms);
|
||||
cres = Swig_cresult(ty, "result", call);
|
||||
cres = Swig_cresult(ty, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
Delete(mangled);
|
||||
Delete(membername);
|
||||
Delete(gname);
|
||||
} else {
|
||||
String *call = Swig_cmemberget_call(name, type, self, varcref);
|
||||
String *cres = Swig_cresult(ty, "result", call);
|
||||
String *cres = Swig_cresult(ty, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(call);
|
||||
Delete(cres);
|
||||
|
|
@ -1360,9 +1412,6 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
Setattr(n, "parms", parms);
|
||||
Delete(parms);
|
||||
Delete(ty);
|
||||
Delete(membername);
|
||||
Delete(gname);
|
||||
Delete(mangled);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1385,10 +1434,10 @@ int Swig_VarsetToFunction(Node *n, int flags) {
|
|||
type = Getattr(n, "type");
|
||||
nname = SwigType_namestr(name);
|
||||
ty = Swig_wrapped_var_type(type, varcref);
|
||||
parms = NewParm(ty, name);
|
||||
parms = NewParm(ty, name, n);
|
||||
|
||||
if (flags & CWRAP_EXTEND) {
|
||||
String *sname = Swig_name_set(name);
|
||||
String *sname = Swig_name_set(0, name);
|
||||
String *mangled = Swig_name_mangle(sname);
|
||||
String *call = Swig_cfunction_call(mangled, parms);
|
||||
String *cres = NewStringf("%s;", call);
|
||||
|
|
@ -1442,17 +1491,17 @@ int Swig_VargetToFunction(Node *n, int flags) {
|
|||
ty = Swig_wrapped_var_type(type, varcref);
|
||||
|
||||
if (flags & CWRAP_EXTEND) {
|
||||
String *sname = Swig_name_get(name);
|
||||
String *sname = Swig_name_get(0, name);
|
||||
String *mangled = Swig_name_mangle(sname);
|
||||
call = Swig_cfunction_call(mangled, 0);
|
||||
cres = Swig_cresult(ty, "result", call);
|
||||
cres = Swig_cresult(ty, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(mangled);
|
||||
Delete(sname);
|
||||
} else {
|
||||
String *nname = SwigType_namestr(name);
|
||||
call = Swig_wrapped_var_assign(type, nname, varcref);
|
||||
cres = Swig_cresult(ty, "result", call);
|
||||
cres = Swig_cresult(ty, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(nname);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* deprecate.c
|
||||
*
|
||||
|
|
@ -73,7 +77,7 @@ int ParmList_is_compactdefargs(ParmList *p) {
|
|||
* ParmList_errorstr()
|
||||
*
|
||||
* Generate a prototype string suitable for use in error/warning messages.
|
||||
* This function is aware of hidden parameters.
|
||||
* Similar to ParmList_protostr() but is also aware of hidden parameters.
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
/* Discussion. This function is used to generate error messages, but take
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* error.c
|
||||
*
|
||||
|
|
@ -49,16 +53,18 @@ static char wrn_wnum_fmt[64];
|
|||
static char wrn_nnum_fmt[64];
|
||||
static char err_line_fmt[64];
|
||||
static char err_eof_fmt[64];
|
||||
static char diag_line_fmt[64];
|
||||
static char diag_eof_fmt[64];
|
||||
|
||||
static String *format_filename(const String_or_char *filename);
|
||||
static String *format_filename(const_String_or_char_ptr filename);
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_warning()
|
||||
*
|
||||
* Issue a warning message
|
||||
* Issue a warning message on stderr.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
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;
|
||||
|
|
@ -118,10 +124,10 @@ void Swig_warning(int wnum, const String_or_char *filename, int line, const char
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_error()
|
||||
*
|
||||
* Issue an error message
|
||||
* Issue an error message on stderr.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
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 +176,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;
|
||||
|
|
@ -245,8 +251,8 @@ void Swig_error_msg_format(ErrorMessageFormat format) {
|
|||
by now a switch is used to translated into one. */
|
||||
switch (format) {
|
||||
case EMF_MICROSOFT:
|
||||
fmt_line = "%s(%d)";
|
||||
fmt_eof = "%s(999999)"; /* Is there a special character for EOF? Just use a large number. */
|
||||
fmt_line = "%s(%d) ";
|
||||
fmt_eof = "%s(999999) "; /* Is there a special character for EOF? Just use a large number. */
|
||||
break;
|
||||
case EMF_STANDARD:
|
||||
default:
|
||||
|
|
@ -254,10 +260,12 @@ void Swig_error_msg_format(ErrorMessageFormat format) {
|
|||
fmt_eof = "%s:EOF";
|
||||
}
|
||||
|
||||
sprintf(wrn_wnum_fmt, "%s: %s(%%d): ", fmt_line, warning);
|
||||
sprintf(wrn_wnum_fmt, "%s: %s %%d: ", fmt_line, warning);
|
||||
sprintf(wrn_nnum_fmt, "%s: %s: ", fmt_line, warning);
|
||||
sprintf(err_line_fmt, "%s: %s: ", fmt_line, error);
|
||||
sprintf(err_eof_fmt, "%s: %s: ", fmt_eof, error);
|
||||
sprintf(diag_line_fmt, "%s: ", fmt_line);
|
||||
sprintf(diag_eof_fmt, "%s: ", fmt_eof);
|
||||
|
||||
msg_format = format;
|
||||
init_fmt = 1;
|
||||
|
|
@ -268,10 +276,71 @@ 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, "\\\\", "\\");
|
||||
#endif
|
||||
return formatted_filename;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_stringify_with_location()
|
||||
*
|
||||
* Return a string representation of any DOH object with line and file location
|
||||
* information in the appropriate error message format. The string representation
|
||||
* is enclosed within [] brackets after the line and file information.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_stringify_with_location(DOH *object) {
|
||||
String *str = NewStringEmpty();
|
||||
|
||||
if (!init_fmt)
|
||||
Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
|
||||
|
||||
if (object) {
|
||||
int line = Getline(object);
|
||||
String *formatted_filename = format_filename(Getfile(object));
|
||||
if (line > 0) {
|
||||
Printf(str, diag_line_fmt, formatted_filename, line);
|
||||
} else {
|
||||
Printf(str, diag_eof_fmt, formatted_filename);
|
||||
}
|
||||
if (Len(object) == 0) {
|
||||
Printf(str, "[EMPTY]");
|
||||
} else {
|
||||
Printf(str, "[%s]", object);
|
||||
}
|
||||
Delete(formatted_filename);
|
||||
} else {
|
||||
Printf(str, "[NULL]");
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_diagnostic()
|
||||
*
|
||||
* Issue a diagnostic message on stdout.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
String *formatted_filename = NULL;
|
||||
|
||||
if (!init_fmt)
|
||||
Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
|
||||
|
||||
va_start(ap, fmt);
|
||||
formatted_filename = format_filename(filename);
|
||||
if (line > 0) {
|
||||
Printf(stdout, diag_line_fmt, formatted_filename, line);
|
||||
} else {
|
||||
Printf(stdout, diag_eof_fmt, formatted_filename);
|
||||
}
|
||||
vPrintf(stdout, fmt, ap);
|
||||
va_end(ap);
|
||||
Delete(formatted_filename);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* fragment.c
|
||||
*
|
||||
|
|
@ -56,6 +60,8 @@ void Swig_fragment_register(Node *fragment) {
|
|||
if (kwargs) {
|
||||
Setmeta(ccode, "kwargs", kwargs);
|
||||
}
|
||||
Setfile(ccode, Getfile(fragment));
|
||||
Setline(ccode, Getline(fragment));
|
||||
Setattr(fragments, name, ccode);
|
||||
if (debug)
|
||||
Printf(stdout, "registering fragment %s %s\n", name, section);
|
||||
|
|
@ -138,7 +144,7 @@ void Swig_fragment_emit(Node *n) {
|
|||
if (section) {
|
||||
File *f = Swig_filebyname(section);
|
||||
if (!f) {
|
||||
Swig_error(Getfile(code), Getline(code), "Bad section '%s' for code fragment '%s'\n", section, name);
|
||||
Swig_error(Getfile(code), Getline(code), "Bad section '%s' in %%fragment declaration for code fragment '%s'\n", section, name);
|
||||
} else {
|
||||
if (debug)
|
||||
Printf(stdout, "emitting subfragment %s %s\n", name, section);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* getopt.c
|
||||
*
|
||||
|
|
@ -100,7 +104,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);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* include.c
|
||||
*
|
||||
|
|
@ -17,6 +21,7 @@ static List *directories = 0; /* List of include directories */
|
|||
static String *lastpath = 0; /* Last file that was included */
|
||||
static List *pdirectories = 0; /* List of pushed directories */
|
||||
static int dopush = 1; /* Whether to push directories */
|
||||
static int file_debug = 0;
|
||||
|
||||
/* This functions determine whether to push/pop dirs in the preprocessor */
|
||||
void Swig_set_push_dir(int push) {
|
||||
|
|
@ -33,7 +38,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 +58,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 +78,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 +92,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 +156,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;
|
||||
|
|
@ -168,8 +174,11 @@ static FILE *Swig_open_any(const String_or_char *name, int sysfile) {
|
|||
cname = Char(name);
|
||||
filename = NewString(cname);
|
||||
assert(filename);
|
||||
if (file_debug) {
|
||||
Printf(stdout, " Open: %s\n", 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 +191,20 @@ 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 = 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);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -215,6 +225,8 @@ String *Swig_read_file(FILE *f) {
|
|||
Append(str, buffer);
|
||||
}
|
||||
len = Len(str);
|
||||
/* Add a newline if not present on last line -- the preprocessor seems to
|
||||
* rely on \n and not EOF terminating lines */
|
||||
if (len) {
|
||||
char *cstr = Char(str);
|
||||
if (cstr[len - 1] != '\n') {
|
||||
|
|
@ -230,29 +242,29 @@ 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);
|
||||
fclose(f);
|
||||
Seek(str, 0, SEEK_SET);
|
||||
file = Copy(lastpath);
|
||||
file = Copy(Swig_last_file());
|
||||
Setfile(str, file);
|
||||
Delete(file);
|
||||
Setline(str, 1);
|
||||
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 +274,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 +298,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 +310,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 +322,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 +344,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,13 +358,14 @@ 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;
|
||||
|
||||
strcpy(tmp, Char(filename));
|
||||
if ((c = strrchr(tmp, *delim)))
|
||||
c = strrchr(tmp, *delim);
|
||||
if (c)
|
||||
return c + 1;
|
||||
else
|
||||
return tmp;
|
||||
|
|
@ -363,7 +376,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;
|
||||
|
|
@ -377,3 +390,10 @@ char *Swig_file_dirname(const String_or_char *filename) {
|
|||
*(++c) = 0;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Swig_file_debug()
|
||||
*/
|
||||
void Swig_file_debug_set() {
|
||||
file_debug = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* misc.c
|
||||
*
|
||||
|
|
@ -13,6 +17,15 @@ char cvsroot_misc_c[] = "$Id$";
|
|||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(mode) (((mode) & S_IFDIR) == S_IFDIR)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static char *fake_version = 0;
|
||||
|
||||
|
|
@ -54,7 +67,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,15 +80,29 @@ 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
|
||||
* returned if there aren't any.
|
||||
* Return a new string with C comments stripped from the input string. NULL is
|
||||
* returned if there aren't any comments.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_strip_c_comments(const String *s) {
|
||||
|
|
@ -93,9 +120,10 @@ String *Swig_strip_c_comments(const String *s) {
|
|||
comment_begin = c-1;
|
||||
} else if (comment_begin && !comment_end && *c == '*') {
|
||||
++c;
|
||||
if (*c == '/')
|
||||
if (*c == '/') {
|
||||
comment_end = c;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
++c;
|
||||
}
|
||||
|
|
@ -116,6 +144,133 @@ String *Swig_strip_c_comments(const String *s) {
|
|||
return stripped;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* is_directory()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
static int is_directory(String *directory) {
|
||||
int last = Len(directory) - 1;
|
||||
int statres;
|
||||
struct stat st;
|
||||
char *dir = Char(directory);
|
||||
if (dir[last] == SWIG_FILE_DELIMITER[0]) {
|
||||
/* remove trailing slash - can cause S_ISDIR to fail on Windows, at least */
|
||||
dir[last] = 0;
|
||||
statres = stat(dir, &st);
|
||||
dir[last] = SWIG_FILE_DELIMITER[0];
|
||||
} else {
|
||||
statres = stat(dir, &st);
|
||||
}
|
||||
return (statres == 0 && S_ISDIR(st.st_mode));
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_new_subdirectory()
|
||||
*
|
||||
* Create the subdirectory only if the basedirectory already exists as a directory.
|
||||
* basedirectory can be NULL or empty to indicate current directory.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) {
|
||||
String *error = 0;
|
||||
struct stat st;
|
||||
int current_directory = basedirectory ? (Len(basedirectory) == 0 ? 1 : 0) : 0;
|
||||
|
||||
if (current_directory || is_directory(basedirectory)) {
|
||||
Iterator it;
|
||||
String *dir = basedirectory ? NewString(basedirectory) : NewString("");
|
||||
List *subdirs = Split(subdirectory, SWIG_FILE_DELIMITER[0], INT_MAX);
|
||||
|
||||
for (it = First(subdirs); it.item; it = Next(it)) {
|
||||
int statdir;
|
||||
String *subdirectory = it.item;
|
||||
Printf(dir, "%s", subdirectory);
|
||||
statdir = stat(Char(dir), &st);
|
||||
if (statdir == 0) {
|
||||
Printf(dir, SWIG_FILE_DELIMITER);
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
continue;
|
||||
} else {
|
||||
error = NewStringf("Cannot create directory %s", dir);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
int result = _mkdir(Char(dir));
|
||||
#else
|
||||
int result = mkdir(Char(dir), 0777);
|
||||
#endif
|
||||
Printf(dir, SWIG_FILE_DELIMITER);
|
||||
if (result != 0 && errno != EEXIST) {
|
||||
error = NewStringf("Cannot create directory %s", dir);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error = NewStringf("Cannot create subdirectory %s under the base directory %s. Either the base does not exist as a directory or it is not readable.", subdirectory, basedirectory);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_filename_correct()
|
||||
*
|
||||
* Corrects filename paths by removing duplicate delimeters and on non-unix
|
||||
* systems use the correct delimeter across the whole name.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_filename_correct(String *filename) {
|
||||
int network_path = 0;
|
||||
if (Len(filename) >= 2) {
|
||||
const char *fname = Char(filename);
|
||||
if (fname[0] == '\\' && fname[1] == '\\')
|
||||
network_path = 1;
|
||||
if (fname[0] == '/' && fname[1] == '/')
|
||||
network_path = 1;
|
||||
}
|
||||
#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
|
||||
/* remove all duplicate file name delimiters */
|
||||
while (Replaceall(filename, SWIG_FILE_DELIMITER SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER)) {
|
||||
}
|
||||
/* Network paths can start with a double slash on Windows - unremove the duplicate slash we just removed */
|
||||
if (network_path)
|
||||
Insert(filename, 0, SWIG_FILE_DELIMITER);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_filename_escape()
|
||||
*
|
||||
* Escapes backslashes in filename - for Windows
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_filename_escape(String *filename) {
|
||||
String *adjusted_filename = Copy(filename);
|
||||
Swig_filename_correct(adjusted_filename);
|
||||
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
|
||||
Replaceall(adjusted_filename, "\\", "\\\\");
|
||||
#endif
|
||||
return adjusted_filename;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_filename_unescape()
|
||||
*
|
||||
* Remove double backslash escaping in filename - for Windows
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_filename_unescape(String *filename) {
|
||||
(void)filename;
|
||||
#if defined(_WIN32)
|
||||
Replaceall(filename, "\\\\", "\\");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_escape()
|
||||
|
|
@ -380,7 +535,6 @@ String *Swig_string_schemify(String *s) {
|
|||
return ns;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_typecode()
|
||||
*
|
||||
|
|
@ -604,7 +758,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;
|
||||
|
|
@ -614,7 +768,8 @@ void Swig_scopename_split(String *s, String **rprefix, String **rlast) {
|
|||
*rlast = Copy(s);
|
||||
}
|
||||
|
||||
if ((co = strstr(cc, "operator "))) {
|
||||
co = strstr(cc, "operator ");
|
||||
if (co) {
|
||||
if (co == cc) {
|
||||
*rprefix = 0;
|
||||
*rlast = Copy(s);
|
||||
|
|
@ -657,14 +812,16 @@ 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;
|
||||
char *co = 0;
|
||||
if (!strstr(c, "::"))
|
||||
return 0;
|
||||
if ((co = strstr(cc, "operator "))) {
|
||||
co = strstr(cc, "operator ");
|
||||
|
||||
if (co) {
|
||||
if (co == cc) {
|
||||
return 0;
|
||||
} else {
|
||||
|
|
@ -707,7 +864,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;
|
||||
|
|
@ -715,7 +872,8 @@ String *Swig_scopename_last(String *s) {
|
|||
if (!strstr(c, "::"))
|
||||
return NewString(s);
|
||||
|
||||
if ((co = strstr(cc, "operator "))) {
|
||||
co = strstr(cc, "operator ");
|
||||
if (co) {
|
||||
return NewString(co);
|
||||
}
|
||||
|
||||
|
|
@ -750,13 +908,15 @@ 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;
|
||||
if (!strstr(c, "::"))
|
||||
return 0;
|
||||
if ((co = strstr(c, "operator "))) {
|
||||
|
||||
co = strstr(c, "operator ");
|
||||
if (co) {
|
||||
if (co == c) {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -798,13 +958,15 @@ 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;
|
||||
if (!strstr(c, "::"))
|
||||
return 0;
|
||||
if ((co = strstr(c, "operator "))) {
|
||||
|
||||
co = strstr(c, "operator ");
|
||||
if (co) {
|
||||
if (co == c)
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -837,13 +999,18 @@ String *Swig_scopename_suffix(String *s) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_scopename_check()
|
||||
*
|
||||
* Checks to see if a name is qualified with a scope name
|
||||
* Checks to see if a name is qualified with a scope name, examples:
|
||||
* foo -> 0
|
||||
* ::foo -> 1
|
||||
* foo::bar -> 1
|
||||
* foo< ::bar > -> 0
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_scopename_check(String *s) {
|
||||
int Swig_scopename_check(const String *s) {
|
||||
char *c = Char(s);
|
||||
char *co = 0;
|
||||
if ((co = strstr(c, "operator "))) {
|
||||
char *co = strstr(c, "operator ");
|
||||
|
||||
if (co) {
|
||||
if (co == c)
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -918,112 +1085,163 @@ String *Swig_string_command(String *s) {
|
|||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_rxspencer()
|
||||
* Swig_string_strip()
|
||||
*
|
||||
* Executes a regexp substitution via the RxSpencer library. For example:
|
||||
* Strip given prefix from identifiers
|
||||
*
|
||||
* Printf(stderr,"gsl%(rxspencer:[GSL_.*_][@1])s","GSL_Hello_") -> gslHello
|
||||
* Printf(stderr,"%(strip:[wx])s","wxHello") -> Hello
|
||||
* ----------------------------------------------------------------------------- */
|
||||
#if defined(HAVE_RXSPENCER)
|
||||
#include <sys/types.h>
|
||||
#include <rxspencer/regex.h>
|
||||
#define USE_RXSPENCER
|
||||
#endif
|
||||
|
||||
const char *skip_delim(char pb, char pe, const char *ce) {
|
||||
int end = 0;
|
||||
int lb = 0;
|
||||
while (!end && *ce != '\0') {
|
||||
if (*ce == pb) {
|
||||
++lb;
|
||||
}
|
||||
if (*ce == pe) {
|
||||
if (!lb) {
|
||||
end = 1;
|
||||
--ce;
|
||||
} else {
|
||||
--lb;
|
||||
}
|
||||
}
|
||||
++ce;
|
||||
}
|
||||
return end ? ce : 0;
|
||||
}
|
||||
|
||||
|
||||
#if defined(USE_RXSPENCER)
|
||||
String *Swig_string_rxspencer(String *s) {
|
||||
String *res = 0;
|
||||
if (Len(s)) {
|
||||
String *Swig_string_strip(String *s) {
|
||||
String *ns;
|
||||
if (!Len(s)) {
|
||||
ns = NewString(s);
|
||||
} else {
|
||||
const char *cs = Char(s);
|
||||
const char *cb;
|
||||
const char *ce;
|
||||
if (*cs == '[') {
|
||||
int retval;
|
||||
regex_t compiled;
|
||||
cb = ++cs;
|
||||
ce = skip_delim('[', ']', cb);
|
||||
if (ce) {
|
||||
char bregexp[512];
|
||||
strncpy(bregexp, cb, ce - cb);
|
||||
bregexp[ce - cb] = '\0';
|
||||
++ce;
|
||||
retval = regcomp(&compiled, bregexp, REG_EXTENDED);
|
||||
if (retval == 0) {
|
||||
cs = ce;
|
||||
if (*cs == '[') {
|
||||
cb = ++cs;
|
||||
ce = skip_delim('[', ']', cb);
|
||||
if (ce) {
|
||||
const char *cvalue = ce + 1;
|
||||
int nsub = (int) compiled.re_nsub + 1;
|
||||
regmatch_t *pmatch = (regmatch_t *) malloc(sizeof(regmatch_t) * (nsub));
|
||||
retval = regexec(&compiled, cvalue, nsub, pmatch, 0);
|
||||
if (retval != REG_NOMATCH) {
|
||||
char *spos = 0;
|
||||
res = NewStringWithSize(cb, ce - cb);
|
||||
spos = Strchr(res, '@');
|
||||
while (spos) {
|
||||
char cd = *(++spos);
|
||||
if (isdigit(cd)) {
|
||||
char arg[8];
|
||||
size_t len;
|
||||
int i = cd - '0';
|
||||
sprintf(arg, "@%d", i);
|
||||
if (i < nsub && (len = pmatch[i].rm_eo - pmatch[i].rm_so)) {
|
||||
char value[256];
|
||||
strncpy(value, cvalue + pmatch[i].rm_so, len);
|
||||
value[len] = 0;
|
||||
Replaceall(res, arg, value);
|
||||
} else {
|
||||
Replaceall(res, arg, "");
|
||||
}
|
||||
spos = Strchr(res, '@');
|
||||
} else if (cd == '@') {
|
||||
spos = strchr(spos + 1, '@');
|
||||
}
|
||||
}
|
||||
}
|
||||
free(pmatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
regfree(&compiled);
|
||||
const char *ce = Strchr(cs, ']');
|
||||
if (*cs != '[' || !ce) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!res)
|
||||
res = NewStringEmpty();
|
||||
return res;
|
||||
return ns;
|
||||
}
|
||||
#else
|
||||
String *Swig_string_rxspencer(String *s) {
|
||||
(void) s;
|
||||
return NewStringEmpty();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_PCRE
|
||||
#include <pcre.h>
|
||||
|
||||
static int split_regex_pattern_subst(String *s, String **pattern, String **subst, const char **input)
|
||||
{
|
||||
const char *pats, *pate;
|
||||
const char *subs, *sube;
|
||||
|
||||
/* Locate the search pattern */
|
||||
const char *p = Char(s);
|
||||
if (*p++ != '/') goto err_out;
|
||||
pats = p;
|
||||
p = strchr(p, '/');
|
||||
if (!p) goto err_out;
|
||||
pate = p;
|
||||
|
||||
/* Locate the substitution string */
|
||||
subs = ++p;
|
||||
p = strchr(p, '/');
|
||||
if (!p) goto err_out;
|
||||
sube = p;
|
||||
|
||||
*pattern = NewStringWithSize(pats, pate - pats);
|
||||
*subst = NewStringWithSize(subs, sube - subs);
|
||||
*input = p + 1;
|
||||
return 1;
|
||||
|
||||
err_out:
|
||||
Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
String *replace_captures(int num_captures, const char *input, String *subst, int captures[], String *pattern, String *s)
|
||||
{
|
||||
String *result = NewStringEmpty();
|
||||
const char *p = Char(subst);
|
||||
|
||||
while (*p) {
|
||||
/* Copy part without substitutions */
|
||||
const char *q = strchr(p, '\\');
|
||||
if (!q) {
|
||||
Write(result, p, strlen(p));
|
||||
break;
|
||||
}
|
||||
Write(result, p, q - p);
|
||||
p = q + 1;
|
||||
|
||||
/* Handle substitution */
|
||||
if (*p == '\0') {
|
||||
Putc('\\', result);
|
||||
} else if (isdigit((unsigned char)*p)) {
|
||||
int group = *p++ - '0';
|
||||
if (group < num_captures) {
|
||||
int l = captures[group*2], r = captures[group*2 + 1];
|
||||
if (l != -1) {
|
||||
Write(result, input + l, r - l);
|
||||
}
|
||||
} else {
|
||||
Swig_error("SWIG", Getline(s), "PCRE capture replacement failed while matching \"%s\" using \"%s\" - request for group %d is greater than the number of captures %d.\n",
|
||||
Char(pattern), input, group, num_captures-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_regex()
|
||||
*
|
||||
* Executes a regular expression substitution. For example:
|
||||
*
|
||||
* Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello
|
||||
* ----------------------------------------------------------------------------- */
|
||||
String *Swig_string_regex(String *s) {
|
||||
const int pcre_options = 0;
|
||||
|
||||
String *res = 0;
|
||||
pcre *compiled_pat = 0;
|
||||
const char *pcre_error, *input;
|
||||
int pcre_errorpos;
|
||||
String *pattern = 0, *subst = 0;
|
||||
int captures[30];
|
||||
|
||||
if (split_regex_pattern_subst(s, &pattern, &subst, &input)) {
|
||||
int rc;
|
||||
|
||||
compiled_pat = pcre_compile(
|
||||
Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL);
|
||||
if (!compiled_pat) {
|
||||
Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n",
|
||||
pcre_error, Char(pattern), pcre_errorpos);
|
||||
exit(1);
|
||||
}
|
||||
rc = pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30);
|
||||
if (rc >= 0) {
|
||||
res = replace_captures(rc, input, subst, captures, pattern, s);
|
||||
} else if (rc != PCRE_ERROR_NOMATCH) {
|
||||
Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" using \"%s\".\n",
|
||||
rc, Char(pattern), input);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
DohDelete(pattern);
|
||||
DohDelete(subst);
|
||||
pcre_free(compiled_pat);
|
||||
return res ? res : NewStringEmpty();
|
||||
}
|
||||
|
||||
String *Swig_pcre_version(void) {
|
||||
return NewStringf("PCRE Version: %s", pcre_version());
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
String *Swig_string_regex(String *s) {
|
||||
Swig_error("SWIG", Getline(s), "PCRE regex support not enabled in this SWIG build.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
String *Swig_pcre_version(void) {
|
||||
return NewStringf("PCRE not used");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_init()
|
||||
*
|
||||
|
|
@ -1042,8 +1260,9 @@ void Swig_init() {
|
|||
DohEncoding("typecode", Swig_string_typecode);
|
||||
DohEncoding("mangle", Swig_string_emangle);
|
||||
DohEncoding("command", Swig_string_command);
|
||||
DohEncoding("rxspencer", Swig_string_rxspencer);
|
||||
DohEncoding("schemify", Swig_string_schemify);
|
||||
DohEncoding("strip", Swig_string_strip);
|
||||
DohEncoding("regex", Swig_string_regex);
|
||||
|
||||
/* aliases for the case encoders */
|
||||
DohEncoding("uppercase", Swig_string_upper);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,23 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* naming.c
|
||||
*
|
||||
* Functions for generating various kinds of names during code generation.
|
||||
*
|
||||
* Swig_name_register is used to register a format string for generating names.
|
||||
* The format string makes use of the following format specifiers:
|
||||
*
|
||||
* %c - class name is substituted
|
||||
* %f - function name is substituted
|
||||
* %m - member name is substituted
|
||||
* %n - namespace is substituted
|
||||
* %v - variable name is substituted
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_naming_c[] = "$Id$";
|
||||
|
|
@ -27,13 +40,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);
|
||||
}
|
||||
|
|
@ -121,13 +134,30 @@ static int name_mangle(String *r) {
|
|||
return special;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* replace_nspace()
|
||||
*
|
||||
* Mangles in the namespace from nspace by replacing %n in name if nspace feature required.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void replace_nspace(String *name, const_String_or_char_ptr nspace) {
|
||||
if (nspace) {
|
||||
String *namspace = NewStringf("%s_", nspace);
|
||||
Replaceall(namspace, NSPACE_SEPARATOR, "_");
|
||||
Replace(name, "%n", namspace, DOH_REPLACE_ANY);
|
||||
Delete(namspace);
|
||||
} else {
|
||||
Replace(name, "%n", "", DOH_REPLACE_ANY);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_name_mangle()
|
||||
*
|
||||
* 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 +173,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 +198,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 nspace, const_String_or_char_ptr classname, const_String_or_char_ptr membername) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -180,7 +210,7 @@ String *Swig_name_member(const String_or_char *classname, const String_or_char *
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "member");
|
||||
if (!f) {
|
||||
Append(r, "%c_%m");
|
||||
Append(r, "%n%c_%m");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -188,8 +218,9 @@ String *Swig_name_member(const String_or_char *classname, const String_or_char *
|
|||
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
|
||||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Replace(r, "%m", mname, DOH_REPLACE_ANY);
|
||||
Replace(r, "%m", membername, DOH_REPLACE_ANY);
|
||||
/* name_mangle(r); */
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -201,7 +232,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 nspace, const_String_or_char_ptr vname) {
|
||||
String *r;
|
||||
String *f;
|
||||
|
||||
|
|
@ -214,10 +245,12 @@ String *Swig_name_get(const String_or_char *vname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "get");
|
||||
if (!f) {
|
||||
Append(r, "%v_get");
|
||||
Append(r, "%n%v_get");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%v", vname, DOH_REPLACE_ANY);
|
||||
/* name_mangle(r); */
|
||||
return r;
|
||||
|
|
@ -229,7 +262,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 nspace, const_String_or_char_ptr vname) {
|
||||
String *r;
|
||||
String *f;
|
||||
|
||||
|
|
@ -238,10 +271,12 @@ String *Swig_name_set(const String_or_char *vname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "set");
|
||||
if (!f) {
|
||||
Append(r, "%v_set");
|
||||
Append(r, "%n%v_set");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%v", vname, DOH_REPLACE_ANY);
|
||||
/* name_mangle(r); */
|
||||
return r;
|
||||
|
|
@ -253,7 +288,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 nspace, const_String_or_char_ptr classname) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -265,7 +300,7 @@ String *Swig_name_construct(const String_or_char *classname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "construct");
|
||||
if (!f) {
|
||||
Append(r, "new_%c");
|
||||
Append(r, "new_%n%c");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -274,6 +309,8 @@ String *Swig_name_construct(const String_or_char *classname) {
|
|||
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
|
||||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -286,7 +323,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 nspace, const_String_or_char_ptr classname) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -298,7 +335,7 @@ String *Swig_name_copyconstructor(const String_or_char *classname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "copy");
|
||||
if (!f) {
|
||||
Append(r, "copy_%c");
|
||||
Append(r, "copy_%n%c");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -308,6 +345,7 @@ String *Swig_name_copyconstructor(const String_or_char *classname) {
|
|||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -319,7 +357,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 nspace, const_String_or_char_ptr classname) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -330,7 +368,7 @@ String *Swig_name_destroy(const String_or_char *classname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "destroy");
|
||||
if (!f) {
|
||||
Append(r, "delete_%c");
|
||||
Append(r, "delete_%n%c");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -339,6 +377,8 @@ String *Swig_name_destroy(const String_or_char *classname) {
|
|||
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
|
||||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -351,7 +391,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 nspace, const_String_or_char_ptr classname) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -362,7 +402,7 @@ String *Swig_name_disown(const String_or_char *classname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "disown");
|
||||
if (!f) {
|
||||
Append(r, "disown_%c");
|
||||
Append(r, "disown_%n%c");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -371,6 +411,8 @@ String *Swig_name_disown(const String_or_char *classname) {
|
|||
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
|
||||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -474,23 +516,12 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType
|
|||
Delete(cls);
|
||||
}
|
||||
/* A template-based class lookup, check name first */
|
||||
if (!rn && SwigType_istemplate(name)) {
|
||||
String *t_name = SwigType_templateprefix(name);
|
||||
if (!Equal(t_name, name)) {
|
||||
if (!rn) {
|
||||
String *t_name = SwigType_istemplate_templateprefix(name);
|
||||
if (t_name)
|
||||
rn = Swig_name_object_get(namehash, prefix, t_name, decl);
|
||||
}
|
||||
Delete(t_name);
|
||||
}
|
||||
/* A template-based class lookup */
|
||||
if (0 && !rn && SwigType_istemplate(prefix)) {
|
||||
String *t_prefix = SwigType_templateprefix(prefix);
|
||||
if (Strcmp(t_prefix, prefix) != 0) {
|
||||
String *t_name = SwigType_templateprefix(name);
|
||||
rn = Swig_name_object_get(namehash, t_prefix, t_name, decl);
|
||||
Delete(t_name);
|
||||
}
|
||||
Delete(t_prefix);
|
||||
}
|
||||
}
|
||||
/* A wildcard-based class lookup */
|
||||
if (!rn) {
|
||||
|
|
@ -534,6 +565,7 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType
|
|||
|
||||
void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
|
||||
Iterator ki;
|
||||
Hash *derh;
|
||||
String *bprefix;
|
||||
String *dprefix;
|
||||
char *cbprefix;
|
||||
|
|
@ -542,6 +574,9 @@ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
|
|||
if (!namehash)
|
||||
return;
|
||||
|
||||
/* Temporary hash holding all the entries we add while we iterate over
|
||||
namehash itself as we can't modify the latter while iterating over it. */
|
||||
derh = NULL;
|
||||
bprefix = NewStringf("%s::", base);
|
||||
dprefix = NewStringf("%s::", derived);
|
||||
cbprefix = Char(bprefix);
|
||||
|
|
@ -549,13 +584,20 @@ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
|
|||
for (ki = First(namehash); ki.key; ki = Next(ki)) {
|
||||
char *k = Char(ki.key);
|
||||
if (strncmp(k, cbprefix, plen) == 0) {
|
||||
/* Copy, adjusting name, this element to the derived hash. */
|
||||
Iterator oi;
|
||||
String *nkey = NewStringf("%s%s", dprefix, k + plen);
|
||||
Hash *n = ki.item;
|
||||
Hash *newh = Getattr(namehash, nkey);
|
||||
Hash *newh;
|
||||
|
||||
/* Don't overwrite an existing value for the derived class, if any. */
|
||||
newh = Getattr(namehash, nkey);
|
||||
if (!newh) {
|
||||
if (!derh)
|
||||
derh = NewHash();
|
||||
|
||||
newh = NewHash();
|
||||
Setattr(namehash, nkey, newh);
|
||||
Setattr(derh, nkey, newh);
|
||||
Delete(newh);
|
||||
}
|
||||
for (oi = First(n); oi.key; oi = Next(oi)) {
|
||||
|
|
@ -568,8 +610,17 @@ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
|
|||
Delete(nkey);
|
||||
}
|
||||
}
|
||||
|
||||
/* Merge the contents of derived hash into the main hash. */
|
||||
if (derh) {
|
||||
for (ki = First(derh); ki.key; ki = Next(ki)) {
|
||||
Setattr(namehash, ki.key, ki.item);
|
||||
}
|
||||
}
|
||||
|
||||
Delete(bprefix);
|
||||
Delete(dprefix);
|
||||
Delete(derh);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -598,7 +649,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);
|
||||
|
|
@ -653,7 +704,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 */
|
||||
|
|
@ -661,10 +712,9 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
|
|||
if (name) {
|
||||
String *tname = NewStringEmpty();
|
||||
/* add features for 'root' template */
|
||||
if (SwigType_istemplate(name)) {
|
||||
String *dname = SwigType_templateprefix(name);
|
||||
String *dname = SwigType_istemplate_templateprefix(name);
|
||||
if (dname) {
|
||||
features_get(features, dname, decl, ncdecl, node);
|
||||
Delete(dname);
|
||||
}
|
||||
/* Catch-all */
|
||||
features_get(features, name, decl, ncdecl, node);
|
||||
|
|
@ -682,16 +732,16 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
|
|||
/* A specific class lookup */
|
||||
if (Len(prefix)) {
|
||||
/* A template-based class lookup */
|
||||
if (SwigType_istemplate(prefix)) {
|
||||
String *tprefix = SwigType_templateprefix(prefix);
|
||||
String *tprefix = SwigType_istemplate_templateprefix(prefix);
|
||||
if (tprefix) {
|
||||
Clear(tname);
|
||||
Printf(tname, "%s::%s", tprefix, name);
|
||||
features_get(features, tname, decl, ncdecl, node);
|
||||
Delete(tprefix);
|
||||
}
|
||||
Clear(tname);
|
||||
Printf(tname, "%s::%s", prefix, name);
|
||||
features_get(features, tname, decl, ncdecl, node);
|
||||
Delete(tprefix);
|
||||
}
|
||||
} else {
|
||||
/* Lookup in the global namespace only */
|
||||
|
|
@ -700,6 +750,7 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
|
|||
features_get(features, tname, decl, ncdecl, node);
|
||||
}
|
||||
Delete(tname);
|
||||
Delete(dname);
|
||||
}
|
||||
if (name && SwigType_istemplate(name)) {
|
||||
/* add features for complete template type */
|
||||
|
|
@ -725,12 +776,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);
|
||||
|
|
@ -862,11 +913,14 @@ static int nodes_are_equivalent(Node *a, Node *b, int a_inclass) {
|
|||
/* they must have the same type */
|
||||
String *ta = nodeType(a);
|
||||
String *tb = nodeType(b);
|
||||
if (Cmp(ta, tb) != 0)
|
||||
return 0;
|
||||
if (!Equal(ta, tb)) {
|
||||
if (!(Equal(ta, "using") && Equal(tb, "cdecl"))) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* cdecl case */
|
||||
if (Cmp(ta, "cdecl") == 0) {
|
||||
/* both cdecl case */
|
||||
/* typedef */
|
||||
String *a_storage = Getattr(a, "storage");
|
||||
String *b_storage = Getattr(b, "storage");
|
||||
|
|
@ -925,8 +979,17 @@ static int nodes_are_equivalent(Node *a, Node *b, int a_inclass) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (Equal(ta, "using")) {
|
||||
/* using and cdecl case */
|
||||
String *b_storage = Getattr(b, "storage");
|
||||
if (Equal(b_storage, "typedef")) {
|
||||
String *a_name = Getattr(a, "name");
|
||||
String *b_name = Getattr(b, "name");
|
||||
if (Equal(a_name, b_name))
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
/* %constant case */
|
||||
/* both %constant case */
|
||||
String *a_storage = Getattr(a, "storage");
|
||||
String *b_storage = Getattr(b, "storage");
|
||||
if ((Cmp(a_storage, "%constant") == 0)
|
||||
|
|
@ -969,7 +1032,7 @@ int Swig_need_redefined_warn(Node *a, Node *b, int InClass) {
|
|||
* This is basically any protected members when the allprotected mode is set.
|
||||
* Otherwise we take just the protected virtual methods and non-static methods
|
||||
* (potentially virtual methods) as well as constructors/destructors.
|
||||
*
|
||||
* Also any "using" statements in a class may potentially be virtual.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_need_protected(Node *n) {
|
||||
|
|
@ -986,6 +1049,8 @@ int Swig_need_protected(Node *n) {
|
|||
}
|
||||
} else if (Equal(nodetype, "constructor") || Equal(nodetype, "destructor")) {
|
||||
return 1;
|
||||
} else if (Equal(nodetype, "using") && !Getattr(n, "namespace")) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1030,25 +1095,21 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
|
|||
if (ckey) {
|
||||
const char **rkey;
|
||||
int isnotmatch = 0;
|
||||
int isrxsmatch = 0;
|
||||
int isregexmatch = 0;
|
||||
if ((strncmp(ckey, "match", 5) == 0)
|
||||
|| (isnotmatch = (strncmp(ckey, "notmatch", 8) == 0))
|
||||
|| (isrxsmatch = (strncmp(ckey, "rxsmatch", 8) == 0))
|
||||
|| (isnotmatch = isrxsmatch = (strncmp(ckey, "notrxsmatch", 11) == 0))) {
|
||||
|| (isregexmatch = (strncmp(ckey, "regexmatch", 10) == 0))
|
||||
|| (isnotmatch = isregexmatch = (strncmp(ckey, "notregexmatch", 13) == 0))) {
|
||||
Hash *mi = NewHash();
|
||||
List *attrlist = Swig_make_attrlist(ckey);
|
||||
if (!matchlist)
|
||||
matchlist = NewList();
|
||||
Setattr(mi, "value", Getattr(kw, "value"));
|
||||
Setattr(mi, "attrlist", attrlist);
|
||||
#ifdef SWIG_DEBUG
|
||||
if (isrxsmatch)
|
||||
Printf(stdout, "rxsmatch to use: %s %s %s\n", ckey, Getattr(kw, "value"), attrlist);
|
||||
#endif
|
||||
if (isnotmatch)
|
||||
SetFlag(mi, "notmatch");
|
||||
if (isrxsmatch)
|
||||
SetFlag(mi, "rxsmatch");
|
||||
if (isregexmatch)
|
||||
SetFlag(mi, "regexmatch");
|
||||
Delete(attrlist);
|
||||
Append(matchlist, mi);
|
||||
Delete(mi);
|
||||
|
|
@ -1083,7 +1144,7 @@ void Swig_name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, Str
|
|||
}
|
||||
|
||||
if (!nname || !Len(nname) || Getattr(nameobj, "fullname") || /* any of these options trigger a 'list' nameobj */
|
||||
Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist")) {
|
||||
Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist") || Getattr(nameobj, "regextarget")) {
|
||||
if (decl)
|
||||
Setattr(nameobj, "decl", decl);
|
||||
if (nname && Len(nname))
|
||||
|
|
@ -1124,36 +1185,50 @@ static DOH *Swig_get_lattr(Node *n, List *lattr) {
|
|||
return res;
|
||||
}
|
||||
|
||||
#if defined(HAVE_RXSPENCER)
|
||||
#include <sys/types.h>
|
||||
#include <rxspencer/regex.h>
|
||||
#define USE_RXSPENCER
|
||||
#endif
|
||||
#ifdef HAVE_PCRE
|
||||
#include <pcre.h>
|
||||
|
||||
#if defined(USE_RXSPENCER)
|
||||
int Swig_name_rxsmatch_value(String *mvalue, String *value) {
|
||||
int match = 0;
|
||||
char *cvalue = Char(value);
|
||||
char *cmvalue = Char(mvalue);
|
||||
regex_t compiled;
|
||||
int retval = regcomp(&compiled, cmvalue, REG_EXTENDED | REG_NOSUB);
|
||||
if (retval != 0)
|
||||
int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
|
||||
pcre *compiled_pat;
|
||||
const char *err;
|
||||
int errpos;
|
||||
int rc;
|
||||
|
||||
compiled_pat = pcre_compile(Char(pattern), 0, &err, &errpos, NULL);
|
||||
if (!compiled_pat) {
|
||||
Swig_error("SWIG", Getline(n),
|
||||
"Invalid regex \"%s\": compilation failed at %d: %s\n",
|
||||
Char(pattern), errpos, err);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0);
|
||||
pcre_free(compiled_pat);
|
||||
|
||||
if (rc == PCRE_ERROR_NOMATCH)
|
||||
return 0;
|
||||
retval = regexec(&compiled, cvalue, 0, 0, 0);
|
||||
match = (retval == REG_NOMATCH) ? 0 : 1;
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "rxsmatch_value: %s %s %d\n", cvalue, cmvalue, match);
|
||||
#endif
|
||||
regfree(&compiled);
|
||||
return match;
|
||||
|
||||
if (rc < 0 ) {
|
||||
Swig_error("SWIG", Getline(n),
|
||||
"Matching \"%s\" against regex \"%s\" failed: %d\n",
|
||||
Char(s), Char(pattern), rc);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
int Swig_name_rxsmatch_value(String *mvalue, String *value) {
|
||||
(void) mvalue;
|
||||
(void) value;
|
||||
return 0;
|
||||
|
||||
#else /* !HAVE_PCRE */
|
||||
|
||||
int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
|
||||
(void)pattern;
|
||||
(void)s;
|
||||
Swig_error("SWIG", Getline(n),
|
||||
"PCRE regex matching is not available in this SWIG build.\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_PCRE/!HAVE_PCRE */
|
||||
|
||||
int Swig_name_match_value(String *mvalue, String *value) {
|
||||
#if defined(SWIG_USE_SIMPLE_MATCHOR)
|
||||
|
|
@ -1196,17 +1271,11 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) {
|
|||
List *lattr = Getattr(mi, "attrlist");
|
||||
String *nval = Swig_get_lattr(n, lattr);
|
||||
int notmatch = GetFlag(mi, "notmatch");
|
||||
int rxsmatch = GetFlag(mi, "rxsmatch");
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "mi %d %s re %d not %d \n", i, nval, notmatch, rxsmatch);
|
||||
if (rxsmatch) {
|
||||
Printf(stdout, "rxsmatch %s\n", lattr);
|
||||
}
|
||||
#endif
|
||||
int regexmatch = GetFlag(mi, "regexmatch");
|
||||
match = 0;
|
||||
if (nval) {
|
||||
String *kwval = Getattr(mi, "value");
|
||||
match = rxsmatch ? Swig_name_rxsmatch_value(kwval, nval)
|
||||
match = regexmatch ? Swig_name_regexmatch_value(n, kwval, nval)
|
||||
: Swig_name_match_value(kwval, nval);
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "val %s %s %d %d \n", nval, kwval, match, ilen);
|
||||
|
|
@ -1246,7 +1315,7 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
|
|||
String *sfmt = Getattr(rn, "sourcefmt");
|
||||
String *sname = 0;
|
||||
int fullname = GetFlag(rn, "fullname");
|
||||
int rxstarget = GetFlag(rn, "rxstarget");
|
||||
int regextarget = GetFlag(rn, "regextarget");
|
||||
if (sfmt) {
|
||||
if (fullname && prefix) {
|
||||
String *pname = NewStringf("%s::%s", prefix, name);
|
||||
|
|
@ -1263,10 +1332,17 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
|
|||
DohIncref(name);
|
||||
}
|
||||
}
|
||||
match = rxstarget ? Swig_name_rxsmatch_value(tname, sname) : Swig_name_match_value(tname, sname);
|
||||
match = regextarget ? Swig_name_regexmatch_value(n, tname, sname)
|
||||
: Swig_name_match_value(tname, sname);
|
||||
Delete(sname);
|
||||
} else {
|
||||
match = 1;
|
||||
/* Applying the renaming rule may fail if it contains a %(regex)s expression that doesn't match the given name. */
|
||||
String *sname = NewStringf(Getattr(rn, "name"), name);
|
||||
if (sname) {
|
||||
if (Len(sname))
|
||||
match = 1;
|
||||
Delete(sname);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
|
|
@ -1362,7 +1438,7 @@ void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *ne
|
|||
|
||||
ParmList *declparms = declaratorparms;
|
||||
|
||||
const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "rxstarget", 0 };
|
||||
const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "regextarget", 0 };
|
||||
Swig_name_object_attach_keys(rename_keys, newname);
|
||||
|
||||
/* Add the name */
|
||||
|
|
@ -1434,7 +1510,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);
|
||||
|
|
@ -1477,7 +1553,7 @@ String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType
|
|||
}
|
||||
|
||||
|
||||
if (rename_hash || rename_list) {
|
||||
if (rename_hash || rename_list || namewarn_hash || namewarn_list) {
|
||||
Hash *rn = Swig_name_object_get(Swig_name_rename_hash(), prefix, name, decl);
|
||||
if (!rn || !Swig_name_match_nameobj(rn, n)) {
|
||||
rn = Swig_name_nameobj_lget(Swig_name_rename_list(), n, prefix, name, decl);
|
||||
|
|
@ -1573,19 +1649,20 @@ void Swig_name_inherit(String *base, String *derived) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Swig_name_decl()
|
||||
* void Swig_name_str()
|
||||
*
|
||||
* Return a stringified version of a C/C++ declaration without the return type.
|
||||
* The node passed in is expected to be a function. Some example return values:
|
||||
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate()"
|
||||
* "MyNameSpace::ABC::ABC(int,double)"
|
||||
* "MyNameSpace::ABC::constmethod(int) const"
|
||||
* Return a stringified version of a C/C++ symbol from a node.
|
||||
* The node passed in is expected to be a function, constructor, destructor or
|
||||
* variable. Some example return values:
|
||||
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate"
|
||||
* "MyNameSpace::ABC::ABC"
|
||||
* "MyNameSpace::ABC::constmethod"
|
||||
* "MyNameSpace::ABC::variablename"
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_decl(Node *n) {
|
||||
String *Swig_name_str(Node *n) {
|
||||
String *qname;
|
||||
String *decl;
|
||||
String *qualifier = Swig_symbol_qualified(n);
|
||||
String *name = Swig_scopename_last(Getattr(n, "name"));
|
||||
if (qualifier)
|
||||
|
|
@ -1609,12 +1686,38 @@ String *Swig_name_decl(Node *n) {
|
|||
qname = NewString("");
|
||||
if (qualifier && Len(qualifier) > 0)
|
||||
Printf(qname, "%s::", qualifier);
|
||||
Printf(qname, "%s", name);
|
||||
|
||||
decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : "");
|
||||
Printf(qname, "%s", SwigType_str(name, 0));
|
||||
|
||||
Delete(name);
|
||||
Delete(qualifier);
|
||||
|
||||
return qname;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Swig_name_decl()
|
||||
*
|
||||
* Return a stringified version of a C/C++ declaration without the return type.
|
||||
* The node passed in is expected to be a function, constructor, destructor or
|
||||
* variable. Some example return values:
|
||||
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate()"
|
||||
* "MyNameSpace::ABC::ABC(int,double)"
|
||||
* "MyNameSpace::ABC::constmethod(int) const"
|
||||
* "MyNameSpace::ABC::variablename"
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_decl(Node *n) {
|
||||
String *qname;
|
||||
String *decl;
|
||||
|
||||
qname = Swig_name_str(n);
|
||||
|
||||
if (checkAttribute(n, "kind", "variable"))
|
||||
decl = NewStringf("%s", qname);
|
||||
else
|
||||
decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : "");
|
||||
|
||||
Delete(qname);
|
||||
|
||||
return decl;
|
||||
|
|
@ -1624,7 +1727,8 @@ String *Swig_name_decl(Node *n) {
|
|||
* void Swig_name_fulldecl()
|
||||
*
|
||||
* Return a stringified version of a C/C++ declaration including the return type.
|
||||
* The node passed in is expected to be a function. Some example return values:
|
||||
* The node passed in is expected to be a function, constructor or destructor.
|
||||
* Some example return values:
|
||||
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate()"
|
||||
* "MyNameSpace::ABC::ABC(int,double)"
|
||||
* "int * MyNameSpace::ABC::constmethod(int) const"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* parms.c
|
||||
*
|
||||
|
|
@ -14,10 +18,25 @@ char cvsroot_parms_c[] = "$Id$";
|
|||
/* ------------------------------------------------------------------------
|
||||
* NewParm()
|
||||
*
|
||||
* Create a new parameter from datatype 'type' and name 'name'.
|
||||
* Create a new parameter from datatype 'type' and name 'name' copying
|
||||
* the file and line number from the Node file_line_node.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
Parm *NewParm(SwigType *type, const String_or_char *name) {
|
||||
Parm *NewParm(SwigType *type, const_String_or_char_ptr name, Node *file_line_node) {
|
||||
Parm *p = NewParmWithoutFileLineInfo(type, name);
|
||||
Setfile(p, Getfile(file_line_node));
|
||||
Setline(p, Getline(file_line_node));
|
||||
return p;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* NewParmWithoutFileLineInfo()
|
||||
*
|
||||
* Create a new parameter from datatype 'type' and name 'name' without any
|
||||
* file / line numbering information.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
Parm *NewParmWithoutFileLineInfo(SwigType *type, const_String_or_char_ptr name) {
|
||||
Parm *p = NewHash();
|
||||
set_nodeType(p, "parm");
|
||||
if (type) {
|
||||
|
|
@ -114,6 +133,14 @@ int ParmList_len(ParmList *p) {
|
|||
return i;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* get_empty_type()
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
static SwigType *get_empty_type() {
|
||||
return NewStringEmpty();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* ParmList_str()
|
||||
*
|
||||
|
|
@ -123,7 +150,8 @@ int ParmList_len(ParmList *p) {
|
|||
String *ParmList_str(ParmList *p) {
|
||||
String *out = NewStringEmpty();
|
||||
while (p) {
|
||||
String *pstr = SwigType_str(Getattr(p, "type"), Getattr(p, "name"));
|
||||
String *type = Getattr(p, "type");
|
||||
String *pstr = SwigType_str(type ? type : get_empty_type(), Getattr(p, "name"));
|
||||
Append(out, pstr);
|
||||
p = nextSibling(p);
|
||||
if (p) {
|
||||
|
|
@ -144,7 +172,8 @@ String *ParmList_str_defaultargs(ParmList *p) {
|
|||
String *out = NewStringEmpty();
|
||||
while (p) {
|
||||
String *value = Getattr(p, "value");
|
||||
String *pstr = SwigType_str(Getattr(p, "type"), Getattr(p, "name"));
|
||||
String *type = Getattr(p, "type");
|
||||
String *pstr = SwigType_str(type ? type : get_empty_type(), Getattr(p, "name"));
|
||||
Append(out, pstr);
|
||||
if (value) {
|
||||
Printf(out, "=%s", value);
|
||||
|
|
@ -158,6 +187,24 @@ String *ParmList_str_defaultargs(ParmList *p) {
|
|||
return out;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* ParmList_str_multibrackets()
|
||||
*
|
||||
* Generates a string of parameters including default arguments adding brackets
|
||||
* if more than one parameter
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *ParmList_str_multibrackets(ParmList *p) {
|
||||
String *out;
|
||||
String *parm_str = ParmList_str_defaultargs(p);
|
||||
if (ParmList_len(p) > 1)
|
||||
out = NewStringf("(%s)", parm_str);
|
||||
else
|
||||
out = NewStringf("%s", parm_str);
|
||||
Delete(parm_str);
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* ParmList_protostr()
|
||||
*
|
||||
|
|
@ -167,7 +214,8 @@ String *ParmList_str_defaultargs(ParmList *p) {
|
|||
String *ParmList_protostr(ParmList *p) {
|
||||
String *out = NewStringEmpty();
|
||||
while (p) {
|
||||
String *pstr = SwigType_str(Getattr(p, "type"), 0);
|
||||
String *type = Getattr(p, "type");
|
||||
String *pstr = SwigType_str(type ? type : get_empty_type(), 0);
|
||||
Append(out, pstr);
|
||||
p = nextSibling(p);
|
||||
if (p) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* scanner.c
|
||||
*
|
||||
|
|
@ -15,6 +19,11 @@ char cvsroot_scanner_c[] = "$Id$";
|
|||
#include "swig.h"
|
||||
#include <ctype.h>
|
||||
|
||||
extern String *cparse_file;
|
||||
extern int cparse_line;
|
||||
extern int cparse_cplusplus;
|
||||
extern int cparse_start_line;
|
||||
|
||||
struct Scanner {
|
||||
String *text; /* Current token value */
|
||||
List *scanobjs; /* Objects being scanned */
|
||||
|
|
@ -30,13 +39,20 @@ struct Scanner {
|
|||
int freeze_line; /* Suspend line number updates */
|
||||
};
|
||||
|
||||
typedef struct Locator {
|
||||
String *filename;
|
||||
int line_number;
|
||||
struct Locator *next;
|
||||
} Locator;
|
||||
static int follow_locators = 0;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* NewScanner()
|
||||
*
|
||||
* Create a new scanner object
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Scanner *NewScanner() {
|
||||
Scanner *NewScanner(void) {
|
||||
Scanner *s;
|
||||
s = (Scanner *) malloc(sizeof(Scanner));
|
||||
s->line = 1;
|
||||
|
|
@ -82,6 +98,7 @@ void Scanner_clear(Scanner * s) {
|
|||
Clear(s->text);
|
||||
Clear(s->scanobjs);
|
||||
Delete(s->error);
|
||||
s->str = 0;
|
||||
s->error = 0;
|
||||
s->line = 1;
|
||||
s->nexttoken = -1;
|
||||
|
|
@ -115,11 +132,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);
|
||||
}
|
||||
|
|
@ -200,7 +217,7 @@ static char nextchar(Scanner * s) {
|
|||
if ((nc == '\n') && (!s->freeze_line))
|
||||
s->line++;
|
||||
Putc(nc,s->text);
|
||||
return nc;
|
||||
return (char)nc;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -209,7 +226,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);
|
||||
}
|
||||
|
|
@ -221,8 +238,7 @@ static void set_error(Scanner *s, int line, String_or_char *msg) {
|
|||
* Returns error information (if any)
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *
|
||||
Scanner_errmsg(Scanner *s) {
|
||||
String *Scanner_errmsg(Scanner *s) {
|
||||
return s->error;
|
||||
}
|
||||
|
||||
|
|
@ -232,13 +248,12 @@ Scanner_errline(Scanner *s) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Scanner_freeze_line()
|
||||
* freeze_line()
|
||||
*
|
||||
* Freezes the current line number.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
Scanner_freeze_line(Scanner *s, int val) {
|
||||
static void freeze_line(Scanner *s, int val) {
|
||||
s->freeze_line = val;
|
||||
}
|
||||
|
||||
|
|
@ -349,7 +364,7 @@ static void get_escape(Scanner *s) {
|
|||
} else {
|
||||
char tmp[3];
|
||||
tmp[0] = '\\';
|
||||
tmp[1] = c;
|
||||
tmp[1] = (char)c;
|
||||
tmp[2] = 0;
|
||||
Delitem(s->text, DOH_END);
|
||||
Append(s->text, tmp);
|
||||
|
|
@ -536,7 +551,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 +563,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 +574,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 +588,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 +671,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 == '%')
|
||||
|
|
@ -726,15 +741,25 @@ static int look(Scanner * s) {
|
|||
break;
|
||||
case 7: /* Identifier */
|
||||
if ((c = nextchar(s)) == 0)
|
||||
return SWIG_TOKEN_ID;
|
||||
if (isalnum(c) || (c == '_') || (c == '$')) {
|
||||
state = 71;
|
||||
else if (isalnum(c) || (c == '_') || (c == '$')) {
|
||||
state = 7;
|
||||
} else {
|
||||
retract(s, 1);
|
||||
return SWIG_TOKEN_ID;
|
||||
state = 71;
|
||||
}
|
||||
break;
|
||||
|
||||
case 71: /* Identifier or true/false */
|
||||
if (cparse_cplusplus) {
|
||||
if (Strcmp(s->text, "true") == 0)
|
||||
return SWIG_TOKEN_BOOL;
|
||||
else if (Strcmp(s->text, "false") == 0)
|
||||
return SWIG_TOKEN_BOOL;
|
||||
}
|
||||
return SWIG_TOKEN_ID;
|
||||
break;
|
||||
|
||||
case 75: /* Special identifier $ */
|
||||
if ((c = nextchar(s)) == 0)
|
||||
return SWIG_TOKEN_DOLLAR;
|
||||
|
|
@ -743,7 +768,7 @@ static int look(Scanner * s) {
|
|||
} else {
|
||||
retract(s,1);
|
||||
if (Len(s->text) == 1) return SWIG_TOKEN_DOLLAR;
|
||||
return SWIG_TOKEN_ID;
|
||||
state = 71;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -933,7 +958,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 +1073,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 == '`') {
|
||||
|
|
@ -1131,10 +1156,9 @@ void Scanner_skip_line(Scanner * s) {
|
|||
int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
||||
char c;
|
||||
int num_levels = 1;
|
||||
int l;
|
||||
int state = 0;
|
||||
char temp[2] = { 0, 0 };
|
||||
l = s->line;
|
||||
String *locator = 0;
|
||||
temp[0] = (char) startchar;
|
||||
Clear(s->text);
|
||||
Setfile(s->text, Getfile(s->str));
|
||||
|
|
@ -1143,6 +1167,7 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
|||
Append(s->text, temp);
|
||||
while (num_levels > 0) {
|
||||
if ((c = nextchar(s)) == 0) {
|
||||
Delete(locator);
|
||||
return -1;
|
||||
}
|
||||
switch (state) {
|
||||
|
|
@ -1163,6 +1188,10 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
|||
state = 11;
|
||||
else if (c == '*')
|
||||
state = 12;
|
||||
else if (c == startchar) {
|
||||
state = 0;
|
||||
num_levels++;
|
||||
}
|
||||
else
|
||||
state = 0;
|
||||
break;
|
||||
|
|
@ -1172,17 +1201,25 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
|||
else
|
||||
state = 11;
|
||||
break;
|
||||
case 12:
|
||||
case 12: /* first character inside C comment */
|
||||
if (c == '*')
|
||||
state = 14;
|
||||
else if (c == '@')
|
||||
state = 40;
|
||||
else
|
||||
state = 13;
|
||||
break;
|
||||
case 13:
|
||||
if (c == '*')
|
||||
state = 13;
|
||||
state = 14;
|
||||
break;
|
||||
case 14: /* possible end of C comment */
|
||||
if (c == '*')
|
||||
state = 14;
|
||||
else if (c == '/')
|
||||
state = 0;
|
||||
else
|
||||
state = 12;
|
||||
state = 13;
|
||||
break;
|
||||
case 20:
|
||||
if (c == '\"')
|
||||
|
|
@ -1202,10 +1239,43 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
|||
case 31:
|
||||
state = 30;
|
||||
break;
|
||||
/* 40-45 SWIG locator checks - a C comment with contents starting: @SWIG */
|
||||
case 40:
|
||||
state = (c == 'S') ? 41 : (c == '*') ? 14 : 13;
|
||||
break;
|
||||
case 41:
|
||||
state = (c == 'W') ? 42 : (c == '*') ? 14 : 13;
|
||||
break;
|
||||
case 42:
|
||||
state = (c == 'I') ? 43 : (c == '*') ? 14 : 13;
|
||||
break;
|
||||
case 43:
|
||||
state = (c == 'G') ? 44 : (c == '*') ? 14 : 13;
|
||||
if (c == 'G') {
|
||||
Delete(locator);
|
||||
locator = NewString("/*@SWIG");
|
||||
}
|
||||
break;
|
||||
case 44:
|
||||
if (c == '*')
|
||||
state = 45;
|
||||
Putc(c, locator);
|
||||
break;
|
||||
case 45: /* end of SWIG locator in C comment */
|
||||
if (c == '/') {
|
||||
state = 0;
|
||||
Putc(c, locator);
|
||||
Scanner_locator(s, locator);
|
||||
} else {
|
||||
/* malformed locator */
|
||||
state = (c == '*') ? 14 : 13;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
Delete(locator);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1216,8 +1286,98 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
|||
* operator.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
Scanner_isoperator(int tokval) {
|
||||
int Scanner_isoperator(int tokval) {
|
||||
if (tokval >= 100) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* locator()
|
||||
*
|
||||
* Support for locator strings. These are strings of the form
|
||||
* @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They
|
||||
* are primarily used for macro line number reporting.
|
||||
* We just use the locator to mark when to activate/deactivate linecounting.
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
void Scanner_locator(Scanner *s, String *loc) {
|
||||
static Locator *locs = 0;
|
||||
static int expanding_macro = 0;
|
||||
|
||||
if (!follow_locators) {
|
||||
if (Equal(loc, "/*@SWIG@*/")) {
|
||||
/* End locator. */
|
||||
if (expanding_macro)
|
||||
--expanding_macro;
|
||||
} else {
|
||||
/* Begin locator. */
|
||||
++expanding_macro;
|
||||
}
|
||||
/* Freeze line number processing in Scanner */
|
||||
freeze_line(s,expanding_macro);
|
||||
} else {
|
||||
int c;
|
||||
Locator *l;
|
||||
Seek(loc, 7, SEEK_SET);
|
||||
c = Getc(loc);
|
||||
if (c == '@') {
|
||||
/* Empty locator. We pop the last location off */
|
||||
if (locs) {
|
||||
Scanner_set_location(s, locs->filename, locs->line_number);
|
||||
cparse_file = locs->filename;
|
||||
cparse_line = locs->line_number;
|
||||
l = locs->next;
|
||||
free(locs);
|
||||
locs = l;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* We're going to push a new location */
|
||||
l = (Locator *) malloc(sizeof(Locator));
|
||||
l->filename = cparse_file;
|
||||
l->line_number = cparse_line;
|
||||
l->next = locs;
|
||||
locs = l;
|
||||
|
||||
/* Now, parse the new location out of the locator string */
|
||||
{
|
||||
String *fn = NewStringEmpty();
|
||||
/* Putc(c, fn); */
|
||||
|
||||
while ((c = Getc(loc)) != EOF) {
|
||||
if ((c == '@') || (c == ','))
|
||||
break;
|
||||
Putc(c, fn);
|
||||
}
|
||||
cparse_file = Swig_copy_string(Char(fn));
|
||||
Clear(fn);
|
||||
cparse_line = 1;
|
||||
/* Get the line number */
|
||||
while ((c = Getc(loc)) != EOF) {
|
||||
if ((c == '@') || (c == ','))
|
||||
break;
|
||||
Putc(c, fn);
|
||||
}
|
||||
cparse_line = atoi(Char(fn));
|
||||
Clear(fn);
|
||||
|
||||
/* Get the rest of it */
|
||||
while ((c = Getc(loc)) != EOF) {
|
||||
if (c == '@')
|
||||
break;
|
||||
Putc(c, fn);
|
||||
}
|
||||
/* Swig_diagnostic(cparse_file, cparse_line, "Scanner_set_location\n"); */
|
||||
Scanner_set_location(s, cparse_file, cparse_line);
|
||||
Delete(fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Swig_cparse_follow_locators(int v) {
|
||||
follow_locators = v;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* stype.c
|
||||
*
|
||||
|
|
@ -173,7 +177,7 @@ void SwigType_push(SwigType *t, String *cons) {
|
|||
* Testing functions for querying a raw datatype
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_ispointer_return(SwigType *t) {
|
||||
int SwigType_ispointer_return(const SwigType *t) {
|
||||
char *c;
|
||||
int idx;
|
||||
if (!t)
|
||||
|
|
@ -186,7 +190,7 @@ int SwigType_ispointer_return(SwigType *t) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SwigType_isreference_return(SwigType *t) {
|
||||
int SwigType_isreference_return(const SwigType *t) {
|
||||
char *c;
|
||||
int idx;
|
||||
if (!t)
|
||||
|
|
@ -199,7 +203,7 @@ int SwigType_isreference_return(SwigType *t) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SwigType_isconst(SwigType *t) {
|
||||
int SwigType_isconst(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -225,7 +229,7 @@ int SwigType_isconst(SwigType *t) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SwigType_ismutable(SwigType *t) {
|
||||
int SwigType_ismutable(const SwigType *t) {
|
||||
int r;
|
||||
SwigType *qt = SwigType_typedef_resolve_all(t);
|
||||
if (SwigType_isreference(qt) || SwigType_isarray(qt)) {
|
||||
|
|
@ -236,7 +240,7 @@ int SwigType_ismutable(SwigType *t) {
|
|||
return r ? 0 : 1;
|
||||
}
|
||||
|
||||
int SwigType_isenum(SwigType *t) {
|
||||
int SwigType_isenum(const SwigType *t) {
|
||||
char *c = Char(t);
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -246,7 +250,7 @@ int SwigType_isenum(SwigType *t) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SwigType_issimple(SwigType *t) {
|
||||
int SwigType_issimple(const SwigType *t) {
|
||||
char *c = Char(t);
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -285,223 +289,187 @@ int SwigType_isbuiltin(SwigType *t) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_default()
|
||||
* SwigType_default_create()
|
||||
*
|
||||
* Create the default string for this datatype. This takes a type and strips it
|
||||
* down to its most primitive form--resolving all typedefs and removing operators.
|
||||
* Create the default type for this datatype. This takes a type and strips it
|
||||
* down to a generic form first by resolving all typedefs.
|
||||
*
|
||||
* Rules:
|
||||
* Pointers: p.SWIGTYPE
|
||||
* References: r.SWIGTYPE
|
||||
* Arrays: a().SWIGTYPE
|
||||
* Types: SWIGTYPE
|
||||
* MemberPointer: m(CLASS).SWIGTYPE
|
||||
* Enums: enum SWIGTYPE
|
||||
* Pointers: p.SWIGTYPE
|
||||
* References: r.SWIGTYPE
|
||||
* Arrays no dimension: a().SWIGTYPE
|
||||
* Arrays with dimension: a(ANY).SWIGTYPE
|
||||
* Member pointer: m(CLASS).SWIGTYPE
|
||||
* Function pointer: f(ANY).SWIGTYPE
|
||||
* Enums: enum SWIGTYPE
|
||||
* Types: SWIGTYPE
|
||||
*
|
||||
* Note: if this function is applied to a primitive type, it returns NULL. This
|
||||
* allows recursive application for special types like arrays.
|
||||
* Examples (also see SwigType_default_deduce):
|
||||
*
|
||||
* int [2][4]
|
||||
* a(2).a(4).int
|
||||
* a(ANY).a(ANY).SWIGTYPE
|
||||
*
|
||||
* struct A {};
|
||||
* typedef A *Aptr;
|
||||
* Aptr const &
|
||||
* r.q(const).Aptr
|
||||
* r.q(const).p.SWIGTYPE
|
||||
*
|
||||
* enum E {e1, e2};
|
||||
* enum E const &
|
||||
* r.q(const).enum E
|
||||
* r.q(const).enum SWIGTYPE
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef SWIG_DEFAULT_CACHE
|
||||
static Hash *default_cache = 0;
|
||||
#endif
|
||||
SwigType *SwigType_default_create(const SwigType *ty) {
|
||||
SwigType *r = 0;
|
||||
List *l;
|
||||
Iterator it;
|
||||
int numitems;
|
||||
|
||||
#define SWIG_NEW_TYPE_DEFAULT
|
||||
/* The new default type resolution method:
|
||||
if (!SwigType_isvarargs(ty)) {
|
||||
SwigType *t = SwigType_typedef_resolve_all(ty);
|
||||
r = NewStringEmpty();
|
||||
l = SwigType_split(t);
|
||||
numitems = Len(l);
|
||||
|
||||
1.- It preserves the original mixed types, then it goes 'backward'
|
||||
first deleting the qualifier, then the inner types
|
||||
|
||||
typedef A *Aptr;
|
||||
const Aptr&;
|
||||
r.q(const).Aptr -> r.q(const).p.SWIGTYPE
|
||||
r.q(const).p.SWIGTYPE -> r.p.SWIGTYPE
|
||||
r.p.SWIGTYPE -> r.SWIGTYPE
|
||||
r.SWIGTYPE -> SWIGTYPE
|
||||
if (numitems >= 1) {
|
||||
String *last_subtype = Getitem(l, numitems-1);
|
||||
if (SwigType_isenum(last_subtype))
|
||||
Setitem(l, numitems-1, NewString("enum SWIGTYPE"));
|
||||
else
|
||||
Setitem(l, numitems-1, NewString("SWIGTYPE"));
|
||||
}
|
||||
|
||||
for (it = First(l); it.item; it = Next(it)) {
|
||||
String *subtype = it.item;
|
||||
if (SwigType_isarray(subtype)) {
|
||||
if (Equal(subtype, "a()."))
|
||||
Append(r, NewString("a()."));
|
||||
else
|
||||
Append(r, NewString("a(ANY)."));
|
||||
} else if (SwigType_isfunction(subtype)) {
|
||||
Append(r, NewString("f(ANY).SWIGTYPE"));
|
||||
break;
|
||||
} else if (SwigType_ismemberpointer(subtype)) {
|
||||
Append(r, NewString("m(CLASS).SWIGTYPE"));
|
||||
break;
|
||||
} else {
|
||||
Append(r, subtype);
|
||||
}
|
||||
}
|
||||
|
||||
enum Hello {};
|
||||
const Hello& hi;
|
||||
r.q(const).Hello -> r.q(const).enum SWIGTYPE
|
||||
r.q(const).enum SWIGTYPE -> r.enum SWIGTYPE
|
||||
r.enum SWIGTYPE -> r.SWIGTYPE
|
||||
r.SWIGTYPE -> SWIGTYPE
|
||||
Delete(l);
|
||||
Delete(t);
|
||||
}
|
||||
|
||||
int a[2][4];
|
||||
a(2).a(4).int -> a(ANY).a(ANY).SWIGTYPE
|
||||
a(ANY).a(ANY).SWIGTYPE -> a(ANY).a().SWIGTYPE
|
||||
a(ANY).a().SWIGTYPE -> a(ANY).p.SWIGTYPE
|
||||
a(ANY).p.SWIGTYPE -> a(ANY).SWIGTYPE
|
||||
a(ANY).SWIGTYPE -> a().SWIGTYPE
|
||||
a().SWIGTYPE -> p.SWIGTYPE
|
||||
p.SWIGTYPE -> SWIGTYPE
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
static
|
||||
void SwigType_add_default(String *def, SwigType *nr) {
|
||||
if (Strcmp(nr, "SWIGTYPE") == 0) {
|
||||
Append(def, "SWIGTYPE");
|
||||
} else {
|
||||
String *q = SwigType_isqualifier(nr) ? SwigType_pop(nr) : 0;
|
||||
if (q && strstr(Char(nr), "SWIGTYPE")) {
|
||||
Append(def, nr);
|
||||
} else {
|
||||
String *nd = SwigType_default(nr);
|
||||
if (nd) {
|
||||
String *bdef = nd;
|
||||
if (q) {
|
||||
bdef = NewStringf("%s%s", q, nd);
|
||||
if ((Strcmp(nr, bdef) == 0)) {
|
||||
Delete(bdef);
|
||||
bdef = nd;
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_default_deduce()
|
||||
*
|
||||
* This function implements type deduction used in the typemap matching rules
|
||||
* and is very close to the type deduction used in partial template class
|
||||
* specialization matching in that the most specialized type is always chosen.
|
||||
* SWIGTYPE is used as the generic type. The basic idea is to repeatedly call
|
||||
* this function to find a deduced type unless until nothing matches.
|
||||
*
|
||||
* The type t must have already been converted to the default type via a call to
|
||||
* SwigType_default_create() before calling this function.
|
||||
*
|
||||
* Example deductions (matching the examples described in SwigType_default_create),
|
||||
* where the most specialized matches are highest in the list:
|
||||
*
|
||||
* a(ANY).a(ANY).SWIGTYPE
|
||||
* a(ANY).a().SWIGTYPE
|
||||
* a(ANY).p.SWIGTYPE
|
||||
* a(ANY).SWIGTYPE
|
||||
* a().SWIGTYPE
|
||||
* p.SWIGTYPE
|
||||
* SWIGTYPE
|
||||
*
|
||||
* r.q(const).p.SWIGTYPE
|
||||
* r.q(const).SWIGTYPE
|
||||
* r.SWIGTYPE
|
||||
* SWIGTYPE
|
||||
*
|
||||
* r.q(const).enum SWIGTYPE
|
||||
* r.enum SWIGTYPE
|
||||
* r.SWIGTYPE
|
||||
* SWIGTYPE
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_default_deduce(const SwigType *t) {
|
||||
SwigType *r = NewStringEmpty();
|
||||
List *l;
|
||||
Iterator it;
|
||||
int numitems;
|
||||
|
||||
l = SwigType_split(t);
|
||||
|
||||
numitems = Len(l);
|
||||
if (numitems >= 1) {
|
||||
String *last_subtype = Getitem(l, numitems-1);
|
||||
int is_enum = SwigType_isenum(last_subtype);
|
||||
|
||||
if (numitems >=2 ) {
|
||||
String *subtype = Getitem(l, numitems-2); /* last but one */
|
||||
if (SwigType_isarray(subtype)) {
|
||||
if (is_enum) {
|
||||
/* enum deduction, enum SWIGTYPE => SWIGTYPE */
|
||||
Setitem(l, numitems-1, NewString("SWIGTYPE"));
|
||||
} else {
|
||||
/* array deduction, a(ANY). => a(). => p. */
|
||||
String *deduced_subtype = 0;
|
||||
if (Strcmp(subtype, "a().") == 0) {
|
||||
deduced_subtype = NewString("p.");
|
||||
} else if (Strcmp(subtype, "a(ANY).") == 0) {
|
||||
deduced_subtype = NewString("a().");
|
||||
} else {
|
||||
Delete(nd);
|
||||
assert(0);
|
||||
}
|
||||
Setitem(l, numitems-2, deduced_subtype);
|
||||
}
|
||||
Append(def, bdef);
|
||||
Delete(bdef);
|
||||
} else if (SwigType_ismemberpointer(subtype)) {
|
||||
/* member pointer deduction, m(CLASS). => p. */
|
||||
Setitem(l, numitems-2, NewString("p."));
|
||||
} else if (is_enum && !SwigType_isqualifier(subtype)) {
|
||||
/* enum deduction, enum SWIGTYPE => SWIGTYPE */
|
||||
Setitem(l, numitems-1, NewString("SWIGTYPE"));
|
||||
} else {
|
||||
Append(def, nr);
|
||||
/* simple type deduction, eg, r.p.p. => r.p. */
|
||||
/* also function pointers eg, p.f(ANY). => p. */
|
||||
Delitem(l, numitems-2);
|
||||
}
|
||||
}
|
||||
Delete(q);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SwigType *SwigType_default(SwigType *t) {
|
||||
String *r1, *def;
|
||||
String *r = 0;
|
||||
char *cr;
|
||||
|
||||
#ifdef SWIG_DEFAULT_CACHE
|
||||
if (!default_cache)
|
||||
default_cache = NewHash();
|
||||
|
||||
r = Getattr(default_cache, t);
|
||||
if (r) {
|
||||
return Copy(r);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (SwigType_isvarargs(t)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = t;
|
||||
while ((r1 = SwigType_typedef_resolve(r))) {
|
||||
if (r != t)
|
||||
Delete(r);
|
||||
r = r1;
|
||||
}
|
||||
if (SwigType_isqualifier(r)) {
|
||||
String *q;
|
||||
if (r == t)
|
||||
r = Copy(t);
|
||||
q = SwigType_pop(r);
|
||||
if (strstr(Char(r), "SWIGTYPE")) {
|
||||
Delete(q);
|
||||
def = r;
|
||||
return def;
|
||||
}
|
||||
Delete(q);
|
||||
}
|
||||
cr = Char(r);
|
||||
if (strcmp(cr, "p.SWIGTYPE") == 0) {
|
||||
def = NewString("SWIGTYPE");
|
||||
} else if (SwigType_ispointer(r)) {
|
||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||
SwigType *nr = Copy(r);
|
||||
SwigType_del_pointer(nr);
|
||||
def = SwigType_isfunction(nr) ? NewStringEmpty() : NewString("p.");
|
||||
SwigType_add_default(def, nr);
|
||||
Delete(nr);
|
||||
#else
|
||||
def = NewString("p.SWIGTYPE");
|
||||
#endif
|
||||
} else if (strcmp(cr, "r.SWIGTYPE") == 0) {
|
||||
def = NewString("SWIGTYPE");
|
||||
} else if (SwigType_isreference(r)) {
|
||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||
SwigType *nr = Copy(r);
|
||||
SwigType_del_reference(nr);
|
||||
def = NewString("r.");
|
||||
SwigType_add_default(def, nr);
|
||||
Delete(nr);
|
||||
#else
|
||||
def = NewString("r.SWIGTYPE");
|
||||
#endif
|
||||
} else if (SwigType_isarray(r)) {
|
||||
if (strcmp(cr, "a().SWIGTYPE") == 0) {
|
||||
def = NewString("p.SWIGTYPE");
|
||||
} else if (strcmp(cr, "a(ANY).SWIGTYPE") == 0) {
|
||||
def = NewString("a().SWIGTYPE");
|
||||
} else {
|
||||
int i, empty = 0;
|
||||
int ndim = SwigType_array_ndim(r);
|
||||
SwigType *nr = Copy(r);
|
||||
for (i = 0; i < ndim; i++) {
|
||||
String *dim = SwigType_array_getdim(r, i);
|
||||
if (!Len(dim)) {
|
||||
char *c = Char(nr);
|
||||
empty = strstr(c, "a(ANY).") != c;
|
||||
}
|
||||
Delete(dim);
|
||||
}
|
||||
if (empty) {
|
||||
def = NewString("a().");
|
||||
if (is_enum) {
|
||||
/* enum deduction, enum SWIGTYPE => SWIGTYPE */
|
||||
Setitem(l, numitems-1, NewString("SWIGTYPE"));
|
||||
} else {
|
||||
def = NewString("a(ANY).");
|
||||
/* delete the only item, we are done with deduction */
|
||||
Delitem(l, 0);
|
||||
}
|
||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||
SwigType_del_array(nr);
|
||||
SwigType_add_default(def, nr);
|
||||
#else
|
||||
Append(def, "SWIGTYPE");
|
||||
#endif
|
||||
Delete(nr);
|
||||
}
|
||||
} else if (SwigType_ismemberpointer(r)) {
|
||||
if (strcmp(cr, "m(CLASS).SWIGTYPE") == 0) {
|
||||
def = NewString("p.SWIGTYPE");
|
||||
} else {
|
||||
def = NewString("m(CLASS).SWIGTYPE");
|
||||
}
|
||||
} else if (SwigType_isenum(r)) {
|
||||
if (strcmp(cr, "enum SWIGTYPE") == 0) {
|
||||
def = NewString("SWIGTYPE");
|
||||
} else {
|
||||
def = NewString("enum SWIGTYPE");
|
||||
}
|
||||
} else if (SwigType_isfunction(r)) {
|
||||
if (strcmp(cr, "f(ANY).SWIGTYPE") == 0) {
|
||||
def = NewString("p.SWIGTYPE");
|
||||
} else {
|
||||
def = NewString("p.f(ANY).SWIGTYPE");
|
||||
}
|
||||
} else {
|
||||
def = NewString("SWIGTYPE");
|
||||
assert(0);
|
||||
}
|
||||
if (r != t)
|
||||
|
||||
for (it = First(l); it.item; it = Next(it)) {
|
||||
Append(r, it.item);
|
||||
}
|
||||
|
||||
if (Len(r) == 0) {
|
||||
Delete(r);
|
||||
if (Equal(def, t)) {
|
||||
Delete(def);
|
||||
def = 0;
|
||||
r = 0;
|
||||
}
|
||||
#ifdef SWIG_DEFAULT_CACHE
|
||||
/* The cache produces strange results, see enum_template.i case */
|
||||
if (def) {
|
||||
String *cdef = Copy(def);
|
||||
Setattr(default_cache, t, cdef);
|
||||
Delete(cdef);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Printf(stderr,"type : def %s : %s\n", t, def); */
|
||||
|
||||
return def;
|
||||
Delete(l);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_namestr()
|
||||
*
|
||||
|
|
@ -539,7 +507,13 @@ String *SwigType_namestr(const SwigType *t) {
|
|||
Putc(' ', r);
|
||||
Putc('>', r);
|
||||
suffix = SwigType_templatesuffix(t);
|
||||
Append(r, suffix);
|
||||
if (Len(suffix) > 0) {
|
||||
String *suffix_namestr = SwigType_namestr(suffix);
|
||||
Append(r, suffix_namestr);
|
||||
Delete(suffix_namestr);
|
||||
} else {
|
||||
Append(r, suffix);
|
||||
}
|
||||
Delete(suffix);
|
||||
Delete(p);
|
||||
return r;
|
||||
|
|
@ -551,14 +525,19 @@ 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(const SwigType *s, const_String_or_char_ptr id) {
|
||||
String *result;
|
||||
String *element = 0, *nextelement;
|
||||
String *element = 0;
|
||||
String *nextelement;
|
||||
String *forwardelement;
|
||||
List *elements;
|
||||
int nelements, i;
|
||||
|
||||
if (id) {
|
||||
result = NewString(id);
|
||||
/* stringify the id expanding templates, for example when the id is a fully qualified templated class name */
|
||||
String *id_str = NewString(id); /* unfortunate copy due to current const limitations */
|
||||
result = SwigType_str(id_str, 0);
|
||||
Delete(id_str);
|
||||
} else {
|
||||
result = NewStringEmpty();
|
||||
}
|
||||
|
|
@ -573,8 +552,14 @@ String *SwigType_str(SwigType *s, const String_or_char *id) {
|
|||
for (i = 0; i < nelements; i++) {
|
||||
if (i < (nelements - 1)) {
|
||||
nextelement = Getitem(elements, i + 1);
|
||||
forwardelement = nextelement;
|
||||
if (SwigType_isqualifier(nextelement)) {
|
||||
if (i < (nelements - 2))
|
||||
forwardelement = Getitem(elements, i + 2);
|
||||
}
|
||||
} else {
|
||||
nextelement = 0;
|
||||
forwardelement = 0;
|
||||
}
|
||||
if (SwigType_isqualifier(element)) {
|
||||
DOH *q = 0;
|
||||
|
|
@ -584,7 +569,7 @@ String *SwigType_str(SwigType *s, const String_or_char *id) {
|
|||
Delete(q);
|
||||
} else if (SwigType_ispointer(element)) {
|
||||
Insert(result, 0, "*");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
|
|
@ -593,14 +578,14 @@ String *SwigType_str(SwigType *s, const String_or_char *id) {
|
|||
q = SwigType_parm(element);
|
||||
Insert(result, 0, "::*");
|
||||
Insert(result, 0, q);
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
Delete(q);
|
||||
} else if (SwigType_isreference(element)) {
|
||||
Insert(result, 0, "&");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
|
|
@ -643,12 +628,12 @@ String *SwigType_str(SwigType *s, const String_or_char *id) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_ltype(SwigType *ty)
|
||||
* SwigType_ltype(const SwigType *ty)
|
||||
*
|
||||
* Create a locally assignable type
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_ltype(SwigType *s) {
|
||||
SwigType *SwigType_ltype(const SwigType *s) {
|
||||
String *result;
|
||||
String *element;
|
||||
SwigType *td, *tc = 0;
|
||||
|
|
@ -746,7 +731,7 @@ SwigType *SwigType_ltype(SwigType *s) {
|
|||
* with an equivalent assignable version.
|
||||
* -------------------------------------------------------------------- */
|
||||
|
||||
String *SwigType_lstr(SwigType *s, const String_or_char *id) {
|
||||
String *SwigType_lstr(const SwigType *s, const_String_or_char_ptr id) {
|
||||
String *result;
|
||||
SwigType *tc;
|
||||
|
||||
|
|
@ -763,16 +748,19 @@ 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(const SwigType *s, const_String_or_char_ptr name) {
|
||||
String *result, *cast;
|
||||
String *element = 0, *nextelement;
|
||||
SwigType *td, *rs, *tc = 0;
|
||||
String *element = 0;
|
||||
String *nextelement;
|
||||
String *forwardelement;
|
||||
SwigType *td, *tc = 0;
|
||||
const SwigType *rs;
|
||||
List *elements;
|
||||
int nelements, i;
|
||||
int clear = 1;
|
||||
int firstarray = 1;
|
||||
int isreference = 0;
|
||||
int isarray = 0;
|
||||
int isfunction = 0;
|
||||
|
||||
result = NewStringEmpty();
|
||||
|
||||
|
|
@ -808,8 +796,14 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
|||
for (i = 0; i < nelements; i++) {
|
||||
if (i < (nelements - 1)) {
|
||||
nextelement = Getitem(elements, i + 1);
|
||||
forwardelement = nextelement;
|
||||
if (SwigType_isqualifier(nextelement)) {
|
||||
if (i < (nelements - 2))
|
||||
forwardelement = Getitem(elements, i + 2);
|
||||
}
|
||||
} else {
|
||||
nextelement = 0;
|
||||
forwardelement = 0;
|
||||
}
|
||||
if (SwigType_isqualifier(element)) {
|
||||
DOH *q = 0;
|
||||
|
|
@ -820,7 +814,7 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
|||
clear = 0;
|
||||
} else if (SwigType_ispointer(element)) {
|
||||
Insert(result, 0, "*");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
|
|
@ -831,18 +825,19 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
|||
q = SwigType_parm(element);
|
||||
Insert(result, 0, q);
|
||||
Delete(q);
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
firstarray = 0;
|
||||
} else if (SwigType_isreference(element)) {
|
||||
Insert(result, 0, "&");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
isreference = 1;
|
||||
if (!isfunction)
|
||||
isreference = 1;
|
||||
} else if (SwigType_isarray(element)) {
|
||||
DOH *size;
|
||||
if (firstarray && !isreference) {
|
||||
|
|
@ -856,7 +851,6 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
|||
Delete(size);
|
||||
clear = 0;
|
||||
}
|
||||
isarray = 1;
|
||||
} else if (SwigType_isfunction(element)) {
|
||||
DOH *parms, *p;
|
||||
int j, plen;
|
||||
|
|
@ -872,6 +866,7 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
|||
}
|
||||
Append(result, ")");
|
||||
Delete(parms);
|
||||
isfunction = 1;
|
||||
} else {
|
||||
String *bs = SwigType_namestr(element);
|
||||
Insert(result, 0, " ");
|
||||
|
|
@ -888,8 +883,6 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
|||
}
|
||||
if (name) {
|
||||
if (isreference) {
|
||||
if (isarray)
|
||||
Clear(cast);
|
||||
Append(cast, "*");
|
||||
}
|
||||
Append(cast, name);
|
||||
|
|
@ -906,7 +899,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(const SwigType *s, const_String_or_char_ptr name) {
|
||||
String *result;
|
||||
|
||||
result = NewStringEmpty();
|
||||
|
|
@ -932,27 +925,163 @@ String *SwigType_lcaststr(SwigType *s, const String_or_char *name) {
|
|||
return result;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Alternative implementation for manglestr_default. Mangling is similar to the original
|
||||
except for a few subtle differences for example in templates:
|
||||
namespace foo {
|
||||
template<class T> class bar {};
|
||||
typedef int Integer;
|
||||
void test2(bar<Integer *> *x);
|
||||
}
|
||||
Mangling is more consistent and changes from
|
||||
_p_foo__barT_int_p_t to
|
||||
_p_foo__barT_p_int_t.
|
||||
*/
|
||||
static void mangle_stringcopy(String *destination, const char *source, int count) {
|
||||
while (count-- > 0) {
|
||||
char newc = '_';
|
||||
if (!(*source == '.' || *source == ':' || *source == ' '))
|
||||
newc = *source;
|
||||
/* TODO: occasionally '*' or numerics need converting to '_', eg in array dimensions and template expressions */
|
||||
Putc(newc, destination);
|
||||
source++;
|
||||
}
|
||||
}
|
||||
|
||||
/* keep old mangling since Java codes need it */
|
||||
String *SwigType_manglestr_default(SwigType *s) {
|
||||
char *c;
|
||||
String *result = 0;
|
||||
String *base = 0;
|
||||
static void mangle_subtype(String *mangled, SwigType *s);
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* mangle_namestr()
|
||||
*
|
||||
* Mangles a type taking care of template expansions. Similar to SwigType_namestr().
|
||||
* The type may include a trailing '.', for example "p."
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void mangle_namestr(String *mangled, SwigType *t) {
|
||||
int length = Len(t);
|
||||
if (SwigType_isqualifier(t)) {
|
||||
Append(mangled, "q_");
|
||||
mangle_stringcopy(mangled, Char(t)+2, length-4);
|
||||
Append(mangled, "__");
|
||||
} else if (SwigType_ismemberpointer(t)) {
|
||||
Append(mangled, "m_");
|
||||
mangle_stringcopy(mangled, Char(t)+2, length-4);
|
||||
Append(mangled, "__");
|
||||
} else if (SwigType_isarray(t)) {
|
||||
Append(mangled, "a_");
|
||||
mangle_stringcopy(mangled, Char(t)+2, length-4);
|
||||
Append(mangled, "__");
|
||||
} else if (SwigType_isfunction(t)) {
|
||||
List *p = SwigType_parmlist(t);
|
||||
int sz = Len(p);
|
||||
int i;
|
||||
Append(mangled, "f_");
|
||||
for (i = 0; i < sz; i++) {
|
||||
mangle_subtype(mangled, Getitem(p, i));
|
||||
Putc('_', mangled);
|
||||
}
|
||||
Append(mangled, (sz > 0) ? "_" : "__");
|
||||
} else if (SwigType_isvarargs(t)) {
|
||||
Append(mangled, "___");
|
||||
} else {
|
||||
char *d = Char(t);
|
||||
char *c = strstr(d, "<(");
|
||||
if (!c || !strstr(c + 2, ")>")) {
|
||||
/* not a template type */
|
||||
mangle_stringcopy(mangled, Char(t), Len(t));
|
||||
} else {
|
||||
/* a template type */
|
||||
String *suffix;
|
||||
List *p;
|
||||
int i, sz;
|
||||
mangle_stringcopy(mangled, d, c-d);
|
||||
Putc('T', mangled);
|
||||
Putc('_', mangled);
|
||||
|
||||
p = SwigType_parmlist(c + 1);
|
||||
sz = Len(p);
|
||||
for (i = 0; i < sz; i++) {
|
||||
mangle_subtype(mangled, Getitem(p, i));
|
||||
Putc('_', mangled);
|
||||
}
|
||||
Putc('t', mangled);
|
||||
suffix = SwigType_templatesuffix(t);
|
||||
if (Len(suffix) > 0) {
|
||||
mangle_namestr(mangled, suffix);
|
||||
} else {
|
||||
Append(mangled, suffix);
|
||||
}
|
||||
Delete(suffix);
|
||||
Delete(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mangle_subtype(String *mangled, SwigType *s) {
|
||||
List *elements;
|
||||
int nelements, i;
|
||||
|
||||
assert(s);
|
||||
elements = SwigType_split(s);
|
||||
nelements = Len(elements);
|
||||
for (i = 0; i < nelements; i++) {
|
||||
SwigType *element = Getitem(elements, i);
|
||||
mangle_namestr(mangled, element);
|
||||
}
|
||||
Delete(elements);
|
||||
}
|
||||
|
||||
static String *manglestr_default(const SwigType *s) {
|
||||
String *mangled = NewString("_");
|
||||
SwigType *sr = SwigType_typedef_resolve_all(s);
|
||||
SwigType *sq = SwigType_typedef_qualified(sr);
|
||||
SwigType *ss = SwigType_remove_global_scope_prefix(sq);
|
||||
SwigType *type = ss;
|
||||
SwigType *lt;
|
||||
SwigType *sr = SwigType_typedef_qualified(s);
|
||||
SwigType *ss = SwigType_typedef_resolve_all(sr);
|
||||
|
||||
s = ss;
|
||||
|
||||
if (SwigType_istemplate(ss)) {
|
||||
SwigType *ty = Swig_symbol_template_deftype(ss, 0);
|
||||
Delete(ss);
|
||||
ss = ty;
|
||||
s = ss;
|
||||
type = ss;
|
||||
}
|
||||
|
||||
lt = SwigType_ltype(type);
|
||||
|
||||
Replace(lt, "struct ", "", DOH_REPLACE_ANY);
|
||||
Replace(lt, "class ", "", DOH_REPLACE_ANY);
|
||||
Replace(lt, "union ", "", DOH_REPLACE_ANY);
|
||||
Replace(lt, "enum ", "", DOH_REPLACE_ANY);
|
||||
|
||||
mangle_subtype(mangled, lt);
|
||||
|
||||
Delete(ss);
|
||||
Delete(sq);
|
||||
Delete(sr);
|
||||
|
||||
lt = SwigType_ltype(s);
|
||||
return mangled;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static String *manglestr_default(const SwigType *s) {
|
||||
char *c;
|
||||
String *result = 0;
|
||||
String *base = 0;
|
||||
SwigType *lt;
|
||||
SwigType *sr = SwigType_typedef_resolve_all(s);
|
||||
SwigType *sq = SwigType_typedef_qualified(sr);
|
||||
SwigType *ss = SwigType_remove_global_scope_prefix(sq);
|
||||
SwigType *type = ss;
|
||||
|
||||
if (SwigType_istemplate(ss)) {
|
||||
SwigType *ty = Swig_symbol_template_deftype(ss, 0);
|
||||
Delete(ss);
|
||||
ss = ty;
|
||||
type = ss;
|
||||
}
|
||||
|
||||
lt = SwigType_ltype(type);
|
||||
result = SwigType_prefix(lt);
|
||||
base = SwigType_base(lt);
|
||||
|
||||
|
|
@ -999,13 +1128,23 @@ String *SwigType_manglestr_default(SwigType *s) {
|
|||
Insert(result, 0, "_");
|
||||
Delete(lt);
|
||||
Delete(base);
|
||||
if (ss)
|
||||
Delete(ss);
|
||||
Delete(ss);
|
||||
Delete(sq);
|
||||
Delete(sr);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
String *SwigType_manglestr(SwigType *s) {
|
||||
return SwigType_manglestr_default(s);
|
||||
String *SwigType_manglestr(const SwigType *s) {
|
||||
#if 0
|
||||
/* Debugging checks to ensure a proper SwigType is passed in and not a stringified type */
|
||||
String *angle = Strstr(s, "<");
|
||||
if (angle && Strncmp(angle, "<(", 2) != 0)
|
||||
Printf(stderr, "SwigType_manglestr error: %s\n", s);
|
||||
else if (Strstr(s, "*") || Strstr(s, "&") || Strstr(s, "["))
|
||||
Printf(stderr, "SwigType_manglestr error: %s\n", s);
|
||||
#endif
|
||||
return manglestr_default(s);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -1099,13 +1238,32 @@ void SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
|
|||
Delete(elem);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_remove_global_scope_prefix()
|
||||
*
|
||||
* Removes the unary scope operator (::) prefix indicating global scope in all
|
||||
* components of the type
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_remove_global_scope_prefix(const SwigType *t) {
|
||||
SwigType *result;
|
||||
const char *type = Char(t);
|
||||
if (strncmp(type, "::", 2) == 0)
|
||||
type += 2;
|
||||
result = NewString(type);
|
||||
Replaceall(result, ".::", ".");
|
||||
Replaceall(result, "(::", "(");
|
||||
Replaceall(result, "enum ::", "enum ");
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_check_decl()
|
||||
*
|
||||
* Checks type declarators for a match
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_check_decl(SwigType *ty, const SwigType *decl) {
|
||||
int SwigType_check_decl(const SwigType *ty, const SwigType *decl) {
|
||||
SwigType *t, *t1, *t2;
|
||||
int r;
|
||||
t = SwigType_typedef_resolve_all(ty);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* swig.h
|
||||
*
|
||||
* Header file for the SWIG core.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef SWIGCORE_H_
|
||||
#define SWIGCORE_H_
|
||||
|
||||
|
|
@ -33,6 +35,10 @@ extern "C" {
|
|||
#define SWIG_ERROR 0
|
||||
#define SWIG_NOWRAP 0
|
||||
|
||||
/* Global macros */
|
||||
#define NSPACE_SEPARATOR "." /* Namespace separator for the nspace feature - this should be changed to a target language configurable variable */
|
||||
#define NSPACE_TODO 0 /* Languages that still need to implement and test the nspace feature use this */
|
||||
|
||||
/* Short names for common data types */
|
||||
|
||||
typedef DOH String;
|
||||
|
|
@ -110,121 +116,128 @@ 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);
|
||||
extern SwigType *SwigType_pop_function(SwigType *t);
|
||||
extern ParmList *SwigType_function_parms(SwigType *t);
|
||||
extern ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node);
|
||||
extern List *SwigType_split(const SwigType *t);
|
||||
extern String *SwigType_pop(SwigType *t);
|
||||
extern void SwigType_push(SwigType *t, SwigType *s);
|
||||
extern void SwigType_push(SwigType *t, String *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_manglestr(SwigType *t);
|
||||
extern SwigType *SwigType_ltype(SwigType *t);
|
||||
extern int SwigType_ispointer(SwigType *t);
|
||||
extern int SwigType_ispointer_return(SwigType *t);
|
||||
extern int SwigType_isfunctionpointer(SwigType *t);
|
||||
extern int SwigType_ismemberpointer(SwigType *t);
|
||||
extern int SwigType_isreference(SwigType *t);
|
||||
extern int SwigType_isreference_return(SwigType *t);
|
||||
extern int SwigType_isarray(SwigType *t);
|
||||
extern int SwigType_prefix_is_simple_1D_array(SwigType *t);
|
||||
extern int SwigType_isfunction(SwigType *t);
|
||||
extern int SwigType_isqualifier(SwigType *t);
|
||||
extern int SwigType_isconst(SwigType *t);
|
||||
extern int SwigType_issimple(SwigType *t);
|
||||
extern int SwigType_ismutable(SwigType *t);
|
||||
extern String *SwigType_parm(const SwigType *p);
|
||||
extern String *SwigType_str(const SwigType *s, const_String_or_char_ptr id);
|
||||
extern String *SwigType_lstr(const SwigType *s, const_String_or_char_ptr id);
|
||||
extern String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr id);
|
||||
extern String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr id);
|
||||
extern String *SwigType_manglestr(const SwigType *t);
|
||||
extern SwigType *SwigType_ltype(const SwigType *t);
|
||||
extern int SwigType_ispointer(const SwigType *t);
|
||||
extern int SwigType_ispointer_return(const SwigType *t);
|
||||
extern int SwigType_isfunctionpointer(const SwigType *t);
|
||||
extern int SwigType_ismemberpointer(const SwigType *t);
|
||||
extern int SwigType_isreference(const SwigType *t);
|
||||
extern int SwigType_isreference_return(const SwigType *t);
|
||||
extern int SwigType_isarray(const SwigType *t);
|
||||
extern int SwigType_prefix_is_simple_1D_array(const SwigType *t);
|
||||
extern int SwigType_isfunction(const SwigType *t);
|
||||
extern int SwigType_isqualifier(const SwigType *t);
|
||||
extern int SwigType_isconst(const SwigType *t);
|
||||
extern int SwigType_issimple(const SwigType *t);
|
||||
extern int SwigType_ismutable(const SwigType *t);
|
||||
extern int SwigType_isvarargs(const SwigType *t);
|
||||
extern int SwigType_istemplate(const SwigType *t);
|
||||
extern int SwigType_isenum(SwigType *t);
|
||||
extern int SwigType_isbuiltin(SwigType *t);
|
||||
extern int SwigType_check_decl(SwigType *t, const String_or_char *decl);
|
||||
extern SwigType *SwigType_strip_qualifiers(SwigType *t);
|
||||
extern int SwigType_isenum(const SwigType *t);
|
||||
extern int SwigType_check_decl(const SwigType *t, const_String_or_char_ptr decl);
|
||||
extern SwigType *SwigType_strip_qualifiers(const SwigType *t);
|
||||
extern SwigType *SwigType_strip_single_qualifier(const SwigType *t);
|
||||
extern SwigType *SwigType_functionpointer_decompose(SwigType *t);
|
||||
extern String *SwigType_base(const SwigType *t);
|
||||
extern String *SwigType_namestr(const SwigType *t);
|
||||
extern String *SwigType_templateprefix(const SwigType *t);
|
||||
extern String *SwigType_templatesuffix(const SwigType *t);
|
||||
extern String *SwigType_istemplate_templateprefix(const SwigType *t);
|
||||
extern String *SwigType_istemplate_only_templateprefix(const SwigType *t);
|
||||
extern String *SwigType_templateargs(const SwigType *t);
|
||||
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 SwigType *SwigType_array_type(SwigType *t);
|
||||
extern String *SwigType_default(SwigType *t);
|
||||
extern int SwigType_array_ndim(const SwigType *t);
|
||||
extern String *SwigType_array_getdim(const SwigType *t, int n);
|
||||
extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep);
|
||||
extern SwigType *SwigType_array_type(const SwigType *t);
|
||||
extern SwigType *SwigType_default_create(const SwigType *ty);
|
||||
extern SwigType *SwigType_default_deduce(const SwigType *t);
|
||||
extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
|
||||
extern SwigType *SwigType_alttype(SwigType *t, int ltmap);
|
||||
|
||||
extern void SwigType_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
|
||||
extern SwigType *SwigType_template_deftype(const SwigType *type, Symtab *tscope);
|
||||
extern SwigType *SwigType_remove_global_scope_prefix(const SwigType *t);
|
||||
extern SwigType *SwigType_alttype(const SwigType *t, int ltmap);
|
||||
|
||||
/* --- 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(const 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 int SwigType_issubtype(const SwigType *subtype, const 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_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_print_scope(void);
|
||||
extern SwigType *SwigType_typedef_resolve(const SwigType *t);
|
||||
extern SwigType *SwigType_typedef_resolve_all(const SwigType *t);
|
||||
extern SwigType *SwigType_typedef_qualified(const SwigType *t);
|
||||
extern int SwigType_istypedef(const SwigType *t);
|
||||
extern int SwigType_isclass(const 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_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *);
|
||||
extern void SwigType_remember(const SwigType *t);
|
||||
extern void SwigType_remember_clientdata(const 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) (const SwigType *, String *, String *))) (const SwigType *, String *, String *);
|
||||
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
|
||||
extern int SwigType_type(SwigType *t);
|
||||
extern int SwigType_type(const SwigType *t);
|
||||
|
||||
/* --- Symbol table module --- */
|
||||
|
||||
extern void Swig_symbol_print_tables(Symtab *symtab);
|
||||
extern void Swig_symbol_print_tables_summary(void);
|
||||
extern void Swig_symbol_print_symbols(void);
|
||||
extern void Swig_symbol_print_csymbols(void);
|
||||
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 String *Swig_symbol_qualified_language_scopename(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_global_scope(void);
|
||||
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);
|
||||
extern SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab);
|
||||
extern SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab);
|
||||
|
||||
extern ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
|
||||
extern SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope);
|
||||
|
|
@ -247,17 +260,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 nspace, const_String_or_char_ptr classname, const_String_or_char_ptr membername);
|
||||
extern String *Swig_name_get(const_String_or_char_ptr nspace, const_String_or_char_ptr vname);
|
||||
extern String *Swig_name_set(const_String_or_char_ptr nspace, const_String_or_char_ptr vname);
|
||||
extern String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_copyconstructor(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_disown(const_String_or_char_ptr nspace, 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);
|
||||
|
|
@ -268,79 +281,84 @@ 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_str(Node *n);
|
||||
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_new_subdirectory(String *basedirectory, String *subdirectory);
|
||||
extern void Swig_filename_correct(String *filename);
|
||||
extern String *Swig_filename_escape(String *filename);
|
||||
extern void Swig_filename_unescape(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);
|
||||
|
||||
extern String *Swig_pcre_version(void);
|
||||
extern void Swig_init(void);
|
||||
extern void Swig_warn(const char *filename, int line, const char *msg);
|
||||
|
||||
extern int Swig_value_wrapper_mode(int mode);
|
||||
|
||||
|
||||
#define WARNING(msg) Swig_warn(__FILE__,__LINE__,msg)
|
||||
|
||||
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);
|
||||
extern void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...);
|
||||
extern String *Swig_stringify_with_location(DOH *object);
|
||||
|
||||
/* --- C Wrappers --- */
|
||||
extern void Swig_cresult_name_set(const char *new_name);
|
||||
extern const char *Swig_cresult_name(void);
|
||||
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);
|
||||
|
||||
/* --- Transformations --- */
|
||||
|
||||
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_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director);
|
||||
extern int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags);
|
||||
extern int Swig_DestructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int cplus, int flags);
|
||||
extern int Swig_MembersetToFunction(Node *n, String *classname, int flags);
|
||||
extern int Swig_MembergetToFunction(Node *n, String *classname, int flags);
|
||||
extern int Swig_VargetToFunction(Node *n, int flags);
|
||||
|
|
@ -352,6 +370,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
#define CWRAP_DIRECTOR_ONE_CALL 0x08
|
||||
#define CWRAP_DIRECTOR_TWO_CALLS 0x10
|
||||
#define CWRAP_ALL_PROTECTED_ACCESS 0x20
|
||||
#define CWRAP_SMART_POINTER_OVERLOAD 0x40
|
||||
|
||||
/* --- Director Helpers --- */
|
||||
extern Node *Swig_methodclass(Node *n);
|
||||
|
|
@ -361,22 +380,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 tmap_method, ParmList *pattern, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs);
|
||||
extern int Swig_typemap_copy(const_String_or_char_ptr tmap_method, ParmList *srcpattern, ParmList *pattern);
|
||||
extern void Swig_typemap_clear(const_String_or_char_ptr tmap_method, 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 void Swig_typemap_search_debug_set(void);
|
||||
extern void Swig_typemap_used_debug_set(void);
|
||||
extern void Swig_typemap_register_debug_set(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 String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f);
|
||||
extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode);
|
||||
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 tmap_method, ParmList *parms, Wrapper *f);
|
||||
|
||||
/* --- Code fragment support --- */
|
||||
|
||||
|
|
@ -391,6 +410,9 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern void Wrapper_director_mode_set(int);
|
||||
extern void Wrapper_director_protected_mode_set(int);
|
||||
extern void Wrapper_all_protected_mode_set(int);
|
||||
extern void Language_replace_special_variables(String *method, String *tm, Parm *parm);
|
||||
extern void Swig_print(DOH *object, int count);
|
||||
extern void Swig_print_with_location(DOH *object, int count);
|
||||
|
||||
|
||||
/* -- template init -- */
|
||||
|
|
|
|||
|
|
@ -1,32 +1,36 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* swigfile.h
|
||||
*
|
||||
* File handling functions in the SWIG core
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $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);
|
||||
extern void Swig_file_debug_set();
|
||||
|
||||
/* Delimiter used in accessing files and directories */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* swigopt.h
|
||||
*
|
||||
* Header file for the SWIG command line processing functions
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9622 2006-12-19 03:49:17Z beazley $ */
|
||||
|
||||
extern void Swig_init_args(int argc, char **argv);
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* swigparm.h
|
||||
*
|
||||
|
|
@ -8,10 +12,9 @@
|
|||
* parameter lists.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $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, Node *file_line_node);
|
||||
extern Parm *NewParmWithoutFileLineInfo(SwigType *type, const_String_or_char_ptr name);
|
||||
extern Parm *CopyParm(Parm *p);
|
||||
|
||||
/* Parameter lists */
|
||||
|
|
@ -24,6 +27,7 @@ extern int ParmList_has_defaultargs(ParmList *p);
|
|||
/* Output functions */
|
||||
extern String *ParmList_str(ParmList *);
|
||||
extern String *ParmList_str_defaultargs(ParmList *);
|
||||
extern String *ParmList_str_multibrackets(ParmList *);
|
||||
extern String *ParmList_protostr(ParmList *);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,23 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* swigscan.h
|
||||
*
|
||||
* C/C++ scanner.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9633 2007-01-10 23:43:07Z beazley $ */
|
||||
|
||||
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 *);
|
||||
|
|
@ -28,7 +30,7 @@ extern void Scanner_idstart(Scanner *, const char *idchar);
|
|||
extern String *Scanner_errmsg(Scanner *);
|
||||
extern int Scanner_errline(Scanner *);
|
||||
extern int Scanner_isoperator(int tokval);
|
||||
extern void Scanner_freeze_line(Scanner *s, int val);
|
||||
extern void Scanner_locator(Scanner *, String *loc);
|
||||
|
||||
/* Note: Tokens in range 100+ are for C/C++ operators */
|
||||
|
||||
|
|
@ -64,6 +66,7 @@ extern void Scanner_freeze_line(Scanner *s, int val);
|
|||
#define SWIG_TOKEN_ULONGLONG 29 /* 314ULL */
|
||||
#define SWIG_TOKEN_QUESTION 30 /* ? */
|
||||
#define SWIG_TOKEN_COMMENT 31 /* C or C++ comment */
|
||||
#define SWIG_TOKEN_BOOL 32 /* true or false */
|
||||
#define SWIG_TOKEN_ILLEGAL 99
|
||||
#define SWIG_TOKEN_ERROR -1
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* swigtree.h
|
||||
*
|
||||
|
|
@ -9,8 +13,6 @@
|
|||
* and function names are meant to be similar.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9622 2006-12-19 03:49:17Z beazley $ */
|
||||
|
||||
/* Macros to traverse the DOM tree */
|
||||
|
||||
#define nodeType(x) Getattr(x,"nodeType")
|
||||
|
|
@ -31,7 +33,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);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* swigwrap.h
|
||||
*
|
||||
* Functions related to wrapper objects.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9635 2007-01-12 01:44:16Z beazley $ */
|
||||
|
||||
typedef struct Wrapper {
|
||||
Hash *localh;
|
||||
String *def;
|
||||
|
|
@ -16,14 +18,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, ...);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* symbol.c
|
||||
*
|
||||
|
|
@ -175,20 +179,83 @@ static Hash *global_scope = 0; /* Global scope */
|
|||
/* common attribute keys, to avoid calling find_key all the times */
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_print_tables()
|
||||
*
|
||||
* Debug display of symbol tables
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#if 0
|
||||
void Swig_symbol_dump_symtable() {
|
||||
Printf(stdout, "DUMPING SYMTABLE start =======================================\n");
|
||||
{
|
||||
Hash *cst = Getattr(current_symtab, "csymtab");
|
||||
Swig_print_tree(cst);
|
||||
/*
|
||||
Swig_print_tree(Getattr(cst, "NumSpace"));
|
||||
*/
|
||||
}
|
||||
Printf(stdout, "DUMPING SYMTABLE end =======================================\n");
|
||||
void Swig_symbol_print_tables(Symtab *symtab) {
|
||||
if (!symtab)
|
||||
symtab = current_symtab;
|
||||
|
||||
Printf(stdout, "SYMBOL TABLES start =======================================\n");
|
||||
Swig_print_tree(symtab);
|
||||
Printf(stdout, "SYMBOL TABLES finish =======================================\n");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_print_tables_summary()
|
||||
*
|
||||
* Debug summary display of all symbol tables by fully-qualified name
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_symbol_print_tables_summary(void) {
|
||||
Printf(stdout, "SYMBOL TABLES SUMMARY start =======================================\n");
|
||||
Swig_print_node(symtabs);
|
||||
Printf(stdout, "SYMBOL TABLES SUMMARY finish =======================================\n");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* symbol_print_symbols()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void symbol_print_symbols(const char *symboltabletype) {
|
||||
Node *table = symtabs;
|
||||
Iterator ki = First(table);
|
||||
while (ki.key) {
|
||||
String *k = ki.key;
|
||||
Printf(stdout, "===================================================\n");
|
||||
Printf(stdout, "%s -\n", k);
|
||||
{
|
||||
Symtab *symtab = Getattr(Getattr(table, k), symboltabletype);
|
||||
Iterator it = First(symtab);
|
||||
while (it.key) {
|
||||
String *symname = it.key;
|
||||
Printf(stdout, " %s\n", symname);
|
||||
/*
|
||||
Printf(stdout, " %s - %p (%s)\n", symname, it.item, Getattr(it.item, "name"));
|
||||
*/
|
||||
it = Next(it);
|
||||
}
|
||||
}
|
||||
ki = Next(ki);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_print_symbols()
|
||||
*
|
||||
* Debug display of all the target language symbols
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_symbol_print_symbols(void) {
|
||||
Printf(stdout, "SYMBOLS start =======================================\n");
|
||||
symbol_print_symbols("symtab");
|
||||
Printf(stdout, "SYMBOLS finish =======================================\n");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_print_csymbols()
|
||||
*
|
||||
* Debug display of all the C symbols
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_symbol_print_csymbols(void) {
|
||||
Printf(stdout, "CSYMBOLS start =======================================\n");
|
||||
symbol_print_symbols("csymtab");
|
||||
Printf(stdout, "CSYMBOLS finish =======================================\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_init()
|
||||
|
|
@ -196,7 +263,7 @@ void Swig_symbol_dump_symtable() {
|
|||
* Create a new symbol table object
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_symbol_init() {
|
||||
void Swig_symbol_init(void) {
|
||||
|
||||
current = NewHash();
|
||||
current_symtab = NewHash();
|
||||
|
|
@ -220,7 +287,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);
|
||||
|
|
@ -240,7 +307,7 @@ void Swig_symbol_setscopename(const String_or_char *name) {
|
|||
* Get the C scopename of the current symbol table
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_symbol_getscopename() {
|
||||
String *Swig_symbol_getscopename(void) {
|
||||
return Getattr(current_symtab, "name");
|
||||
}
|
||||
|
||||
|
|
@ -250,10 +317,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);
|
||||
}
|
||||
|
|
@ -289,13 +356,28 @@ String *Swig_symbol_qualifiedscopename(Symtab *symtab) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_qualified_language_scopename()
|
||||
*
|
||||
* Get the fully qualified C scopename of a symbol table but using a language
|
||||
* specific separator for the scopenames. Basically the same as
|
||||
* Swig_symbol_qualifiedscopename() but using the different separator.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_symbol_qualified_language_scopename(Symtab *n) {
|
||||
/* TODO: fix for %rename to work */
|
||||
String *result = Swig_symbol_qualifiedscopename(n);
|
||||
Replaceall(result, "::", NSPACE_SEPARATOR);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_newscope()
|
||||
*
|
||||
* Create a new scope. Returns the newly created scope.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Symtab *Swig_symbol_newscope() {
|
||||
Symtab *Swig_symbol_newscope(void) {
|
||||
Hash *n;
|
||||
Hash *hsyms, *h;
|
||||
|
||||
|
|
@ -346,7 +428,7 @@ Symtab *Swig_symbol_setscope(Symtab *sym) {
|
|||
* scope to the parent scope.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Symtab *Swig_symbol_popscope() {
|
||||
Symtab *Swig_symbol_popscope(void) {
|
||||
Hash *h = current_symtab;
|
||||
current_symtab = Getattr(current_symtab, "parentNode");
|
||||
assert(current_symtab);
|
||||
|
|
@ -357,13 +439,23 @@ Symtab *Swig_symbol_popscope() {
|
|||
return h;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_global_scope()
|
||||
*
|
||||
* Return the symbol table for the global scope.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Symtab *Swig_symbol_global_scope(void) {
|
||||
return global_scope;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_current()
|
||||
*
|
||||
* Return the current symbol table.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Symtab *Swig_symbol_current() {
|
||||
Symtab *Swig_symbol_current(void) {
|
||||
return current_symtab;
|
||||
}
|
||||
|
||||
|
|
@ -373,7 +465,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 +513,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 +686,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 +919,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");
|
||||
|
|
@ -871,6 +963,7 @@ static Node *_symbol_lookup(String *name, Symtab *symtab, int (*check) (Node *n)
|
|||
Delete(dname);
|
||||
if (n)
|
||||
return n;
|
||||
Setmark(symtab, 1);
|
||||
}
|
||||
|
||||
inherit = Getattr(symtab, "inherit");
|
||||
|
|
@ -890,7 +983,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 +1001,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 +1021,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 +1031,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 +1069,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;
|
||||
|
||||
|
|
@ -996,6 +1091,8 @@ Node *Swig_symbol_clookup(String_or_char *name, Symtab *n) {
|
|||
String *nname = NewString(cname + 2);
|
||||
if (Swig_scopename_check(nname)) {
|
||||
s = symbol_lookup_qualified(nname, global_scope, 0, 0, 0);
|
||||
} else {
|
||||
s = symbol_lookup(nname, global_scope, 0);
|
||||
}
|
||||
Delete(nname);
|
||||
} else {
|
||||
|
|
@ -1046,7 +1143,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;
|
||||
|
||||
|
|
@ -1068,6 +1165,8 @@ Node *Swig_symbol_clookup_check(String_or_char *name, Symtab *n, int (*checkfunc
|
|||
String *nname = NewString(cname + 2);
|
||||
if (Swig_scopename_check(nname)) {
|
||||
s = symbol_lookup_qualified(nname, global_scope, 0, 0, checkfunc);
|
||||
} else {
|
||||
s = symbol_lookup(nname, global_scope, checkfunc);
|
||||
}
|
||||
Delete(nname);
|
||||
} else {
|
||||
|
|
@ -1110,20 +1209,18 @@ 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) {
|
||||
Hash *h, *hsym;
|
||||
Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) {
|
||||
Hash *hsym;
|
||||
Node *s = 0;
|
||||
|
||||
if (!n) {
|
||||
hsym = current_symtab;
|
||||
h = ccurrent;
|
||||
} else {
|
||||
if (!Checkattr(n, "nodeType", "symboltable")) {
|
||||
n = Getattr(n, "sym:symtab");
|
||||
}
|
||||
assert(n);
|
||||
hsym = n;
|
||||
h = Getattr(n, "csymtab");
|
||||
}
|
||||
|
||||
if (Swig_scopename_check(name)) {
|
||||
|
|
@ -1132,6 +1229,8 @@ Node *Swig_symbol_clookup_local(String_or_char *name, Symtab *n) {
|
|||
String *nname = NewString(cname + 2);
|
||||
if (Swig_scopename_check(nname)) {
|
||||
s = symbol_lookup_qualified(nname, global_scope, 0, 0, 0);
|
||||
} else {
|
||||
s = symbol_lookup(nname, global_scope, 0);
|
||||
}
|
||||
Delete(nname);
|
||||
} else {
|
||||
|
|
@ -1158,20 +1257,18 @@ 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 *)) {
|
||||
Hash *h, *hsym;
|
||||
Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *)) {
|
||||
Hash *hsym;
|
||||
Node *s = 0;
|
||||
|
||||
if (!n) {
|
||||
hsym = current_symtab;
|
||||
h = ccurrent;
|
||||
} else {
|
||||
if (!Checkattr(n, "nodeType", "symboltable")) {
|
||||
n = Getattr(n, "sym:symtab");
|
||||
}
|
||||
assert(n);
|
||||
hsym = n;
|
||||
h = Getattr(n, "csymtab");
|
||||
}
|
||||
|
||||
if (Swig_scopename_check(name)) {
|
||||
|
|
@ -1180,6 +1277,8 @@ Node *Swig_symbol_clookup_local_check(String_or_char *name, Symtab *n, int (*che
|
|||
String *nname = NewString(cname + 2);
|
||||
if (Swig_scopename_check(nname)) {
|
||||
s = symbol_lookup_qualified(nname, global_scope, 0, 0, checkfunc);
|
||||
} else {
|
||||
s = symbol_lookup(nname, global_scope, checkfunc);
|
||||
}
|
||||
Delete(nname);
|
||||
} else {
|
||||
|
|
@ -1209,7 +1308,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);
|
||||
|
|
@ -1251,7 +1350,8 @@ void Swig_symbol_remove(Node *n) {
|
|||
Setattr(symtab, symname, symnext);
|
||||
fixovername = symnext; /* fix as symbol to remove is at head of linked list */
|
||||
} else {
|
||||
Delattr(symtab, symname);
|
||||
if (symname)
|
||||
Delattr(symtab, symname);
|
||||
}
|
||||
}
|
||||
if (symnext) {
|
||||
|
|
@ -1542,7 +1642,7 @@ SwigType *Swig_symbol_template_reduce(SwigType *qt, Symtab *ntab) {
|
|||
* Chase a typedef through symbol tables looking for a match.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
|
||||
SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab) {
|
||||
SwigType *prefix, *base;
|
||||
Node *n;
|
||||
String *nt;
|
||||
|
|
@ -1649,8 +1749,9 @@ String *Swig_symbol_string_qualify(String *s, Symtab *st) {
|
|||
String *id = NewStringEmpty();
|
||||
String *r = NewStringEmpty();
|
||||
char *c = Char(s);
|
||||
int first_char = 1;
|
||||
while (*c) {
|
||||
if (isalpha((int) *c) || (*c == '_') || (*c == ':')) {
|
||||
if (isalpha((int) *c) || (*c == '_') || (*c == ':') || (isdigit((int) *c) && !first_char)) {
|
||||
Putc(*c, id);
|
||||
have_id = 1;
|
||||
} else {
|
||||
|
|
@ -1663,6 +1764,7 @@ String *Swig_symbol_string_qualify(String *s, Symtab *st) {
|
|||
}
|
||||
Putc(*c, r);
|
||||
}
|
||||
first_char = (*c == ':');
|
||||
c++;
|
||||
}
|
||||
if (have_id) {
|
||||
|
|
@ -1726,7 +1828,7 @@ ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope,
|
|||
ntq = ty;
|
||||
}
|
||||
/* Printf(stderr,"value %s %s %s\n",value,ntr,ntq); */
|
||||
cp = NewParm(ntq, 0);
|
||||
cp = NewParmWithoutFileLineInfo(ntq, 0);
|
||||
if (lp)
|
||||
set_nextSibling(lp, cp);
|
||||
else
|
||||
|
|
@ -1803,7 +1905,7 @@ SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) {
|
|||
String *tprefix = SwigType_templateprefix(base);
|
||||
String *targs = SwigType_templateargs(base);
|
||||
String *tsuffix = SwigType_templatesuffix(base);
|
||||
ParmList *tparms = SwigType_function_parms(targs);
|
||||
ParmList *tparms = SwigType_function_parms(targs, 0);
|
||||
Node *tempn = Swig_symbol_clookup_local(tprefix, tscope);
|
||||
if (!tempn && tsuffix && Len(tsuffix)) {
|
||||
tempn = Swig_symbol_clookup(tprefix, 0);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* tree.c
|
||||
*
|
||||
|
|
@ -30,7 +34,7 @@ void Swig_print_tags(DOH *obj, DOH *root) {
|
|||
croot = root;
|
||||
|
||||
while (obj) {
|
||||
Printf(stdout, "%s . %s (%s:%d)\n", croot, nodeType(obj), Getfile(obj), Getline(obj));
|
||||
Swig_diagnostic(Getfile(obj), Getline(obj), "%s . %s\n", croot, nodeType(obj));
|
||||
cobj = firstChild(obj);
|
||||
if (cobj) {
|
||||
newroot = NewStringf("%s . %s", croot, nodeType(obj));
|
||||
|
|
@ -229,7 +233,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;
|
||||
}
|
||||
|
|
@ -268,7 +272,7 @@ void Swig_require(const char *ns, Node *n, ...) {
|
|||
}
|
||||
obj = Getattr(n, name);
|
||||
if (!opt && !obj) {
|
||||
Printf(stderr, "%s:%d. Fatal error (Swig_require). Missing attribute '%s' in node '%s'.\n", Getfile(n), Getline(n), name, nodeType(n));
|
||||
Swig_error(Getfile(n), Getline(n), "Fatal error (Swig_require). Missing attribute '%s' in node '%s'.\n", name, nodeType(n));
|
||||
assert(obj);
|
||||
}
|
||||
if (!obj)
|
||||
|
|
@ -287,10 +291,10 @@ void Swig_require(const char *ns, Node *n, ...) {
|
|||
if (view) {
|
||||
if (Strcmp(view, ns) != 0) {
|
||||
Setattr(n, NewStringf("%s:view", ns), view);
|
||||
Setattr(n, "view", ns);
|
||||
Setattr(n, "view", NewString(ns));
|
||||
}
|
||||
} else {
|
||||
Setattr(n, "view", ns);
|
||||
Setattr(n, "view", NewString(ns));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -333,10 +337,10 @@ void Swig_save(const char *ns, Node *n, ...) {
|
|||
if (view) {
|
||||
if (Strcmp(view, ns) != 0) {
|
||||
Setattr(n, NewStringf("%s:view", ns), view);
|
||||
Setattr(n, "view", ns);
|
||||
Setattr(n, "view", NewString(ns));
|
||||
}
|
||||
} else {
|
||||
Setattr(n, "view", ns);
|
||||
Setattr(n, "view", NewString(ns));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* typeobj.c
|
||||
*
|
||||
|
|
@ -46,6 +50,9 @@ char cvsroot_typeobj_c[] = "$Id$";
|
|||
* 'q(str).' = Qualifier (such as const or volatile) (const, volatile)
|
||||
* 'm(qual).' = Pointer to member (qual::*)
|
||||
*
|
||||
* The complete type representation for varargs is:
|
||||
* 'v(...)'
|
||||
*
|
||||
* The encoding follows the order that you might describe a type in words.
|
||||
* For example "p.a(200).int" is "A pointer to array of int's" and
|
||||
* "p.q(const).char" is "a pointer to a const char".
|
||||
|
|
@ -110,7 +117,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);
|
||||
}
|
||||
|
||||
|
|
@ -173,6 +180,9 @@ SwigType *SwigType_del_element(SwigType *t) {
|
|||
* SwigType_pop()
|
||||
*
|
||||
* Pop one type element off the type.
|
||||
* Example: t in: q(const).p.Integer
|
||||
* t out: p.Integer
|
||||
* result: q(const).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_pop(SwigType *t) {
|
||||
|
|
@ -200,7 +210,7 @@ SwigType *SwigType_pop(SwigType *t) {
|
|||
* Returns the parameter of an operator as a string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *SwigType_parm(SwigType *t) {
|
||||
String *SwigType_parm(const SwigType *t) {
|
||||
char *start, *c;
|
||||
int nparens = 0;
|
||||
|
||||
|
|
@ -352,7 +362,7 @@ SwigType *SwigType_del_pointer(SwigType *t) {
|
|||
return t;
|
||||
}
|
||||
|
||||
int SwigType_ispointer(SwigType *t) {
|
||||
int SwigType_ispointer(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -394,7 +404,7 @@ SwigType *SwigType_del_reference(SwigType *t) {
|
|||
return t;
|
||||
}
|
||||
|
||||
int SwigType_isreference(SwigType *t) {
|
||||
int SwigType_isreference(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -419,7 +429,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;
|
||||
|
|
@ -484,7 +494,7 @@ SwigType *SwigType_del_qualifier(SwigType *t) {
|
|||
return t;
|
||||
}
|
||||
|
||||
int SwigType_isqualifier(SwigType *t) {
|
||||
int SwigType_isqualifier(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -499,7 +509,7 @@ int SwigType_isqualifier(SwigType *t) {
|
|||
* Function Pointers
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_isfunctionpointer(SwigType *t) {
|
||||
int SwigType_isfunctionpointer(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -537,7 +547,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);
|
||||
|
|
@ -552,7 +562,7 @@ SwigType *SwigType_del_memberpointer(SwigType *t) {
|
|||
return t;
|
||||
}
|
||||
|
||||
int SwigType_ismemberpointer(SwigType *t) {
|
||||
int SwigType_ismemberpointer(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -579,7 +589,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));
|
||||
|
|
@ -596,7 +606,7 @@ SwigType *SwigType_del_array(SwigType *t) {
|
|||
return t;
|
||||
}
|
||||
|
||||
int SwigType_isarray(SwigType *t) {
|
||||
int SwigType_isarray(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -612,7 +622,7 @@ int SwigType_isarray(SwigType *t) {
|
|||
* Determine if the type is a 1D array type that is treated as a pointer within SWIG
|
||||
* eg Foo[], Foo[3] return true, but Foo[3][3], Foo*[], Foo*[3], Foo**[] return false
|
||||
*/
|
||||
int SwigType_prefix_is_simple_1D_array(SwigType *t) {
|
||||
int SwigType_prefix_is_simple_1D_array(const SwigType *t) {
|
||||
char *c = Char(t);
|
||||
|
||||
if (c && (strncmp(c, "a(", 2) == 0)) {
|
||||
|
|
@ -638,7 +648,7 @@ SwigType *SwigType_pop_arrays(SwigType *t) {
|
|||
}
|
||||
|
||||
/* Return number of array dimensions */
|
||||
int SwigType_array_ndim(SwigType *t) {
|
||||
int SwigType_array_ndim(const SwigType *t) {
|
||||
int ndim = 0;
|
||||
char *c = Char(t);
|
||||
|
||||
|
|
@ -651,7 +661,7 @@ int SwigType_array_ndim(SwigType *t) {
|
|||
}
|
||||
|
||||
/* Get nth array dimension */
|
||||
String *SwigType_array_getdim(SwigType *t, int n) {
|
||||
String *SwigType_array_getdim(const SwigType *t, int n) {
|
||||
char *c = Char(t);
|
||||
while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) {
|
||||
c = strchr(c, '.');
|
||||
|
|
@ -673,7 +683,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;
|
||||
|
|
@ -703,7 +713,7 @@ void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep) {
|
|||
}
|
||||
|
||||
/* Return base type of an array */
|
||||
SwigType *SwigType_array_type(SwigType *ty) {
|
||||
SwigType *SwigType_array_type(const SwigType *ty) {
|
||||
SwigType *t;
|
||||
t = Copy(ty);
|
||||
while (SwigType_isarray(t)) {
|
||||
|
|
@ -761,7 +771,7 @@ SwigType *SwigType_pop_function(SwigType *t) {
|
|||
return g;
|
||||
}
|
||||
|
||||
int SwigType_isfunction(SwigType *t) {
|
||||
int SwigType_isfunction(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t) {
|
||||
return 0;
|
||||
|
|
@ -781,13 +791,15 @@ int SwigType_isfunction(SwigType *t) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
ParmList *SwigType_function_parms(SwigType *t) {
|
||||
/* Create a list of parameters from the type t, using the file_line_node Node for
|
||||
* file and line numbering for the parameters */
|
||||
ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node) {
|
||||
List *l = SwigType_parmlist(t);
|
||||
Hash *p, *pp = 0, *firstp = 0;
|
||||
Iterator o;
|
||||
|
||||
for (o = First(l); o.item; o = Next(o)) {
|
||||
p = NewParm(o.item, 0);
|
||||
p = file_line_node ? NewParm(o.item, 0, file_line_node) : NewParmWithoutFileLineInfo(o.item, 0);
|
||||
if (!firstp)
|
||||
firstp = p;
|
||||
if (pp) {
|
||||
|
|
@ -850,11 +862,12 @@ SwigType *SwigType_add_template(SwigType *t, ParmList *parms) {
|
|||
* SwigType_templateprefix()
|
||||
*
|
||||
* Returns the prefix before the first template definition.
|
||||
* Returns the type unmodified if not a template.
|
||||
* For example:
|
||||
*
|
||||
* Foo<(p.int)>::bar
|
||||
*
|
||||
* returns "Foo"
|
||||
* Foo<(p.int)>::bar => Foo
|
||||
* r.q(const).Foo<(p.int)>::bar => r.q(const).Foo
|
||||
* Foo => Foo
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *SwigType_templateprefix(const SwigType *t) {
|
||||
|
|
@ -895,6 +908,51 @@ String *SwigType_templatesuffix(const SwigType *t) {
|
|||
return NewStringEmpty();
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_istemplate_templateprefix()
|
||||
*
|
||||
* Combines SwigType_istemplate and SwigType_templateprefix efficiently into one function.
|
||||
* Returns the prefix before the first template definition.
|
||||
* Returns NULL if not a template.
|
||||
* For example:
|
||||
*
|
||||
* Foo<(p.int)>::bar => Foo
|
||||
* r.q(const).Foo<(p.int)>::bar => r.q(const).Foo
|
||||
* Foo => NULL
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *SwigType_istemplate_templateprefix(const SwigType *t) {
|
||||
const char *s = Char(t);
|
||||
const char *c = strstr(s, "<(");
|
||||
return c ? NewStringWithSize(s, c - s) : 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_istemplate_only_templateprefix()
|
||||
*
|
||||
* Similar to SwigType_istemplate_templateprefix() but only returns the template
|
||||
* prefix if the type is just the template and not a subtype/symbol within the template.
|
||||
* Returns NULL if not a template or is a template with a symbol within the template.
|
||||
* For example:
|
||||
*
|
||||
* Foo<(p.int)> => Foo
|
||||
* Foo<(p.int)>::bar => NULL
|
||||
* r.q(const).Foo<(p.int)> => r.q(const).Foo
|
||||
* r.q(const).Foo<(p.int)>::bar => NULL
|
||||
* Foo => NULL
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *SwigType_istemplate_only_templateprefix(const SwigType *t) {
|
||||
int len = Len(t);
|
||||
const char *s = Char(t);
|
||||
if (len >= 4 && strcmp(s + len - 2, ")>") == 0) {
|
||||
const char *c = strstr(s, "<(");
|
||||
return c ? NewStringWithSize(s, c - s) : 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_templateargs()
|
||||
*
|
||||
|
|
@ -937,7 +995,8 @@ String *SwigType_templateargs(const SwigType *t) {
|
|||
|
||||
int SwigType_istemplate(const SwigType *t) {
|
||||
char *ct = Char(t);
|
||||
if ((ct = strstr(ct, "<(")) && (strstr(ct + 2, ")>")))
|
||||
ct = strstr(ct, "<(");
|
||||
if (ct && (strstr(ct + 2, ")>")))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1061,7 +1120,7 @@ String *SwigType_prefix(const SwigType *t) {
|
|||
* Strip all qualifiers from a type and return a new type
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_strip_qualifiers(SwigType *t) {
|
||||
SwigType *SwigType_strip_qualifiers(const SwigType *t) {
|
||||
static Hash *memoize_stripped = 0;
|
||||
SwigType *r;
|
||||
List *l;
|
||||
|
|
@ -1092,3 +1151,62 @@ SwigType *SwigType_strip_qualifiers(SwigType *t) {
|
|||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_strip_single_qualifier()
|
||||
*
|
||||
* If the type contains a qualifier, strip one qualifier and return a new type.
|
||||
* The left most qualifier is stripped first (when viewed as C source code) but
|
||||
* this is the equivalent to the right most qualifier using SwigType notation.
|
||||
* Example:
|
||||
* r.q(const).p.q(const).int => r.q(const).p.int
|
||||
* r.q(const).p.int => r.p.int
|
||||
* r.p.int => r.p.int
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_strip_single_qualifier(const SwigType *t) {
|
||||
static Hash *memoize_stripped = 0;
|
||||
SwigType *r = 0;
|
||||
List *l;
|
||||
int numitems;
|
||||
|
||||
if (!memoize_stripped)
|
||||
memoize_stripped = NewHash();
|
||||
r = Getattr(memoize_stripped, t);
|
||||
if (r)
|
||||
return Copy(r);
|
||||
|
||||
l = SwigType_split(t);
|
||||
|
||||
numitems = Len(l);
|
||||
if (numitems >= 2) {
|
||||
int item;
|
||||
/* iterate backwards from last but one item */
|
||||
for (item = numitems - 2; item >= 0; --item) {
|
||||
String *subtype = Getitem(l, item);
|
||||
if (SwigType_isqualifier(subtype)) {
|
||||
Iterator it;
|
||||
Delitem(l, item);
|
||||
r = NewStringEmpty();
|
||||
for (it = First(l); it.item; it = Next(it)) {
|
||||
Append(r, it.item);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!r)
|
||||
r = Copy(t);
|
||||
|
||||
Delete(l);
|
||||
{
|
||||
String *key, *value;
|
||||
key = Copy(t);
|
||||
value = Copy(r);
|
||||
Setattr(memoize_stripped, key, value);
|
||||
Delete(key);
|
||||
Delete(value);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* typesys.c
|
||||
*
|
||||
|
|
@ -75,7 +79,7 @@ char cvsroot_typesys_c[] = "$Id$";
|
|||
*
|
||||
* class Bar : public Foo {
|
||||
* void blah(Integer x);
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* The argument type of Bar::blah will be set to Foo::Integer.
|
||||
*
|
||||
|
|
@ -103,11 +107,13 @@ static Typetab *global_scope = 0; /* The global scope
|
|||
static Hash *scopes = 0; /* Hash table containing fully qualified scopes */
|
||||
|
||||
/* Performance optimization */
|
||||
#define SWIG_TYPEDEF_RESOLVE_CACHE
|
||||
#define SWIG_TYPEDEF_RESOLVE_CACHE
|
||||
static Hash *typedef_resolve_cache = 0;
|
||||
static Hash *typedef_all_cache = 0;
|
||||
static Hash *typedef_qualified_cache = 0;
|
||||
|
||||
static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix);
|
||||
|
||||
/* common attribute keys, to avoid calling find_key all the times */
|
||||
|
||||
/*
|
||||
|
|
@ -161,8 +167,7 @@ void SwigType_typesystem_init() {
|
|||
* already defined.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_typedef(SwigType *type, String_or_char *name) {
|
||||
Typetab *SwigType_find_scope(Typetab *, String *s);
|
||||
int SwigType_typedef(const 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 */
|
||||
|
|
@ -192,7 +197,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))
|
||||
|
|
@ -231,7 +236,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;
|
||||
|
|
@ -384,12 +389,13 @@ void SwigType_attach_symtab(Symtab *sym) {
|
|||
* Debugging function for printing out current scope
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void SwigType_print_scope(Typetab *t) {
|
||||
void SwigType_print_scope(void) {
|
||||
Hash *ttab;
|
||||
Iterator i, j;
|
||||
|
||||
Printf(stdout, "SCOPES start =======================================\n");
|
||||
for (i = First(scopes); i.key; i = Next(i)) {
|
||||
t = i.item;
|
||||
Printf(stdout, "-------------------------------------------------------------\n");
|
||||
ttab = Getattr(i.item, "typetab");
|
||||
|
||||
Printf(stdout, "Type scope '%s' (%x)\n", i.key, i.item);
|
||||
|
|
@ -402,19 +408,22 @@ void SwigType_print_scope(Typetab *t) {
|
|||
}
|
||||
}
|
||||
}
|
||||
Printf(stdout, "-------------------------------------------------------------\n");
|
||||
for (j = First(ttab); j.key; j = Next(j)) {
|
||||
Printf(stdout, "%40s -> %s\n", j.key, j.item);
|
||||
}
|
||||
}
|
||||
Printf(stdout, "SCOPES finish =======================================\n");
|
||||
}
|
||||
|
||||
Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
|
||||
static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix) {
|
||||
Typetab *ss;
|
||||
Typetab *s_orig = s;
|
||||
String *nnameprefix = 0;
|
||||
static int check_parent = 1;
|
||||
|
||||
/* Printf(stdout,"find_scope: %x(%s) '%s'\n", s, Getattr(s,"name"), nameprefix); */
|
||||
if (Getmark(s))
|
||||
return 0;
|
||||
Setmark(s, 1);
|
||||
|
||||
if (SwigType_istemplate(nameprefix)) {
|
||||
nnameprefix = SwigType_typedef_resolve_all(nameprefix);
|
||||
|
|
@ -439,6 +448,7 @@ Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
|
|||
if (s) {
|
||||
if (nnameprefix)
|
||||
Delete(nnameprefix);
|
||||
Setmark(s_orig, 0);
|
||||
return s;
|
||||
}
|
||||
if (!s) {
|
||||
|
|
@ -458,6 +468,7 @@ Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
|
|||
if (s) {
|
||||
if (nnameprefix)
|
||||
Delete(nnameprefix);
|
||||
Setmark(s_orig, 0);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
|
@ -469,6 +480,7 @@ Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
|
|||
}
|
||||
if (nnameprefix)
|
||||
Delete(nnameprefix);
|
||||
Setmark(s_orig, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -528,6 +540,53 @@ static SwigType *_typedef_resolve(Typetab *s, String *base, int look_parent) {
|
|||
return type;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* template_parameters_resolve()
|
||||
*
|
||||
* For use with templates only. The template parameters are resolved. If none
|
||||
* of the parameters can be resolved, zero is returned.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *template_parameters_resolve(const String *base) {
|
||||
List *tparms;
|
||||
String *suffix;
|
||||
String *type;
|
||||
int i, sz;
|
||||
int rep = 0;
|
||||
type = SwigType_templateprefix(base);
|
||||
suffix = SwigType_templatesuffix(base);
|
||||
Append(type, "<(");
|
||||
tparms = SwigType_parmlist(base);
|
||||
sz = Len(tparms);
|
||||
for (i = 0; i < sz; i++) {
|
||||
SwigType *tpr;
|
||||
SwigType *tp = Getitem(tparms, i);
|
||||
if (!rep) {
|
||||
tpr = SwigType_typedef_resolve(tp);
|
||||
} else {
|
||||
tpr = 0;
|
||||
}
|
||||
if (tpr) {
|
||||
Append(type, tpr);
|
||||
Delete(tpr);
|
||||
rep = 1;
|
||||
} else {
|
||||
Append(type, tp);
|
||||
}
|
||||
if ((i + 1) < sz)
|
||||
Append(type, ",");
|
||||
}
|
||||
Append(type, ")>");
|
||||
Append(type, suffix);
|
||||
Delete(suffix);
|
||||
Delete(tparms);
|
||||
if (!rep) {
|
||||
Delete(type);
|
||||
type = 0;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
static SwigType *typedef_resolve(Typetab *s, String *base) {
|
||||
return _typedef_resolve(s, base, 1);
|
||||
}
|
||||
|
|
@ -538,7 +597,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;
|
||||
|
|
@ -548,12 +607,6 @@ SwigType *SwigType_typedef_resolve(SwigType *t) {
|
|||
String *nameprefix = 0;
|
||||
int newtype = 0;
|
||||
|
||||
/*
|
||||
if (!noscope) {
|
||||
noscope = NewStringEmpty();
|
||||
}
|
||||
*/
|
||||
|
||||
resolved_scope = 0;
|
||||
|
||||
#ifdef SWIG_TYPEDEF_RESOLVE_CACHE
|
||||
|
|
@ -597,6 +650,9 @@ SwigType *SwigType_typedef_resolve(SwigType *t) {
|
|||
#endif
|
||||
if (nameprefix) {
|
||||
/* Name had a prefix on it. See if we can locate the proper scope for it */
|
||||
String *rnameprefix = template_parameters_resolve(nameprefix);
|
||||
nameprefix = rnameprefix ? Copy(rnameprefix) : nameprefix;
|
||||
Delete(rnameprefix);
|
||||
s = SwigType_find_scope(s, nameprefix);
|
||||
|
||||
/* Couldn't locate a scope for the type. */
|
||||
|
|
@ -663,42 +719,8 @@ SwigType *SwigType_typedef_resolve(SwigType *t) {
|
|||
template arguments one by one to see if they can be resolved. */
|
||||
|
||||
if (!type && SwigType_istemplate(base)) {
|
||||
List *tparms;
|
||||
String *suffix;
|
||||
int i, sz;
|
||||
int rep = 0;
|
||||
type = SwigType_templateprefix(base);
|
||||
newtype = 1;
|
||||
suffix = SwigType_templatesuffix(base);
|
||||
Append(type, "<(");
|
||||
tparms = SwigType_parmlist(base);
|
||||
sz = Len(tparms);
|
||||
for (i = 0; i < sz; i++) {
|
||||
SwigType *tpr;
|
||||
SwigType *tp = Getitem(tparms, i);
|
||||
if (!rep) {
|
||||
tpr = SwigType_typedef_resolve(tp);
|
||||
} else {
|
||||
tpr = 0;
|
||||
}
|
||||
if (tpr) {
|
||||
Append(type, tpr);
|
||||
Delete(tpr);
|
||||
rep = 1;
|
||||
} else {
|
||||
Append(type, tp);
|
||||
}
|
||||
if ((i + 1) < sz)
|
||||
Append(type, ",");
|
||||
}
|
||||
Append(type, ")>");
|
||||
Append(type, suffix);
|
||||
Delete(suffix);
|
||||
Delete(tparms);
|
||||
if (!rep) {
|
||||
Delete(type);
|
||||
type = 0;
|
||||
}
|
||||
type = template_parameters_resolve(base);
|
||||
}
|
||||
if (namebase)
|
||||
Delete(namebase);
|
||||
|
|
@ -801,9 +823,10 @@ return_result:
|
|||
* Fully resolve a type down to its most basic datatype
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_typedef_resolve_all(SwigType *t) {
|
||||
SwigType *SwigType_typedef_resolve_all(const SwigType *t) {
|
||||
SwigType *n;
|
||||
SwigType *r;
|
||||
int count = 0;
|
||||
|
||||
/* Check to see if the typedef resolve has been done before by checking the cache */
|
||||
if (!typedef_all_cache) {
|
||||
|
|
@ -819,6 +842,10 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
|
|||
while ((n = SwigType_typedef_resolve(r))) {
|
||||
Delete(r);
|
||||
r = n;
|
||||
if (++count >= 512) {
|
||||
Swig_error(Getfile(t), Getline(t), "Recursive typedef detected resolving '%s' to '%s' to '%s' and so on...\n", SwigType_str(t, 0), SwigType_str(SwigType_typedef_resolve(t), 0), SwigType_str(SwigType_typedef_resolve(SwigType_typedef_resolve(t)), 0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add the typedef to the cache for next time it is looked up */
|
||||
|
|
@ -839,17 +866,15 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
|
|||
*
|
||||
* Given a type declaration, this function tries to fully qualify it according to
|
||||
* typedef scope rules.
|
||||
* If the unary scope operator (::) is used as a prefix to the type to denote global
|
||||
* scope, it is left in place.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_typedef_qualified(SwigType *t) {
|
||||
SwigType *SwigType_typedef_qualified(const SwigType *t) {
|
||||
List *elements;
|
||||
String *result;
|
||||
int i, len;
|
||||
|
||||
if (t && strncmp(Char(t), "::", 2) == 0) {
|
||||
return Copy(t);
|
||||
}
|
||||
|
||||
if (!typedef_qualified_cache)
|
||||
typedef_qualified_cache = NewHash();
|
||||
result = Getattr(typedef_qualified_cache, t);
|
||||
|
|
@ -997,10 +1022,6 @@ SwigType *SwigType_typedef_qualified(SwigType *t) {
|
|||
Delete(qprefix);
|
||||
Delete(parms);
|
||||
}
|
||||
if (strncmp(Char(e), "::", 2) == 0) {
|
||||
Delitem(e, 0);
|
||||
Delitem(e, 0);
|
||||
}
|
||||
Append(result, e);
|
||||
Delete(ty);
|
||||
} else if (SwigType_isfunction(e)) {
|
||||
|
|
@ -1050,7 +1071,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t) {
|
|||
* Checks a typename to see if it is a typedef.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_istypedef(SwigType *t) {
|
||||
int SwigType_istypedef(const SwigType *t) {
|
||||
String *type;
|
||||
|
||||
type = SwigType_typedef_resolve(t);
|
||||
|
|
@ -1070,7 +1091,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;
|
||||
|
|
@ -1118,11 +1139,13 @@ int SwigType_typedef_using(String_or_char *name) {
|
|||
/* Figure out the scope the using directive refers to */
|
||||
{
|
||||
prefix = Swig_scopename_prefix(name);
|
||||
s = SwigType_find_scope(current_scope, prefix);
|
||||
if (s) {
|
||||
Hash *ttab = Getattr(s, "typetab");
|
||||
if (!Getattr(ttab, base) && defined_name) {
|
||||
Setattr(ttab, base, defined_name);
|
||||
if (prefix) {
|
||||
s = SwigType_find_scope(current_scope, prefix);
|
||||
if (s) {
|
||||
Hash *ttab = Getattr(s, "typetab");
|
||||
if (!Getattr(ttab, base) && defined_name) {
|
||||
Setattr(ttab, base, defined_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1149,7 +1172,7 @@ int SwigType_typedef_using(String_or_char *name) {
|
|||
* a class.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_isclass(SwigType *t) {
|
||||
int SwigType_isclass(const SwigType *t) {
|
||||
SwigType *qty, *qtys;
|
||||
int isclass = 0;
|
||||
|
||||
|
|
@ -1164,9 +1187,9 @@ int SwigType_isclass(SwigType *t) {
|
|||
isclass = 1;
|
||||
}
|
||||
/* Hmmm. Not a class. If a template, it might be uninstantiated */
|
||||
if (!isclass && SwigType_istemplate(qtys)) {
|
||||
String *tp = SwigType_templateprefix(qtys);
|
||||
if (Strcmp(tp, t) != 0) {
|
||||
if (!isclass) {
|
||||
String *tp = SwigType_istemplate_templateprefix(qtys);
|
||||
if (tp && Strcmp(tp, t) != 0) {
|
||||
isclass = SwigType_isclass(tp);
|
||||
}
|
||||
Delete(tp);
|
||||
|
|
@ -1185,7 +1208,7 @@ int SwigType_isclass(SwigType *t) {
|
|||
* everything is based on typemaps.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_type(SwigType *t) {
|
||||
int SwigType_type(const SwigType *t) {
|
||||
char *c;
|
||||
/* Check for the obvious stuff */
|
||||
c = Char(t);
|
||||
|
|
@ -1294,7 +1317,7 @@ int SwigType_type(SwigType *t) {
|
|||
* %feature("valuewrapper").
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_alttype(SwigType *t, int local_tmap) {
|
||||
SwigType *SwigType_alttype(const SwigType *t, int local_tmap) {
|
||||
Node *n;
|
||||
SwigType *w = 0;
|
||||
int use_wrapper = 0;
|
||||
|
|
@ -1311,7 +1334,8 @@ SwigType *SwigType_alttype(SwigType *t, int local_tmap) {
|
|||
SwigType *ftd = SwigType_typedef_resolve_all(t);
|
||||
td = SwigType_strip_qualifiers(ftd);
|
||||
Delete(ftd);
|
||||
if ((n = Swig_symbol_clookup(td, 0))) {
|
||||
n = Swig_symbol_clookup(td, 0);
|
||||
if (n) {
|
||||
if (GetFlag(n, "feature:valuewrapper")) {
|
||||
use_wrapper = 1;
|
||||
} else {
|
||||
|
|
@ -1334,7 +1358,8 @@ SwigType *SwigType_alttype(SwigType *t, int local_tmap) {
|
|||
Delete(ftd);
|
||||
if (SwigType_type(td) == T_USER) {
|
||||
use_wrapper = 1;
|
||||
if ((n = Swig_symbol_clookup(td, 0))) {
|
||||
n = Swig_symbol_clookup(td, 0);
|
||||
if (n) {
|
||||
if ((Checkattr(n, "nodeType", "class")
|
||||
&& !Getattr(n, "allocate:noassign")
|
||||
&& (Getattr(n, "allocate:default_constructor")))
|
||||
|
|
@ -1410,9 +1435,9 @@ static Hash *r_clientdata = 0; /* Hash mapping resolved types to client data
|
|||
static Hash *r_mangleddata = 0; /* Hash mapping mangled types to client data */
|
||||
static Hash *r_remembered = 0; /* Hash of types we remembered already */
|
||||
|
||||
static void (*r_tracefunc) (SwigType *t, String *mangled, String *clientdata) = 0;
|
||||
static void (*r_tracefunc) (const 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();
|
||||
}
|
||||
|
|
@ -1420,7 +1445,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(const SwigType *t, const_String_or_char_ptr clientdata) {
|
||||
String *mt;
|
||||
SwigType *lt;
|
||||
Hash *h;
|
||||
|
|
@ -1533,12 +1558,12 @@ void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata)
|
|||
}
|
||||
}
|
||||
|
||||
void SwigType_remember(SwigType *ty) {
|
||||
void SwigType_remember(const SwigType *ty) {
|
||||
SwigType_remember_clientdata(ty, 0);
|
||||
}
|
||||
|
||||
void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *) {
|
||||
void (*o) (SwigType *, String *, String *) = r_tracefunc;
|
||||
void (*SwigType_remember_trace(void (*tf) (const SwigType *, String *, String *))) (const SwigType *, String *, String *) {
|
||||
void (*o) (const SwigType *, String *, String *) = r_tracefunc;
|
||||
r_tracefunc = tf;
|
||||
return o;
|
||||
}
|
||||
|
|
@ -1710,7 +1735,7 @@ void SwigType_inherit(String *derived, String *base, String *cast, String *conve
|
|||
* Determines if a t1 is a subtype of t2, ie, is t1 derived from t2
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_issubtype(SwigType *t1, SwigType *t2) {
|
||||
int SwigType_issubtype(const SwigType *t1, const SwigType *t2) {
|
||||
SwigType *ft1, *ft2;
|
||||
String *b1, *b2;
|
||||
Hash *h;
|
||||
|
|
@ -1770,7 +1795,7 @@ void SwigType_inherit_equiv(File *out) {
|
|||
continue;
|
||||
}
|
||||
|
||||
/* This type has subclasses. We now need to walk through these subtypes and generate pointer converion functions */
|
||||
/* This type has subclasses. We now need to walk through these subtypes and generate pointer conversion functions */
|
||||
|
||||
rh = Getattr(r_resolved, rk.key);
|
||||
rlist = NewList();
|
||||
|
|
@ -1795,13 +1820,15 @@ void SwigType_inherit_equiv(File *out) {
|
|||
String *lprefix = SwigType_lstr(prefix, 0);
|
||||
Hash *subhash = Getattr(sub, bk.key);
|
||||
String *convcode = Getattr(subhash, "convcode");
|
||||
Printf(out, "static void *%s(void *x, int *newmemory) {", convname);
|
||||
if (convcode) {
|
||||
char *newmemoryused = Strstr(convcode, "newmemory"); /* see if newmemory parameter is used in order to avoid unused parameter warnings */
|
||||
String *fn = Copy(convcode);
|
||||
Replaceall(fn, "$from", "x");
|
||||
Printf(out, "static void *%s(void *x, int *%s) {", convname, newmemoryused ? "newmemory" : "SWIGUNUSEDPARM(newmemory)");
|
||||
Printf(out, "%s", fn);
|
||||
} else {
|
||||
String *cast = Getattr(subhash, "cast");
|
||||
Printf(out, "static void *%s(void *x, int *SWIGUNUSEDPARM(newmemory)) {", convname);
|
||||
Printf(out, "\n return (void *)((%s) ", lkey);
|
||||
if (cast)
|
||||
Printf(out, "%s", cast);
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
*
|
||||
* warn.c
|
||||
*
|
||||
* SWIG warning framework. This was added to warn developers about
|
||||
* deprecated APIs and other features.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_warn_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
|
||||
static Hash *warnings = 0;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_warn()
|
||||
*
|
||||
* Issue a warning
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_warn(const char *filename, int line, const char *msg) {
|
||||
String *key;
|
||||
if (!warnings) {
|
||||
warnings = NewHash();
|
||||
}
|
||||
key = NewStringf("%s:%d", filename, line);
|
||||
if (!Getattr(warnings, key)) {
|
||||
Printf(stderr, "swig-dev warning:%s:%d:%s\n", filename, line, msg);
|
||||
Setattr(warnings, key, key);
|
||||
}
|
||||
Delete(key);
|
||||
}
|
||||
|
|
@ -1,6 +1,10 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* wrapfunc.c
|
||||
*
|
||||
|
|
@ -23,7 +27,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 +410,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 +428,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 +455,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 +469,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 +500,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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue