Remove some vc++ /W4 warnings

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10540 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2008-06-21 15:23:02 +00:00
commit 49675199f4
20 changed files with 146 additions and 152 deletions

View file

@ -331,7 +331,9 @@ static void add_symbols(Node *n) {
Delete(prefix);
}
if (0 && !Getattr(n,"parentNode") && class_level) set_parentNode(n,class_decl[class_level - 1]);
/*
if (!Getattr(n,"parentNode") && class_level) set_parentNode(n,class_decl[class_level - 1]);
*/
Setattr(n,"ismember","1");
}
}
@ -4109,10 +4111,11 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end {
/* Check for template names. If the class is a template
and the constructor is missing the template part, we
add it */
if (Classprefix && (c = strchr(Char(Classprefix),'<'))) {
if (!Strchr($3,'<')) {
$3 = NewStringf("%s%s",$3,c);
}
if (Classprefix) {
c = strchr(Char(Classprefix),'<');
if (c && !Strchr($3,'<')) {
$3 = NewStringf("%s%s",$3,c);
}
}
Setattr($$,"storage","virtual");
name = NewStringf("%s",$3);
@ -4428,12 +4431,8 @@ parms : rawparms {
;
rawparms : parm ptail {
if (1) {
set_nextSibling($1,$2);
$$ = $1;
} else {
$$ = $2;
}
set_nextSibling($1,$2);
$$ = $1;
}
| empty { $$ = 0; }
;
@ -4486,12 +4485,8 @@ valparms : rawvalparms {
;
rawvalparms : valparm valptail {
if (1) {
set_nextSibling($1,$2);
$$ = $1;
} else {
$$ = $2;
}
set_nextSibling($1,$2);
$$ = $1;
}
| empty { $$ = 0; }
;

View file

@ -281,13 +281,13 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab
Delete(ptargs);
}
if (0) {
/*
Parm *p = tparms;
while (p) {
Printf(stdout, "tparm: '%s' '%s' '%s'\n", Getattr(p, "name"), Getattr(p, "type"), Getattr(p, "value"));
p = nextSibling(p);
}
}
*/
/* Printf(stdout,"targs = '%s'\n", templateargs);
Printf(stdout,"rname = '%s'\n", rname);

View file

@ -112,12 +112,11 @@ static void DelHash(DOH *ho) {
int i;
for (i = 0; i < h->hashsize; i++) {
if ((n = h->hashtable[i])) {
while (n) {
next = n->next;
DelNode(n);
n = next;
}
n = h->hashtable[i];
while (n) {
next = n->next;
DelNode(n);
n = next;
}
}
DohFree(h->hashtable);
@ -138,12 +137,11 @@ static void Hash_clear(DOH *ho) {
int i;
for (i = 0; i < h->hashsize; i++) {
if ((n = h->hashtable[i])) {
while (n) {
next = n->next;
DelNode(n);
n = next;
}
n = h->hashtable[i];
while (n) {
next = n->next;
DelNode(n);
n = next;
}
h->hashtable[i] = 0;
}
@ -454,11 +452,10 @@ static DOH *CopyHash(DOH *ho) {
nho = DohObjMalloc(&DohHashType, nh);
for (i = 0; i < h->hashsize; i++) {
if ((n = h->hashtable[i])) {
while (n) {
Hash_setattr(nho, n->key, n->object);
n = n->next;
}
n = h->hashtable[i];
while (n) {
Hash_setattr(nho, n->key, n->object);
n = n->next;
}
}
return nho;

View file

@ -2935,11 +2935,9 @@ int ALLEGROCL::classHandler(Node *n) {
#endif
if (Generate_Wrapper)
return cppClassHandler(n);
return cppClassHandler(n);
else
return cClassHandler(n);
return SWIG_OK;
return cClassHandler(n);
}
int ALLEGROCL::cClassHandler(Node *n) {

View file

@ -329,7 +329,6 @@ int CHICKEN::functionWrapper(Node *n) {
Parm *p;
int i;
String *wname;
String *source;
Wrapper *f;
String *mangle = NewString("");
String *get_pointers;
@ -398,8 +397,6 @@ int CHICKEN::functionWrapper(Node *n) {
SwigType *pt = Getattr(p, "type");
String *ln = Getattr(p, "lname");
source = NewStringf("scm%d", i + 1);
Printf(f->def, ", C_word scm%d", i + 1);
Printf(declfunc, ",C_word");
@ -407,6 +404,7 @@ int CHICKEN::functionWrapper(Node *n) {
if ((tm = Getattr(p, "tmap:in"))) {
String *parse = Getattr(p, "tmap:in:parse");
if (!parse) {
String *source = NewStringf("scm%d", i + 1);
Replaceall(tm, "$source", source);
Replaceall(tm, "$target", ln);
Replaceall(tm, "$input", source);
@ -445,20 +443,15 @@ int CHICKEN::functionWrapper(Node *n) {
}
}
}
} else {
Delete(source);
}
p = Getattr(p, "tmap:in:next");
continue;
} else {
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
break;
}
Delete(source);
p = nextSibling(p);
}
/* finish argument marshalling */

View file

@ -1097,38 +1097,33 @@ int Language::globalfunctionHandler(Node *n) {
String *name = Getattr(n, "name");
String *symname = Getattr(n, "sym:name");
SwigType *type = Getattr(n, "type");
String *storage = Getattr(n, "storage");
ParmList *parms = Getattr(n, "parms");
if (0 && (Cmp(storage, "static") == 0)) {
Swig_restore(n);
return SWIG_NOWRAP; /* Can't wrap static functions */
} else {
/* Check for callback mode */
String *cb = GetFlagAttr(n, "feature:callback");
if (cb) {
String *cbname = Getattr(n, "feature:callback:name");
if (!cbname) {
cbname = NewStringf(cb, symname);
Setattr(n, "feature:callback:name", cbname);
}
callbackfunctionHandler(n);
if (Cmp(cbname, symname) == 0) {
Delete(cbname);
Swig_restore(n);
return SWIG_NOWRAP;
}
Delete(cbname);
/* Check for callback mode */
String *cb = GetFlagAttr(n, "feature:callback");
if (cb) {
String *cbname = Getattr(n, "feature:callback:name");
if (!cbname) {
cbname = NewStringf(cb, symname);
Setattr(n, "feature:callback:name", cbname);
}
Setattr(n, "parms", nonvoid_parms(parms));
String *call = Swig_cfunction_call(name, parms);
String *cres = Swig_cresult(type, "result", call);
Setattr(n, "wrap:action", cres);
Delete(cres);
Delete(call);
functionWrapper(n);
callbackfunctionHandler(n);
if (Cmp(cbname, symname) == 0) {
Delete(cbname);
Swig_restore(n);
return SWIG_NOWRAP;
}
Delete(cbname);
}
Setattr(n, "parms", nonvoid_parms(parms));
String *call = Swig_cfunction_call(name, parms);
String *cres = Swig_cresult(type, "result", call);
Setattr(n, "wrap:action", cres);
Delete(cres);
Delete(call);
functionWrapper(n);
Swig_restore(n);
return SWIG_OK;
}
@ -1376,9 +1371,6 @@ int Language::variableHandler(Node *n) {
* ---------------------------------------------------------------------- */
int Language::globalvariableHandler(Node *n) {
String *storage = Getattr(n, "storage");
if (0 && (Cmp(storage, "static") == 0))
return SWIG_NOWRAP;
variableWrapper(n);
return SWIG_OK;
}
@ -2108,8 +2100,8 @@ int Language::classDirector(Node *n) {
String *using_protected_members_code = NewString("");
for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) {
Node *nodeType = Getattr(ni, "nodeType");
bool cdecl = (Cmp(nodeType, "cdecl") == 0);
if (cdecl && !GetFlag(ni, "feature:ignore")) {
bool cdeclaration = (Cmp(nodeType, "cdecl") == 0);
if (cdeclaration && !GetFlag(ni, "feature:ignore")) {
if (is_non_virtual_protected_access(ni)) {
Node *overloaded = Getattr(ni, "sym:overloaded");
// emit the using base::member statement (but only once if the method is overloaded)
@ -3391,7 +3383,8 @@ int Language::is_assignable(Node *n) {
SwigType *ftd = SwigType_typedef_resolve_all(type);
SwigType *td = SwigType_strip_qualifiers(ftd);
if (SwigType_type(td) == T_USER) {
if ((cn = Swig_symbol_clookup(td, 0))) {
cn = Swig_symbol_clookup(td, 0);
if (cn) {
if ((Strcmp(nodeType(cn), "class") == 0)) {
if (Getattr(cn, "allocate:noassign")) {
SetFlag(n, "feature:immutable");

View file

@ -490,8 +490,6 @@ public:
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
break;
}
p = nextSibling(p);
}
// add all argcheck code
@ -1101,7 +1099,6 @@ public:
virtual int staticmemberfunctionHandler(Node *n) {
current = STATIC_FUNC;
return Language::staticmemberfunctionHandler(n);
current = NO_CPP;
}
/* ------------------------------------------------------------
@ -1123,7 +1120,6 @@ public:
// REPORT("staticmembervariableHandler",n);
current = STATIC_VAR;
return Language::staticmembervariableHandler(n);
current = NO_CPP;
}
/* ---------------------------------------------------------------------

View file

@ -472,9 +472,9 @@ MODULA3():
cap = true;
} else {
if (cap) {
m3sym[i] = toupper(c);
m3sym[i] = (char)toupper(c);
} else {
m3sym[i] = tolower(c);
m3sym[i] = (char)tolower(c);
}
cap = false;
}

View file

@ -150,45 +150,44 @@ void SwigPHP_emit_resource_registrations() {
ki = First(zend_types);
if (ki.key)
Printf(s_oinit, "\n/* Register resource destructors for pointer types */\n");
while (ki.key)
if (1 /* is pointer type */ ) {
DOH *key = ki.key;
Node *class_node = ki.item;
String *human_name = key;
while (ki.key) {
DOH *key = ki.key;
Node *class_node = ki.item;
String *human_name = key;
// Write out destructor function header
Printf(s_wrappers, "/* NEW Destructor style */\nstatic ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key);
// Write out destructor function header
Printf(s_wrappers, "/* NEW Destructor style */\nstatic ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key);
// write out body
if ((class_node != NOTCLASS)) {
String *destructor = Getattr(class_node, "destructor");
human_name = Getattr(class_node, "sym:name");
if (!human_name)
human_name = Getattr(class_node, "name");
// Do we have a known destructor for this type?
if (destructor) {
Printf(s_wrappers, " %s(rsrc, SWIGTYPE%s->name TSRMLS_CC);\n", destructor, key);
} else {
Printf(s_wrappers, " /* No destructor for class %s */\n", human_name);
}
// write out body
if ((class_node != NOTCLASS)) {
String *destructor = Getattr(class_node, "destructor");
human_name = Getattr(class_node, "sym:name");
if (!human_name)
human_name = Getattr(class_node, "name");
// Do we have a known destructor for this type?
if (destructor) {
Printf(s_wrappers, " %s(rsrc, SWIGTYPE%s->name TSRMLS_CC);\n", destructor, key);
} else {
Printf(s_wrappers, " /* No destructor for simple type %s */\n", key);
Printf(s_wrappers, " /* No destructor for class %s */\n", human_name);
}
// close function
Printf(s_wrappers, "}\n");
// declare le_swig_<mangled> to store php registration
Printf(s_vdecl, "static int le_swig_%s=0; /* handle for %s */\n", key, human_name);
// register with php
Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex" "(_wrap_destroy%s,NULL,(char *)(SWIGTYPE%s->name),module_number);\n", key, key, key);
// store php type in class struct
Printf(s_oinit, "SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key);
ki = Next(ki);
} else {
Printf(s_wrappers, " /* No destructor for simple type %s */\n", key);
}
// close function
Printf(s_wrappers, "}\n");
// declare le_swig_<mangled> to store php registration
Printf(s_vdecl, "static int le_swig_%s=0; /* handle for %s */\n", key, human_name);
// register with php
Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex" "(_wrap_destroy%s,NULL,(char *)(SWIGTYPE%s->name),module_number);\n", key, key, key);
// store php type in class struct
Printf(s_oinit, "SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key);
ki = Next(ki);
}
}
class PHP:public Language {

View file

@ -1773,7 +1773,6 @@ public:
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
break;
}
p = nextSibling(p);
}
/* finish argument marshalling */

View file

@ -57,11 +57,13 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) {
Insert(tmp, 0, retName);
return tmp;
/*
if(count)
return(b);
Delete(b);
return(NewString(""));
*/
}
#if 0
@ -104,7 +106,7 @@ static String * getRType(Node *n) {
Now handles arrays, i.e. struct A[2]
****************/
static String *getRClassName(String *retType, int addRef = 1, int upRef=0) {
static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) {
String *tmp = NewString("");
SwigType *resolved = SwigType_typedef_resolve_all(retType);
char *retName = Char(SwigType_manglestr(resolved));
@ -115,6 +117,7 @@ static String *getRClassName(String *retType, int addRef = 1, int upRef=0) {
}
return tmp;
/*
#if 1
List *l = SwigType_split(retType);
int n = Len(l);
@ -160,6 +163,7 @@ static String *getRClassName(String *retType, int addRef = 1, int upRef=0) {
#endif
return tmp;
*/
}
/*********************
@ -2030,14 +2034,18 @@ int R::functionWrapper(Node *n) {
Replaceall(tm,"$owner", "R_SWIG_EXTERNAL");
}
if(0 && addCopyParam) {
#if 0
if(addCopyParam) {
Printf(f->code, "if(LOGICAL(s_swig_copy)[0]) {\n");
Printf(f->code, "/* Deal with returning a reference. */\nr_ans = R_NilValue;\n");
Printf(f->code, "}\n else {\n");
}
#endif
Printf(f->code, "%s\n", tm);
if(0 && addCopyParam)
#if 0
if(addCopyParam)
Printf(f->code, "}\n"); /* end of if(s_swig_copy) ... else { ... } */
#endif
} else {
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number,

View file

@ -448,7 +448,7 @@ private:
parent_name = Copy( Getattr(mod, "name") );
if ( parent_name )
{
(Char(parent_name))[0] = toupper((Char(parent_name))[0]);
(Char(parent_name))[0] = (char)toupper((Char(parent_name))[0]);
}
}
if ( parent_name )
@ -1194,7 +1194,7 @@ public:
while (m.item) {
if (Len(m.item) > 0) {
String *cap = NewString(m.item);
(Char(cap))[0] = toupper((Char(cap))[0]);
(Char(cap))[0] = (char)toupper((Char(cap))[0]);
if (last != 0) {
Append(module, "::");
}
@ -1206,7 +1206,7 @@ public:
if (feature == 0) {
feature = Copy(last);
}
(Char(last))[0] = toupper((Char(last))[0]);
(Char(last))[0] = (char)toupper((Char(last))[0]);
modvar = NewStringf("m%s", last);
Delete(modules);
}
@ -2219,7 +2219,7 @@ public:
return name;
if (islower(name[0])) {
name[0] = toupper(name[0]);
name[0] = (char)toupper(name[0]);
Swig_warning(WARN_RUBY_WRONG_NAME, input_file, line_number, "Wrong %s name (corrected to `%s')\n", reason, name);
return name;
}
@ -2545,7 +2545,7 @@ public:
String *name = Copy(symname);
char *cname = Char(name);
if (cname)
cname[0] = toupper(cname[0]);
cname[0] = (char)toupper(cname[0]);
Printv(director_prot_ctor_code,
"if ( $comparison ) { /* subclassed */\n",
" $director_new \n",

View file

@ -36,6 +36,7 @@ static int error_as_warning = 0; /* Understand the cpp #error directive as a spe
/* Test a character to see if it valid in an identifier (after the first letter) */
#define isidchar(c) ((isalnum(c)) || (c == '_') || (c == '$'))
DOH *Preprocessor_replace(DOH *);
/* Skip whitespace */
static void skip_whitespace(String *s, String *out) {
@ -698,7 +699,6 @@ static String *get_options(String *str) {
static String *expand_macro(String *name, List *args) {
String *ns;
DOH *symbols, *macro, *margs, *mvalue, *temp, *tempa, *e;
DOH *Preprocessor_replace(DOH *);
int i, l;
int isvarargs = 0;
@ -935,7 +935,6 @@ static String *expand_macro(String *name, List *args) {
List *evaluate_args(List *x) {
Iterator i;
String *Preprocessor_replace(String *);
List *nl = NewList();
for (i = First(x); i.item; i = Next(i)) {
@ -1795,7 +1794,7 @@ String *Preprocessor_parse(String *s) {
for (i = 0; i < 6;) {
c = Getc(s);
Putc(c, value);
statement[i++] = c;
statement[i++] = (char)c;
if (strncmp(statement, ed, i) && strncmp(statement, df, i))
break;
}

View file

@ -513,7 +513,8 @@ String *Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int
pname = Swig_cparm_name(p, i);
i++;
} else {
if ((pname = Getattr(p, "value")))
pname = Getattr(p, "value");
if (pname)
pname = Copy(pname);
else
pname = Copy(Getattr(p, "name"));

View file

@ -352,7 +352,8 @@ char *Swig_file_filename(const String_or_char *filename) {
char *c;
strcpy(tmp, Char(filename));
if ((c = strrchr(tmp, *delim)))
c = strrchr(tmp, *delim);
if (c)
return c + 1;
else
return tmp;

View file

@ -614,7 +614,8 @@ void Swig_scopename_split(String *s, String **rprefix, String **rlast) {
*rlast = Copy(s);
}
if ((co = strstr(cc, "operator "))) {
co = strstr(cc, "operator ");
if (co) {
if (co == cc) {
*rprefix = 0;
*rlast = Copy(s);
@ -664,7 +665,9 @@ String *Swig_scopename_prefix(String *s) {
char *co = 0;
if (!strstr(c, "::"))
return 0;
if ((co = strstr(cc, "operator "))) {
co = strstr(cc, "operator ");
if (co) {
if (co == cc) {
return 0;
} else {
@ -715,7 +718,8 @@ String *Swig_scopename_last(String *s) {
if (!strstr(c, "::"))
return NewString(s);
if ((co = strstr(cc, "operator "))) {
co = strstr(cc, "operator ");
if (co) {
return NewString(co);
}
@ -756,7 +760,9 @@ String *Swig_scopename_first(String *s) {
char *co = 0;
if (!strstr(c, "::"))
return 0;
if ((co = strstr(c, "operator "))) {
co = strstr(c, "operator ");
if (co) {
if (co == c) {
return 0;
}
@ -804,7 +810,9 @@ String *Swig_scopename_suffix(String *s) {
char *co = 0;
if (!strstr(c, "::"))
return 0;
if ((co = strstr(c, "operator "))) {
co = strstr(c, "operator ");
if (co) {
if (co == c)
return 0;
}
@ -842,8 +850,9 @@ String *Swig_scopename_suffix(String *s) {
int Swig_scopename_check(String *s) {
char *c = Char(s);
char *co = 0;
if ((co = strstr(c, "operator "))) {
char *co = strstr(c, "operator ");
if (co) {
if (co == c)
return 0;
}

View file

@ -482,7 +482,8 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType
Delete(t_name);
}
/* A template-based class lookup */
if (0 && !rn && SwigType_istemplate(prefix)) {
/*
if (!rn && SwigType_istemplate(prefix)) {
String *t_prefix = SwigType_templateprefix(prefix);
if (Strcmp(t_prefix, prefix) != 0) {
String *t_name = SwigType_templateprefix(name);
@ -491,6 +492,7 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType
}
Delete(t_prefix);
}
*/
}
/* A wildcard-based class lookup */
if (!rn) {

View file

@ -200,7 +200,7 @@ static char nextchar(Scanner * s) {
if ((nc == '\n') && (!s->freeze_line))
s->line++;
Putc(nc,s->text);
return nc;
return (char)nc;
}
/* -----------------------------------------------------------------------------
@ -349,7 +349,7 @@ static void get_escape(Scanner *s) {
} else {
char tmp[3];
tmp[0] = '\\';
tmp[1] = c;
tmp[1] = (char)c;
tmp[2] = 0;
Delitem(s->text, DOH_END);
Append(s->text, tmp);

View file

@ -937,7 +937,8 @@ String *SwigType_templateargs(const SwigType *t) {
int SwigType_istemplate(const SwigType *t) {
char *ct = Char(t);
if ((ct = strstr(ct, "<(")) && (strstr(ct + 2, ")>")))
ct = strstr(ct, "<(");
if (ct && (strstr(ct + 2, ")>")))
return 1;
return 0;
}

View file

@ -108,6 +108,8 @@ static Hash *typedef_resolve_cache = 0;
static Hash *typedef_all_cache = 0;
static Hash *typedef_qualified_cache = 0;
static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix);
/* common attribute keys, to avoid calling find_key all the times */
/*
@ -162,7 +164,6 @@ void SwigType_typesystem_init() {
* ----------------------------------------------------------------------------- */
int SwigType_typedef(SwigType *type, String_or_char *name) {
Typetab *SwigType_find_scope(Typetab *, String *s);
if (Getattr(current_typetab, name))
return -1; /* Already defined */
if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */
@ -409,7 +410,7 @@ void SwigType_print_scope(Typetab *t) {
}
}
Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
Typetab *ss;
String *nnameprefix = 0;
static int check_parent = 1;
@ -1311,7 +1312,8 @@ SwigType *SwigType_alttype(SwigType *t, int local_tmap) {
SwigType *ftd = SwigType_typedef_resolve_all(t);
td = SwigType_strip_qualifiers(ftd);
Delete(ftd);
if ((n = Swig_symbol_clookup(td, 0))) {
n = Swig_symbol_clookup(td, 0);
if (n) {
if (GetFlag(n, "feature:valuewrapper")) {
use_wrapper = 1;
} else {
@ -1334,7 +1336,8 @@ SwigType *SwigType_alttype(SwigType *t, int local_tmap) {
Delete(ftd);
if (SwigType_type(td) == T_USER) {
use_wrapper = 1;
if ((n = Swig_symbol_clookup(td, 0))) {
n = Swig_symbol_clookup(td, 0);
if (n) {
if ((Checkattr(n, "nodeType", "class")
&& !Getattr(n, "allocate:noassign")
&& (Getattr(n, "allocate:default_constructor")))