Another merge with master.

Updated Doxygen error numbers yet again, as Python errors got added in the
meanwhile, pushing the Doxygen ones further off.

And re-merged PEP8/whitespace-related conflicts in autodoc_runme.py once again
(if anybody is looking for a motivating example about why significant
whitespace is bad, here is a great use case).
This commit is contained in:
Vadim Zeitlin 2015-07-20 00:40:32 +02:00
commit 302955a152
448 changed files with 8836 additions and 5079 deletions

View file

@ -632,7 +632,10 @@ int yylex(void) {
*/
nexttok = Scanner_token(scan);
do {
nexttok = Scanner_token(scan);
} while (nexttok == SWIG_TOKEN_ENDLINE || nexttok == SWIG_TOKEN_COMMENT);
if (Scanner_isoperator(nexttok)) {
/* One of the standard C/C++ symbolic operators */
Append(s,Scanner_text(scan));
@ -703,6 +706,8 @@ int yylex(void) {
Append(s," ");
}
Append(s,Scanner_text(scan));
} else if (nexttok == SWIG_TOKEN_ENDLINE) {
} else if (nexttok == SWIG_TOKEN_COMMENT) {
} else {
Append(s,Scanner_text(scan));
needspace = 0;
@ -739,7 +744,7 @@ int yylex(void) {
Setfile(cs,cparse_file);
Scanner_push(scan,cs);
Delete(cs);
return COPERATOR;
return CONVERSIONOPERATOR;
}
}
if (termtoken)
@ -908,7 +913,7 @@ int yylex(void) {
return (WARN);
/* Note down the apparently unknown directive for error reporting. */
cparse_unknown_directive = Swig_copy_string(yytext);
cparse_unknown_directive = NewString(yytext);
}
/* Have an unknown identifier, as a last step, we'll do a typedef lookup on it. */

View file

@ -27,7 +27,6 @@ to work, see Byacc man page: http://invisible-island.net/byacc/manpage/yacc.html
#include "preprocessor.h"
#include <ctype.h>
/* We do this for portability */
#undef alloca
#define alloca malloc
@ -52,7 +51,7 @@ static String *Classprefix = 0;
static String *Namespaceprefix = 0;
static int inclass = 0;
static Node *currentOuterClass = 0; /* for nested classes */
static char *last_cpptype = 0;
static const char *last_cpptype = 0;
static int inherit_list = 0;
static Parm *template_parameters = 0;
static int extendmode = 0;
@ -466,6 +465,10 @@ static void add_symbols(Node *n) {
if ((Cmp(Getattr(n,"storage"),"virtual") == 0) && (Cmp(Getattr(n,"value"),"0") == 0)) {
only_csymbol = 0;
}
if (Cmp(nodeType(n),"destructor") == 0) {
/* Needed for "unref" feature */
only_csymbol = 0;
}
}
} else {
Setattr(n,"access", "public");
@ -794,14 +797,14 @@ static String *make_class_name(String *name) {
/* Use typedef name as class name */
static void add_typedef_name(Node *n, Node *decl, String *oldName, Symtab *cscope, String *scpname) {
static void add_typedef_name(Node *n, Node *declnode, String *oldName, Symtab *cscope, String *scpname) {
String *class_rename = 0;
SwigType *decltype = Getattr(decl, "decl");
if (!decltype || !Len(decltype)) {
SwigType *decl = Getattr(declnode, "decl");
if (!decl || !Len(decl)) {
String *cname;
String *tdscopename;
String *class_scope = Swig_symbol_qualifiedscopename(cscope);
String *name = Getattr(decl, "name");
String *name = Getattr(declnode, "name");
cname = Copy(name);
Setattr(n, "tdname", cname);
tdscopename = class_scope ? NewStringf("%s::%s", class_scope, name) : Copy(name);
@ -812,7 +815,7 @@ static void add_typedef_name(Node *n, Node *decl, String *oldName, Symtab *cscop
if (!Equal(scpname, tdscopename) && !Getattr(classes_typedefs, tdscopename)) {
Setattr(classes_typedefs, tdscopename, n);
}
Setattr(n, "decl", decltype);
Setattr(n, "decl", decl);
Delete(class_scope);
Delete(cname);
Delete(tdscopename);
@ -835,7 +838,7 @@ static String *remove_block(Node *kw, const String *inputcode) {
String *name = Getattr(kw,"name");
if (name && (Cmp(name,"noblock") == 0)) {
char *cstr = Char(inputcode);
size_t len = Len(inputcode);
int len = Len(inputcode);
if (len && cstr[0] == '{') {
--len; ++cstr;
if (len && cstr[len - 1] == '}') { --len; }
@ -1072,7 +1075,6 @@ static void update_nested_classes(Node *n)
static Node *nested_forward_declaration(const char *storage, const char *kind, String *sname, String *name, Node *cpp_opt_declarators) {
Node *nn = 0;
int warned = 0;
if (sname) {
/* Add forward declaration of the nested type */
@ -1116,13 +1118,12 @@ static Node *nested_forward_declaration(const char *storage, const char *kind, S
if (!currentOuterClass || !GetFlag(currentOuterClass, "nested")) {
if (nn && Equal(nodeType(nn), "classforward")) {
Node *n = nn;
SWIG_WARN_NODE_BEGIN(n);
Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", kind, sname ? sname : name);
SWIG_WARN_NODE_END(n);
warned = 1;
}
if (!warned) {
if (!GetFlag(n, "feature:ignore")) {
SWIG_WARN_NODE_BEGIN(n);
Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", kind, sname ? sname : name);
SWIG_WARN_NODE_END(n);
}
} else {
Swig_warning(WARN_PARSE_UNNAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", kind);
}
}
@ -1243,7 +1244,6 @@ static void default_arguments(Node *n) {
Node *function = n;
if (function) {
ParmList *varargs = Getattr(function,"feature:varargs");
if (varargs) {
/* Handles the %varargs directive by looking for "feature:varargs" and
@ -1393,7 +1393,7 @@ static void mark_nodes_as_extend(Node *n) {
%}
%union {
char *id;
const char *id;
List *bases;
struct Define {
String *val;
@ -1468,7 +1468,7 @@ static void mark_nodes_as_extend(Node *n) {
%token NONID DSTAR DCNOT
%token <intvalue> TEMPLATE
%token <str> OPERATOR
%token <str> COPERATOR
%token <str> CONVERSIONOPERATOR
%token PARSETYPE PARSEPARM PARSEPARMS
%token <str> DOXYGENSTRING
%token <str> DOXYGENPOSTSTRING
@ -1513,7 +1513,7 @@ static void mark_nodes_as_extend(Node *n) {
/* Misc */
%type <id> identifier;
%type <dtype> initializer cpp_const exception_specification;
%type <id> storage_class;
%type <id> storage_class extern_string;
%type <pl> parms ptail rawparms varargs_parms ;
%type <pl> templateparameters templateparameterstail;
%type <p> parm valparm rawvalparms valparms valptail ;
@ -1527,7 +1527,7 @@ static void mark_nodes_as_extend(Node *n) {
%type <dtype> definetype def_args etype default_delete deleted_definition explicit_default;
%type <dtype> expr exprnum exprcompound valexpr;
%type <id> ename ;
%type <id> template_decl;
%type <id> less_valparms_greater;
%type <str> type_qualifier ;
%type <id> type_qualifier_raw;
%type <id> idstring idstringopt;
@ -1535,11 +1535,11 @@ static void mark_nodes_as_extend(Node *n) {
%type <str> pragma_arg;
%type <loc> includetype;
%type <type> pointer primitive_type;
%type <decl> declarator direct_declarator notso_direct_declarator parameter_declarator typemap_parameter_declarator;
%type <decl> declarator direct_declarator notso_direct_declarator parameter_declarator plain_declarator;
%type <decl> abstract_declarator direct_abstract_declarator ctor_end;
%type <tmap> typemap_type;
%type <str> idcolon idcolontail idcolonnt idcolontailnt idtemplate stringbrace stringbracesemi;
%type <id> string stringnum wstring;
%type <str> idcolon idcolontail idcolonnt idcolontailnt idtemplate idtemplatetemplate stringbrace stringbracesemi;
%type <str> string stringnum wstring;
%type <tparms> template_parms;
%type <dtype> cpp_end cpp_vend;
%type <intvalue> rename_namewarn;
@ -1648,10 +1648,11 @@ declaration : swig_directive { $$ = $1; }
This is nearly impossible to parse normally. We just let the
first part generate a syntax error and then resynchronize on the
COPERATOR token---discarding the rest of the definition. Ugh.
CONVERSIONOPERATOR token---discarding the rest of the definition. Ugh.
*/
| error COPERATOR {
| error CONVERSIONOPERATOR {
$$ = 0;
skip_decl();
}
@ -1856,7 +1857,7 @@ echo_directive : ECHO HBLOCK {
}
| ECHO string {
char temp[64];
String *s = NewString($2);
String *s = $2;
Replace(s,"$file",cparse_file, DOH_REPLACE_ANY);
sprintf(temp,"%d", cparse_line);
Replace(s,"$line",temp,DOH_REPLACE_ANY);
@ -1961,7 +1962,7 @@ fragment_directive: FRAGMENT LPAREN fname COMMA kwargs RPAREN HBLOCK {
include_directive: includetype options string BEGINFILE {
$1.filename = Copy(cparse_file);
$1.line = cparse_line;
scanner_set_location(NewString($3),1);
scanner_set_location($3,1);
if ($2) {
String *maininput = Getattr($2, "maininput");
if (maininput)
@ -2216,7 +2217,7 @@ pragma_directive : PRAGMA pragma_lang identifier EQUAL pragma_arg {
}
;
pragma_arg : string { $$ = NewString($1); }
pragma_arg : string { $$ = $1; }
| HBLOCK { $$ = $1; }
;
@ -2368,7 +2369,7 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr
scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum RPAREN declarator cpp_const SEMI {
String *val = Len($5) ? NewString($5) : 0;
String *val = Len($5) ? $5 : 0;
new_feature($3, val, 0, $7.id, $7.type, $7.parms, $8.qualifier);
$$ = 0;
scanner_clear_rename();
@ -2380,7 +2381,7 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr
scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum featattr RPAREN declarator cpp_const SEMI {
String *val = Len($5) ? NewString($5) : 0;
String *val = Len($5) ? $5 : 0;
new_feature($3, val, $6, $8.id, $8.type, $8.parms, $9.qualifier);
$$ = 0;
scanner_clear_rename();
@ -2394,7 +2395,7 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr
scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum RPAREN SEMI {
String *val = Len($5) ? NewString($5) : 0;
String *val = Len($5) ? $5 : 0;
new_feature($3, val, 0, 0, 0, 0, 0);
$$ = 0;
scanner_clear_rename();
@ -2406,7 +2407,7 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr
scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum featattr RPAREN SEMI {
String *val = Len($5) ? NewString($5) : 0;
String *val = Len($5) ? $5 : 0;
new_feature($3, val, $6, 0, 0, 0, 0);
$$ = 0;
scanner_clear_rename();
@ -2581,7 +2582,7 @@ tm_tail : COMMA typemap_parm tm_tail {
| empty { $$ = 0;}
;
typemap_parm : type typemap_parameter_declarator {
typemap_parm : type plain_declarator {
Parm *parm;
SwigType_push($1,$2.type);
$$ = new_node("typemapitem");
@ -2783,7 +2784,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
String *symname = Swig_name_make(templnode,0,$3,0,0);
*/
String *symname = $3;
String *symname = NewString($3);
Swig_cparse_template_expand(templnode,symname,temparms,tscope);
Setattr(templnode,"sym:name",symname);
} else {
@ -2918,7 +2919,6 @@ warn_directive : WARN string {
}
;
/* ======================================================================
* C Parsing
* ====================================================================== */
@ -2966,10 +2966,11 @@ c_declaration : c_decl {
Swig_warning(WARN_CPP11_LAMBDA, cparse_file, cparse_line, "Lambda expressions and closures are not fully supported yet.\n");
SWIG_WARN_NODE_END($$);
}
| USING idcolon EQUAL {
skip_decl();
| USING idcolon EQUAL type plain_declarator SEMI {
$$ = new_node("using");
Setattr($$,"name",$2);
SwigType_push($4,$5.type);
Setattr($$,"uname",$4);
add_symbols($$);
SWIG_WARN_NODE_BEGIN($$);
Swig_warning(WARN_CPP11_ALIAS_DECLARATION, cparse_file, cparse_line, "The 'using' keyword in type aliasing is not fully supported yet.\n");
@ -2977,15 +2978,17 @@ c_declaration : c_decl {
$$ = 0; /* TODO - ignored for now */
}
| TEMPLATE LESSTHAN template_parms GREATERTHAN USING idcolon EQUAL identifier {
skip_decl();
| TEMPLATE LESSTHAN template_parms GREATERTHAN USING idcolon EQUAL type plain_declarator SEMI {
$$ = new_node("using");
Setattr($$,"uname",$8);
Setattr($$,"name",$6);
SwigType_push($8,$9.type);
Setattr($$,"uname",$8);
add_symbols($$);
SWIG_WARN_NODE_BEGIN($$);
Swig_warning(WARN_CPP11_ALIAS_TEMPLATE, cparse_file, cparse_line, "The 'using' keyword in template aliasing is not fully supported yet.\n");
SWIG_WARN_NODE_END($$);
$$ = 0; /* TODO - ignored for now */
}
;
@ -3186,7 +3189,9 @@ initializer : def_args {
cpp_alternate_rettype : primitive_type { $$ = $1; }
| TYPE_BOOL { $$ = $1; }
| TYPE_VOID { $$ = $1; }
/*
| TYPE_TYPEDEF template_decl { $$ = NewStringf("%s%s",$1,$2); }
*/
| TYPE_RAW { $$ = $1; }
| idcolon { $$ = $1; }
| decltype { $$ = $1; }
@ -4617,7 +4622,7 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end {
/* C++ type conversion operator */
cpp_conversion_operator : storage_class COPERATOR type pointer LPAREN parms RPAREN cpp_vend {
cpp_conversion_operator : storage_class CONVERSIONOPERATOR type pointer LPAREN parms RPAREN cpp_vend {
$$ = new_node("cdecl");
Setattr($$,"type",$3);
Setattr($$,"name",$2);
@ -4632,7 +4637,7 @@ cpp_conversion_operator : storage_class COPERATOR type pointer LPAREN parms RPAR
Setattr($$,"conversion_operator","1");
add_symbols($$);
}
| storage_class COPERATOR type AND LPAREN parms RPAREN cpp_vend {
| storage_class CONVERSIONOPERATOR type AND LPAREN parms RPAREN cpp_vend {
SwigType *decl;
$$ = new_node("cdecl");
Setattr($$,"type",$3);
@ -4649,7 +4654,7 @@ cpp_conversion_operator : storage_class COPERATOR type pointer LPAREN parms RPAR
Setattr($$,"conversion_operator","1");
add_symbols($$);
}
| storage_class COPERATOR type LAND LPAREN parms RPAREN cpp_vend {
| storage_class CONVERSIONOPERATOR type LAND LPAREN parms RPAREN cpp_vend {
SwigType *decl;
$$ = new_node("cdecl");
Setattr($$,"type",$3);
@ -4667,7 +4672,7 @@ cpp_conversion_operator : storage_class COPERATOR type pointer LPAREN parms RPAR
add_symbols($$);
}
| storage_class COPERATOR type pointer AND LPAREN parms RPAREN cpp_vend {
| storage_class CONVERSIONOPERATOR type pointer AND LPAREN parms RPAREN cpp_vend {
SwigType *decl;
$$ = new_node("cdecl");
Setattr($$,"type",$3);
@ -4686,7 +4691,7 @@ cpp_conversion_operator : storage_class COPERATOR type pointer LPAREN parms RPAR
add_symbols($$);
}
| storage_class COPERATOR type LPAREN parms RPAREN cpp_vend {
| storage_class CONVERSIONOPERATOR type LPAREN parms RPAREN cpp_vend {
String *t = NewStringEmpty();
$$ = new_node("cdecl");
Setattr($$,"type",$3);
@ -4823,7 +4828,9 @@ anon_bitfield_type : primitive_type { $$ = $1;
}
| TYPE_BOOL { $$ = $1; }
| TYPE_VOID { $$ = $1; }
/*
| TYPE_TYPEDEF template_decl { $$ = NewStringf("%s%s",$1,$2); }
*/
| TYPE_RAW { $$ = $1; }
| idcolon {
@ -4834,28 +4841,22 @@ anon_bitfield_type : primitive_type { $$ = $1;
/* ======================================================================
* PRIMITIVES
* ====================================================================== */
storage_class : EXTERN { $$ = "extern"; }
| EXTERN string {
if (strcmp($2,"C") == 0) {
extern_string : EXTERN string {
if (Strcmp($2,"C") == 0) {
$$ = "externc";
} else if (strcmp($2,"C++") == 0) {
} else if (Strcmp($2,"C++") == 0) {
$$ = "extern";
} else {
Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", $2);
$$ = 0;
}
}
| EXTERN string THREAD_LOCAL {
if (strcmp($2,"C") == 0) {
$$ = "externc thread_local";
} else if (strcmp($2,"C++") == 0) {
$$ = "extern thread_local";
} else {
Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", $2);
$$ = 0;
}
}
;
storage_class : EXTERN { $$ = "extern"; }
| extern_string { $$ = $1; }
| extern_string THREAD_LOCAL { $$ = "thread_local"; }
| extern_string TYPEDEF { $$ = "typedef"; }
| STATIC { $$ = "static"; }
| TYPEDEF { $$ = "typedef"; }
| VIRTUAL { $$ = "virtual"; }
@ -4920,6 +4921,7 @@ parm : rawtype parameter_declarator {
Setattr($$,"value",$2.defarg);
}
}
| TEMPLATE LESSTHAN cpptype GREATERTHAN cpptype idcolon def_args {
$$ = NewParmWithoutFileLineInfo(NewStringf("template<class> %s %s", $5,$6), 0);
previousNode = currentNode;
@ -5084,7 +5086,7 @@ parameter_declarator : declarator def_args {
}
;
typemap_parameter_declarator : declarator {
plain_declarator : declarator {
$$ = $1;
if (SwigType_isfunction($1.type)) {
Delete(SwigType_pop_function($1.type));
@ -5794,7 +5796,9 @@ type_right : primitive_type { $$ = $1;
}
| TYPE_BOOL { $$ = $1; }
| TYPE_VOID { $$ = $1; }
/*
| TYPE_TYPEDEF template_decl { $$ = NewStringf("%s%s",$1,$2); }
*/
| c_enum_key idcolon { $$ = NewStringf("enum %s", $2); }
| TYPE_RAW { $$ = $1; }
@ -5977,17 +5981,6 @@ definetype : { /* scanner_check_typedef(); */ } expr {
| default_delete {
$$ = $1;
}
/*
| string {
$$.val = NewString($1);
$$.rawval = NewStringf("\"%(escape)s\"",$$.val);
$$.type = T_STRING;
$$.bitfield = 0;
$$.throws = 0;
$$.throwf = 0;
$$.nexcept = 0;
}
*/
;
default_delete : deleted_definition {
@ -6123,7 +6116,7 @@ expr : valexpr { $$ = $1; }
valexpr : exprnum { $$ = $1; }
| string {
$$.val = NewString($1);
$$.val = $1;
$$.type = T_STRING;
}
| SIZEOF LPAREN type parameter_declarator RPAREN {
@ -6138,7 +6131,7 @@ valexpr : exprnum { $$ = $1; }
}
| exprcompound { $$ = $1; }
| wstring {
$$.val = NewString($1);
$$.val = $1;
$$.rawval = NewStringf("L\"%s\"", $$.val);
$$.type = T_WSTRING;
}
@ -6633,14 +6626,13 @@ mem_initializer : idcolon LPAREN {
}
;
template_decl : LESSTHAN valparms GREATERTHAN {
less_valparms_greater : LESSTHAN valparms GREATERTHAN {
String *s = NewStringEmpty();
SwigType_add_template(s,$2);
$$ = Char(s);
scanner_last_id(1);
}
| empty { $$ = (char*)""; }
;
}
;
/* Identifiers including the C++11 identifiers with special meaning */
identifier : ID { $$ = $1; }
@ -6649,8 +6641,8 @@ identifier : ID { $$ = $1; }
;
idstring : identifier { $$ = $1; }
| default_delete { $$ = $1.val; }
| string { $$ = $1; }
| default_delete { $$ = Char($1.val); }
| string { $$ = Char($1); }
;
idstringopt : idstring { $$ = $1; }
@ -6662,35 +6654,38 @@ idcolon : idtemplate idcolontail {
if (!$$) $$ = NewStringf("%s%s", $1,$2);
Delete($2);
}
| NONID DCOLON idtemplate idcolontail {
| NONID DCOLON idtemplatetemplate idcolontail {
$$ = NewStringf("::%s%s",$3,$4);
Delete($4);
}
| idtemplate {
$$ = NewString($1);
}
| NONID DCOLON idtemplate {
| NONID DCOLON idtemplatetemplate {
$$ = NewStringf("::%s",$3);
}
| OPERATOR {
$$ = NewString($1);
$$ = NewStringf("%s", $1);
}
| OPERATOR less_valparms_greater {
$$ = NewStringf("%s%s", $1, $2);
}
| NONID DCOLON OPERATOR {
$$ = NewStringf("::%s",$3);
}
;
idcolontail : DCOLON idtemplate idcolontail {
idcolontail : DCOLON idtemplatetemplate idcolontail {
$$ = NewStringf("::%s%s",$2,$3);
Delete($3);
}
| DCOLON idtemplate {
| DCOLON idtemplatetemplate {
$$ = NewStringf("::%s",$2);
}
| DCOLON OPERATOR {
$$ = NewStringf("::%s",$2);
}
/* | DCOLON COPERATOR {
/* | DCOLON CONVERSIONOPERATOR {
$$ = NewString($2);
} */
@ -6700,12 +6695,20 @@ idcolontail : DCOLON idtemplate idcolontail {
;
idtemplate : identifier template_decl {
$$ = NewStringf("%s%s",$1,$2);
/* if (Len($2)) {
scanner_last_id(1);
} */
}
idtemplate : identifier {
$$ = NewStringf("%s", $1);
}
| identifier less_valparms_greater {
$$ = NewStringf("%s%s", $1, $2);
}
;
idtemplatetemplate : idtemplate {
$$ = $1;
}
| TEMPLATE identifier less_valparms_greater {
$$ = NewStringf("%s%s", $2, $3);
}
;
/* Identifier, but no templates */
@ -6749,30 +6752,24 @@ idcolontailnt : DCOLON identifier idcolontailnt {
/* Concatenated strings */
string : string STRING {
$$ = (char *) malloc(strlen($1)+strlen($2)+1);
strcpy($$,$1);
strcat($$,$2);
$$ = NewStringf("%s%s", $1, $2);
}
| STRING { $$ = $1;}
| STRING { $$ = NewString($1);}
;
/* Concatenated wide strings: L"str1" L"str2" */
wstring : wstring WSTRING {
$$ = (char *) malloc(strlen($1)+strlen($2)+1);
strcpy($$,$1);
strcat($$,$2);
$$ = NewStringf("%s%s", $1, $2);
}
/* Concatenated wide string and normal string literal: L"str1" "str2" */
/*not all the compilers support this concatenation mode, so perhaps better to postpone it*/
/*| wstring STRING { here $2 comes unescaped, we have to escape it back first via NewStringf("%(escape)s)"
$$ = (char *) malloc(strlen($1)+strlen($2)+1);
strcpy($$,$1);
strcat($$,$2);
$$ = NewStringf("%s%s", $1, $2);
}*/
| WSTRING { $$ = $1;}
| WSTRING { $$ = NewString($1);}
;
stringbrace : string {
$$ = NewString($1);
$$ = $1;
}
| LBRACE {
skip_balanced('{','}');
@ -6888,3 +6885,4 @@ ParmList *Swig_cparse_parms(String *s, Node *file_line_node) {
/* Printf(stdout,"typeparse: '%s' ---> '%s'\n", s, top); */
return top;
}

View file

@ -97,6 +97,15 @@ static int cparse_template_expand(Node *n, String *tname, String *rname, String
Append(cpatchlist, Getattr(n, "sym:name"));
}
}
if (checkAttribute(n, "storage", "friend")) {
String *symname = Getattr(n, "sym:name");
if (symname) {
String *stripped_name = SwigType_templateprefix(symname);
Setattr(n, "sym:name", stripped_name);
Delete(stripped_name);
}
Append(typelist, Getattr(n, "name"));
}
add_parms(Getattr(n, "parms"), cpatchlist, typelist);
add_parms(Getattr(n, "throws"), cpatchlist, typelist);
@ -228,7 +237,7 @@ String *partial_arg(String *s, String *p) {
if (!c) {
return Copy(s);
}
prefix = NewStringWithSize(cp, c - cp);
prefix = NewStringWithSize(cp, (int)(c - cp));
newarg = Copy(s);
Replace(newarg, prefix, "", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
Delete(prefix);

View file

@ -146,7 +146,7 @@ int DohLen(const DOH *obj) {
}
return 0;
} else {
return strlen((char *) obj);
return (int)strlen((char *) obj);
}
}
@ -636,7 +636,7 @@ int DohRead(DOH *obj, void *buffer, int length) {
return -1;
}
/* Hmmm. Not a file. Maybe it's a real FILE */
return fread(buffer, 1, length, (FILE *) b);
return (int)fread(buffer, 1, length, (FILE *) b);
}
/* -----------------------------------------------------------------------------
@ -654,7 +654,7 @@ int DohWrite(DOH *obj, const void *buffer, int length) {
return -1;
}
/* Hmmm. Not a file. Maybe it's a real FILE */
return fwrite(buffer, 1, length, (FILE *) b);
return (int)fwrite(buffer, 1, length, (FILE *) b);
}
/* -----------------------------------------------------------------------------

View file

@ -52,7 +52,7 @@ static int File_read(DOH *fo, void *buffer, int len) {
DohFile *f = (DohFile *) ObjData(fo);
if (f->filep) {
return fread(buffer, 1, len, f->filep);
return (int)fread(buffer, 1, len, f->filep);
} else if (f->fd) {
#ifdef DOH_INTFILE
return read(f->fd, buffer, len);

View file

@ -304,9 +304,9 @@ int DohvPrintf(DOH *so, const char *format, va_list ap) {
}
if (strlen(encoder)) {
enc = encode(encoder, Sval);
maxwidth = maxwidth + strlen(newformat) + Len(enc);
maxwidth = maxwidth + (int)strlen(newformat) + Len(enc);
} else {
maxwidth = maxwidth + strlen(newformat) + Len(Sval);
maxwidth = maxwidth + (int)strlen(newformat) + Len(Sval);
}
*(fmt++) = 's';
*fmt = 0;
@ -320,7 +320,7 @@ int DohvPrintf(DOH *so, const char *format, va_list ap) {
} else {
nbytes += sprintf(stemp, newformat, Data(Sval));
}
if (Writen(so, stemp, strlen(stemp)) < 0)
if (Writen(so, stemp, (int)strlen(stemp)) < 0)
return -1;
if ((DOH *) Sval != doh) {
Delete(Sval);
@ -346,7 +346,7 @@ int DohvPrintf(DOH *so, const char *format, va_list ap) {
} else {
enc = 0;
}
maxwidth = maxwidth + strlen(newformat) + strlen((char *) doh);
maxwidth = maxwidth + (int)strlen(newformat) + (int)strlen((char *) doh);
*(fmt++) = 's';
*fmt = 0;
if ((maxwidth + 1) < OBUFLEN) {
@ -355,7 +355,7 @@ int DohvPrintf(DOH *so, const char *format, va_list ap) {
stemp = (char *) DohMalloc(maxwidth + 1);
}
nbytes += sprintf(stemp, newformat, doh);
if (Writen(so, stemp, strlen(stemp)) < 0)
if (Writen(so, stemp, (int)strlen(stemp)) < 0)
return -1;
if (stemp != obuffer) {
DohFree(stemp);
@ -366,7 +366,7 @@ int DohvPrintf(DOH *so, const char *format, va_list ap) {
} else {
*(fmt++) = *p;
*fmt = 0;
maxwidth = maxwidth + strlen(newformat) + 64;
maxwidth = maxwidth + (int)strlen(newformat) + 64;
/* Only allocate a buffer if it is too big to fit. Shouldn't have to do
this very often */
@ -401,7 +401,7 @@ int DohvPrintf(DOH *so, const char *format, va_list ap) {
default:
break;
}
if (Writen(so, stemp, strlen(stemp)) < 0)
if (Writen(so, stemp, (int)strlen(stemp)) < 0)
return -1;
if (stemp != obuffer)
DohFree(stemp);
@ -414,7 +414,7 @@ int DohvPrintf(DOH *so, const char *format, va_list ap) {
if (state) {
int r;
*fmt = 0;
r = Writen(so, fmt, strlen(fmt));
r = Writen(so, fmt, (int)strlen(fmt));
if (r < 0)
return -1;
nbytes += r;
@ -455,7 +455,7 @@ int DohPrintv(DOHFile * f, ...) {
if (DohCheck(obj)) {
ret += DohDump(obj, f);
} else {
ret += DohWrite(f, obj, strlen((char *) obj));
ret += DohWrite(f, obj, (int)strlen((char *) obj));
}
}
va_end(ap);

View file

@ -687,7 +687,7 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co
return 0;
base = str->str;
tokenlen = strlen(token);
tokenlen = (int)strlen(token);
s = (*match) (base, base, token, tokenlen);
if (!s)
@ -724,7 +724,7 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co
}
first = s;
replen = strlen(rep);
replen = (int)strlen(rep);
delta = (replen - tokenlen);

View file

@ -236,13 +236,17 @@
/* please leave 720-739 free for Scilab */
#define WARN_DOXYGEN_UNKNOWN_COMMAND 740
#define WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT 741
#define WARN_DOXYGEN_COMMAND_EXPECTED 742
#define WARN_DOXYGEN_UNTERMINATED_STRING 743
#define WARN_DOXYGEN_COMMAND_ERROR 744
#define WARN_PYTHON_INDENT_MISMATCH 740
/* please leave 740-749 free for Doxygen */
/* please leave 740-759 free for Python */
#define WARN_DOXYGEN_UNKNOWN_COMMAND 760
#define WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT 761
#define WARN_DOXYGEN_COMMAND_EXPECTED 762
#define WARN_DOXYGEN_UNTERMINATED_STRING 763
#define WARN_DOXYGEN_COMMAND_ERROR 764
/* please leave 760-779 free for Doxygen */
#define WARN_RUBY_WRONG_NAME 801
#define WARN_RUBY_MULTIPLE_INHERITANCE 802

View file

@ -1794,12 +1794,12 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
String *t2 = Getattr(p2, "tmap:typecheck:precedence");
if ((!t1) && (!nodes[i].error)) {
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
"Overloaded method %s not supported (no type checking rule for '%s').\n",
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0));
nodes[i].error = 1;
} else if ((!t2) && (!nodes[j].error)) {
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s not supported (no type checking rule for '%s').\n",
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0));
nodes[j].error = 1;
}

View file

@ -941,6 +941,8 @@ Allocate():
Setattr(inclass, "allocate:default_destructor", "1");
} else if (cplus_mode == PROTECTED) {
Setattr(inclass, "allocate:default_base_destructor", "1");
} else if (cplus_mode == PRIVATE) {
Setattr(inclass, "allocate:private_destructor", "1");
}
} else {
Setattr(inclass, "allocate:has_destructor", "1");

View file

@ -831,7 +831,12 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
if (slot_name && (Strcmp(slot_name, "t") == 0 || Strcmp(slot_name, "T") == 0))
slot_name = NewStringf("t_var");
Printf(f_cl, "\n\t(%s %s)", slot_name, typespec);
if (SwigType_isarray(childType) && SwigType_array_ndim(childType) == 1) {
String *dim = SwigType_array_getdim(childType, 0);
Printf(f_cl, "\n\t(%s %s :count %s)", slot_name, typespec, dim);
Delete(dim);
} else
Printf(f_cl, "\n\t(%s %s)", slot_name, typespec);
Delete(node);
Delete(childType);

View file

@ -34,6 +34,7 @@ class CSHARP:public Language {
File *f_init;
File *f_directors;
File *f_directors_h;
File *f_single_out;
List *filenames_list;
bool proxy_flag; // Flag for generating proxy classes
@ -78,6 +79,7 @@ class CSHARP:public Language {
String *director_method_types; // Director method types
String *director_connect_parms; // Director delegates parameter list for director connect call
String *destructor_call; //C++ destructor call if any
String *output_file; // File name for single file mode. If set all generated code will be written to this file
// Director method stuff:
List *dmethods_seq;
@ -108,6 +110,7 @@ public:
f_init(NULL),
f_directors(NULL),
f_directors_h(NULL),
f_single_out(NULL),
filenames_list(NULL),
proxy_flag(true),
native_function_flag(false),
@ -150,6 +153,7 @@ public:
director_method_types(NULL),
director_connect_parms(NULL),
destructor_call(NULL),
output_file(NULL),
dmethods_seq(NULL),
dmethods_table(NULL),
n_dmethods(0),
@ -244,6 +248,16 @@ public:
} else if (strcmp(argv[i], "-oldvarnames") == 0) {
Swig_mark_arg(i);
old_variable_names = true;
} else if (strcmp(argv[i], "-outfile") == 0) {
if (argv[i + 1]) {
output_file = NewString("");
Printf(output_file, argv[i + 1]);
Swig_mark_arg(i);
Swig_mark_arg(i + 1);
i++;
} else {
Swig_arg_error();
}
} else if (strcmp(argv[i], "-help") == 0) {
Printf(stdout, "%s\n", usage);
}
@ -418,22 +432,12 @@ public:
if (directorsEnabled()) {
// Insert director runtime into the f_runtime file (make it occur before %header section)
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
}
// Generate the intermediary class
{
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), imclass_name);
File *f_im = NewFile(filen, "w", SWIG_output_files());
if (!f_im) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
}
Append(filenames_list, Copy(filen));
Delete(filen);
filen = NULL;
// Start writing out the intermediary class file
emitBanner(f_im);
File *f_im = getOutputFile(SWIG_output_directory(), imclass_name);
addOpenNamespace(0, f_im);
@ -461,23 +465,14 @@ public:
Printf(f_im, "}\n");
addCloseNamespace(0, f_im);
Delete(f_im);
if (f_im != f_single_out)
Delete(f_im);
f_im = NULL;
}
// Generate the C# module class
{
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), module_class_name);
File *f_module = NewFile(filen, "w", SWIG_output_files());
if (!f_module) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
}
Append(filenames_list, Copy(filen));
Delete(filen);
filen = NULL;
// Start writing out the module class file
emitBanner(f_module);
File *f_module = getOutputFile(SWIG_output_directory(), module_class_name);
addOpenNamespace(0, f_module);
@ -513,7 +508,9 @@ public:
Printf(f_module, "}\n");
addCloseNamespace(0, f_module);
Delete(f_module);
if (f_module != f_single_out)
Delete(f_module);
f_module = NULL;
}
if (upcasts_code)
@ -612,6 +609,12 @@ public:
f_directors_h = NULL;
}
if (f_single_out) {
Dump(f_single_out, f_begin);
Delete(f_single_out);
f_single_out = NULL;
}
Dump(f_wrappers, f_begin);
Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
@ -634,6 +637,50 @@ public:
Printf(f, "//------------------------------------------------------------------------------\n\n");
}
/* -----------------------------------------------------------------------------
* getOutputFile()
*
* Prepares a File object by creating the file in the file system and
* writing the banner for auto-generated files to it (emitBanner).
* If '-outfile' is provided (single file mode) the supplied parameters will
* be ignored and the returned file will always be:
* <outdir>/<outfile>
* Otherwise the file will be:
* <dir>/<name>.cs
* ----------------------------------------------------------------------------- */
File *getOutputFile(const String *dir, const String *name) {
if (output_file) {
if (!f_single_out) {
String *filen = NewStringf("%s%s", SWIG_output_directory(), output_file);
f_single_out = NewFile(filen, "w", SWIG_output_files());
if (!f_single_out) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
}
Append(filenames_list, Copy(filen));
Delete(filen);
filen = NULL;
emitBanner(f_single_out);
}
return f_single_out;
} else {
String *filen = NewStringf("%s%s.cs", dir, name);
File *f = NewFile(filen, "w", SWIG_output_files());
if (!f) {
FileErrorDisplay(f);
SWIG_exit(EXIT_FAILURE);
}
Append(filenames_list, Copy(filen));
Delete(filen);
filen = NULL;
emitBanner(f);
return f;
}
}
/*-----------------------------------------------------------------------
* Add new director upcall signature
*----------------------------------------------------------------------*/
@ -1085,7 +1132,7 @@ public:
scope = NewString("");
if (nspace)
Printf(scope, "%s", nspace);
if (Node* cls = getCurrentClass()) {
if (Node *cls = getCurrentClass()) {
if (Node *outer = Getattr(cls, "nested:outer")) {
String *outerClassesPrefix = Copy(Getattr(outer, "sym:name"));
for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) {
@ -1197,18 +1244,7 @@ public:
} else {
// Global enums are defined in their own file
String *output_directory = outputDirectory(nspace);
String *filen = NewStringf("%s%s.cs", output_directory, symname);
File *f_enum = NewFile(filen, "w", SWIG_output_files());
if (!f_enum) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
}
Append(filenames_list, Copy(filen));
Delete(filen);
filen = NULL;
// Start writing out the enum file
emitBanner(f_enum);
File *f_enum = getOutputFile(output_directory, symname);
addOpenNamespace(nspace, f_enum);
@ -1216,7 +1252,9 @@ public:
"\n", enum_code, "\n", NIL);
addCloseNamespace(nspace, f_enum);
Delete(f_enum);
if (f_enum != f_single_out)
Delete(f_enum);
f_enum = NULL;
Delete(output_directory);
}
} else {
@ -1641,7 +1679,7 @@ public:
String *proxyclassname = Getattr(n, "classtypeobj");
String *baseclassname = Getattr(base.item, "name");
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
base = Next(base);
}
}
@ -1916,21 +1954,9 @@ public:
}
}
// Each outer proxy class goes into a separate file
if (!has_outerclass) {
String *output_directory = outputDirectory(nspace);
String *filen = NewStringf("%s%s.cs", output_directory, proxy_class_name);
f_proxy = NewFile(filen, "w", SWIG_output_files());
if (!f_proxy) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
}
Append(filenames_list, Copy(filen));
Delete(filen);
filen = NULL;
// Start writing out the proxy class file
emitBanner(f_proxy);
f_proxy = getOutputFile(output_directory, proxy_class_name);
addOpenNamespace(nspace, f_proxy);
}
@ -1990,7 +2016,8 @@ public:
if (!has_outerclass) {
Printf(f_proxy, "}\n");
addCloseNamespace(nspace, f_proxy);
Delete(f_proxy);
if (f_proxy != f_single_out)
Delete(f_proxy);
f_proxy = NULL;
} else {
for (int i = 0; i < nesting_depth; ++i)
@ -2003,7 +2030,7 @@ public:
good place to put this code, since Abstract Base Classes (ABCs) can and should have
downcasts, making the constructorHandler() a bad place (because ABCs don't get to
have constructors emitted.) */
if (GetFlag(n, "feature:javadowncast")) {
if (GetFlag(n, "feature:csdowncast")) {
String *downcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGDowncast");
String *wname = Swig_name_wrapper(downcast_method);
@ -3215,18 +3242,7 @@ public:
Setline(n, line_number);
String *swigtype = NewString("");
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), classname);
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
if (!f_swigtype) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
}
Append(filenames_list, Copy(filen));
Delete(filen);
filen = NULL;
// Start writing out the type wrapper class file
emitBanner(f_swigtype);
File *f_swigtype = getOutputFile(SWIG_output_directory(), classname);
addOpenNamespace(0, f_swigtype);
@ -3261,8 +3277,9 @@ public:
Printv(f_swigtype, swigtype, NIL);
addCloseNamespace(0, f_swigtype);
Delete(f_swigtype);
if (f_swigtype != f_single_out)
Delete(f_swigtype);
f_swigtype = NULL;
Delete(swigtype);
Delete(n);
}
@ -3358,7 +3375,7 @@ public:
/* -----------------------------------------------------------------------------
* outputDirectory()
*
* Return the directory to use for generating Java classes/enums and create the
* Return the directory to use for generating C# classes/enums and create the
* subdirectory (does not create if language specific outdir does not exist).
* ----------------------------------------------------------------------------- */
@ -3498,7 +3515,7 @@ public:
* classDirectorMethod()
*
* Emit a virtual director method to pass a method call on to the
* underlying Java object.
* underlying C# object.
*
* --------------------------------------------------------------- */
@ -3659,7 +3676,7 @@ public:
if (!ignored_method)
Printf(w->code, "} else {\n");
/* Go through argument list, convert from native to Java */
/* Go through argument list, convert from native to C# */
for (i = 0, p = l; p; ++i) {
/* Is this superfluous? */
while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
@ -4284,4 +4301,5 @@ C# Options (available with -csharp)\n\
-noproxy - Generate the low-level functional interface instead\n\
of proxy classes\n\
-oldvarnames - Old intermediary method names for variable wrappers\n\
-outfile <file> - Write all C# into a single <file> located in the output directory\n\
\n";

View file

@ -508,6 +508,7 @@ public:
if (directorsEnabled()) {
// Insert director runtime into the f_runtime file (before %header section).
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
}

File diff suppressed because it is too large Load diff

View file

@ -508,6 +508,7 @@ public:
if (directorsEnabled()) {
// Insert director runtime into the f_runtime file (make it occur before %header section)
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
}
// Generate the intermediary class
@ -1892,7 +1893,7 @@ public:
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. "
"Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
"Perhaps you need one of the 'replace' or 'notderived' attributes in the javabase typemap?\n", typemap_lookup_type, pure_baseclass);
}
// Pure Java interfaces
@ -3569,7 +3570,7 @@ public:
Printf(f_runtime, "namespace Swig {\n");
Printf(f_runtime, " namespace {\n");
Printf(f_runtime, " jclass jclass_%s = NULL;\n", imclass_name);
Printf(f_runtime, " jmethodID director_methids[%d];\n", n_methods);
Printf(f_runtime, " jmethodID director_method_ids[%d];\n", n_methods);
Printf(f_runtime, " }\n");
Printf(f_runtime, "}\n");
@ -3586,8 +3587,8 @@ public:
Printf(w->code, "Swig::jclass_%s = (jclass) jenv->NewGlobalRef(jcls);\n", imclass_name);
Printf(w->code, "if (!Swig::jclass_%s) return;\n", imclass_name);
Printf(w->code, "for (i = 0; i < (int) (sizeof(methods)/sizeof(methods[0])); ++i) {\n");
Printf(w->code, " Swig::director_methids[i] = jenv->GetStaticMethodID(jcls, methods[i].method, methods[i].signature);\n");
Printf(w->code, " if (!Swig::director_methids[i]) return;\n");
Printf(w->code, " Swig::director_method_ids[i] = jenv->GetStaticMethodID(jcls, methods[i].method, methods[i].signature);\n");
Printf(w->code, " if (!Swig::director_method_ids[i]) return;\n");
Printf(w->code, "}\n");
Printf(w->code, "}\n");
@ -4241,7 +4242,7 @@ public:
if (!is_void)
Printf(w->code, "jresult = (%s) ", c_ret_type);
Printf(w->code, "jenv->%s(Swig::jclass_%s, Swig::director_methids[%s], %s);\n", methop, imclass_name, methid, jupcall_args);
Printf(w->code, "jenv->%s(Swig::jclass_%s, Swig::director_method_ids[%s], %s);\n", methop, imclass_name, methid, jupcall_args);
// Generate code to handle any Java exception thrown by director delegation
directorExceptHandler(n, catches_list ? catches_list : throw_parm_list, w);
@ -4630,7 +4631,7 @@ public:
Printf(f_directors_h, " return (n < %d ? swig_override[n] : false);\n", n_methods);
Printf(f_directors_h, " }\n");
Printf(f_directors_h, "protected:\n");
Printf(f_directors_h, " bool swig_override[%d];\n", n_methods);
Printf(f_directors_h, " Swig::BoolArray<%d> swig_override;\n", n_methods);
/* Emit the code to look up the class's methods, initialize the override array */

View file

@ -943,7 +943,7 @@ int Language::cDeclaration(Node *n) {
}
if (!validIdentifier(symname)) {
Swig_warning(WARN_LANG_IDENTIFIER, input_file, line_number, "Can't wrap '%s' unless renamed to a valid identifier.\n", symname);
Swig_warning(WARN_LANG_IDENTIFIER, input_file, line_number, "Can't wrap '%s' unless renamed to a valid identifier.\n", SwigType_namestr(symname));
return SWIG_NOWRAP;
}
@ -3699,14 +3699,26 @@ int Language::abstractClassTest(Node *n) {
return 0;
if (Getattr(n, "allocate:nonew"))
return 1;
// A class cannot be instantiated if one of its bases has a private destructor
// Note that if the above does not hold the class can be instantiated if its own destructor is private
List *bases = Getattr(n, "bases");
if (bases) {
for (int i = 0; i < Len(bases); i++) {
Node *b = Getitem(bases, i);
if (GetFlag(b, "allocate:private_destructor"))
return 1;
}
}
/* now check for the rest */
List *abstracts = Getattr(n, "abstracts");
if (!abstracts)
return 0;
int labs = Len(abstracts);
#ifdef SWIG_DEBUG
List *bases = Getattr(n, "allbases");
Printf(stderr, "testing %s %d %d\n", Getattr(n, "name"), labs, Len(bases));
List *allbases = Getattr(n, "allbases");
Printf(stderr, "testing %s %d %d\n", Getattr(n, "name"), labs, Len(allbases));
#endif
if (!labs)
return 0; /*strange, but need to be fixed */

View file

@ -131,8 +131,8 @@ static const char *usage3 = (const char *) "\
static const char *usage4 = (const char *) "\
-O - Enable the optimization options: \n\
-fastdispatch -fvirtual \n\
-o <outfile> - Set name of the output file to <outfile>\n\
-oh <headfile> - Set name of the output header file to <headfile>\n\
-o <outfile> - Set name of C/C++ output file to <outfile>\n\
-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\
@ -595,7 +595,7 @@ void SWIG_getoptions(int argc, char *argv[]) {
Swig_filename_correct(outfile_name);
if (!outfile_name_h || !dependencies_file) {
char *ext = strrchr(Char(outfile_name), '.');
String *basename = ext ? NewStringWithSize(Char(outfile_name), Char(ext) - Char(outfile_name)) : NewString(outfile_name);
String *basename = ext ? NewStringWithSize(Char(outfile_name), (int)(Char(ext) - Char(outfile_name))) : NewString(outfile_name);
if (!dependencies_file) {
dependencies_file = NewStringf("%s.%s", basename, depends_extension);
}
@ -899,7 +899,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
String *vers = NewString("SWIG_VERSION 0x");
int count = 0;
while (token) {
int len = strlen(token);
int len = (int)strlen(token);
assert(len == 1 || len == 2);
Printf(vers, "%s%s", (len == 1) ? "0" : "", token);
token = strtok(NULL, ".");
@ -1221,7 +1221,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
Printf(stdout, "debug-top stage 3\n");
Swig_print_tree(top);
}
if (dump_module & STAGE3) {
if (top && (dump_module & STAGE3)) {
Printf(stdout, "debug-module stage 3\n");
Swig_print_tree(Getattr(top, "module"));
}
@ -1230,7 +1230,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
Printf(stdout, "Generating wrappers...\n");
}
if (dump_classes) {
if (top && dump_classes) {
Hash *classes = Getattr(top, "classes");
if (classes) {
Printf(stdout, "Classes\n");

View file

@ -340,6 +340,8 @@ static void insertNodeAfter(Node *n, Node *c) {
}
void Swig_nested_name_unnamed_c_structs(Node *n) {
if (!n)
return;
if (!classhash)
classhash = Getattr(n, "classes");
Node *c = firstChild(n);
@ -427,6 +429,8 @@ static void remove_outer_class_reference(Node *n) {
}
void Swig_nested_process_classes(Node *n) {
if (!n)
return;
Node *c = firstChild(n);
while (c) {
Node *next = nextSibling(c);

View file

@ -325,6 +325,7 @@ public:
if (directorsEnabled()) {
// Insert director runtime into the f_runtime file (make it occur before %header section)
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
}
@ -619,9 +620,9 @@ public:
}
/* if the object is a director, and the method call originated from its
* underlying python object, resolve the call by going up the c++
* inheritance chain. otherwise try to resolve the method in python.
* without this check an infinite loop is set up between the director and
* underlying ocaml object, resolve the call by going up the c++
* inheritance chain. otherwise try to resolve the method in ocaml.
* without this check an infinite loop is set up between the director and
* shadow class method calls.
*/
@ -989,7 +990,7 @@ public:
find_marker += strlen("(*Stream:");
if (next) {
int num_chars = next - find_marker;
int num_chars = (int)(next - find_marker);
String *stream_name = NewString(find_marker);
Delslice(stream_name, num_chars, Len(stream_name));
File *fout = Swig_filebyname(stream_name);
@ -1000,7 +1001,7 @@ public:
if (!following)
following = next + strlen(next);
String *chunk = NewString(next);
Delslice(chunk, following - next, Len(chunk));
Delslice(chunk, (int)(following - next), Len(chunk));
Printv(fout, chunk, NIL);
}
}

View file

@ -228,8 +228,10 @@ public:
if (Len(docs))
emit_doc_texinfo();
if (directorsEnabled())
if (directorsEnabled()) {
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
}
Printf(f_init, "return true;\n}\n");
Printf(s_global_tab, "{0,0,0,0,0}\n};\n");
@ -1385,7 +1387,7 @@ public:
SwigType_namestr(name));
}
} else {
// attach typemaps to arguments (C/C++ -> Python)
// attach typemaps to arguments (C/C++ -> Octave)
String *parse_args = NewString("");
Swig_director_parms_fixup(l);

View file

@ -158,12 +158,12 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
String *t2 = Getattr(p2, "tmap:typecheck:precedence");
if ((!t1) && (!nodes[i].error)) {
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
"Overloaded method %s not supported (no type checking rule for '%s').\n",
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0));
nodes[i].error = 1;
} else if ((!t2) && (!nodes[j].error)) {
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s not supported (no type checking rule for '%s').\n",
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0));
nodes[j].error = 1;
}

View file

@ -13,8 +13,6 @@
#include "swigmod.h"
#include "cparse.h"
static int treduce = SWIG_cparse_template_reduce(0);
#include <ctype.h>
static const char *usage = "\
@ -470,6 +468,7 @@ public:
if (directorsEnabled()) {
// Insert director runtime into the f_runtime file (make it occur before %header section)
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
}
@ -2254,7 +2253,7 @@ public:
if (SwigType_isreference(ptype)) {
Insert(ppname, 0, "&");
}
/* if necessary, cast away const since Python doesn't support it! */
/* if necessary, cast away const since Perl doesn't support it! */
if (SwigType_isconst(nptype)) {
nonconst = NewStringf("nc_tmp_%s", pname);
String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(ptype, 0), ppname);

View file

@ -190,7 +190,7 @@ class PHP : public Language {
p = strchr(p, '"');
if (p) {
++p;
Insert(action, p - Char(action), " TSRMLS_CC");
Insert(action, (int)(p - Char(action)), " TSRMLS_CC");
}
}
}
@ -473,6 +473,7 @@ public:
if (directorsEnabled()) {
// Insert director runtime
Swig_insert_file("director_common.swg", s_header);
Swig_insert_file("director.swg", s_header);
}
@ -1721,7 +1722,7 @@ public:
Printf(output, "\t\t\treturn new %s%s($r);\n", prefix, Getattr(classLookup(d), "sym:name"));
} else {
Printf(output, "\t\t\t$c = new stdClass();\n");
Printf(output, "\t\t\t$c->"SWIG_PTR" = $r;\n");
Printf(output, "\t\t\t$c->" SWIG_PTR " = $r;\n");
Printf(output, "\t\t\treturn $c;\n");
}
Printf(output, "\t\t}\n\t\treturn $r;\n");
@ -2423,7 +2424,7 @@ done:
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
const char * p = Char(target);
const char * comma = strchr(p, ',');
size_t ins = comma ? comma - p : Len(target) - 1;
int ins = comma ? (int)(comma - p) : Len(target) - 1;
Insert(target, ins, " TSRMLS_DC");
call = Swig_csuperclass_call(0, basetype, superparms);
@ -2442,7 +2443,7 @@ done:
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
const char * p = Char(target);
const char * comma = strchr(p, ',');
size_t ins = comma ? comma - p : Len(target) - 1;
int ins = comma ? (int)(comma - p) : Len(target) - 1;
Insert(target, ins, " TSRMLS_DC");
Printf(f_directors_h, " %s;\n", target);

View file

@ -13,9 +13,6 @@
#include "swigmod.h"
#include "cparse.h"
static int treduce = SWIG_cparse_template_reduce(0);
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
@ -993,6 +990,7 @@ public:
if (directorsEnabled()) {
// Insert director runtime into the f_runtime file (make it occur before %header section)
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
}
@ -1212,7 +1210,7 @@ public:
const char *py3_end1 = Strchr(rpkg, '.');
if (!py3_end1)
py3_end1 = (Char(rpkg)) + Len(rpkg);
py3_rlen1 = py3_end1 - (Char(rpkg));
py3_rlen1 = (int)(py3_end1 - Char(rpkg));
} else {
rpkg = NewString("");
}
@ -1389,7 +1387,7 @@ public:
* pythoncode() - Output python code into the shadow file
* ------------------------------------------------------------ */
String *pythoncode(String *code, const_String_or_char_ptr indent) {
String *pythoncode(String *code, const_String_or_char_ptr indent, String * file, int line) {
String *out = NewString("");
String *temp;
char *t;
@ -1407,38 +1405,91 @@ public:
/* Split the input text into lines */
List *clist = SplitLines(temp);
Delete(temp);
int initial = 0;
String *s = 0;
Iterator si;
/* Get the initial indentation */
for (si = First(clist); si.item; si = Next(si)) {
s = si.item;
if (Len(s)) {
char *c = Char(s);
while (*c) {
if (!isspace(*c))
break;
initial++;
c++;
}
if (*c && !isspace(*c)) {
break;
} else {
initial = 0;
}
// Line number within the pythoncode.
int py_line = 0;
String * initial = 0;
Iterator si;
/* Get the initial indentation. Skip lines which only contain whitespace
* and/or a comment, as the indentation of those doesn't matter:
*
* A logical line that contains only spaces, tabs, formfeeds and
* possibly a comment, is ignored (i.e., no NEWLINE token is
* generated).
*
* see:
* https://docs.python.org/2/reference/lexical_analysis.html#blank-lines
* https://docs.python.org/3/reference/lexical_analysis.html#blank-lines
*/
for (si = First(clist); si.item; si = Next(si), ++py_line) {
const char *c = Char(si.item);
int i;
for (i = 0; isspace((unsigned char)c[i]); i++) {
// Scan forward until we find a non-space (which may be a nul byte).
}
char ch = c[i];
if (ch && ch != '#') {
// Found a line with actual content.
initial = NewStringWithSize(c, i);
break;
}
if (ch) {
Printv(out, indent, c, NIL);
}
Putc('\n', out);
}
while (si.item) {
s = si.item;
if (Len(s) > initial) {
char *c = Char(s);
c += initial;
// Process remaining lines.
for ( ; si.item; si = Next(si), ++py_line) {
const char *c = Char(si.item);
// If no prefixed line was found, the above loop should have completed.
assert(initial);
int i;
for (i = 0; isspace((unsigned char)c[i]); i++) {
// Scan forward until we find a non-space (which may be a nul byte).
}
char ch = c[i];
if (!ch) {
// Line is just whitespace - emit an empty line.
Putc('\n', out);
continue;
}
if (ch == '#') {
// Comment - the indentation doesn't matter to python, but try to
// adjust the whitespace for the benefit of human readers (though SWIG
// currently seems to always remove any whitespace before a '#' before
// we get here, in which case we'll just leave the comment at the start
// of the line).
if (i >= Len(initial)) {
Printv(out, indent, NIL);
}
Printv(out, c + i, "\n", NIL);
continue;
}
if (i < Len(initial)) {
// There's non-whitespace in the initial prefix of this line.
Swig_error(file, line, "Line indented less than expected (line %d of pythoncode)\n", py_line);
Printv(out, indent, c, "\n", NIL);
} else {
Printv(out, "\n", NIL);
if (memcmp(c, Char(initial), Len(initial)) == 0) {
// Prefix matches initial, so just remove it.
Printv(out, indent, c + Len(initial), "\n", NIL);
continue;
}
Swig_warning(WARN_PYTHON_INDENT_MISMATCH,
file, line, "Whitespace prefix doesn't match (line %d of pythoncode)\n", py_line);
// To avoid gratuitously breaking interface files which worked with
// SWIG <= 3.0.5, we remove a prefix of the same number of bytes for
// lines which start with different whitespace to the line we got
// 'initial' from.
Printv(out, indent, c + Len(initial), "\n", NIL);
}
si = Next(si);
}
Delete(clist);
return out;
@ -1811,10 +1862,17 @@ public:
// Only do the autodoc if there isn't a docstring for the class
String *str = Getattr(n, "feature:docstring");
if (!str || Len(str) == 0) {
if (CPlusPlus) {
Printf(doc, "Proxy of C++ %s class", real_classname);
if (builtin) {
String *name = Getattr(n, "name");
String *rname = add_explicit_scope(SwigType_namestr(name));
Printf(doc, "%s", rname);
Delete(rname);
} else {
Printf(doc, "Proxy of C %s struct", real_classname);
if (CPlusPlus) {
Printf(doc, "Proxy of C++ %s class", real_classname);
} else {
Printf(doc, "Proxy of C %s struct", real_classname);
}
}
}
}
@ -1926,7 +1984,7 @@ public:
// Avoid unnecessary string allocation in the common case when we don't
// need to remove any suffix.
return *end == '\0' ? v : NewStringWithSize(s, end - s);
return *end == '\0' ? v : NewStringWithSize(s, (int)(end - s));
}
return NIL;
@ -1937,9 +1995,12 @@ public:
* Check if string v can be a Python value literal or a
* constant. Return NIL if it isn't.
* ------------------------------------------------------------ */
String *convertValue(String *v, SwigType *t) {
String *convertValue(String *v, SwigType *type) {
const char *const s = Char(v);
char *end;
String *result = NIL;
bool fail = false;
SwigType *resolved_type = 0;
// Check if this is a number in any base.
long value = strtol(s, &end, 0);
@ -1948,93 +2009,108 @@ public:
if (errno == ERANGE) {
// There was an overflow, we could try representing the value as Python
// long integer literal, but for now don't bother with it.
return NIL;
}
fail = true;
} else {
if (*end != '\0') {
// If there is a suffix after the number, we can safely ignore any
// combination of "l" and "u", but not anything else (again, stuff like
// "LL" could be handled, but we don't bother to do it currently).
bool seen_long = false;
for (char* p = end; *p != '\0'; ++p) {
switch (*p) {
case 'l':
case 'L':
// Bail out on "LL".
if (seen_long) {
fail = true;
break;
}
seen_long = true;
break;
if (*end != '\0') {
// If there is a suffix after the number, we can safely ignore any
// combination of "l" and "u", but not anything else (again, stuff like
// "LL" could be handled, but we don't bother to do it currently).
bool seen_long = false;
for (char* p = end; *p != '\0'; ++p) {
switch (*p) {
case 'l':
case 'L':
// Bail out on "LL".
if (seen_long)
return NIL;
seen_long = true;
break;
case 'u':
case 'U':
break;
case 'u':
case 'U':
break;
default:
// Except that our suffix could actually be the fractional part of
// a floating point number, so we still have to check for this.
return convertDoubleValue(v);
}
}
}
// Deal with the values starting with 0 first as they can be octal or
// hexadecimal numbers or even pointers.
if (s[0] == '0') {
if (Len(v) == 1) {
// This is just a lone 0, but it needs to be represented differently
// in Python depending on whether it's a zero or a null pointer.
if (SwigType_ispointer(t))
return NewString("None");
else
return v;
} else if (s[1] == 'x' || s[1] == 'X') {
// This must have been a hex number, we can use it directly in Python,
// so nothing to do here.
} else {
// This must have been an octal number, we have to change its prefix
// to be "0o" in Python 3 only (and as long as we still support Python
// 2.5, this can't be done unconditionally).
if (py3) {
if (end - s > 1) {
String *res = NewString("0o");
Append(res, NewStringWithSize(s + 1, end - s - 1));
return res;
default:
// Except that our suffix could actually be the fractional part of
// a floating point number, so we still have to check for this.
result = convertDoubleValue(v);
}
}
}
}
// Avoid unnecessary string allocation in the common case when we don't
// need to remove any suffix.
return *end == '\0' ? v : NewStringWithSize(s, end - s);
if (!fail) {
// Allow integers as the default value for a bool parameter.
resolved_type = SwigType_typedef_resolve_all(type);
if (Cmp(resolved_type, "bool") == 0) {
result = NewString(value ? "True" : "False");
} else {
// Deal with the values starting with 0 first as they can be octal or
// hexadecimal numbers or even pointers.
if (s[0] == '0') {
if (Len(v) == 1) {
// This is just a lone 0, but it needs to be represented differently
// in Python depending on whether it's a zero or a null pointer.
if (SwigType_ispointer(resolved_type))
result = NewString("None");
else
result = v;
} else if (s[1] == 'x' || s[1] == 'X') {
// This must have been a hex number, we can use it directly in Python,
// so nothing to do here.
} else {
// This must have been an octal number, we have to change its prefix
// to be "0o" in Python 3 only (and as long as we still support Python
// 2.5, this can't be done unconditionally).
if (py3) {
if (end - s > 1) {
result = NewString("0o");
Append(result, NewStringWithSize(s + 1, (int)(end - s - 1)));
}
}
}
}
// Avoid unnecessary string allocation in the common case when we don't
// need to remove any suffix.
if (!result)
result = *end == '\0' ? v : NewStringWithSize(s, (int)(end - s));
}
}
}
}
// Check if this is a floating point number (notice that it wasn't
// necessarily parsed as a long above, consider e.g. ".123").
if (String *res = convertDoubleValue(v)) {
return res;
}
if (!fail && !result) {
result = convertDoubleValue(v);
if (!result) {
if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
result = NewString("True");
else if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
result = NewString("False");
else if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0) {
if (!resolved_type)
resolved_type = SwigType_typedef_resolve_all(type);
result = SwigType_ispointer(resolved_type) ? NewString("None") : NewString("0");
}
if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
return NewString("True");
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
return NewString("False");
if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
return SwigType_ispointer(t) ? NewString("None") : NewString("0");
// This could also be an enum type, default value of which could be
// representable in Python if it doesn't include any scope (which could,
// but currently is not, translated).
if (!Strchr(s, ':')) {
Node *lookup = Swig_symbol_clookup(v, 0);
if (lookup) {
if (Cmp(Getattr(lookup, "nodeType"), "enumitem") == 0)
return Getattr(lookup, "sym:name");
// This could also be an enum type, default value of which could be
// representable in Python if it doesn't include any scope (which could,
// but currently is not, translated).
else if (!Strchr(s, ':')) {
Node *lookup = Swig_symbol_clookup(v, 0);
if (lookup) {
if (Cmp(Getattr(lookup, "nodeType"), "enumitem") == 0)
result = Getattr(lookup, "sym:name");
}
}
}
}
return NIL;
Delete(resolved_type);
return result;
}
/* ------------------------------------------------------------
@ -2047,34 +2123,40 @@ public:
* at C++ code level where they can always be handled.
* ------------------------------------------------------------ */
bool is_representable_as_pyargs(Node *n) {
bool is_representable = true;
ParmList *plist = CopyParmList(Getattr(n, "parms"));
Swig_typemap_attach_parms("default", plist, NULL);
Parm *p;
Parm *pnext;
for (p = plist; p; p = pnext) {
pnext = NIL;
pnext = nextSibling(p);
String *tm = Getattr(p, "tmap:in");
if (tm) {
pnext = Getattr(p, "tmap:in:next");
Parm *in_next = Getattr(p, "tmap:in:next");
if (in_next)
pnext = in_next;
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
continue;
}
}
if (!pnext) {
pnext = nextSibling(p);
}
// "default" typemap can contain arbitrary C++ code, so while it could, in
// principle, be possible to examine it and check if it's just something
// simple of the form "$1 = expression" and then use convertValue() to
// check if expression can be used in Python, but for now we just
// pessimistically give up and prefer to handle this at C++ level only.
if (Getattr(p, "tmap:default"))
return false;
if (String *value = Getattr(p, "value")) {
String *type = Getattr(p, "type");
if (!convertValue(value, type)) {
is_representable = false;
break;
}
if (!convertValue(value, type))
return false;
}
}
return is_representable;
return true;
}
@ -2116,8 +2198,17 @@ public:
if (nn)
n = nn;
/* For overloaded function, just use *args */
if (is_real_overloaded(n) || GetFlag(n, "feature:compactdefaultargs") || !is_representable_as_pyargs(n)) {
/* We prefer to explicitly list all parameters of the C function in the
generated Python code as this makes the function more convenient to use,
however in some cases we must replace the real parameters list with just
the catch all "*args". This happens when:
1. The function is overloaded as Python doesn't support this.
2. We were explicitly asked to use the "compact" arguments form.
3. We were explicitly asked to use default args from C via the "python:cdefaultargs" feature.
4. One of the default argument values can't be represented in Python.
*/
if (is_real_overloaded(n) || GetFlag(n, "feature:compactdefaultargs") || GetFlag(n, "feature:python:cdefaultargs") || !is_representable_as_pyargs(n)) {
String *parms = NewString("");
if (in_class)
Printf(parms, "self, ");
@ -2256,10 +2347,10 @@ public:
if (have_docstring(n))
Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC), "\n", NIL);
if (have_pythonprepend(n))
Printv(f_dest, pythoncode(pythonprepend(n), tab4), "\n", NIL);
Printv(f_dest, pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n)), "\n", NIL);
if (have_pythonappend(n)) {
Printv(f_dest, tab4 "val = ", funcCall(name, callParms), "\n", NIL);
Printv(f_dest, pythoncode(pythonappend(n), tab4), "\n", NIL);
Printv(f_dest, pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n)), "\n", NIL);
Printv(f_dest, tab4 "return val\n", NIL);
} else {
Printv(f_dest, tab4 "return ", funcCall(name, callParms), "\n", NIL);
@ -2746,14 +2837,12 @@ public:
Printv(f->locals, " char * kwnames[] = ", kwargs, ";\n", NIL);
}
if (use_parse || allow_kwargs || !modernargs) {
if (builtin && in_class && tuple_arguments == 0) {
Printf(parse_args, " if (args && PyTuple_Check(args) && PyTuple_GET_SIZE(args) > 0) SWIG_fail;\n");
} else {
Printf(parse_args, ":%s\"", iname);
Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL);
funpack = 0;
}
if (builtin && !funpack && in_class && tuple_arguments == 0) {
Printf(parse_args, " if (args && PyTuple_Check(args) && PyTuple_GET_SIZE(args) > 0) SWIG_exception_fail(SWIG_TypeError, \"%s takes no arguments\");\n", iname);
} else if (use_parse || allow_kwargs || !modernargs) {
Printf(parse_args, ":%s\"", iname);
Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL);
funpack = 0;
} else {
Clear(parse_args);
if (funpack) {
@ -3120,6 +3209,17 @@ public:
}
/* If this is a builtin type, create a PyGetSetDef entry for this member variable. */
if (builtin) {
const char *memname = "__dict__";
Hash *h = Getattr(builtin_getset, memname);
if (!h) {
h = NewHash();
Setattr(builtin_getset, memname, h);
Delete(h);
}
Setattr(h, "getter", "SwigPyObject_get___dict__");
}
if (builtin_getter) {
String *memname = Getattr(n, "membervariableHandler:sym:name");
if (!memname)
@ -3853,7 +3953,7 @@ public:
else
quoted_symname = NewStringf("\"%s\"", symname);
}
String *quoted_rname = NewStringf("\"%s\"", rname);
String *quoted_tp_doc_str = NewStringf("\"%s\"", getSlot(n, "feature:python:tp_doc"));
char const *tp_init = builtin_tp_init ? Char(builtin_tp_init) : Swig_directorclass(n) ? "0" : "SwigPyBuiltin_BadInit";
String *tp_flags = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES");
String *py3_tp_flags = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE");
@ -3904,7 +4004,7 @@ public:
printSlot(f, tp_doc, "tp_doc");
Delete(tp_doc);
} else {
printSlot(f, quoted_rname, "tp_doc");
printSlot(f, quoted_tp_doc_str, "tp_doc");
}
printSlot(f, getSlot(n, "feature:python:tp_traverse"), "tp_traverse", "traverseproc");
printSlot(f, getSlot(n, "feature:python:tp_clear"), "tp_clear", "inquiry");
@ -4088,7 +4188,7 @@ public:
Delete(tp_flags);
Delete(py3_tp_flags);
Delete(quoted_symname);
Delete(quoted_rname);
Delete(quoted_tp_doc_str);
Delete(clientdata_klass);
Delete(richcompare_func);
Delete(getset_name);
@ -4183,7 +4283,18 @@ public:
Printv(base_class, abcs, NIL);
}
if (!builtin) {
if (builtin) {
if (have_docstring(n)) {
String *str = cdocstring(n, AUTODOC_CLASS);
Setattr(n, "feature:python:tp_doc", str);
Delete(str);
} else {
String *name = Getattr(n, "name");
String *rname = add_explicit_scope(SwigType_namestr(name));
Setattr(n, "feature:python:tp_doc", rname);
Delete(rname);
}
} else {
Printv(f_shadow, "class ", class_name, NIL);
if (Len(base_class)) {
@ -4462,7 +4573,7 @@ public:
have_repr = 1;
}
if (Getattr(n, "feature:shadow")) {
String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4);
String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n));
String *pyaction = NewStringf("%s.%s", module, fullname);
Replaceall(pycode, "$action", pyaction);
Delete(pyaction);
@ -4484,12 +4595,12 @@ public:
Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD), "\n", NIL);
if (have_pythonprepend(n)) {
fproxy = 0;
Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
Printv(f_shadow, pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL);
}
if (have_pythonappend(n)) {
fproxy = 0;
Printv(f_shadow, tab8, "val = ", funcCall(fullname, callParms), "\n", NIL);
Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL);
Printv(f_shadow, pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL);
Printv(f_shadow, tab8, "return val\n\n", NIL);
} else {
Printv(f_shadow, tab8, "return ", funcCall(fullname, callParms), "\n\n", NIL);
@ -4569,10 +4680,10 @@ public:
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC), "\n", NIL);
if (have_pythonprepend(n))
Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
Printv(f_shadow, pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL);
if (have_pythonappend(n)) {
Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL);
Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL);
Printv(f_shadow, pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL);
Printv(f_shadow, tab8, "return val\n\n", NIL);
} else {
Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL);
@ -4657,7 +4768,7 @@ public:
if (!have_constructor && handled_as_init) {
if (!builtin) {
if (Getattr(n, "feature:shadow")) {
String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4);
String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n));
String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname));
Replaceall(pycode, "$action", pyaction);
Delete(pyaction);
@ -4686,17 +4797,17 @@ public:
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR), "\n", NIL);
if (have_pythonprepend(n))
Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
Printv(f_shadow, pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL);
Printv(f_shadow, pass_self, NIL);
if (fastinit) {
Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), ")\n", NIL);
Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self, ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), ")\n", NIL);
} else {
Printv(f_shadow,
tab8, "this = ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), "\n",
tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", tab8, "except:\n", tab8, tab4, "self.this = this\n", NIL);
}
if (have_pythonappend(n))
Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n\n", NIL);
Printv(f_shadow, pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n\n", NIL);
Delete(pass_self);
}
have_constructor = 1;
@ -4705,7 +4816,7 @@ public:
/* Hmmm. We seem to be creating a different constructor. We're just going to create a
function for it. */
if (Getattr(n, "feature:shadow")) {
String *pycode = pythoncode(Getattr(n, "feature:shadow"), "");
String *pycode = pythoncode(Getattr(n, "feature:shadow"), "", Getfile(n), Getline(n));
String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname));
Replaceall(pycode, "$action", pyaction);
Delete(pyaction);
@ -4719,7 +4830,7 @@ public:
if (have_docstring(n))
Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR), "\n", NIL);
if (have_pythonprepend(n))
Printv(f_shadow_stubs, pythoncode(pythonprepend(n), tab4), "\n", NIL);
Printv(f_shadow_stubs, pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n)), "\n", NIL);
String *subfunc = NULL;
/*
if (builtin)
@ -4732,7 +4843,7 @@ public:
Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL);
#endif
if (have_pythonappend(n))
Printv(f_shadow_stubs, pythoncode(pythonappend(n), tab4), "\n", NIL);
Printv(f_shadow_stubs, pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n)), "\n", NIL);
Printv(f_shadow_stubs, tab4, "return val\n", NIL);
Delete(subfunc);
}
@ -4769,7 +4880,7 @@ public:
if (shadow) {
if (Getattr(n, "feature:shadow")) {
String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4);
String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n));
String *pyaction = NewStringf("%s.%s", module, Swig_name_destroy(NSPACE_TODO, symname));
Replaceall(pycode, "$action", pyaction);
Delete(pyaction);
@ -4787,7 +4898,7 @@ public:
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR), "\n", NIL);
if (have_pythonprepend(n))
Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
Printv(f_shadow, pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\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);
@ -4795,7 +4906,7 @@ public:
#else
#endif
if (have_pythonappend(n))
Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL);
Printv(f_shadow, pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL);
Printv(f_shadow, tab8, "pass\n", NIL);
Printv(f_shadow, "\n", NIL);
}
@ -4977,12 +5088,12 @@ public:
if (!ImportMode && (Cmp(section, "python") == 0 || Cmp(section, "shadow") == 0)) {
if (shadow) {
String *pycode = pythoncode(code, shadow_indent);
String *pycode = pythoncode(code, shadow_indent, Getfile(n), Getline(n));
Printv(f_shadow, pycode, NIL);
Delete(pycode);
}
} else if (!ImportMode && (Cmp(section, "pythonbegin") == 0)) {
String *pycode = pythoncode(code, "");
String *pycode = pythoncode(code, "", Getfile(n), Getline(n));
Printv(f_shadow_begin, pycode, NIL);
Delete(pycode);
} else {

View file

@ -281,6 +281,7 @@ public:
void dispatchFunction(Node *n);
int functionWrapper(Node *n);
int constantWrapper(Node *n);
int variableWrapper(Node *n);
int classDeclaration(Node *n);
@ -1381,12 +1382,12 @@ List * R::Swig_overload_rank(Node *n,
}
if ((!t1) && (!nodes[i].error)) {
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
"Overloaded method %s not supported (no type checking rule for '%s').\n",
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0));
nodes[i].error = 1;
} else if ((!t2) && (!nodes[j].error)) {
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n),
"xx Overloaded method %s not supported (no type checking rule for '%s').\n",
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0));
nodes[j].error = 1;
}
@ -2181,6 +2182,16 @@ int R::functionWrapper(Node *n) {
return SWIG_OK;
}
/* ----------------------------------------------------------------------
* R::constantWrapper()
* ---------------------------------------------------------------------- */
int R::constantWrapper(Node *n) {
(void) n;
// TODO
return SWIG_OK;
}
/*****************************************************
Add the specified routine name to the collection of
generated routines that are called from R functions.

View file

@ -13,14 +13,12 @@
#include "swigmod.h"
#include "cparse.h"
static int treduce = SWIG_cparse_template_reduce(0);
#define SWIG_PROTECTED_TARGET_METHODS 1
#include <ctype.h>
#include <string.h>
#include <limits.h> /* for INT_MAX */
#define SWIG_PROTECTED_TARGET_METHODS 1
class RClass {
private:
String *temp;
@ -1171,6 +1169,7 @@ public:
if (directorsEnabled()) {
// Insert director runtime into the f_runtime file (make it occur before %header section)
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
}
@ -1794,8 +1793,8 @@ public:
/* if the object is a director, and the method call originated from its
* underlying Ruby object, resolve the call by going up the c++
* inheritance chain. otherwise try to resolve the method in python.
* without this check an infinite loop is set up between the director and
* inheritance chain. otherwise try to resolve the method in Ruby.
* without this check an infinite loop is set up between the director and
* shadow class method calls.
*/

View file

@ -346,14 +346,18 @@ public:
emit_attach_parmmaps(functionParamsList, wrapper);
Setattr(node, "wrap:parms", functionParamsList);
/* Check arguments */
/* Check input/output arguments count */
int maxInputArguments = emit_num_arguments(functionParamsList);
int minInputArguments = emit_num_required(functionParamsList);
int minOutputArguments = 0;
int maxOutputArguments = 0;
/* Insert calls to CheckInputArgument and CheckOutputArgument */
Printf(wrapper->code, "SWIG_CheckInputArgument(pvApiCtx, $mininputarguments, $maxinputarguments);\n");
if (!emit_isvarargs(functionParamsList)) {
Printf(wrapper->code, "SWIG_CheckInputArgument(pvApiCtx, $mininputarguments, $maxinputarguments);\n");
}
else {
Printf(wrapper->code, "SWIG_CheckInputArgumentAtLeast(pvApiCtx, $mininputarguments-1);\n");
}
Printf(wrapper->code, "SWIG_CheckOutputArgument(pvApiCtx, $minoutputarguments, $maxoutputarguments);\n");
/* Set context */
@ -675,7 +679,7 @@ public:
}
}
/* Create variables for member pointer constants, not suppported by typemaps (like Python wrapper does) */
/* Create variables for member pointer constants, not supported by typemaps (like Python wrapper does) */
if (SwigType_type(type) == T_MPOINTER) {
String *wname = Swig_name_wrapper(constantName);
String *str = SwigType_str(type, wname);

View file

@ -13,7 +13,6 @@
#include "swigmod.h"
#include "cparse.h"
static int treduce = SWIG_cparse_template_reduce(0);
static const char *usage = "\
Tcl 8 Options (available with -tcl)\n\

View file

@ -1771,7 +1771,10 @@ String *Preprocessor_parse(String *s) {
} else if (Equal(id, "")) {
/* Null directive */
} else {
Swig_error(Getfile(s), Getline(id), "Unknown SWIG preprocessor directive: %s (if this is a block of target language code, delimit it with %%{ and %%})\n", id);
/* Ignore unknown preprocessor directives which are inside an inactive
* conditional (github issue #394). */
if (allow)
Swig_error(Getfile(s), Getline(id), "Unknown SWIG preprocessor directive: %s (if this is a block of target language code, delimit it with %%{ and %%})\n", id);
}
for (i = 0; i < cpp_lines; i++)
Putc('\n', ns);

View file

@ -194,7 +194,7 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_
lastpath = filename;
/* Skip the UTF-8 BOM if it's present */
nbytes = fread(bom, 1, 3, f);
nbytes = (int)fread(bom, 1, 3, f);
if (nbytes == 3 && bom[0] == (char)0xEF && bom[1] == (char)0xBB && bom[2] == (char)0xBF) {
/* skip */
} else {
@ -369,7 +369,7 @@ String *Swig_file_filename(const_String_or_char_ptr filename) {
String *Swig_file_dirname(const_String_or_char_ptr filename) {
const char *delim = SWIG_FILE_DELIMITER;
const char *c = strrchr(Char(filename), *delim);
return c ? NewStringWithSize(filename, c - Char(filename) + 1) : NewString("");
return c ? NewStringWithSize(filename, (int)(c - Char(filename) + 1)) : NewString("");
}
/*

View file

@ -127,7 +127,7 @@ String *Swig_strip_c_comments(const String *s) {
}
if (comment_begin && comment_end) {
int size = comment_begin - Char(s);
int size = (int)(comment_begin - Char(s));
String *stripmore = 0;
stripped = NewStringWithSize(s, size);
Printv(stripped, comment_end + 1, NIL);
@ -808,7 +808,7 @@ void Swig_scopename_split(const String *s, String **rprefix, String **rlast) {
*rlast = Copy(s);
return;
} else {
*rprefix = NewStringWithSize(cc, co - cc - 2);
*rprefix = NewStringWithSize(cc, (int)(co - cc - 2));
*rlast = NewString(co);
return;
}
@ -835,7 +835,7 @@ void Swig_scopename_split(const String *s, String **rprefix, String **rlast) {
}
if (cc != tmp) {
*rprefix = NewStringWithSize(tmp, cc - tmp);
*rprefix = NewStringWithSize(tmp, (int)(cc - tmp));
*rlast = NewString(cc + 2);
return;
} else {
@ -858,7 +858,7 @@ String *Swig_scopename_prefix(const String *s) {
if (co == cc) {
return 0;
} else {
String *prefix = NewStringWithSize(cc, co - cc - 2);
String *prefix = NewStringWithSize(cc, (int)(co - cc - 2));
return prefix;
}
}
@ -884,7 +884,7 @@ String *Swig_scopename_prefix(const String *s) {
}
if (cc != tmp) {
return NewStringWithSize(tmp, cc - tmp);
return NewStringWithSize(tmp, (int)(cc - tmp));
} else {
return 0;
}
@ -977,7 +977,7 @@ String *Swig_scopename_first(const String *s) {
}
}
if (*c && (c != tmp)) {
return NewStringWithSize(tmp, c - tmp);
return NewStringWithSize(tmp, (int)(c - tmp));
} else {
return 0;
}
@ -1219,8 +1219,8 @@ static int split_regex_pattern_subst(String *s, String **pattern, String **subst
if (!p) goto err_out;
sube = p;
*pattern = NewStringWithSize(pats, pate - pats);
*subst = NewStringWithSize(subs, sube - subs);
*pattern = NewStringWithSize(pats, (int)(pate - pats));
*subst = NewStringWithSize(subs, (int)(sube - subs));
*input = p + 1;
return 1;
@ -1270,10 +1270,10 @@ String *replace_captures(int num_captures, const char *input, String *subst, int
/* Copy part without substitutions */
const char *q = strchr(p, '\\');
if (!q) {
copy_with_maybe_case_conversion(result, p, strlen(p), &convertCase, convertNextOnly);
copy_with_maybe_case_conversion(result, p, (int)strlen(p), &convertCase, convertNextOnly);
break;
}
copy_with_maybe_case_conversion(result, p, q - p, &convertCase, convertNextOnly);
copy_with_maybe_case_conversion(result, p, (int)(q - p), &convertCase, convertNextOnly);
p = q + 1;
/* Handle substitution */
@ -1350,7 +1350,7 @@ String *Swig_string_regex(String *s) {
pcre_error, Char(pattern), pcre_errorpos);
exit(1);
}
rc = pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30);
rc = pcre_exec(compiled_pat, NULL, input, (int)strlen(input), 0, 0, captures, 30);
if (rc >= 0) {
res = replace_captures(rc, input, subst, captures, pattern, s);
} else if (rc != PCRE_ERROR_NOMATCH) {

View file

@ -578,7 +578,7 @@ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
bprefix = NewStringf("%s::", base);
dprefix = NewStringf("%s::", derived);
cbprefix = Char(bprefix);
plen = strlen(cbprefix);
plen = (int)strlen(cbprefix);
for (ki = First(namehash); ki.key; ki = Next(ki)) {
char *k = Char(ki.key);
if (strncmp(k, cbprefix, plen) == 0) {
@ -1003,6 +1003,10 @@ static int nodes_are_equivalent(Node *a, Node *b, int a_inclass) {
}
return 0;
}
if (Equal(ta, "template") && Equal(tb, "template")) {
if (Cmp(a_storage, "friend") == 0 || Cmp(b_storage, "friend") == 0)
return 1;
}
}
return 0;
}
@ -1070,7 +1074,7 @@ static List *Swig_make_attrlist(const char *ckey) {
String *nattr;
const char *rattr = strchr(++cattr, '$');
while (rattr) {
nattr = NewStringWithSize(cattr, rattr - cattr);
nattr = NewStringWithSize(cattr, (int)(rattr - cattr));
Append(list, nattr);
Delete(nattr);
cattr = rattr + 1;

View file

@ -336,7 +336,7 @@ static void brackets_reset(Scanner *s) {
* Usually called when '(' is found.
* ----------------------------------------------------------------------------- */
static void brackets_push(Scanner *s) {
int *newInt = malloc(sizeof(int));
int *newInt = (int *)malloc(sizeof(int));
*newInt = 0;
Push(s->brackets, NewVoid(newInt, free));
}

View file

@ -195,7 +195,7 @@ int SwigType_ispointer_return(const SwigType *t) {
if (!t)
return 0;
c = Char(t);
idx = strlen(c) - 4;
idx = (int)strlen(c) - 4;
if (idx >= 0) {
return (strcmp(c + idx, ").p.") == 0);
}
@ -208,7 +208,7 @@ int SwigType_isreference_return(const SwigType *t) {
if (!t)
return 0;
c = Char(t);
idx = strlen(c) - 4;
idx = (int)strlen(c) - 4;
if (idx >= 0) {
return (strcmp(c + idx, ").r.") == 0);
}
@ -485,7 +485,7 @@ String *SwigType_namestr(const SwigType *t) {
if (!c || !strstr(c + 2, ")>"))
return NewString(t);
r = NewStringWithSize(d, c - d);
r = NewStringWithSize(d, (int)(c - d));
if (*(c - 1) == '<')
Putc(' ', r);
Putc('<', r);

View file

@ -1149,7 +1149,7 @@ 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_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", Getattr(s, "uname"));
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
}
s = ss;
}
@ -1221,7 +1221,7 @@ 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_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", Getattr(s, "uname"));
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
}
s = ss;
}
@ -1272,7 +1272,7 @@ 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_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", Getattr(s, "uname"));
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
}
s = ss;
}
@ -1320,7 +1320,7 @@ 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_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", Getattr(s, "uname"));
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
}
s = ss;
}

View file

@ -1844,7 +1844,7 @@ static List *split_embedded_typemap(String *s) {
}
}
if ((level == 0) && angle_level == 0 && ((*c == ',') || (*c == ')'))) {
String *tmp = NewStringWithSize(start, c - start);
String *tmp = NewStringWithSize(start, (int)(c - start));
Append(args, tmp);
Delete(tmp);
start = c + 1;
@ -1915,10 +1915,10 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
c++;
}
if (end) {
dollar_typemap = NewStringWithSize(start, (end - start));
dollar_typemap = NewStringWithSize(start, (int)((end - start)));
syntax_error = 0;
} else {
dollar_typemap = NewStringWithSize(start, (c - start));
dollar_typemap = NewStringWithSize(start, (int)((c - start)));
}
if (!syntax_error) {
@ -1963,7 +1963,7 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
char *eq = strchr(Char(parm), '=');
char *c = Char(parm);
if (eq && (eq - c > 0)) {
String *name = NewStringWithSize(c, eq - c);
String *name = NewStringWithSize(c, (int)(eq - c));
String *value = NewString(eq + 1);
Insert(name, 0, "$");
Setattr(vars, name, value);

View file

@ -361,7 +361,7 @@ SwigType *SwigType_del_pointer(SwigType *t) {
printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n");
abort();
}
Delslice(t, 0, (c - s) + 2);
Delslice(t, 0, (int)((c - s) + 2));
return t;
}
@ -915,7 +915,7 @@ SwigType *SwigType_add_template(SwigType *t, ParmList *parms) {
String *SwigType_templateprefix(const SwigType *t) {
const char *s = Char(t);
const char *c = strstr(s, "<(");
return c ? NewStringWithSize(s, c - s) : NewString(s);
return c ? NewStringWithSize(s, (int)(c - s)) : NewString(s);
}
/* -----------------------------------------------------------------------------
@ -966,7 +966,7 @@ String *SwigType_templatesuffix(const SwigType *t) {
String *SwigType_istemplate_templateprefix(const SwigType *t) {
const char *s = Char(t);
const char *c = strstr(s, "<(");
return c ? NewStringWithSize(s, c - s) : 0;
return c ? NewStringWithSize(s, (int)(c - s)) : 0;
}
/* -----------------------------------------------------------------------------
@ -989,7 +989,7 @@ String *SwigType_istemplate_only_templateprefix(const SwigType *t) {
const char *s = Char(t);
if (len >= 4 && strcmp(s + len - 2, ")>") == 0) {
const char *c = strstr(s, "<(");
return c ? NewStringWithSize(s, c - s) : 0;
return c ? NewStringWithSize(s, (int)(c - s)) : 0;
} else {
return 0;
}
@ -1022,7 +1022,7 @@ String *SwigType_templateargs(const SwigType *t) {
nest--;
c++;
}
return NewStringWithSize(start, c - start);
return NewStringWithSize(start, (int)(c - start));
}
c++;
}