remove many memory leaks and cleanup

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7898 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-11-29 01:47:10 +00:00
commit 3413b92e7a
21 changed files with 224 additions and 112 deletions

View file

@ -93,6 +93,7 @@ static Node *copy_node(Node *n) {
Setfile(nn,Getfile(n)); Setfile(nn,Getfile(n));
Setline(nn,Getline(n)); Setline(nn,Getline(n));
for (k = First(n); k.key; k = Next(k)) { for (k = First(n); k.key; k = Next(k)) {
String *ci;
String *key = k.key; String *key = k.key;
char *ckey = Char(key); char *ckey = Char(key);
if ((strcmp(ckey,"nextSibling") == 0) || if ((strcmp(ckey,"nextSibling") == 0) ||
@ -106,7 +107,9 @@ static Node *copy_node(Node *n) {
if ((strcmp(ckey,"sym:name") == 0) || if ((strcmp(ckey,"sym:name") == 0) ||
(strcmp(ckey,"sym:weak") == 0) || (strcmp(ckey,"sym:weak") == 0) ||
(strcmp(ckey,"sym:typename") == 0)) { (strcmp(ckey,"sym:typename") == 0)) {
Setattr(nn,key, Copy(k.item)); String *ci = Copy(k.item);
Setattr(nn,key, ci);
Delete(ci);
continue; continue;
} }
if (strcmp(ckey,"sym:symtab") == 0) { if (strcmp(ckey,"sym:symtab") == 0) {
@ -146,7 +149,9 @@ static Node *copy_node(Node *n) {
continue; continue;
} }
/* Looks okay. Just copy the data using Copy */ /* Looks okay. Just copy the data using Copy */
Setattr(nn, key, Copy(k.item)); ci = Copy(k.item);
Setattr(nn, key, ci);
Delete(ci);
} }
return nn; return nn;
} }
@ -227,15 +232,17 @@ static String *feature_identifier_fix(String *s) {
} }
} }
static void single_rename_add(const char *name, SwigType *decl, const char *newname) { static void single_rename_add(const char *name, SwigType *decl, const char *cnewname) {
String *nname; String *nname;
String *newname = NewString(cnewname);
if (!rename_hash) rename_hash = NewHash(); if (!rename_hash) rename_hash = NewHash();
if (Namespaceprefix) { if (Namespaceprefix) {
nname = NewStringf("%s::%s",Namespaceprefix, name); nname = NewStringf("%s::%s",Namespaceprefix, name);
} else { } else {
nname = NewString(name); nname = NewString(name);
} }
Swig_name_object_set(rename_hash,nname,decl,NewString(newname)); Swig_name_object_set(rename_hash,nname,decl,newname);
Delete(newname);
Delete(nname); Delete(nname);
} }
@ -394,6 +401,7 @@ static void add_symbols(Node *n) {
if (name && Namespaceprefix) { if (name && Namespaceprefix) {
String *nname = NewStringf("%s::%s", Namespaceprefix, name); String *nname = NewStringf("%s::%s", Namespaceprefix, name);
Setattr(n,"name",nname); Setattr(n,"name",nname);
Delete(nname);
} }
} else { } else {
Symtab *st = Swig_symbol_getscope(prefix); Symtab *st = Swig_symbol_getscope(prefix);
@ -401,6 +409,7 @@ static void add_symbols(Node *n) {
String *base = Swig_scopename_last(name); String *base = Swig_scopename_last(name);
String *nname = NewStringf("%s::%s", ns, base); String *nname = NewStringf("%s::%s", ns, base);
Setattr(n,"name",nname); Setattr(n,"name",nname);
Delete(nname);
Delete(base); Delete(base);
Delete(prefix); Delete(prefix);
} }
@ -418,6 +427,7 @@ static void add_symbols(Node *n) {
if (Classprefix && (Strcmp(prefix,Classprefix) == 0)) { if (Classprefix && (Strcmp(prefix,Classprefix) == 0)) {
String *base = Swig_scopename_last(name); String *base = Swig_scopename_last(name);
Setattr(n,"name",base); Setattr(n,"name",base);
Delete(base);
} }
Delete(prefix); Delete(prefix);
} }
@ -539,6 +549,7 @@ static void add_symbols(Node *n) {
Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(n),Getline(n),en, Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(n),Getline(n),en,
Getfile(c),Getline(c),ec); Getfile(c),Getline(c),ec);
Setattr(n,"error",e); Setattr(n,"error",e);
Delete(e);
Delete(en); Delete(en);
Delete(ec); Delete(ec);
} }
@ -690,6 +701,7 @@ static void merge_extensions(Node *cls, Node *am) {
Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(csym),Getline(csym),ec, Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(csym),Getline(csym),ec,
Getfile(n),Getline(n),en); Getfile(n),Getline(n),en);
Setattr(csym,"error",e); Setattr(csym,"error",e);
Delete(e);
Delete(en); Delete(en);
Delete(ec); Delete(ec);
Swig_symbol_remove(csym); /* Remove class definition */ Swig_symbol_remove(csym); /* Remove class definition */
@ -991,6 +1003,7 @@ static Node *dump_nested(const char *parent) {
while (n) { while (n) {
char temp[256]; char temp[256];
Node *retx; Node *retx;
SwigType *nt;
/* Token replace the name of the parent class */ /* Token replace the name of the parent class */
Replace(n->code, "$classname", parent, DOH_REPLACE_ANY); Replace(n->code, "$classname", parent, DOH_REPLACE_ANY);
/* Fix up the name of the datatype (for building typedefs and other stuff) */ /* Fix up the name of the datatype (for building typedefs and other stuff) */
@ -1003,7 +1016,9 @@ static Node *dump_nested(const char *parent) {
/* Add the appropriate declaration to the C++ processor */ /* Add the appropriate declaration to the C++ processor */
retx = new_node("cdecl"); retx = new_node("cdecl");
Setattr(retx,"name",n->name); Setattr(retx,"name",n->name);
Setattr(retx,"type",Copy(n->type)); nt = Copy(n->type);
Setattr(retx,"type",nt);
Delete(nt);
Setattr(retx,"nested",parent); Setattr(retx,"nested",parent);
add_symbols(retx); add_symbols(retx);
if (ret) { if (ret) {
@ -1065,9 +1080,10 @@ static Node *dump_nested(const char *parent) {
} }
} }
{ {
Node *head; Node *head = new_node("insert");
head = new_node("insert"); String *code = NewStringf("\n%s\n",n->code);
Setattr(head,"code",NewStringf("\n%s\n",n->code)); Setattr(head,"code", code);
Delete(code);
set_nextSibling(head,ret); set_nextSibling(head,ret);
ret = head; ret = head;
} }
@ -1200,7 +1216,9 @@ static void default_arguments(Node *n) {
if (pp) { if (pp) {
set_nextSibling(pp,Copy(varargs)); set_nextSibling(pp,Copy(varargs));
} else { } else {
Setattr(function,"parms", Copy(varargs)); ParmList *cv = Copy(varargs);
Setattr(function,"parms", cv);
Delete(cv);
} }
break; break;
} }
@ -1235,19 +1253,28 @@ static void default_arguments(Node *n) {
Node *new_function = new_node(Copy(nodeType(function))); Node *new_function = new_node(Copy(nodeType(function)));
SwigType *decl = Copy(Getattr(function,"decl")); SwigType *decl = Copy(Getattr(function,"decl"));
int constqualifier = SwigType_isconst(decl); int constqualifier = SwigType_isconst(decl);
String *ccode = Copy(Getattr(function,"code"));
String *cstorage = Copy(Getattr(function,"storage"));
SwigType *ctype = Copy(Getattr(function,"type"));
String *cthrow = Copy(Getattr(function,"throw"));
Delete(SwigType_pop_function(decl)); /* remove the old parameter list from decl */ Delete(SwigType_pop_function(decl)); /* remove the old parameter list from decl */
SwigType_add_function(decl,newparms); SwigType_add_function(decl,newparms);
if (constqualifier) if (constqualifier)
SwigType_add_qualifier(decl,"const"); SwigType_add_qualifier(decl,"const");
Setattr(new_function,"name",Getattr(function,"name")); Setattr(new_function,"name", Getattr(function,"name"));
Setattr(new_function,"code",Copy(Getattr(function,"code"))); Setattr(new_function,"code", ccode);
Setattr(new_function,"decl", decl); Setattr(new_function,"decl", decl);
Setattr(new_function,"parms",newparms); Setattr(new_function,"parms", newparms);
Setattr(new_function,"storage",Copy(Getattr(function,"storage"))); Setattr(new_function,"storage", cstorage);
Setattr(new_function,"type",Copy(Getattr(function,"type"))); Setattr(new_function,"type", ctype);
Setattr(new_function,"throw",Copy(Getattr(function,"throw"))); Setattr(new_function,"throw", cthrow);
Delete(ccode);
Delete(cstorage);
Delete(ctype);
Delete(cthrow);
Delete(decl);
{ {
Node *throws = Getattr(function,"throws"); Node *throws = Getattr(function,"throws");

View file

@ -204,19 +204,25 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
} }
Delete(stripped_name); Delete(stripped_name);
} }
if (Strstr(name,"<")) { if (strstr(Char(name),"<")) {
Append(patchlist,Getattr(n,k_name)); Append(patchlist,Getattr(n,k_name));
} else { } else {
Append(name,templateargs); Append(name,templateargs);
} }
name = Getattr(n,k_symname); name = Getattr(n,k_symname);
if (name && (Strstr(name,"<"))) { if (name) {
if (strstr(Char(name),"<")) {
Clear(name); Clear(name);
Append(name,rname); Append(name,rname);
} else { } else {
Replace(name,tname,rname, DOH_REPLACE_ANY); String *tmp = Copy(name);
Replace(tmp,tname,rname, DOH_REPLACE_ANY);
Clear(name);
Append(name,tmp);
Delete(tmp);
} }
Setattr(n,k_symname,name); }
/* Setattr(n,k_symname,name); */
} }
Append(cpatchlist,Getattr(n,k_code)); Append(cpatchlist,Getattr(n,k_code));
Append(typelist, Getattr(n,k_decl)); Append(typelist, Getattr(n,k_decl));
@ -224,28 +230,26 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
add_parms(Getattr(n,k_throws), cpatchlist, typelist); add_parms(Getattr(n,k_throws), cpatchlist, typelist);
} else if (StringEqual(nodeType,k_destructor)) { } else if (StringEqual(nodeType,k_destructor)) {
String *name = Getattr(n,k_name); String *name = Getattr(n,k_name);
if (Strstr(name,"<")) { if (name && strstr(Char(name),"<")) {
Append(patchlist,Getattr(n,k_name)); Append(patchlist,Getattr(n,k_name));
} else { } else {
Append(name,templateargs); Append(name,templateargs);
} }
name = Getattr(n,k_symname); name = Getattr(n,k_symname);
if (name && Strstr(name,"<")) { if (name && strstr(Char(name),"<")) {
String *sn = Copy(tname); String *sn = Copy(tname);
Setattr(n,k_symname, sn); Setattr(n,k_symname, sn);
Delete(sn); Delete(sn);
} else { } else {
Replace(name,tname,rname, DOH_REPLACE_ANY); Replace(name,tname,rname, DOH_REPLACE_ANY);
} }
Setattr(n,k_symname,name); /* Setattr(n,k_symname,name); */
Append(cpatchlist,Getattr(n,k_code)); Append(cpatchlist,Getattr(n,k_code));
} else if (StringEqual(nodeType,k_using)) { } else if (StringEqual(nodeType,k_using)) {
String *uname = Getattr(n,k_uname); String *uname = Getattr(n,k_uname);
if (uname) { if (uname && strstr(Char(uname),"<")) {
if (Strstr(uname,"<")) {
Append(patchlist, uname); Append(patchlist, uname);
} }
}
if (Getattr(n,k_namespace)) { if (Getattr(n,k_namespace)) {
/* Namespace link. This is nasty. Is other namespace defined? */ /* Namespace link. This is nasty. Is other namespace defined? */
@ -272,17 +276,18 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
static static
String *partial_arg(String *s, String *p) { String *partial_arg(String *s, String *p) {
char *c; char *c;
char *cp = Char(p);
String *prefix; String *prefix;
String *newarg; String *newarg;
/* Find the prefix on the partial argument */ /* Find the prefix on the partial argument */
c = Strstr(p,"$"); c = strstr(cp,"$");
if (!c) { if (!c) {
return NewString(s); return Copy(s);
} }
prefix = NewStringWithSize(Char(p),c-Char(p)); prefix = NewStringWithSize(cp,c-cp);
newarg = NewString(s); newarg = Copy(s);
Replace(newarg,prefix,"",DOH_REPLACE_ANY | DOH_REPLACE_FIRST); Replace(newarg,prefix,"",DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
Delete(prefix); Delete(prefix);
return newarg; return newarg;
@ -462,6 +467,7 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *ts
Delete(cpatchlist); Delete(cpatchlist);
Delete(typelist); Delete(typelist);
Delete(tbase); Delete(tbase);
Delete(tname);
Delete(templateargs); Delete(templateargs);
/* set_nodeType(n,k_template);*/ /* set_nodeType(n,k_template);*/

View file

@ -233,12 +233,19 @@ DohEqual(const DOH *obj1, const DOH *obj2) {
if (DohCheck(b2)) { if (DohCheck(b2)) {
b2info = b2->type; b2info = b2->type;
} else { } else {
return strncmp((b1info->doh_data)(b1), (void*) obj2, (b1info->doh_len)(b1)) == 0; int len = (b1info->doh_len)(b1);
char *cobj = (char *) obj2;
return len == strlen(cobj) ? (memcmp(RawData(b1), cobj, len) == 0) : 0;
} }
} else if (DohCheck(b2)) { } else if (DohCheck(b2)) {
b2info = b2->type; b2info = b2->type;
return strncmp((b2info->doh_data)(b2), (void*) obj1, (b2info->doh_len)(b2)) == 0; int len = (b2info->doh_len)(b2);
char *cobj = (char *) obj1;
return len == strlen(cobj) ? (memcmp(RawData(b2), cobj, len) == 0) : 0;
} else {
return strcmp((char*) obj1, (char*) obj2) == 0;
} }
if (!b1info) { if (!b1info) {
return obj1 == obj2; return obj1 == obj2;
} else if ((b1info == b2info)) { } else if ((b1info == b2info)) {

View file

@ -263,10 +263,10 @@ extern int DohString_equal(DOH *s1, DOH *s2);
#define DohStringPutc(ch,so) DohString_putc(so, ch) #define DohStringPutc(ch,so) DohString_putc(so, ch)
#define DohStringGetc(so) DohString_getc(so) #define DohStringGetc(so) DohString_getc(so)
#define DohStringUngetc(ch,so) DohString_ungetc(so, ch) #define DohStringUngetc(ch,so) DohString_ungetc(so, ch)
#define DohStringAppend(so,str) DohString_append(so, str) #define DohStringAppend(so,str) DohString_append(so, (DOH*)str)
#define DohStringLen(so) DohString_len(so) #define DohStringLen(so) DohString_len((DOH*)so)
#define DohStringChar(so) DohString_char(so) #define DohStringChar(so) DohString_char(so)
#define DohStringEqual(s1,s2) DohString_equal(s1,s2) #define DohStringEqual(s1,s2) DohString_equal((DOH *)s1, (DOH *)s2)
/* Meta-variables */ /* Meta-variables */
extern DOH *DohGetmeta(DOH *, const DOH *); extern DOH *DohGetmeta(DOH *, const DOH *);

View file

@ -150,6 +150,7 @@ DohString_equal(DOH *so1, DOH *so2)
} else { } else {
register char *c1 = s1->str; register char *c1 = s1->str;
register char *c2 = s2->str; register char *c2 = s2->str;
#if 0
register int mlen = len >> 2; register int mlen = len >> 2;
register int i = mlen; register int i = mlen;
for (; i; --i) { for (; i; --i) {
@ -162,6 +163,9 @@ DohString_equal(DOH *so1, DOH *so2)
if (*(c1++) != *(c2++)) return 0; if (*(c1++) != *(c2++)) return 0;
} }
return 1; return 1;
#else
return memcmp(c1, c2, len) == 0;
#endif
} }
} }
@ -208,7 +212,7 @@ DohString_append(DOH *so, DOH *str) {
if (DohCheck(str)) { if (DohCheck(str)) {
String *ss = (String *) ObjData(str); String *ss = (String *) ObjData(str);
newstr = String_data(str); newstr = String_data((DOH*)str);
l = ss->len; l = ss->len;
} else { } else {
newstr = (char *) (str); newstr = (char *) (str);
@ -667,8 +671,6 @@ replace_simple(String *str, char *token, char *rep, int flags, int count, char *
register char *base; register char *base;
int i; int i;
str->hashkey = -1;
/* Figure out if anything gets replaced */ /* Figure out if anything gets replaced */
if (!strlen(token)) return 0; if (!strlen(token)) return 0;
@ -678,6 +680,8 @@ replace_simple(String *str, char *token, char *rep, int flags, int count, char *
if (!s) return 0; /* No matches. Who cares */ if (!s) return 0; /* No matches. Who cares */
str->hashkey = -1;
if (flags & DOH_REPLACE_NOQUOTE) noquote = 1; if (flags & DOH_REPLACE_NOQUOTE) noquote = 1;
/* If we are not replacing inside quotes, we need to do a little extra work */ /* If we are not replacing inside quotes, we need to do a little extra work */

View file

@ -269,6 +269,8 @@ Language::~Language() {
Delete(symbols); Delete(symbols);
Delete(classtypes); Delete(classtypes);
Delete(enumtypes); Delete(enumtypes);
Delete(director_ctor_code);
Delete(none_comparison);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View file

@ -185,7 +185,7 @@ static void install_opts(int argc, char *argv[]) {
} }
if (!noopt) { if (!noopt) {
/* Printf(stdout,"%s\n", opt); */ /* Printf(stdout,"%s\n", opt); */
Preprocessor_define(opt, 0); Delete(Preprocessor_define(opt, 0));
} }
} }
} }
@ -359,7 +359,7 @@ void SWIG_getoptions(int argc, char *argv[])
} else if (strncmp(argv[i],"-D",2) == 0) { } else if (strncmp(argv[i],"-D",2) == 0) {
DOH *d = NewString(argv[i]+2); DOH *d = NewString(argv[i]+2);
Replace(d,(char*)"=",(char*)" ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST); Replace(d,(char*)"=",(char*)" ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
Preprocessor_define((DOH *) d,0); Delete(Preprocessor_define((DOH *) d,0));
// Create a symbol // Create a symbol
Swig_mark_arg(i); Swig_mark_arg(i);
} else if (strcmp(argv[i],"-E") == 0) { } else if (strcmp(argv[i],"-E") == 0) {
@ -374,7 +374,7 @@ void SWIG_getoptions(int argc, char *argv[])
Swig_mark_arg(i); Swig_mark_arg(i);
} else if (strcmp(argv[i],"-c++") == 0) { } else if (strcmp(argv[i],"-c++") == 0) {
CPlusPlus=1; CPlusPlus=1;
Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0); Delete(Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0));
Swig_cparse_cplusplus(1); Swig_cparse_cplusplus(1);
Swig_mark_arg(i); Swig_mark_arg(i);
} else if (strcmp(argv[i],"-fcompact") == 0) { } else if (strcmp(argv[i],"-fcompact") == 0) {
@ -651,13 +651,13 @@ int SWIG_main(int argc, char *argv[], Language *l) {
// Set up some default symbols (available in both SWIG interface files // Set up some default symbols (available in both SWIG interface files
// and C files) // and C files)
Preprocessor_define((DOH *) "SWIG 1", 0); Delete(Preprocessor_define((DOH *) "SWIG 1", 0));
Preprocessor_define((DOH *) "__STDC__", 0); Delete(Preprocessor_define((DOH *) "__STDC__", 0));
#ifdef MACSWIG #ifdef MACSWIG
Preprocessor_define((DOH *) "SWIGMAC 1", 0); Delete(Preprocessor_define((DOH *) "SWIGMAC 1", 0));
#endif #endif
#ifdef SWIGWIN32 #ifdef SWIGWIN32
Preprocessor_define((DOH *) "SWIGWIN32 1", 0); Delete(Preprocessor_define((DOH *) "SWIGWIN32 1", 0));
#endif #endif
// Set the SWIG version value in format 0xAABBCC from package version expected to be in format A.B.C // Set the SWIG version value in format 0xAABBCC from package version expected to be in format A.B.C
@ -678,7 +678,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
/* Turn on contracts */ /* Turn on contracts */
Swig_contract_mode_set(1); Swig_contract_mode_set(1);
Preprocessor_define(vers,0); Delete(Preprocessor_define(vers,0));
/* Turn off directors mode */ /* Turn off directors mode */
Wrapper_director_mode_set(0); Wrapper_director_mode_set(0);
@ -715,7 +715,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
// Define the __cplusplus symbol // Define the __cplusplus symbol
if (CPlusPlus) if (CPlusPlus)
Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0); Delete(Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0));
// Parse language dependent options // Parse language dependent options
lang->main(argc,argv); lang->main(argc,argv);
@ -892,6 +892,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
} }
Node *top = Swig_cparse(cpps); Node *top = Swig_cparse(cpps);
Delete(cpps);
if (Verbose) { if (Verbose) {

View file

@ -23,6 +23,11 @@ struct Module {
strcpy(name, n); strcpy(name, n);
next = 0; next = 0;
} }
~Module()
{
delete[] name;
}
}; };
static Module *modules = 0; static Module *modules = 0;

View file

@ -164,7 +164,7 @@ public:
Swig_mark_arg(i); Swig_mark_arg(i);
} else if (strcmp(argv[i],"-nortti") == 0) { } else if (strcmp(argv[i],"-nortti") == 0) {
/* Turn on no RTTI mode */ /* Turn on no RTTI mode */
Preprocessor_define((DOH *) "SWIG_NORTTI", 0); Delete(Preprocessor_define((DOH *) "SWIG_NORTTI", 0));
Swig_mark_arg(i); Swig_mark_arg(i);
} else if (strcmp(argv[i],"-modern") == 0) { } else if (strcmp(argv[i],"-modern") == 0) {
apply = 0; apply = 0;
@ -189,11 +189,11 @@ public:
} }
if (cppcast) { if (cppcast) {
Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); Delete(Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0));
} }
if (!global_name) global_name = NewString("cvar"); if (!global_name) global_name = NewString("cvar");
Preprocessor_define("SWIGPYTHON 1", 0); Delete(Preprocessor_define("SWIGPYTHON 1", 0));
SWIG_typemap_lang("python"); SWIG_typemap_lang("python");
SWIG_config_file("python.swg"); SWIG_config_file("python.swg");
allow_overloading(); allow_overloading();
@ -489,6 +489,7 @@ public:
Delete(f_directors_h); Delete(f_directors_h);
Close(f_runtime); Close(f_runtime);
Delete(f_runtime);
return SWIG_OK; return SWIG_OK;
} }
@ -1210,7 +1211,9 @@ public:
num_required = emit_num_required(l); num_required = emit_num_required(l);
varargs = emit_isvarargs(l); varargs = emit_isvarargs(l);
strcpy(wname,Char(Swig_name_wrapper(iname))); String *nw = Swig_name_wrapper(iname);
strcpy(wname,Char(nw));
Delete(nw);
if (overname) { if (overname) {
strcat(wname,Char(overname)); strcat(wname,Char(overname));
} }
@ -1526,6 +1529,7 @@ public:
#else #else
Printf(f->code,"%s\n", tm); Printf(f->code,"%s\n", tm);
#endif #endif
Delete(tm);
} else { } else {
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number,
"Unable to use return type %s in function %s.\n", SwigType_str(d,0), name); "Unable to use return type %s in function %s.\n", SwigType_str(d,0), name);
@ -1559,6 +1563,7 @@ public:
Replaceall(tm,"$input","result"); Replaceall(tm,"$input","result");
Replaceall(tm,"$result","resultobj"); Replaceall(tm,"$result","resultobj");
Printf(f->code,"%s\n",tm); Printf(f->code,"%s\n",tm);
Delete(tm);
} }
} }
@ -1717,6 +1722,7 @@ public:
Replaceall(tm,"$target","pyobj"); Replaceall(tm,"$target","pyobj");
Replaceall(tm,"$result","pyobj"); Replaceall(tm,"$result","pyobj");
Printf(getf->code,"%s\n", tm); Printf(getf->code,"%s\n", tm);
Delete(tm);
} else { } else {
Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number,
"Unable to read variable of type %s\n", SwigType_str(t,0)); "Unable to read variable of type %s\n", SwigType_str(t,0));
@ -1763,6 +1769,7 @@ public:
Replaceall(tm,"$target",name); Replaceall(tm,"$target",name);
Replaceall(tm,"$value", value); Replaceall(tm,"$value", value);
Printf(const_code,"%s,\n", tm); Printf(const_code,"%s,\n", tm);
Delete(tm);
have_tm = 1; have_tm = 1;
} }
if ((tm = Swig_typemap_lookup_new("constcode", n, name, 0))) { if ((tm = Swig_typemap_lookup_new("constcode", n, name, 0))) {
@ -1770,6 +1777,7 @@ public:
Replaceall(tm,"$target",name); Replaceall(tm,"$target",name);
Replaceall(tm,"$value",value); Replaceall(tm,"$value",value);
Printf(f_init, "%s\n", tm); Printf(f_init, "%s\n", tm);
Delete(tm);
have_tm = 1; have_tm = 1;
} }
if (!have_tm) { if (!have_tm) {
@ -2237,6 +2245,7 @@ public:
modern = oldmodern; modern = oldmodern;
/* Restore shadow file back to original version */ /* Restore shadow file back to original version */
Delete(f_shadow);
f_shadow = f_shadow_file; f_shadow = f_shadow_file;
return SWIG_OK; return SWIG_OK;
@ -2957,6 +2966,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
tm = Swig_typemap_lookup_new("director:except", n, "result", 0); tm = Swig_typemap_lookup_new("director:except", n, "result", 0);
if (!tm) { if (!tm) {
tm = Getattr(n, "feature:director:except"); tm = Getattr(n, "feature:director:except");
if (tm) tm = Copy(tm);
} }
Printf(w->code, "if (result == NULL) {\n"); Printf(w->code, "if (result == NULL) {\n");
Printf(w->code, " PyObject *error = PyErr_Occurred();\n"); Printf(w->code, " PyObject *error = PyErr_Occurred();\n");
@ -2970,6 +2980,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
Printf(w->code, " }\n"); Printf(w->code, " }\n");
} }
Printf(w->code, "}\n"); Printf(w->code, "}\n");
Delete(tm);
/* /*
* Python method may return a simple object, or a tuple. * Python method may return a simple object, or a tuple.
@ -3029,6 +3040,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
} }
Replaceall(tm, "$result", "c_result"); Replaceall(tm, "$result", "c_result");
Printv(w->code, tm, "\n", NIL); Printv(w->code, tm, "\n", NIL);
Delete(tm);
} else { } else {
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
"Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(return_type, 0), classname, name); "Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(return_type, 0), classname, name);

View file

@ -240,7 +240,9 @@ class TypePass : private Dispatcher {
Swig_symbol_setscope(s); Swig_symbol_setscope(s);
/* Recursively hit base classes */ /* Recursively hit base classes */
String *newcast = NewStringf("(%s *)%s", SwigType_namestr(Getattr(bclass,"name")), cast); String *namestr = SwigType_namestr(Getattr(bclass,"name"));
String *newcast = NewStringf("(%s *)%s", namestr, cast);
Delete(namestr);
cplus_inherit_types_impl(first,bclass,clsname,bases,baselist,ispublic,newcast); cplus_inherit_types_impl(first,bclass,clsname,bases,baselist,ispublic,newcast);
Delete(newcast); Delete(newcast);
} }
@ -434,6 +436,7 @@ class TypePass : private Dispatcher {
/* If in a namespace, patch the class name */ /* If in a namespace, patch the class name */
if (nname) { if (nname) {
Setattr(n,"name",nname); Setattr(n,"name",nname);
Delete(nname);
} }
return SWIG_OK; return SWIG_OK;
} }

View file

@ -90,11 +90,14 @@ static String *cpp_include(String_or_char *fn, int sysfile) {
Swig_error(Getfile(fn),Getline(fn),"Unable to find '%s'\n", fn); Swig_error(Getfile(fn),Getline(fn),"Unable to find '%s'\n", fn);
} }
} else { } else {
String *lf;
Seek(s,0,SEEK_SET); Seek(s,0,SEEK_SET);
if (!dependencies) { if (!dependencies) {
dependencies = NewList(); dependencies = NewList();
} }
Append(dependencies, Copy(Swig_last_file())); lf = Copy(Swig_last_file());
Append(dependencies, lf);
Delete(lf);
} }
return s; return s;
} }
@ -213,30 +216,34 @@ String_or_char *Macro_vararg_name(String_or_char *str,
argname = Copy(str); argname = Copy(str);
s = Char(argname); s = Char(argname);
dots = strchr(s, '.'); dots = strchr(s, '.');
if (!dots) return NULL; if (!dots) {
Delete(argname);
return NULL;
}
if (strcmp(dots, "...") != 0) { if (strcmp(dots, "...") != 0) {
Swig_error(Getfile(line), Getline(line), Swig_error(Getfile(line), Getline(line),
"Illegal macro argument name '%s'\n", str); "Illegal macro argument name '%s'\n", str);
Delete(argname);
return NULL; return NULL;
} }
if (dots == s) { if (dots == s) {
varargname = NewString("__VA_ARGS__"); varargname = NewString("__VA_ARGS__");
} else { } else {
*dots = '\0'; *dots = '\0';
varargname = NewStringf(argname); varargname = NewString(s);
} }
Delete(argname); Delete(argname);
return varargname; return varargname;
} }
Hash *Preprocessor_define(const String_or_char *_str, int swigmacro) Hash *Preprocessor_define(const String *str, int swigmacro)
{ {
String *macroname = 0, *argstr = 0, *macrovalue = 0, *file = 0, *s = 0; String *macroname = 0, *argstr = 0, *macrovalue = 0, *file = 0, *s = 0;
Hash *macro = 0, *symbols = 0, *m1; Hash *macro = 0, *symbols = 0, *m1;
List *arglist = 0; List *arglist = 0;
int c, line; int c, line;
int varargs = 0; int varargs = 0;
String_or_char *str = (String_or_char *) _str;
assert(cpp); assert(cpp);
assert(str); assert(str);
@ -307,6 +314,7 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
if (c == ',') { if (c == ',') {
varargname = Macro_vararg_name(argname, str); varargname = Macro_vararg_name(argname, str);
if (varargname) { if (varargname) {
Delete(varargname);
Swig_error(Getfile(str),Getline(str),"Variable-length macro argument must be last parameter\n"); Swig_error(Getfile(str),Getline(str),"Variable-length macro argument must be last parameter\n");
} else { } else {
Append(arglist,argname); Append(arglist,argname);
@ -316,6 +324,7 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
} else if (isidchar(c) || (c == '.')) { } else if (isidchar(c) || (c == '.')) {
StringPutc(c,argname); StringPutc(c,argname);
} else if (!(isspace(c) || (c == '\\'))) { } else if (!(isspace(c) || (c == '\\'))) {
Delete(argname);
Swig_error(Getfile(str),Getline(str),"Illegal character in macro argument name\n"); Swig_error(Getfile(str),Getline(str),"Illegal character in macro argument name\n");
goto macro_error; goto macro_error;
} }
@ -330,8 +339,8 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
} else { } else {
Append(arglist,argname); Append(arglist,argname);
} }
Delete(argname);
} }
Delete(argname);
} }
if (!swigmacro) { if (!swigmacro) {
@ -409,6 +418,7 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
/* Go create the macro */ /* Go create the macro */
macro = NewHash(); macro = NewHash();
Setattr(macro,k_name, macroname); Setattr(macro,k_name, macroname);
if (arglist) { if (arglist) {
Setattr(macro,k_args,arglist); Setattr(macro,k_args,arglist);
Delete(arglist); Delete(arglist);
@ -432,15 +442,16 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
} }
} }
Setattr(symbols,macroname,macro); Setattr(symbols,macroname,macro);
Delete(macroname);
Delete(str); Delete(str);
Delete(argstr); Delete(argstr);
Delete(macroname);
return macro; return macro;
macro_error: macro_error:
Delete(str); Delete(str);
Delete(argstr); Delete(argstr);
Delete(arglist);
Delete(macroname); Delete(macroname);
return 0; return 0;
} }
@ -1029,9 +1040,7 @@ Preprocessor_replace(DOH *s)
StringAppend(ns,id); StringAppend(ns,id);
} }
} }
#ifndef SWIG_PUT_BUFF
Delete(id); Delete(id);
#endif
return ns; return ns;
} }
@ -1103,7 +1112,8 @@ static void add_chunk(DOH *ns, DOH *chunk, int allow) {
static void static void
push_imported() { push_imported() {
if (imported_depth == 0) { if (imported_depth == 0) {
Preprocessor_define("SWIGIMPORTED 1", 0); DOH *m = Preprocessor_define("SWIGIMPORTED 1", 0);
Delete(m);
} }
++imported_depth; ++imported_depth;
} }
@ -1678,7 +1688,8 @@ Preprocessor_parse(String *s)
} }
if (allow) { if (allow) {
Seek(value,0,SEEK_SET); Seek(value,0,SEEK_SET);
Preprocessor_define(value,1); DOH *m = Preprocessor_define(value,1);
Delete(m);
} }
StringPutc('\n',ns); StringPutc('\n',ns);
addline(ns,value,0); addline(ns,value,0);

View file

@ -80,9 +80,11 @@ Swig_clocal(SwigType *t, const String_or_char *name, const String_or_char *value
if (value) { if (value) {
String *lcaststr = SwigType_lcaststr(t,value); String *lcaststr = SwigType_lcaststr(t,value);
String *lstr = SwigType_lstr(t,0); String *lstr = SwigType_lstr(t,0);
Printf(decl,"%s = (%s) %s", SwigType_lstr(t,name), lstr, lcaststr); String *lstrn = SwigType_lstr(t,name);
Printf(decl,"%s = (%s) %s", lstrn, lstr, lcaststr);
Delete(lcaststr); Delete(lcaststr);
Delete(lstr); Delete(lstr);
Delete(lstrn);
} else { } else {
String *lstrname = SwigType_lstr(t,name); String *lstrname = SwigType_lstr(t,name);
Printf(decl,"%s", lstrname); Printf(decl,"%s", lstrname);
@ -194,7 +196,9 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
tycode = SwigType_type(tvalue); tycode = SwigType_type(tvalue);
if (tycode != T_USER) { if (tycode != T_USER) {
/* plain primitive type, we copy the the def value */ /* plain primitive type, we copy the the def value */
defvalue = NewStringf("%s = %s", SwigType_lstr(tvalue,defname),qvalue); String *lstr = SwigType_lstr(tvalue,defname);
defvalue = NewStringf("%s = %s", lstr,qvalue);
Delete(lstr);
} else { } else {
/* user type, we copy the reference value */ /* user type, we copy the reference value */
String *str = SwigType_str(type,defname); String *str = SwigType_str(type,defname);
@ -240,8 +244,12 @@ String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_ch
case T_VOID: case T_VOID:
break; break;
case T_REFERENCE: case T_REFERENCE:
{
String *str = SwigType_str(t,"_result_ref");
Printf(fcall,"{\n"); Printf(fcall,"{\n");
Printf(fcall,"%s = ", SwigType_str(t,"_result_ref")); Printf(fcall,"%s = ", str);
Delete(str);
}
break; break;
case T_USER: case T_USER:
Printf(fcall,"%s = ", name); Printf(fcall,"%s = ", name);
@ -249,7 +257,11 @@ String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_ch
default: default:
/* Normal return value */ /* Normal return value */
Printf(fcall,"%s = (%s)", name, SwigType_lstr(t,0)); {
String *lstr = SwigType_lstr(t,0);
Printf(fcall,"%s = (%s)", name, lstr);
Delete(lstr);
}
break; break;
} }
@ -311,7 +323,7 @@ Swig_cfunction_call(String_or_char *name, ParmList *parms) {
} else { } else {
Printf(func,"%s(", nname); Printf(func,"%s(", nname);
} }
Delete(nname);
while (p) { while (p) {
SwigType *pt = Getattr(p,"type"); SwigType *pt = Getattr(p,"type");
@ -770,7 +782,11 @@ Swig_MethodToFunction(Node *n, String *classname, int flags) {
/* Generate action code for the access */ /* Generate action code for the access */
if (!(flags & CWRAP_EXTEND)) { if (!(flags & CWRAP_EXTEND)) {
Setattr(n,"wrap:action", Swig_cresult(Getattr(n,"type"),"result", Swig_cmethod_call(name,p,self))); String *call = Swig_cmethod_call(name,p,self);
String *result = Swig_cresult(Getattr(n,"type"),"result", call);
Setattr(n,"wrap:action", result);
Delete(call);
Delete(result);
} else { } else {
/* Methods with default arguments are wrapped with additional methods for each default argument, /* Methods with default arguments are wrapped with additional methods for each default argument,
* however, only one extra %extend method is generated. */ * however, only one extra %extend method is generated. */

View file

@ -43,8 +43,8 @@ Swig_fragment_register(Node* fragment) {
Append(name,mangle); Append(name,mangle);
Delete(mangle); Delete(mangle);
Delete(rtype); Delete(rtype);
}
if (debug) Printf(stdout,"register fragment %s %s\n",name,type); if (debug) Printf(stdout,"register fragment %s %s\n",name,type);
}
if (!fragments) { if (!fragments) {
fragments = NewHash(); fragments = NewHash();
} }
@ -54,15 +54,14 @@ Swig_fragment_register(Node* fragment) {
Hash *kwargs = Getattr(fragment,"kwargs"); Hash *kwargs = Getattr(fragment,"kwargs");
Setmeta(ccode,"section",section); Setmeta(ccode,"section",section);
if (kwargs) { if (kwargs) {
kwargs = Copy(kwargs);
Setmeta(ccode,"kwargs",kwargs); Setmeta(ccode,"kwargs",kwargs);
Delete(kwargs);
} }
Setattr(fragments,name,ccode); Setattr(fragments,name,ccode);
if (debug) Printf(stdout,"registering fragment %s %s\n",name,section); if (debug) Printf(stdout,"registering fragment %s %s\n",name,section);
Delete(section); Delete(section);
Delete(ccode); Delete(ccode);
} }
Delete(name);
} }
} }
@ -140,6 +139,7 @@ Swig_fragment_emit(Node *n) {
pc = char_index(tok,','); pc = char_index(tok,',');
if (pc) *pc = 0; if (pc) *pc = 0;
} }
Delete(name);
} }
Delete(t); Delete(t);
} }

View file

@ -167,6 +167,7 @@ Swig_search_path_any(int syspath) {
} else { } else {
Append(slist,filename); Append(slist,filename);
} }
Delete(filename);
} }
if (syspath) { if (syspath) {
for (i = 0; i < Len(llist); i++) { for (i = 0; i < Len(llist); i++) {

View file

@ -401,12 +401,15 @@ Swig_name_object_set(Hash *namehash, String *name, SwigType *decl, DOH *object)
if (!n) { if (!n) {
n = NewHash(); n = NewHash();
Setattr(namehash,name,n); Setattr(namehash,name,n);
Delete(n);
} }
/* Add an object based on the declarator value */ /* Add an object based on the declarator value */
if (!decl) { if (!decl) {
Setattr(n,"*",object); Setattr(n,"*",object);
} else { } else {
Setattr(n,Copy(decl),object); SwigType *cd = Copy(decl);
Setattr(n,cd,object);
Delete(cd);
} }
} }
@ -555,7 +558,9 @@ static void merge_features(Hash *features, Node *n) {
if (!features) return; if (!features) return;
for (ki = First(features); ki.key; ki = Next(ki)) { for (ki = First(features); ki.key; ki = Next(ki)) {
Setattr(n,ki.key,Copy(ki.item)); String *ci = Copy(ki.item);
Setattr(n,ki.key,ci);
Delete(ci);
} }
} }
@ -683,18 +688,21 @@ Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, con
if (!n) { if (!n) {
n = NewHash(); n = NewHash();
Setattr(features,name,n); Setattr(features,name,n);
Delete(n);
} }
if (!decl) { if (!decl) {
fhash = Getattr(n,"*"); fhash = Getattr(n,"*");
if (!fhash) { if (!fhash) {
fhash = NewHash(); fhash = NewHash();
Setattr(n,"*",fhash); Setattr(n,"*",fhash);
Delete(fhash);
} }
} else { } else {
fhash = Getattr(n,decl); fhash = Getattr(n,decl);
if (!fhash) { if (!fhash) {
fhash = NewHash(); fhash = NewHash();
Setattr(n,Copy(decl),fhash); Setattr(n,Copy(decl),fhash);
Delete(fhash);
} }
} }
if (value) { if (value) {

View file

@ -195,10 +195,10 @@ String *ParmList_str(ParmList *p) {
String *out = NewStringEmpty(); String *out = NewStringEmpty();
while(p) { while(p) {
String *pstr = SwigType_str(Getattr(p,"type"), Getattr(p,"name")); String *pstr = SwigType_str(Getattr(p,"type"), Getattr(p,"name"));
Append(out,pstr); StringAppend(out,pstr);
p = nextSibling(p); p = nextSibling(p);
if (p) { if (p) {
Append(out,","); StringAppend(out,",");
} }
Delete(pstr); Delete(pstr);
} }
@ -216,13 +216,13 @@ String *ParmList_str_defaultargs(ParmList *p) {
while(p) { while(p) {
String *value = Getattr(p,"value"); String *value = Getattr(p,"value");
String *pstr = SwigType_str(Getattr(p,"type"), Getattr(p,"name")); String *pstr = SwigType_str(Getattr(p,"type"), Getattr(p,"name"));
Append(out,pstr); StringAppend(out,pstr);
if (value) { if (value) {
Printf(out,"=%s", value); Printf(out,"=%s", value);
} }
p = nextSibling(p); p = nextSibling(p);
if (p) { if (p) {
Append(out,","); StringAppend(out,",");
} }
Delete(pstr); Delete(pstr);
} }
@ -242,10 +242,10 @@ String *ParmList_protostr(ParmList *p) {
p = nextSibling(p); p = nextSibling(p);
} else { } else {
String *pstr = SwigType_str(Getattr(p,"type"), 0); String *pstr = SwigType_str(Getattr(p,"type"), 0);
Append(out,pstr); StringAppend(out,pstr);
p = nextSibling(p); p = nextSibling(p);
if (p) { if (p) {
Append(out,","); StringAppend(out,",");
} }
Delete(pstr); Delete(pstr);
} }

View file

@ -889,18 +889,22 @@ String *SwigType_lcaststr(SwigType *s, const String_or_char *name) {
result = NewStringEmpty(); result = NewStringEmpty();
if (SwigType_isarray(s)) { if (SwigType_isarray(s)) {
Printf(result,"(%s)%s", SwigType_lstr(s,0),name); String *lstr = SwigType_lstr(s,0);
Printf(result,"(%s)%s", lstr,name);
Delete(lstr);
} else if (SwigType_isreference(s)) { } else if (SwigType_isreference(s)) {
String *str = SwigType_str(s,0); String *str = SwigType_str(s,0);
Printf(result,"(%s)", str); Printf(result,"(%s)", str);
Delete(str); Delete(str);
if (name) if (name)
Append(result,name); StringAppend(result,name);
} else if (SwigType_isqualifier(s)) { } else if (SwigType_isqualifier(s)) {
Printf(result,"(%s)%s", SwigType_lstr(s,0),name); String *lstr = SwigType_lstr(s,0);
Printf(result,"(%s)%s", lstr,name);
Delete(lstr);
} else { } else {
if (name) if (name)
Append(result,name); StringAppend(result,name);
} }
return result; return result;
} }
@ -1007,17 +1011,17 @@ SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
List *tparms = SwigType_parmlist(e); List *tparms = SwigType_parmlist(e);
int j; int j;
String *nt = SwigType_templateprefix(e); String *nt = SwigType_templateprefix(e);
Append(nt,"<("); StringAppend(nt,"<(");
for (j = 0; j < Len(tparms); j++) { for (j = 0; j < Len(tparms); j++) {
SwigType_typename_replace(Getitem(tparms,j), pat, rep); SwigType_typename_replace(Getitem(tparms,j), pat, rep);
Append(nt,Getitem(tparms,j)); StringAppend(nt,Getitem(tparms,j));
if (j < (Len(tparms)-1)) Putc(',',nt); if (j < (Len(tparms)-1)) Putc(',',nt);
} }
tsuffix = SwigType_templatesuffix(e); tsuffix = SwigType_templatesuffix(e);
Printf(nt,")>%s", tsuffix); Printf(nt,")>%s", tsuffix);
Delete(tsuffix); Delete(tsuffix);
Clear(e); Clear(e);
Append(e,nt); StringAppend(e,nt);
Delete(nt); Delete(nt);
Delete(tparms); Delete(tparms);
} }
@ -1036,18 +1040,18 @@ SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
int j; int j;
List *fparms = SwigType_parmlist(e); List *fparms = SwigType_parmlist(e);
Clear(e); Clear(e);
Append(e,"f("); StringAppend(e,"f(");
for (j = 0; j < Len(fparms); j++) { for (j = 0; j < Len(fparms); j++) {
SwigType_typename_replace(Getitem(fparms,j), pat, rep); SwigType_typename_replace(Getitem(fparms,j), pat, rep);
Append(e,Getitem(fparms,j)); StringAppend(e,Getitem(fparms,j));
if (j < (Len(fparms)-1)) Putc(',',e); if (j < (Len(fparms)-1)) Putc(',',e);
} }
Append(e,")."); StringAppend(e,").");
Delete(fparms); Delete(fparms);
} else if (SwigType_isarray(e)) { } else if (SwigType_isarray(e)) {
Replace(e,pat,rep, DOH_REPLACE_ID); Replace(e,pat,rep, DOH_REPLACE_ID);
} }
Append(nt,e); StringAppend(nt,e);
} }
Clear(t); Clear(t);
Append(t,nt); Append(t,nt);
@ -1067,10 +1071,9 @@ SwigType_check_decl(SwigType *ty, const SwigType *decl) {
t = SwigType_typedef_resolve_all(ty); t = SwigType_typedef_resolve_all(ty);
t1 = SwigType_strip_qualifiers(t); t1 = SwigType_strip_qualifiers(t);
t2 = SwigType_prefix(t1); t2 = SwigType_prefix(t1);
r = Cmp(t2,decl); r = Equal(t2,decl);
Delete(t); Delete(t);
Delete(t1); Delete(t1);
Delete(t2); Delete(t2);
if (r == 0) return 1; return r == 1;
return 0;
} }

View file

@ -236,7 +236,7 @@ Swig_symbol_dump_symtable() {
void void
Swig_symbol_init() { Swig_symbol_init() {
empty_string = NewStringEmpty(); empty_string = NewString("");
k_allowstypedef = NewString("allows_typedef"); k_allowstypedef = NewString("allows_typedef");
k_cdecl = NewString("cdecl"); k_cdecl = NewString("cdecl");
k_coloncolon = NewString("::"); k_coloncolon = NewString("::");

View file

@ -560,11 +560,12 @@ Swig_typemap_clear_apply(Parm *parms) {
if (tm) { if (tm) {
/* Clear typemaps that match our signature */ /* Clear typemaps that match our signature */
Iterator ki, ki2; Iterator ki, ki2;
char *ctsig = Char(tsig);
for (ki = First(tm); ki.key; ki = Next(ki)) { for (ki = First(tm); ki.key; ki = Next(ki)) {
if (Strncmp(ki.key,"tmap:",5) == 0) { char *ckey = Char(ki.key);
if (strncmp(ckey,"tmap:",5) == 0) {
int na = count_args(ki.key); int na = count_args(ki.key);
if ((na == narg) && Strstr(ki.key,tsig)) { if ((na == narg) && strstr(ckey,ctsig)) {
Hash *h = ki.item; Hash *h = ki.item;
for (ki2 = First(h); ki2.key; ki2 = Next(ki2)) { for (ki2 = First(h); ki2.key; ki2 = Next(ki2)) {
Delattr(h,ki2.key); Delattr(h,ki2.key);
@ -1255,7 +1256,7 @@ Printf(stdout, "Swig_typemap_lookup %s [%s %s]\n", op, type, pname ? pname : "NO
*/ */
st = Getattr(node,"sym:symtab"); st = Getattr(node,"sym:symtab");
qsn = st ? Swig_symbol_qualifiedscopename(st) : 0; qsn = st ? Swig_symbol_qualifiedscopename(st) : 0;
if (qsn && Len(qsn)) { if (qsn && StringLen(qsn)) {
/* look qualified names first, such as /* look qualified names first, such as
int *Foo::foo(int bar) -> Foo::foo int *Foo::foo(int bar) -> Foo::foo
@ -1540,6 +1541,7 @@ Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f)
/* increase argnum to consider numinputs */ /* increase argnum to consider numinputs */
argnum += nmatch - 1; argnum += nmatch - 1;
Delete(s);
} }
} }
@ -1566,7 +1568,7 @@ static List *split_embedded(String *s) {
int leading = 1; int leading = 1;
args = NewList(); args = NewList();
c = Strstr(s,"("); c = strstr(Char(s),"(");
c++; c++;
start = c; start = c;
@ -1605,7 +1607,7 @@ static void split_var(String *s, String **name, String **value) {
char *eq; char *eq;
char *c; char *c;
eq = Strstr(s,"="); eq = strstr(Char(s),"=");
if (!eq) { if (!eq) {
*name = 0; *name = 0;
*value = 0; *value = 0;
@ -1630,10 +1632,10 @@ static void split_var(String *s, String **name, String **value) {
static void replace_embedded_typemap(String *s) { static void replace_embedded_typemap(String *s) {
char *start = 0; char *start = 0;
while (start = strstr(Char(s),"$TYPEMAP(")) { while ((start = strstr(Char(s),"$TYPEMAP("))) {
/* Gather the argument */ /* Gather the argument */
char *start, *end=0,*c; char *end=0,*c;
int level = 0; int level = 0;
String *tmp; String *tmp;
c = start; c = start;

View file

@ -719,6 +719,7 @@ SwigType_function_parms(SwigType *t) {
if (!firstp) firstp = p; if (!firstp) firstp = p;
if (pp) { if (pp) {
set_nextSibling(pp,p); set_nextSibling(pp,p);
Delete(p);
} }
pp = p; pp = p;
} }

View file

@ -858,7 +858,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
String *result; String *result;
int i,len; int i,len;
if (!typedef_qualified_cache) typedef_qualified_cache = NewHash(); if (!typedef_qualified_cache) typedef_qualified_cache = NewHash();
result = Getattr(typedef_qualified_cache,t); result = HashGetAttr(typedef_qualified_cache,t);
if (result) { if (result) {
String *rc = Copy(result); String *rc = Copy(result);
return rc; return rc;
@ -1403,6 +1403,7 @@ void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata)
SwigType *fr; SwigType *fr;
SwigType *qr; SwigType *qr;
String *tkey; String *tkey;
String *cd;
if (!r_mangled) { if (!r_mangled) {
r_mangled = NewHash(); r_mangled = NewHash();
@ -1419,8 +1420,10 @@ void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata)
} }
tkey = Copy(t); tkey = Copy(t);
Setattr(r_remembered, tkey, clientdata ? NewString(clientdata) : (void *) ""); cd = clientdata ? NewString(clientdata) : NewStringEmpty();
Setattr(r_remembered, tkey, cd);
Delete(tkey); Delete(tkey);
Delete(cd);
mt = SwigType_manglestr(t); /* Create mangled string */ mt = SwigType_manglestr(t); /* Create mangled string */