Merge branch 'restore-compat-wrappers-names' into C
Merge with the latest master including PR #2371.
This commit is contained in:
commit
864f32159a
851 changed files with 21837 additions and 7327 deletions
|
|
@ -11,8 +11,8 @@
|
|||
* SWIG parser module.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef SWIG_CPARSE_H_
|
||||
#define SWIG_CPARSE_H_
|
||||
#ifndef SWIG_CPARSE_H
|
||||
#define SWIG_CPARSE_H
|
||||
|
||||
#include "swig.h"
|
||||
#include "swigwarn.h"
|
||||
|
|
@ -43,7 +43,7 @@ extern "C" {
|
|||
extern void scanner_clear_rename(void);
|
||||
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 String *scanner_get_main_input_file(void);
|
||||
extern void Swig_cparse_follow_locators(int);
|
||||
extern void start_inline(char *, int);
|
||||
extern String *scanner_ccode;
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ void Swig_cparse_cplusplusout(int v) {
|
|||
* Initialize buffers
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
void scanner_init() {
|
||||
void scanner_init(void) {
|
||||
scan = NewScanner();
|
||||
Scanner_idstart(scan,"%");
|
||||
scan_init = 1;
|
||||
|
|
@ -214,13 +214,13 @@ void skip_decl(void) {
|
|||
tok = Scanner_token(scan);
|
||||
if (tok == 0) {
|
||||
if (!Swig_error_count()) {
|
||||
Swig_error(cparse_file, start_line, "Missing semicolon. Reached end of input.\n");
|
||||
Swig_error(cparse_file, start_line, "Missing semicolon (';'). Reached end of input.\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (tok == SWIG_TOKEN_LBRACE) {
|
||||
if (Scanner_skip_balanced(scan,'{','}') < 0) {
|
||||
Swig_error(cparse_file, start_line, "Missing '}'. Reached end of input.\n");
|
||||
Swig_error(cparse_file, start_line, "Missing closing brace ('}'). Reached end of input.\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -267,7 +267,7 @@ static int yylook(void) {
|
|||
case SWIG_TOKEN_RBRACE:
|
||||
num_brace--;
|
||||
if (num_brace < 0) {
|
||||
Swig_error(cparse_file, cparse_line, "Syntax error. Extraneous '}'\n");
|
||||
Swig_error(cparse_file, cparse_line, "Syntax error. Extraneous closing brace ('}')\n");
|
||||
num_brace = 0;
|
||||
} else {
|
||||
return RBRACE;
|
||||
|
|
@ -331,6 +331,8 @@ static int yylook(void) {
|
|||
return COLON;
|
||||
case SWIG_TOKEN_DCOLONSTAR:
|
||||
return DSTAR;
|
||||
case SWIG_TOKEN_LTEQUALGT:
|
||||
return LESSEQUALGREATER;
|
||||
|
||||
case SWIG_TOKEN_DCOLON:
|
||||
{
|
||||
|
|
@ -351,6 +353,23 @@ static int yylook(void) {
|
|||
}
|
||||
break;
|
||||
|
||||
case SWIG_TOKEN_ELLIPSIS:
|
||||
return ELLIPSIS;
|
||||
|
||||
case SWIG_TOKEN_LLBRACKET:
|
||||
do {
|
||||
tok = Scanner_token(scan);
|
||||
} while ((tok != SWIG_TOKEN_RRBRACKET) && (tok > 0));
|
||||
if (tok <= 0) {
|
||||
Swig_error(cparse_file, cparse_line, "Unbalanced double brackets, missing closing (']]'). Reached end of input.\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case SWIG_TOKEN_RRBRACKET:
|
||||
/* Turn an unmatched ]] back into two ] - e.g. `a[a[0]]` */
|
||||
scanner_next_token(RBRACKET);
|
||||
return RBRACKET;
|
||||
|
||||
/* Look for multi-character sequences */
|
||||
|
||||
case SWIG_TOKEN_RSTRING:
|
||||
|
|
@ -525,11 +544,11 @@ void scanner_set_location(String *file, int line) {
|
|||
Scanner_set_location(scan,file,line-1);
|
||||
}
|
||||
|
||||
void scanner_check_typedef() {
|
||||
void scanner_check_typedef(void) {
|
||||
check_typedef = 1;
|
||||
}
|
||||
|
||||
void scanner_ignore_typedef() {
|
||||
void scanner_ignore_typedef(void) {
|
||||
check_typedef = 0;
|
||||
}
|
||||
|
||||
|
|
@ -537,7 +556,7 @@ void scanner_last_id(int x) {
|
|||
last_id = x;
|
||||
}
|
||||
|
||||
void scanner_clear_rename() {
|
||||
void scanner_clear_rename(void) {
|
||||
rename_active = 0;
|
||||
}
|
||||
|
||||
|
|
@ -551,7 +570,7 @@ void scanner_set_main_input_file(String *file) {
|
|||
main_input_file = file;
|
||||
}
|
||||
|
||||
String *scanner_get_main_input_file() {
|
||||
String *scanner_get_main_input_file(void) {
|
||||
return main_input_file;
|
||||
}
|
||||
|
||||
|
|
@ -570,6 +589,9 @@ int yylex(void) {
|
|||
scanner_init();
|
||||
}
|
||||
|
||||
Delete(cparse_unknown_directive);
|
||||
cparse_unknown_directive = NULL;
|
||||
|
||||
if (next_token) {
|
||||
l = next_token;
|
||||
next_token = 0;
|
||||
|
|
@ -948,10 +970,8 @@ int yylex(void) {
|
|||
return (yylex());
|
||||
|
||||
} else {
|
||||
Delete(cparse_unknown_directive);
|
||||
cparse_unknown_directive = NULL;
|
||||
|
||||
/* SWIG directives */
|
||||
String *stext = 0;
|
||||
if (strcmp(yytext, "%module") == 0)
|
||||
return (MODULE);
|
||||
if (strcmp(yytext, "%insert") == 0)
|
||||
|
|
@ -1028,8 +1048,23 @@ int yylex(void) {
|
|||
if (strcmp(yytext, "%warn") == 0)
|
||||
return (WARN);
|
||||
|
||||
/* Note down the apparently unknown directive for error reporting. */
|
||||
/* Note down the apparently unknown directive for error reporting - if
|
||||
* we end up reporting a generic syntax error we'll instead report an
|
||||
* error for his as an unknown directive. Then we treat it as MODULO
|
||||
* (`%`) followed by an identifier and if that parses OK then
|
||||
* `cparse_unknown_directive` doesn't get used.
|
||||
*
|
||||
* This allows `a%b` to be handled in expressions without a space after
|
||||
* the operator.
|
||||
*/
|
||||
cparse_unknown_directive = NewString(yytext);
|
||||
stext = NewString(yytext + 1);
|
||||
Seek(stext,0,SEEK_SET);
|
||||
Setfile(stext,cparse_file);
|
||||
Setline(stext,cparse_line);
|
||||
Scanner_push(scan,stext);
|
||||
Delete(stext);
|
||||
return (MODULO);
|
||||
}
|
||||
/* Have an unknown identifier, as a last step, we'll do a typedef lookup on it. */
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,15 @@
|
|||
%{
|
||||
#define yylex yylex
|
||||
|
||||
/* doh.h uses #pragma GCC poison with GCC to prevent direct calls to certain
|
||||
* standard C library functions being introduced, but those cause errors due
|
||||
* to checks like `#if defined YYMALLOC || defined malloc` in the bison
|
||||
* template code. We can't easily arrange to include headers after that
|
||||
* template code, so instead we disable the problematic poisoning for this
|
||||
* file.
|
||||
*/
|
||||
#define DOH_NO_POISON_MALLOC_FREE
|
||||
|
||||
#include "swig.h"
|
||||
#include "cparse.h"
|
||||
#include "preprocessor.h"
|
||||
|
|
@ -32,13 +41,16 @@
|
|||
|
||||
/* We do this for portability */
|
||||
#undef alloca
|
||||
#define alloca malloc
|
||||
#define alloca Malloc
|
||||
|
||||
#define YYMALLOC Malloc
|
||||
#define YYFREE Free
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Externals
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int yyparse();
|
||||
int yyparse(void);
|
||||
|
||||
/* NEW Variables */
|
||||
|
||||
|
|
@ -337,7 +349,7 @@ static String *make_name(Node *n, String *name,SwigType *decl) {
|
|||
}
|
||||
|
||||
/* Generate an unnamed identifier */
|
||||
static String *make_unnamed() {
|
||||
static String *make_unnamed(void) {
|
||||
unnamed++;
|
||||
return NewStringf("$unnamed%d$",unnamed);
|
||||
}
|
||||
|
|
@ -862,7 +874,7 @@ static void add_typedef_name(Node *n, Node *declnode, String *oldName, Symtab *c
|
|||
|
||||
/* If the class name is qualified. We need to create or lookup namespace entries */
|
||||
|
||||
static Symtab *set_scope_to_global() {
|
||||
static Symtab *set_scope_to_global(void) {
|
||||
Symtab *symtab = Swig_symbol_global_scope();
|
||||
Swig_symbol_setscope(symtab);
|
||||
return symtab;
|
||||
|
|
@ -1587,6 +1599,9 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
|
|||
Node *node;
|
||||
};
|
||||
|
||||
// Define special token END for end of input.
|
||||
%token END 0
|
||||
|
||||
%token <id> ID
|
||||
%token <str> HBLOCK
|
||||
%token <id> POUND
|
||||
|
|
@ -1596,7 +1611,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
|
|||
%token <dtype> NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG NUM_BOOL
|
||||
%token <intvalue> TYPEDEF
|
||||
%token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64
|
||||
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD
|
||||
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD ELLIPSIS
|
||||
%token CONST_QUAL VOLATILE REGISTER STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET
|
||||
%token BEGINFILE ENDOFFILE
|
||||
%token ILLEGAL CONSTANT
|
||||
|
|
@ -1611,7 +1626,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
|
|||
%token TYPEMAP EXCEPT ECHO APPLY CLEAR SWIGTEMPLATE FRAGMENT
|
||||
%token WARN
|
||||
%token LESSTHAN GREATERTHAN DELETE_KW DEFAULT
|
||||
%token LESSTHANOREQUALTO GREATERTHANOREQUALTO EQUALTO NOTEQUALTO
|
||||
%token LESSTHANOREQUALTO GREATERTHANOREQUALTO EQUALTO NOTEQUALTO LESSEQUALGREATER
|
||||
%token ARROW
|
||||
%token QUESTIONMARK
|
||||
%token TYPES PARMS
|
||||
|
|
@ -1633,6 +1648,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
|
|||
%left AND
|
||||
%left EQUALTO NOTEQUALTO
|
||||
%left GREATERTHAN LESSTHAN GREATERTHANOREQUALTO LESSTHANOREQUALTO
|
||||
%left LESSEQUALGREATER
|
||||
%left LSHIFT RSHIFT
|
||||
%left PLUS MINUS
|
||||
%left STAR SLASH MODULO
|
||||
|
|
@ -1671,11 +1687,11 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
|
|||
%type <p> templateparameter ;
|
||||
%type <id> templcpptype cpptype classkey classkeyopt access_specifier;
|
||||
%type <node> base_specifier;
|
||||
%type <str> ellipsis variadic;
|
||||
%type <str> variadic;
|
||||
%type <type> type rawtype type_right anon_bitfield_type decltype ;
|
||||
%type <bases> base_list inherit raw_inherit;
|
||||
%type <dtype> definetype def_args etype default_delete deleted_definition explicit_default;
|
||||
%type <dtype> expr exprnum exprcompound valexpr exprmem;
|
||||
%type <dtype> expr exprnum exprsimple exprcompound valexpr exprmem callparms callptail;
|
||||
%type <id> ename ;
|
||||
%type <id> less_valparms_greater;
|
||||
%type <str> type_qualifier;
|
||||
|
|
@ -1697,7 +1713,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
|
|||
%type <ptype> type_specifier primitive_type_list ;
|
||||
%type <node> fname stringtype;
|
||||
%type <node> featattr;
|
||||
%type <node> lambda_introducer lambda_body;
|
||||
%type <node> lambda_introducer lambda_body lambda_template;
|
||||
%type <pl> lambda_tail;
|
||||
%type <str> virt_specifier_seq virt_specifier_seq_opt;
|
||||
|
||||
|
|
@ -1779,7 +1795,7 @@ declaration : swig_directive { $$ = $1; }
|
|||
} else {
|
||||
Swig_error(cparse_file, cparse_line, "Syntax error in input(1).\n");
|
||||
}
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
/* Out of class constructor/destructor declarations */
|
||||
| c_constructor_decl {
|
||||
|
|
@ -1860,7 +1876,7 @@ extend_directive : EXTEND options classkeyopt idcolon LBRACE {
|
|||
} else {
|
||||
/* Previous typedef class definition. Use its symbol table.
|
||||
Deprecated, just the real name should be used.
|
||||
Note that %extend before the class typedef never worked, only %extend after the class typdef. */
|
||||
Note that %extend before the class typedef never worked, only %extend after the class typedef. */
|
||||
prev_symtab = Swig_symbol_setscope(Getattr(cls, "symtab"));
|
||||
current_class = cls;
|
||||
SWIG_WARN_NODE_BEGIN(cls);
|
||||
|
|
@ -1936,6 +1952,9 @@ clear_directive : CLEAR tm_list SEMI {
|
|||
/* ------------------------------------------------------------
|
||||
%constant name = value;
|
||||
%constant type name = value;
|
||||
|
||||
Note: Source/Preprocessor/cpp.c injects `%constant X = Y;` for
|
||||
each `#define X Y` so that's handled here too.
|
||||
------------------------------------------------------------ */
|
||||
|
||||
constant_directive : CONSTANT identifier EQUAL definetype SEMI {
|
||||
|
|
@ -2010,6 +2029,10 @@ constant_directive : CONSTANT identifier EQUAL definetype SEMI {
|
|||
Swig_warning(WARN_PARSE_BAD_VALUE,cparse_file,cparse_line,"Bad constant value (ignored).\n");
|
||||
$$ = 0;
|
||||
}
|
||||
| CONSTANT error END {
|
||||
Swig_error(cparse_file,cparse_line,"Missing semicolon (';') after %%constant.\n");
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
;
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
|
|
@ -2716,26 +2739,23 @@ typemap_directive : TYPEMAP LPAREN typemap_type RPAREN tm_list stringbrace {
|
|||
/* typemap method type (lang,method) or (method) */
|
||||
|
||||
typemap_type : kwargs {
|
||||
Hash *p;
|
||||
String *name;
|
||||
p = nextSibling($1);
|
||||
if (p && (!Getattr(p,"value"))) {
|
||||
/* this is the deprecated two argument typemap form */
|
||||
Swig_warning(WARN_DEPRECATED_TYPEMAP_LANG,cparse_file, cparse_line,
|
||||
"Specifying the language name in %%typemap is deprecated - use #ifdef SWIG<LANG> instead.\n");
|
||||
/* two argument typemap form */
|
||||
name = Getattr($1,"name");
|
||||
if (!name || (Strcmp(name,typemap_lang))) {
|
||||
$$.method = 0;
|
||||
$$.kwargs = 0;
|
||||
} else {
|
||||
$$.method = Getattr(p,"name");
|
||||
$$.kwargs = nextSibling(p);
|
||||
String *name = Getattr($1, "name");
|
||||
Hash *p = nextSibling($1);
|
||||
$$.method = name;
|
||||
$$.kwargs = p;
|
||||
if (Getattr($1, "value")) {
|
||||
Swig_error(cparse_file, cparse_line,
|
||||
"%%typemap method shouldn't have a value specified.\n");
|
||||
}
|
||||
while (p) {
|
||||
if (!Getattr(p, "value")) {
|
||||
Swig_error(cparse_file, cparse_line,
|
||||
"%%typemap attribute '%s' is missing its value. If this is specifying the target language, that's no longer supported: use #ifdef SWIG<LANG> instead.\n",
|
||||
Getattr(p, "name"));
|
||||
/* Set to empty value to avoid segfaults later. */
|
||||
Setattr(p, "value", NewStringEmpty());
|
||||
}
|
||||
} else {
|
||||
/* one-argument typemap-form */
|
||||
$$.method = Getattr($1,"name");
|
||||
$$.kwargs = p;
|
||||
p = nextSibling(p);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
|
@ -2963,6 +2983,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
String *nname = NewStringf("__dummy_%d__", cnt++);
|
||||
Swig_cparse_template_expand(templnode,nname,temparms,tscope);
|
||||
Setattr(templnode,"sym:name",nname);
|
||||
SetFlag(templnode,"hidden");
|
||||
Delete(nname);
|
||||
Setattr(templnode,"feature:onlychildren", "typemap,typemapitem,typemapcopy,typedef,types,fragment,apply");
|
||||
if ($3) {
|
||||
|
|
@ -3126,14 +3147,22 @@ c_declaration : c_decl {
|
|||
Setattr($$,"name",$2);
|
||||
appendChild($$,n);
|
||||
while (n) {
|
||||
SwigType *decl = Getattr(n,"decl");
|
||||
if (SwigType_isfunction(decl) && !Equal(Getattr(n, "storage"), "typedef")) {
|
||||
String *s = Getattr(n, "storage");
|
||||
if (s) {
|
||||
if (Strstr(s, "thread_local")) {
|
||||
Insert(s,0,"externc ");
|
||||
} else if (!Equal(s, "typedef")) {
|
||||
Setattr(n,"storage","externc");
|
||||
}
|
||||
} else {
|
||||
Setattr(n,"storage","externc");
|
||||
}
|
||||
n = nextSibling(n);
|
||||
}
|
||||
} else {
|
||||
Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", $2);
|
||||
if (!Equal($2,"C++")) {
|
||||
Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", $2);
|
||||
}
|
||||
$$ = new_node("extern");
|
||||
Setattr($$,"name",$2);
|
||||
appendChild($$,firstChild($5));
|
||||
|
|
@ -3355,11 +3384,11 @@ c_decl_tail : SEMI {
|
|||
| error {
|
||||
$$ = 0;
|
||||
if (yychar == RPAREN) {
|
||||
Swig_error(cparse_file, cparse_line, "Unexpected ')'.\n");
|
||||
Swig_error(cparse_file, cparse_line, "Unexpected closing parenthesis (')').\n");
|
||||
} else {
|
||||
Swig_error(cparse_file, cparse_line, "Syntax error - possibly a missing semicolon.\n");
|
||||
Swig_error(cparse_file, cparse_line, "Syntax error - possibly a missing semicolon (';').\n");
|
||||
}
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -3376,6 +3405,10 @@ cpp_alternate_rettype : primitive_type { $$ = $1; }
|
|||
*/
|
||||
| TYPE_RAW { $$ = $1; }
|
||||
| idcolon { $$ = $1; }
|
||||
| idcolon AND {
|
||||
$$ = $1;
|
||||
SwigType_add_reference($$);
|
||||
}
|
||||
| decltype { $$ = $1; }
|
||||
;
|
||||
|
||||
|
|
@ -3387,17 +3420,17 @@ cpp_alternate_rettype : primitive_type { $$ = $1; }
|
|||
auto myFunc = [](int x, int y) throw() -> int { return x+y; };
|
||||
auto six = [](int x, int y) { return x+y; }(4, 2);
|
||||
------------------------------------------------------------ */
|
||||
cpp_lambda_decl : storage_class AUTO idcolon EQUAL lambda_introducer LPAREN parms RPAREN cpp_const lambda_body lambda_tail {
|
||||
cpp_lambda_decl : storage_class AUTO idcolon EQUAL lambda_introducer lambda_template LPAREN parms RPAREN cpp_const lambda_body lambda_tail {
|
||||
$$ = new_node("lambda");
|
||||
Setattr($$,"name",$3);
|
||||
add_symbols($$);
|
||||
}
|
||||
| storage_class AUTO idcolon EQUAL lambda_introducer LPAREN parms RPAREN cpp_const ARROW type lambda_body lambda_tail {
|
||||
| storage_class AUTO idcolon EQUAL lambda_introducer lambda_template LPAREN parms RPAREN cpp_const ARROW type lambda_body lambda_tail {
|
||||
$$ = new_node("lambda");
|
||||
Setattr($$,"name",$3);
|
||||
add_symbols($$);
|
||||
}
|
||||
| storage_class AUTO idcolon EQUAL lambda_introducer lambda_body lambda_tail {
|
||||
| storage_class AUTO idcolon EQUAL lambda_introducer lambda_template lambda_body lambda_tail {
|
||||
$$ = new_node("lambda");
|
||||
Setattr($$,"name",$3);
|
||||
add_symbols($$);
|
||||
|
|
@ -3410,6 +3443,13 @@ lambda_introducer : LBRACKET {
|
|||
}
|
||||
;
|
||||
|
||||
lambda_template : LESSTHAN {
|
||||
skip_balanced('<','>');
|
||||
$$ = 0;
|
||||
}
|
||||
| empty { $$ = 0; }
|
||||
;
|
||||
|
||||
lambda_body : LBRACE {
|
||||
skip_balanced('{','}');
|
||||
$$ = 0;
|
||||
|
|
@ -3649,7 +3689,7 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end {
|
|||
}
|
||||
if (err) {
|
||||
Swig_error(cparse_file,cparse_line,"Syntax error in input(2).\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
|
@ -4355,18 +4395,30 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN {
|
|||
parsing_template_declaration = 0;
|
||||
}
|
||||
|
||||
/* Explicit template instantiation */
|
||||
/* Class template explicit instantiation definition */
|
||||
| TEMPLATE cpptype idcolon {
|
||||
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n");
|
||||
$$ = 0;
|
||||
}
|
||||
|
||||
/* Explicit template instantiation without the translation unit */
|
||||
/* Function template explicit instantiation definition */
|
||||
| TEMPLATE cpp_alternate_rettype idcolon LPAREN parms RPAREN {
|
||||
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n");
|
||||
$$ = 0;
|
||||
}
|
||||
|
||||
/* Class template explicit instantiation declaration (extern template) */
|
||||
| EXTERN TEMPLATE cpptype idcolon {
|
||||
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n");
|
||||
Swig_warning(WARN_PARSE_EXTERN_TEMPLATE, cparse_file, cparse_line, "Extern template ignored.\n");
|
||||
$$ = 0;
|
||||
}
|
||||
;
|
||||
|
||||
/* Function template explicit instantiation declaration (extern template) */
|
||||
| EXTERN TEMPLATE cpp_alternate_rettype idcolon LPAREN parms RPAREN {
|
||||
Swig_warning(WARN_PARSE_EXTERN_TEMPLATE, cparse_file, cparse_line, "Extern template ignored.\n");
|
||||
$$ = 0;
|
||||
}
|
||||
;
|
||||
|
||||
cpp_template_possible: c_decl {
|
||||
$$ = $1;
|
||||
|
|
@ -4629,10 +4681,8 @@ cpp_members : cpp_member cpp_members {
|
|||
| include_directive { $$ = $1; }
|
||||
| empty { $$ = 0;}
|
||||
| error {
|
||||
int start_line = cparse_line;
|
||||
skip_decl();
|
||||
Swig_error(cparse_file,start_line,"Syntax error in input(3).\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Swig_error(cparse_file,cparse_line,"Syntax error in input(3).\n");
|
||||
Exit(EXIT_FAILURE);
|
||||
} cpp_members {
|
||||
$$ = $3;
|
||||
}
|
||||
|
|
@ -5062,7 +5112,13 @@ extern_string : EXTERN string {
|
|||
|
||||
storage_class : EXTERN { $$ = "extern"; }
|
||||
| extern_string { $$ = $1; }
|
||||
| extern_string THREAD_LOCAL { $$ = "thread_local"; }
|
||||
| extern_string THREAD_LOCAL {
|
||||
if (Equal($1, "extern")) {
|
||||
$$ = "extern thread_local";
|
||||
} else {
|
||||
$$ = "externc thread_local";
|
||||
}
|
||||
}
|
||||
| extern_string TYPEDEF { $$ = "typedef"; }
|
||||
| STATIC { $$ = "static"; }
|
||||
| TYPEDEF { $$ = "typedef"; }
|
||||
|
|
@ -5143,7 +5199,7 @@ parm_no_dox : rawtype parameter_declarator {
|
|||
Setattr($$,"value",$7.val);
|
||||
}
|
||||
}
|
||||
| PERIOD PERIOD PERIOD {
|
||||
| ELLIPSIS {
|
||||
SwigType *t = NewString("v(...)");
|
||||
$$ = NewParmWithoutFileLineInfo(t, 0);
|
||||
previousNode = currentNode;
|
||||
|
|
@ -5230,6 +5286,20 @@ valparm : parm {
|
|||
}
|
||||
;
|
||||
|
||||
callparms : valexpr callptail {
|
||||
$$ = $1;
|
||||
Printf($$.val, "%s", $2);
|
||||
}
|
||||
| empty { $$.val = NewStringEmpty(); }
|
||||
;
|
||||
|
||||
callptail : COMMA valexpr callptail {
|
||||
$$.val = NewStringf(",%s%s", $2, $3);
|
||||
$$.type = 0;
|
||||
}
|
||||
| empty { $$.val = NewStringEmpty(); }
|
||||
;
|
||||
|
||||
def_args : EQUAL definetype {
|
||||
$$ = $2;
|
||||
if ($2.type == T_ERROR) {
|
||||
|
|
@ -5488,16 +5558,16 @@ declarator : pointer notso_direct_declarator {
|
|||
|
||||
/* Variadic versions eg. MyClasses&... myIds */
|
||||
|
||||
| pointer PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
$$ = $5;
|
||||
| pointer ELLIPSIS notso_direct_declarator {
|
||||
$$ = $3;
|
||||
if ($$.type) {
|
||||
SwigType_push($1,$$.type);
|
||||
Delete($$.type);
|
||||
}
|
||||
$$.type = $1;
|
||||
}
|
||||
| pointer AND PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
$$ = $6;
|
||||
| pointer AND ELLIPSIS notso_direct_declarator {
|
||||
$$ = $4;
|
||||
SwigType_add_reference($1);
|
||||
if ($$.type) {
|
||||
SwigType_push($1,$$.type);
|
||||
|
|
@ -5505,8 +5575,8 @@ declarator : pointer notso_direct_declarator {
|
|||
}
|
||||
$$.type = $1;
|
||||
}
|
||||
| pointer LAND PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
$$ = $6;
|
||||
| pointer LAND ELLIPSIS notso_direct_declarator {
|
||||
$$ = $4;
|
||||
SwigType_add_rvalue_reference($1);
|
||||
if ($$.type) {
|
||||
SwigType_push($1,$$.type);
|
||||
|
|
@ -5514,34 +5584,34 @@ declarator : pointer notso_direct_declarator {
|
|||
}
|
||||
$$.type = $1;
|
||||
}
|
||||
| PERIOD PERIOD PERIOD direct_declarator {
|
||||
$$ = $4;
|
||||
| ELLIPSIS direct_declarator {
|
||||
$$ = $2;
|
||||
if (!$$.type) $$.type = NewStringEmpty();
|
||||
}
|
||||
| AND PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
$$ = $5;
|
||||
| AND ELLIPSIS notso_direct_declarator {
|
||||
$$ = $3;
|
||||
$$.type = NewStringEmpty();
|
||||
SwigType_add_reference($$.type);
|
||||
if ($5.type) {
|
||||
SwigType_push($$.type,$5.type);
|
||||
Delete($5.type);
|
||||
if ($3.type) {
|
||||
SwigType_push($$.type,$3.type);
|
||||
Delete($3.type);
|
||||
}
|
||||
}
|
||||
| LAND PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
| LAND ELLIPSIS notso_direct_declarator {
|
||||
/* Introduced in C++11, move operator && */
|
||||
/* Adds one S/R conflict */
|
||||
$$ = $5;
|
||||
$$ = $3;
|
||||
$$.type = NewStringEmpty();
|
||||
SwigType_add_rvalue_reference($$.type);
|
||||
if ($5.type) {
|
||||
SwigType_push($$.type,$5.type);
|
||||
Delete($5.type);
|
||||
if ($3.type) {
|
||||
SwigType_push($$.type,$3.type);
|
||||
Delete($3.type);
|
||||
}
|
||||
}
|
||||
| idcolon DSTAR PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
| idcolon DSTAR ELLIPSIS notso_direct_declarator {
|
||||
SwigType *t = NewStringEmpty();
|
||||
|
||||
$$ = $6;
|
||||
$$ = $4;
|
||||
SwigType_add_memberpointer(t,$1);
|
||||
if ($$.type) {
|
||||
SwigType_push(t,$$.type);
|
||||
|
|
@ -5549,9 +5619,9 @@ declarator : pointer notso_direct_declarator {
|
|||
}
|
||||
$$.type = t;
|
||||
}
|
||||
| pointer idcolon DSTAR PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
| pointer idcolon DSTAR ELLIPSIS notso_direct_declarator {
|
||||
SwigType *t = NewStringEmpty();
|
||||
$$ = $7;
|
||||
$$ = $5;
|
||||
SwigType_add_memberpointer(t,$2);
|
||||
SwigType_push($1,t);
|
||||
if ($$.type) {
|
||||
|
|
@ -5561,8 +5631,8 @@ declarator : pointer notso_direct_declarator {
|
|||
$$.type = $1;
|
||||
Delete(t);
|
||||
}
|
||||
| pointer idcolon DSTAR AND PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
$$ = $8;
|
||||
| pointer idcolon DSTAR AND ELLIPSIS notso_direct_declarator {
|
||||
$$ = $6;
|
||||
SwigType_add_memberpointer($1,$2);
|
||||
SwigType_add_reference($1);
|
||||
if ($$.type) {
|
||||
|
|
@ -5571,8 +5641,8 @@ declarator : pointer notso_direct_declarator {
|
|||
}
|
||||
$$.type = $1;
|
||||
}
|
||||
| pointer idcolon DSTAR LAND PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
$$ = $8;
|
||||
| pointer idcolon DSTAR LAND ELLIPSIS notso_direct_declarator {
|
||||
$$ = $6;
|
||||
SwigType_add_memberpointer($1,$2);
|
||||
SwigType_add_rvalue_reference($1);
|
||||
if ($$.type) {
|
||||
|
|
@ -5581,9 +5651,9 @@ declarator : pointer notso_direct_declarator {
|
|||
}
|
||||
$$.type = $1;
|
||||
}
|
||||
| idcolon DSTAR AND PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
| idcolon DSTAR AND ELLIPSIS notso_direct_declarator {
|
||||
SwigType *t = NewStringEmpty();
|
||||
$$ = $7;
|
||||
$$ = $5;
|
||||
SwigType_add_memberpointer(t,$1);
|
||||
SwigType_add_reference(t);
|
||||
if ($$.type) {
|
||||
|
|
@ -5592,9 +5662,9 @@ declarator : pointer notso_direct_declarator {
|
|||
}
|
||||
$$.type = t;
|
||||
}
|
||||
| idcolon DSTAR LAND PERIOD PERIOD PERIOD notso_direct_declarator {
|
||||
| idcolon DSTAR LAND ELLIPSIS notso_direct_declarator {
|
||||
SwigType *t = NewStringEmpty();
|
||||
$$ = $7;
|
||||
$$ = $5;
|
||||
SwigType_add_memberpointer(t,$1);
|
||||
SwigType_add_rvalue_reference(t);
|
||||
if ($$.type) {
|
||||
|
|
@ -6505,23 +6575,38 @@ exprmem : ID ARROW ID {
|
|||
$$.val = NewStringf("%s->%s", $1, $3);
|
||||
$$.type = 0;
|
||||
}
|
||||
| ID ARROW ID LPAREN callparms RPAREN {
|
||||
$$.val = NewStringf("%s->%s(%s)", $1, $3, $5);
|
||||
$$.type = 0;
|
||||
}
|
||||
| exprmem ARROW ID {
|
||||
$$ = $1;
|
||||
Printf($$.val, "->%s", $3);
|
||||
}
|
||||
/* This generates a shift-reduce
|
||||
| exprmem ARROW ID LPAREN callparms RPAREN {
|
||||
$$ = $1;
|
||||
Printf($$.val, "->%s(%s)", $3, $5);
|
||||
}
|
||||
| ID PERIOD ID {
|
||||
$$.val = NewStringf("%s.%s", $1, $3);
|
||||
$$.type = 0;
|
||||
}
|
||||
*/
|
||||
| ID PERIOD ID LPAREN callparms RPAREN {
|
||||
$$.val = NewStringf("%s.%s(%s)", $1, $3, $5);
|
||||
$$.type = 0;
|
||||
}
|
||||
| exprmem PERIOD ID {
|
||||
$$ = $1;
|
||||
Printf($$.val, ".%s", $3);
|
||||
}
|
||||
| exprmem PERIOD ID LPAREN callparms RPAREN {
|
||||
$$ = $1;
|
||||
Printf($$.val, ".%s(%s)", $3, $5);
|
||||
}
|
||||
;
|
||||
|
||||
valexpr : exprnum {
|
||||
/* Non-compound expression */
|
||||
exprsimple : exprnum {
|
||||
$$ = $1;
|
||||
}
|
||||
| exprmem {
|
||||
|
|
@ -6536,12 +6621,30 @@ valexpr : exprnum {
|
|||
$$.val = NewStringf("sizeof(%s)",SwigType_str($3,0));
|
||||
$$.type = T_ULONG;
|
||||
}
|
||||
| SIZEOF PERIOD PERIOD PERIOD LPAREN type parameter_declarator RPAREN {
|
||||
SwigType_push($6,$7.type);
|
||||
$$.val = NewStringf("sizeof...(%s)",SwigType_str($6,0));
|
||||
| SIZEOF ELLIPSIS LPAREN type parameter_declarator RPAREN {
|
||||
SwigType_push($4,$5.type);
|
||||
$$.val = NewStringf("sizeof...(%s)",SwigType_str($4,0));
|
||||
$$.type = T_ULONG;
|
||||
}
|
||||
| exprcompound { $$ = $1; }
|
||||
/* We don't support all valid expressions here currently - e.g.
|
||||
* sizeof(<unaryop> x) doesn't work - but those are unlikely to
|
||||
* be seen in real code.
|
||||
*
|
||||
* Note: sizeof(x) is not handled here, but instead by the rule
|
||||
* for sizeof(<type>) because it matches that syntactically.
|
||||
*/
|
||||
| SIZEOF LPAREN exprsimple RPAREN {
|
||||
$$.val = NewStringf("sizeof(%s)", $3.val);
|
||||
$$.type = T_ULONG;
|
||||
}
|
||||
/* `sizeof expr` without parentheses is valid for an expression,
|
||||
* but not for a type. This doesn't support `sizeof x` in
|
||||
* addition to the case not supported above.
|
||||
*/
|
||||
| SIZEOF exprsimple {
|
||||
$$.val = NewStringf("sizeof(%s)", $2.val);
|
||||
$$.type = T_ULONG;
|
||||
}
|
||||
| wstring {
|
||||
$$.val = $1;
|
||||
$$.rawval = NewStringf("L\"%s\"", $$.val);
|
||||
|
|
@ -6576,6 +6679,11 @@ valexpr : exprnum {
|
|||
$$.final = 0;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
valexpr : exprsimple { $$ = $1; }
|
||||
| exprcompound { $$ = $1; }
|
||||
|
||||
/* grouping */
|
||||
| LPAREN expr RPAREN %prec CAST {
|
||||
$$.val = NewStringf("(%s)",$2.val);
|
||||
|
|
@ -6646,15 +6754,11 @@ valexpr : exprnum {
|
|||
$$ = $2;
|
||||
$$.val = NewStringf("&%s",$2.val);
|
||||
}
|
||||
| LAND expr {
|
||||
$$ = $2;
|
||||
$$.val = NewStringf("&&%s",$2.val);
|
||||
}
|
||||
| STAR expr {
|
||||
$$ = $2;
|
||||
$$.val = NewStringf("*%s",$2.val);
|
||||
}
|
||||
;
|
||||
;
|
||||
|
||||
exprnum : NUM_INT { $$ = $1; }
|
||||
| NUM_FLOAT { $$ = $1; }
|
||||
|
|
@ -6722,16 +6826,24 @@ exprcompound : expr PLUS expr {
|
|||
$$.val = NewStringf("%s!=%s",COMPOUND_EXPR_VAL($1),COMPOUND_EXPR_VAL($3));
|
||||
$$.type = cparse_cplusplus ? T_BOOL : T_INT;
|
||||
}
|
||||
/* Sadly this causes 2 reduce-reduce conflicts with templates. FIXME resolve these.
|
||||
| expr GREATERTHAN expr {
|
||||
$$.val = NewStringf("%s > %s", COMPOUND_EXPR_VAL($1), COMPOUND_EXPR_VAL($3));
|
||||
/* Trying to parse `>` in the general case results in conflicts
|
||||
* in the parser, but all user-reported cases are actually inside
|
||||
* parentheses and we can handle that case.
|
||||
*/
|
||||
| LPAREN expr GREATERTHAN expr RPAREN {
|
||||
$$.val = NewStringf("%s > %s", COMPOUND_EXPR_VAL($2), COMPOUND_EXPR_VAL($4));
|
||||
$$.type = cparse_cplusplus ? T_BOOL : T_INT;
|
||||
}
|
||||
| expr LESSTHAN expr {
|
||||
$$.val = NewStringf("%s < %s", COMPOUND_EXPR_VAL($1), COMPOUND_EXPR_VAL($3));
|
||||
|
||||
/* Similarly for `<` except trying to handle exprcompound on the
|
||||
* left side gives a shift/reduce conflict, so also restrict
|
||||
* handling to non-compound subexpressions there. Again this
|
||||
* covers all user-reported cases.
|
||||
*/
|
||||
| LPAREN exprsimple LESSTHAN expr RPAREN {
|
||||
$$.val = NewStringf("%s < %s", COMPOUND_EXPR_VAL($2), COMPOUND_EXPR_VAL($4));
|
||||
$$.type = cparse_cplusplus ? T_BOOL : T_INT;
|
||||
}
|
||||
*/
|
||||
| expr GREATERTHANOREQUALTO expr {
|
||||
$$.val = NewStringf("%s >= %s", COMPOUND_EXPR_VAL($1), COMPOUND_EXPR_VAL($3));
|
||||
$$.type = cparse_cplusplus ? T_BOOL : T_INT;
|
||||
|
|
@ -6740,6 +6852,15 @@ exprcompound : expr PLUS expr {
|
|||
$$.val = NewStringf("%s <= %s", COMPOUND_EXPR_VAL($1), COMPOUND_EXPR_VAL($3));
|
||||
$$.type = cparse_cplusplus ? T_BOOL : T_INT;
|
||||
}
|
||||
| expr LESSEQUALGREATER expr {
|
||||
$$.val = NewStringf("%s <=> %s", COMPOUND_EXPR_VAL($1), COMPOUND_EXPR_VAL($3));
|
||||
/* Really `<=>` returns one of `std::strong_ordering`,
|
||||
* `std::partial_ordering` or `std::weak_ordering`, but we
|
||||
* fake it by treating the return value as `int`. The main
|
||||
* thing to do with the return value in this context is to
|
||||
* compare it with 0, for which `int` does the job. */
|
||||
$$.type = T_INT;
|
||||
}
|
||||
| expr QUESTIONMARK expr COLON expr %prec QUESTIONMARK {
|
||||
$$.val = NewStringf("%s?%s:%s", COMPOUND_EXPR_VAL($1), COMPOUND_EXPR_VAL($3), COMPOUND_EXPR_VAL($5));
|
||||
/* This may not be exactly right, but is probably good enough
|
||||
|
|
@ -6778,14 +6899,9 @@ exprcompound : expr PLUS expr {
|
|||
}
|
||||
;
|
||||
|
||||
ellipsis : PERIOD PERIOD PERIOD {
|
||||
variadic : ELLIPSIS {
|
||||
$$ = NewString("...");
|
||||
}
|
||||
;
|
||||
|
||||
variadic : ellipsis {
|
||||
$$ = $1;
|
||||
}
|
||||
| empty {
|
||||
$$ = 0;
|
||||
}
|
||||
|
|
@ -6875,11 +6991,11 @@ templcpptype : CLASS {
|
|||
$$ = (char *)"typename";
|
||||
if (!inherit_list) last_cpptype = $$;
|
||||
}
|
||||
| CLASS PERIOD PERIOD PERIOD {
|
||||
| CLASS ELLIPSIS {
|
||||
$$ = (char *)"class...";
|
||||
if (!inherit_list) last_cpptype = $$;
|
||||
}
|
||||
| TYPENAME PERIOD PERIOD PERIOD {
|
||||
| TYPENAME ELLIPSIS {
|
||||
$$ = (char *)"typename...";
|
||||
if (!inherit_list) last_cpptype = $$;
|
||||
}
|
||||
|
|
@ -7085,8 +7201,8 @@ ctor_initializer : COLON mem_initializer_list
|
|||
|
||||
mem_initializer_list : mem_initializer
|
||||
| mem_initializer_list COMMA mem_initializer
|
||||
| mem_initializer PERIOD PERIOD PERIOD
|
||||
| mem_initializer_list COMMA mem_initializer PERIOD PERIOD PERIOD
|
||||
| mem_initializer ELLIPSIS
|
||||
| mem_initializer_list COMMA mem_initializer ELLIPSIS
|
||||
;
|
||||
|
||||
mem_initializer : idcolon LPAREN {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ static int template_debug = 0;
|
|||
|
||||
const char *baselists[3];
|
||||
|
||||
void SwigType_template_init() {
|
||||
void SwigType_template_init(void) {
|
||||
baselists[0] = "baselist";
|
||||
baselists[1] = "protectedbaselist";
|
||||
baselists[2] = "privatebaselist";
|
||||
|
|
@ -249,7 +249,7 @@ String *partial_arg(String *s, String *p) {
|
|||
}
|
||||
prefix = NewStringWithSize(cp, (int)(c - cp));
|
||||
newarg = Copy(s);
|
||||
Replace(newarg, prefix, "", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
|
||||
Replace(newarg, prefix, "", DOH_REPLACE_FIRST);
|
||||
Delete(prefix);
|
||||
return newarg;
|
||||
}
|
||||
|
|
@ -620,7 +620,7 @@ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) {
|
|||
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_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;
|
||||
|
|
@ -818,7 +818,7 @@ success:
|
|||
Printf(stdout, " chosen template:'%s'\n", Getattr(n, "name"));
|
||||
}
|
||||
Delete(parms);
|
||||
free(priorities_matrix);
|
||||
Free(priorities_matrix);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,6 @@
|
|||
* DohDelete()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef SWIG_DEBUG_DELETE
|
||||
#define SWIG_DEBUG_DELETE 0
|
||||
#endif
|
||||
|
||||
void DohDelete(DOH *obj) {
|
||||
DohBase *b = (DohBase *) obj;
|
||||
DohObjInfo *objinfo;
|
||||
|
|
@ -29,13 +25,8 @@ void DohDelete(DOH *obj) {
|
|||
if (!obj)
|
||||
return;
|
||||
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;
|
||||
fputs("Fatal internal error: Attempt to delete a non-DOH object.\n", stderr);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
if (b->flag_intern)
|
||||
return;
|
||||
|
|
@ -64,13 +55,8 @@ 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;
|
||||
fputs("Fatal internal error: Attempt to copy a non-DOH object.\n", stderr);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
objinfo = b->type;
|
||||
if (objinfo->doh_copy) {
|
||||
|
|
|
|||
|
|
@ -11,15 +11,14 @@
|
|||
* This file describes of the externally visible functions in DOH.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef _DOH_H
|
||||
#define _DOH_H
|
||||
#ifndef SWIG_DOH_H
|
||||
#define SWIG_DOH_H
|
||||
|
||||
#ifndef MACSWIG
|
||||
#include "swigconfig.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Set the namespace prefix for DOH API functions. This can be used to control
|
||||
visibility of the functions in libraries */
|
||||
|
|
@ -122,6 +121,12 @@
|
|||
#define DohIterator DOH_NAMESPACE(Iterator)
|
||||
#define DohFirst DOH_NAMESPACE(First)
|
||||
#define DohNext DOH_NAMESPACE(Next)
|
||||
#define DohMalloc DOH_NAMESPACE(Malloc)
|
||||
#define DohRealloc DOH_NAMESPACE(Realloc)
|
||||
#define DohCalloc DOH_NAMESPACE(Calloc)
|
||||
#define DohFree DOH_NAMESPACE(Free)
|
||||
#define DohSetExitHandler DOH_NAMESPACE(SetExitHandler)
|
||||
#define DohExit DOH_NAMESPACE(Exit)
|
||||
#endif
|
||||
|
||||
#define DOH_MAJOR_VERSION 0
|
||||
|
|
@ -163,12 +168,11 @@ typedef struct {
|
|||
|
||||
/* Memory management */
|
||||
|
||||
#ifndef DohMalloc
|
||||
#define DohMalloc malloc
|
||||
#endif
|
||||
#ifndef DohRealloc
|
||||
#define DohRealloc realloc
|
||||
#endif
|
||||
/* Wrappers around malloc(), realloc() and calloc() which never return NULL. */
|
||||
extern void *DohMalloc(size_t size);
|
||||
extern void *DohRealloc(void *ptr, size_t size);
|
||||
extern void *DohCalloc(size_t n, size_t size);
|
||||
|
||||
#ifndef DohFree
|
||||
#define DohFree free
|
||||
#endif
|
||||
|
|
@ -271,6 +275,24 @@ extern int DohGetMaxHashExpand(void);
|
|||
extern void DohSetmark(DOH *obj, int x);
|
||||
extern int DohGetmark(DOH *obj);
|
||||
|
||||
/* Set the function for DohExit() to call instead of exit().
|
||||
*
|
||||
* The registered function can perform clean up, etc. It should simply
|
||||
* return when done and then exit() will get called. Bear in mind that
|
||||
* the handler function can be called after malloc() has failed, so it's
|
||||
* a good idea for it to avoid allocating additional memory.
|
||||
*
|
||||
* The registered handler function is unregistered by DohExit() before calling
|
||||
* it to avoid the potential for infinite loops.
|
||||
*
|
||||
* Note: This is sort of like C's atexit(), only for DohExit(). However
|
||||
* only one function can be registered (setting a new function overrides the
|
||||
* previous one) and the registered function is passed the exit status so can
|
||||
* vary its actions based on that.
|
||||
*/
|
||||
extern void DohSetExitHandler(void (*new_handler)(int));
|
||||
extern void DohExit(int status);
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Strings.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -364,7 +386,7 @@ extern void DohMemoryDebug(void);
|
|||
#define Push(s,x) DohInsertitem(s,DOH_BEGIN,x)
|
||||
#define Len DohLen
|
||||
#define Data DohData
|
||||
#define Char (char *) Data
|
||||
#define Char(X) ((char *) Data(X))
|
||||
#define Cmp DohCmp
|
||||
#define Equal DohEqual
|
||||
#define Setline DohSetline
|
||||
|
|
@ -440,6 +462,12 @@ extern void DohMemoryDebug(void);
|
|||
#define Next DohNext
|
||||
#define Iterator DohIterator
|
||||
#define SortList DohSortList
|
||||
#define Malloc DohMalloc
|
||||
#define Realloc DohRealloc
|
||||
#define Calloc DohCalloc
|
||||
#define Free DohFree
|
||||
#define SetExitHandler DohSetExitHandler
|
||||
#define Exit DohExit
|
||||
#endif
|
||||
|
||||
#ifdef NIL
|
||||
|
|
@ -448,5 +476,29 @@ extern void DohMemoryDebug(void);
|
|||
|
||||
#define NIL (char *) NULL
|
||||
|
||||
/* Defines to allow use of poisoned identifiers.
|
||||
*
|
||||
* For DOH-internal use only!
|
||||
*/
|
||||
#define doh_internal_calloc calloc
|
||||
#define doh_internal_exit exit
|
||||
/* doh_internal_free not needed as Free() is a macro defined above. */
|
||||
#define doh_internal_malloc malloc
|
||||
#define doh_internal_realloc realloc
|
||||
|
||||
#endif /* DOH_H */
|
||||
#if defined __GNUC__ && defined DOH_POISON
|
||||
/* Use Malloc(), Realloc(), Calloc(), and Free() instead (which will exit with
|
||||
* an error rather than return NULL).
|
||||
*/
|
||||
# ifndef DOH_NO_POISON_MALLOC_FREE
|
||||
/* This works around bison's template checking if malloc and free are defined,
|
||||
* which triggers GCC's poison checks.
|
||||
*/
|
||||
# pragma GCC poison malloc free
|
||||
# endif
|
||||
# pragma GCC poison realloc calloc
|
||||
/* Use Exit() instead (which will remove output files on error). */
|
||||
# pragma GCC poison abort exit
|
||||
#endif
|
||||
|
||||
#endif /* SWIG_DOH_H */
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
* This file describes internally managed objects.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef _DOHINT_H
|
||||
#define _DOHINT_H
|
||||
#ifndef SWIG_DOHINT_H
|
||||
#define SWIG_DOHINT_H
|
||||
|
||||
#include "doh.h"
|
||||
|
||||
|
|
@ -128,4 +128,4 @@ typedef struct {
|
|||
extern DOH *DohObjMalloc(DohObjInfo *type, void *data); /* Allocate a DOH object */
|
||||
extern void DohObjFree(DOH *ptr); /* Free a DOH object */
|
||||
|
||||
#endif /* DOHINT_H */
|
||||
#endif /* SWIG_DOHINT_H */
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ typedef struct {
|
|||
* reference count of the underlying DOH objects.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static DOHList *open_files_list_instance() {
|
||||
static DOHList *open_files_list_instance(void) {
|
||||
static DOHList *all_open_files = 0;
|
||||
if (!all_open_files)
|
||||
all_open_files = DohNewList();
|
||||
|
|
@ -73,7 +73,7 @@ static void open_files_list_remove(DohFile *f) {
|
|||
* Close all opened files, to be called on program termination
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void DohCloseAllOpenFiles() {
|
||||
void DohCloseAllOpenFiles(void) {
|
||||
int i;
|
||||
DOHList *all_open_files = open_files_list_instance();
|
||||
for (i = 0; i < DohLen(all_open_files); i++) {
|
||||
|
|
@ -291,10 +291,6 @@ DOH *DohNewFile(DOHString *filename, const char *mode, DOHList *newfiles) {
|
|||
return 0;
|
||||
|
||||
f = (DohFile *) DohMalloc(sizeof(DohFile));
|
||||
if (!f) {
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
if (newfiles)
|
||||
Append(newfiles, filename);
|
||||
f->filep = file;
|
||||
|
|
@ -314,8 +310,6 @@ DOH *DohNewFile(DOHString *filename, const char *mode, DOHList *newfiles) {
|
|||
DOH *DohNewFileFromFile(FILE *file) {
|
||||
DohFile *f;
|
||||
f = (DohFile *) DohMalloc(sizeof(DohFile));
|
||||
if (!f)
|
||||
return 0;
|
||||
f->filep = file;
|
||||
f->fd = 0;
|
||||
f->closeondel = 0;
|
||||
|
|
@ -331,8 +325,6 @@ DOH *DohNewFileFromFile(FILE *file) {
|
|||
DOH *DohNewFileFromFd(int fd) {
|
||||
DohFile *f;
|
||||
f = (DohFile *) DohMalloc(sizeof(DohFile));
|
||||
if (!f)
|
||||
return 0;
|
||||
f->filep = 0;
|
||||
f->fd = fd;
|
||||
f->closeondel = 0;
|
||||
|
|
|
|||
|
|
@ -173,10 +173,7 @@ static void resize(Hash *h) {
|
|||
p = p + 2;
|
||||
}
|
||||
|
||||
table = (HashNode **) DohMalloc(newsize * sizeof(HashNode *));
|
||||
for (i = 0; i < newsize; i++) {
|
||||
table[i] = 0;
|
||||
}
|
||||
table = (HashNode **) DohCalloc(newsize, sizeof(HashNode *));
|
||||
|
||||
/* Walk down the old set of nodes and re-place */
|
||||
h->hashsize = newsize;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ extern DohObjInfo DohListType;
|
|||
static
|
||||
void more(List *l) {
|
||||
l->items = (void **) DohRealloc(l->items, l->maxitems * 2 * sizeof(void *));
|
||||
assert(l->items);
|
||||
l->maxitems *= 2;
|
||||
}
|
||||
|
||||
|
|
@ -346,15 +345,10 @@ DohObjInfo DohListType = {
|
|||
#define MAXLISTITEMS 8
|
||||
|
||||
DOH *DohNewList(void) {
|
||||
List *l;
|
||||
int i;
|
||||
l = (List *) DohMalloc(sizeof(List));
|
||||
List *l = (List *) DohMalloc(sizeof(List));
|
||||
l->nitems = 0;
|
||||
l->maxitems = MAXLISTITEMS;
|
||||
l->items = (void **) DohMalloc(l->maxitems * sizeof(void *));
|
||||
for (i = 0; i < MAXLISTITEMS; i++) {
|
||||
l->items[i] = 0;
|
||||
}
|
||||
l->items = (void **) DohCalloc(l->maxitems, sizeof(void *));
|
||||
l->file = 0;
|
||||
l->line = 0;
|
||||
return DohObjMalloc(&DohListType, l);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
#include "dohint.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef DOH_POOL_SIZE
|
||||
#define DOH_POOL_SIZE 4194304
|
||||
#endif
|
||||
|
|
@ -45,13 +48,10 @@ static int pools_initialized = 0;
|
|||
* CreatePool() - Create a new memory pool
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
static void CreatePool() {
|
||||
static void CreatePool(void) {
|
||||
Pool *p = 0;
|
||||
p = (Pool *) DohMalloc(sizeof(Pool));
|
||||
assert(p);
|
||||
p->ptr = (DohBase *) DohMalloc(sizeof(DohBase) * PoolSize);
|
||||
assert(p->ptr);
|
||||
memset(p->ptr, 0, sizeof(DohBase) * PoolSize);
|
||||
p->ptr = (DohBase *) DohCalloc(PoolSize, sizeof(DohBase));
|
||||
p->len = PoolSize;
|
||||
p->blen = PoolSize * sizeof(DohBase);
|
||||
p->current = 0;
|
||||
|
|
@ -65,7 +65,7 @@ static void CreatePool() {
|
|||
* InitPools() - Initialize the memory allocator
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
static void InitPools() {
|
||||
static void InitPools(void) {
|
||||
if (pools_initialized)
|
||||
return;
|
||||
CreatePool(); /* Create initial pool */
|
||||
|
|
@ -234,3 +234,59 @@ void DohMemoryDebug(void) {
|
|||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* Function to call instead of exit(). */
|
||||
static void (*doh_exit_handler)(int) = NULL;
|
||||
|
||||
void DohSetExitHandler(void (*new_handler)(int)) {
|
||||
doh_exit_handler = new_handler;
|
||||
}
|
||||
|
||||
void DohExit(int status) {
|
||||
if (doh_exit_handler) {
|
||||
void (*handler)(int) = doh_exit_handler;
|
||||
/* Unset the handler to avoid infinite loops if it tries to do something
|
||||
* which calls DohExit() (e.g. calling Malloc() and that failing).
|
||||
*/
|
||||
doh_exit_handler = NULL;
|
||||
handler(status);
|
||||
}
|
||||
doh_internal_exit(status);
|
||||
}
|
||||
|
||||
static void allocation_failed(size_t n, size_t size) {
|
||||
/* Report and exit as directly as possible to try to avoid further issues due
|
||||
* to lack of memory. */
|
||||
if (n == 1) {
|
||||
#if defined __STDC_VERSION__ && __STDC_VERSION__-0 >= 19901L
|
||||
fprintf(stderr, "Failed to allocate %zu bytes\n", size);
|
||||
#else
|
||||
fprintf(stderr, "Failed to allocate %lu bytes\n", (unsigned long)size);
|
||||
#endif
|
||||
} else {
|
||||
#if defined __STDC_VERSION__ && __STDC_VERSION__-0 >= 19901L
|
||||
fprintf(stderr, "Failed to allocate %zu*%zu bytes\n", n, size);
|
||||
#else
|
||||
fprintf(stderr, "Failed to allocate %lu*%lu bytes\n", (unsigned long)n, (unsigned long)size);
|
||||
#endif
|
||||
}
|
||||
DohExit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void *DohMalloc(size_t size) {
|
||||
void *p = doh_internal_malloc(size);
|
||||
if (!p) allocation_failed(1, size);
|
||||
return p;
|
||||
}
|
||||
|
||||
void *DohRealloc(void *ptr, size_t size) {
|
||||
void *p = doh_internal_realloc(ptr, size);
|
||||
if (!p) allocation_failed(1, size);
|
||||
return p;
|
||||
}
|
||||
|
||||
void *DohCalloc(size_t n, size_t size) {
|
||||
void *p = doh_internal_calloc(n, size);
|
||||
if (!p) allocation_failed(n, size);
|
||||
return p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,7 +229,6 @@ static void DohString_append(DOH *so, const DOHString_or_char *str) {
|
|||
if (newlen >= newmaxsize - 1)
|
||||
newmaxsize = newlen + 1;
|
||||
s->str = (char *) DohRealloc(s->str, newmaxsize);
|
||||
assert(s->str);
|
||||
s->maxsize = newmaxsize;
|
||||
}
|
||||
tc = s->str;
|
||||
|
|
@ -296,7 +295,6 @@ static int String_insert(DOH *so, int pos, DOH *str) {
|
|||
while (s->maxsize <= s->len + len) {
|
||||
int newsize = 2 * s->maxsize;
|
||||
s->str = (char *) DohRealloc(s->str, newsize);
|
||||
assert(s->str);
|
||||
s->maxsize = newsize;
|
||||
}
|
||||
memmove(s->str + pos + len, s->str + pos, (s->len - pos));
|
||||
|
|
@ -424,7 +422,6 @@ static int String_write(DOH *so, const void *buffer, int len) {
|
|||
newlen = s->sp + len + 1;
|
||||
if (newlen > s->maxsize) {
|
||||
s->str = (char *) DohRealloc(s->str, newlen);
|
||||
assert(s->str);
|
||||
s->maxsize = newlen;
|
||||
s->len = s->sp + len;
|
||||
}
|
||||
|
|
@ -517,7 +514,6 @@ static int String_putc(DOH *so, int ch) {
|
|||
if (len > (maxsize - 2)) {
|
||||
maxsize *= 2;
|
||||
tc = (char *) DohRealloc(tc, maxsize);
|
||||
assert(tc);
|
||||
s->maxsize = (int) maxsize;
|
||||
s->str = tc;
|
||||
}
|
||||
|
|
@ -614,11 +610,13 @@ static char *match_identifier(char *base, char *s, char *token, int tokenlen) {
|
|||
if (!s)
|
||||
return 0;
|
||||
if ((s > base) && (isalnum((int) *(s - 1)) || (*(s - 1) == '_'))) {
|
||||
s += tokenlen;
|
||||
/* We could advance by tokenlen if strstr(s, token) matches can't overlap. */
|
||||
++s;
|
||||
continue;
|
||||
}
|
||||
if (isalnum((int) *(s + tokenlen)) || (*(s + tokenlen) == '_')) {
|
||||
s += tokenlen;
|
||||
/* We could advance by tokenlen if strstr(s, token) matches can't overlap. */
|
||||
++s;
|
||||
continue;
|
||||
}
|
||||
return s;
|
||||
|
|
@ -628,12 +626,14 @@ static char *match_identifier(char *base, char *s, char *token, int tokenlen) {
|
|||
|
||||
|
||||
static char *match_identifier_begin(char *base, char *s, char *token, int tokenlen) {
|
||||
(void)tokenlen;
|
||||
while (s) {
|
||||
s = strstr(s, token);
|
||||
if (!s)
|
||||
return 0;
|
||||
if ((s > base) && (isalnum((int) *(s - 1)) || (*(s - 1) == '_'))) {
|
||||
s += tokenlen;
|
||||
/* We could advance by tokenlen if strstr(s, token) matches can't overlap. */
|
||||
++s;
|
||||
continue;
|
||||
}
|
||||
return s;
|
||||
|
|
@ -648,7 +648,8 @@ static char *match_identifier_end(char *base, char *s, char *token, int tokenlen
|
|||
if (!s)
|
||||
return 0;
|
||||
if (isalnum((int) *(s + tokenlen)) || (*(s + tokenlen) == '_')) {
|
||||
s += tokenlen;
|
||||
/* We could advance by tokenlen if strstr(s, token) matches can't overlap. */
|
||||
++s;
|
||||
continue;
|
||||
}
|
||||
return s;
|
||||
|
|
@ -663,7 +664,8 @@ static char *match_number_end(char *base, char *s, char *token, int tokenlen) {
|
|||
if (!s)
|
||||
return 0;
|
||||
if (isdigit((int) *(s + tokenlen))) {
|
||||
s += tokenlen;
|
||||
/* We could advance by tokenlen if strstr(s, token) matches can't overlap. */
|
||||
++s;
|
||||
continue;
|
||||
}
|
||||
return s;
|
||||
|
|
@ -923,7 +925,6 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co
|
|||
newsize *= 2;
|
||||
|
||||
ns = (char *) DohMalloc(newsize);
|
||||
assert(ns);
|
||||
t = ns;
|
||||
s = first;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ const int sectionIndicatorsSize = sizeof(sectionIndicators) / sizeof(*sectionInd
|
|||
const char *simpleCommands[] = {
|
||||
// the first line are escaped chars, except \~, which is a language ID command.
|
||||
"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%", "\"", ".", "::",
|
||||
// Member groups, which we currently ignore.
|
||||
"{", "}",
|
||||
"endcond",
|
||||
"callgraph", "callergraph", "showinitializer", "hideinitializer", "internal",
|
||||
"nosubgrouping", "public", "publicsection", "private", "privatesection",
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
* Part of the Doxygen comment translation module of SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef DOXYGENENTITY_H_
|
||||
#define DOXYGENENTITY_H_
|
||||
#ifndef SWIG_DOXYENTITY_H
|
||||
#define SWIG_DOXYENTITY_H
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
|
|
|||
|
|
@ -1241,18 +1241,21 @@ void DoxygenParser::processHtmlTags(size_t &pos, const std::string &line) {
|
|||
// prepend '<' to distinguish HTML tags from doxygen commands
|
||||
if (!cmd.empty() && addDoxyCommand(m_tokenList, '<' + cmd)) {
|
||||
// it is a valid HTML command
|
||||
if (pos == string::npos) {
|
||||
pos = line.size();
|
||||
}
|
||||
if (line[pos] != '>') {
|
||||
// it should be HTML tag with args,
|
||||
// for example <A ...>, <IMG ...>, ...
|
||||
if (isEndHtmlTag) {
|
||||
m_tokenListIt = m_tokenList.end();
|
||||
printListError(WARN_DOXYGEN_HTML_ERROR, "Doxygen HTML error for tag " + cmd + ": Illegal end HTML tag without '>' found.");
|
||||
printListError(WARN_DOXYGEN_HTML_ERROR, "Doxygen HTML error for tag " + cmd + ": Illegal end HTML tag without greater-than ('>') found.");
|
||||
}
|
||||
|
||||
endHtmlPos = line.find(">", pos);
|
||||
if (endHtmlPos == string::npos) {
|
||||
m_tokenListIt = m_tokenList.end();
|
||||
printListError(WARN_DOXYGEN_HTML_ERROR, "Doxygen HTML error for tag " + cmd + ": HTML tag without '>' found.");
|
||||
printListError(WARN_DOXYGEN_HTML_ERROR, "Doxygen HTML error for tag " + cmd + ": HTML tag without greater-than ('>') found.");
|
||||
}
|
||||
// add args of HTML command, like link URL, image URL, ...
|
||||
m_tokenList.push_back(Token(PLAINSTRING, line.substr(pos, endHtmlPos - pos)));
|
||||
|
|
@ -1266,7 +1269,7 @@ void DoxygenParser::processHtmlTags(size_t &pos, const std::string &line) {
|
|||
}
|
||||
}
|
||||
|
||||
if (pos != string::npos) {
|
||||
if (pos < line.size()) {
|
||||
pos++; // skip '>'
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
* doxyparser.h
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef DOXYGENPARSER_H_
|
||||
#define DOXYGENPARSER_H_
|
||||
#ifndef SWIG_DOXYPARSER_H
|
||||
#define SWIG_DOXYPARSER_H
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
|
@ -238,7 +238,7 @@ private:
|
|||
* Method for Adding a Simple Command
|
||||
* Format: @command
|
||||
* Plain commands, such as newline etc, they contain no other data
|
||||
* \n \\ \@ \& \$ \# \< \> \%
|
||||
* \n \\ \@ \& \$ \# \< \> \% \{ \}
|
||||
*/
|
||||
void addSimpleCommand(const std::string &theCommand, DoxygenEntityList &doxyList);
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
* systems.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef DOXYGENTRANSLATOR_H_
|
||||
#define DOXYGENTRANSLATOR_H_
|
||||
#ifndef SWIG_DOXYTRANSLATOR_H
|
||||
#define SWIG_DOXYTRANSLATOR_H
|
||||
|
||||
#include "swig.h"
|
||||
#include "doxyentity.h"
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ void JavaDocConverter::fillStaticTables() {
|
|||
tagHandlers["f{"] = make_pair(&JavaDocConverter::handleTagVerbatim, "");
|
||||
|
||||
tagHandlers["warning"] = make_pair(&JavaDocConverter::handleTagMessage, "Warning: ");
|
||||
// this command just prints it's contents
|
||||
// this command just prints its contents
|
||||
// (it is internal command of swig's parser, contains plain text)
|
||||
tagHandlers["plainstd::string"] = make_pair(&JavaDocConverter::handlePlainString, "");
|
||||
tagHandlers["plainstd::endl"] = make_pair(&JavaDocConverter::handleNewLine, "");
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
* Module to return documentation for nodes formatted for JavaDoc
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef JAVADOCCONVERTER_H_
|
||||
#define JAVADOCCONVERTER_H_
|
||||
#ifndef SWIG_JAVADOC_H
|
||||
#define SWIG_JAVADOC_H
|
||||
|
||||
#include "doxytranslator.h"
|
||||
#include <map>
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ void PyDocConverter::fillStaticTables() {
|
|||
tagHandlers["ref"] = make_handler(&PyDocConverter::handleTagRef);
|
||||
tagHandlers["result"] = tagHandlers["return"] = tagHandlers["returns"] = make_handler(&PyDocConverter::handleTagReturn);
|
||||
|
||||
// this command just prints it's contents
|
||||
// this command just prints its contents
|
||||
// (it is internal command of swig's parser, contains plain text)
|
||||
tagHandlers["plainstd::string"] = make_handler(&PyDocConverter::handlePlainString);
|
||||
tagHandlers["plainstd::endl"] = make_handler(&PyDocConverter::handleNewLine);
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
* Module to return documentation for nodes formatted for PyDoc
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef PYDOCCONVERTER_H_
|
||||
#define PYDOCCONVERTER_H_
|
||||
#ifndef SWIG_PYDOC_H
|
||||
#define SWIG_PYDOC_H
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@
|
|||
* This file is used as the input for generating Lib/swigwarn.swg.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef SWIGWARN_H_
|
||||
#define SWIGWARN_H_
|
||||
#ifndef SWIG_SWIGWARN_H
|
||||
#define SWIG_SWIGWARN_H
|
||||
|
||||
#define WARN_NONE 0
|
||||
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
#define WARN_DEPRECATED_NAME 121
|
||||
#define WARN_DEPRECATED_NOEXTERN 122
|
||||
#define WARN_DEPRECATED_NODEFAULT 123
|
||||
#define WARN_DEPRECATED_TYPEMAP_LANG 124
|
||||
/* Unused since 4.1.0: #define WARN_DEPRECATED_TYPEMAP_LANG 124 */
|
||||
#define WARN_DEPRECATED_INPUT_FILE 125
|
||||
#define WARN_DEPRECATED_NESTED_WORKAROUND 126
|
||||
|
||||
|
|
@ -93,6 +93,7 @@
|
|||
#define WARN_PARSE_NESTED_TEMPLATE 324
|
||||
#define WARN_PARSE_NAMED_NESTED_CLASS 325
|
||||
#define WARN_PARSE_EXTEND_NAME 326
|
||||
#define WARN_PARSE_EXTERN_TEMPLATE 327
|
||||
|
||||
#define WARN_CPP11_LAMBDA 340
|
||||
#define WARN_CPP11_ALIAS_DECLARATION 341 /* redundant now */
|
||||
|
|
@ -146,8 +147,9 @@
|
|||
#define WARN_IGNORE_OPERATOR_NEWARR 394 /* new [] */
|
||||
#define WARN_IGNORE_OPERATOR_DELARR 395 /* delete [] */
|
||||
#define WARN_IGNORE_OPERATOR_REF 396 /* operator *() */
|
||||
#define WARN_IGNORE_OPERATOR_LTEQUALGT 397 /* <=> */
|
||||
|
||||
/* 394-399 are reserved */
|
||||
/* please leave 350-399 free for WARN_IGNORE_OPERATOR_* */
|
||||
|
||||
/* -- Type system and typemaps -- */
|
||||
|
||||
|
|
@ -162,6 +164,7 @@
|
|||
#define WARN_TYPEMAP_SWIGTYPE 452 /* No longer issued */
|
||||
#define WARN_TYPEMAP_APPLY_UNDEF 453
|
||||
#define WARN_TYPEMAP_SWIGTYPELEAK 454
|
||||
#define WARN_TYPEMAP_WCHARLEAK 455
|
||||
|
||||
#define WARN_TYPEMAP_IN_UNDEF 460
|
||||
#define WARN_TYPEMAP_OUT_UNDEF 461
|
||||
|
|
@ -212,6 +215,7 @@
|
|||
#define WARN_LANG_EXTEND_DESTRUCTOR 523
|
||||
#define WARN_LANG_EXPERIMENTAL 524
|
||||
#define WARN_LANG_DIRECTOR_FINAL 525
|
||||
#define WARN_LANG_USING_NAME_DIFFERENT 526
|
||||
|
||||
/* -- Doxygen comments -- */
|
||||
|
||||
|
|
@ -223,7 +227,7 @@
|
|||
#define WARN_DOXYGEN_UNKNOWN_CHARACTER 565
|
||||
#define WARN_DOXYGEN_UNEXPECTED_ITERATOR_VALUE 566
|
||||
|
||||
/* -- Reserved (600-799) -- */
|
||||
/* -- Reserved (600-699) -- */
|
||||
|
||||
/* -- Language module specific warnings (700 - 899) -- */
|
||||
|
||||
|
|
@ -282,7 +286,7 @@
|
|||
#define WARN_JAVA_TYPEMAP_DIRECTORIN_NODESC 824
|
||||
#define WARN_JAVA_NO_DIRECTORCONNECT_ATTR 825
|
||||
#define WARN_JAVA_NSPACE_WITHOUT_PACKAGE 826
|
||||
#define WARN_JAVA_TYPEMAP_INTERFACEMODIFIERS_UNDEF 847
|
||||
#define WARN_JAVA_TYPEMAP_INTERFACEMODIFIERS_UNDEF 827
|
||||
|
||||
/* please leave 810-829 free for Java */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ AUTOMAKE_OPTIONS = foreign nostdinc subdir-objects 1.7.2
|
|||
SOURCE_DIR=$(top_srcdir)/Source
|
||||
BUILD_SOURCE_DIR=$(top_builddir)/Source
|
||||
|
||||
SWIG_CXX_DEFS = @SWILL@
|
||||
|
||||
AM_CPPFLAGS = -I$(BUILD_SOURCE_DIR)/Include \
|
||||
-I$(BUILD_SOURCE_DIR)/CParse \
|
||||
-I$(SOURCE_DIR)/Include \
|
||||
|
|
@ -18,7 +16,7 @@ AM_CPPFLAGS = -I$(BUILD_SOURCE_DIR)/Include \
|
|||
-I$(SOURCE_DIR)/Swig \
|
||||
-I$(SOURCE_DIR)/Modules
|
||||
|
||||
AM_CXXFLAGS = $(SWIG_CXX_DEFS)
|
||||
AM_CXXFLAGS =
|
||||
|
||||
AM_YFLAGS = -d
|
||||
|
||||
|
|
@ -46,7 +44,6 @@ eswig_SOURCES = CParse/cscanner.c \
|
|||
Doxygen/pydoc.cxx \
|
||||
Doxygen/pydoc.h \
|
||||
Modules/allocate.cxx \
|
||||
Modules/browser.cxx \
|
||||
Modules/contract.cxx \
|
||||
Modules/c.cxx \
|
||||
Modules/csharp.cxx \
|
||||
|
|
@ -99,7 +96,6 @@ eswig_SOURCES = CParse/cscanner.c \
|
|||
Swig/wrapfunc.c
|
||||
|
||||
bin_PROGRAMS = eswig
|
||||
eswig_LDADD = @SWIGLIBS@
|
||||
|
||||
# Override the link stage to avoid using Libtool
|
||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ class Allocate:public Dispatcher {
|
|||
// Found a polymorphic method.
|
||||
// Mark the polymorphic method, in case the virtual keyword was not used.
|
||||
Setattr(n, "storage", "virtual");
|
||||
if (!Getattr(b, "feature:interface")) { // interface implementation neither hides nor overrides
|
||||
if (!GetFlag(b, "feature:interface")) { // interface implementation neither hides nor overrides
|
||||
if (both_have_public_access || both_have_protected_access) {
|
||||
if (!is_non_public_base(inclass, b))
|
||||
Setattr(n, "override", base); // Note C# definition of override, ie access must be the same
|
||||
|
|
@ -779,6 +779,12 @@ Allocate():
|
|||
|
||||
if (Swig_storage_isstatic(n)) {
|
||||
Setattr(n, "cplus:staticbase", inclass);
|
||||
} else if (Cmp(Getattr(n, "kind"), "variable") == 0) {
|
||||
/* Check member variable to determine whether assignment is valid */
|
||||
if (SwigType_isreference(Getattr(n, "type"))) {
|
||||
/* Can't assign a class with reference member data */
|
||||
Setattr(inclass, "allocate:noassign", "1");
|
||||
}
|
||||
}
|
||||
|
||||
String *name = Getattr(n, "name");
|
||||
|
|
|
|||
|
|
@ -1,421 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
* included with the SWIG source code as distributed by the SWIG developers
|
||||
* and at http://www.swig.org/legal.html.
|
||||
*
|
||||
* browser.cxx
|
||||
*
|
||||
* A web-base parse tree browser using SWILL. This is an optional
|
||||
* feature that's normally disabled.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#ifdef SWIG_SWILL
|
||||
extern "C" {
|
||||
#include "swill.h"
|
||||
} static FILE *out = 0;
|
||||
static Node *view_top = 0;
|
||||
|
||||
class Browser:public Dispatcher {
|
||||
void show_checkbox(Node *t, Node *n) {
|
||||
int v = 0;
|
||||
if (Getmeta(n, "visible")) {
|
||||
v = 1;
|
||||
}
|
||||
if (v) {
|
||||
Printf(out, "<a name=\"n%p\"></a>[<a href=\"hide.html?node=%p&hn=%p#n%p\">-</a>] ", n, t, n, n);
|
||||
} else {
|
||||
Printf(out, "<a name=\"n%p\"></a>[<a href=\"show.html?node=%p&hn=%p#n%p\">+</a>] ", n, t, n, n);
|
||||
}
|
||||
}
|
||||
void show_attributes(Node *obj) {
|
||||
if (!Getmeta(obj, "visible"))
|
||||
return;
|
||||
String *os = NewString("");
|
||||
String *k;
|
||||
Iterator ki;
|
||||
ki = First(obj);
|
||||
while (ki.key) {
|
||||
k = ki.key;
|
||||
if ((Cmp(k, "nodeType") == 0) || (Cmp(k, "firstChild") == 0) || (Cmp(k, "lastChild") == 0) ||
|
||||
(Cmp(k, "parentNode") == 0) || (Cmp(k, "nextSibling") == 0) || (Cmp(k, "previousSibling") == 0) || (*(Char(k)) == '$')) {
|
||||
/* Do nothing */
|
||||
} else if (Cmp(k, "parms") == 0) {
|
||||
String *o = NewString("");
|
||||
Printf(o, "%s", ParmList_protostr(Getattr(obj, k)));
|
||||
Replaceall(o, "&", "&");
|
||||
Replaceall(o, "<", "<");
|
||||
Replaceall(o, ">", ">");
|
||||
Printf(os, "<a href=\"data.html?n=%p\">?</a> %-12s - %s\n", Getattr(obj, k), k, o);
|
||||
Delete(o);
|
||||
} else {
|
||||
DOH *o;
|
||||
char *trunc = "";
|
||||
if (DohIsString(Getattr(obj, k))) {
|
||||
o = Str(Getattr(obj, k));
|
||||
if (Len(o) > 70) {
|
||||
trunc = "...";
|
||||
}
|
||||
Replaceall(o, "&", "&");
|
||||
Replaceall(o, "<", "<");
|
||||
Printf(os, "<a href=\"data.html?n=%p\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
|
||||
Delete(o);
|
||||
} else {
|
||||
Printf(os, "<a href=\"data.html?n=%p\">?</a> %-12s - %p\n", Getattr(obj, k), k, Getattr(obj, k));
|
||||
}
|
||||
}
|
||||
ki = Next(ki);
|
||||
}
|
||||
Printf(out, "<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
|
||||
Delete(os);
|
||||
}
|
||||
|
||||
public:
|
||||
virtual int emit_one(Node *n) {
|
||||
char *tag = Char(nodeType(n));
|
||||
char *file = Char(Getfile(n));
|
||||
int line = Getline(n);
|
||||
char *name = GetChar(n, "name");
|
||||
|
||||
show_checkbox(view_top, n);
|
||||
Printf(out, "<b><a href=\"index.html?node=%p\">%s</a></b>", n, tag);
|
||||
if (name) {
|
||||
Printf(out, " (%s)", name);
|
||||
}
|
||||
Printf(out, ". %s:%d\n", file, line);
|
||||
Printf(out, "<br>");
|
||||
Dispatcher::emit_one(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
virtual int emit_children(Node *n) {
|
||||
if (Getmeta(n, "visible")) {
|
||||
Printf(out, "<blockquote>\n");
|
||||
Dispatcher::emit_children(n);
|
||||
Printf(out, "</blockquote>\n");
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
virtual int defaultHandler(Node *n) {
|
||||
show_attributes(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
virtual int top(Node *n) {
|
||||
show_attributes(n);
|
||||
emit_children(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
virtual int includeDirective(Node *n) {
|
||||
show_attributes(n);
|
||||
emit_children(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
virtual int importDirective(Node *n) {
|
||||
show_attributes(n);
|
||||
emit_children(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
virtual int extendDirective(Node *n) {
|
||||
show_attributes(n);
|
||||
emit_children(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
virtual int classDeclaration(Node *n) {
|
||||
show_attributes(n);
|
||||
emit_children(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
virtual int templateDeclaration(Node *n) {
|
||||
show_attributes(n);
|
||||
emit_children(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
virtual int lambdaDeclaration(Node *n) {
|
||||
show_attributes(n);
|
||||
emit_children(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
virtual int enumDeclaration(Node *n) {
|
||||
show_attributes(n);
|
||||
emit_children(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
virtual int typemapDirective(Node *n) {
|
||||
show_attributes(n);
|
||||
emit_children(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
virtual int namespaceDeclaration(Node *n) {
|
||||
show_attributes(n);
|
||||
emit_children(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
virtual int usingDeclaration(Node *n) {
|
||||
show_attributes(n);
|
||||
emit_children(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static int browser_exit = 0;
|
||||
static Node *tree_top = 0;
|
||||
static Browser *browse = 0;
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* exit_handler() - Force the browser to exit
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
void exit_handler(FILE *f) {
|
||||
browser_exit = 1;
|
||||
Printf(f, "Terminated.\n");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* node_handler() - Generate information about a specific node
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
static void display(FILE *f, Node *n) {
|
||||
/* Print standard HTML header */
|
||||
|
||||
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", Swig_package_version());
|
||||
Printf(f, "<b>SWIG-%s</b><br>\n", Swig_package_version());
|
||||
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
|
||||
Printf(f, " [ <a href=\"index.html?node=%p\">Top</a> ]", tree_top);
|
||||
if (n != tree_top) {
|
||||
Printf(f, " [ <a href=\"index.html?node=%p\">Up</a> ]", parentNode(n));
|
||||
}
|
||||
Printf(f, " [ <a href=\"symbol.html\">Symbols</a> ]");
|
||||
Printf(f, "<br><hr><p>\n");
|
||||
|
||||
out = f;
|
||||
|
||||
browse->emit_one(n);
|
||||
|
||||
/* Print standard footer */
|
||||
Printf(f, "<br><hr></BODY></HTML>\n");
|
||||
|
||||
}
|
||||
|
||||
void node_handler(FILE *f) {
|
||||
Node *n = 0;
|
||||
if (!swill_getargs("p(node)", &n)) {
|
||||
n = tree_top;
|
||||
}
|
||||
view_top = n;
|
||||
display(f, n);
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* hide_handler() - Hide a node
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
void hide_handler(FILE *f) {
|
||||
Node *n = 0;
|
||||
if (!swill_getargs("p(hn)", &n)) {
|
||||
n = 0;
|
||||
}
|
||||
if (n) {
|
||||
Delmeta(n, "visible");
|
||||
}
|
||||
node_handler(f);
|
||||
}
|
||||
|
||||
void show_handler(FILE *f) {
|
||||
Node *n = 0;
|
||||
if (!swill_getargs("p(hn)", &n)) {
|
||||
n = 0;
|
||||
}
|
||||
if (n) {
|
||||
Setmeta(n, "visible", "1");
|
||||
}
|
||||
node_handler(f);
|
||||
}
|
||||
|
||||
void raw_data(FILE *out, Node *obj) {
|
||||
if (!obj)
|
||||
return;
|
||||
if (DohIsMapping(obj)) {
|
||||
String *k;
|
||||
Iterator ki;
|
||||
String *os = NewString("");
|
||||
Printf(os, "Hash {\n");
|
||||
ki = First(obj);
|
||||
while (ki.key) {
|
||||
k = ki.key;
|
||||
DOH *o;
|
||||
const char *trunc = "";
|
||||
if (DohIsString(Getattr(obj, k))) {
|
||||
o = Str(Getattr(obj, k));
|
||||
if (Len(o) > 70) {
|
||||
trunc = "...";
|
||||
}
|
||||
Replaceall(o, "<", "<");
|
||||
Printf(os, " <a href=\"data.html?n=%p\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
|
||||
Delete(o);
|
||||
} else {
|
||||
Printf(os, " <a href=\"data.html?n=%p\">?</a> %-12s - %p\n", Getattr(obj, k), k, Getattr(obj, k));
|
||||
}
|
||||
ki = Next(ki);
|
||||
}
|
||||
Printf(os, "}\n");
|
||||
Printf(out, "<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
|
||||
Delete(os);
|
||||
} else if (DohIsString(obj)) {
|
||||
String *o = Str(obj);
|
||||
Replaceall(o, "<", "<");
|
||||
Printf(out, "<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(o));
|
||||
Delete(o);
|
||||
} else if (DohIsSequence(obj)) {
|
||||
int i;
|
||||
String *os = NewString("");
|
||||
Printf(os, "List [\n");
|
||||
for (i = 0; i < Len(obj); i++) {
|
||||
DOH *o = Getitem(obj, i);
|
||||
const char *trunc = "";
|
||||
if (DohIsString(o)) {
|
||||
String *s = Str(o);
|
||||
if (Len(s) > 70) {
|
||||
trunc = "...";
|
||||
}
|
||||
Replaceall(o, "<", "<");
|
||||
Printf(os, " <a href=\"data.html?n=%p\">?</a> [%d] - \"%(escape)-0.70s%s\"\n", o, i, s, trunc);
|
||||
Delete(s);
|
||||
} else {
|
||||
Printf(os, " <a href=\"data.html?n=%p\">?</a> [%d] - %p\n", o, i, o);
|
||||
}
|
||||
}
|
||||
Printf(os, "\n]\n");
|
||||
Printf(out, "<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
|
||||
Delete(os);
|
||||
}
|
||||
}
|
||||
|
||||
void data_handler(FILE *f) {
|
||||
DOH *n = 0;
|
||||
if (!swill_getargs("p(n)", &n)) {
|
||||
n = 0;
|
||||
}
|
||||
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", Swig_package_version());
|
||||
Printf(f, "<b>SWIG-%s</b><br>\n", Swig_package_version());
|
||||
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
|
||||
Printf(f, " [ <a href=\"index.html?node=%p\">Top</a> ]", tree_top);
|
||||
Printf(f, "<br><hr><p>\n");
|
||||
if (n) {
|
||||
raw_data(f, n);
|
||||
}
|
||||
/* Print standard footer */
|
||||
Printf(f, "<br><hr></BODY></HTML>\n");
|
||||
}
|
||||
|
||||
void symbol_handler(FILE *f) {
|
||||
Symtab *sym;
|
||||
char *name = 0;
|
||||
|
||||
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", Swig_package_version());
|
||||
Printf(f, "<b>SWIG-%s</b><br>\n", Swig_package_version());
|
||||
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
|
||||
Printf(f, " [ <a href=\"index.html?node=%p\">Top</a> ]", tree_top);
|
||||
Printf(f, " [ <a href=\"symbol.html\">Symbols</a> ]");
|
||||
Printf(f, "<br><hr><p>\n");
|
||||
|
||||
if (!swill_getargs("p(sym)|s(name)", &sym, &name)) {
|
||||
sym = Swig_symbol_getscope("");
|
||||
name = 0;
|
||||
}
|
||||
if (!sym) {
|
||||
Printf(f, "No symbol table specified!\n");
|
||||
return;
|
||||
}
|
||||
{
|
||||
String *q = Swig_symbol_qualifiedscopename(sym);
|
||||
if (!Len(q)) {
|
||||
Printf(f, "<b>Symbol table: :: (global)</b><br>\n");
|
||||
} else {
|
||||
Printf(f, "<b>Symbol table: %s</b><br>\n", q);
|
||||
}
|
||||
Delete(q);
|
||||
}
|
||||
|
||||
fprintf(f, "<p><form action=\"symbol.html\" method=GET>\n");
|
||||
fprintf(f, "Symbol lookup: <input type=text name=name size=40></input><br>\n");
|
||||
fprintf(f, "<input type=hidden name=sym value=\"%p\">\n", sym);
|
||||
fprintf(f, "Submit : <input type=submit></input>\n");
|
||||
fprintf(f, "</form>");
|
||||
|
||||
if (name) {
|
||||
Node *n = Swig_symbol_clookup(name, sym);
|
||||
Printf(f, "Symbol '%s':\n", name);
|
||||
Printf(f, "<blockquote>\n");
|
||||
if (!n) {
|
||||
Printf(f, "Not defined!\n");
|
||||
} else {
|
||||
raw_data(f, n);
|
||||
}
|
||||
Printf(f, "</blockquote>\n");
|
||||
}
|
||||
|
||||
Printf(f, "<p><b>Nested scopes</b><br>\n");
|
||||
Printf(f, "<blockquote><pre>\n");
|
||||
{
|
||||
Hash *h;
|
||||
h = firstChild(sym);
|
||||
while (h) {
|
||||
Printf(f, "<a href=\"symbol.html?sym=%p\">%s</a>\n", h, Getattr(h, "name"));
|
||||
h = nextSibling(h);
|
||||
}
|
||||
}
|
||||
Printf(f, "</pre></blockquote>\n");
|
||||
|
||||
Printf(f, "<p><b>Symbol table contents</b></br>\n");
|
||||
raw_data(f, Getattr(sym, "symtab"));
|
||||
Printf(f, "<br><hr></BODY></HTML>\n");
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void Swig_browser(Node *top, int port) {
|
||||
#ifdef SWIG_SWILL
|
||||
int sport;
|
||||
browser_exit = 0;
|
||||
|
||||
/* Initialize the server */
|
||||
sport = swill_init(port);
|
||||
if (sport < 0) {
|
||||
Printf(stderr, "Couldn't open socket on port %d. Sorry.\n", port);
|
||||
return;
|
||||
}
|
||||
browse = new Browser();
|
||||
Setmeta(top, "visible", "1");
|
||||
tree_top = top;
|
||||
|
||||
Printf(stderr, "SWIG: Tree browser listening on port %d\n", sport);
|
||||
|
||||
swill_handle("exit.html", exit_handler, 0);
|
||||
swill_handle("index.html", node_handler, 0);
|
||||
swill_handle("hide.html", hide_handler, 0);
|
||||
swill_handle("show.html", show_handler, 0);
|
||||
swill_handle("data.html", data_handler, 0);
|
||||
swill_handle("symbol.html", symbol_handler, 0);
|
||||
swill_netscape("index.html");
|
||||
|
||||
while (!browser_exit) {
|
||||
swill_serve();
|
||||
}
|
||||
Printf(stderr, "Browser terminated.\n");
|
||||
swill_close();
|
||||
delete browse;
|
||||
return;
|
||||
#else
|
||||
(void) top;
|
||||
(void) port;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ int CFFI::top(Node *n) {
|
|||
File *f_lisp = NewFile(lisp_filename, "w", SWIG_output_files());
|
||||
if (!f_lisp) {
|
||||
FileErrorDisplay(lisp_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (CPlusPlus || CWrap) {
|
||||
|
|
@ -142,7 +142,7 @@ int CFFI::top(Node *n) {
|
|||
if (!f_begin) {
|
||||
Delete(f_lisp);
|
||||
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
String *clos_filename = NewString("");
|
||||
|
|
@ -151,7 +151,7 @@ int CFFI::top(Node *n) {
|
|||
if (!f_clos) {
|
||||
Delete(f_lisp);
|
||||
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
f_begin = NewString("");
|
||||
|
|
@ -217,7 +217,7 @@ int CFFI::classHandler(Node *n) {
|
|||
} else {
|
||||
Printf(stderr, "Don't know how to deal with %s kind of class yet.\n", kind);
|
||||
Printf(stderr, " (name: %s)\n", name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -873,7 +873,7 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
|
|||
if (Strcmp(kind, "struct") != 0 && Strcmp(kind, "union") != 0) {
|
||||
Printf(stderr, "Don't know how to deal with %s kind of class yet.\n", kind);
|
||||
Printf(stderr, " (name: %s)\n", name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
String *lisp_name = lispify_name(n, name, "'classname");
|
||||
|
||||
|
|
@ -909,7 +909,7 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
|
|||
// nodeType(c),
|
||||
// Getattr(c, "name"),
|
||||
// Getattr(c, "type"));
|
||||
// SWIG_exit(EXIT_FAILURE);
|
||||
// Exit(EXIT_FAILURE);
|
||||
} else {
|
||||
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), Getattr(c, "type"));
|
||||
|
||||
|
|
@ -981,27 +981,14 @@ String *CFFI::lispify_name(Node *n, String *ty, const char *flag, bool kw) {
|
|||
/* utilities */
|
||||
/* returns new string w/ parens stripped */
|
||||
String *CFFI::strip_parens(String *string) {
|
||||
char *s = Char(string), *p;
|
||||
char *s = Char(string);
|
||||
int len = Len(string);
|
||||
String *res;
|
||||
|
||||
if (len == 0 || s[0] != '(' || s[len - 1] != ')') {
|
||||
return NewString(string);
|
||||
}
|
||||
|
||||
p = (char *) malloc(len - 2 + 1);
|
||||
if (!p) {
|
||||
Printf(stderr, "Malloc failed\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
strncpy(p, s + 1, len - 1);
|
||||
p[len - 2] = 0; /* null terminate */
|
||||
|
||||
res = NewString(p);
|
||||
free(p);
|
||||
|
||||
return res;
|
||||
return NewStringWithSize(s + 1, len - 2);
|
||||
}
|
||||
|
||||
String *CFFI::trim(String *str) {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "swigmod.h"
|
||||
#include <limits.h> // for INT_MAX
|
||||
#include "cparse.h"
|
||||
#include <limits.h> // for INT_MAX
|
||||
#include <ctype.h>
|
||||
|
||||
/* Hash type used for upcalls from C/C++ */
|
||||
|
|
@ -316,24 +316,24 @@ public:
|
|||
|
||||
if (!outfile) {
|
||||
Printf(stderr, "Unable to determine outfile\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (directorsEnabled()) {
|
||||
if (!outfile_h) {
|
||||
Printf(stderr, "Unable to determine outfile_h\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
|
||||
if (!f_runtime_h) {
|
||||
FileErrorDisplay(outfile_h);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -670,7 +670,7 @@ public:
|
|||
f_single_out = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_single_out) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, Copy(filen));
|
||||
Delete(filen);
|
||||
|
|
@ -684,7 +684,7 @@ public:
|
|||
File *f = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, Copy(filen));
|
||||
Delete(filen);
|
||||
|
|
@ -1699,10 +1699,9 @@ public:
|
|||
* addInterfaceNameAndUpcasts()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, Hash *base_list, SwigType *c_classname) {
|
||||
List *keys = Keys(base_list);
|
||||
for (Iterator it = First(keys); it.item; it = Next(it)) {
|
||||
Node *base = Getattr(base_list, it.item);
|
||||
void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, List *base_list, SwigType *c_classname) {
|
||||
for (Iterator it = First(base_list); it.item; it = Next(it)) {
|
||||
Node *base = it.item;
|
||||
SwigType *c_baseclassname = Getattr(base, "name");
|
||||
String *interface_name = Getattr(base, "interface:name");
|
||||
if (Len(interface_list))
|
||||
|
|
@ -1729,7 +1728,6 @@ public:
|
|||
Delete(cptr_method_name);
|
||||
Delete(interface_code);
|
||||
}
|
||||
Delete(keys);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -1806,7 +1804,7 @@ public:
|
|||
if (baselist) {
|
||||
Iterator base = First(baselist);
|
||||
while (base.item) {
|
||||
if (!(GetFlag(base.item, "feature:ignore") || Getattr(base.item, "feature:interface"))) {
|
||||
if (!(GetFlag(base.item, "feature:ignore") || GetFlag(base.item, "feature:interface"))) {
|
||||
SwigType *baseclassname = Getattr(base.item, "name");
|
||||
if (!c_baseclassname) {
|
||||
String *name = getProxyName(baseclassname);
|
||||
|
|
@ -1825,7 +1823,7 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
Hash *interface_bases = Getattr(n, "interface:bases");
|
||||
List *interface_bases = Getattr(n, "interface:bases");
|
||||
if (interface_bases)
|
||||
addInterfaceNameAndUpcasts(smart, interface_list, interface_upcasts, interface_bases, c_classname);
|
||||
|
||||
|
|
@ -1964,9 +1962,32 @@ public:
|
|||
// Only emit if there is at least one director method
|
||||
Printf(proxy_class_code, "\n");
|
||||
Printf(proxy_class_code, " private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes) {\n");
|
||||
Printf(proxy_class_code,
|
||||
" global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);\n");
|
||||
Printf(proxy_class_code, " bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(%s));\n", proxy_class_name);
|
||||
Printf(proxy_class_code, " global::System.Reflection.MethodInfo[] methodInfos = this.GetType().GetMethods(\n");
|
||||
Printf(proxy_class_code, " global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance);\n");
|
||||
Printf(proxy_class_code, " foreach (global::System.Reflection.MethodInfo methodInfo in methodInfos) {\n");
|
||||
Printf(proxy_class_code, " if (methodInfo.DeclaringType == null)\n");
|
||||
Printf(proxy_class_code, " continue;\n\n");
|
||||
Printf(proxy_class_code, " if (methodInfo.Name != methodName)\n");
|
||||
Printf(proxy_class_code, " continue;\n\n");
|
||||
Printf(proxy_class_code, " var parameters = methodInfo.GetParameters();\n");
|
||||
Printf(proxy_class_code, " if (parameters.Length != methodTypes.Length)\n");
|
||||
Printf(proxy_class_code, " continue;\n\n");
|
||||
Printf(proxy_class_code, " bool parametersMatch = true;\n");
|
||||
Printf(proxy_class_code, " for (var i = 0; i < parameters.Length; i++) {\n");
|
||||
Printf(proxy_class_code, " if (parameters[i].ParameterType != methodTypes[i]) {\n");
|
||||
Printf(proxy_class_code, " parametersMatch = false;\n");
|
||||
Printf(proxy_class_code, " break;\n");
|
||||
Printf(proxy_class_code, " }\n");
|
||||
Printf(proxy_class_code, " }\n\n");
|
||||
Printf(proxy_class_code, " if (!parametersMatch)\n");
|
||||
Printf(proxy_class_code, " continue;\n\n");
|
||||
Printf(proxy_class_code, " if (methodInfo.IsVirtual && (methodInfo.DeclaringType.IsSubclassOf(typeof(%s))) &&\n", proxy_class_name);
|
||||
Printf(proxy_class_code, " methodInfo.DeclaringType != methodInfo.GetBaseDefinition().DeclaringType) {\n");
|
||||
Printf(proxy_class_code, " return true;\n");
|
||||
Printf(proxy_class_code, " }\n");
|
||||
Printf(proxy_class_code, " }\n\n");
|
||||
Printf(proxy_class_code, " return false;\n");
|
||||
|
||||
/* Could add this code to cover corner case where the GetMethod() returns a method which allows type
|
||||
* promotion, eg it will return foo(double), if looking for foo(int).
|
||||
if (hasDerivedMethod) {
|
||||
|
|
@ -1986,7 +2007,7 @@ public:
|
|||
}
|
||||
}
|
||||
*/
|
||||
Printf(proxy_class_code, " return hasDerivedMethod;\n");
|
||||
//Printf(proxy_class_code, " return hasDerivedMethod;\n");
|
||||
Printf(proxy_class_code, " }\n");
|
||||
}
|
||||
|
||||
|
|
@ -2045,7 +2066,7 @@ public:
|
|||
if (List *baselist = Getattr(n, "bases")) {
|
||||
String *bases = 0;
|
||||
for (Iterator base = First(baselist); base.item; base = Next(base)) {
|
||||
if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface"))
|
||||
if (GetFlag(base.item, "feature:ignore") || !GetFlag(base.item, "feature:interface"))
|
||||
continue; // TODO: warn about skipped non-interface bases
|
||||
String *base_iname = Getattr(base.item, "interface:name");
|
||||
if (!bases)
|
||||
|
|
@ -2096,7 +2117,7 @@ public:
|
|||
|
||||
if (proxy_flag) {
|
||||
proxy_class_name = NewString(Getattr(n, "sym:name"));
|
||||
String *interface_name = Getattr(n, "feature:interface") ? Getattr(n, "interface:name") : 0;
|
||||
String *interface_name = GetFlag(n, "feature:interface") ? Getattr(n, "interface:name") : 0;
|
||||
if (Node *outer = Getattr(n, "nested:outer")) {
|
||||
String *outerClassesPrefix = Copy(Getattr(outer, "sym:name"));
|
||||
for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) {
|
||||
|
|
@ -2122,12 +2143,12 @@ public:
|
|||
full_imclass_name = NewStringf("%s", imclass_name);
|
||||
if (Cmp(proxy_class_name, imclass_name) == 0) {
|
||||
Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (Cmp(proxy_class_name, module_class_name) == 0) {
|
||||
Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
if (namespce) {
|
||||
|
|
@ -2152,7 +2173,7 @@ public:
|
|||
destructor_call = NewString("");
|
||||
proxy_class_constants_code = NewString("");
|
||||
|
||||
if (Getattr(n, "feature:interface")) {
|
||||
if (GetFlag(n, "feature:interface")) {
|
||||
interface_class_code = NewString("");
|
||||
String *output_directory = outputDirectory(nspace);
|
||||
f_interface = getOutputFile(output_directory, interface_name);
|
||||
|
|
@ -2323,7 +2344,7 @@ public:
|
|||
String *pre_code = NewString("");
|
||||
String *post_code = NewString("");
|
||||
String *terminator_code = NewString("");
|
||||
bool is_interface = Getattr(parentNode(n), "feature:interface") != 0
|
||||
bool is_interface = GetFlag(parentNode(n), "feature:interface") && !checkAttribute(n, "kind", "variable")
|
||||
&& !static_flag && Getattr(n, "interface:owner") == 0;
|
||||
|
||||
if (!proxy_flag)
|
||||
|
|
@ -2553,8 +2574,8 @@ public:
|
|||
Replaceall(imcall, "$imfuncname", intermediary_function_name);
|
||||
String *excode = NewString("");
|
||||
Node *directorNode = Getattr(n, "directorNode");
|
||||
if (directorNode) {
|
||||
UpcallData *udata = Getattr(directorNode, "upcalldata");
|
||||
UpcallData *udata = directorNode ? Getattr(directorNode, "upcalldata") : 0;
|
||||
if (udata) {
|
||||
String *methid = Getattr(udata, "class_methodidx");
|
||||
|
||||
if (!Cmp(return_type, "void"))
|
||||
|
|
@ -2572,6 +2593,7 @@ public:
|
|||
} else {
|
||||
Replaceall(imcall, "$imfuncname", intermediary_function_name);
|
||||
}
|
||||
Replaceall(tm, "$imfuncname", intermediary_function_name);
|
||||
Replaceall(tm, "$imcall", imcall);
|
||||
} else {
|
||||
Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csout typemap defined for %s\n", SwigType_str(t, 0));
|
||||
|
|
@ -2615,6 +2637,7 @@ public:
|
|||
if ((tm = Swig_typemap_lookup("csvarin", variable_parm, "", 0))) {
|
||||
substituteClassname(cvariable_type, tm);
|
||||
Replaceall(tm, "$csinput", "value");
|
||||
Replaceall(tm, "$imfuncname", intermediary_function_name);
|
||||
Replaceall(tm, "$imcall", imcall);
|
||||
excodeSubstitute(n, tm, "csvarin", variable_parm);
|
||||
Printf(proxy_class_code, "%s", tm);
|
||||
|
|
@ -2629,6 +2652,7 @@ public:
|
|||
else
|
||||
Replaceall(tm, "$owner", "false");
|
||||
substituteClassname(t, tm);
|
||||
Replaceall(tm, "$imfuncname", intermediary_function_name);
|
||||
Replaceall(tm, "$imcall", imcall);
|
||||
excodeSubstitute(n, tm, "csvarout", n);
|
||||
Printf(proxy_class_code, "%s", tm);
|
||||
|
|
@ -3141,6 +3165,7 @@ public:
|
|||
else
|
||||
Replaceall(tm, "$owner", "false");
|
||||
substituteClassname(t, tm);
|
||||
Replaceall(tm, "$imfuncname", overloaded_name);
|
||||
Replaceall(tm, "$imcall", imcall);
|
||||
} else {
|
||||
Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csout typemap defined for %s\n", SwigType_str(t, 0));
|
||||
|
|
@ -3179,6 +3204,7 @@ public:
|
|||
if ((tm = Getattr(p, "tmap:csvarin"))) {
|
||||
substituteClassname(pt, tm);
|
||||
Replaceall(tm, "$csinput", "value");
|
||||
Replaceall(tm, "$imfuncname", overloaded_name);
|
||||
Replaceall(tm, "$imcall", imcall);
|
||||
excodeSubstitute(n, tm, "csvarin", p);
|
||||
Printf(module_class_code, "%s", tm);
|
||||
|
|
@ -3193,6 +3219,7 @@ public:
|
|||
else
|
||||
Replaceall(tm, "$owner", "false");
|
||||
substituteClassname(t, tm);
|
||||
Replaceall(tm, "$imfuncname", overloaded_name);
|
||||
Replaceall(tm, "$imcall", imcall);
|
||||
excodeSubstitute(n, tm, "csvarout", n);
|
||||
Printf(module_class_code, "%s", tm);
|
||||
|
|
@ -3660,7 +3687,7 @@ public:
|
|||
if (newdir_error) {
|
||||
Printf(stderr, "%s\n", newdir_error);
|
||||
Delete(newdir_error);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Printv(output_directory, nspace_subdirectory, SWIG_FILE_DELIMITER, 0);
|
||||
Delete(nspace_subdirectory);
|
||||
|
|
|
|||
|
|
@ -378,24 +378,24 @@ public:
|
|||
|
||||
if (!outfile) {
|
||||
Printf(stderr, "Unable to determine outfile\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (directorsEnabled()) {
|
||||
if (!outfile_h) {
|
||||
Printf(stderr, "Unable to determine outfile_h\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
|
||||
if (!f_runtime_h) {
|
||||
FileErrorDisplay(outfile_h);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -518,7 +518,7 @@ public:
|
|||
File *im_d_file = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!im_d_file) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, Copy(filen));
|
||||
Delete(filen);
|
||||
|
|
@ -549,7 +549,7 @@ public:
|
|||
File *proxy_d_file = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!proxy_d_file) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, Copy(filen));
|
||||
Delete(filen);
|
||||
|
|
@ -583,7 +583,7 @@ public:
|
|||
File *file = NewFile(filename, "w", SWIG_output_files());
|
||||
if (!file) {
|
||||
FileErrorDisplay(filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delete(filename);
|
||||
|
||||
|
|
@ -863,7 +863,7 @@ public:
|
|||
File *class_file = NewFile(filename, "w", SWIG_output_files());
|
||||
if (!class_file) {
|
||||
FileErrorDisplay(filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, Copy(filename));
|
||||
Delete(filename);
|
||||
|
|
@ -1335,7 +1335,7 @@ public:
|
|||
Delete(output_directory);
|
||||
if (!class_file) {
|
||||
FileErrorDisplay(filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, Copy(filename));
|
||||
Delete(filename);
|
||||
|
|
@ -2898,6 +2898,7 @@ private:
|
|||
} else {
|
||||
Replaceall(imcall, "$imfuncname", intermediary_function_name);
|
||||
}
|
||||
Replaceall(tm, "$imfuncname", intermediary_function_name);
|
||||
Replaceall(tm, "$imcall", imcall);
|
||||
} else {
|
||||
Swig_warning(WARN_D_TYPEMAP_DOUT_UNDEF, input_file, line_number,
|
||||
|
|
@ -3100,6 +3101,7 @@ private:
|
|||
else
|
||||
Replaceall(tm, "$owner", "false");
|
||||
replaceClassname(tm, t);
|
||||
Replaceall(tm, "$imfuncname", overloaded_name);
|
||||
Replaceall(tm, "$imcall", imcall);
|
||||
} else {
|
||||
Swig_warning(WARN_D_TYPEMAP_DOUT_UNDEF, input_file, line_number,
|
||||
|
|
@ -3400,7 +3402,7 @@ private:
|
|||
} else {
|
||||
Printv(upcasts_code,
|
||||
"SWIGEXPORT ", baseclassname, " * ", upcast_wrapper_name,
|
||||
"(", baseclassname, " *objectRef) {\n",
|
||||
"(", classname, " *objectRef) {\n",
|
||||
" return (", baseclassname, " *)objectRef;\n"
|
||||
"}\n",
|
||||
"\n", NIL);
|
||||
|
|
@ -3434,7 +3436,7 @@ private:
|
|||
class_file = NewFile(filename, "w", SWIG_output_files());
|
||||
if (!class_file) {
|
||||
FileErrorDisplay(filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, Copy(filename));
|
||||
Delete(filename);
|
||||
|
|
@ -3756,7 +3758,7 @@ private:
|
|||
Swig_error(input_file, line_number,
|
||||
"Class name cannot be equal to intermediary D module name: %s\n",
|
||||
class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
String *nspace = getNSpace();
|
||||
|
|
@ -3769,7 +3771,7 @@ private:
|
|||
Swig_error(input_file, line_number,
|
||||
"Class name cannot be the same as the root package it is in: %s\n",
|
||||
class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delete(dotless_package);
|
||||
} else {
|
||||
|
|
@ -3778,7 +3780,7 @@ private:
|
|||
Swig_error(input_file, line_number,
|
||||
"Class name cannot be the same as the outermost namespace it is in: %s\n",
|
||||
class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delete(outer);
|
||||
}
|
||||
|
|
@ -3790,7 +3792,7 @@ private:
|
|||
Swig_error(input_file, line_number,
|
||||
"Class name cannot be the same as the innermost namespace it is in: %s\n",
|
||||
class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delete(inner);
|
||||
} else {
|
||||
|
|
@ -3798,7 +3800,7 @@ private:
|
|||
Swig_error(input_file, line_number,
|
||||
"Class name cannot be equal to proxy D module name: %s\n",
|
||||
class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4498,7 +4500,7 @@ private:
|
|||
if (newdir_error) {
|
||||
Printf(stderr, "%s\n", newdir_error);
|
||||
Delete(newdir_error);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Printv(output_directory, nspace_subdirectory, SWIG_FILE_DELIMITER, 0);
|
||||
Delete(nspace_subdirectory);
|
||||
|
|
|
|||
|
|
@ -97,7 +97,6 @@ String *Swig_director_declaration(Node *n) {
|
|||
|
||||
String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) {
|
||||
String *func;
|
||||
int i = 0;
|
||||
int comma = 0;
|
||||
Parm *p = parms;
|
||||
SwigType *pt;
|
||||
|
|
@ -115,7 +114,6 @@ String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) {
|
|||
pname = Getattr(p, "name");
|
||||
Printf(func, "%s", pname);
|
||||
comma = 1;
|
||||
i++;
|
||||
}
|
||||
p = nextSibling(p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,7 +244,6 @@ private:
|
|||
virtual void main(int argc, char *argv[]) {
|
||||
|
||||
SWIG_library_directory("go");
|
||||
bool display_help = false;
|
||||
bool saw_nocgo_flag = false;
|
||||
|
||||
// Process command line options.
|
||||
|
|
@ -329,7 +328,6 @@ private:
|
|||
Swig_arg_error();
|
||||
}
|
||||
} else if (strcmp(argv[i], "-help") == 0) {
|
||||
display_help = true;
|
||||
Printf(stdout, "%s\n", usage);
|
||||
}
|
||||
}
|
||||
|
|
@ -337,7 +335,7 @@ private:
|
|||
|
||||
if (saw_nocgo_flag) {
|
||||
Printf(stderr, "SWIG -go: -no-cgo option is no longer supported\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (gccgo_flag && !pkgpath_option && !prefix_option) {
|
||||
|
|
@ -351,14 +349,6 @@ private:
|
|||
Preprocessor_define("SWIGGO_GCCGO 1", 0);
|
||||
}
|
||||
|
||||
// This test may be removed in the future, when we can assume that
|
||||
// everybody has upgraded to Go 1.1. The code below is prepared
|
||||
// for this test to simply be taken out.
|
||||
if (intgo_type_size == 0 && !display_help) {
|
||||
Printf(stderr, "SWIG -go: -intgosize option required but not specified\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (intgo_type_size == 32) {
|
||||
Preprocessor_define("SWIGGO_INTGO_SIZE 32", 0);
|
||||
} else if (intgo_type_size == 64) {
|
||||
|
|
@ -377,7 +367,7 @@ private:
|
|||
/* ---------------------------------------------------------------------
|
||||
* top()
|
||||
*
|
||||
* For 6g/8g, we are going to create the following files:
|
||||
* For gc, we are going to create the following files:
|
||||
*
|
||||
* 1) A .c or .cxx file compiled with gcc. This file will contain
|
||||
* function wrappers. Each wrapper will take a pointer to a
|
||||
|
|
@ -453,7 +443,7 @@ private:
|
|||
FILE *swig_input = Swig_open(swig_filename);
|
||||
if (swig_input == NULL) {
|
||||
FileErrorDisplay(swig_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
String *swig_input_content = Swig_read_file(swig_input);
|
||||
siphash(&hash, Char(swig_input_content), Len(swig_input_content));
|
||||
|
|
@ -467,25 +457,25 @@ private:
|
|||
f_c_begin = NewFile(c_filename, "w", SWIG_output_files());
|
||||
if (!f_c_begin) {
|
||||
FileErrorDisplay(c_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (directorsEnabled()) {
|
||||
if (!c_filename_h) {
|
||||
Printf(stderr, "Unable to determine outfile_h\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_c_directors_h = NewFile(c_filename_h, "w", SWIG_output_files());
|
||||
if (!f_c_directors_h) {
|
||||
FileErrorDisplay(c_filename_h);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
f_go_begin = NewFile(go_filename, "w", SWIG_output_files());
|
||||
if (!f_go_begin) {
|
||||
FileErrorDisplay(go_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
f_c_runtime = NewString("");
|
||||
|
|
@ -1262,9 +1252,15 @@ private:
|
|||
|
||||
String *goin = goGetattr(p, "tmap:goin");
|
||||
if (goin == NULL) {
|
||||
Printv(f_go_wrappers, "\t", ivar, " := ", ln, NULL);
|
||||
Printv(f_go_wrappers, "\t", ivar, " := ", NULL);
|
||||
bool need_close = false;
|
||||
if ((i == 0 && info->is_destructor) || ((i > 0 || !info->receiver || info->base || info->is_constructor) && goTypeIsInterface(p, pt))) {
|
||||
Printv(f_go_wrappers, ".Swigcptr()", NULL);
|
||||
Printv(f_go_wrappers, "getSwigcptr(", NULL);
|
||||
need_close = true;
|
||||
}
|
||||
Printv(f_go_wrappers, ln, NULL);
|
||||
if (need_close) {
|
||||
Printv(f_go_wrappers, ")", NULL);
|
||||
}
|
||||
Printv(f_go_wrappers, "\n", NULL);
|
||||
Setattr(p, "emit:goinput", ln);
|
||||
|
|
@ -1457,7 +1453,7 @@ private:
|
|||
p = getParm(p);
|
||||
|
||||
SwigType *pt = Copy(Getattr(p, "type"));
|
||||
if (SwigType_isarray(pt)) {
|
||||
if (SwigType_isarray(pt) && Getattr(p, "tmap:gotype") == NULL) {
|
||||
SwigType_del_array(pt);
|
||||
SwigType_add_pointer(pt);
|
||||
}
|
||||
|
|
@ -2208,76 +2204,9 @@ private:
|
|||
}
|
||||
|
||||
for (Node *ni = Getattr(base, "firstChild"); ni; ni = nextSibling(ni)) {
|
||||
|
||||
if (GetFlag(ni, "feature:ignore")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!is_public(ni)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String *type = Getattr(ni, "nodeType");
|
||||
if (Strcmp(type, "constructor") == 0 || Strcmp(type, "destructor") == 0 || Strcmp(type, "enum") == 0 || Strcmp(type, "using") == 0 || Strcmp(type, "classforward") == 0 || Strcmp(type, "template") == 0) {
|
||||
continue;
|
||||
}
|
||||
String *storage = Getattr(ni, "storage");
|
||||
if (storage && (Strcmp(storage, "typedef") == 0 || Strcmp(storage, "friend") == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String *mname = Getattr(ni, "sym:name");
|
||||
if (!mname) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String *lname = Getattr(ni, "name");
|
||||
if (Getattr(class_methods, lname)) {
|
||||
continue;
|
||||
}
|
||||
if (Getattr(local, lname)) {
|
||||
continue;
|
||||
}
|
||||
Setattr(local, lname, NewString(""));
|
||||
|
||||
String *ty = NewString(Getattr(ni, "type"));
|
||||
SwigType_push(ty, Getattr(ni, "decl"));
|
||||
String *fullty = SwigType_typedef_resolve_all(ty);
|
||||
bool is_function = SwigType_isfunction(fullty) ? true : false;
|
||||
Delete(ty);
|
||||
Delete(fullty);
|
||||
|
||||
if (is_function) {
|
||||
int r = goBaseMethod(n, bases, ni);
|
||||
if (r != SWIG_OK) {
|
||||
return r;
|
||||
}
|
||||
|
||||
if (Getattr(ni, "sym:overloaded")) {
|
||||
for (Node *on = Getattr(ni, "sym:nextSibling"); on; on = Getattr(on, "sym:nextSibling")) {
|
||||
r = goBaseMethod(n, bases, on);
|
||||
if (r != SWIG_OK) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
String *receiver = class_receiver;
|
||||
bool is_static = isStatic(ni);
|
||||
if (is_static) {
|
||||
receiver = NULL;
|
||||
}
|
||||
String *go_name = buildGoName(Getattr(ni, "sym:name"), is_static, false);
|
||||
r = makeDispatchFunction(ni, go_name, receiver, is_static, NULL, false);
|
||||
Delete(go_name);
|
||||
if (r != SWIG_OK) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int r = goBaseVariable(n, bases, ni);
|
||||
if (r != SWIG_OK) {
|
||||
return r;
|
||||
}
|
||||
int r = goBaseEntry(n, bases, local, ni);
|
||||
if (r != SWIG_OK) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2297,6 +2226,105 @@ private:
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* goBaseEntry()
|
||||
*
|
||||
* Implement one entry defined in a parent class for a child class.
|
||||
* n is the child class.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
int goBaseEntry(Node* n, List* bases, Hash *local, Node* entry) {
|
||||
if (GetFlag(entry, "feature:ignore")) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
if (!is_public(entry)) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
String *type = Getattr(entry, "nodeType");
|
||||
if (Strcmp(type, "constructor") == 0 || Strcmp(type, "destructor") == 0 || Strcmp(type, "enum") == 0 || Strcmp(type, "using") == 0 || Strcmp(type, "classforward") == 0 || Strcmp(type, "template") == 0) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
if (Strcmp(type, "extend") == 0) {
|
||||
for (Node* extend = firstChild(entry); extend; extend = nextSibling(extend)) {
|
||||
if (isStatic(extend)) {
|
||||
// If we don't do this, the extend_default test case fails.
|
||||
continue;
|
||||
}
|
||||
|
||||
int r = goBaseEntry(n, bases, local, extend);
|
||||
if (r != SWIG_OK) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
String *storage = Getattr(entry, "storage");
|
||||
if (storage && (Strcmp(storage, "typedef") == 0 || Strcmp(storage, "friend") == 0)) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
String *mname = Getattr(entry, "sym:name");
|
||||
if (!mname) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
String *lname = Getattr(entry, "name");
|
||||
if (Getattr(class_methods, lname)) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
if (Getattr(local, lname)) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
Setattr(local, lname, NewString(""));
|
||||
|
||||
String *ty = NewString(Getattr(entry, "type"));
|
||||
SwigType_push(ty, Getattr(entry, "decl"));
|
||||
String *fullty = SwigType_typedef_resolve_all(ty);
|
||||
bool is_function = SwigType_isfunction(fullty) ? true : false;
|
||||
Delete(ty);
|
||||
Delete(fullty);
|
||||
|
||||
if (is_function) {
|
||||
int r = goBaseMethod(n, bases, entry);
|
||||
if (r != SWIG_OK) {
|
||||
return r;
|
||||
}
|
||||
|
||||
if (Getattr(entry, "sym:overloaded")) {
|
||||
for (Node *on = Getattr(entry, "sym:nextSibling"); on; on = Getattr(on, "sym:nextSibling")) {
|
||||
r = goBaseMethod(n, bases, on);
|
||||
if (r != SWIG_OK) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
String *receiver = class_receiver;
|
||||
bool is_static = isStatic(entry);
|
||||
if (is_static) {
|
||||
receiver = NULL;
|
||||
}
|
||||
String *go_name = buildGoName(Getattr(entry, "sym:name"), is_static, false);
|
||||
r = makeDispatchFunction(entry, go_name, receiver, is_static, NULL, false);
|
||||
Delete(go_name);
|
||||
if (r != SWIG_OK) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int r = goBaseVariable(n, bases, entry);
|
||||
if (r != SWIG_OK) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* goBaseMethod()
|
||||
*
|
||||
|
|
@ -2351,7 +2379,13 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
int r = makeWrappers(method, go_name, overname, wname, bases, Getattr(method, "parms"), result, is_static);
|
||||
// A method added by %extend in a base class may have void parms.
|
||||
ParmList* parms = Getattr(method, "parms");
|
||||
if (parms != NULL && SwigType_type(Getattr(parms, "type")) == T_VOID) {
|
||||
parms = NULL;
|
||||
}
|
||||
|
||||
int r = makeWrappers(method, go_name, overname, wname, bases, parms, result, is_static);
|
||||
|
||||
Swig_restore(method);
|
||||
|
||||
|
|
@ -2506,7 +2540,7 @@ private:
|
|||
Printv(interfaces, "\tSwigIs", go_base_name, "()\n", NULL);
|
||||
|
||||
Printv(f_go_wrappers, "func (p ", go_type_name, ") SwigGet", go_base_name, "() ", go_base_type, " {\n", NULL);
|
||||
Printv(f_go_wrappers, "\treturn ", go_base_type_name, "(p.Swigcptr())\n", NULL);
|
||||
Printv(f_go_wrappers, "\treturn ", go_base_type_name, "(getSwigcptr(p))\n", NULL);
|
||||
Printv(f_go_wrappers, "}\n\n", NULL);
|
||||
|
||||
Printv(interfaces, "\tSwigGet", go_base_name, "() ", go_base_type, "\n", NULL);
|
||||
|
|
@ -2708,7 +2742,7 @@ private:
|
|||
Printv(f_go_wrappers, "}\n\n", NULL);
|
||||
|
||||
Printv(f_go_wrappers, "func (p *", director_struct_name, ") Swigcptr() uintptr {\n", NULL);
|
||||
Printv(f_go_wrappers, "\treturn p.", go_type_name, ".Swigcptr()\n", NULL);
|
||||
Printv(f_go_wrappers, "\treturn getSwigcptr(p.", go_type_name, ")\n", NULL);
|
||||
Printv(f_go_wrappers, "}\n\n", NULL);
|
||||
|
||||
Printv(f_go_wrappers, "func (p *", director_struct_name, ") SwigIs", go_name, "() {\n", NULL);
|
||||
|
|
@ -2866,9 +2900,15 @@ private:
|
|||
|
||||
String *goin = goGetattr(p, "tmap:goin");
|
||||
if (goin == NULL) {
|
||||
Printv(f_go_wrappers, "\t", ivar, " := ", ln, NULL);
|
||||
Printv(f_go_wrappers, "\t", ivar, " := ", NULL);
|
||||
bool need_close = false;
|
||||
if (goTypeIsInterface(p, pt)) {
|
||||
Printv(f_go_wrappers, ".Swigcptr()", NULL);
|
||||
Printv(f_go_wrappers, "getSwigcptr(", NULL);
|
||||
need_close = true;
|
||||
}
|
||||
Printv(f_go_wrappers, ln, NULL);
|
||||
if (need_close) {
|
||||
Printv(f_go_wrappers, ")", NULL);
|
||||
}
|
||||
Printv(f_go_wrappers, "\n", NULL);
|
||||
} else {
|
||||
|
|
@ -3461,9 +3501,15 @@ private:
|
|||
// the goin typemap.
|
||||
String *goin = goGetattr(p, "tmap:goin");
|
||||
if (goin == NULL) {
|
||||
Printv(f_go_wrappers, "\t", ivar, " := ", ln, NULL);
|
||||
Printv(f_go_wrappers, "\t", ivar, " := ", NULL);
|
||||
bool need_close = false;
|
||||
if (goTypeIsInterface(p, pt)) {
|
||||
Printv(f_go_wrappers, ".Swigcptr()", NULL);
|
||||
Printv(f_go_wrappers, "getSwigcptr(", NULL);
|
||||
need_close = true;
|
||||
}
|
||||
Printv(f_go_wrappers, ln, NULL);
|
||||
if (need_close) {
|
||||
Printv(f_go_wrappers, ")", NULL);
|
||||
}
|
||||
Printv(f_go_wrappers, "\n", NULL);
|
||||
} else {
|
||||
|
|
@ -3472,7 +3518,7 @@ private:
|
|||
goin = Copy(goin);
|
||||
Replaceall(goin, "$input", ln);
|
||||
Replaceall(goin, "$result", ivar);
|
||||
Printv(f_go_wrappers, goin, NULL);
|
||||
Printv(f_go_wrappers, goin, "\n", NULL);
|
||||
Delete(goin);
|
||||
}
|
||||
|
||||
|
|
@ -3534,11 +3580,162 @@ private:
|
|||
|
||||
Printv(f_go_wrappers, "}\n\n", NULL);
|
||||
|
||||
// Define a method in the C++ director class that the C++ upcall
|
||||
// function can call. This permits an upcall to a protected
|
||||
// method.
|
||||
|
||||
if (!GetFlag(n, "abstract")) {
|
||||
// Define a function that uses the Go director type that other
|
||||
// methods in the Go type can call to get parent methods.
|
||||
|
||||
Printv(f_go_wrappers, "func Director", cn, go_with_over_name, "(swig_p ", cn, NULL);
|
||||
|
||||
p = parms;
|
||||
for (int i = 0; i < parm_count; ++i) {
|
||||
p = getParm(p);
|
||||
Printv(f_go_wrappers, ", ", Getattr(p, "lname"), " ", NULL);
|
||||
String *tm = goType(p, Getattr(p, "type"));
|
||||
Printv(f_go_wrappers, tm, NULL);
|
||||
Delete(tm);
|
||||
p = nextParm(p);
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, ")", NULL);
|
||||
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
String *tm = goType(n, result);
|
||||
Printv(f_go_wrappers, " ", tm, NULL);
|
||||
Delete(tm);
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, " {\n", NULL);
|
||||
|
||||
String *ret_type = NULL;
|
||||
bool memcpy_ret = false;
|
||||
String *wt = NULL;
|
||||
String *goout = NULL;
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
ret_type = goImType(n, result);
|
||||
Printv(f_go_wrappers, "\tvar swig_r ", ret_type, "\n", NULL);
|
||||
goout = goTypemapLookup("goout", n, "swig_r");
|
||||
|
||||
bool c_struct_type;
|
||||
Delete(cgoTypeForGoValue(n, result, &c_struct_type));
|
||||
if (c_struct_type) {
|
||||
memcpy_ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
String *call = NewString("");
|
||||
|
||||
Printv(call, "\t", NULL);
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
if (memcpy_ret) {
|
||||
Printv(call, "swig_r_p := ", NULL);
|
||||
} else {
|
||||
Printv(call, "swig_r = (", ret_type, ")(", NULL);
|
||||
}
|
||||
if (goTypeIsInterface(n, result)) {
|
||||
wt = goWrapperType(n, result, true);
|
||||
Printv(call, "(", wt, ")(", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
Printv(call, "C.", upcall_wname, "(C.uintptr_t(swig_p.(*",
|
||||
director_struct_name, ").", go_type_name, ")", NULL);
|
||||
|
||||
p = parms;
|
||||
for (int i = 0; i < parm_count; ++i) {
|
||||
Printv(call, ", ", NULL);
|
||||
p = getParm(p);
|
||||
SwigType *pt = Getattr(p, "type");
|
||||
|
||||
String *ivar = NewStringf("_swig_i_%d", i);
|
||||
|
||||
String *ln = Copy(Getattr(p, "lname"));
|
||||
|
||||
String *goin = goGetattr(p, "tmap:goin");
|
||||
if (goin == NULL) {
|
||||
Printv(f_go_wrappers, "\t", ivar, " := ", NULL);
|
||||
bool need_close = false;
|
||||
if (goTypeIsInterface(p, pt)) {
|
||||
Printv(f_go_wrappers, "getSwigcptr(", NULL);
|
||||
need_close = true;
|
||||
}
|
||||
Printv(f_go_wrappers, ln, NULL);
|
||||
if (need_close) {
|
||||
Printv(f_go_wrappers, ")", NULL);
|
||||
}
|
||||
Printv(f_go_wrappers, "\n", NULL);
|
||||
} else {
|
||||
String *itm = goImType(p, pt);
|
||||
Printv(f_go_wrappers, "\tvar ", ivar, " ", itm, "\n", NULL);
|
||||
goin = Copy(goin);
|
||||
Replaceall(goin, "$input", ln);
|
||||
Replaceall(goin, "$result", ivar);
|
||||
Printv(f_go_wrappers, goin, "\n", NULL);
|
||||
Delete(goin);
|
||||
}
|
||||
|
||||
Setattr(p, "emit:goinput", ivar);
|
||||
|
||||
bool c_struct_type;
|
||||
String *ct = cgoTypeForGoValue(p, pt, &c_struct_type);
|
||||
if (c_struct_type) {
|
||||
Printv(call, "*(*C.", ct, ")(unsafe.Pointer(&", ivar, "))", NULL);
|
||||
} else {
|
||||
Printv(call, "C.", ct, "(", ivar, ")", NULL);
|
||||
}
|
||||
|
||||
Delete(ln);
|
||||
|
||||
p = nextParm(p);
|
||||
}
|
||||
|
||||
Printv(call, ")", NULL);
|
||||
|
||||
if (wt) {
|
||||
// Close the type conversion to the wrapper type.
|
||||
Printv(call, ")", NULL);
|
||||
}
|
||||
if (SwigType_type(result) != T_VOID && !memcpy_ret) {
|
||||
// Close the type conversion of the return value.
|
||||
Printv(call, ")", NULL);
|
||||
}
|
||||
|
||||
Printv(call, "\n", NULL);
|
||||
|
||||
Printv(f_go_wrappers, call, NULL);
|
||||
Delete(call);
|
||||
|
||||
if (memcpy_ret) {
|
||||
Printv(f_go_wrappers, "\tswig_r = *(*", ret_type, ")(unsafe.Pointer(&swig_r_p))\n", NULL);
|
||||
}
|
||||
|
||||
goargout(parms);
|
||||
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
if (goout == NULL) {
|
||||
Printv(f_go_wrappers, "\treturn swig_r\n", NULL);
|
||||
} else {
|
||||
String *tm = goType(n, result);
|
||||
Printv(f_go_wrappers, "\tvar swig_r_1 ", tm, "\n", NULL);
|
||||
Replaceall(goout, "$input", "swig_r");
|
||||
Replaceall(goout, "$result", "swig_r_1");
|
||||
Printv(f_go_wrappers, goout, "\n", NULL);
|
||||
Printv(f_go_wrappers, "\treturn swig_r_1\n", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, "}\n\n", NULL);
|
||||
|
||||
if (ret_type) {
|
||||
Delete(ret_type);
|
||||
}
|
||||
if (wt) {
|
||||
Delete(wt);
|
||||
}
|
||||
|
||||
// Define a method in the C++ director class that the C++
|
||||
// upcall function can call. This permits an upcall to a
|
||||
// protected method.
|
||||
|
||||
String *upcall_method_name = NewString("_swig_upcall_");
|
||||
Append(upcall_method_name, name);
|
||||
if (overname) {
|
||||
|
|
@ -3637,151 +3834,6 @@ private:
|
|||
|
||||
Swig_restore(n);
|
||||
Delete(upcall_method_name);
|
||||
|
||||
// Define a function that uses the Go director type that other
|
||||
// methods in the Go type can call to get parent methods.
|
||||
|
||||
Printv(f_go_wrappers, "func Director", cn, go_with_over_name, "(p ", cn, NULL);
|
||||
|
||||
p = parms;
|
||||
for (int i = 0; i < parm_count; ++i) {
|
||||
p = getParm(p);
|
||||
Printv(f_go_wrappers, ", ", Getattr(p, "lname"), " ", NULL);
|
||||
String *tm = goType(p, Getattr(p, "type"));
|
||||
Printv(f_go_wrappers, tm, NULL);
|
||||
Delete(tm);
|
||||
p = nextParm(p);
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, ")", NULL);
|
||||
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
String *tm = goType(n, result);
|
||||
Printv(f_go_wrappers, " ", tm, NULL);
|
||||
Delete(tm);
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, " {\n", NULL);
|
||||
|
||||
String *ret_type = NULL;
|
||||
bool memcpy_ret = false;
|
||||
String *wt = NULL;
|
||||
String *goout = NULL;
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
ret_type = goImType(n, result);
|
||||
Printv(f_go_wrappers, "\tvar swig_r ", ret_type, "\n", NULL);
|
||||
goout = goTypemapLookup("goout", n, "swig_r");
|
||||
|
||||
bool c_struct_type;
|
||||
Delete(cgoTypeForGoValue(n, result, &c_struct_type));
|
||||
if (c_struct_type) {
|
||||
memcpy_ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
String *call = NewString("");
|
||||
|
||||
Printv(call, "\t", NULL);
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
if (memcpy_ret) {
|
||||
Printv(call, "swig_r_p := ", NULL);
|
||||
} else {
|
||||
Printv(call, "swig_r = (", ret_type, ")(", NULL);
|
||||
}
|
||||
if (goTypeIsInterface(n, result)) {
|
||||
wt = goWrapperType(n, result, true);
|
||||
Printv(call, "(", wt, ")(", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
Printv(call, "C.", upcall_wname, "(C.uintptr_t(p.(*",
|
||||
director_struct_name, ").", go_type_name, ")", NULL);
|
||||
|
||||
p = parms;
|
||||
for (int i = 0; i < parm_count; ++i) {
|
||||
Printv(call, ", ", NULL);
|
||||
p = getParm(p);
|
||||
SwigType *pt = Getattr(p, "type");
|
||||
|
||||
String *ivar = NewStringf("_swig_i_%d", i);
|
||||
|
||||
String *ln = Copy(Getattr(p, "lname"));
|
||||
|
||||
String *goin = goGetattr(p, "tmap:goin");
|
||||
if (goin == NULL) {
|
||||
Printv(f_go_wrappers, "\t", ivar, " := ", ln, NULL);
|
||||
if (goTypeIsInterface(p, pt)) {
|
||||
Printv(f_go_wrappers, ".Swigcptr()", NULL);
|
||||
}
|
||||
Printv(f_go_wrappers, "\n", NULL);
|
||||
} else {
|
||||
String *itm = goImType(p, pt);
|
||||
Printv(f_go_wrappers, "\tvar ", ivar, " ", itm, "\n", NULL);
|
||||
goin = Copy(goin);
|
||||
Replaceall(goin, "$input", ln);
|
||||
Replaceall(goin, "$result", ivar);
|
||||
Printv(f_go_wrappers, goin, NULL);
|
||||
Delete(goin);
|
||||
}
|
||||
|
||||
Setattr(p, "emit:goinput", ivar);
|
||||
|
||||
bool c_struct_type;
|
||||
String *ct = cgoTypeForGoValue(p, pt, &c_struct_type);
|
||||
if (c_struct_type) {
|
||||
Printv(call, "*(*C.", ct, ")(unsafe.Pointer(&", ivar, "))", NULL);
|
||||
} else {
|
||||
Printv(call, "C.", ct, "(", ivar, ")", NULL);
|
||||
}
|
||||
|
||||
Delete(ln);
|
||||
|
||||
p = nextParm(p);
|
||||
}
|
||||
|
||||
Printv(call, ")", NULL);
|
||||
|
||||
if (wt) {
|
||||
// Close the type conversion to the wrapper type.
|
||||
Printv(call, ")", NULL);
|
||||
}
|
||||
if (SwigType_type(result) != T_VOID && !memcpy_ret) {
|
||||
// Close the type conversion of the return value.
|
||||
Printv(call, ")", NULL);
|
||||
}
|
||||
|
||||
Printv(call, "\n", NULL);
|
||||
|
||||
Printv(f_go_wrappers, call, NULL);
|
||||
Delete(call);
|
||||
|
||||
if (memcpy_ret) {
|
||||
Printv(f_go_wrappers, "\tswig_r = *(*", ret_type, ")(unsafe.Pointer(&swig_r_p))\n", NULL);
|
||||
}
|
||||
|
||||
goargout(parms);
|
||||
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
if (goout == NULL) {
|
||||
Printv(f_go_wrappers, "\treturn swig_r\n", NULL);
|
||||
} else {
|
||||
String *tm = goType(n, result);
|
||||
Printv(f_go_wrappers, "\tvar swig_r_1 ", tm, "\n", NULL);
|
||||
Replaceall(goout, "$input", "swig_r");
|
||||
Replaceall(goout, "$result", "swig_r_1");
|
||||
Printv(f_go_wrappers, goout, "\n", NULL);
|
||||
Printv(f_go_wrappers, "\treturn swig_r_1\n", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, "}\n\n", NULL);
|
||||
|
||||
if (ret_type) {
|
||||
Delete(ret_type);
|
||||
}
|
||||
if (wt) {
|
||||
Delete(wt);
|
||||
}
|
||||
}
|
||||
|
||||
// The Go function which invokes the method. This is called by
|
||||
|
|
@ -3830,7 +3882,7 @@ private:
|
|||
if (SwigType_type(result) != T_VOID) {
|
||||
Printv(call, "swig_r = ", NULL);
|
||||
if (result_is_interface) {
|
||||
Printv(call, result_wrapper, "(", NULL);
|
||||
Printv(call, result_wrapper, "(getSwigcptr(", NULL);
|
||||
}
|
||||
}
|
||||
Printv(call, "swig_p.", go_with_over_name, "(", NULL);
|
||||
|
|
@ -3890,7 +3942,7 @@ private:
|
|||
Printv(call, ")", NULL);
|
||||
|
||||
if (result_is_interface) {
|
||||
Printv(call, ".Swigcptr())", NULL);
|
||||
Printv(call, "))", NULL);
|
||||
}
|
||||
Printv(call, "\n", NULL);
|
||||
|
||||
|
|
@ -5085,7 +5137,7 @@ private:
|
|||
}
|
||||
|
||||
String *t = Copy(type);
|
||||
if (SwigType_isarray(t)) {
|
||||
if (SwigType_isarray(t) && Getattr(n, "tmap:gotype") == NULL) {
|
||||
SwigType_del_array(t);
|
||||
SwigType_add_pointer(t);
|
||||
}
|
||||
|
|
@ -5226,10 +5278,14 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
if (Getattr(undefined_types, ty) && !Getattr(defined_types, ty)) {
|
||||
String* go_type = goType(n, ty);
|
||||
|
||||
if (Getattr(undefined_types, ty) && !Getattr(defined_types, go_type)) {
|
||||
Delete(go_type);
|
||||
return goWrapperType(n, type, true);
|
||||
}
|
||||
|
||||
Delete(go_type);
|
||||
return goType(n, type);
|
||||
}
|
||||
|
||||
|
|
@ -5280,7 +5336,7 @@ private:
|
|||
* gcCTypeForGoValue()
|
||||
*
|
||||
* Given a type, return the C/C++ type which will be used to catch
|
||||
* the value in Go. This is the 6g/8g version.
|
||||
* the value in Go. This is the gc version.
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
String *gcCTypeForGoValue(Node *n, SwigType *type, String *name) {
|
||||
|
|
@ -5289,7 +5345,19 @@ private:
|
|||
|
||||
String *tail = NewString("");
|
||||
SwigType *t = SwigType_typedef_resolve_all(type);
|
||||
if (!SwigType_isreference(t)) {
|
||||
bool is_const_ref = false;
|
||||
if (SwigType_isreference(t)) {
|
||||
SwigType* tt = Copy(t);
|
||||
SwigType_del_reference(tt);
|
||||
if (SwigType_isqualifier(tt)) {
|
||||
String* q = SwigType_parm(tt);
|
||||
if (Strcmp(q, "const") == 0) {
|
||||
is_const_ref = true;
|
||||
}
|
||||
}
|
||||
Delete(tt);
|
||||
}
|
||||
if (!is_const_ref) {
|
||||
while (Strncmp(gt, "*", 1) == 0) {
|
||||
Replace(gt, "*", "", DOH_REPLACE_FIRST);
|
||||
Printv(tail, "*", NULL);
|
||||
|
|
@ -5432,17 +5500,6 @@ private:
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* gccgoCTypeForGoValue()
|
||||
*
|
||||
* Given a type, return the C/C++ type which will be used to catch
|
||||
* the value in Go. This is the gccgo version.
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
String *gccgoCTypeForGoValue(Node *n, SwigType *type, String *name) {
|
||||
return gcCTypeForGoValue(n, type, name);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* goTypeIsInterface
|
||||
*
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
// Note string broken in half for compilers that can't handle long strings
|
||||
|
|
@ -132,7 +131,7 @@ public:
|
|||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(usage, stdout);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
Exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
prefix = NewString(argv[i + 1]);
|
||||
|
|
@ -176,7 +175,7 @@ public:
|
|||
procdoc = NewFile(argv[i + 1], "w", SWIG_output_files());
|
||||
if (!procdoc) {
|
||||
FileErrorDisplay(argv[i + 1]);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
|
|
@ -255,7 +254,7 @@ public:
|
|||
if (goops) {
|
||||
if (linkage != GUILE_LSTYLE_PASSIVE && linkage != GUILE_LSTYLE_MODULE) {
|
||||
Printf(stderr, "guile: GOOPS support requires passive or module linkage\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -298,7 +297,7 @@ public:
|
|||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
|
|
@ -476,7 +475,8 @@ public:
|
|||
Printf(f_init, "}\n");
|
||||
break;
|
||||
default:
|
||||
abort(); // for now
|
||||
fputs("Fatal internal error: Invalid Guile linkage setting.\n", stderr);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (scmstub) {
|
||||
|
|
@ -495,7 +495,7 @@ public:
|
|||
File *scmstubfile = NewFile(fname, "w", SWIG_output_files());
|
||||
if (!scmstubfile) {
|
||||
FileErrorDisplay(fname);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delete(fname);
|
||||
|
||||
|
|
@ -526,7 +526,7 @@ public:
|
|||
File *goopsfile = NewFile(fname, "w", SWIG_output_files());
|
||||
if (!goopsfile) {
|
||||
FileErrorDisplay(fname);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delete(fname);
|
||||
Swig_banner_target_lang(goopsfile, ";;;");
|
||||
|
|
@ -947,20 +947,16 @@ public:
|
|||
|
||||
if (!is_setter) {
|
||||
/* Strip off "-get" */
|
||||
char *pws_name = (char *) malloc(sizeof(char) * (len - 3));
|
||||
strncpy(pws_name, pc, len - 3);
|
||||
pws_name[len - 4] = 0;
|
||||
if (struct_member == 2) {
|
||||
/* There was a setter, so create a procedure with setter */
|
||||
Printf(f_init, "scm_c_define");
|
||||
Printf(f_init, "(\"%s\", " "scm_make_procedure_with_setter(getter, setter));\n", pws_name);
|
||||
Printf(f_init, "(\"%.*s\", " "scm_make_procedure_with_setter(getter, setter));\n", pc, len - 4);
|
||||
} else {
|
||||
/* There was no setter, so make an alias to the getter */
|
||||
Printf(f_init, "scm_c_define");
|
||||
Printf(f_init, "(\"%s\", getter);\n", pws_name);
|
||||
Printf(f_init, "(\"%.*s\", getter);\n", pc, len - 4);
|
||||
}
|
||||
Printf(exported_symbols, "\"%s\", ", pws_name);
|
||||
free(pws_name);
|
||||
Printf(exported_symbols, "\"%.*s\", ", pc, len - 4);
|
||||
}
|
||||
} else {
|
||||
/* Register the function */
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
|
||||
static bool interface_feature_enabled = false;
|
||||
|
||||
|
|
@ -28,25 +29,31 @@ static bool interface_feature_enabled = false;
|
|||
|
||||
static List *collect_interface_methods(Node *n) {
|
||||
List *methods = NewList();
|
||||
if (Hash *bases = Getattr(n, "interface:bases")) {
|
||||
List *keys = Keys(bases);
|
||||
for (Iterator base = First(keys); base.item; base = Next(base)) {
|
||||
Node *cls = Getattr(bases, base.item);
|
||||
if (List *bases = Getattr(n, "interface:bases")) {
|
||||
for (Iterator base = First(bases); base.item; base = Next(base)) {
|
||||
Node *cls = base.item;
|
||||
if (cls == n)
|
||||
continue;
|
||||
for (Node *child = firstChild(cls); child; child = nextSibling(child)) {
|
||||
if (Cmp(nodeType(child), "cdecl") == 0) {
|
||||
if (GetFlag(child, "feature:ignore") || Getattr(child, "interface:owner"))
|
||||
continue; // skip methods propagated to bases
|
||||
Node *m = Copy(child);
|
||||
set_nextSibling(m, NIL);
|
||||
set_previousSibling(m, NIL);
|
||||
Setattr(m, "interface:owner", cls);
|
||||
Append(methods, m);
|
||||
if (!checkAttribute(child, "kind", "function"))
|
||||
continue;
|
||||
if (checkAttribute(child, "storage", "static"))
|
||||
continue; // accept virtual methods, non-virtual methods too... mmm??. Warn that the interface class has something that is not a virtual method?
|
||||
Node *nn = copyNode(child);
|
||||
Setattr(nn, "interface:owner", cls);
|
||||
ParmList *parms = CopyParmList(Getattr(child, "parms"));
|
||||
Setattr(nn, "parms", parms);
|
||||
Delete(parms);
|
||||
ParmList *throw_parm_list = Getattr(child, "throws");
|
||||
if (throw_parm_list)
|
||||
Setattr(nn, "throws", CopyParmList(throw_parm_list));
|
||||
Append(methods, nn);
|
||||
}
|
||||
}
|
||||
}
|
||||
Delete(keys);
|
||||
}
|
||||
return methods;
|
||||
}
|
||||
|
|
@ -55,17 +62,17 @@ static List *collect_interface_methods(Node *n) {
|
|||
* collect_interface_bases
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void collect_interface_bases(Hash *bases, Node *n) {
|
||||
if (Getattr(n, "feature:interface")) {
|
||||
static void collect_interface_bases(List *bases, Node *n) {
|
||||
if (GetFlag(n, "feature:interface")) {
|
||||
String *name = Getattr(n, "interface:name");
|
||||
if (!Getattr(bases, name))
|
||||
Setattr(bases, name, n);
|
||||
Append(bases, n);
|
||||
}
|
||||
|
||||
if (List *baselist = Getattr(n, "bases")) {
|
||||
for (Iterator base = First(baselist); base.item; base = Next(base)) {
|
||||
if (!GetFlag(base.item, "feature:ignore")) {
|
||||
if (Getattr(base.item, "feature:interface"))
|
||||
if (GetFlag(base.item, "feature:interface"))
|
||||
collect_interface_bases(bases, base.item);
|
||||
}
|
||||
}
|
||||
|
|
@ -83,21 +90,21 @@ static void collect_interface_bases(Hash *bases, Node *n) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void collect_interface_base_classes(Node *n) {
|
||||
if (Getattr(n, "feature:interface")) {
|
||||
if (GetFlag(n, "feature:interface")) {
|
||||
// check all bases are also interfaces
|
||||
if (List *baselist = Getattr(n, "bases")) {
|
||||
for (Iterator base = First(baselist); base.item; base = Next(base)) {
|
||||
if (!GetFlag(base.item, "feature:ignore")) {
|
||||
if (!Getattr(base.item, "feature:interface")) {
|
||||
if (!GetFlag(base.item, "feature:interface")) {
|
||||
Swig_error(Getfile(n), Getline(n), "Base class '%s' of '%s' is not similarly marked as an interface.\n", SwigType_namestr(Getattr(base.item, "name")), SwigType_namestr(Getattr(n, "name")));
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Hash *interface_bases = NewHash();
|
||||
List *interface_bases = NewList();
|
||||
collect_interface_bases(interface_bases, n);
|
||||
if (Len(interface_bases) == 0)
|
||||
Delete(interface_bases);
|
||||
|
|
@ -110,11 +117,11 @@ static void collect_interface_base_classes(Node *n) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void process_interface_name(Node *n) {
|
||||
if (Getattr(n, "feature:interface")) {
|
||||
if (GetFlag(n, "feature:interface")) {
|
||||
String *interface_name = Getattr(n, "feature:interface:name");
|
||||
if (!Len(interface_name)) {
|
||||
Swig_error(Getfile(n), Getline(n), "The interface feature for '%s' is missing the name attribute.\n", SwigType_namestr(Getattr(n, "name")));
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
if (Strchr(interface_name, '%')) {
|
||||
String *name = NewStringf(interface_name, Getattr(n, "sym:name"));
|
||||
|
|
@ -139,7 +146,7 @@ void Swig_interface_propagate_methods(Node *n) {
|
|||
process_interface_name(n);
|
||||
collect_interface_base_classes(n);
|
||||
List *methods = collect_interface_methods(n);
|
||||
bool is_interface = Getattr(n, "feature:interface") != 0;
|
||||
bool is_interface = GetFlag(n, "feature:interface") ? true : false;
|
||||
for (Iterator mi = First(methods); mi.item; mi = Next(mi)) {
|
||||
if (!is_interface && GetFlag(mi.item, "abstract"))
|
||||
continue;
|
||||
|
|
@ -164,8 +171,25 @@ void Swig_interface_propagate_methods(Node *n) {
|
|||
}
|
||||
Delete(this_decl_resolved);
|
||||
if (!identically_overloaded_method) {
|
||||
// TODO: Fix if the method is overloaded with different arguments / has default args
|
||||
appendChild(n, mi.item);
|
||||
// Add method copied from base class to this derived class
|
||||
Node *cn = mi.item;
|
||||
Delattr(cn, "sym:overname");
|
||||
String *prefix = Getattr(n, "name");
|
||||
String *name = Getattr(cn, "name");
|
||||
String *decl = Getattr(cn, "decl");
|
||||
String *oldname = Getattr(cn, "sym:name");
|
||||
|
||||
String *symname = Swig_name_make(cn, prefix, name, decl, oldname);
|
||||
if (Strcmp(symname, "$ignore") != 0) {
|
||||
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||
Node *on = Swig_symbol_add(symname, cn);
|
||||
assert(on == cn);
|
||||
|
||||
// Features from the copied base class method are already present, now add in features specific to the added method in the derived class
|
||||
Swig_features_get(Swig_cparse_features(), Swig_symbol_qualifiedscopename(0), name, decl, cn);
|
||||
Swig_symbol_setscope(oldscope);
|
||||
appendChild(n, cn);
|
||||
}
|
||||
} else {
|
||||
Delete(mi.item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "swigmod.h"
|
||||
#include <limits.h> // for INT_MAX
|
||||
#include "cparse.h"
|
||||
#include <limits.h> // for INT_MAX
|
||||
#include <ctype.h>
|
||||
#include "javadoc.h"
|
||||
|
||||
|
|
@ -371,24 +371,24 @@ public:
|
|||
|
||||
if (!outfile) {
|
||||
Printf(stderr, "Unable to determine outfile\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (directorsEnabled()) {
|
||||
if (!outfile_h) {
|
||||
Printf(stderr, "Unable to determine outfile_h\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
|
||||
if (!f_runtime_h) {
|
||||
FileErrorDisplay(outfile_h);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -521,7 +521,7 @@ public:
|
|||
File *f_im = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_im) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, Copy(filen));
|
||||
Delete(filen);
|
||||
|
|
@ -576,7 +576,7 @@ public:
|
|||
File *f_module = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_module) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, Copy(filen));
|
||||
Delete(filen);
|
||||
|
|
@ -635,7 +635,7 @@ public:
|
|||
File *f_module = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_module) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, Copy(filen));
|
||||
Delete(filen);
|
||||
|
|
@ -1332,10 +1332,7 @@ public:
|
|||
// Add extra indentation
|
||||
Replaceall(enum_code, "\n", "\n ");
|
||||
Replaceall(enum_code, " \n", "\n");
|
||||
if (GetFlag(getCurrentClass(), "feature:interface"))
|
||||
Printv(interface_class_code, " ", enum_code, "\n\n", NIL);
|
||||
else
|
||||
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
|
||||
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
|
||||
} else {
|
||||
// Global enums are defined in their own file
|
||||
String *output_directory = outputDirectory(nspace);
|
||||
|
|
@ -1343,7 +1340,7 @@ public:
|
|||
File *f_enum = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_enum) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, Copy(filen));
|
||||
Delete(filen);
|
||||
|
|
@ -1843,10 +1840,9 @@ public:
|
|||
* addInterfaceNameAndUpcasts()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, Hash *base_list, SwigType *c_classname) {
|
||||
List *keys = Keys(base_list);
|
||||
for (Iterator it = First(keys); it.item; it = Next(it)) {
|
||||
Node *base = Getattr(base_list, it.item);
|
||||
void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, List *base_list, SwigType *c_classname) {
|
||||
for (Iterator it = First(base_list); it.item; it = Next(it)) {
|
||||
Node *base = it.item;
|
||||
SwigType *c_baseclassname = Getattr(base, "name");
|
||||
String *interface_name = Getattr(base, "interface:name");
|
||||
if (Len(interface_list))
|
||||
|
|
@ -1873,7 +1869,6 @@ public:
|
|||
Delete(cptr_method_name);
|
||||
Delete(interface_code);
|
||||
}
|
||||
Delete(keys);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -1959,7 +1954,7 @@ public:
|
|||
if (baselist) {
|
||||
Iterator base = First(baselist);
|
||||
while (base.item) {
|
||||
if (!(GetFlag(base.item, "feature:ignore") || Getattr(base.item, "feature:interface"))) {
|
||||
if (!(GetFlag(base.item, "feature:ignore") || GetFlag(base.item, "feature:interface"))) {
|
||||
SwigType *baseclassname = Getattr(base.item, "name");
|
||||
if (!c_baseclassname) {
|
||||
String *name = getProxyName(baseclassname);
|
||||
|
|
@ -1979,7 +1974,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
Hash *interface_bases = Getattr(n, "interface:bases");
|
||||
List *interface_bases = Getattr(n, "interface:bases");
|
||||
if (interface_bases)
|
||||
addInterfaceNameAndUpcasts(smart, interface_list, interface_upcasts, interface_bases, c_classname);
|
||||
|
||||
|
|
@ -2140,7 +2135,7 @@ public:
|
|||
if (List *baselist = Getattr(n, "bases")) {
|
||||
String *bases = 0;
|
||||
for (Iterator base = First(baselist); base.item; base = Next(base)) {
|
||||
if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface"))
|
||||
if (GetFlag(base.item, "feature:ignore") || !GetFlag(base.item, "feature:interface"))
|
||||
continue; // TODO: warn about skipped non-interface bases
|
||||
String *base_iname = Getattr(base.item, "interface:name");
|
||||
if (!bases)
|
||||
|
|
@ -2215,12 +2210,12 @@ public:
|
|||
|
||||
if (Cmp(proxy_class_name, imclass_name) == 0) {
|
||||
Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (Cmp(proxy_class_name, module_class_name) == 0) {
|
||||
Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
if (outerClassesPrefix) {
|
||||
|
|
@ -2236,7 +2231,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
String *interface_name = Getattr(n, "feature:interface") ? Getattr(n, "interface:name") : 0;
|
||||
String *interface_name = GetFlag(n, "feature:interface") ? Getattr(n, "interface:name") : 0;
|
||||
if (outerClassesPrefix) {
|
||||
String *fnspace = nspace ? NewStringf("%s.%s", nspace, outerClassesPrefix) : outerClassesPrefix;
|
||||
if (!addSymbol(proxy_class_name, n, fnspace))
|
||||
|
|
@ -2260,7 +2255,7 @@ public:
|
|||
f_proxy = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_proxy) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, Copy(filen));
|
||||
Delete(filen);
|
||||
|
|
@ -2287,14 +2282,14 @@ public:
|
|||
destructor_throws_clause = NewString("");
|
||||
proxy_class_constants_code = NewString("");
|
||||
|
||||
if (Getattr(n, "feature:interface")) {
|
||||
if (GetFlag(n, "feature:interface")) {
|
||||
interface_class_code = NewString("");
|
||||
String *output_directory = outputDirectory(nspace);
|
||||
String *filen = NewStringf("%s%s.java", output_directory, interface_name);
|
||||
f_interface = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_interface) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, filen); // file name ownership goes to the list
|
||||
emitBanner(f_interface);
|
||||
|
|
@ -2462,7 +2457,7 @@ public:
|
|||
bool setter_flag = false;
|
||||
String *pre_code = NewString("");
|
||||
String *post_code = NewString("");
|
||||
bool is_interface = Getattr(parentNode(n), "feature:interface") != 0
|
||||
bool is_interface = GetFlag(parentNode(n), "feature:interface") && !checkAttribute(n, "kind", "variable")
|
||||
&& !static_flag && Getattr(n, "interface:owner") == 0;
|
||||
|
||||
if (!proxy_flag)
|
||||
|
|
@ -2694,6 +2689,7 @@ public:
|
|||
Replaceall(imcall, "$imfuncname", intermediary_function_name);
|
||||
}
|
||||
|
||||
Replaceall(tm, "$imfuncname", intermediary_function_name);
|
||||
Replaceall(tm, "$jnicall", imcall);
|
||||
} else {
|
||||
Swig_warning(WARN_JAVA_TYPEMAP_JAVAOUT_UNDEF, input_file, line_number, "No javaout typemap defined for %s\n", SwigType_str(t, 0));
|
||||
|
|
@ -3179,6 +3175,7 @@ public:
|
|||
else
|
||||
Replaceall(tm, "$owner", "false");
|
||||
substituteClassname(t, tm);
|
||||
Replaceall(tm, "$imfuncname", overloaded_name);
|
||||
Replaceall(tm, "$jnicall", imcall);
|
||||
} else {
|
||||
Swig_warning(WARN_JAVA_TYPEMAP_JAVAOUT_UNDEF, input_file, line_number, "No javaout typemap defined for %s\n", SwigType_str(t, 0));
|
||||
|
|
@ -3497,7 +3494,7 @@ public:
|
|||
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_swigtype) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Append(filenames_list, Copy(filen));
|
||||
Delete(filen);
|
||||
|
|
@ -3712,7 +3709,7 @@ public:
|
|||
if (newdir_error) {
|
||||
Printf(stderr, "%s\n", newdir_error);
|
||||
Delete(newdir_error);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Printv(output_directory, nspace_subdirectory, SWIG_FILE_DELIMITER, 0);
|
||||
Delete(nspace_subdirectory);
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ public:
|
|||
*/
|
||||
virtual int exitClass(Node *) {
|
||||
return SWIG_OK;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked at the beginning of the variableHandler.
|
||||
|
|
@ -178,7 +178,7 @@ public:
|
|||
*/
|
||||
virtual int exitVariable(Node *) {
|
||||
return SWIG_OK;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked at the beginning of the functionHandler.
|
||||
|
|
@ -190,7 +190,7 @@ public:
|
|||
*/
|
||||
virtual int exitFunction(Node *) {
|
||||
return SWIG_OK;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked by functionWrapper callback after call to Language::functionWrapper.
|
||||
|
|
@ -537,21 +537,21 @@ void JAVASCRIPT::main(int argc, char *argv[]) {
|
|||
if (strcmp(argv[i], "-v8") == 0) {
|
||||
if (engine != -1) {
|
||||
Printf(stderr, ERR_MSG_ONLY_ONE_ENGINE_PLEASE);
|
||||
SWIG_exit(-1);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Swig_mark_arg(i);
|
||||
engine = JSEmitter::V8;
|
||||
} else if (strcmp(argv[i], "-jsc") == 0) {
|
||||
if (engine != -1) {
|
||||
Printf(stderr, ERR_MSG_ONLY_ONE_ENGINE_PLEASE);
|
||||
SWIG_exit(-1);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Swig_mark_arg(i);
|
||||
engine = JSEmitter::JavascriptCore;
|
||||
} else if (strcmp(argv[i], "-node") == 0) {
|
||||
if (engine != -1) {
|
||||
Printf(stderr, ERR_MSG_ONLY_ONE_ENGINE_PLEASE);
|
||||
SWIG_exit(-1);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Swig_mark_arg(i);
|
||||
engine = JSEmitter::NodeJS;
|
||||
|
|
@ -595,7 +595,7 @@ void JAVASCRIPT::main(int argc, char *argv[]) {
|
|||
default:
|
||||
{
|
||||
Printf(stderr, "SWIG Javascript: Unknown engine. Please specify one of '-jsc', '-v8' or '-node'.\n");
|
||||
SWIG_exit(-1);
|
||||
Exit(EXIT_FAILURE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -666,7 +666,7 @@ Template JSEmitter::getTemplate(const String *name) {
|
|||
|
||||
if (!templ) {
|
||||
Printf(stderr, "Could not find template %s\n.", name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
Template t(templ, name);
|
||||
|
|
@ -760,13 +760,10 @@ int JSEmitter::emitWrapperFunction(Node *n) {
|
|||
ret = emitSetter(n, is_member, is_static);
|
||||
} else if (is_getter) {
|
||||
ret = emitGetter(n, is_member, is_static);
|
||||
} else {
|
||||
Swig_print_node(n);
|
||||
}
|
||||
|
||||
} else {
|
||||
Printf(stderr, "Warning: unsupported wrapper function type\n");
|
||||
Swig_print_node(n);
|
||||
ret = SWIG_ERROR;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -778,7 +775,6 @@ int JSEmitter::emitWrapperFunction(Node *n) {
|
|||
ret = emitDtor(n);
|
||||
} else {
|
||||
Printf(stderr, "Warning: unsupported wrapper function type");
|
||||
Swig_print_node(n);
|
||||
ret = SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
@ -936,7 +932,7 @@ int JSEmitter::emitDtor(Node *n) {
|
|||
SwigType *type = state.clazz(TYPE);
|
||||
String *p_classtype = SwigType_add_pointer(state.clazz(TYPE));
|
||||
String *ctype = SwigType_lstr(p_classtype, "");
|
||||
String *free = NewString("");
|
||||
String *jsfree = NewString("");
|
||||
|
||||
// (Taken from JSCore implementation.)
|
||||
/* The if (Extend) block was taken from the Ruby implementation.
|
||||
|
|
@ -979,9 +975,9 @@ int JSEmitter::emitDtor(Node *n) {
|
|||
// TODO: generate dtors more similar to other wrappers
|
||||
// EW: I think this is wrong. delete should only be used when new was used to create. If malloc was used, free needs to be used.
|
||||
if (SwigType_isarray(type)) {
|
||||
Printf(free, "delete [] (%s)", ctype);
|
||||
Printf(jsfree, "delete [] (%s)", ctype);
|
||||
} else {
|
||||
Printf(free, "delete (%s)", ctype);
|
||||
Printf(jsfree, "delete (%s)", ctype);
|
||||
}
|
||||
|
||||
String *destructor_action = Getattr(n, "wrap:action");
|
||||
|
|
@ -994,7 +990,7 @@ int JSEmitter::emitDtor(Node *n) {
|
|||
{
|
||||
SWIG_PRV_DATA* t = (SWIG_PRV_DATA*)JSObjectGetPrivate(thisObject);
|
||||
if(t && t->swigCMemOwn) free ((${type}*)t->swigCObject);
|
||||
if(t) free(t);
|
||||
free(t);
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -1007,7 +1003,7 @@ int JSEmitter::emitDtor(Node *n) {
|
|||
${type}* arg1 = (${type}*)t->swigCObject;
|
||||
${destructor_action}
|
||||
}
|
||||
if(t) free(t);
|
||||
free(t);
|
||||
|
||||
Based on what I saw in the Lua and Ruby modules, I use Getattr(n, "wrap:action")
|
||||
to decide if the user has a preferred destructor action.
|
||||
|
|
@ -1031,7 +1027,7 @@ int JSEmitter::emitDtor(Node *n) {
|
|||
state.clazz(DTOR, wrap_name);
|
||||
t_dtor.replace("${classname_mangled}", state.clazz(NAME_MANGLED))
|
||||
.replace("$jswrapper", wrap_name)
|
||||
.replace("$jsfree", free)
|
||||
.replace("$jsfree", jsfree)
|
||||
.replace("$jstype", ctype);
|
||||
|
||||
t_dtor.replace("${destructor_action}", destructor_action);
|
||||
|
|
@ -1041,14 +1037,14 @@ int JSEmitter::emitDtor(Node *n) {
|
|||
state.clazz(DTOR, wrap_name);
|
||||
t_dtor.replace("$jsmangledname", state.clazz(NAME_MANGLED))
|
||||
.replace("$jswrapper", wrap_name)
|
||||
.replace("$jsfree", free)
|
||||
.replace("$jsfree", jsfree)
|
||||
.replace("$jstype", ctype)
|
||||
.pretty_print(f_wrappers);
|
||||
}
|
||||
|
||||
Delete(p_classtype);
|
||||
Delete(ctype);
|
||||
Delete(free);
|
||||
Delete(jsfree);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1143,7 +1139,7 @@ int JSEmitter::emitConstant(Node *n) {
|
|||
String *rawval = Getattr(n, "rawval");
|
||||
String *value = rawval ? rawval : Getattr(n, "value");
|
||||
|
||||
// HACK: forcing usage of cppvalue for v8 (which turned out to fix typdef_struct.i, et. al)
|
||||
// HACK: forcing usage of cppvalue for v8 (which turned out to fix typedef_struct.i, et. al)
|
||||
if (State::IsSet(state.globals(FORCE_CPP)) && Getattr(n, "cppvalue") != NULL) {
|
||||
value = Getattr(n, "cppvalue");
|
||||
}
|
||||
|
|
@ -1409,7 +1405,6 @@ int JSEmitter::switchNamespace(Node *n) {
|
|||
String *_nspace = lang->getNSpace();
|
||||
if (!Equal(nspace, _nspace)) {
|
||||
Printf(stdout, "##### Custom vs Language::getNSpace(): %s | %s\n", nspace, _nspace);
|
||||
Swig_print_node(n);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1576,7 +1571,7 @@ void JSCEmitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Ma
|
|||
break;
|
||||
default:
|
||||
Printf(stderr, "Illegal MarshallingMode.");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
tm = emitInputTypemap(n, p, wrapper, arg);
|
||||
Delete(arg);
|
||||
|
|
@ -1599,7 +1594,7 @@ int JSCEmitter::initialize(Node *n) {
|
|||
f_wrap_cpp = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_wrap_cpp) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Initialization of members */
|
||||
|
|
@ -1920,7 +1915,7 @@ int V8Emitter::initialize(Node *n) {
|
|||
f_wrap_cpp = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_wrap_cpp) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
f_runtime = NewString("");
|
||||
|
|
@ -2214,7 +2209,7 @@ void V8Emitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Mar
|
|||
break;
|
||||
default:
|
||||
Printf(stderr, "Illegal MarshallingMode.");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
tm = emitInputTypemap(n, p, wrapper, arg);
|
||||
|
|
@ -2370,7 +2365,7 @@ Template::Template(const String *code_) {
|
|||
|
||||
if (!code_) {
|
||||
Printf(stdout, "Template code was null. Illegal input for template.");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
code = NewString(code_);
|
||||
templateName = NewString("");
|
||||
|
|
@ -2380,7 +2375,7 @@ Template::Template(const String *code_, const String *templateName_) {
|
|||
|
||||
if (!code_) {
|
||||
Printf(stdout, "Template code was null. Illegal input for template.");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
code = NewString(code_);
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ static Hash *classhash;
|
|||
extern int GenerateDefault;
|
||||
extern int ForceExtern;
|
||||
extern int AddExtern;
|
||||
extern int UseWrapperSuffix;
|
||||
|
||||
/* import modes */
|
||||
|
||||
|
|
@ -1324,7 +1325,7 @@ int Language::staticmemberfunctionHandler(Node *n) {
|
|||
// See Swig_MethodToFunction() for the explanation of this code.
|
||||
if (Getattr(n, "sym:overloaded")) {
|
||||
Append(cname, Getattr(defaultargs ? defaultargs : n, "sym:overname"));
|
||||
} else {
|
||||
} else if (UseWrapperSuffix) {
|
||||
Append(cname, "__SWIG");
|
||||
}
|
||||
|
||||
|
|
@ -1845,20 +1846,82 @@ static String *vtable_method_id(Node *n) {
|
|||
String *tmp = SwigType_pop_function(local_decl);
|
||||
Delete(local_decl);
|
||||
local_decl = tmp;
|
||||
Node *method_id = NewStringf("%s|%s", name, local_decl);
|
||||
String *method_id = NewStringf("%s|%s", name, local_decl);
|
||||
Delete(local_decl);
|
||||
return method_id;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Language::unrollOneVirtualMethod()
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
void Language::unrollOneVirtualMethod(String *classname, Node *n, Node *parent, List *vm, int &virtual_destructor, int protectedbase) {
|
||||
if (!checkAttribute(n, "storage", "virtual"))
|
||||
return;
|
||||
if (GetFlag(n, "final"))
|
||||
return;
|
||||
|
||||
String *nodeType = Getattr(n, "nodeType");
|
||||
|
||||
/* we need to add methods(cdecl) and destructor (to check for throw decl) */
|
||||
int is_destructor = (Cmp(nodeType, "destructor") == 0);
|
||||
if ((Cmp(nodeType, "cdecl") == 0) || is_destructor) {
|
||||
String *decl = Getattr(n, "decl");
|
||||
/* extra check for function type and proper access */
|
||||
if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(n)) || need_nonpublic_member(n))) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(n);
|
||||
/* Make sure that the new method overwrites the existing: */
|
||||
int len = Len(vm);
|
||||
const int DO_NOT_REPLACE = -1;
|
||||
int replace = DO_NOT_REPLACE;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Node *item = Getitem(vm, i);
|
||||
String *check_vmid = Getattr(item, "vmid");
|
||||
|
||||
if (Strcmp(method_id, check_vmid) == 0) {
|
||||
replace = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* filling a new method item */
|
||||
String *fqdname = NewStringf("%s::%s", classname, name);
|
||||
Hash *item = NewHash();
|
||||
Setattr(item, "fqdname", fqdname);
|
||||
Node *m = Copy(n);
|
||||
|
||||
/* Store the complete return type - needed for non-simple return types (pointers, references etc.) */
|
||||
SwigType *ty = NewString(Getattr(m, "type"));
|
||||
SwigType_push(ty, decl);
|
||||
if (SwigType_isqualifier(ty)) {
|
||||
Delete(SwigType_pop(ty));
|
||||
}
|
||||
Delete(SwigType_pop_function(ty));
|
||||
Setattr(m, "returntype", ty);
|
||||
|
||||
String *mname = NewStringf("%s::%s", Getattr(parent, "name"), name);
|
||||
/* apply the features of the original method found in the base class */
|
||||
Swig_features_get(Swig_cparse_features(), 0, mname, Getattr(m, "decl"), m);
|
||||
Setattr(item, "methodNode", m);
|
||||
Setattr(item, "vmid", method_id);
|
||||
if (replace == DO_NOT_REPLACE)
|
||||
Append(vm, item);
|
||||
else
|
||||
Setitem(vm, replace, item);
|
||||
Setattr(n, "directorNode", m);
|
||||
|
||||
Delete(mname);
|
||||
}
|
||||
if (is_destructor) {
|
||||
virtual_destructor = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Language::unrollVirtualMethods()
|
||||
* ---------------------------------------------------------------------- */
|
||||
int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_director, int &virtual_destructor, int protectedbase) {
|
||||
Node *ni;
|
||||
String *nodeType;
|
||||
String *classname;
|
||||
String *decl;
|
||||
int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int &virtual_destructor, int protectedbase) {
|
||||
bool first_base = false;
|
||||
// recurse through all base classes to build the vtable
|
||||
List *bl = Getattr(n, "bases");
|
||||
|
|
@ -1867,10 +1930,11 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
|
|||
for (bi = First(bl); bi.item; bi = Next(bi)) {
|
||||
if (first_base && !director_multiple_inheritance)
|
||||
break;
|
||||
unrollVirtualMethods(bi.item, parent, vm, default_director, virtual_destructor);
|
||||
unrollVirtualMethods(bi.item, parent, vm, virtual_destructor);
|
||||
first_base = true;
|
||||
}
|
||||
}
|
||||
|
||||
// recurse through all protected base classes to build the vtable, as needed
|
||||
bl = Getattr(n, "protectedbases");
|
||||
if (bl) {
|
||||
|
|
@ -1878,88 +1942,28 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
|
|||
for (bi = First(bl); bi.item; bi = Next(bi)) {
|
||||
if (first_base && !director_multiple_inheritance)
|
||||
break;
|
||||
unrollVirtualMethods(bi.item, parent, vm, default_director, virtual_destructor, 1);
|
||||
unrollVirtualMethods(bi.item, parent, vm, virtual_destructor, 1);
|
||||
first_base = true;
|
||||
}
|
||||
}
|
||||
|
||||
// find the methods that need directors
|
||||
classname = Getattr(n, "name");
|
||||
for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) {
|
||||
String *classname = Getattr(n, "name");
|
||||
for (Node *ni = firstChild(n); ni; ni = nextSibling(ni)) {
|
||||
/* we only need to check the virtual members */
|
||||
nodeType = Getattr(ni, "nodeType");
|
||||
int is_using = (Cmp(nodeType, "using") == 0);
|
||||
Node *nn = is_using ? firstChild(ni) : ni; /* assume there is only one child node for "using" nodes */
|
||||
if (is_using) {
|
||||
if (nn)
|
||||
nodeType = Getattr(nn, "nodeType");
|
||||
else
|
||||
continue; // A private "using" node
|
||||
}
|
||||
if (!checkAttribute(nn, "storage", "virtual"))
|
||||
continue;
|
||||
if (GetFlag(nn, "final"))
|
||||
continue;
|
||||
/* we need to add methods(cdecl) and destructor (to check for throw decl) */
|
||||
int is_destructor = (Cmp(nodeType, "destructor") == 0);
|
||||
if ((Cmp(nodeType, "cdecl") == 0) || is_destructor) {
|
||||
decl = Getattr(nn, "decl");
|
||||
/* extra check for function type and proper access */
|
||||
if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(nn)) || need_nonpublic_member(nn))) {
|
||||
String *name = Getattr(nn, "name");
|
||||
Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(nn);
|
||||
/* Make sure that the new method overwrites the existing: */
|
||||
int len = Len(vm);
|
||||
const int DO_NOT_REPLACE = -1;
|
||||
int replace = DO_NOT_REPLACE;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Node *item = Getitem(vm, i);
|
||||
String *check_vmid = Getattr(item, "vmid");
|
||||
|
||||
if (Strcmp(method_id, check_vmid) == 0) {
|
||||
replace = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* filling a new method item */
|
||||
String *fqdname = NewStringf("%s::%s", classname, name);
|
||||
Hash *item = NewHash();
|
||||
Setattr(item, "fqdname", fqdname);
|
||||
Node *m = Copy(nn);
|
||||
|
||||
/* Store the complete return type - needed for non-simple return types (pointers, references etc.) */
|
||||
SwigType *ty = NewString(Getattr(m, "type"));
|
||||
SwigType_push(ty, decl);
|
||||
if (SwigType_isqualifier(ty)) {
|
||||
Delete(SwigType_pop(ty));
|
||||
}
|
||||
Delete(SwigType_pop_function(ty));
|
||||
Setattr(m, "returntype", ty);
|
||||
|
||||
String *mname = NewStringf("%s::%s", Getattr(parent, "name"), name);
|
||||
/* apply the features of the original method found in the base class */
|
||||
Swig_features_get(Swig_cparse_features(), 0, mname, Getattr(m, "decl"), m);
|
||||
Setattr(item, "methodNode", m);
|
||||
Setattr(item, "vmid", method_id);
|
||||
if (replace == DO_NOT_REPLACE)
|
||||
Append(vm, item);
|
||||
else
|
||||
Setitem(vm, replace, item);
|
||||
Setattr(nn, "directorNode", m);
|
||||
|
||||
Delete(mname);
|
||||
}
|
||||
if (is_destructor) {
|
||||
virtual_destructor = 1;
|
||||
if (Equal(nodeType(ni), "using")) {
|
||||
for (Node *nn = firstChild(ni); nn; nn = Getattr(nn, "sym:nextSibling")) {
|
||||
unrollOneVirtualMethod(classname, nn, parent, vm, virtual_destructor, protectedbase);
|
||||
}
|
||||
}
|
||||
unrollOneVirtualMethod(classname, ni, parent, vm, virtual_destructor, protectedbase);
|
||||
}
|
||||
|
||||
/*
|
||||
We delete all the nodirector methods. This prevents the
|
||||
generation of 'empty' director classes.
|
||||
|
||||
But this has to be done outside the previous 'for'
|
||||
and the recursive loop!.
|
||||
Done once we've collated all the virtual methods into vm.
|
||||
*/
|
||||
if (n == parent) {
|
||||
int len = Len(vm);
|
||||
|
|
@ -2196,7 +2200,7 @@ int Language::classDirector(Node *n) {
|
|||
}
|
||||
List *vtable = NewList();
|
||||
int virtual_destructor = 0;
|
||||
unrollVirtualMethods(n, n, vtable, 0, virtual_destructor);
|
||||
unrollVirtualMethods(n, n, vtable, virtual_destructor);
|
||||
|
||||
// Emit all the using base::member statements for non virtual members (allprotected mode)
|
||||
Node *ni;
|
||||
|
|
@ -3788,7 +3792,7 @@ int Language::abstractClassTest(Node *n) {
|
|||
#endif
|
||||
for (int i = 0; i < labs; i++) {
|
||||
Node *ni = Getitem(abstracts, i);
|
||||
Node *method_id = vtable_method_id(ni);
|
||||
String *method_id = vtable_method_id(ni);
|
||||
if (!method_id)
|
||||
continue;
|
||||
bool exists_item = false;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
/**** Diagnostics:
|
||||
With the #define REPORT(), you can change the amount of diagnostics given
|
||||
This helps me search the parse tree & figure out what is going on inside SWIG
|
||||
(because its not clear or documented)
|
||||
(because it's not clear or documented)
|
||||
*/
|
||||
#define REPORT(T,D) // no info:
|
||||
//#define REPORT(T,D) {Printf(stdout,T"\n");} // only title
|
||||
|
|
@ -304,7 +304,7 @@ public:
|
|||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
|
|
@ -435,7 +435,7 @@ public:
|
|||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
This is it!
|
||||
you get this one right, and most of your work is done
|
||||
but its going to take some file to get it working right
|
||||
but it's going to take some file to get it working right
|
||||
quite a bit of this is generally boilerplate code
|
||||
(or stuff I don't understand)
|
||||
that which matters will have extra added comments
|
||||
|
|
@ -1418,7 +1418,6 @@ public:
|
|||
List *baselist = Getattr(n, "bases");
|
||||
if (baselist && Len(baselist)) {
|
||||
Iterator b;
|
||||
int index = 0;
|
||||
b = First(baselist);
|
||||
while (b.item) {
|
||||
String *bname = Getattr(b.item, "name");
|
||||
|
|
@ -1431,7 +1430,6 @@ public:
|
|||
Printf(base_class_names, "\"%s *\",", SwigType_namestr(bname));
|
||||
|
||||
b = Next(b);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
// First, print class static part
|
||||
|
|
@ -2053,8 +2051,8 @@ public:
|
|||
if (GetFlag(carrays_hash, "lua:class_instance")) {
|
||||
String *static_cls = Getattr(carrays_hash, "lua:class_instance:static_hash");
|
||||
assert(static_cls);
|
||||
// static_cls is swig_lua_namespace. This structure can't be use with eLua(LTR)
|
||||
// Instead structure describing its methods isused
|
||||
// static_cls is swig_lua_namespace. This structure can't be used with eLua(LTR)
|
||||
// Instead a structure describing its methods is used
|
||||
String *static_cls_cname = Getattr(static_cls, "methods:name");
|
||||
assert(static_cls_cname);
|
||||
Printv(metatable_tab, tab4, "{LSTRKEY(\".static\"), LROVAL(", static_cls_cname, ")},\n", NIL);
|
||||
|
|
@ -2225,36 +2223,6 @@ public:
|
|||
|
||||
};
|
||||
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
in order to add you language into swig, you need to make the following changes:
|
||||
- write this file (obviously)
|
||||
- add into the makefile (not 100% clear on how to do this)
|
||||
- edit swigmain.cxx to add your module
|
||||
|
||||
near the top of swigmain.cxx, look for this code & add you own codes
|
||||
======= begin change ==========
|
||||
extern "C" {
|
||||
Language *swig_tcl(void);
|
||||
Language *swig_python(void);
|
||||
//etc,etc,etc...
|
||||
Language *swig_lua(void); // this is my code
|
||||
}
|
||||
|
||||
//etc,etc,etc...
|
||||
|
||||
swig_module modules[] = {
|
||||
{"-guile", swig_guile, "Guile"},
|
||||
{"-java", swig_java, "Java"},
|
||||
//etc,etc,etc...
|
||||
{"-lua", swig_lua, "Lua"}, // this is my code
|
||||
{NULL, NULL, NULL} // this must come at the end of the list
|
||||
};
|
||||
======= end change ==========
|
||||
|
||||
This is all that is needed
|
||||
|
||||
NEW LANGUAGE NOTE:END ************************************************/
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* swig_lua() - Instantiate module
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ int Verbose = 0;
|
|||
int AddExtern = 0;
|
||||
int NoExcept = 0;
|
||||
int SwigRuntime = 0; // 0 = no option, 1 = -runtime, 2 = -noruntime
|
||||
int UseWrapperSuffix = 0; // If 1, append suffix to non-overloaded functions too.
|
||||
|
||||
/* Suppress warning messages for private inheritance, preprocessor evaluation etc...
|
||||
WARN_PP_EVALUATION 202
|
||||
|
|
@ -74,6 +75,7 @@ static const char *usage1 = (const char *) "\
|
|||
-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-quiet - Display less parse tree node debug info when using other -debug options\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\
|
||||
|
|
@ -137,7 +139,7 @@ static const char *usage4 = (const char *) "\
|
|||
-oh <headfile> - Set name of C++ output header file for directors to <headfile>\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\
|
||||
-pcreversion - Display PCRE2 version information\n\
|
||||
-small - Compile in virtual elimination and compact mode\n\
|
||||
-swiglib - Report location of SWIG library and exit\n\
|
||||
-templatereduce - Reduce all the typedefs in templates\n\
|
||||
|
|
@ -193,7 +195,6 @@ static int dump_tags = 0;
|
|||
static int dump_module = 0;
|
||||
static int dump_top = 0;
|
||||
static int dump_xml = 0;
|
||||
static int browse = 0;
|
||||
static int dump_typedef = 0;
|
||||
static int dump_classes = 0;
|
||||
static int werror = 0;
|
||||
|
|
@ -403,14 +404,14 @@ static void SWIG_dump_runtime() {
|
|||
outfile = lang->defaultExternalRuntimeFilename();
|
||||
if (!outfile) {
|
||||
Printf(stderr, "*** Please provide a filename for the external runtime\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
runtime = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!runtime) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
Swig_banner(runtime);
|
||||
|
|
@ -420,7 +421,7 @@ static void SWIG_dump_runtime() {
|
|||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swiglabels.swg'\n");
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
Delete(s);
|
||||
|
|
@ -429,7 +430,7 @@ static void SWIG_dump_runtime() {
|
|||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigerrors.swg'\n");
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
Delete(s);
|
||||
|
|
@ -438,7 +439,7 @@ static void SWIG_dump_runtime() {
|
|||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigrun.swg'\n");
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
Delete(s);
|
||||
|
|
@ -451,13 +452,13 @@ static void SWIG_dump_runtime() {
|
|||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'runtime.swg'\n");
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
Delete(s);
|
||||
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
Exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void getoptions(int argc, char *argv[]) {
|
||||
|
|
@ -471,13 +472,14 @@ static void getoptions(int argc, char *argv[]) {
|
|||
Swig_mark_arg(i);
|
||||
} else if (strncmp(argv[i], "-I", 2) == 0) {
|
||||
// Add a new directory search path
|
||||
char *a = Swig_copy_string(argv[i] + 2);
|
||||
Swig_add_directory((DOH *) a);
|
||||
free(a);
|
||||
Swig_add_directory((String_or_char*)(argv[i] + 2));
|
||||
Swig_mark_arg(i);
|
||||
} else if (strncmp(argv[i], "-D", 2) == 0) {
|
||||
String *d = NewString(argv[i] + 2);
|
||||
Replace(d, "=", " ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
|
||||
if (Replace(d, "=", " ", DOH_REPLACE_FIRST) == 0) {
|
||||
// Match C preprocessor behaviour whereby -DFOO sets FOO=1.
|
||||
Append(d, " 1");
|
||||
}
|
||||
Preprocessor_define((DOH *) d, 0);
|
||||
Delete(d);
|
||||
// Create a symbol
|
||||
|
|
@ -530,7 +532,7 @@ static void getoptions(int argc, char *argv[]) {
|
|||
Printf(stdout, "%s\n", version);
|
||||
Delete(version);
|
||||
Swig_mark_arg(i);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
Exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-small") == 0) {
|
||||
Wrapper_compact_print_mode_set(1);
|
||||
Wrapper_virtual_elimination_mode_set(1);
|
||||
|
|
@ -593,7 +595,7 @@ static void getoptions(int argc, char *argv[]) {
|
|||
Printf(stdout, "%s\n", SwigLib);
|
||||
if (SwigLibWinUnix)
|
||||
Printf(stdout, "%s\n", SwigLibWinUnix);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
Exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-o") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
|
|
@ -646,7 +648,7 @@ static void getoptions(int argc, char *argv[]) {
|
|||
#endif
|
||||
);
|
||||
fprintf(stdout, "\nPlease see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
Exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-copyright") == 0) {
|
||||
fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version());
|
||||
fprintf(stdout, "Copyright (c) 1995-1998\n");
|
||||
|
|
@ -655,7 +657,7 @@ static void getoptions(int argc, char *argv[]) {
|
|||
fprintf(stdout, "University of Chicago\n");
|
||||
fprintf(stdout, "Copyright (c) 2005-2006\n");
|
||||
fprintf(stdout, "Arizona Board of Regents (University of Arizona)\n");
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
Exit(EXIT_SUCCESS);
|
||||
} else if (strncmp(argv[i], "-l", 2) == 0) {
|
||||
// Add a new directory search path
|
||||
Append(libfiles, argv[i] + 2);
|
||||
|
|
@ -777,6 +779,9 @@ static void 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-quiet") == 0) {
|
||||
Swig_print_quiet(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-debug-symtabs") == 0) {
|
||||
dump_symtabs = 1;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -845,9 +850,6 @@ static void getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-nocontract") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
Swig_contract_mode_set(0);
|
||||
} else if (strcmp(argv[i], "-browse") == 0) {
|
||||
browse = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if ((strcmp(argv[i], "-debug-typedef") == 0) || (strcmp(argv[i], "-dump_typedef") == 0)) {
|
||||
dump_typedef = 1;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -879,9 +881,14 @@ static void getoptions(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
static void SWIG_exit_handler(int status);
|
||||
|
||||
int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
||||
char *c;
|
||||
|
||||
/* Set function for Exit() to call. */
|
||||
SetExitHandler(SWIG_exit_handler);
|
||||
|
||||
/* Initialize the SWIG core */
|
||||
Swig_init();
|
||||
|
||||
|
|
@ -968,7 +975,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
|||
|
||||
if (help) {
|
||||
Printf(stdout, "\nNote: 'swig -<lang> -help' displays options for a specific target language.\n\n");
|
||||
SWIG_exit(EXIT_SUCCESS); // Exit if we're in help mode
|
||||
Exit(EXIT_SUCCESS); // Exit if we're in help mode
|
||||
}
|
||||
|
||||
// Check all of the options to make sure we're cool.
|
||||
|
|
@ -977,7 +984,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
|||
|
||||
if (CPlusPlus && cparse_cplusplusout) {
|
||||
Printf(stderr, "The -c++out option is for C input but C++ input has been requested via -c++\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
install_opts(argc, argv);
|
||||
|
|
@ -1042,7 +1049,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
|||
File *f_outfile = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_outfile) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
} else {
|
||||
if (Verbose)
|
||||
Printf(stdout, "'%s' checked out from the SWIG library.\n", outfile);
|
||||
|
|
@ -1070,7 +1077,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
|||
} else {
|
||||
Printf(stderr, "Unable to find file '%s'.\n", input_file);
|
||||
}
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
} else {
|
||||
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
|
||||
}
|
||||
|
|
@ -1079,7 +1086,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
|||
if (!tlm) {
|
||||
Printf(stderr, "No target language specified.\n");
|
||||
Printf(stderr, "Use 'swig -help' for more information.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!no_cpp) {
|
||||
|
|
@ -1103,11 +1110,11 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
|||
fclose(df);
|
||||
}
|
||||
if (Swig_error_count()) {
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
if (cpp_only) {
|
||||
Printf(stdout, "%s", cpps);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
Exit(EXIT_SUCCESS);
|
||||
}
|
||||
if (depend) {
|
||||
if (!no_cpp) {
|
||||
|
|
@ -1129,14 +1136,14 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
|||
f_dependencies_file = NewFile(dependencies_file, "w", SWIG_output_files());
|
||||
if (!f_dependencies_file) {
|
||||
FileErrorDisplay(dependencies_file);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
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);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
} else
|
||||
f_dependencies_file = stdout;
|
||||
|
|
@ -1169,14 +1176,14 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
|||
if (f_dependencies_file != stdout)
|
||||
Delete(f_dependencies_file);
|
||||
if (depend_only)
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
Exit(EXIT_SUCCESS);
|
||||
Delete(inputfile_filename);
|
||||
Delete(basename);
|
||||
Delete(phony_targets);
|
||||
} else {
|
||||
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);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
Seek(cpps, 0, SEEK_SET);
|
||||
|
|
@ -1281,13 +1288,13 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
|||
if (top) {
|
||||
if (!Getattr(top, "name")) {
|
||||
Printf(stderr, "No module name specified using %%module or -module.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
} else {
|
||||
/* Set some filename information on the object */
|
||||
String *infile = scanner_get_main_input_file();
|
||||
if (!infile) {
|
||||
Printf(stderr, "Missing input file in preprocessed output.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
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);
|
||||
|
|
@ -1325,9 +1332,6 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
|||
|
||||
lang->top(top);
|
||||
|
||||
if (browse) {
|
||||
Swig_browser(top, 0);
|
||||
}
|
||||
Delete(infile_filename);
|
||||
Delete(basename);
|
||||
}
|
||||
|
|
@ -1361,7 +1365,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
|||
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);
|
||||
Exit(EXIT_FAILURE);
|
||||
} else {
|
||||
int i;
|
||||
for (i = 0; i < Len(all_output_files); i++)
|
||||
|
|
@ -1383,22 +1387,22 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
|||
error_count += Swig_error_count();
|
||||
|
||||
if (error_count != 0)
|
||||
SWIG_exit(error_count);
|
||||
Exit(EXIT_FAILURE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SWIG_exit()
|
||||
* SWIG_exit_handler()
|
||||
*
|
||||
* Cleanup and either freeze or exit
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void SWIG_exit(int exit_code) {
|
||||
static void SWIG_exit_handler(int status) {
|
||||
while (freeze) {
|
||||
}
|
||||
|
||||
if (exit_code > 0) {
|
||||
if (status > 0) {
|
||||
CloseAllOpenFiles();
|
||||
|
||||
/* Remove all generated files */
|
||||
|
|
@ -1411,6 +1415,4 @@ void SWIG_exit(int exit_code) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit(exit_code);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static const char *usage = "\
|
||||
|
|
@ -66,7 +65,7 @@ public:
|
|||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(usage, stdout);
|
||||
SWIG_exit(0);
|
||||
Exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
prefix = NewString(argv[i + 1]);
|
||||
|
|
@ -130,7 +129,7 @@ public:
|
|||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ void Swig_nested_name_unnamed_c_structs(Node *n) {
|
|||
Delete(ins);
|
||||
Delattr(c, "nested:outer");
|
||||
} else {
|
||||
// global unnamed struct - ignore it and it's instances
|
||||
// global unnamed struct - ignore it and its instances
|
||||
SetFlag(c, "feature:ignore");
|
||||
while (next && Getattr(next, "nested:unnamedtype") == c) {
|
||||
SetFlag(next, "feature:ignore");
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static const char *usage = "\
|
||||
|
|
@ -99,10 +98,10 @@ public:
|
|||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(usage, stdout);
|
||||
SWIG_exit(0);
|
||||
Exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-where") == 0) {
|
||||
PrintIncludeArg();
|
||||
SWIG_exit(0);
|
||||
Exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
prefix = NewString(argv[i + 1]);
|
||||
|
|
@ -228,7 +227,7 @@ public:
|
|||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
|
|
@ -311,12 +310,12 @@ public:
|
|||
String *mlfilen = NewStringf("%s%s", SWIG_output_directory(), mlfile);
|
||||
if ((f_mlout = NewFile(mlfilen, "w", SWIG_output_files())) == 0) {
|
||||
FileErrorDisplay(mlfilen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
String *mlifilen = NewStringf("%s%s", SWIG_output_directory(), mlifile);
|
||||
if ((f_mliout = NewFile(mlifilen, "w", SWIG_output_files())) == 0) {
|
||||
FileErrorDisplay(mlifilen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
emitBanner(f_mlout);
|
||||
emitBanner(f_mliout);
|
||||
|
|
@ -398,26 +397,18 @@ public:
|
|||
*/
|
||||
|
||||
void oc_SwigType_del_reference(SwigType *t) {
|
||||
char *c = Char(t);
|
||||
if (strncmp(c, "q(", 2) == 0) {
|
||||
Delete(SwigType_pop(t));
|
||||
c = Char(t);
|
||||
if (SwigType_isqualifier(t)) {
|
||||
SwigType_del_qualifier(t);
|
||||
}
|
||||
if (strncmp(c, "r.", 2)) {
|
||||
printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n");
|
||||
abort();
|
||||
}
|
||||
Replace(t, "r.", "", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
|
||||
SwigType_del_reference(t);
|
||||
}
|
||||
|
||||
void oc_SwigType_del_array(SwigType *t) {
|
||||
char *c = Char(t);
|
||||
if (strncmp(c, "q(", 2) == 0) {
|
||||
Delete(SwigType_pop(t));
|
||||
c = Char(t);
|
||||
if (SwigType_isqualifier(t)) {
|
||||
SwigType_del_qualifier(t);
|
||||
}
|
||||
if (strncmp(c, "a(", 2) == 0) {
|
||||
Delete(SwigType_pop(t));
|
||||
if (SwigType_isarray(t)) {
|
||||
SwigType_del_array(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1495,10 +1486,6 @@ public:
|
|||
int i;
|
||||
char source[256];
|
||||
|
||||
int outputs = 0;
|
||||
if (!is_void)
|
||||
outputs++;
|
||||
|
||||
/* build argument list and type conversion string */
|
||||
for (i = 0, idx = 0, p = l; i < num_arguments; i++) {
|
||||
|
||||
|
|
@ -1506,9 +1493,6 @@ public:
|
|||
p = Getattr(p, "tmap:ignore:next");
|
||||
}
|
||||
|
||||
if (Getattr(p, "tmap:directorargout") != 0)
|
||||
outputs++;
|
||||
|
||||
String *pname = Getattr(p, "name");
|
||||
String *ptype = Getattr(p, "type");
|
||||
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ public:
|
|||
} else if (strcmp(argv[i], "-nocppcast") == 0) {
|
||||
Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]);
|
||||
Swig_mark_arg(i);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ public:
|
|||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_header = NewString("");
|
||||
|
|
@ -1003,7 +1003,6 @@ public:
|
|||
List *baselist = Getattr(n, "bases");
|
||||
if (baselist && Len(baselist)) {
|
||||
Iterator b;
|
||||
int index = 0;
|
||||
b = First(baselist);
|
||||
while (b.item) {
|
||||
String *bname = Getattr(b.item, "name");
|
||||
|
|
@ -1016,7 +1015,6 @@ public:
|
|||
Printf(base_class_names, "\"%s\",", bname_mangled);
|
||||
Printf(base_class, "0,");
|
||||
b = Next(b);
|
||||
index++;
|
||||
Delete(bname_mangled);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -339,7 +339,6 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
Setattr(nodes[i].n, "overload:ignore", "1");
|
||||
Append(result, nodes[i].n);
|
||||
// Printf(stdout,"[ %d ] %d %s\n", i, nodes[i].implicitconv_function, ParmList_errorstr(nodes[i].parms));
|
||||
// Swig_print_node(nodes[i].n);
|
||||
if (i == nnodes-1 || nodes[i].argc != nodes[i+1].argc) {
|
||||
if (argc_changed_index+2 < nnodes && (nodes[argc_changed_index+1].argc == nodes[argc_changed_index+2].argc)) {
|
||||
// Add additional implicitconv functions in same order as already ranked.
|
||||
|
|
@ -351,7 +350,6 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
SetFlag(nodes[j].n, "implicitconvtypecheckoff");
|
||||
Append(result, nodes[j].n);
|
||||
// Printf(stdout,"[ %d ] %d + %s\n", j, nodes[j].implicitconv_function, ParmList_errorstr(nodes[j].parms));
|
||||
// Swig_print_node(nodes[j].n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ Perl 5 Options (available with -perl5)\n\
|
|||
-const - Wrap constants as constants and not variables (implies -proxy)\n\
|
||||
-nopm - Do not generate the .pm file\n\
|
||||
-noproxy - Don't create proxy classes\n\
|
||||
-proxy - Create proxy classes\n\
|
||||
-proxy - Create proxy classes (enabled by default)\n\
|
||||
-static - Omit code related to dynamic loading\n\
|
||||
\n";
|
||||
|
||||
|
|
@ -154,11 +154,11 @@ public:
|
|||
if (strcmp(argv[i], "-package") == 0) {
|
||||
Printv(stderr,
|
||||
"*** -package is no longer supported\n*** use the directive '%module A::B::C' in your interface file instead\n*** see the Perl section in the manual for details.\n", NIL);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
} else if (strcmp(argv[i], "-interface") == 0) {
|
||||
Printv(stderr,
|
||||
"*** -interface is no longer supported\n*** use the directive '%module A::B::C' in your interface file instead\n*** see the Perl section in the manual for details.\n", NIL);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
} else if (strcmp(argv[i], "-exportall") == 0) {
|
||||
export_all = 1;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -197,7 +197,7 @@ public:
|
|||
} else if (strcmp(argv[i], "-nocppcast") == 0) {
|
||||
Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]);
|
||||
Swig_mark_arg(i);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -276,7 +276,7 @@ public:
|
|||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
|
|
@ -289,7 +289,7 @@ public:
|
|||
f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
|
||||
if (!f_runtime_h) {
|
||||
FileErrorDisplay(outfile_h);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -407,7 +407,7 @@ public:
|
|||
String *filen = NewStringf("%s%s", SWIG_output_directory(), pmfile);
|
||||
if ((f_pm = NewFile(filen, "w", SWIG_output_files())) == 0) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delete(filen);
|
||||
filen = NULL;
|
||||
|
|
@ -445,13 +445,7 @@ public:
|
|||
|
||||
Printv(magic,
|
||||
"#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n",
|
||||
"#ifdef PERL_OBJECT\n",
|
||||
"#define MAGIC_CLASS _wrap_", underscore_module, "_var::\n",
|
||||
"class _wrap_", underscore_module, "_var : public CPerlObj {\n",
|
||||
"public:\n",
|
||||
"#else\n",
|
||||
"#define MAGIC_CLASS\n",
|
||||
"#endif\n",
|
||||
"SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *SWIGUNUSEDPARM(sv), MAGIC *SWIGUNUSEDPARM(mg)) {\n",
|
||||
tab4, "MAGIC_PPERL\n", tab4, "croak(\"Value is read-only.\");\n", tab4, "return 0;\n", "}\n", NIL);
|
||||
|
||||
|
|
@ -470,7 +464,6 @@ public:
|
|||
|
||||
/* Dump out variable wrappers */
|
||||
|
||||
Printv(magic, "\n\n#ifdef PERL_OBJECT\n", "};\n", "#endif\n", NIL);
|
||||
Printv(magic, "\n#ifdef __cplusplus\n}\n#endif\n", NIL);
|
||||
|
||||
Printf(f_header, "%s\n", magic);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -12,13 +12,12 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "swigmod.h"
|
||||
#include <limits.h>
|
||||
#include "cparse.h"
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include "pydoc.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include "pydoc.h"
|
||||
|
||||
#define PYSHADOW_MEMBER 0x2
|
||||
#define WARN_PYTHON_MULTIPLE_INH 405
|
||||
|
|
@ -69,12 +68,12 @@ static int no_header_file = 0;
|
|||
static int max_bases = 0;
|
||||
static int builtin_bases_needed = 0;
|
||||
|
||||
static int py3 = 0;
|
||||
|
||||
/* C++ Support + Shadow Classes */
|
||||
|
||||
static int have_constructor;
|
||||
static int have_repr;
|
||||
static int have_constructor = 0;
|
||||
static int have_repr = 0;
|
||||
static bool have_builtin_static_member_method_callback = false;
|
||||
static bool have_fast_proxy_static_member_method_callback = false;
|
||||
static String *real_classname;
|
||||
|
||||
/* Thread Support */
|
||||
|
|
@ -91,6 +90,7 @@ static int castmode = 0;
|
|||
static int extranative = 0;
|
||||
static int nortti = 0;
|
||||
static int relativeimport = 0;
|
||||
static int flat_static_method = 0;
|
||||
|
||||
/* flags for the make_autodoc function */
|
||||
namespace {
|
||||
|
|
@ -116,6 +116,7 @@ Python Options (available with -python)\n\
|
|||
-doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes\n\
|
||||
-extranative - Return extra native wrappers for C++ std containers wherever possible\n\
|
||||
-fastproxy - Use fast proxy mechanism for member methods\n\
|
||||
-flatstaticmethod - Generate additional flattened Python methods for C++ static methods\n\
|
||||
-globals <name> - Set <name> used to access C global variable (default: 'cvar')\n\
|
||||
-interface <mod>- Set low-level C/C++ module name to <mod> (default: module name prefixed by '_')\n\
|
||||
-keyword - Use keyword arguments\n";
|
||||
|
|
@ -127,7 +128,6 @@ static const char *usage3 = "\
|
|||
-nortti - Disable the use of the native C++ RTTI with directors\n\
|
||||
-nothreads - Disable thread support for the entire interface\n\
|
||||
-olddefs - Keep the old method definitions when using -fastproxy\n\
|
||||
-py3 - Generate code with Python 3 specific features and syntax\n\
|
||||
-relativeimport - Use relative Python imports\n\
|
||||
-threads - Add thread support for all the interface\n\
|
||||
-O - Enable the following optimization options:\n\
|
||||
|
|
@ -314,7 +314,6 @@ public:
|
|||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
/* end added */
|
||||
} else if (strcmp(argv[i], "-globals") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
global_name = NewString(argv[i + 1]);
|
||||
|
|
@ -372,6 +371,9 @@ public:
|
|||
} else if (strcmp(argv[i], "-extranative") == 0) {
|
||||
extranative = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-flatstaticmethod") == 0) {
|
||||
flat_static_method = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-noh") == 0) {
|
||||
no_header_file = 1;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -390,10 +392,6 @@ public:
|
|||
fputs(usage1, stdout);
|
||||
fputs(usage2, stdout);
|
||||
fputs(usage3, stdout);
|
||||
} else if (strcmp(argv[i], "-py3") == 0) {
|
||||
py3 = 1;
|
||||
Preprocessor_define("SWIGPYTHON_PY3", 0);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-builtin") == 0) {
|
||||
builtin = 1;
|
||||
Preprocessor_define("SWIGPYTHON_BUILTIN", 0);
|
||||
|
|
@ -409,7 +407,10 @@ public:
|
|||
strcmp(argv[i], "-modernargs") == 0 ||
|
||||
strcmp(argv[i], "-noproxydel") == 0 ||
|
||||
strcmp(argv[i], "-safecstrings") == 0) {
|
||||
Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]);
|
||||
Printf(stderr, "Deprecated command line option: %s. Ignored, this option is now always on.\n", argv[i]);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-py3") == 0) {
|
||||
Printf(stderr, "Deprecated command line option: %s. Ignored, this option is no longer supported.\n", argv[i]);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-aliasobj0") == 0 ||
|
||||
strcmp(argv[i], "-buildnone") == 0 ||
|
||||
|
|
@ -437,14 +438,23 @@ public:
|
|||
strcmp(argv[i], "-oldrepr") == 0 ||
|
||||
strcmp(argv[i], "-outputtuple") == 0 ||
|
||||
strcmp(argv[i], "-proxydel") == 0) {
|
||||
Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]);
|
||||
Printf(stderr, "Deprecated command line option: %s. This option is no longer available.\n", argv[i]);
|
||||
Swig_mark_arg(i);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (builtin && !shadow) {
|
||||
Printf(stderr, "Incompatible options -builtin and -noproxy specified.\n");
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (fastproxy) {
|
||||
Preprocessor_define("SWIGPYTHON_FASTPROXY", 0);
|
||||
}
|
||||
|
||||
if (doxygen)
|
||||
doxygenTranslator = new PyDocConverter(doxygen_translator_flags);
|
||||
|
||||
|
|
@ -497,22 +507,22 @@ public:
|
|||
}
|
||||
if (Getattr(options, "nocastmode")) {
|
||||
Printf(stderr, "Deprecated module option: %s. This option is no longer supported.\n", "nocastmode");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
if (Getattr(options, "extranative")) {
|
||||
extranative = 1;
|
||||
}
|
||||
if (Getattr(options, "noextranative")) {
|
||||
Printf(stderr, "Deprecated module option: %s. This option is no longer supported.\n", "noextranative");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
if (Getattr(options, "outputtuple")) {
|
||||
Printf(stderr, "Deprecated module option: %s. This option is no longer supported.\n", "outputtuple");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
if (Getattr(options, "nooutputtuple")) {
|
||||
Printf(stderr, "Deprecated module option: %s. This option is no longer supported.\n", "nooutputtuple");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
mod_docstring = Getattr(options, "docstring");
|
||||
package = Getattr(options, "package");
|
||||
|
|
@ -531,7 +541,7 @@ public:
|
|||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
|
|
@ -555,7 +565,7 @@ public:
|
|||
f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
|
||||
if (!f_runtime_h) {
|
||||
FileErrorDisplay(outfile_h);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
f_runtime_h = f_runtime;
|
||||
|
|
@ -612,6 +622,10 @@ public:
|
|||
Printf(f_runtime, "#define SWIGPYTHON_BUILTIN\n");
|
||||
}
|
||||
|
||||
if (fastproxy) {
|
||||
Printf(f_runtime, "#define SWIGPYTHON_FASTPROXY\n");
|
||||
}
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
|
||||
Printf(f_header, "#ifdef SWIG_TypeQuery\n");
|
||||
|
|
@ -656,7 +670,7 @@ public:
|
|||
Insert(module, 0, "_");
|
||||
if ((f_shadow_py = NewFile(filen, "w", SWIG_output_files())) == 0) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delete(filen);
|
||||
filen = NULL;
|
||||
|
|
@ -697,9 +711,11 @@ public:
|
|||
Printv(default_import_code, tab4, "from ", module, " import *\n", NULL);
|
||||
}
|
||||
|
||||
/* Need builtins to qualify names like Exception that might also be
|
||||
defined in this module (try both Python 3 and Python 2 names) */
|
||||
Printv(f_shadow, "try:\n", tab4, "import builtins as __builtin__\n", "except ImportError:\n", tab4, "import __builtin__\n", NULL);
|
||||
if (!builtin) {
|
||||
/* Need builtins to qualify names like Exception that might also be
|
||||
defined in this module (try both Python 3 and Python 2 names) */
|
||||
Printv(f_shadow, "try:\n", tab4, "import builtins as __builtin__\n", "except ImportError:\n", tab4, "import __builtin__\n", NULL);
|
||||
}
|
||||
|
||||
if (!builtin && fastproxy) {
|
||||
Printf(f_shadow, "\n");
|
||||
|
|
@ -707,58 +723,54 @@ public:
|
|||
Printf(f_shadow, "_swig_new_static_method = %s.SWIG_PyStaticMethod_New\n", module);
|
||||
}
|
||||
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_repr(self):\n",
|
||||
tab4, "try:\n",
|
||||
tab4, tab4, "strthis = \"proxy of \" + self.this.__repr__()\n",
|
||||
tab4, "except __builtin__.Exception:\n",
|
||||
tab4, tab4, "strthis = \"\"\n",
|
||||
tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);
|
||||
if (!builtin) {
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_repr(self):\n",
|
||||
tab4, "try:\n",
|
||||
tab4, tab4, "strthis = \"proxy of \" + self.this.__repr__()\n",
|
||||
tab4, "except __builtin__.Exception:\n",
|
||||
tab4, tab4, "strthis = \"\"\n",
|
||||
tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);
|
||||
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_setattr_nondynamic_instance_variable(set):\n",
|
||||
tab4, "def set_instance_attr(self, name, value):\n",
|
||||
#ifdef USE_THISOWN
|
||||
tab4, tab4, "if name in (\"this\", \"thisown\"):\n",
|
||||
tab4, tab4, tab4, "set(self, name, value)\n",
|
||||
#else
|
||||
tab4, tab4, "if name == \"thisown\":\n",
|
||||
tab4, tab4, tab4, "self.this.own(value)\n",
|
||||
tab4, tab4, "elif name == \"this\":\n",
|
||||
tab4, tab4, tab4, "set(self, name, value)\n",
|
||||
#endif
|
||||
tab4, tab4, "elif hasattr(self, name) and isinstance(getattr(type(self), name), property):\n",
|
||||
tab4, tab4, tab4, "set(self, name, value)\n",
|
||||
tab4, tab4, "else:\n",
|
||||
tab4, tab4, tab4, "raise AttributeError(\"You cannot add instance attributes to %s\" % self)\n",
|
||||
tab4, "return set_instance_attr\n\n", NIL);
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_setattr_nondynamic_instance_variable(set):\n",
|
||||
tab4, "def set_instance_attr(self, name, value):\n",
|
||||
tab4, tab4, "if name == \"this\":\n",
|
||||
tab4, tab4, tab4, "set(self, name, value)\n",
|
||||
tab4, tab4, "elif name == \"thisown\":\n",
|
||||
tab4, tab4, tab4, "self.this.own(value)\n",
|
||||
tab4, tab4, "elif hasattr(self, name) and isinstance(getattr(type(self), name), property):\n",
|
||||
tab4, tab4, tab4, "set(self, name, value)\n",
|
||||
tab4, tab4, "else:\n",
|
||||
tab4, tab4, tab4, "raise AttributeError(\"You cannot add instance attributes to %s\" % self)\n",
|
||||
tab4, "return set_instance_attr\n\n", NIL);
|
||||
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_setattr_nondynamic_class_variable(set):\n",
|
||||
tab4, "def set_class_attr(cls, name, value):\n",
|
||||
tab4, tab4, "if hasattr(cls, name) and not isinstance(getattr(cls, name), property):\n",
|
||||
tab4, tab4, tab4, "set(cls, name, value)\n",
|
||||
tab4, tab4, "else:\n",
|
||||
tab4, tab4, tab4, "raise AttributeError(\"You cannot add class attributes to %s\" % cls)\n",
|
||||
tab4, "return set_class_attr\n\n", NIL);
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_setattr_nondynamic_class_variable(set):\n",
|
||||
tab4, "def set_class_attr(cls, name, value):\n",
|
||||
tab4, tab4, "if hasattr(cls, name) and not isinstance(getattr(cls, name), property):\n",
|
||||
tab4, tab4, tab4, "set(cls, name, value)\n",
|
||||
tab4, tab4, "else:\n",
|
||||
tab4, tab4, tab4, "raise AttributeError(\"You cannot add class attributes to %s\" % cls)\n",
|
||||
tab4, "return set_class_attr\n\n", NIL);
|
||||
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_add_metaclass(metaclass):\n",
|
||||
tab4, "\"\"\"Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass\"\"\"\n",
|
||||
tab4, "def wrapper(cls):\n",
|
||||
tab4, tab4, "return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())\n",
|
||||
tab4, "return wrapper\n\n", NIL);
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_add_metaclass(metaclass):\n",
|
||||
tab4, "\"\"\"Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass\"\"\"\n",
|
||||
tab4, "def wrapper(cls):\n",
|
||||
tab4, tab4, "return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())\n",
|
||||
tab4, "return wrapper\n\n", NIL);
|
||||
|
||||
Printv(f_shadow, "\n",
|
||||
"class _SwigNonDynamicMeta(type):\n",
|
||||
tab4, "\"\"\"Meta class to enforce nondynamic attributes (no new attributes) for a class\"\"\"\n",
|
||||
tab4, "__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)\n",
|
||||
"\n", NIL);
|
||||
Printv(f_shadow, "\n",
|
||||
"class _SwigNonDynamicMeta(type):\n",
|
||||
tab4, "\"\"\"Meta class to enforce nondynamic attributes (no new attributes) for a class\"\"\"\n",
|
||||
tab4, "__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)\n",
|
||||
"\n", NIL);
|
||||
|
||||
Printv(f_shadow, "\n", NIL);
|
||||
Printv(f_shadow, "\n", NIL);
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printv(f_shadow, "import weakref\n\n", NIL);
|
||||
if (directorsEnabled())
|
||||
Printv(f_shadow, "import weakref\n\n", NIL);
|
||||
}
|
||||
}
|
||||
// Include some information in the code
|
||||
|
|
@ -805,7 +817,8 @@ public:
|
|||
Printf(f_wrappers, "%s\n", methods);
|
||||
Append(methods_proxydocs, "\t { NULL, NULL, 0, NULL }\n");
|
||||
Append(methods_proxydocs, "};\n");
|
||||
Printf(f_wrappers, "%s\n", methods_proxydocs);
|
||||
if ((fastproxy && !builtin) || have_fast_proxy_static_member_method_callback)
|
||||
Printf(f_wrappers, "%s\n", methods_proxydocs);
|
||||
|
||||
if (builtin) {
|
||||
Dump(f_builtins, f_wrappers);
|
||||
|
|
@ -815,6 +828,10 @@ public:
|
|||
|
||||
Append(const_code, "{0, 0, 0, 0.0, 0, 0}};\n");
|
||||
Printf(f_wrappers, "%s\n", const_code);
|
||||
|
||||
if (have_fast_proxy_static_member_method_callback)
|
||||
Printf(f_init, " SWIG_Python_FixMethods(SwigMethods_proxydocs, swig_const_table, swig_types, swig_type_initial);\n\n");
|
||||
|
||||
initialize_threads(f_init);
|
||||
|
||||
Printf(f_init, "#if PY_VERSION_HEX >= 0x03000000\n");
|
||||
|
|
@ -847,13 +864,6 @@ public:
|
|||
Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL);
|
||||
|
||||
Printv(f_shadow_py, "\nfrom sys import version_info as _swig_python_version_info\n", NULL);
|
||||
if (py3) {
|
||||
Printv(f_shadow_py, "if _swig_python_version_info < (3, 0):\n", NULL);
|
||||
Printv(f_shadow_py, tab4, "raise RuntimeError(\"Python 3.x or later required\")\n\n", NULL);
|
||||
} else {
|
||||
Printv(f_shadow_py, "if _swig_python_version_info < (2, 7, 0):\n", NULL);
|
||||
Printv(f_shadow_py, tab4, "raise RuntimeError(\"Python 2.7 or later required\")\n\n", NULL);
|
||||
}
|
||||
|
||||
if (Len(f_shadow_after_begin) > 0)
|
||||
Printv(f_shadow_py, f_shadow_after_begin, "\n", NIL);
|
||||
|
|
@ -865,8 +875,10 @@ public:
|
|||
Printv(f_shadow_py, default_import_code, NIL);
|
||||
}
|
||||
|
||||
Printv(f_shadow_py, "\n", f_shadow, "\n", NIL);
|
||||
Printv(f_shadow_py, f_shadow_stubs, "\n", NIL);
|
||||
if (Len(f_shadow) > 0)
|
||||
Printv(f_shadow_py, "\n", f_shadow, "\n", NIL);
|
||||
if (Len(f_shadow_stubs) > 0)
|
||||
Printv(f_shadow_py, f_shadow_stubs, "\n", NIL);
|
||||
Delete(f_shadow_py);
|
||||
}
|
||||
|
||||
|
|
@ -911,15 +923,15 @@ public:
|
|||
* as a replacement of new.instancemethod in Python 3.
|
||||
* ------------------------------------------------------------ */
|
||||
int add_pyinstancemethod_new() {
|
||||
String *name = NewString("SWIG_PyInstanceMethod_New");
|
||||
String *line = NewString("");
|
||||
Printf(line, "\t { \"%s\", %s, METH_O, NULL},\n", name, name);
|
||||
Append(methods, line);
|
||||
if (fastproxy) {
|
||||
if (!builtin && fastproxy) {
|
||||
String *name = NewString("SWIG_PyInstanceMethod_New");
|
||||
String *line = NewString("");
|
||||
Printf(line, "\t { \"%s\", %s, METH_O, NULL},\n", name, name);
|
||||
Append(methods, line);
|
||||
Append(methods_proxydocs, line);
|
||||
Delete(line);
|
||||
Delete(name);
|
||||
}
|
||||
Delete(line);
|
||||
Delete(name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -929,7 +941,7 @@ public:
|
|||
* generated for static methods when using -fastproxy
|
||||
* ------------------------------------------------------------ */
|
||||
int add_pystaticmethod_new() {
|
||||
if (fastproxy) {
|
||||
if (!builtin && fastproxy) {
|
||||
String *name = NewString("SWIG_PyStaticMethod_New");
|
||||
String *line = NewString("");
|
||||
Printf(line, "\t { \"%s\", %s, METH_O, NULL},\n", name, name);
|
||||
|
|
@ -1479,16 +1491,18 @@ public:
|
|||
/* ------------------------------------------------------------
|
||||
* build_combined_docstring()
|
||||
*
|
||||
* Build the full docstring which may be a combination of the
|
||||
* explicit docstring and autodoc string or, if none of them
|
||||
* is specified, obtained by translating Doxygen comment to
|
||||
* Python.
|
||||
* Build the full docstring:
|
||||
* Use the docstring if there is one present otherwise
|
||||
* use the Doxygen comment if there is one present.
|
||||
* Ignore autodoc if there is a Doxygen comment, otherwise
|
||||
* create the autodoc string and append to any docstring.
|
||||
*
|
||||
* Return new string to be deleted by caller (never NIL but
|
||||
* may be empty if there is no docstring).
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
String *build_combined_docstring(Node *n, autodoc_t ad_type, const String *indent = "", bool low_level = false) {
|
||||
bool add_autodoc = true;
|
||||
String *docstr = Getattr(n, "feature:docstring");
|
||||
if (docstr) {
|
||||
// Simplify the code below by just ignoring empty docstrings.
|
||||
|
|
@ -1506,26 +1520,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
if (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")) {
|
||||
String *autodoc = make_autodoc(n, ad_type, low_level);
|
||||
if (autodoc && Len(autodoc) > 0) {
|
||||
if (docstr) {
|
||||
Append(autodoc, "\n");
|
||||
Append(autodoc, docstr);
|
||||
}
|
||||
|
||||
String *tmp = autodoc;
|
||||
autodoc = docstr;
|
||||
docstr = tmp;
|
||||
}
|
||||
|
||||
Delete(autodoc);
|
||||
}
|
||||
|
||||
if (!docstr) {
|
||||
if (doxygen) {
|
||||
if (doxygen && doxygenTranslator->hasDocumentation(n)) {
|
||||
docstr = Getattr(n, "python:docstring");
|
||||
if (!docstr && doxygenTranslator->hasDocumentation(n)) {
|
||||
if (!docstr) {
|
||||
docstr = doxygenTranslator->getDocumentation(n, 0);
|
||||
|
||||
// Avoid rebuilding it again the next time: notice that we can't do
|
||||
|
|
@ -1541,9 +1539,26 @@ public:
|
|||
// the cached object!
|
||||
docstr = Copy(docstr);
|
||||
}
|
||||
add_autodoc = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (add_autodoc && Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")) {
|
||||
String *autodoc = make_autodoc(n, ad_type, low_level);
|
||||
if (autodoc && Len(autodoc) > 0) {
|
||||
if (docstr) {
|
||||
Append(autodoc, "\n");
|
||||
Append(autodoc, docstr);
|
||||
}
|
||||
|
||||
String *tmp = autodoc;
|
||||
autodoc = docstr;
|
||||
docstr = tmp;
|
||||
}
|
||||
|
||||
Delete(autodoc);
|
||||
}
|
||||
|
||||
if (!docstr)
|
||||
docstr = NewString("");
|
||||
|
||||
|
|
@ -2256,7 +2271,7 @@ public:
|
|||
return parms;
|
||||
}
|
||||
|
||||
bool funcanno = py3 ? true : false;
|
||||
bool funcanno = Equal(Getattr(n, "feature:python:annotations"), "c") ? true : false;
|
||||
String *params = NewString("");
|
||||
String *_params = make_autodocParmList(n, false, ((in_class || has_self_for_count)? 2 : 1), is_calling, funcanno);
|
||||
|
||||
|
|
@ -2372,8 +2387,25 @@ public:
|
|||
if (ret)
|
||||
ret = SwigType_str(ret, 0);
|
||||
}
|
||||
return (ret && py3) ? NewStringf(" -> \"%s\"", ret)
|
||||
: NewString("");
|
||||
bool funcanno = Equal(Getattr(n, "feature:python:annotations"), "c") ? true : false;
|
||||
return (ret && funcanno) ? NewStringf(" -> \"%s\"", ret) : NewString("");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* variableAnnotation()
|
||||
*
|
||||
* Helper function for constructing a variable annotation
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
String *variableAnnotation(Node *n) {
|
||||
String *type = Getattr(n, "type");
|
||||
if (type)
|
||||
type = SwigType_str(type, 0);
|
||||
bool anno = Equal(Getattr(n, "feature:python:annotations"), "c") ? true : false;
|
||||
anno = GetFlag(n, "feature:python:annotations:novar") ? false : anno;
|
||||
String *annotation = (type && anno) ? NewStringf(": \"%s\"", type) : NewString("");
|
||||
Delete(type);
|
||||
return annotation;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
|
|
@ -2478,6 +2510,7 @@ public:
|
|||
Printf(methods, "\"swig_ptr: %s\"", Getattr(n, "feature:callback:name"));
|
||||
if (fastproxy) {
|
||||
Printf(methods_proxydocs, "\"swig_ptr: %s\"", Getattr(n, "feature:callback:name"));
|
||||
have_fast_proxy_static_member_method_callback = true;
|
||||
}
|
||||
} else {
|
||||
Append(methods, "NULL");
|
||||
|
|
@ -2495,7 +2528,7 @@ public:
|
|||
/* ------------------------------------------------------------
|
||||
* dispatchFunction()
|
||||
* ------------------------------------------------------------ */
|
||||
void dispatchFunction(Node *n, String *linkage, int funpack = 0, bool builtin_self = false, bool builtin_ctor = false, bool director_class = false) {
|
||||
void dispatchFunction(Node *n, String *linkage, int funpack = 0, bool builtin_self = false, bool builtin_ctor = false, bool director_class = false, bool use_static_method = false) {
|
||||
/* Last node in overloaded chain */
|
||||
|
||||
bool add_self = builtin_self && (!builtin_ctor || director_class);
|
||||
|
|
@ -2533,6 +2566,11 @@ public:
|
|||
const char *builtin_kwargs = builtin_ctor ? ", PyObject *kwargs" : "";
|
||||
Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
|
||||
if (builtin) {
|
||||
/* Avoid warning if the self parameter is not used. */
|
||||
Append(f->code, "(void)self;\n");
|
||||
}
|
||||
|
||||
Wrapper_add_local(f, "argc", "Py_ssize_t argc");
|
||||
Printf(tmp, "PyObject *argv[%d] = {0}", maxargs + 1);
|
||||
Wrapper_add_local(f, "argv", tmp);
|
||||
|
|
@ -2594,11 +2632,11 @@ public:
|
|||
Printv(f->code, "}\n", NIL);
|
||||
Wrapper_print(f, f_wrappers);
|
||||
Node *p = Getattr(n, "sym:previousSibling");
|
||||
if (!builtin_self)
|
||||
if (!builtin_self && (use_static_method || !builtin))
|
||||
add_method(symname, wname, 0, p);
|
||||
|
||||
/* Create a shadow for this function (if enabled and not in a member function) */
|
||||
if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
||||
if (!builtin && shadow && !(shadow & PYSHADOW_MEMBER) && use_static_method) {
|
||||
emitFunctionShadowHelper(n, in_class ? f_shadow_stubs : f_shadow, symname, 0);
|
||||
}
|
||||
DelWrapper(f);
|
||||
|
|
@ -2702,7 +2740,6 @@ public:
|
|||
bool add_self = builtin_self && (!builtin_ctor || director_class);
|
||||
bool builtin_getter = (builtin && GetFlag(n, "memberget"));
|
||||
bool builtin_setter = (builtin && GetFlag(n, "memberset") && !builtin_getter);
|
||||
char const *self_param = builtin ? "self" : "SWIGUNUSEDPARM(self)";
|
||||
char const *wrap_return = builtin_ctor ? "int " : "PyObject *";
|
||||
String *linkage = NewString("SWIGINTERN ");
|
||||
String *wrapper_name = Swig_name_wrapper(iname);
|
||||
|
|
@ -2757,9 +2794,9 @@ public:
|
|||
const char *builtin_kwargs = builtin_ctor ? ", PyObject *kwargs" : "";
|
||||
if (!allow_kwargs || overname) {
|
||||
if (!varargs) {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *self, PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
} else {
|
||||
Printv(f->def, linkage, wrap_return, wname, "__varargs__", "(PyObject *", self_param, ", PyObject *args, PyObject *varargs", builtin_kwargs, ") {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "__varargs__", "(PyObject *self, PyObject *args, PyObject *varargs", builtin_kwargs, ") {", NIL);
|
||||
}
|
||||
if (allow_kwargs) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_KEYWORD, input_file, line_number, "Can't use keyword arguments with overloaded functions (%s).\n", Swig_name_decl(n));
|
||||
|
|
@ -2770,8 +2807,14 @@ public:
|
|||
Swig_warning(WARN_LANG_VARARGS_KEYWORD, input_file, line_number, "Can't wrap varargs with keyword arguments enabled\n");
|
||||
varargs = 0;
|
||||
}
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args, PyObject *kwargs) {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *self, PyObject *args, PyObject *kwargs) {", NIL);
|
||||
}
|
||||
|
||||
if (builtin) {
|
||||
/* Avoid warning if the self parameter is not used. */
|
||||
Append(f->code, "(void)self;\n");
|
||||
}
|
||||
|
||||
if (!builtin || !in_class || tuple_arguments > 0 || builtin_ctor) {
|
||||
if (!allow_kwargs) {
|
||||
Append(parse_args, " if (!PyArg_ParseTuple(args, \"");
|
||||
|
|
@ -2798,7 +2841,7 @@ public:
|
|||
|
||||
/* Generate code for argument marshalling */
|
||||
if (funpack) {
|
||||
if (num_arguments > 0 && !overname) {
|
||||
if (num_arguments > (builtin_self && !constructor ? 1 : 0) && !overname) {
|
||||
sprintf(source, "PyObject *swig_obj[%d]", num_arguments);
|
||||
Wrapper_add_localv(f, "swig_obj", source, NIL);
|
||||
}
|
||||
|
|
@ -2930,14 +2973,14 @@ public:
|
|||
Clear(f->def);
|
||||
if (overname) {
|
||||
if (noargs) {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *self, Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) {", NIL);
|
||||
} else {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", Py_ssize_t nobjs, PyObject **swig_obj) {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {", NIL);
|
||||
}
|
||||
Printf(parse_args, "if ((nobjs < %d) || (nobjs > %d)) SWIG_fail;\n", num_required, num_arguments);
|
||||
} else {
|
||||
int is_tp_call = Equal(Getattr(n, "feature:python:slot"), "tp_call");
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *self, PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
if (builtin_ctor)
|
||||
Printf(parse_args, "if (!SWIG_Python_CheckNoKeywords(kwargs, \"%s\")) SWIG_fail;\n", iname);
|
||||
if (onearg && !builtin_ctor && !is_tp_call) {
|
||||
|
|
@ -3229,9 +3272,9 @@ public:
|
|||
f = NewWrapper();
|
||||
if (funpack) {
|
||||
// Note: funpack is currently always false for varargs
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", Py_ssize_t nobjs, PyObject **swig_obj) {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {", NIL);
|
||||
} else {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *self, PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
}
|
||||
Wrapper_add_local(f, "resultobj", builtin_ctor ? "int resultobj" : "PyObject *resultobj");
|
||||
Wrapper_add_local(f, "varargs", "PyObject *varargs");
|
||||
|
|
@ -3260,18 +3303,20 @@ public:
|
|||
Wrapper_print(f, f_wrappers);
|
||||
}
|
||||
|
||||
bool use_static_method = flat_static_method || !Swig_storage_isstatic_custom(n, "staticmemberfunctionHandler:storage");
|
||||
/* Now register the function with the interpreter. */
|
||||
if (!Getattr(n, "sym:overloaded")) {
|
||||
if (!builtin_self)
|
||||
if (!builtin_self && (use_static_method || !builtin))
|
||||
add_method(iname, wname, allow_kwargs, n, funpack, num_required, num_arguments);
|
||||
|
||||
/* Create a shadow for this function (if enabled and not in a member function) */
|
||||
if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
||||
if (!builtin && shadow && !(shadow & PYSHADOW_MEMBER) && use_static_method) {
|
||||
emitFunctionShadowHelper(n, in_class ? f_shadow_stubs : f_shadow, iname, allow_kwargs);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
dispatchFunction(n, linkage, funpack, builtin_self, builtin_ctor, director_class);
|
||||
dispatchFunction(n, linkage, funpack, builtin_self, builtin_ctor, director_class, use_static_method);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3424,11 +3469,10 @@ public:
|
|||
Printf(f_init, "#endif\n");
|
||||
Printf(f_init, "\t }\n");
|
||||
Printf(f_init, "\t PyDict_SetItemString(md, \"%s\", globals);\n", global_name);
|
||||
Printf(f_init, "\t Py_DECREF(globals);\n");
|
||||
if (builtin)
|
||||
Printf(f_init, "\t SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", global_name);
|
||||
have_globals = 1;
|
||||
if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
||||
if (!builtin && shadow && !(shadow & PYSHADOW_MEMBER)) {
|
||||
Printf(f_shadow_stubs, "%s = %s.%s\n", global_name, module, global_name);
|
||||
}
|
||||
}
|
||||
|
|
@ -3586,7 +3630,7 @@ public:
|
|||
|
||||
if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
|
||||
Replaceall(tm, "$value", value);
|
||||
if (needs_swigconstant(n) && !builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER)) && (!in_class || !Getattr(n, "feature:python:callback"))) {
|
||||
if (needs_swigconstant(n) && !builtin && shadow && !(shadow & PYSHADOW_MEMBER) && (!in_class || !Getattr(n, "feature:python:callback"))) {
|
||||
// Generate `*_swigconstant()` method which registers the new constant.
|
||||
//
|
||||
// *_swigconstant methods are required for constants of class type.
|
||||
|
|
@ -3624,7 +3668,7 @@ public:
|
|||
return SWIG_NOWRAP;
|
||||
}
|
||||
|
||||
if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
||||
if (!builtin && shadow && !(shadow & PYSHADOW_MEMBER)) {
|
||||
String *f_s;
|
||||
if (!in_class) {
|
||||
f_s = f_shadow;
|
||||
|
|
@ -3859,11 +3903,7 @@ public:
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
String *mrename = Swig_name_disown(NSPACE_TODO, symname); //Getattr(n, "name"));
|
||||
Printv(f_shadow, tab4, "def __disown__(self):\n", NIL);
|
||||
#ifdef USE_THISOWN
|
||||
Printv(f_shadow, tab8, "self.thisown = 0\n", NIL);
|
||||
#else
|
||||
Printv(f_shadow, tab8, "self.this.disown()\n", NIL);
|
||||
#endif
|
||||
Printv(f_shadow, tab8, module, ".", mrename, "(self)\n", NIL);
|
||||
Printv(f_shadow, tab8, "return weakref.proxy(self)\n", NIL);
|
||||
Delete(mrename);
|
||||
|
|
@ -3936,6 +3976,10 @@ public:
|
|||
int funpack = fastunpack;
|
||||
static String *tp_new = NewString("PyType_GenericNew");
|
||||
|
||||
if (have_builtin_static_member_method_callback) {
|
||||
Printf(f_init, " SWIG_Python_FixMethods(SwigPyBuiltin_%s_methods, swig_const_table, swig_types, swig_type_initial);\n", mname);
|
||||
}
|
||||
|
||||
Printv(f_init, " SwigPyBuiltin_SetMetaType(builtin_pytype, metatype);\n", NIL);
|
||||
|
||||
// We can’t statically initialize a structure member with a function defined in another C module
|
||||
|
|
@ -4100,7 +4144,11 @@ public:
|
|||
printSlot(f, getSlot(n, "feature:python:tp_basicsize", tp_basicsize), "tp_basicsize");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_itemsize"), "tp_itemsize");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_dealloc", tp_dealloc_bad), "tp_dealloc", "destructor");
|
||||
Printv(f, "#if PY_VERSION_HEX < 0x030800b4\n", NIL);
|
||||
printSlot(f, getSlot(n, "feature:python:tp_print"), "tp_print", "printfunc");
|
||||
Printv(f, "#else\n", NIL);
|
||||
printSlot(f, getSlot(n, "feature:python:tp_vectorcall_offset"), "tp_vectorcall_offset", "Py_ssize_t");
|
||||
Printv(f, "#endif\n", NIL);
|
||||
printSlot(f, getSlot(n, "feature:python:tp_getattr"), "tp_getattr", "getattrfunc");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_setattr"), "tp_setattr", "setattrfunc");
|
||||
Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL);
|
||||
|
|
@ -4184,6 +4232,9 @@ public:
|
|||
printSlot(f, getSlot(n, "feature:python:am_await"), "am_await", "unaryfunc");
|
||||
printSlot(f, getSlot(n, "feature:python:am_aiter"), "am_aiter", "unaryfunc");
|
||||
printSlot(f, getSlot(n, "feature:python:am_anext"), "am_anext", "unaryfunc");
|
||||
Printv(f, "# if PY_VERSION_HEX >= 0x030a0000\n", NIL);
|
||||
printSlot(f, getSlot(n, "feature:python:am_send"), "am_send", "sendfunc");
|
||||
Printv(f, "# endif\n", NIL);
|
||||
Printf(f, " },\n");
|
||||
Printv(f, "#endif\n", NIL);
|
||||
|
||||
|
|
@ -4297,9 +4348,20 @@ public:
|
|||
printSlot(f, getSlot(n, "feature:python:ht_cached_keys"), "ht_cached_keys");
|
||||
Printv(f, "#endif\n", NIL);
|
||||
|
||||
// PyObject *ht_module;
|
||||
Printv(f, "#if PY_VERSION_HEX >= 0x03090000\n", NIL);
|
||||
printSlot(f, getSlot(n, "feature:python:ht_module"), "ht_module", "PyObject *");
|
||||
Printv(f, "#endif\n", NIL);
|
||||
|
||||
// char *_ht_tpname;
|
||||
Printv(f, "#if PY_VERSION_HEX >= 0x030b0000\n", NIL);
|
||||
printSlot(f, getSlot(n, "feature:python:_ht_tpname"), "_ht_tpname", "char *");
|
||||
|
||||
// struct _specialization_cache _spec_cache;
|
||||
Printf(f, " {\n");
|
||||
printSlot(f, getSlot(n, "feature:python:getitem"), "getitem", "PyObject *");
|
||||
Printf(f, " }\n");
|
||||
Printv(f, "#endif\n", NIL);
|
||||
Printf(f, "};\n\n");
|
||||
|
||||
String *clientdata = NewString("");
|
||||
|
|
@ -4366,6 +4428,7 @@ public:
|
|||
/* Create new strings for building up a wrapper function */
|
||||
have_constructor = 0;
|
||||
have_repr = 0;
|
||||
have_builtin_static_member_method_callback = false;
|
||||
|
||||
class_name = Getattr(n, "sym:name");
|
||||
real_classname = Getattr(n, "name");
|
||||
|
|
@ -4423,10 +4486,9 @@ public:
|
|||
|
||||
/* dealing with abstract base class */
|
||||
String *abcs = Getattr(n, "feature:python:abc");
|
||||
if (py3 && abcs) {
|
||||
if (Len(base_class)) {
|
||||
if (abcs) {
|
||||
if (Len(base_class) > 0)
|
||||
Printv(base_class, ", ", NIL);
|
||||
}
|
||||
Printv(base_class, abcs, NIL);
|
||||
}
|
||||
|
||||
|
|
@ -4442,10 +4504,8 @@ public:
|
|||
Delete(rname);
|
||||
}
|
||||
} else {
|
||||
if (!py3) {
|
||||
if (GetFlag(n, "feature:python:nondynamic"))
|
||||
Printv(f_shadow, "@_swig_add_metaclass(_SwigNonDynamicMeta)\n", NIL);
|
||||
}
|
||||
if (GetFlag(n, "feature:python:nondynamic"))
|
||||
Printv(f_shadow, "@_swig_add_metaclass(_SwigNonDynamicMeta)\n", NIL);
|
||||
Printv(f_shadow, "class ", class_name, NIL);
|
||||
|
||||
if (Len(base_class)) {
|
||||
|
|
@ -4455,9 +4515,11 @@ public:
|
|||
Printf(f_shadow, "(Exception)");
|
||||
} else {
|
||||
Printf(f_shadow, "(object");
|
||||
if (py3 && GetFlag(n, "feature:python:nondynamic")) {
|
||||
/* Replace @_swig_add_metaclass above with below when support for python 2.7 is dropped
|
||||
if (GetFlag(n, "feature:python:nondynamic")) {
|
||||
Printf(f_shadow, ", metaclass=_SwigNonDynamicMeta");
|
||||
}
|
||||
*/
|
||||
Printf(f_shadow, ")");
|
||||
}
|
||||
}
|
||||
|
|
@ -4572,7 +4634,8 @@ public:
|
|||
}
|
||||
|
||||
shadow_indent = 0;
|
||||
Printf(f_shadow_file, "%s\n", f_shadow_stubs);
|
||||
if (Len(f_shadow_stubs) > 0)
|
||||
Printf(f_shadow_file, "%s\n", f_shadow_stubs);
|
||||
Clear(f_shadow_stubs);
|
||||
}
|
||||
|
||||
|
|
@ -4728,6 +4791,7 @@ public:
|
|||
Swig_restore(n);
|
||||
}
|
||||
|
||||
int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0;
|
||||
if (builtin && in_class) {
|
||||
if ((GetFlagAttr(n, "feature:extend") || checkAttribute(n, "access", "public"))
|
||||
&& !Getattr(class_members, symname)) {
|
||||
|
|
@ -4742,7 +4806,7 @@ public:
|
|||
else if (funpack && argcount == 1)
|
||||
Append(pyflags, "METH_O");
|
||||
else
|
||||
Append(pyflags, "METH_VARARGS");
|
||||
Append(pyflags, kw ? "METH_VARARGS|METH_KEYWORDS" : "METH_VARARGS");
|
||||
// Cast via void(*)(void) to suppress GCC -Wcast-function-type warning.
|
||||
// Python should always call the function correctly, but the Python C
|
||||
// API requires us to store it in function pointer of a different type.
|
||||
|
|
@ -4750,6 +4814,11 @@ public:
|
|||
String *ds = cdocstring(n, AUTODOC_STATICFUNC);
|
||||
Printf(builtin_methods, " { \"%s\", (PyCFunction)(void(*)(void))%s, %s, \"%s\" },\n", symname, wname, pyflags, ds);
|
||||
Delete(ds);
|
||||
} else if (Getattr(n, "feature:callback")) {
|
||||
String *ds = NewStringf("swig_ptr: %s", Getattr(n, "feature:callback:name"));
|
||||
Printf(builtin_methods, " { \"%s\", (PyCFunction)(void(*)(void))%s, %s, \"%s\" },\n", symname, wname, pyflags, ds);
|
||||
Delete(ds);
|
||||
have_builtin_static_member_method_callback = true;
|
||||
} else {
|
||||
Printf(builtin_methods, " { \"%s\", (PyCFunction)(void(*)(void))%s, %s, \"\" },\n", symname, wname, pyflags);
|
||||
}
|
||||
|
|
@ -4768,7 +4837,6 @@ public:
|
|||
String *staticfunc_name = NewString(fastproxy ? "_swig_new_static_method" : "staticmethod");
|
||||
bool fast = (fastproxy && !have_addtofunc(n)) || Getattr(n, "feature:callback");
|
||||
if (!fast || olddefs) {
|
||||
int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0;
|
||||
String *parms = make_pyParmList(n, false, false, kw);
|
||||
String *callParms = make_pyParmList(n, false, true, kw);
|
||||
Printv(f_shadow, "\n", tab4, "@staticmethod", NIL);
|
||||
|
|
@ -4913,9 +4981,6 @@ public:
|
|||
if (have_pythonprepend(n))
|
||||
Printv(f_shadow_stubs, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL);
|
||||
Printv(f_shadow_stubs, tab4, "val = ", funcCall(subfunc, callParms), "\n", NIL);
|
||||
#ifdef USE_THISOWN
|
||||
Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL);
|
||||
#endif
|
||||
if (have_pythonappend(n))
|
||||
Printv(f_shadow_stubs, indent_pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL);
|
||||
Printv(f_shadow_stubs, tab4, "return val\n", NIL);
|
||||
|
|
@ -4971,12 +5036,6 @@ public:
|
|||
Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL);
|
||||
if (have_pythonprepend(n))
|
||||
Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL);
|
||||
#ifdef USE_THISOWN
|
||||
Printv(f_shadow, tab8, "try:\n", NIL);
|
||||
Printv(f_shadow, tab8, tab4, "if self.thisown:", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "(self)\n", NIL);
|
||||
Printv(f_shadow, tab8, "except __builtin__.Exception: pass\n", NIL);
|
||||
#else
|
||||
#endif
|
||||
if (have_pythonappend(n))
|
||||
Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL);
|
||||
Printv(f_shadow, tab8, "pass\n", NIL);
|
||||
|
|
@ -5004,12 +5063,17 @@ public:
|
|||
String *setname = Swig_name_set(NSPACE_TODO, mname);
|
||||
String *getname = Swig_name_get(NSPACE_TODO, mname);
|
||||
int assignable = is_assignable(n);
|
||||
Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL);
|
||||
String *variable_annotation = variableAnnotation(n);
|
||||
Printv(f_shadow, tab4, symname, variable_annotation, " = property(", module, ".", getname, NIL);
|
||||
if (assignable)
|
||||
Printv(f_shadow, ", ", module, ".", setname, NIL);
|
||||
if (have_docstring(n))
|
||||
Printv(f_shadow, ", doc=", docstring(n, AUTODOC_VAR, tab4), NIL);
|
||||
if (have_docstring(n)) {
|
||||
String *s = docstring(n, AUTODOC_VAR, tab4);
|
||||
if (Len(s))
|
||||
Printv(f_shadow, ", doc=", s, NIL);
|
||||
}
|
||||
Printv(f_shadow, ")\n", NIL);
|
||||
Delete(variable_annotation);
|
||||
Delete(mname);
|
||||
Delete(setname);
|
||||
Delete(getname);
|
||||
|
|
@ -5074,8 +5138,11 @@ public:
|
|||
Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL);
|
||||
if (assignable)
|
||||
Printv(f_shadow, ", ", module, ".", setname, NIL);
|
||||
if (have_docstring(n))
|
||||
Printv(f_shadow, ", doc=", docstring(n, AUTODOC_VAR, tab4), NIL);
|
||||
if (have_docstring(n)) {
|
||||
String *s = docstring(n, AUTODOC_VAR, tab4);
|
||||
if (Len(s))
|
||||
Printv(f_shadow, ", doc=", s, NIL);
|
||||
}
|
||||
Printv(f_shadow, ")\n", NIL);
|
||||
}
|
||||
String *getter = Getattr(n, "pybuiltin:getter");
|
||||
|
|
|
|||
|
|
@ -805,7 +805,7 @@ int R::DumpCode(Node *n) {
|
|||
File *scode = NewFile(output_filename, "w", SWIG_output_files());
|
||||
if (!scode) {
|
||||
FileErrorDisplay(output_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delete(output_filename);
|
||||
|
||||
|
|
@ -820,7 +820,7 @@ int R::DumpCode(Node *n) {
|
|||
File *runtime = NewFile(outfile,"w", SWIG_output_files());
|
||||
if (!runtime) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
Printf(runtime, "%s", f_begin);
|
||||
|
|
@ -837,7 +837,7 @@ int R::DumpCode(Node *n) {
|
|||
File *ns = NewFile(output_filename, "w", SWIG_output_files());
|
||||
if (!ns) {
|
||||
FileErrorDisplay(output_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delete(output_filename);
|
||||
|
||||
|
|
@ -940,7 +940,7 @@ int R::OutputClassMethodsTable(File *) {
|
|||
* The entries are indexed by <class name>_set and
|
||||
* <class_name>_get. Each entry is a List *.
|
||||
|
||||
* out - the stram where the code is to be written. This is the S
|
||||
* out - the stream where the code is to be written. This is the S
|
||||
* code stream as we generate only S code here.
|
||||
* --------------------------------------------------------------*/
|
||||
|
||||
|
|
@ -1542,8 +1542,6 @@ List * R::Swig_overload_rank(Node *n,
|
|||
if (nodes[i].error)
|
||||
Setattr(nodes[i].n, "overload:ignore", "1");
|
||||
Append(result,nodes[i].n);
|
||||
// Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms));
|
||||
// Swig_print_node(nodes[i].n);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
@ -2569,7 +2567,7 @@ int R::generateCopyRoutines(Node *n) {
|
|||
|
||||
|
||||
Printf(sfile, "# Start definition of copy methods for %s\n", rclassName);
|
||||
Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s);\n", rclassName,
|
||||
Printf(sfile, "setMethod('copyToR', '_p%s', CopyToR%s);\n", mangledName,
|
||||
mangledName);
|
||||
Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s);\n\n", rclassName,
|
||||
mangledName);
|
||||
|
|
@ -2740,7 +2738,7 @@ void R::main(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-nocppcast") == 0) {
|
||||
Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]);
|
||||
Swig_mark_arg(i);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (debugMode) {
|
||||
|
|
|
|||
|
|
@ -106,9 +106,10 @@ public:
|
|||
|
||||
char *strip(const_String_or_char_ptr s) {
|
||||
Clear(temp);
|
||||
Append(temp, s);
|
||||
if (Strncmp(s, prefix, Len(prefix)) == 0) {
|
||||
Replaceall(temp, prefix, "");
|
||||
Append(temp, Char(s) + Len(prefix));
|
||||
} else {
|
||||
Append(temp, s);
|
||||
}
|
||||
return Char(temp);
|
||||
}
|
||||
|
|
@ -897,7 +898,7 @@ public:
|
|||
} else if (strcmp(argv[i], "-nocppcast") == 0) {
|
||||
Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]);
|
||||
Swig_mark_arg(i);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1036,13 +1037,13 @@ public:
|
|||
|
||||
if (!outfile) {
|
||||
Printf(stderr, "Unable to determine outfile\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
f_runtime = NewString("");
|
||||
|
|
@ -1057,12 +1058,12 @@ public:
|
|||
if (directorsEnabled()) {
|
||||
if (!outfile_h) {
|
||||
Printf(stderr, "Unable to determine outfile_h\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
|
||||
if (!f_runtime_h) {
|
||||
FileErrorDisplay(outfile_h);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,10 @@
|
|||
* --------------------------------------------------------------------------*/
|
||||
|
||||
#include "swigmod.h"
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
|
||||
static const int SCILAB_IDENTIFIER_NAME_CHAR_MAX = 24;
|
||||
static const int SCILAB_VARIABLE_NAME_CHAR_MAX = SCILAB_IDENTIFIER_NAME_CHAR_MAX - 4;
|
||||
|
||||
static const char *usage = (char *) " \
|
||||
Scilab options (available with -scilab)\n \
|
||||
|
|
@ -25,7 +26,6 @@ Scilab options (available with -scilab)\n \
|
|||
-buildersources <files> - Add the (comma separated) files <files> to the builder sources\n \
|
||||
-builderverbositylevel <level> - Set the builder verbosity level to <level> (default 0: off, 2: high)\n \
|
||||
-gatewayxml <gateway_id> - Generate gateway xml with the given <gateway_id>\n \
|
||||
-targetversion <scilab_major_version> - Generate for Scilab target (major) version (default: 5)\n \
|
||||
\n";
|
||||
|
||||
|
||||
|
|
@ -40,11 +40,11 @@ protected:
|
|||
|
||||
String *variablesCode;
|
||||
|
||||
int targetVersion;
|
||||
|
||||
bool generateBuilder;
|
||||
File *builderFile;
|
||||
String *builderCode;
|
||||
String *builderCode5;
|
||||
String *builderCode6;
|
||||
int builderFunctionCount;
|
||||
|
||||
List *sourceFileList;
|
||||
|
|
@ -67,6 +67,9 @@ protected:
|
|||
bool createLoader;
|
||||
File *loaderFile;
|
||||
String *loaderScript;
|
||||
String *loaderScript5;
|
||||
String *loaderScript6;
|
||||
int loaderFunctionCount;
|
||||
public:
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
|
|
@ -74,8 +77,6 @@ public:
|
|||
* ----------------------------------------------------------------------*/
|
||||
|
||||
virtual void main(int argc, char *argv[]) {
|
||||
targetVersion = 5;
|
||||
|
||||
generateBuilder = false;
|
||||
sourceFileList = NewList();
|
||||
cflags = NewList();
|
||||
|
|
@ -99,23 +100,23 @@ public:
|
|||
/* Manage command line arguments */
|
||||
for (int argIndex = 1; argIndex < argc; argIndex++) {
|
||||
if (argv[argIndex] != NULL) {
|
||||
if (strcmp(argv[argIndex], "-help") == 0) {
|
||||
Printf(stdout, "%s\n", usage);
|
||||
} else if (strcmp(argv[argIndex], "-builder") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
generateBuilder = true;
|
||||
createLoader = false;
|
||||
} else if (strcmp(argv[argIndex], "-buildersources") == 0) {
|
||||
if (argv[argIndex + 1] != NULL) {
|
||||
Swig_mark_arg(argIndex);
|
||||
char *sourceFile = strtok(argv[argIndex + 1], ",");
|
||||
while (sourceFile != NULL) {
|
||||
Insert(sourceFileList, Len(sourceFileList), sourceFile);
|
||||
sourceFile = strtok(NULL, ",");
|
||||
}
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
}
|
||||
} else if (strcmp(argv[argIndex], "-buildercflags") == 0) {
|
||||
if (strcmp(argv[argIndex], "-help") == 0) {
|
||||
Printf(stdout, "%s\n", usage);
|
||||
} else if (strcmp(argv[argIndex], "-builder") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
generateBuilder = true;
|
||||
createLoader = false;
|
||||
} else if (strcmp(argv[argIndex], "-buildersources") == 0) {
|
||||
if (argv[argIndex + 1] != NULL) {
|
||||
Swig_mark_arg(argIndex);
|
||||
char *sourceFile = strtok(argv[argIndex + 1], ",");
|
||||
while (sourceFile != NULL) {
|
||||
Insert(sourceFileList, Len(sourceFileList), sourceFile);
|
||||
sourceFile = strtok(NULL, ",");
|
||||
}
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
}
|
||||
} else if (strcmp(argv[argIndex], "-buildercflags") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
if (argv[argIndex + 1] != NULL) {
|
||||
Insert(cflags, Len(cflags), argv[argIndex + 1]);
|
||||
|
|
@ -140,12 +141,6 @@ public:
|
|||
createGatewayXML = true;
|
||||
gatewayID = NewString(argv[argIndex + 1]);
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
} else if (strcmp(argv[argIndex], "-targetversion") == 0) {
|
||||
if (argv[argIndex + 1] != NULL) {
|
||||
Swig_mark_arg(argIndex);
|
||||
targetVersion = atoi(argv[argIndex + 1]);
|
||||
Swig_mark_arg(argIndex + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -188,7 +183,7 @@ public:
|
|||
beginSection = NewFile(outputFilename, "w", SWIG_output_files());
|
||||
if (!beginSection) {
|
||||
FileErrorDisplay(outputFilename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
runtimeSection = NewString("");
|
||||
initSection = NewString("");
|
||||
|
|
@ -227,10 +222,13 @@ public:
|
|||
}
|
||||
|
||||
// Module initialization function
|
||||
String *smallFunctionName = createSmallIdentifierName(gatewayName, SCILAB_IDENTIFIER_NAME_CHAR_MAX - 5);
|
||||
String *gatewayInitFunctionName = NewStringf("%s_Init", gatewayName);
|
||||
String *gatewayInitSmallFunctionName = NewStringf("%s_Init", smallFunctionName);
|
||||
String *wrapperFunctionName = NewStringf("SWIG_%s_Init", gatewayName);
|
||||
|
||||
/* Add initialization function to builder table */
|
||||
addFunctionToScilab(gatewayInitFunctionName, gatewayInitFunctionName);
|
||||
addFunctionToScilab(gatewayInitFunctionName, gatewayInitSmallFunctionName, wrapperFunctionName);
|
||||
|
||||
// Add helper functions to builder table
|
||||
addHelperFunctions();
|
||||
|
|
@ -254,7 +252,7 @@ public:
|
|||
|
||||
// Add Builder footer code and save
|
||||
if (generateBuilder) {
|
||||
saveBuilderFile(gatewayName);
|
||||
saveBuilderFile(gatewayLibraryName);
|
||||
}
|
||||
|
||||
/* Close the init function and rename with module name */
|
||||
|
|
@ -316,6 +314,8 @@ public:
|
|||
|
||||
/* Get some useful attributes of this function */
|
||||
String *functionName = Getattr(node, "sym:name");
|
||||
String *smallFunctionName = createSmallIdentifierName(functionName);
|
||||
|
||||
SwigType *functionReturnType = Getattr(node, "type");
|
||||
ParmList *functionParamsList = Getattr(node, "parms");
|
||||
|
||||
|
|
@ -345,7 +345,7 @@ public:
|
|||
}
|
||||
|
||||
/* Write the wrapper function definition (standard Scilab gateway function prototype) */
|
||||
Printv(wrapper->def, "int ", overloadedName, "(SWIG_GatewayParameters) {", NIL);
|
||||
Printv(wrapper->def, "SWIGEXPORT int ", overloadedName, "(SWIG_GatewayParameters) {", NIL);
|
||||
|
||||
/* Emit all of the local variables for holding arguments */
|
||||
// E.g.: double arg1;
|
||||
|
|
@ -360,7 +360,7 @@ public:
|
|||
int maxInputArguments = emit_num_arguments(functionParamsList);
|
||||
int minInputArguments = emit_num_required(functionParamsList);
|
||||
int minOutputArguments = 0;
|
||||
int maxOutputArguments = 0;
|
||||
int maxOutputArguments = 1;
|
||||
|
||||
if (!emit_isvarargs(functionParamsList)) {
|
||||
Printf(wrapper->code, "SWIG_CheckInputArgument(pvApiCtx, $mininputarguments, $maxinputarguments);\n");
|
||||
|
|
@ -498,10 +498,12 @@ public:
|
|||
Replaceall(wrapper->code, "$symname", functionName);
|
||||
|
||||
/* Set CheckInputArgument and CheckOutputArgument input arguments */
|
||||
/* In Scilab there is always one output even if not defined */
|
||||
if (minOutputArguments == 0) {
|
||||
if (maxOutputArguments < 1) {
|
||||
maxOutputArguments = 1;
|
||||
}
|
||||
if (minOutputArguments == 1) {
|
||||
minOutputArguments = 0;
|
||||
}
|
||||
String *argnumber = NewString("");
|
||||
Printf(argnumber, "%d", minInputArguments);
|
||||
Replaceall(wrapper->code, "$mininputarguments", argnumber);
|
||||
|
|
@ -521,16 +523,14 @@ public:
|
|||
/* Dump the function out */
|
||||
Wrapper_print(wrapper, wrappersSection);
|
||||
|
||||
String *scilabFunctionName = checkIdentifierName(functionName, SCILAB_IDENTIFIER_NAME_CHAR_MAX);
|
||||
|
||||
/* Update builder.sce contents */
|
||||
if (isLastOverloaded) {
|
||||
addFunctionToScilab(scilabFunctionName, wrapperName);
|
||||
addFunctionToScilab(functionName, smallFunctionName, wrapperName);
|
||||
dispatchFunction(node);
|
||||
}
|
||||
|
||||
if (!isOverloaded) {
|
||||
addFunctionToScilab(scilabFunctionName, wrapperName);
|
||||
addFunctionToScilab(functionName, smallFunctionName, wrapperName);
|
||||
}
|
||||
|
||||
/* tidy up */
|
||||
|
|
@ -556,7 +556,7 @@ public:
|
|||
String *dispatch = Swig_overload_dispatch(node, "return %s(SWIG_GatewayArguments);", &maxargs);
|
||||
String *tmp = NewString("");
|
||||
|
||||
Printv(wrapper->def, "int ", wrapperName, "(SWIG_GatewayParameters) {\n", NIL);
|
||||
Printv(wrapper->def, "SWIGEXPORT int ", wrapperName, "(SWIG_GatewayParameters) {\n", NIL);
|
||||
|
||||
/* Get the number of the parameters */
|
||||
Wrapper_add_local(wrapper, "argc", "int argc = SWIG_NbInputArgument(pvApiCtx)");
|
||||
|
|
@ -591,21 +591,20 @@ public:
|
|||
/* Get information about variable */
|
||||
String *origVariableName = Getattr(node, "name"); // Ex: Shape::nshapes
|
||||
String *variableName = Getattr(node, "sym:name"); // Ex; Shape_nshapes (can be used for function names, ...)
|
||||
|
||||
// Variable names can have SCILAB_VARIABLE_NAME_CHAR_MAX because of suffixes "_get" or "_set" added to function
|
||||
String *scilabVariableName = checkIdentifierName(variableName, SCILAB_VARIABLE_NAME_CHAR_MAX);
|
||||
String *smallVariableName = createSmallIdentifierName(variableName, SCILAB_IDENTIFIER_NAME_CHAR_MAX - 4);
|
||||
|
||||
/* Manage GET function */
|
||||
Wrapper *getFunctionWrapper = NewWrapper();
|
||||
String *getFunctionName = Swig_name_get(NSPACE_TODO, variableName);
|
||||
String *scilabGetFunctionName = Swig_name_get(NSPACE_TODO, scilabVariableName);
|
||||
String *scilabGetFunctionName = Swig_name_get(NSPACE_TODO, variableName);
|
||||
String *scilabGetSmallFunctionName = Swig_name_get(NSPACE_TODO, smallVariableName);
|
||||
|
||||
Setattr(node, "wrap:name", getFunctionName);
|
||||
Printv(getFunctionWrapper->def, "int ", getFunctionName, "(SWIG_GatewayParameters) {\n", NIL);
|
||||
Printv(getFunctionWrapper->def, "SWIGEXPORT int ", getFunctionName, "(SWIG_GatewayParameters) {\n", NIL);
|
||||
|
||||
/* Check the number of input and output */
|
||||
Printf(getFunctionWrapper->def, "SWIG_CheckInputArgument(pvApiCtx, 0, 0);\n");
|
||||
Printf(getFunctionWrapper->def, "SWIG_CheckOutputArgument(pvApiCtx, 1, 1);\n");
|
||||
Printf(getFunctionWrapper->def, "SWIG_CheckOutputArgument(pvApiCtx, 0, 1);\n");
|
||||
Printf(getFunctionWrapper->def, "SWIG_Scilab_SetApiContext(pvApiCtx);\n");
|
||||
|
||||
String *varoutTypemap = Swig_typemap_lookup("varout", node, origVariableName, 0);
|
||||
|
|
@ -621,20 +620,21 @@ public:
|
|||
Wrapper_print(getFunctionWrapper, wrappersSection);
|
||||
|
||||
/* Add function to builder table */
|
||||
addFunctionToScilab(scilabGetFunctionName, getFunctionName);
|
||||
addFunctionToScilab(scilabGetFunctionName, scilabGetSmallFunctionName, getFunctionName);
|
||||
|
||||
/* Manage SET function */
|
||||
if (is_assignable(node)) {
|
||||
Wrapper *setFunctionWrapper = NewWrapper();
|
||||
String *setFunctionName = Swig_name_set(NSPACE_TODO, variableName);
|
||||
String *scilabSetFunctionName = Swig_name_set(NSPACE_TODO, scilabVariableName);
|
||||
String *scilabSetFunctionName = Swig_name_set(NSPACE_TODO, variableName);
|
||||
String *scilabSetSmallFunctionName = Swig_name_set(NSPACE_TODO, smallVariableName);
|
||||
|
||||
Setattr(node, "wrap:name", setFunctionName);
|
||||
Printv(setFunctionWrapper->def, "int ", setFunctionName, "(SWIG_GatewayParameters) {\n", NIL);
|
||||
Printv(setFunctionWrapper->def, "SWIGEXPORT int ", setFunctionName, "(SWIG_GatewayParameters) {\n", NIL);
|
||||
|
||||
/* Check the number of input and output */
|
||||
Printf(setFunctionWrapper->def, "SWIG_CheckInputArgument(pvApiCtx, 1, 1);\n");
|
||||
Printf(setFunctionWrapper->def, "SWIG_CheckOutputArgument(pvApiCtx, 1, 1);\n");
|
||||
Printf(setFunctionWrapper->def, "SWIG_CheckOutputArgument(pvApiCtx, 0, 1);\n");
|
||||
Printf(setFunctionWrapper->def, "SWIG_Scilab_SetApiContext(pvApiCtx);\n");
|
||||
|
||||
String *varinTypemap = Swig_typemap_lookup("varin", node, origVariableName, 0);
|
||||
|
|
@ -648,7 +648,7 @@ public:
|
|||
Wrapper_print(setFunctionWrapper, wrappersSection);
|
||||
|
||||
/* Add function to builder table */
|
||||
addFunctionToScilab(scilabSetFunctionName, setFunctionName);
|
||||
addFunctionToScilab(scilabSetFunctionName, scilabSetSmallFunctionName, setFunctionName);
|
||||
|
||||
DelWrapper(setFunctionWrapper);
|
||||
}
|
||||
|
|
@ -684,10 +684,9 @@ public:
|
|||
|
||||
constantTypemap = Swig_typemap_lookup("scilabconstcode", node, nodeName, 0);
|
||||
if (constantTypemap != NULL) {
|
||||
String *scilabConstantName = checkIdentifierName(constantName, SCILAB_IDENTIFIER_NAME_CHAR_MAX);
|
||||
|
||||
Setattr(node, "wrap:name", constantName);
|
||||
Replaceall(constantTypemap, "$result", scilabConstantName);
|
||||
Replaceall(constantTypemap, "$result", constantName);
|
||||
Replaceall(constantTypemap, "$value", constantValue);
|
||||
|
||||
emit_action_code(node, variablesCode, constantTypemap);
|
||||
|
|
@ -705,19 +704,21 @@ public:
|
|||
Delete(str);
|
||||
constantValue = wname;
|
||||
}
|
||||
|
||||
// Constant names can have SCILAB_VARIABLE_NAME_CHAR_MAX because of suffixes "_get" added to function
|
||||
String *scilabConstantName = checkIdentifierName(constantName, SCILAB_VARIABLE_NAME_CHAR_MAX);
|
||||
String *smallConstantName = createSmallIdentifierName(constantName, SCILAB_IDENTIFIER_NAME_CHAR_MAX - 4);
|
||||
|
||||
/* Create GET function to get the constant value */
|
||||
Wrapper *getFunctionWrapper = NewWrapper();
|
||||
String *getFunctionName = Swig_name_get(NSPACE_TODO, constantName);
|
||||
String *scilabGetFunctionName = Swig_name_get(NSPACE_TODO, scilabConstantName);
|
||||
String *scilabGetSmallFunctionName = Swig_name_get(NSPACE_TODO, smallConstantName);
|
||||
Setattr(node, "wrap:name", getFunctionName);
|
||||
Printv(getFunctionWrapper->def, "int ", getFunctionName, "(SWIG_GatewayParameters) {\n", NIL);
|
||||
Setattr(node, "wrap:name", getFunctionName);
|
||||
Printv(getFunctionWrapper->def, "SWIGEXPORT int ", getFunctionName, "(SWIG_GatewayParameters) {\n", NIL);
|
||||
|
||||
/* Check the number of input and output */
|
||||
Printf(getFunctionWrapper->def, "SWIG_CheckInputArgument(pvApiCtx, 0, 0);\n");
|
||||
Printf(getFunctionWrapper->def, "SWIG_CheckOutputArgument(pvApiCtx, 1, 1);\n");
|
||||
Printf(getFunctionWrapper->def, "SWIG_CheckOutputArgument(pvApiCtx, 0, 1);\n");
|
||||
Printf(getFunctionWrapper->def, "SWIG_Scilab_SetApiContext(pvApiCtx);\n");
|
||||
|
||||
constantTypemap = Swig_typemap_lookup("constcode", node, nodeName, 0);
|
||||
|
|
@ -735,7 +736,7 @@ public:
|
|||
Wrapper_print(getFunctionWrapper, wrappersSection);
|
||||
|
||||
/* Add the function to Scilab */
|
||||
addFunctionToScilab(scilabGetFunctionName, getFunctionName);
|
||||
addFunctionToScilab(getFunctionName, scilabGetSmallFunctionName, getFunctionName);
|
||||
|
||||
DelWrapper(getFunctionWrapper);
|
||||
|
||||
|
|
@ -782,78 +783,13 @@ public:
|
|||
return Language::enumvalueDeclaration(node);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* membervariableHandler()
|
||||
* --------------------------------------------------------------------- */
|
||||
virtual int membervariableHandler(Node *node) {
|
||||
checkMemberIdentifierName(node, SCILAB_VARIABLE_NAME_CHAR_MAX);
|
||||
return Language::membervariableHandler(node);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
* checkIdentifierName()
|
||||
* If Scilab target version is lower than 6:
|
||||
* truncates (and displays a warning) too long member identifier names
|
||||
* (applies on members of structs, classes...)
|
||||
* (Scilab 5 identifier names are limited to 24 chars max)
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
String *checkIdentifierName(String *name, int char_size_max) {
|
||||
String *scilabIdentifierName;
|
||||
if (targetVersion <= 5) {
|
||||
if (Len(name) > char_size_max) {
|
||||
scilabIdentifierName = DohNewStringWithSize(name, char_size_max);
|
||||
Swig_warning(WARN_SCILAB_TRUNCATED_NAME, input_file, line_number,
|
||||
"Identifier name '%s' exceeds 24 characters and has been truncated to '%s'.\n", name, scilabIdentifierName);
|
||||
} else
|
||||
scilabIdentifierName = name;
|
||||
} else {
|
||||
scilabIdentifierName = DohNewString(name);
|
||||
}
|
||||
return scilabIdentifierName;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
* checkMemberIdentifierName()
|
||||
* If Scilab target version is lower than 6:
|
||||
* truncates (and displays a warning) too long member identifier names
|
||||
* (applies on members of structs, classes...)
|
||||
* (Scilab 5 identifier names are limited to 24 chars max)
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
void checkMemberIdentifierName(Node *node, int char_size_max) {
|
||||
if (targetVersion <= 5) {
|
||||
String *memberName = Getattr(node, "sym:name");
|
||||
Node *containerNode = parentNode(node);
|
||||
String *containerName = Getattr(containerNode, "sym:name");
|
||||
int lenContainerName = Len(containerName);
|
||||
int lenMemberName = Len(memberName);
|
||||
|
||||
if (lenContainerName + lenMemberName + 1 > char_size_max) {
|
||||
int lenScilabMemberName = char_size_max - lenContainerName - 1;
|
||||
|
||||
if (lenScilabMemberName > 0) {
|
||||
String *scilabMemberName = DohNewStringWithSize(memberName, lenScilabMemberName);
|
||||
Setattr(node, "sym:name", scilabMemberName);
|
||||
Swig_warning(WARN_SCILAB_TRUNCATED_NAME, input_file, line_number,
|
||||
"Wrapping functions names for member '%s.%s' will exceed 24 characters, "
|
||||
"so member name has been truncated to '%s'.\n", containerName, memberName, scilabMemberName);
|
||||
} else {
|
||||
Swig_error(input_file, line_number,
|
||||
"Wrapping functions names for member '%s.%s' will exceed 24 characters, "
|
||||
"please rename the container of member '%s'.\n", containerName, memberName, containerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
* addHelperFunctions()
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
void addHelperFunctions() {
|
||||
addFunctionToScilab("SWIG_this", "SWIG_this");
|
||||
addFunctionToScilab("SWIG_ptr", "SWIG_ptr");
|
||||
addFunctionToScilab("SWIG_this", "SWIG_this", "SWIG_this");
|
||||
addFunctionToScilab("SWIG_ptr", "SWIG_ptr", "SWIG_ptr");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
|
|
@ -861,20 +797,20 @@ public:
|
|||
* Declare a wrapped function in Scilab (builder, gateway, XML, ...)
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
void addFunctionToScilab(const_String_or_char_ptr scilabFunctionName, const_String_or_char_ptr wrapperFunctionName) {
|
||||
void addFunctionToScilab(const_String_or_char_ptr scilabFunctionName, const_String_or_char_ptr scilabSmallFunctionName, const_String_or_char_ptr wrapperFunctionName) {
|
||||
if (!generateBuilder)
|
||||
addFunctionInGatewayHeader(scilabFunctionName, wrapperFunctionName);
|
||||
addFunctionInGatewayHeader(scilabFunctionName, scilabSmallFunctionName, wrapperFunctionName);
|
||||
|
||||
if (generateBuilder) {
|
||||
addFunctionInScriptTable(scilabFunctionName, wrapperFunctionName, builderCode);
|
||||
addFunctionInScriptTable(scilabFunctionName, scilabSmallFunctionName, wrapperFunctionName, builderCode5, builderCode6);
|
||||
}
|
||||
|
||||
if (createLoader) {
|
||||
addFunctionInLoader(scilabFunctionName);
|
||||
addFunctionInLoader(scilabFunctionName, scilabSmallFunctionName);
|
||||
}
|
||||
|
||||
if (gatewayXMLFile) {
|
||||
Printf(gatewayXML, "<PRIMITIVE gatewayId=\"%s\" primitiveId=\"%d\" primitiveName=\"%s\"/>\n", gatewayID, primitiveID++, scilabFunctionName);
|
||||
Printf(gatewayXML, "<PRIMITIVE gatewayId=\"%s\" primitiveId=\"%d\" primitiveName=\"%s\"/>\n", gatewayID, primitiveID++, scilabSmallFunctionName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -888,12 +824,14 @@ public:
|
|||
builderFile = NewFile(builderFilename, "w", SWIG_output_files());
|
||||
if (!builderFile) {
|
||||
FileErrorDisplay(builderFilename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
emitBanner(builderFile);
|
||||
|
||||
builderFunctionCount = 0;
|
||||
builderCode = NewString("");
|
||||
builderCode5 = NewString("");
|
||||
builderCode6 = NewString("");
|
||||
Printf(builderCode, "mode(-1);\n");
|
||||
Printf(builderCode, "lines(0);\n"); /* Useful for automatic tests */
|
||||
|
||||
|
|
@ -943,7 +881,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
Printf(builderCode, "table = [");
|
||||
Printf(builderCode5, "table = [ ..\n");
|
||||
Printf(builderCode6, "table = [ ..\n");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
|
|
@ -951,11 +890,13 @@ public:
|
|||
* Add a function wrapper in the function table of generated builder script
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
void addFunctionInScriptTable(const_String_or_char_ptr scilabFunctionName, const_String_or_char_ptr wrapperFunctionName, String *scriptCode) {
|
||||
void addFunctionInScriptTable(const_String_or_char_ptr scilabFunctionName, const_String_or_char_ptr scilabSmallFunctionName, const_String_or_char_ptr wrapperFunctionName, String *scriptCode5, String *scriptCode6) {
|
||||
if (++builderFunctionCount % 10 == 0) {
|
||||
Printf(scriptCode, "];\ntable = [table;");
|
||||
Printf(scriptCode5, "];\ntable = [table; ..\n");
|
||||
Printf(scriptCode6, "];\ntable = [table; ..\n");
|
||||
}
|
||||
Printf(scriptCode, "\"%s\",\"%s\";", scilabFunctionName, wrapperFunctionName);
|
||||
Printf(scriptCode5, "\"%s\",\"%s\"; ..\n", scilabSmallFunctionName, wrapperFunctionName);
|
||||
Printf(scriptCode6, "\"%s\",\"%s\"; ..\n", scilabFunctionName, wrapperFunctionName);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
|
|
@ -963,7 +904,26 @@ public:
|
|||
* ----------------------------------------------------------------------- */
|
||||
|
||||
void saveBuilderFile(String *gatewayName) {
|
||||
Printf(builderCode, "];\n");
|
||||
Printf(builderCode5, "];\n");
|
||||
Printf(builderCode6, "];\n");
|
||||
|
||||
if (Equal(builderCode5, builderCode6)) {
|
||||
Append(builderCode, builderCode6);
|
||||
} else {
|
||||
Printf(builderCode, "ver = getversion('scilab');\n");
|
||||
Printf(builderCode, "if ver(1) < 6 then\n");
|
||||
Printf(builderCode, " // version is less or equal to 5.5.2\n");
|
||||
Printf(builderCode, " \n");
|
||||
Append(builderCode, builderCode5);
|
||||
Printf(builderCode, " \n");
|
||||
Printf(builderCode, "else\n");
|
||||
Printf(builderCode, " // version is 6.0.0 or more\n");
|
||||
Printf(builderCode, " \n");
|
||||
Append(builderCode, builderCode6);
|
||||
Printf(builderCode, " \n");
|
||||
Printf(builderCode, "end\n");
|
||||
}
|
||||
|
||||
Printf(builderCode, "ierr = 0;\n");
|
||||
Printf(builderCode, "if ~isempty(table) then\n");
|
||||
Printf(builderCode, " ierr = execstr(\"ilib_build(''%s'', table, files, libs, [], ldflags, cflags);\", 'errcatch');\n", gatewayName);
|
||||
|
|
@ -976,6 +936,8 @@ public:
|
|||
Printf(builderCode, " error(ierr, err_msg);\n");
|
||||
Printf(builderCode, "end\n");
|
||||
Printv(builderFile, builderCode, NIL);
|
||||
|
||||
Delete(builderCode);
|
||||
Delete(builderFile);
|
||||
}
|
||||
|
||||
|
|
@ -989,7 +951,7 @@ public:
|
|||
gatewayXMLFile = NewFile(gatewayXMLFilename, "w", SWIG_output_files());
|
||||
if (!gatewayXMLFile) {
|
||||
FileErrorDisplay(gatewayXMLFilename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
// Add a slightly modified SWIG banner to the gateway XML ("--modify" is illegal in XML)
|
||||
gatewayXML = NewString("");
|
||||
|
|
@ -1038,7 +1000,7 @@ public:
|
|||
Printf(gatewayHeaderV6, "#ifdef __cplusplus\n");
|
||||
Printf(gatewayHeaderV6, "extern \"C\"\n");
|
||||
Printf(gatewayHeaderV6, "#endif\n");
|
||||
Printf(gatewayHeaderV6, "int %s(wchar_t *pwstFuncName) {\n", gatewayLibraryName);
|
||||
Printf(gatewayHeaderV6, "SWIGEXPORT int %s(wchar_t *pwstFuncName) {\n", gatewayLibraryName);
|
||||
Printf(gatewayHeaderV6, "\n");
|
||||
}
|
||||
|
||||
|
|
@ -1047,13 +1009,13 @@ public:
|
|||
* Add a function in the gateway header
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
void addFunctionInGatewayHeader(const_String_or_char_ptr scilabFunctionName, const_String_or_char_ptr wrapperFunctionName) {
|
||||
void addFunctionInGatewayHeader(const_String_or_char_ptr scilabFunctionName, const_String_or_char_ptr scilabSmallFunctionName, const_String_or_char_ptr wrapperFunctionName) {
|
||||
if (gatewayHeaderV5 == NULL) {
|
||||
gatewayHeaderV5 = NewString("");
|
||||
Printf(gatewayHeaderV5, "static GenericTable Tab[] = {\n");
|
||||
} else
|
||||
Printf(gatewayHeaderV5, ",\n");
|
||||
Printf(gatewayHeaderV5, " {(Myinterfun)sci_gateway, (GT)%s, (char *)\"%s\"}", wrapperFunctionName, scilabFunctionName);
|
||||
Printf(gatewayHeaderV5, " {(Myinterfun)sci_gateway, (GT)%s, (char *)\"%s\"}", wrapperFunctionName, scilabSmallFunctionName);
|
||||
|
||||
Printf(gatewayHeaderV6, "if (wcscmp(pwstFuncName, L\"%s\") == 0) { addCStackFunction((wchar_t *)L\"%s\", &%s, (wchar_t *)MODULE_NAME); }\n", scilabFunctionName, scilabFunctionName, wrapperFunctionName);
|
||||
}
|
||||
|
|
@ -1069,7 +1031,7 @@ public:
|
|||
Printf(gatewayHeaderV5, "#ifdef __cplusplus\n");
|
||||
Printf(gatewayHeaderV5, "extern \"C\" {\n");
|
||||
Printf(gatewayHeaderV5, "#endif\n");
|
||||
Printf(gatewayHeaderV5, "int C2F(%s)() {\n", gatewayLibraryName);
|
||||
Printf(gatewayHeaderV5, "SWIGEXPORT int C2F(%s)() {\n", gatewayLibraryName);
|
||||
Printf(gatewayHeaderV5, " Rhs = Max(0, Rhs);\n");
|
||||
Printf(gatewayHeaderV5, " if (*(Tab[Fin-1].f) != NULL) {\n");
|
||||
Printf(gatewayHeaderV5, " if(pvApiCtx == NULL) {\n");
|
||||
|
|
@ -1106,18 +1068,20 @@ public:
|
|||
loaderFile = NewFile(loaderFilename, "w", SWIG_output_files());
|
||||
if (!loaderFile) {
|
||||
FileErrorDisplay(loaderFilename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
emitBanner(loaderFile);
|
||||
|
||||
loaderScript = NewString("");
|
||||
Printf(loaderScript, "%s_path = get_absolute_file_path('loader.sce');\n", gatewayLibraryName);
|
||||
Printf(loaderScript, "[bOK, ilib] = c_link('%s');\n", gatewayLibraryName);
|
||||
Printf(loaderScript, "if bOK then\n");
|
||||
Printf(loaderScript, " ulink(ilib);\n");
|
||||
Printf(loaderScript, "end\n");
|
||||
Printf(loaderScript, "list_functions = [..\n");
|
||||
loaderFunctionCount = 0;
|
||||
loaderScript = NewString("function loader_function()\n");
|
||||
Printf(loaderScript, " p = get_absolute_file_path('loader.sce');\n", gatewayLibraryName);
|
||||
Printf(loaderScript, " [bOK, ilib] = c_link('%s');\n", gatewayLibraryName);
|
||||
Printf(loaderScript, " if bOK then\n");
|
||||
Printf(loaderScript, " ulink(ilib);\n");
|
||||
Printf(loaderScript, " end\n");
|
||||
loaderScript5 = NewString(" list_functions = [ ..\n");
|
||||
loaderScript6 = NewString(" list_functions = [ ..\n");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
|
|
@ -1125,8 +1089,13 @@ public:
|
|||
* Add a function in the loader script table
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
void addFunctionInLoader(const_String_or_char_ptr scilabFunctionName) {
|
||||
Printf(loaderScript, " '%s'; ..\n", scilabFunctionName);
|
||||
void addFunctionInLoader(const_String_or_char_ptr scilabFunctionName, const_String_or_char_ptr scilabSmallFunctionName) {
|
||||
if (++loaderFunctionCount % 10 == 0) {
|
||||
Printf(loaderScript5, " ];\n list_functions = [list_functions; ..\n");
|
||||
Printf(loaderScript6, " ];\n list_functions = [list_functions; ..\n");
|
||||
}
|
||||
Printf(loaderScript5, " '%s'; ..\n", scilabSmallFunctionName);
|
||||
Printf(loaderScript6, " '%s'; ..\n", scilabFunctionName);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
|
|
@ -1135,18 +1104,66 @@ public:
|
|||
* ----------------------------------------------------------------------- */
|
||||
|
||||
void saveLoaderFile(String *gatewayLibraryName) {
|
||||
Printf(loaderScript, "];\n");
|
||||
Printf(loaderScript, "addinter(fullfile(%s_path, '%s' + getdynlibext()), '%s', list_functions);\n",
|
||||
gatewayLibraryName, gatewayLibraryName, gatewayLibraryName);
|
||||
Printf(loaderScript, "clear %s_path;\n", gatewayLibraryName);
|
||||
Printf(loaderScript, "clear bOK;\n");
|
||||
Printf(loaderScript, "clear ilib;\n");
|
||||
Printf(loaderScript, "clear list_functions;\n");
|
||||
Printf(loaderScript5, " ];\n");
|
||||
Printf(loaderScript6, " ];\n");
|
||||
|
||||
if (Equal(loaderScript5, loaderScript6)) {
|
||||
Append(loaderScript, loaderScript6);
|
||||
} else {
|
||||
Printf(loaderScript, " ver = getversion('scilab');\n");
|
||||
Printf(loaderScript, " if ver(1) < 6 then\n");
|
||||
Printf(loaderScript, " // version is less or equal to 5.5.2\n");
|
||||
Printf(loaderScript, " \n");
|
||||
Append(loaderScript, loaderScript5);
|
||||
Delete(loaderScript5);
|
||||
Printf(loaderScript, " \n");
|
||||
Printf(loaderScript, " else\n");
|
||||
Printf(loaderScript, " // version is 6.0.0 or more\n");
|
||||
Printf(loaderScript, " \n");
|
||||
Append(loaderScript, loaderScript6);
|
||||
Delete(loaderScript6);
|
||||
Printf(loaderScript, " \n");
|
||||
Printf(loaderScript, " end\n");
|
||||
}
|
||||
|
||||
Printf(loaderScript, " addinter(p + '%s' + getdynlibext(), '%s', list_functions);\n", gatewayLibraryName, gatewayLibraryName);
|
||||
Printf(loaderScript, "endfunction\n");
|
||||
Printf(loaderScript, "loader_function();\n");
|
||||
Printf(loaderScript, "clear loader_function;\n");
|
||||
Printv(loaderFile, loaderScript, NIL);
|
||||
|
||||
Delete(loaderScript);
|
||||
Delete(loaderFile);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
* createSmallIdentifierName()
|
||||
* Create a Scilab small identifier to be used by Scilab 5
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
String* createSmallIdentifierName(String* name, int outputLen = SCILAB_IDENTIFIER_NAME_CHAR_MAX) {
|
||||
char* s = Char(name);
|
||||
int nameLen = Len(s);
|
||||
|
||||
// truncate and preserve common suffix
|
||||
if (outputLen > 4 && nameLen > outputLen) {
|
||||
String* smallName = NewStringWithSize(name, outputLen);
|
||||
char* smallNameStr = (char*) Data(smallName);
|
||||
|
||||
if (s[nameLen-4] == '_' && s[nameLen - 3] == 'g' && s[nameLen - 2] == 'e' && s[nameLen - 1] == 't') {
|
||||
// get
|
||||
memcpy(&smallNameStr[outputLen - 4], &s[nameLen - 4], 4);
|
||||
} else if (s[nameLen-4] == '_' && s[nameLen - 3] == 's' && s[nameLen - 2] == 'e' && s[nameLen - 1] == 't') {
|
||||
// set
|
||||
memcpy(&smallNameStr[outputLen - 4], &s[nameLen - 4], 4);
|
||||
}
|
||||
|
||||
return smallName;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
extern "C" Language *swig_scilab(void) {
|
||||
|
|
|
|||
|
|
@ -82,15 +82,10 @@ static TargetLanguageModule modules[] = {
|
|||
{"-tcl", swig_tcl, NULL, Supported},
|
||||
{"-tcl8", swig_tcl, "Tcl 8", Supported},
|
||||
{"-uffi", NULL, "Common Lisp / UFFI", Disabled},
|
||||
{"-xml", swig_xml, "XML", Supported},
|
||||
{"-xml", swig_xml, "XML", Experimental},
|
||||
{NULL, NULL, NULL, Disabled}
|
||||
};
|
||||
|
||||
#ifdef MACSWIG
|
||||
#include <console.h>
|
||||
#include <SIOUX.h>
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// main()
|
||||
//
|
||||
|
|
@ -100,15 +95,15 @@ static TargetLanguageModule modules[] = {
|
|||
void SWIG_merge_envopt(const char *env, int oargc, char *oargv[], int *nargc, char ***nargv) {
|
||||
if (!env) {
|
||||
*nargc = oargc;
|
||||
*nargv = (char **)malloc(sizeof(char *) * (oargc + 1));
|
||||
*nargv = (char **)Malloc(sizeof(char *) * (oargc + 1));
|
||||
memcpy(*nargv, oargv, sizeof(char *) * (oargc + 1));
|
||||
return;
|
||||
}
|
||||
|
||||
int argc = 1;
|
||||
int arge = oargc + 1024;
|
||||
char **argv = (char **) malloc(sizeof(char *) * (arge + 1));
|
||||
char *buffer = (char *) malloc(2048);
|
||||
char **argv = (char **) Malloc(sizeof(char *) * (arge + 1));
|
||||
char *buffer = (char *) Malloc(2048);
|
||||
char *b = buffer;
|
||||
char *be = b + 1023;
|
||||
const char *c = env;
|
||||
|
|
@ -141,11 +136,11 @@ static void insert_option(int *argc, char ***argv, int index, char const *start,
|
|||
size_t option_len = end - start;
|
||||
|
||||
// Preserve the NULL pointer at argv[argc]
|
||||
new_argv = (char **)realloc(new_argv, (new_argc + 2) * sizeof(char *));
|
||||
new_argv = (char **)Realloc(new_argv, (new_argc + 2) * sizeof(char *));
|
||||
memmove(&new_argv[index + 1], &new_argv[index], sizeof(char *) * (new_argc + 1 - index));
|
||||
new_argc++;
|
||||
|
||||
new_argv[index] = (char *)malloc(option_len + 1);
|
||||
new_argv[index] = (char *)Malloc(option_len + 1);
|
||||
memcpy(new_argv[index], start, option_len);
|
||||
new_argv[index][option_len] = '\0';
|
||||
|
||||
|
|
@ -224,11 +219,6 @@ int main(int margc, char **margv) {
|
|||
SWIG_merge_envopt(getenv("SWIG_FEATURES"), margc, margv, &argc, &argv);
|
||||
merge_options_files(&argc, &argv);
|
||||
|
||||
#ifdef MACSWIG
|
||||
SIOUXSettings.asktosaveonclose = false;
|
||||
argc = ccommand(&argv);
|
||||
#endif
|
||||
|
||||
Swig_init_args(argc, argv);
|
||||
|
||||
/* Get options */
|
||||
|
|
@ -249,7 +239,7 @@ int main(int margc, char **margv) {
|
|||
Printf(stderr, "Target language option %s (%s) is no longer supported.\n", language_module->name, language_module->help);
|
||||
else
|
||||
Printf(stderr, "Target language option %s is no longer supported.\n", language_module->name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
} else if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0)) {
|
||||
if (strcmp(argv[i], "--help") == 0)
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
* Main header file for SWIG modules.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef SWIG_SWIGMOD_H_
|
||||
#define SWIG_SWIGMOD_H_
|
||||
#ifndef SWIG_SWIGMOD_H
|
||||
#define SWIG_SWIGMOD_H
|
||||
|
||||
#include "swig.h"
|
||||
#include "preprocessor.h"
|
||||
|
|
@ -196,7 +196,7 @@ public:
|
|||
virtual int classDirector(Node *n);
|
||||
virtual int classDirectorInit(Node *n);
|
||||
virtual int classDirectorEnd(Node *n);
|
||||
virtual int unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_director, int &virtual_destructor, int protectedbase = 0);
|
||||
virtual int unrollVirtualMethods(Node *n, Node *parent, List *vm, int &virtual_destructor, int protectedbase = 0);
|
||||
virtual int classDirectorConstructor(Node *n);
|
||||
virtual int classDirectorDefaultConstructor(Node *n);
|
||||
virtual int classDirectorMethod(Node *n, Node *parent, String *super);
|
||||
|
|
@ -346,6 +346,8 @@ protected:
|
|||
class DoxygenTranslator *doxygenTranslator;
|
||||
|
||||
private:
|
||||
void unrollOneVirtualMethod(String *classname, Node *n, Node *parent, List *vm, int &virtual_destructor, int protectedbase);
|
||||
|
||||
Hash *symtabs; /* symbol tables */
|
||||
int overloading;
|
||||
int multiinput;
|
||||
|
|
@ -428,16 +430,14 @@ extern "C" {
|
|||
void Swig_print_with_location(DOH *object, int count = -1);
|
||||
}
|
||||
|
||||
void Swig_default_allocators(Node *n);
|
||||
void Swig_process_types(Node *n);
|
||||
|
||||
/* Contracts */
|
||||
void Swig_contracts(Node *n);
|
||||
void Swig_contract_mode_set(int flag);
|
||||
int Swig_contract_mode_get();
|
||||
|
||||
/* Browser */
|
||||
void Swig_browser(Node *n, int);
|
||||
void Swig_default_allocators(Node *n);
|
||||
void Swig_process_types(Node *n);
|
||||
|
||||
/* Nested classes */
|
||||
void Swig_nested_process_classes(Node *n);
|
||||
void Swig_nested_name_unnamed_c_structs(Node *n);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public:
|
|||
} else if (strcmp(argv[i], "-nocppcast") == 0) {
|
||||
Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]);
|
||||
Swig_mark_arg(i);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ public:
|
|||
f_begin = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime = NewString("");
|
||||
f_init = NewString("");
|
||||
|
|
@ -182,7 +182,7 @@ public:
|
|||
|
||||
if ((f_shadow = NewFile(filen, "w", SWIG_output_files())) == 0) {
|
||||
FileErrorDisplay(filen);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
f_shadow_stubs = NewString("");
|
||||
|
||||
|
|
@ -825,6 +825,7 @@ public:
|
|||
|
||||
//Printf(f_init,"/* Register base : %s */\n", bmangle);
|
||||
//Printf(f_init,"swig_%s_bases[%d] = (swig_class *) SWIG_TypeQuery(\"%s *\")->clientdata;\n", mangled_classname, index, SwigType_namestr(bname));
|
||||
(void)index;
|
||||
b = Next(b);
|
||||
index++;
|
||||
Putc(',', base_class);
|
||||
|
|
@ -889,7 +890,7 @@ public:
|
|||
// Add methods
|
||||
if (have_methods) {
|
||||
Printv(ptrclass, imethods, NIL);
|
||||
};
|
||||
}
|
||||
|
||||
// Close out the pointer class
|
||||
Printv(ptrclass, "}\n\n", NIL);
|
||||
|
|
@ -947,7 +948,7 @@ public:
|
|||
if (!itcl) {
|
||||
Printv(cmd_tab, tab4, "{ SWIG_prefix \"", class_name, "\", (swig_wrapper_func) SWIG_ObjectConstructor, (ClientData)&_wrap_class_", mangled_classname,
|
||||
"},\n", NIL);
|
||||
};
|
||||
}
|
||||
|
||||
Delete(t);
|
||||
Delete(mangled_classname);
|
||||
|
|
@ -1023,7 +1024,7 @@ public:
|
|||
Printv(imethods, "{ ", ns_name, "::", class_name, "_", realname, " $swigobj", NIL);
|
||||
} else {
|
||||
Printv(imethods, "{ ", class_name, "_", realname, " $swigobj", NIL);
|
||||
};
|
||||
}
|
||||
|
||||
pnum = 0;
|
||||
for (p = l; p; p = nextSibling(p)) {
|
||||
|
|
|
|||
|
|
@ -969,7 +969,7 @@ class TypePass:private Dispatcher {
|
|||
if (Getattr(c, "sym:overloaded") != checkoverloaded) {
|
||||
Printf(stdout, "sym:overloaded error c:%p checkoverloaded:%p\n", c, checkoverloaded);
|
||||
Swig_print_node(c);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
String *decl = Strcmp(nodeType(c), "using") == 0 ? NewString("------") : Getattr(c, "decl");
|
||||
|
|
@ -977,7 +977,7 @@ class TypePass:private Dispatcher {
|
|||
if (!Getattr(c, "sym:overloaded")) {
|
||||
Printf(stdout, "sym:overloaded error.....%p\n", c);
|
||||
Swig_print_node(c);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
c = Getattr(c, "sym:nextSibling");
|
||||
}
|
||||
|
|
@ -1039,6 +1039,21 @@ class TypePass:private Dispatcher {
|
|||
Node *unodes = 0, *last_unodes = 0;
|
||||
int ccount = 0;
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
|
||||
// The overloaded functions in scope may not yet have had their parameters normalized yet (in cDeclaration).
|
||||
// Happens if the functions were declared after the using declaration. So use a normalized copy.
|
||||
List *n_decl_list = NewList();
|
||||
Node *over = Getattr(n, "sym:overloaded");
|
||||
while (over) {
|
||||
String *odecl = Copy(Getattr(over, "decl"));
|
||||
if (odecl) {
|
||||
normalize_type(odecl);
|
||||
Append(n_decl_list, odecl);
|
||||
Delete(odecl);
|
||||
}
|
||||
over = Getattr(over, "sym:nextSibling");
|
||||
}
|
||||
|
||||
while (c) {
|
||||
if (Strcmp(nodeType(c), "cdecl") == 0) {
|
||||
if (!(Swig_storage_isstatic(c)
|
||||
|
|
@ -1047,37 +1062,40 @@ class TypePass:private Dispatcher {
|
|||
|| (Getattr(c, "feature:extend") && !Getattr(c, "code"))
|
||||
|| GetFlag(c, "feature:ignore"))) {
|
||||
|
||||
/* Don't generate a method if the method is overridden in this class,
|
||||
* for example don't generate another m(bool) should there be a Base::m(bool) :
|
||||
* struct Derived : Base {
|
||||
* void m(bool);
|
||||
* using Base::m;
|
||||
* };
|
||||
*/
|
||||
String *csymname = Getattr(c, "sym:name");
|
||||
if (!csymname || (Strcmp(csymname, symname) == 0)) {
|
||||
{
|
||||
String *decl = Getattr(c, "decl");
|
||||
Node *over = Getattr(n, "sym:overloaded");
|
||||
int match = 0;
|
||||
while (over) {
|
||||
String *odecl = Getattr(over, "decl");
|
||||
if (Cmp(decl, odecl) == 0) {
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
over = Getattr(over, "sym:nextSibling");
|
||||
}
|
||||
if (match) {
|
||||
c = Getattr(c, "csym:nextSibling");
|
||||
continue;
|
||||
String *decl = Getattr(c, "decl");
|
||||
int match = 0;
|
||||
|
||||
for (Iterator it = First(n_decl_list); it.item; it = Next(it)) {
|
||||
String *odecl = it.item;
|
||||
if (Cmp(decl, odecl) == 0) {
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
/* Don't generate a method if the method is overridden in this class,
|
||||
* for example don't generate another m(bool) should there be a Base::m(bool) :
|
||||
* struct Derived : Base {
|
||||
* void m(bool);
|
||||
* using Base::m;
|
||||
* };
|
||||
*/
|
||||
c = Getattr(c, "csym:nextSibling");
|
||||
continue;
|
||||
}
|
||||
|
||||
Node *nn = copyNode(c);
|
||||
Setfile(nn, Getfile(n));
|
||||
Setline(nn, Getline(n));
|
||||
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);
|
||||
Symtab *st = Getattr(n, "sym:symtab");
|
||||
assert(st);
|
||||
Setattr(nn, "sym:symtab", st);
|
||||
|
||||
if (!GetFlag(nn, "feature:ignore")) {
|
||||
ParmList *parms = CopyParmList(Getattr(c, "parms"));
|
||||
|
|
@ -1117,6 +1135,9 @@ class TypePass:private Dispatcher {
|
|||
} else {
|
||||
Delete(nn);
|
||||
}
|
||||
} else {
|
||||
Swig_warning(WARN_LANG_USING_NAME_DIFFERENT, Getfile(n), Getline(n), "Using declaration %s, with name '%s', is not actually using\n", SwigType_namestr(Getattr(n, "uname")), symname);
|
||||
Swig_warning(WARN_LANG_USING_NAME_DIFFERENT, Getfile(c), Getline(c), "the method from %s, with name '%s', as the names are different.\n", Swig_name_decl(c), csymname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1138,14 +1159,30 @@ class TypePass:private Dispatcher {
|
|||
* which is hacked. */
|
||||
if (Getattr(n, "sym:overloaded")) {
|
||||
int cnt = 0;
|
||||
Node *ps = Getattr(n, "sym:previousSibling");
|
||||
Node *ns = Getattr(n, "sym:nextSibling");
|
||||
Node *fc = firstChild(n);
|
||||
Node *firstoverloaded = Getattr(n, "sym:overloaded");
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
Node *debugnode = n;
|
||||
show_overloaded(n);
|
||||
show_overloaded(firstoverloaded);
|
||||
#endif
|
||||
if (!firstChild(n)) {
|
||||
|
||||
if (firstoverloaded == n) {
|
||||
// This 'using' node we are cutting out was the first node in the overloaded list.
|
||||
// Change the first node in the list
|
||||
Delattr(firstoverloaded, "sym:overloaded");
|
||||
firstoverloaded = fc ? fc : ns;
|
||||
|
||||
// Correct all the sibling overloaded methods (before adding in new methods)
|
||||
Node *nnn = ns;
|
||||
while (nnn) {
|
||||
Setattr(nnn, "sym:overloaded", firstoverloaded);
|
||||
nnn = Getattr(nnn, "sym:nextSibling");
|
||||
}
|
||||
}
|
||||
|
||||
if (!fc) {
|
||||
// Remove from overloaded list ('using' node does not actually end up adding in any methods)
|
||||
Node *ps = Getattr(n, "sym:previousSibling");
|
||||
Node *ns = Getattr(n, "sym:nextSibling");
|
||||
if (ps) {
|
||||
Setattr(ps, "sym:nextSibling", ns);
|
||||
}
|
||||
|
|
@ -1153,24 +1190,8 @@ class TypePass:private Dispatcher {
|
|||
Setattr(ns, "sym:previousSibling", ps);
|
||||
}
|
||||
} else {
|
||||
// The 'using' node results in methods being added in - slot in the these methods here
|
||||
Node *ps = Getattr(n, "sym:previousSibling");
|
||||
Node *ns = Getattr(n, "sym:nextSibling");
|
||||
Node *fc = firstChild(n);
|
||||
// The 'using' node results in methods being added in - slot in these methods here
|
||||
Node *pp = fc;
|
||||
|
||||
Node *firstoverloaded = Getattr(n, "sym:overloaded");
|
||||
if (firstoverloaded == n) {
|
||||
// This 'using' node we are cutting out was the first node in the overloaded list.
|
||||
// Change the first node in the list to its first sibling
|
||||
Delattr(firstoverloaded, "sym:overloaded");
|
||||
Node *nnn = Getattr(firstoverloaded, "sym:nextSibling");
|
||||
firstoverloaded = fc;
|
||||
while (nnn) {
|
||||
Setattr(nnn, "sym:overloaded", firstoverloaded);
|
||||
nnn = Getattr(nnn, "sym:nextSibling");
|
||||
}
|
||||
}
|
||||
while (pp) {
|
||||
Node *ppn = Getattr(pp, "sym:nextSibling");
|
||||
Setattr(pp, "sym:overloaded", firstoverloaded);
|
||||
|
|
@ -1188,19 +1209,17 @@ class TypePass:private Dispatcher {
|
|||
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");
|
||||
clean_overloaded(firstoverloaded);
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
show_overloaded(debugnode);
|
||||
show_overloaded(firstoverloaded);
|
||||
#endif
|
||||
clean_overloaded(n); // Needed?
|
||||
}
|
||||
Delete(n_decl_list);
|
||||
}
|
||||
}
|
||||
} else if ((Strcmp(ntype, "class") == 0) || ((Strcmp(ntype, "classforward") == 0))) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* Various utility functions.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include <swigmod.h>
|
||||
#include "swigmod.h"
|
||||
|
||||
int is_public(Node *n) {
|
||||
String *access = Getattr(n, "access");
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public:
|
|||
out = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!out) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ public:
|
|||
out = NewFile(outfile, "w", SWIG_output_files());
|
||||
if (!out) {
|
||||
FileErrorDisplay(outfile);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
Printf(out, "<?xml version=\"1.0\" ?> \n");
|
||||
|
|
@ -310,7 +310,7 @@ void Swig_print_xml(DOH *obj, String *filename) {
|
|||
out = NewFile(filename, "w", SWIG_output_files());
|
||||
if (!out) {
|
||||
FileErrorDisplay(filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -741,14 +741,35 @@ static String *get_options(String *str) {
|
|||
opt = NewString("(");
|
||||
while (((c = Getc(str)) != EOF)) {
|
||||
Putc(c, opt);
|
||||
if (c == ')') {
|
||||
level--;
|
||||
if (!level)
|
||||
return opt;
|
||||
switch (c) {
|
||||
case ')':
|
||||
level--;
|
||||
if (!level)
|
||||
return opt;
|
||||
break;
|
||||
case '(':
|
||||
level++;
|
||||
break;
|
||||
case '"':
|
||||
/* Skip over quoted strings */
|
||||
while (1) {
|
||||
c = Getc(str);
|
||||
if (c == EOF)
|
||||
goto bad;
|
||||
Putc(c, opt);
|
||||
if (c == '"')
|
||||
break;
|
||||
if (c == '\\') {
|
||||
c = Getc(str);
|
||||
if (c == EOF)
|
||||
goto bad;
|
||||
Putc(c, opt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (c == '(')
|
||||
level++;
|
||||
}
|
||||
bad:
|
||||
Delete(opt);
|
||||
return 0;
|
||||
} else {
|
||||
|
|
@ -1335,14 +1356,14 @@ static void add_chunk(DOH *ns, DOH *chunk, int allow) {
|
|||
push/pop_imported(): helper functions for defining and undefining
|
||||
SWIGIMPORTED (when %importing a file).
|
||||
*/
|
||||
static void push_imported() {
|
||||
static void push_imported(void) {
|
||||
if (imported_depth == 0) {
|
||||
Preprocessor_define("SWIGIMPORTED 1", 0);
|
||||
}
|
||||
++imported_depth;
|
||||
}
|
||||
|
||||
static void pop_imported() {
|
||||
static void pop_imported(void) {
|
||||
--imported_depth;
|
||||
if (imported_depth == 0) {
|
||||
Preprocessor_undef("SWIGIMPORTED");
|
||||
|
|
@ -1686,7 +1707,7 @@ String *Preprocessor_parse(String *s) {
|
|||
Seek(value, 0, SEEK_SET);
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate expression '%s'\n", value);
|
||||
if (msg)
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Error: '%s'\n", msg);
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "%s\n", msg);
|
||||
allow = 0;
|
||||
} else {
|
||||
if (val == 0)
|
||||
|
|
@ -1720,7 +1741,7 @@ String *Preprocessor_parse(String *s) {
|
|||
Seek(value, 0, SEEK_SET);
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate expression '%s'\n", value);
|
||||
if (msg)
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Error: '%s'\n", msg);
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "%s\n", msg);
|
||||
allow = 0;
|
||||
} else {
|
||||
if (val)
|
||||
|
|
@ -2055,8 +2076,7 @@ String *Preprocessor_parse(String *s) {
|
|||
break;
|
||||
default:
|
||||
Printf(stderr, "cpp: Invalid parser state %d\n", state);
|
||||
abort();
|
||||
break;
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
while (level > 0) {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@
|
|||
*
|
||||
* Integer arithmetic expression evaluator used to handle expressions
|
||||
* encountered during preprocessing.
|
||||
*
|
||||
* Note that this is used for expressions in `#if` and the like, but not
|
||||
* for expressions in `#define` which SWIG wraps as constants - for those
|
||||
* we inject a `%constant` directive which is handled by the parser in
|
||||
* `Source/CParse/parser.y`.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "swig.h"
|
||||
|
|
@ -18,8 +23,19 @@
|
|||
static Scanner *scan = 0;
|
||||
|
||||
typedef struct {
|
||||
/* One of the EXPR_xxx values defined below. */
|
||||
int op;
|
||||
/* op == EXPR_OP: value is the token specifying which operator.
|
||||
*
|
||||
* op == EXPR_VALUE && svalue == NULL: Numeric expression value.
|
||||
*
|
||||
* Otherwise unused.
|
||||
*/
|
||||
long value;
|
||||
/* op == EXPR_VALUE: If non-NULL, string expression value; if NULL see value.
|
||||
*
|
||||
* Otherwise unused.
|
||||
*/
|
||||
String *svalue;
|
||||
} exprval;
|
||||
|
||||
|
|
@ -27,7 +43,12 @@ typedef struct {
|
|||
#define EXPR_VALUE 2
|
||||
#define EXPR_OP 3
|
||||
#define EXPR_GROUP 4
|
||||
#define EXPR_UMINUS 100
|
||||
|
||||
/* Special token values used here to distinguish from SWIG_TOKEN_MINUS
|
||||
* and SWIG_TOKEN_PLUS (which we use here for a two argument versions).
|
||||
*/
|
||||
#define OP_UMINUS 100
|
||||
#define OP_UPLUS 101
|
||||
|
||||
static exprval stack[256]; /* Parsing stack */
|
||||
static int sp = 0; /* Stack pointer */
|
||||
|
|
@ -36,9 +57,11 @@ static int expr_init = 0; /* Initialization flag */
|
|||
static const char *errmsg = 0; /* Parsing error */
|
||||
|
||||
/* Initialize the precedence table for various operators. Low values have higher precedence */
|
||||
static void init_precedence() {
|
||||
static void init_precedence(void) {
|
||||
prec[SWIG_TOKEN_NOT] = 10;
|
||||
prec[EXPR_UMINUS] = 10;
|
||||
prec[SWIG_TOKEN_LNOT] = 10;
|
||||
prec[OP_UMINUS] = 10;
|
||||
prec[OP_UPLUS] = 10;
|
||||
prec[SWIG_TOKEN_STAR] = 20;
|
||||
prec[SWIG_TOKEN_SLASH] = 20;
|
||||
prec[SWIG_TOKEN_PERCENT] = 20;
|
||||
|
|
@ -46,16 +69,15 @@ static void init_precedence() {
|
|||
prec[SWIG_TOKEN_MINUS] = 30;
|
||||
prec[SWIG_TOKEN_LSHIFT] = 40;
|
||||
prec[SWIG_TOKEN_RSHIFT] = 40;
|
||||
prec[SWIG_TOKEN_AND] = 50;
|
||||
prec[SWIG_TOKEN_XOR] = 60;
|
||||
prec[SWIG_TOKEN_OR] = 70;
|
||||
prec[SWIG_TOKEN_EQUALTO] = 80;
|
||||
prec[SWIG_TOKEN_NOTEQUAL] = 80;
|
||||
prec[SWIG_TOKEN_LESSTHAN] = 80;
|
||||
prec[SWIG_TOKEN_GREATERTHAN] = 80;
|
||||
prec[SWIG_TOKEN_LTEQUAL] = 80;
|
||||
prec[SWIG_TOKEN_GTEQUAL] = 80;
|
||||
prec[SWIG_TOKEN_LNOT] = 90;
|
||||
prec[SWIG_TOKEN_LESSTHAN] = 50;
|
||||
prec[SWIG_TOKEN_GREATERTHAN] = 50;
|
||||
prec[SWIG_TOKEN_LTEQUAL] = 50;
|
||||
prec[SWIG_TOKEN_GTEQUAL] = 50;
|
||||
prec[SWIG_TOKEN_EQUALTO] = 60;
|
||||
prec[SWIG_TOKEN_NOTEQUAL] = 60;
|
||||
prec[SWIG_TOKEN_AND] = 70;
|
||||
prec[SWIG_TOKEN_XOR] = 80;
|
||||
prec[SWIG_TOKEN_OR] = 90;
|
||||
prec[SWIG_TOKEN_LAND] = 100;
|
||||
prec[SWIG_TOKEN_LOR] = 110;
|
||||
expr_init = 1;
|
||||
|
|
@ -63,11 +85,12 @@ static void init_precedence() {
|
|||
|
||||
#define UNARY_OP(token) (((token) == SWIG_TOKEN_NOT) || \
|
||||
((token) == SWIG_TOKEN_LNOT) || \
|
||||
((token) == EXPR_UMINUS))
|
||||
((token) == OP_UMINUS) || \
|
||||
((token) == OP_UPLUS))
|
||||
|
||||
/* Reduce a single operator on the stack */
|
||||
/* return 0 on failure, 1 on success */
|
||||
static int reduce_op() {
|
||||
static int reduce_op(void) {
|
||||
long op_token = stack[sp - 1].value;
|
||||
assert(sp > 0);
|
||||
assert(stack[sp - 1].op == EXPR_OP);
|
||||
|
|
@ -183,10 +206,14 @@ static int reduce_op() {
|
|||
stack[sp - 1].value = !stack[sp].value;
|
||||
sp--;
|
||||
break;
|
||||
case EXPR_UMINUS:
|
||||
case OP_UMINUS:
|
||||
stack[sp - 1].value = -stack[sp].value;
|
||||
sp--;
|
||||
break;
|
||||
case OP_UPLUS:
|
||||
stack[sp - 1].value = stack[sp].value;
|
||||
sp--;
|
||||
break;
|
||||
case SWIG_TOKEN_SLASH:
|
||||
if (stack[sp].value != 0) {
|
||||
stack[sp - 2].value = stack[sp - 2].value / stack[sp].value;
|
||||
|
|
@ -278,13 +305,15 @@ int Preprocessor_expr(DOH *s, int *error) {
|
|||
|
||||
/* Put initial state onto the stack */
|
||||
stack[sp].op = EXPR_TOP;
|
||||
stack[sp].value = 0;
|
||||
|
||||
while (1) {
|
||||
/* Look at the top of the stack */
|
||||
switch (stack[sp].op) {
|
||||
case EXPR_TOP:
|
||||
/* An expression. Can be a number or another expression enclosed in parens */
|
||||
/* EXPR_TOP is a place-holder which can only appear on the top of the
|
||||
* stack. We can reduce it to any expression - a number, a string, an
|
||||
* unary operator, or another expression enclosed in parentheses.
|
||||
*/
|
||||
token = expr_token(scan);
|
||||
if (!token) {
|
||||
errmsg = "Expected an expression";
|
||||
|
|
@ -294,28 +323,35 @@ int Preprocessor_expr(DOH *s, int *error) {
|
|||
if ((token == SWIG_TOKEN_INT) || (token == SWIG_TOKEN_UINT) || (token == SWIG_TOKEN_LONG) || (token == SWIG_TOKEN_ULONG)) {
|
||||
/* A number. Reduce EXPR_TOP to an EXPR_VALUE */
|
||||
char *c = Char(Scanner_text(scan));
|
||||
stack[sp].value = (long) strtol(c, 0, 0);
|
||||
if (c[0] == '0' && (c[1] == 'b' || c[1] == 'B')) {
|
||||
/* strtol() doesn't handle binary constants */
|
||||
stack[sp].value = (long) strtol(c + 2, 0, 2);
|
||||
} else {
|
||||
stack[sp].value = (long) strtol(c, 0, 0);
|
||||
}
|
||||
stack[sp].svalue = 0;
|
||||
/* stack[sp].value = (long) atol(Char(Scanner_text(scan))); */
|
||||
stack[sp].op = EXPR_VALUE;
|
||||
} else if (token == SWIG_TOKEN_PLUS) {
|
||||
} else if ((token == SWIG_TOKEN_MINUS) || (token == SWIG_TOKEN_LNOT) || (token == SWIG_TOKEN_NOT)) {
|
||||
} else if ((token == SWIG_TOKEN_MINUS) || (token == SWIG_TOKEN_PLUS) || (token == SWIG_TOKEN_LNOT) || (token == SWIG_TOKEN_NOT)) {
|
||||
if (token == SWIG_TOKEN_MINUS)
|
||||
token = EXPR_UMINUS;
|
||||
token = OP_UMINUS;
|
||||
else if (token == SWIG_TOKEN_PLUS)
|
||||
token = OP_UPLUS;
|
||||
stack[sp].value = token;
|
||||
stack[sp++].op = EXPR_OP;
|
||||
stack[sp].op = EXPR_OP;
|
||||
sp++;
|
||||
stack[sp].op = EXPR_TOP;
|
||||
stack[sp].svalue = 0;
|
||||
} else if (token == SWIG_TOKEN_LPAREN) {
|
||||
stack[sp++].op = EXPR_GROUP;
|
||||
stack[sp].op = EXPR_GROUP;
|
||||
sp++;
|
||||
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) {
|
||||
stack[sp].svalue = NewString(Scanner_text(scan));
|
||||
stack[sp].op = EXPR_VALUE;
|
||||
} else if (token == SWIG_TOKEN_ID) {
|
||||
/* Defined macros have been expanded already so this is an unknown
|
||||
* macro, which gets treated as zero.
|
||||
*/
|
||||
stack[sp].value = 0;
|
||||
stack[sp].svalue = 0;
|
||||
stack[sp].op = EXPR_VALUE;
|
||||
|
|
@ -327,7 +363,9 @@ int Preprocessor_expr(DOH *s, int *error) {
|
|||
goto syntax_error;
|
||||
break;
|
||||
case EXPR_VALUE:
|
||||
/* A value is on the stack. We may reduce or evaluate depending on what the next token is */
|
||||
/* A value is on top of the stack. We may reduce or evaluate depending
|
||||
* on what the next token is.
|
||||
*/
|
||||
token = expr_token(scan);
|
||||
if (!token) {
|
||||
/* End of input. Might have to reduce if an operator is on stack */
|
||||
|
|
@ -371,7 +409,6 @@ int Preprocessor_expr(DOH *s, int *error) {
|
|||
stack[sp].value = token;
|
||||
sp++;
|
||||
stack[sp].op = EXPR_TOP;
|
||||
stack[sp].value = 0;
|
||||
} else {
|
||||
if (stack[sp - 1].op != EXPR_OP)
|
||||
goto syntax_error_expected_operator;
|
||||
|
|
@ -390,7 +427,6 @@ int Preprocessor_expr(DOH *s, int *error) {
|
|||
stack[sp].value = token;
|
||||
sp++;
|
||||
stack[sp].op = EXPR_TOP;
|
||||
stack[sp].value = 0;
|
||||
}
|
||||
break;
|
||||
case SWIG_TOKEN_RPAREN:
|
||||
|
|
@ -406,8 +442,11 @@ int Preprocessor_expr(DOH *s, int *error) {
|
|||
goto extra_rparen;
|
||||
stack[sp - 1].op = EXPR_VALUE;
|
||||
stack[sp - 1].value = stack[sp].value;
|
||||
stack[sp - 1].svalue = stack[sp].svalue;
|
||||
sp--;
|
||||
break;
|
||||
case SWIG_TOKEN_LTEQUALGT:
|
||||
goto spaceship_not_allowed;
|
||||
default:
|
||||
goto syntax_error_expected_operator;
|
||||
break;
|
||||
|
|
@ -416,7 +455,7 @@ int Preprocessor_expr(DOH *s, int *error) {
|
|||
|
||||
default:
|
||||
fprintf(stderr, "Internal error in expression evaluator.\n");
|
||||
abort();
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -439,6 +478,11 @@ extra_rparen:
|
|||
errmsg = "Extra \')\'";
|
||||
*error = 1;
|
||||
return 0;
|
||||
|
||||
spaceship_not_allowed:
|
||||
errmsg = "Spaceship operator (<=>) not allowed in preprocessor expression";
|
||||
*error = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -447,6 +491,6 @@ extra_rparen:
|
|||
* Return error message set by the evaluator (if any)
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const char *Preprocessor_expr_error() {
|
||||
const char *Preprocessor_expr_error(void) {
|
||||
return errmsg;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
* SWIG preprocessor module.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef SWIG_PREPROCESSOR_H_
|
||||
#define SWIG_PREPROCESSOR_H_
|
||||
#ifndef SWIG_PREPROCESSOR_H
|
||||
#define SWIG_PREPROCESSOR_H
|
||||
|
||||
#include "swigwarn.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
#include "swig.h"
|
||||
#include "cparse.h"
|
||||
|
||||
extern int UseWrapperSuffix; // from main.cxx
|
||||
|
||||
static const char *cresult_variable_name = "result";
|
||||
|
||||
static Parm *nonvoid_parms(Parm *p) {
|
||||
|
|
@ -427,10 +429,14 @@ String *Swig_cfunction_call(const_String_or_char_ptr name, ParmList *parms) {
|
|||
String *rcaststr = SwigType_rcaststr(rpt, pname);
|
||||
|
||||
if (comma) {
|
||||
Printv(func, ",", rcaststr, NIL);
|
||||
} else {
|
||||
Append(func, rcaststr);
|
||||
Append(func, ",");
|
||||
}
|
||||
|
||||
if (cparse_cplusplus && SwigType_type(rpt) == T_USER)
|
||||
Printv(func, "SWIG_STD_MOVE(", rcaststr, ")", NIL);
|
||||
else
|
||||
Printv(func, rcaststr, NIL);
|
||||
|
||||
Delete(rpt);
|
||||
Delete(pname);
|
||||
Delete(rcaststr);
|
||||
|
|
@ -1079,13 +1085,13 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
|
|||
in C.
|
||||
|
||||
But when not using the suffix used for overloaded functions, we still need to ensure that the
|
||||
wrapper name doesn't conflict with any wrapper functions, so make it sufficiently unique by
|
||||
appending a suffix similar to the one used for overloaded functions to it.
|
||||
wrapper name doesn't conflict with any wrapper functions for some languages, so optionally make
|
||||
it sufficiently unique by appending a suffix similar to the one used for overloaded functions to it.
|
||||
*/
|
||||
if (code) {
|
||||
if (Getattr(n, "sym:overloaded")) {
|
||||
Append(mangled, Getattr(defaultargs ? defaultargs : n, "sym:overname"));
|
||||
} else {
|
||||
} else if (UseWrapperSuffix) {
|
||||
Append(mangled, "__SWIG");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,14 +209,14 @@ void Swig_warnfilter(const_String_or_char_ptr wlist, int add) {
|
|||
Insert(filter, 0, "-");
|
||||
}
|
||||
} else {
|
||||
char *temp = (char *)malloc(sizeof(char)*strlen(c) + 2);
|
||||
char *temp = (char *)Malloc(sizeof(char)*strlen(c) + 2);
|
||||
if (isdigit((int) *c)) {
|
||||
sprintf(temp, "-%s", c);
|
||||
} else {
|
||||
strcpy(temp, c);
|
||||
}
|
||||
Replace(filter, temp, "", DOH_REPLACE_FIRST);
|
||||
free(temp);
|
||||
Free(temp);
|
||||
}
|
||||
}
|
||||
c = strtok(NULL, ", ");
|
||||
|
|
|
|||
|
|
@ -32,16 +32,12 @@ static int *marked;
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_init_args(int argc, char **argv) {
|
||||
int i;
|
||||
assert(argc > 0);
|
||||
assert(argv);
|
||||
|
||||
numargs = argc;
|
||||
args = argv;
|
||||
marked = (int *) malloc(numargs * sizeof(int));
|
||||
for (i = 0; i < argc; i++) {
|
||||
marked[i] = 0;
|
||||
}
|
||||
marked = (int *) Calloc(numargs, sizeof(int));
|
||||
marked[0] = 1;
|
||||
}
|
||||
|
||||
|
|
@ -87,11 +83,11 @@ void Swig_check_options(int check_input) {
|
|||
}
|
||||
if (error) {
|
||||
Printf(stderr, "Use 'swig -help' for available options.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
if (check_input && marked[numargs - 1]) {
|
||||
Printf(stderr, "Must specify an input file. Use -help for available options.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -104,5 +100,5 @@ void Swig_check_options(int check_input) {
|
|||
void Swig_arg_error(void) {
|
||||
Printf(stderr, "SWIG : Unable to parse command line options.\n");
|
||||
Printf(stderr, "Use 'swig -help' for available options.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,11 +110,7 @@ static List *Swig_search_path_any(int syspath) {
|
|||
assert(slist);
|
||||
filename = NewStringEmpty();
|
||||
assert(filename);
|
||||
#ifdef MACSWIG
|
||||
Printf(filename, "%s", SWIG_FILE_DELIMITER);
|
||||
#else
|
||||
Printf(filename, ".%s", SWIG_FILE_DELIMITER);
|
||||
#endif
|
||||
Append(slist, filename);
|
||||
Delete(filename);
|
||||
|
||||
|
|
@ -145,7 +141,7 @@ static List *Swig_search_path_any(int syspath) {
|
|||
return slist;
|
||||
}
|
||||
|
||||
List *Swig_search_path() {
|
||||
List *Swig_search_path(void) {
|
||||
return Swig_search_path_any(0);
|
||||
}
|
||||
|
||||
|
|
@ -376,6 +372,6 @@ String *Swig_file_dirname(const_String_or_char_ptr filename) {
|
|||
/*
|
||||
* Swig_file_debug()
|
||||
*/
|
||||
void Swig_file_debug_set() {
|
||||
void Swig_file_debug_set(void) {
|
||||
file_debug = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ static char *fake_version = 0;
|
|||
char *Swig_copy_string(const char *s) {
|
||||
char *c = 0;
|
||||
if (s) {
|
||||
c = (char *) malloc(strlen(s) + 1);
|
||||
c = (char *) Malloc(strlen(s) + 1);
|
||||
strcpy(c, s);
|
||||
}
|
||||
return c;
|
||||
|
|
@ -218,7 +218,7 @@ void Swig_filename_correct(String *filename) {
|
|||
if (fname[0] == '/' && fname[1] == '/')
|
||||
network_path = 1;
|
||||
}
|
||||
#if defined(_WIN32) || defined(MACSWIG)
|
||||
#if defined(_WIN32)
|
||||
/* accept Unix path separator on non-Unix systems */
|
||||
Replaceall(filename, "/", SWIG_FILE_DELIMITER);
|
||||
#endif
|
||||
|
|
@ -1157,47 +1157,15 @@ int Swig_scopename_check(const String *s) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_command()
|
||||
*
|
||||
* Executes a external command via popen with the string as a command
|
||||
* line parameter. For example:
|
||||
*
|
||||
* Printf(stderr,"%(command:sed 's/[a-z]/\U\\1/' <<<)s","hello") -> Hello
|
||||
* Feature removed in SWIG 4.1.0.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
#if defined(_MSC_VER)
|
||||
# define popen _popen
|
||||
# define pclose _pclose
|
||||
# if !defined(HAVE_POPEN)
|
||||
# define HAVE_POPEN 1
|
||||
# endif
|
||||
#else
|
||||
# if !defined(_WIN32)
|
||||
/* These Posix functions are not ISO C and so are not always defined in stdio.h */
|
||||
extern FILE *popen(const char *command, const char *type);
|
||||
extern int pclose(FILE *stream);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
String *Swig_string_command(String *s) {
|
||||
String *res = NewStringEmpty();
|
||||
#if defined(HAVE_POPEN)
|
||||
if (Len(s)) {
|
||||
char *command = Char(s);
|
||||
FILE *fp = popen(command, "r");
|
||||
if (fp) {
|
||||
char buffer[1025];
|
||||
while (fscanf(fp, "%1024s", buffer) != EOF) {
|
||||
Append(res, buffer);
|
||||
}
|
||||
pclose(fp);
|
||||
} else {
|
||||
Swig_error("SWIG", Getline(s), "Command encoder fails attempting '%s'.\n", s);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return res;
|
||||
Swig_error("SWIG", Getline(s), "Command encoder no longer supported - use regex encoder instead.\n");
|
||||
Exit(EXIT_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_strip()
|
||||
*
|
||||
|
|
@ -1283,7 +1251,7 @@ void Swig_offset_string(String *s, int number) {
|
|||
if ((Char(s))[len-1] == '\n')
|
||||
--lines;
|
||||
/* allocate a temporary storage for a padded string */
|
||||
res = (char*)malloc(len + lines * number * 2 + 1);
|
||||
res = (char*)Malloc(len + lines * number * 2 + 1);
|
||||
res[len + lines * number * 2] = 0;
|
||||
|
||||
/* copy lines to res, prepending tabs to each line */
|
||||
|
|
@ -1307,12 +1275,13 @@ void Swig_offset_string(String *s, int number) {
|
|||
/* replace 's' contents with 'res' */
|
||||
Clear(s);
|
||||
Append(s, res);
|
||||
free(res);
|
||||
Free(res);
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_PCRE
|
||||
#include <pcre.h>
|
||||
#define PCRE2_CODE_UNIT_WIDTH 8
|
||||
#include <pcre2.h>
|
||||
|
||||
static int split_regex_pattern_subst(String *s, String **pattern, String **subst, const char **input)
|
||||
{
|
||||
|
|
@ -1340,7 +1309,7 @@ static int split_regex_pattern_subst(String *s, String **pattern, String **subst
|
|||
|
||||
err_out:
|
||||
Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1375,7 +1344,7 @@ static void copy_with_maybe_case_conversion(String *dst, const char *src, int le
|
|||
}
|
||||
}
|
||||
|
||||
String *replace_captures(int num_captures, const char *input, String *subst, int captures[], String *pattern, String *s)
|
||||
String *replace_captures(int num_captures, const char *input, String *subst, size_t captures[], String *pattern, String *s)
|
||||
{
|
||||
int convertCase = 0, convertNextOnly = 0;
|
||||
String *result = NewStringEmpty();
|
||||
|
|
@ -1397,7 +1366,7 @@ String *replace_captures(int num_captures, const char *input, String *subst, int
|
|||
} else if (isdigit((unsigned char)*p)) {
|
||||
int group = *p++ - '0';
|
||||
if (group < num_captures) {
|
||||
int l = captures[group*2], r = captures[group*2 + 1];
|
||||
int l = (int)captures[group*2], r = (int)captures[group*2 + 1];
|
||||
if (l != -1) {
|
||||
copy_with_maybe_case_conversion(result, input + l, r - l, &convertCase, convertNextOnly);
|
||||
}
|
||||
|
|
@ -1449,47 +1418,59 @@ 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;
|
||||
pcre2_code *compiled_pat = 0;
|
||||
const char *input;
|
||||
PCRE2_UCHAR pcre_error[256];
|
||||
int pcre_errornum;
|
||||
size_t pcre_errorpos;
|
||||
String *pattern = 0, *subst = 0;
|
||||
int captures[30];
|
||||
|
||||
size_t *captures = 0;
|
||||
pcre2_match_data *match_data = 0;
|
||||
if (split_regex_pattern_subst(s, &pattern, &subst, &input)) {
|
||||
int rc;
|
||||
|
||||
compiled_pat = pcre_compile(
|
||||
Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL);
|
||||
compiled_pat = pcre2_compile(
|
||||
(PCRE2_SPTR8)Char(pattern), PCRE2_ZERO_TERMINATED, pcre_options, &pcre_errornum, &pcre_errorpos, NULL);
|
||||
if (!compiled_pat) {
|
||||
pcre2_get_error_message (pcre_errornum, pcre_error, sizeof pcre_error);
|
||||
Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n",
|
||||
pcre_error, Char(pattern), pcre_errorpos);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
rc = pcre_exec(compiled_pat, NULL, input, (int)strlen(input), 0, 0, captures, 30);
|
||||
match_data = pcre2_match_data_create_from_pattern (compiled_pat, NULL);
|
||||
rc = pcre2_match(compiled_pat, (PCRE2_SPTR8)input, PCRE2_ZERO_TERMINATED, 0, 0, match_data, NULL);
|
||||
captures = pcre2_get_ovector_pointer (match_data);
|
||||
if (rc >= 0) {
|
||||
res = replace_captures(rc, input, subst, captures, pattern, s);
|
||||
} else if (rc != PCRE_ERROR_NOMATCH) {
|
||||
} else if (rc != PCRE2_ERROR_NOMATCH) {
|
||||
Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" using \"%s\".\n",
|
||||
rc, Char(pattern), input);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
DohDelete(pattern);
|
||||
DohDelete(subst);
|
||||
pcre_free(compiled_pat);
|
||||
pcre2_code_free(compiled_pat);
|
||||
pcre2_match_data_free(match_data);
|
||||
return res ? res : NewStringEmpty();
|
||||
}
|
||||
|
||||
String *Swig_pcre_version(void) {
|
||||
return NewStringf("PCRE Version: %s", pcre_version());
|
||||
int len = pcre2_config(PCRE2_CONFIG_VERSION, NULL);
|
||||
char *buf = Malloc(len);
|
||||
String *result;
|
||||
pcre2_config(PCRE2_CONFIG_VERSION, buf);
|
||||
result = NewStringf("PCRE2 Version: %s", buf);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
String *Swig_string_regex(String *s) {
|
||||
Swig_error("SWIG", Getline(s), "PCRE regex support not enabled in this SWIG build.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1516,7 +1497,7 @@ int Swig_is_generated_overload(Node *n) {
|
|||
* Initialize the SWIG core
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_init() {
|
||||
void Swig_init(void) {
|
||||
/* Set some useful string encoding methods */
|
||||
DohEncoding("escape", Swig_string_escape);
|
||||
DohEncoding("hexescape", Swig_string_hexescape);
|
||||
|
|
|
|||
|
|
@ -771,28 +771,28 @@ void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *d
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static Hash *namewarn_hash = 0;
|
||||
static Hash *name_namewarn_hash() {
|
||||
static Hash *name_namewarn_hash(void) {
|
||||
if (!namewarn_hash)
|
||||
namewarn_hash = NewHash();
|
||||
return namewarn_hash;
|
||||
}
|
||||
|
||||
static Hash *rename_hash = 0;
|
||||
static Hash *name_rename_hash() {
|
||||
static Hash *name_rename_hash(void) {
|
||||
if (!rename_hash)
|
||||
rename_hash = NewHash();
|
||||
return rename_hash;
|
||||
}
|
||||
|
||||
static List *namewarn_list = 0;
|
||||
static List *name_namewarn_list() {
|
||||
static List *name_namewarn_list(void) {
|
||||
if (!namewarn_list)
|
||||
namewarn_list = NewList();
|
||||
return namewarn_list;
|
||||
}
|
||||
|
||||
static List *rename_list = 0;
|
||||
static List *name_rename_list() {
|
||||
static List *name_rename_list(void) {
|
||||
if (!rename_list)
|
||||
rename_list = NewList();
|
||||
return rename_list;
|
||||
|
|
@ -1119,33 +1119,39 @@ static DOH *get_lattr(Node *n, List *lattr) {
|
|||
}
|
||||
|
||||
#ifdef HAVE_PCRE
|
||||
#include <pcre.h>
|
||||
#define PCRE2_CODE_UNIT_WIDTH 8
|
||||
#include <pcre2.h>
|
||||
|
||||
static int name_regexmatch_value(Node *n, String *pattern, String *s) {
|
||||
pcre *compiled_pat;
|
||||
const char *err;
|
||||
int errpos;
|
||||
pcre2_code *compiled_pat;
|
||||
PCRE2_UCHAR err[256];
|
||||
int errornum;
|
||||
size_t errpos;
|
||||
int rc;
|
||||
pcre2_match_data *match_data = 0;
|
||||
|
||||
compiled_pat = pcre_compile(Char(pattern), 0, &err, &errpos, NULL);
|
||||
compiled_pat = pcre2_compile((PCRE2_SPTR8)Char(pattern), PCRE2_ZERO_TERMINATED, 0, &errornum, &errpos, NULL);
|
||||
if (!compiled_pat) {
|
||||
pcre2_get_error_message (errornum, err, sizeof err);
|
||||
Swig_error("SWIG", Getline(n),
|
||||
"Invalid regex \"%s\": compilation failed at %d: %s\n",
|
||||
Char(pattern), errpos, err);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0);
|
||||
pcre_free(compiled_pat);
|
||||
match_data = pcre2_match_data_create_from_pattern (compiled_pat, NULL);
|
||||
rc = pcre2_match(compiled_pat, (PCRE2_SPTR8)Char(s), PCRE2_ZERO_TERMINATED, 0, 0, match_data, 0);
|
||||
pcre2_code_free(compiled_pat);
|
||||
pcre2_match_data_free(match_data);
|
||||
|
||||
if (rc == PCRE_ERROR_NOMATCH)
|
||||
if (rc == PCRE2_ERROR_NOMATCH)
|
||||
return 0;
|
||||
|
||||
if (rc < 0 ) {
|
||||
Swig_error("SWIG", Getline(n),
|
||||
"Matching \"%s\" against regex \"%s\" failed: %d\n",
|
||||
Char(s), Char(pattern), rc);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
@ -1158,7 +1164,7 @@ static int name_regexmatch_value(Node *n, String *pattern, String *s) {
|
|||
(void)s;
|
||||
Swig_error("SWIG", Getline(n),
|
||||
"PCRE regex matching is not available in this SWIG build.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1538,6 +1544,15 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname,
|
|||
result = apply_rename(n, rename, fullname, prefix, name);
|
||||
if ((msg) && (Len(msg))) {
|
||||
if (!Getmeta(nname, "already_warned")) {
|
||||
String* suffix = 0;
|
||||
if (Strcmp(result, "$ignore") == 0) {
|
||||
suffix = NewStringf(": ignoring '%s'\n", name);
|
||||
} else if (Strcmp(result, name) != 0) {
|
||||
suffix = NewStringf(", renaming to '%s'\n", result);
|
||||
} else {
|
||||
/* No rename was performed */
|
||||
suffix = NewString("\n");
|
||||
}
|
||||
if (n) {
|
||||
/* Parameter renaming is not fully implemented. Mainly because there is no C/C++ syntax to
|
||||
* for %rename to fully qualify a function's parameter name from outside the function. Hence it
|
||||
|
|
@ -1545,13 +1560,14 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname,
|
|||
int suppress_parameter_rename_warning = Equal(nodeType(n), "parm");
|
||||
if (!suppress_parameter_rename_warning) {
|
||||
SWIG_WARN_NODE_BEGIN(n);
|
||||
Swig_warning(0, Getfile(n), Getline(n), "%s\n", msg);
|
||||
Swig_warning(0, Getfile(n), Getline(n), "%s%s", msg, suffix);
|
||||
SWIG_WARN_NODE_END(n);
|
||||
}
|
||||
} else {
|
||||
Swig_warning(0, Getfile(name), Getline(name), "%s\n", msg);
|
||||
Swig_warning(0, Getfile(name), Getline(name), "%s%s", msg, suffix);
|
||||
}
|
||||
Setmeta(nname, "already_warned", "1");
|
||||
Delete(suffix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ int ParmList_len(ParmList *p) {
|
|||
* get_empty_type()
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
static SwigType *get_empty_type() {
|
||||
static SwigType *get_empty_type(void) {
|
||||
return NewStringEmpty();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ static void brackets_clear(Scanner *);
|
|||
|
||||
Scanner *NewScanner(void) {
|
||||
Scanner *s;
|
||||
s = (Scanner *) malloc(sizeof(Scanner));
|
||||
s = (Scanner *) Malloc(sizeof(Scanner));
|
||||
s->line = 1;
|
||||
s->file = 0;
|
||||
s->nexttoken = -1;
|
||||
|
|
@ -88,8 +88,8 @@ void DelScanner(Scanner *s) {
|
|||
Delete(s->file);
|
||||
Delete(s->error);
|
||||
Delete(s->str);
|
||||
free(s->idstart);
|
||||
free(s);
|
||||
Free(s->idstart);
|
||||
Free(s);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -202,7 +202,7 @@ int Scanner_start_line(Scanner *s) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Scanner_idstart(Scanner *s, const char *id) {
|
||||
free(s->idstart);
|
||||
Free(s->idstart);
|
||||
s->idstart = Swig_copy_string(id);
|
||||
}
|
||||
|
||||
|
|
@ -336,9 +336,9 @@ static void brackets_reset(Scanner *s) {
|
|||
* Usually called when '(' is found.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
static void brackets_push(Scanner *s) {
|
||||
int *newInt = (int *)malloc(sizeof(int));
|
||||
int *newInt = (int *)Malloc(sizeof(int));
|
||||
*newInt = 0;
|
||||
Push(s->brackets, NewVoid(newInt, free));
|
||||
Push(s->brackets, NewVoid(newInt, Free));
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -596,10 +596,6 @@ static int look(Scanner *s) {
|
|||
state = 3;
|
||||
else if (c == '\\')
|
||||
return SWIG_TOKEN_BACKSLASH;
|
||||
else if (c == '[')
|
||||
return SWIG_TOKEN_LBRACKET;
|
||||
else if (c == ']')
|
||||
return SWIG_TOKEN_RBRACKET;
|
||||
else if (c == '@')
|
||||
return SWIG_TOKEN_AT;
|
||||
else if (c == '$')
|
||||
|
|
@ -636,7 +632,11 @@ static int look(Scanner *s) {
|
|||
}
|
||||
|
||||
else if (c == '.')
|
||||
state = 100; /* Maybe a number, maybe just a period */
|
||||
state = 100; /* Maybe a number, maybe ellipsis, just a period */
|
||||
else if (c == '[')
|
||||
state = 102; /* Maybe a bracket or a double bracket */
|
||||
else if (c == ']')
|
||||
state = 103; /* Maybe a bracket or a double bracket */
|
||||
else if (isdigit(c))
|
||||
state = 8; /* A numerical value */
|
||||
else
|
||||
|
|
@ -833,7 +833,7 @@ static int look(Scanner *s) {
|
|||
return SWIG_TOKEN_MODEQUAL;
|
||||
} else if (c == '}') {
|
||||
Swig_error(cparse_file, cparse_line, "Syntax error. Extraneous '%%}'\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
Exit(EXIT_FAILURE);
|
||||
} else {
|
||||
retract(s, 1);
|
||||
return SWIG_TOKEN_PERCENT;
|
||||
|
|
@ -893,9 +893,16 @@ static int look(Scanner *s) {
|
|||
}
|
||||
if (c == '<')
|
||||
state = 240;
|
||||
else if (c == '=')
|
||||
return SWIG_TOKEN_LTEQUAL;
|
||||
else {
|
||||
else if (c == '=') {
|
||||
if ((c = nextchar(s)) == 0) {
|
||||
return SWIG_TOKEN_LTEQUAL;
|
||||
} else if (c == '>' && cparse_cplusplus) { /* Spaceship operator */
|
||||
return SWIG_TOKEN_LTEQUALGT;
|
||||
} else {
|
||||
retract(s, 1);
|
||||
return SWIG_TOKEN_LTEQUAL;
|
||||
}
|
||||
} else {
|
||||
retract(s, 1);
|
||||
brackets_increment(s);
|
||||
return SWIG_TOKEN_LESSTHAN;
|
||||
|
|
@ -1330,19 +1337,59 @@ static int look(Scanner *s) {
|
|||
}
|
||||
break;
|
||||
|
||||
/* A period or maybe a floating point number */
|
||||
/* A period or an ellipsis or maybe a floating point number */
|
||||
|
||||
case 100:
|
||||
if ((c = nextchar(s)) == 0)
|
||||
return (0);
|
||||
if (isdigit(c))
|
||||
state = 81;
|
||||
else if (c == '.')
|
||||
state = 101;
|
||||
else {
|
||||
retract(s, 1);
|
||||
return SWIG_TOKEN_PERIOD;
|
||||
}
|
||||
break;
|
||||
|
||||
/* An ellipsis */
|
||||
|
||||
case 101:
|
||||
if ((c = nextchar(s)) == 0)
|
||||
return (0);
|
||||
if (c == '.') {
|
||||
return SWIG_TOKEN_ELLIPSIS;
|
||||
} else {
|
||||
retract(s, 2);
|
||||
return SWIG_TOKEN_PERIOD;
|
||||
}
|
||||
break;
|
||||
|
||||
/* A left bracket or a double left bracket */
|
||||
case 102:
|
||||
|
||||
if ((c = nextchar(s)) == 0) {
|
||||
return SWIG_TOKEN_LBRACKET;
|
||||
} else if (c == '[') {
|
||||
return SWIG_TOKEN_LLBRACKET;
|
||||
} else {
|
||||
retract(s, 1);
|
||||
return SWIG_TOKEN_LBRACKET;
|
||||
}
|
||||
break;
|
||||
|
||||
/* a right bracket or a double right bracket */
|
||||
case 103:
|
||||
if ((c = nextchar(s)) == 0) {
|
||||
return SWIG_TOKEN_RBRACKET;
|
||||
} else if (c == ']') {
|
||||
return SWIG_TOKEN_RRBRACKET;
|
||||
} else {
|
||||
retract(s, 1);
|
||||
return SWIG_TOKEN_RBRACKET;
|
||||
}
|
||||
break;
|
||||
|
||||
case 200: /* PLUS, PLUSPLUS, PLUSEQUAL */
|
||||
if ((c = nextchar(s)) == 0)
|
||||
return SWIG_TOKEN_PLUS;
|
||||
|
|
@ -1796,14 +1843,14 @@ void Scanner_locator(Scanner *s, String *loc) {
|
|||
cparse_file = locs->filename;
|
||||
cparse_line = locs->line_number;
|
||||
l = locs->next;
|
||||
free(locs);
|
||||
Free(locs);
|
||||
locs = l;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* We're going to push a new location */
|
||||
l = (Locator *) malloc(sizeof(Locator));
|
||||
l = (Locator *) Malloc(sizeof(Locator));
|
||||
l->filename = cparse_file;
|
||||
l->line_number = cparse_line;
|
||||
l->next = locs;
|
||||
|
|
|
|||
|
|
@ -11,12 +11,10 @@
|
|||
* Header file for the SWIG core.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef SWIGCORE_H_
|
||||
#define SWIGCORE_H_
|
||||
#ifndef SWIG_SWIG_H
|
||||
#define SWIG_SWIG_H
|
||||
|
||||
#ifndef MACSWIG
|
||||
#include "swigconfig.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
@ -440,8 +438,6 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
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);
|
||||
extern void SWIG_exit(int exit_code);
|
||||
|
||||
|
||||
/* -- template init -- */
|
||||
extern void SwigType_template_init(void);
|
||||
|
|
|
|||
|
|
@ -30,13 +30,11 @@ extern String *Swig_file_extension(const_String_or_char_ptr filename);
|
|||
extern String *Swig_file_basename(const_String_or_char_ptr filename);
|
||||
extern String *Swig_file_filename(const_String_or_char_ptr filename);
|
||||
extern String *Swig_file_dirname(const_String_or_char_ptr filename);
|
||||
extern void Swig_file_debug_set();
|
||||
extern void Swig_file_debug_set(void);
|
||||
|
||||
/* Delimiter used in accessing files and directories */
|
||||
|
||||
#if defined(MACSWIG)
|
||||
# define SWIG_FILE_DELIMITER ":"
|
||||
#elif defined(_WIN32)
|
||||
#if defined(_WIN32)
|
||||
# define SWIG_FILE_DELIMITER "\\"
|
||||
#else
|
||||
# define SWIG_FILE_DELIMITER "/"
|
||||
|
|
|
|||
|
|
@ -70,6 +70,9 @@ extern void Scanner_locator(Scanner *, String *loc);
|
|||
#define SWIG_TOKEN_BOOL 32 /* true or false */
|
||||
#define SWIG_TOKEN_WSTRING 33 /* L"str" */
|
||||
#define SWIG_TOKEN_WCHAR 34 /* L'c' */
|
||||
#define SWIG_TOKEN_ELLIPSIS 35 /* ... */
|
||||
#define SWIG_TOKEN_LLBRACKET 36 /* [[ */
|
||||
#define SWIG_TOKEN_RRBRACKET 37 /* ]] */
|
||||
|
||||
#define SWIG_TOKEN_ILLEGAL 99
|
||||
#define SWIG_TOKEN_ERROR -1
|
||||
|
|
@ -113,3 +116,4 @@ extern void Scanner_locator(Scanner *, String *loc);
|
|||
#define SWIG_TOKEN_MODEQUAL 134 /* %= */
|
||||
#define SWIG_TOKEN_ARROW 135 /* -> */
|
||||
#define SWIG_TOKEN_ARROWSTAR 136 /* ->* */
|
||||
#define SWIG_TOKEN_LTEQUALGT 137 /* <=> */
|
||||
|
|
|
|||
|
|
@ -51,3 +51,4 @@ extern void Swig_restore(Node *node);
|
|||
extern void Swig_print_tags(File *obj, Node *root);
|
||||
extern void Swig_print_tree(Node *obj);
|
||||
extern void Swig_print_node(Node *obj);
|
||||
extern int Swig_print_quiet(int quiet);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "swig.h"
|
||||
#include "swigwarn.h"
|
||||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
||||
/* #define SWIG_DEBUG*/
|
||||
|
|
@ -641,10 +641,11 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) {
|
|||
|
||||
{
|
||||
Node *td = n;
|
||||
while (td && Checkattr(td, "nodeType", "cdecl") && Checkattr(td, "storage", "typedef")) {
|
||||
while (td && ((Equal(nodeType(td), "cdecl") && Checkattr(td, "storage", "typedef")) || (Equal(nodeType(td), "using") && !Getattr(n, "namespace")))) {
|
||||
SwigType *type;
|
||||
Node *td1;
|
||||
type = Copy(Getattr(td, "type"));
|
||||
int using_not_typedef = Equal(nodeType(td), "using");
|
||||
type = Copy(Getattr(td, using_not_typedef ? "uname" : "type"));
|
||||
SwigType_push(type, Getattr(td, "decl"));
|
||||
td1 = Swig_symbol_clookup(type, 0);
|
||||
|
||||
|
|
@ -665,9 +666,13 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) {
|
|||
ie, when Foo -> FooBar -> Foo, jump one scope up when possible.
|
||||
|
||||
*/
|
||||
if (td1 && Checkattr(td1, "storage", "typedef")) {
|
||||
String *st = Getattr(td1, "type");
|
||||
if (td1) {
|
||||
String *st = 0;
|
||||
String *sn = Getattr(td, "name");
|
||||
if (Equal(nodeType(td1), "cdecl") && Checkattr(td1, "storage", "typedef"))
|
||||
st = Getattr(td1, "type");
|
||||
else if (Equal(nodeType(td1), "using") && !Getattr(td1, "namespace"))
|
||||
st = Getattr(td1, "uname");
|
||||
if (st && sn && Equal(st, sn)) {
|
||||
Symtab *sc = Getattr(current_symtab, "parentNode");
|
||||
if (sc)
|
||||
|
|
@ -1177,7 +1182,9 @@ Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) {
|
|||
Symtab *un = Getattr(s, "sym:symtab");
|
||||
Node *ss = (!Equal(name, uname) || (un != n)) ? Swig_symbol_clookup(uname, un) : 0; /* avoid infinity loop */
|
||||
if (!ss) {
|
||||
SWIG_WARN_NODE_BEGIN(s);
|
||||
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
|
||||
SWIG_WARN_NODE_END(s);
|
||||
}
|
||||
s = ss;
|
||||
}
|
||||
|
|
@ -1249,7 +1256,9 @@ Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (*
|
|||
Node *ss;
|
||||
ss = Swig_symbol_clookup(Getattr(s, "uname"), Getattr(s, "sym:symtab"));
|
||||
if (!ss && !checkfunc) {
|
||||
SWIG_WARN_NODE_BEGIN(s);
|
||||
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
|
||||
SWIG_WARN_NODE_END(s);
|
||||
}
|
||||
s = ss;
|
||||
}
|
||||
|
|
@ -1300,7 +1309,9 @@ Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) {
|
|||
while (s && Checkattr(s, "nodeType", "using")) {
|
||||
Node *ss = Swig_symbol_clookup_local(Getattr(s, "uname"), Getattr(s, "sym:symtab"));
|
||||
if (!ss) {
|
||||
SWIG_WARN_NODE_BEGIN(s);
|
||||
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
|
||||
SWIG_WARN_NODE_END(s);
|
||||
}
|
||||
s = ss;
|
||||
}
|
||||
|
|
@ -1348,7 +1359,9 @@ Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n,
|
|||
while (s && Checkattr(s, "nodeType", "using")) {
|
||||
Node *ss = Swig_symbol_clookup_local_check(Getattr(s, "uname"), Getattr(s, "sym:symtab"), checkfunc);
|
||||
if (!ss && !checkfunc) {
|
||||
SWIG_WARN_NODE_BEGIN(s);
|
||||
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
|
||||
SWIG_WARN_NODE_END(s);
|
||||
}
|
||||
s = ss;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,20 @@
|
|||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
static int debug_quiet = 0;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_print_quiet()
|
||||
*
|
||||
* Set quiet mode when printing a parse tree node
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_print_quiet(int quiet) {
|
||||
int previous_quiet = debug_quiet;
|
||||
debug_quiet = quiet;
|
||||
return previous_quiet;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_print_tags()
|
||||
*
|
||||
|
|
@ -66,33 +80,42 @@ static void print_indent(int l) {
|
|||
void Swig_print_node(Node *obj) {
|
||||
Iterator ki;
|
||||
Node *cobj;
|
||||
List *keys = Keys(obj);
|
||||
|
||||
print_indent(0);
|
||||
Printf(stdout, "+++ %s - %p ----------------------------------------\n", nodeType(obj), obj);
|
||||
ki = First(obj);
|
||||
while (ki.key) {
|
||||
String *k = ki.key;
|
||||
if ((Cmp(k, "nodeType") == 0) || (Cmp(k, "firstChild") == 0) || (Cmp(k, "lastChild") == 0) ||
|
||||
(Cmp(k, "parentNode") == 0) || (Cmp(k, "nextSibling") == 0) || (Cmp(k, "previousSibling") == 0) || (*(Char(k)) == '$')) {
|
||||
if (debug_quiet)
|
||||
Printf(stdout, "+++ %s ----------------------------------------\n", nodeType(obj));
|
||||
else
|
||||
Printf(stdout, "+++ %s - %p ----------------------------------------\n", nodeType(obj), obj);
|
||||
|
||||
SortList(keys, 0);
|
||||
ki = First(keys);
|
||||
while (ki.item) {
|
||||
String *k = ki.item;
|
||||
DOH *value = Getattr(obj, k);
|
||||
if (Equal(k, "nodeType") || (*(Char(k)) == '$')) {
|
||||
/* Do nothing */
|
||||
} else if (Cmp(k, "kwargs") == 0 || Cmp(k, "parms") == 0 || Cmp(k, "wrap:parms") == 0 ||
|
||||
Cmp(k, "pattern") == 0 || Cmp(k, "templateparms") == 0 || Cmp(k, "throws") == 0) {
|
||||
} else if (debug_quiet && (Equal(k, "firstChild") || Equal(k, "lastChild") || Equal(k, "parentNode") || Equal(k, "nextSibling") ||
|
||||
Equal(k, "previousSibling") || Equal(k, "symtab") || Equal(k, "csymtab") || Equal(k, "sym:symtab") || Equal(k, "sym:nextSibling") ||
|
||||
Equal(k, "sym:previousSibling") || Equal(k, "csym:nextSibling") || Equal(k, "csym:previousSibling"))) {
|
||||
/* Do nothing */
|
||||
} else if (Equal(k, "kwargs") || Equal(k, "parms") || Equal(k, "wrap:parms") || Equal(k, "pattern") || Equal(k, "templateparms") || Equal(k, "throws")) {
|
||||
print_indent(2);
|
||||
/* Differentiate parameter lists by displaying within single quotes */
|
||||
Printf(stdout, "%-12s - \'%s\'\n", k, ParmList_str_defaultargs(Getattr(obj, k)));
|
||||
Printf(stdout, "%-12s - \'%s\'\n", k, ParmList_str_defaultargs(value));
|
||||
} else {
|
||||
DOH *o;
|
||||
const char *trunc = "";
|
||||
print_indent(2);
|
||||
if (DohIsString(Getattr(obj, k))) {
|
||||
o = Str(Getattr(obj, k));
|
||||
if (DohIsString(value)) {
|
||||
o = Str(value);
|
||||
if (Len(o) > 80) {
|
||||
trunc = "...";
|
||||
}
|
||||
Printf(stdout, "%-12s - \"%(escape)-0.80s%s\"\n", k, o, trunc);
|
||||
Delete(o);
|
||||
} else {
|
||||
Printf(stdout, "%-12s - %p\n", k, Getattr(obj, k));
|
||||
Printf(stdout, "%-12s - %p\n", k, value);
|
||||
}
|
||||
}
|
||||
ki = Next(ki);
|
||||
|
|
@ -107,6 +130,7 @@ void Swig_print_node(Node *obj) {
|
|||
print_indent(1);
|
||||
Printf(stdout, "\n");
|
||||
}
|
||||
Delete(keys);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -225,7 +249,7 @@ void removeNode(Node *n) {
|
|||
/* Delete attributes */
|
||||
Delattr(n,"parentNode");
|
||||
Delattr(n,"nextSibling");
|
||||
Delattr(n,"prevSibling");
|
||||
Delattr(n,"previousSibling");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -261,12 +285,16 @@ int checkAttribute(Node *n, const_String_or_char_ptr name, const_String_or_char_
|
|||
* ns - namespace for the view name for saving any attributes under
|
||||
* n - node
|
||||
* ... - list of attribute names of type char*
|
||||
* This method checks that the attribute names exist in the node n and asserts if
|
||||
* not. Assert will only occur unless the attribute is optional. An attribute is
|
||||
* optional if it is prefixed by ?, eg "?value". If the attribute name is prefixed
|
||||
* by * or ?, eg "*value" then a copy of the attribute is saved. The saved
|
||||
* attributes will be restored on a subsequent call to Swig_restore(). All the
|
||||
* saved attributes are saved in the view namespace (prefixed by ns).
|
||||
*
|
||||
* An attribute is optional if it is prefixed by ?, eg "?value". All
|
||||
* non-optional attributes are checked for on node n and if any do not exist
|
||||
* SWIG exits with a fatal error.
|
||||
*
|
||||
* If the attribute name is prefixed by * or ?, eg "*value" then a copy of the
|
||||
* attribute is saved. The saved attributes will be restored on a subsequent
|
||||
* call to Swig_restore(). All the saved attributes are saved in the view
|
||||
* namespace (prefixed by ns).
|
||||
*
|
||||
* This function can be called more than once with different namespaces.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
|
@ -291,7 +319,7 @@ void Swig_require(const char *ns, Node *n, ...) {
|
|||
obj = Getattr(n, name);
|
||||
if (!opt && !obj) {
|
||||
Swig_error(Getfile(n), Getline(n), "Fatal error (Swig_require). Missing attribute '%s' in node '%s'.\n", name, nodeType(n));
|
||||
assert(obj);
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
if (!obj)
|
||||
obj = DohNone;
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ static void set_typemap(const SwigType *type, Hash **tmhash) {
|
|||
* Initialize the typemap system
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_typemap_init() {
|
||||
void Swig_typemap_init(void) {
|
||||
typemaps = NewHash();
|
||||
}
|
||||
|
||||
|
|
@ -511,7 +511,12 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) {
|
|||
if (sm) {
|
||||
/* Got a typemap. Need to only merge attributes for methods that match our signature */
|
||||
Iterator ki;
|
||||
Hash *deferred_add;
|
||||
match = 1;
|
||||
|
||||
/* Since typemap_register can modify the `sm` hash, we *cannot* call typemap_register while iterating over sm.
|
||||
* Create a temporary hash of typemaps to add immediately after. */
|
||||
deferred_add = NewHash();
|
||||
for (ki = First(sm); ki.key; ki = Next(ki)) {
|
||||
/* Check for a signature match with the source signature */
|
||||
if ((count_args(ki.key) == narg) && (Strstr(ki.key, ssig))) {
|
||||
|
|
@ -521,34 +526,36 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) {
|
|||
Replace(nkey, ssig, dsig, DOH_REPLACE_ANY);
|
||||
|
||||
/* Make sure the typemap doesn't already exist in the target map */
|
||||
|
||||
oldm = Getattr(tm, nkey);
|
||||
if (!oldm || (!Getattr(tm, "code"))) {
|
||||
String *code;
|
||||
ParmList *locals;
|
||||
ParmList *kwargs;
|
||||
Hash *sm1 = ki.item;
|
||||
|
||||
code = Getattr(sm1, "code");
|
||||
locals = Getattr(sm1, "locals");
|
||||
kwargs = Getattr(sm1, "kwargs");
|
||||
if (code) {
|
||||
String *src_str = ParmList_str_multibrackets(src);
|
||||
String *dest_str = ParmList_str_multibrackets(dest);
|
||||
String *source_directive = NewStringf("apply %s { %s }", src_str, dest_str);
|
||||
|
||||
Replace(nkey, dsig, "", DOH_REPLACE_ANY);
|
||||
Replace(nkey, "tmap:", "", DOH_REPLACE_ANY);
|
||||
typemap_register(nkey, dest, code, locals, kwargs, source_directive);
|
||||
|
||||
Delete(source_directive);
|
||||
Delete(dest_str);
|
||||
Delete(src_str);
|
||||
Setattr(deferred_add, nkey, sm1);
|
||||
}
|
||||
}
|
||||
Delete(nkey);
|
||||
}
|
||||
}
|
||||
|
||||
/* After assembling the key/item pairs, add the resulting typemaps */
|
||||
for (ki = First(deferred_add); ki.key; ki = Next(ki)) {
|
||||
Hash *sm1 = ki.item;
|
||||
String *src_str = ParmList_str_multibrackets(src);
|
||||
String *dest_str = ParmList_str_multibrackets(dest);
|
||||
String *source_directive = NewStringf("apply %s { %s }", src_str, dest_str);
|
||||
|
||||
typemap_register(ki.key, dest, Getattr(sm1, "code"), Getattr(sm1, "locals"), Getattr(sm1, "kwargs"), source_directive);
|
||||
|
||||
Delete(source_directive);
|
||||
Delete(dest_str);
|
||||
Delete(src_str);
|
||||
}
|
||||
Delete(deferred_add);
|
||||
}
|
||||
Delete(ssig);
|
||||
Delete(dsig);
|
||||
|
|
@ -1256,6 +1263,59 @@ static String *typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) {
|
|||
return w ? Copy(w) : 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* typemap_merge_fragment_kwargs()
|
||||
*
|
||||
* If multiple 'fragment' attributes are provided to a typemap, combine them by
|
||||
* concatenating with commas.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void typemap_merge_fragment_kwargs(Parm *kw) {
|
||||
Parm *reattach_kw = NULL;
|
||||
Parm *prev_kw = NULL;
|
||||
Parm *next_kw = NULL;
|
||||
String *fragment = NULL;
|
||||
while (kw) {
|
||||
next_kw = nextSibling(kw);
|
||||
if (Strcmp(Getattr(kw, "name"), "fragment") == 0) {
|
||||
String *thisfragment = Getattr(kw, "value");
|
||||
String *kwtype = Getattr(kw, "type");
|
||||
if (!fragment) {
|
||||
/* First fragment found; it should remain in the list */
|
||||
fragment = thisfragment;
|
||||
prev_kw = kw;
|
||||
} else {
|
||||
/* Concatenate to previously found fragment */
|
||||
Printv(fragment, ",", thisfragment, NULL);
|
||||
reattach_kw = prev_kw;
|
||||
}
|
||||
if (kwtype) {
|
||||
String *mangle = Swig_string_mangle(kwtype);
|
||||
Append(fragment, mangle);
|
||||
Delete(mangle);
|
||||
/* Remove 'type' from kwargs so it's not duplicated later */
|
||||
Setattr(kw, "type", NULL);
|
||||
}
|
||||
} else {
|
||||
/* Not a fragment */
|
||||
if (reattach_kw) {
|
||||
/* Update linked list to remove duplicate fragment */
|
||||
DohIncref(kw);
|
||||
set_nextSibling(reattach_kw, kw);
|
||||
set_previousSibling(kw, reattach_kw);
|
||||
Delete(reattach_kw);
|
||||
reattach_kw = NULL;
|
||||
}
|
||||
prev_kw = kw;
|
||||
}
|
||||
kw = next_kw;
|
||||
}
|
||||
if (reattach_kw) {
|
||||
/* Update linked list to remove duplicate fragment */
|
||||
set_nextSibling(reattach_kw, kw);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_typemap_lookup()
|
||||
*
|
||||
|
|
@ -1390,7 +1450,6 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
|||
* ie, not use the typemap code, otherwise both f and actioncode must be non null. */
|
||||
if (actioncode) {
|
||||
const String *result_equals = NewStringf("%s = ", Swig_cresult_name());
|
||||
clname = Copy(actioncode);
|
||||
/* check that the code in the typemap can be used in this optimal way.
|
||||
* The code should be in the form "result = ...;\n". We need to extract
|
||||
* the "..." part. This may not be possible for various reasons, eg
|
||||
|
|
@ -1398,22 +1457,17 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
|||
* hack and circumvents the normal requirement for a temporary variable
|
||||
* to hold the result returned from a wrapped function call.
|
||||
*/
|
||||
if (Strncmp(clname, result_equals, 9) == 0) {
|
||||
int numreplacements = Replace(clname, result_equals, "", DOH_REPLACE_ID_BEGIN);
|
||||
if (numreplacements == 1) {
|
||||
numreplacements = Replace(clname, ";\n", "", DOH_REPLACE_ID_END);
|
||||
if (numreplacements == 1) {
|
||||
if (Strchr(clname, ';') == 0) {
|
||||
lname = clname;
|
||||
actioncode = 0;
|
||||
optimal_substitution = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!optimal_substitution) {
|
||||
if (Strncmp(actioncode, result_equals, Len(result_equals)) == 0 &&
|
||||
Strchr(actioncode, ';') == Char(actioncode) + Len(actioncode) - 2 &&
|
||||
Char(actioncode)[Len(actioncode) - 1] == '\n') {
|
||||
clname = NewStringWithSize(Char(actioncode) + Len(result_equals),
|
||||
Len(actioncode) - Len(result_equals) - 2);
|
||||
lname = clname;
|
||||
actioncode = 0;
|
||||
optimal_substitution = 1;
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(node), Getline(node), "Method %s usage of the optimal attribute ignored\n", Swig_name_decl(node));
|
||||
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(s), Getline(s), "in the out typemap as the following cannot be used to generate optimal code: %s\n", clname);
|
||||
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(s), Getline(s), "in the out typemap as the following cannot be used to generate optimal code: %s\n", actioncode);
|
||||
delete_optimal_attribute = 1;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1463,6 +1517,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
|||
|
||||
/* Attach kwargs - ie the typemap attributes */
|
||||
kw = Getattr(tm, "kwargs");
|
||||
typemap_merge_fragment_kwargs(kw);
|
||||
while (kw) {
|
||||
String *value = Copy(Getattr(kw, "value"));
|
||||
String *kwtype = Getattr(kw, "type");
|
||||
|
|
@ -1577,6 +1632,7 @@ String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *node, co
|
|||
static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr tmap_method, Parm *firstp, int nmatch) {
|
||||
String *temp = NewStringEmpty();
|
||||
Parm *kw = Getattr(tm, "kwargs");
|
||||
typemap_merge_fragment_kwargs(kw);
|
||||
while (kw) {
|
||||
String *value = Copy(Getattr(kw, "value"));
|
||||
String *type = Getattr(kw, "type");
|
||||
|
|
@ -2035,6 +2091,7 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
|
|||
Printf(stdout, "Swig_typemap_attach_parms: embedded\n");
|
||||
#endif
|
||||
if (already_substituting < 10) {
|
||||
char* found_colon;
|
||||
already_substituting++;
|
||||
if ((in_typemap_search_multi == 0) && typemap_search_debug) {
|
||||
String *dtypemap = NewString(dollar_typemap);
|
||||
|
|
@ -2042,7 +2099,15 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
|
|||
Printf(stdout, " Containing: %s\n", dtypemap);
|
||||
Delete(dtypemap);
|
||||
}
|
||||
Swig_typemap_attach_parms(tmap_method, to_match_parms, f);
|
||||
found_colon = Strchr(tmap_method, ':');
|
||||
if (found_colon) {
|
||||
/* Substitute from a keyword argument to a typemap. Avoid emitting local variables from the attached typemap by passing NULL for the file. */
|
||||
String *temp_tmap_method = NewStringWithSize(Char(tmap_method), (int)(found_colon - Char(tmap_method)));
|
||||
Swig_typemap_attach_parms(temp_tmap_method, to_match_parms, NULL);
|
||||
Delete(temp_tmap_method);
|
||||
} else {
|
||||
Swig_typemap_attach_parms(tmap_method, to_match_parms, f);
|
||||
}
|
||||
already_substituting--;
|
||||
|
||||
/* Look for the typemap code */
|
||||
|
|
@ -2105,7 +2170,7 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
|
|||
* Display all typemaps
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_typemap_debug() {
|
||||
void Swig_typemap_debug(void) {
|
||||
int nesting_level = 2;
|
||||
Printf(stdout, "---[ typemaps ]--------------------------------------------------------------\n");
|
||||
Swig_print(typemaps, nesting_level);
|
||||
|
|
|
|||
|
|
@ -359,8 +359,8 @@ SwigType *SwigType_del_pointer(SwigType *t) {
|
|||
c++;
|
||||
}
|
||||
if (strncmp(c, "p.", 2)) {
|
||||
printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n");
|
||||
abort();
|
||||
printf("Fatal error: SwigType_del_pointer applied to non-pointer.\n");
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delslice(t, 0, (int)((c - s) + 2));
|
||||
return t;
|
||||
|
|
@ -402,9 +402,10 @@ SwigType *SwigType_add_reference(SwigType *t) {
|
|||
|
||||
SwigType *SwigType_del_reference(SwigType *t) {
|
||||
char *c = Char(t);
|
||||
int check = strncmp(c, "r.", 2);
|
||||
assert(check == 0);
|
||||
(void)check;
|
||||
if (strncmp(c, "r.", 2)) {
|
||||
printf("Fatal error: SwigType_del_reference applied to non-reference.\n");
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delslice(t, 0, 2);
|
||||
return t;
|
||||
}
|
||||
|
|
@ -438,9 +439,10 @@ SwigType *SwigType_add_rvalue_reference(SwigType *t) {
|
|||
|
||||
SwigType *SwigType_del_rvalue_reference(SwigType *t) {
|
||||
char *c = Char(t);
|
||||
int check = strncmp(c, "z.", 2);
|
||||
assert(check == 0);
|
||||
(void)check;
|
||||
if (strncmp(c, "z.", 2)) {
|
||||
fprintf(stderr, "Fatal error: SwigType_del_rvalue_reference() applied to non-rvalue-reference.\n");
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delslice(t, 0, 2);
|
||||
return t;
|
||||
}
|
||||
|
|
@ -643,9 +645,10 @@ SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size) {
|
|||
|
||||
SwigType *SwigType_del_array(SwigType *t) {
|
||||
char *c = Char(t);
|
||||
int check = strncmp(c, "a(", 2);
|
||||
assert(check == 0);
|
||||
(void)check;
|
||||
if (strncmp(c, "a(", 2)) {
|
||||
fprintf(stderr, "Fatal error: SwigType_del_array() applied to non-array.\n");
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
Delslice(t, 0, element_size(c));
|
||||
return t;
|
||||
}
|
||||
|
|
@ -738,8 +741,10 @@ void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) {
|
|||
char *c = Char(t);
|
||||
|
||||
start = c;
|
||||
if (strncmp(c, "a(", 2))
|
||||
abort();
|
||||
if (strncmp(c, "a(", 2)) {
|
||||
fprintf(stderr, "Fatal error: SwigType_array_type applied to non-array.\n");
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) {
|
||||
c = strchr(c, '.');
|
||||
|
|
@ -831,8 +836,8 @@ SwigType *SwigType_pop_function(SwigType *t) {
|
|||
c = Char(t);
|
||||
}
|
||||
if (strncmp(c, "f(", 2)) {
|
||||
printf("Fatal error. SwigType_pop_function applied to non-function.\n");
|
||||
abort();
|
||||
fprintf(stderr, "Fatal error. SwigType_pop_function applied to non-function.\n");
|
||||
Exit(EXIT_FAILURE);
|
||||
}
|
||||
g = SwigType_pop(t);
|
||||
if (f)
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ int Swig_value_wrapper_mode(int mode) {
|
|||
}
|
||||
|
||||
|
||||
static void flush_cache() {
|
||||
static void flush_cache(void) {
|
||||
typedef_resolve_cache = 0;
|
||||
typedef_all_cache = 0;
|
||||
typedef_qualified_cache = 0;
|
||||
|
|
@ -188,7 +188,7 @@ static void flush_cache() {
|
|||
|
||||
/* Initialize the scoping system */
|
||||
|
||||
void SwigType_typesystem_init() {
|
||||
void SwigType_typesystem_init(void) {
|
||||
if (global_scope)
|
||||
Delete(global_scope);
|
||||
if (scopes)
|
||||
|
|
@ -407,7 +407,7 @@ void SwigType_using_scope(Typetab *scope) {
|
|||
* table for the scope that was popped off.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Typetab *SwigType_pop_scope() {
|
||||
Typetab *SwigType_pop_scope(void) {
|
||||
Typetab *t, *old = current_scope;
|
||||
t = Getattr(current_scope, "parent");
|
||||
if (!t)
|
||||
|
|
@ -1702,7 +1702,9 @@ void SwigType_remember_clientdata(const SwigType *t, const_String_or_char_ptr cl
|
|||
|
||||
if (t) {
|
||||
char *ct = Char(t);
|
||||
if (strchr(ct, '<') && !(strstr(ct, "<("))) {
|
||||
const char *lt = strchr(ct, '<');
|
||||
/* Allow for `<<` operator in constant expression for array size. */
|
||||
if (lt && lt[1] != '(' && lt[1] != '<') {
|
||||
Printf(stdout, "Bad template type passed to SwigType_remember: %s\n", t);
|
||||
assert(0);
|
||||
}
|
||||
|
|
@ -2093,7 +2095,7 @@ static int SwigType_compare_mangled(const DOH *a, const DOH *b) {
|
|||
* Returns the sorted list of mangled type names that should be exported into the
|
||||
* wrapper file.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
List *SwigType_get_sorted_mangled_list() {
|
||||
List *SwigType_get_sorted_mangled_list(void) {
|
||||
List *l = Keys(r_mangled);
|
||||
SortList(l, SwigType_compare_mangled);
|
||||
return l;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ static int Max_line_size = 128;
|
|||
|
||||
Wrapper *NewWrapper(void) {
|
||||
Wrapper *w;
|
||||
w = (Wrapper *) malloc(sizeof(Wrapper));
|
||||
w = (Wrapper *) Malloc(sizeof(Wrapper));
|
||||
w->localh = NewHash();
|
||||
w->locals = NewStringEmpty();
|
||||
w->code = NewStringEmpty();
|
||||
|
|
@ -46,7 +46,7 @@ void DelWrapper(Wrapper *w) {
|
|||
Delete(w->locals);
|
||||
Delete(w->code);
|
||||
Delete(w->def);
|
||||
free(w);
|
||||
Free(w);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue