Major refactoring of DOH List/Hash iterators. See CHANGES

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5101 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2003-09-11 20:26:57 +00:00
commit 4cf4dad108
35 changed files with 657 additions and 636 deletions

View file

@ -87,10 +87,12 @@ static Node *new_node(const String_or_char *tag) {
static Node *copy_node(Node *n) { static Node *copy_node(Node *n) {
Node *nn; Node *nn;
String *key; String *key;
Iterator k;
nn = NewHash(); nn = NewHash();
Setfile(nn,Getfile(n)); Setfile(nn,Getfile(n));
Setline(nn,Getline(n)); Setline(nn,Getline(n));
for (key = Firstkey(n); key; key = Nextkey(n)) { for (k = First(n); k.key; k = Next(k)) {
key = k.key;
if ((Strcmp(key,"nextSibling") == 0) || if ((Strcmp(key,"nextSibling") == 0) ||
(Strcmp(key,"previousSibling") == 0) || (Strcmp(key,"previousSibling") == 0) ||
(Strcmp(key,"parentNode") == 0) || (Strcmp(key,"parentNode") == 0) ||
@ -102,7 +104,7 @@ static Node *copy_node(Node *n) {
if ((Strcmp(key,"sym:name") == 0) || if ((Strcmp(key,"sym:name") == 0) ||
(Strcmp(key,"sym:weak") == 0) || (Strcmp(key,"sym:weak") == 0) ||
(Strcmp(key,"sym:typename") == 0)) { (Strcmp(key,"sym:typename") == 0)) {
Setattr(nn,key, Copy(Getattr(n,key))); Setattr(nn,key, Copy(k.item));
continue; continue;
} }
if (Strcmp(key,"sym:symtab") == 0) { if (Strcmp(key,"sym:symtab") == 0) {
@ -115,7 +117,7 @@ static Node *copy_node(Node *n) {
/* If children. We copy them recursively using this function */ /* If children. We copy them recursively using this function */
if (Strcmp(key,"firstChild") == 0) { if (Strcmp(key,"firstChild") == 0) {
/* Copy children */ /* Copy children */
Node *cn = Getattr(n,key); Node *cn = k.item;
while (cn) { while (cn) {
appendChild(nn,copy_node(cn)); appendChild(nn,copy_node(cn));
cn = nextSibling(cn); cn = nextSibling(cn);
@ -135,11 +137,11 @@ static Node *copy_node(Node *n) {
continue; continue;
} }
if ((Strcmp(key,"parms") == 0) || (Strcmp(key,"pattern") == 0) || (Strcmp(key,"throws") == 0)) { if ((Strcmp(key,"parms") == 0) || (Strcmp(key,"pattern") == 0) || (Strcmp(key,"throws") == 0)) {
Setattr(nn,key,CopyParmList(Getattr(n,key))); Setattr(nn,key,CopyParmList(k.item));
continue; continue;
} }
/* Looks okay. Just copy the data using Copy */ /* Looks okay. Just copy the data using Copy */
Setattr(nn, key, Copy(Getattr(n,key))); Setattr(nn, key, Copy(k.item));
} }
return nn; return nn;
} }
@ -527,12 +529,12 @@ static void merge_extensions(Node *cls, Node *am) {
extensions for templates */ extensions for templates */
static void check_extensions() { static void check_extensions() {
String *key; Iterator ki;
if (!extendhash) return; if (!extendhash) return;
for (key = Firstkey(extendhash); key; key = Nextkey(extendhash)) { for (ki = First(extendhash); ki.key; ki = Next(ki)) {
Node *n = Getattr(extendhash,key); if (!Strstr(ki.key,"<")) {
if (!Strstr(key,"<")) { Swig_warning(WARN_PARSE_EXTEND_UNDEF,Getfile(ki.item), Getline(ki.item), "%%extend defined for an undeclared class %s.\n", ki.key);
Swig_warning(WARN_PARSE_EXTEND_UNDEF,Getfile(n), Getline(n), "%%extend defined for an undeclared class %s.\n", key);
} }
} }
} }
@ -1851,6 +1853,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
if (ns) { if (ns) {
List *scopes; List *scopes;
String *sname; String *sname;
Iterator si;
String *name = NewString(prefix); String *name = NewString(prefix);
scopes = NewList(); scopes = NewList();
while (name) { while (name) {
@ -1861,9 +1864,9 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
Delete(name); Delete(name);
name = tprefix; name = tprefix;
} }
for (sname = Firstitem(scopes); sname; sname = Nextitem(scopes)) { for (si = First(scopes); si.item; si = Next(si)) {
Node *ns1,*ns2; Node *ns1,*ns2;
sname = si.item;
ns1 = Swig_symbol_clookup(sname,0); ns1 = Swig_symbol_clookup(sname,0);
assert(ns1); assert(ns1);
if (Strcmp(nodeType(ns1),"namespace") == 0) { if (Strcmp(nodeType(ns1),"namespace") == 0) {
@ -1987,9 +1990,9 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
if (baselist) { if (baselist) {
List *bases = make_inherit_list(Getattr($$,"name"),baselist); List *bases = make_inherit_list(Getattr($$,"name"),baselist);
if (bases) { if (bases) {
Node *s; Iterator s;
for (s = Firstitem(bases); s; s = Nextitem(bases)) { for (s = First(bases); s.item; s = Next(s)) {
Symtab *st = Getattr(s,"symtab"); Symtab *st = Getattr(s.item,"symtab");
if (st) { if (st) {
Swig_symbol_inherit(st); Swig_symbol_inherit(st);
} }
@ -2342,9 +2345,9 @@ cpp_class_decl :
Swig_symbol_newscope(); Swig_symbol_newscope();
Swig_symbol_setscopename($3); Swig_symbol_setscopename($3);
if (bases) { if (bases) {
Node *s; Iterator s;
for (s = Firstitem(bases); s; s = Nextitem(bases)) { for (s = First(bases); s.item; s = Next(s)) {
Symtab *st = Getattr(s,"symtab"); Symtab *st = Getattr(s.item,"symtab");
if (st) { if (st) {
Swig_symbol_inherit(st); Swig_symbol_inherit(st);
} }
@ -2714,16 +2717,16 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para
} }
/* Patch argument names with typedef */ /* Patch argument names with typedef */
{ {
SwigType *tt; Iterator tt;
List *tparms = SwigType_parmlist(fname); List *tparms = SwigType_parmlist(fname);
ffname = SwigType_templateprefix(fname); ffname = SwigType_templateprefix(fname);
Append(ffname,"<("); Append(ffname,"<(");
for (tt = Firstitem(tparms); tt; ) { for (tt = First(tparms); tt.item; ) {
SwigType *ttr = Swig_symbol_typedef_reduce(tt,0); SwigType *ttr = Swig_symbol_typedef_reduce(tt.item,0);
ttr = Swig_symbol_type_qualify(ttr,0); ttr = Swig_symbol_type_qualify(ttr,0);
Append(ffname,ttr); Append(ffname,ttr);
tt = Nextitem(tparms); tt = Next(tt);
if (tt) Putc(',',ffname); if (tt.item) Putc(',',ffname);
} }
Append(ffname,")>"); Append(ffname,")>");
} }
@ -2747,16 +2750,16 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para
/* This needs to be rewritten */ /* This needs to be rewritten */
List *tparms; List *tparms;
String *fname; String *fname;
SwigType *tt; Iterator tt;
fname = SwigType_templateprefix(tname); fname = SwigType_templateprefix(tname);
tparms = SwigType_parmlist(tname); tparms = SwigType_parmlist(tname);
Append(fname,"<("); Append(fname,"<(");
for (tt = Firstitem(tparms); tt; ) { for (tt = First(tparms); tt.item; ) {
SwigType *ttr = Swig_symbol_typedef_reduce(tt,0); SwigType *ttr = Swig_symbol_typedef_reduce(tt.item,0);
ttr = Swig_symbol_type_qualify(ttr,0); ttr = Swig_symbol_type_qualify(ttr,0);
Append(fname,ttr); Append(fname,ttr);
tt = Nextitem(tparms); tt = Next(tt);
if (tt) Putc(',',fname); if (tt.item) Putc(',',fname);
} }
Append(fname,")>"); Append(fname,")>");
Swig_symbol_cadd(fname,$$); Swig_symbol_cadd(fname,$$);

View file

@ -361,11 +361,11 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms) {
{ {
List *bases = Getattr(n,"baselist"); List *bases = Getattr(n,"baselist");
if (bases) { if (bases) {
String *b; Iterator b;
for (b = Firstitem(bases); b; b = Nextitem(bases)) { for (b = First(bases); b.item; b = Next(b)) {
String *qn = Swig_symbol_type_qualify(b,0); String *qn = Swig_symbol_type_qualify(b.item,0);
Clear(b); Clear(b.item);
Append(b,qn); Append(b.item,qn);
} }
} }
} }
@ -473,12 +473,13 @@ Swig_cparse_template_locate(String *name, Parm *tparms) {
char tmp[32]; char tmp[32];
int i; int i;
List *partials; List *partials;
String *s, *ss; String *ss;
Iterator pi;
partials = Getattr(templ,"partials"); partials = Getattr(templ,"partials");
if (partials) { if (partials) {
for (s = Firstitem(partials); s; s= Nextitem(partials)) { for (pi = First(partials); pi.item; pi = Next(pi)) {
ss = Copy(s); ss = Copy(pi.item);
p = parms; p = parms;
i = 1; i = 1;
while (p) { while (p) {
@ -497,10 +498,10 @@ Swig_cparse_template_locate(String *name, Parm *tparms) {
p = nextSibling(p); p = nextSibling(p);
} }
if (template_debug) { if (template_debug) {
Printf(stdout," searching: '%s' (partial specialization - %s)\n", ss, s); Printf(stdout," searching: '%s' (partial specialization - %s)\n", ss, pi.item);
} }
if ((Strcmp(ss,tname) == 0) || (Strcmp(ss,rname) == 0)) { if ((Strcmp(ss,tname) == 0) || (Strcmp(ss,rname) == 0)) {
Append(mpartials,s); Append(mpartials,pi.item);
} }
Delete(ss); Delete(ss);
} }

View file

@ -31,6 +31,8 @@ First(obj) Return first object (iterator)
Next(obj) Return next object Next(obj) Return next object
Dump(obj,out) Serialize on out Dump(obj,out) Serialize on out
Load(in) Unserialize from in Load(in) Unserialize from in
First(obj) Iterator
Next(iter) Next iterator
Mapping Operations (for hash table behavior) Mapping Operations (for hash table behavior)
-------------------------------------------- --------------------------------------------

View file

@ -192,6 +192,51 @@ DohCmp(const DOH *obj1, const DOH *obj2) {
return 1; return 1;
} }
/* -----------------------------------------------------------------------------
* DohFirst()
* ----------------------------------------------------------------------------- */
DohIterator
DohFirst(DOH *obj) {
DohIterator iter;
DohBase *b;
DohObjInfo *binfo;
b = (DohBase *) obj;
if (DohCheck(b)) {
binfo = b->type;
if (binfo->doh_first) {
return (binfo->doh_first)(b);
}
}
iter.object = 0;
iter.item = 0;
iter.key = 0;
return iter;
}
/* -----------------------------------------------------------------------------
* DohNext()
* ----------------------------------------------------------------------------- */
DohIterator
DohNext(DohIterator iter) {
DohIterator niter;
if (iter.object) {
DohBase *b;
DohObjInfo *binfo;
b = (DohBase *) iter.object;
binfo = b->type;
if (binfo->doh_next) {
return (binfo->doh_next)(iter);
}
}
niter = iter;
return niter;
}
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* DohIsMapping() * DohIsMapping()
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
@ -249,35 +294,7 @@ DohDelattr(DOH *obj, const DOH *name) {
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* DohFirstkey() * DohKeys()
* ----------------------------------------------------------------------------- */
DOH *
DohFirstkey(DOH *obj) {
DohBase *b = (DohBase *) obj;
DohObjInfo *objinfo = b->type;
if (objinfo->doh_hash && objinfo->doh_hash->doh_firstkey) {
return (objinfo->doh_hash->doh_firstkey)(b);
}
return 0;
}
/* -----------------------------------------------------------------------------
* DohNextkey()
* ----------------------------------------------------------------------------- */
DOH *
DohNextkey(DOH *obj) {
DohBase *b = (DohBase *) obj;
DohObjInfo *objinfo = b->type;
if (objinfo && objinfo->doh_hash->doh_nextkey) {
return (objinfo->doh_hash->doh_nextkey)(b);
}
return 0;
}
/* -----------------------------------------------------------------------------
* DohNextkey()
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
DOH * DOH *
@ -474,34 +491,6 @@ DohDelslice(DOH *obj, int sindex, int eindex) {
return -1; return -1;
} }
/* -----------------------------------------------------------------------------
* DohFirstitem()
* ----------------------------------------------------------------------------- */
DOH *
DohFirstitem(DOH *obj) {
DohBase *b = (DohBase *) obj;
DohObjInfo *objinfo = b->type;
if (objinfo->doh_list && objinfo->doh_list->doh_firstitem) {
return (objinfo->doh_list->doh_firstitem)(b);
}
return 0;
}
/* -----------------------------------------------------------------------------
* DohNextitem()
* ----------------------------------------------------------------------------- */
DOH *
DohNextitem(DOH *obj) {
DohBase *b = (DohBase *) obj;
DohObjInfo *objinfo = b->type;
if (objinfo->doh_list && objinfo->doh_list->doh_nextitem) {
return (objinfo->doh_list->doh_nextitem)(b);
}
return 0;
}
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* DohIsFile() * DohIsFile()
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */

View file

@ -44,8 +44,6 @@
#define DohGetattr DOH_NAMESPACE(Getattr) #define DohGetattr DOH_NAMESPACE(Getattr)
#define DohSetattr DOH_NAMESPACE(Setattr) #define DohSetattr DOH_NAMESPACE(Setattr)
#define DohDelattr DOH_NAMESPACE(Delattr) #define DohDelattr DOH_NAMESPACE(Delattr)
#define DohFirstkey DOH_NAMESPACE(Firstkey)
#define DohNextkey DOH_NAMESPACE(Nextkey)
#define DohKeys DOH_NAMESPACE(Keys) #define DohKeys DOH_NAMESPACE(Keys)
#define DohGetInt DOH_NAMESPACE(GetInt) #define DohGetInt DOH_NAMESPACE(GetInt)
#define DohGetDouble DOH_NAMESPACE(GetDouble) #define DohGetDouble DOH_NAMESPACE(GetDouble)
@ -60,8 +58,6 @@
#define DohDelitem DOH_NAMESPACE(Delitem) #define DohDelitem DOH_NAMESPACE(Delitem)
#define DohInsertitem DOH_NAMESPACE(Insertitem) #define DohInsertitem DOH_NAMESPACE(Insertitem)
#define DohDelslice DOH_NAMESPACE(Delslice) #define DohDelslice DOH_NAMESPACE(Delslice)
#define DohFirstitem DOH_NAMESPACE(Firstitem)
#define DohNextitem DOH_NAMESPACE(Nextitem)
#define DohWrite DOH_NAMESPACE(Write) #define DohWrite DOH_NAMESPACE(Write)
#define DohRead DOH_NAMESPACE(Read) #define DohRead DOH_NAMESPACE(Read)
#define DohSeek DOH_NAMESPACE(Seek) #define DohSeek DOH_NAMESPACE(Seek)
@ -113,7 +109,9 @@
#define DohHashType DOH_NAMESPACE(HashType) #define DohHashType DOH_NAMESPACE(HashType)
#define DohFileType DOH_NAMESPACE(FileType) #define DohFileType DOH_NAMESPACE(FileType)
#define DohVoidType DOH_NAMESPACE(VoidType) #define DohVoidType DOH_NAMESPACE(VoidType)
#define DohIterator DOH_NAMESPACE(Iterator)
#define DohFirst DOH_NAMESPACE(First)
#define DohNext DOH_NAMESPACE(Next)
#endif #endif
#include <stdio.h> #include <stdio.h>
@ -143,6 +141,16 @@ typedef void DOH;
#define DOH_CUR -3 #define DOH_CUR -3
#define DOH_CURRENT -3 #define DOH_CURRENT -3
/* Iterator objects */
typedef struct {
void *key; /* Current key (if any) */
void *item; /* Current item */
void *object; /* Object being iterated over */
void *_current; /* Internal use */
int _index; /* Internal use */
} DohIterator;
/* Memory management */ /* Memory management */
#ifndef DohMalloc #ifndef DohMalloc
@ -176,8 +184,6 @@ extern void DohIncref(DOH *obj);
extern DOH *DohGetattr(DOH *obj, const DOHString_or_char *name); extern DOH *DohGetattr(DOH *obj, const DOHString_or_char *name);
extern int DohSetattr(DOH *obj, const DOHString_or_char *name, const DOHObj_or_char *value); extern int DohSetattr(DOH *obj, const DOHString_or_char *name, const DOHObj_or_char *value);
extern int DohDelattr(DOH *obj, const DOHString_or_char *name); extern int DohDelattr(DOH *obj, const DOHString_or_char *name);
extern DOH *DohFirstkey(DOH *obj);
extern DOH *DohNextkey(DOH *obj);
extern DOH *DohKeys(DOH *obj); extern DOH *DohKeys(DOH *obj);
extern int DohGetInt(DOH *obj, const DOHString_or_char *name); extern int DohGetInt(DOH *obj, const DOHString_or_char *name);
extern double DohGetDouble(DOH *obj, const DOHString_or_char *name); extern double DohGetDouble(DOH *obj, const DOHString_or_char *name);
@ -194,8 +200,6 @@ extern int DohSetitem(DOH *obj, int index, const DOHObj_or_char *value
extern int DohDelitem(DOH *obj, int index); extern int DohDelitem(DOH *obj, int index);
extern int DohInsertitem(DOH *obj, int index, const DOHObj_or_char *value); extern int DohInsertitem(DOH *obj, int index, const DOHObj_or_char *value);
extern int DohDelslice(DOH *obj, int sindex, int eindex); extern int DohDelslice(DOH *obj, int sindex, int eindex);
extern DOH *DohFirstitem(DOH *obj);
extern DOH *DohNextitem(DOH *obj);
/* File methods */ /* File methods */
@ -207,7 +211,11 @@ extern int DohGetc(DOHFile *obj);
extern int DohPutc(int ch, DOHFile *obj); extern int DohPutc(int ch, DOHFile *obj);
extern int DohUngetc(int ch, DOHFile *obj); extern int DohUngetc(int ch, DOHFile *obj);
/* Positional */ /* Iterators */
extern DohIterator DohFirst(DOH *obj);
extern DohIterator DohNext(DohIterator x);
/* Positional */
extern int DohGetline(DOH *obj); extern int DohGetline(DOH *obj);
extern void DohSetline(DOH *obj, int line); extern void DohSetline(DOH *obj, int line);
@ -321,8 +329,6 @@ extern void DohMemoryDebug(void);
#define Append(s,x) DohInsertitem(s,DOH_END,x) #define Append(s,x) DohInsertitem(s,DOH_END,x)
#define Push(s,x) DohInsertitem(s,DOH_BEGIN,x) #define Push(s,x) DohInsertitem(s,DOH_BEGIN,x)
#define Len DohLen #define Len DohLen
#define Firstkey DohFirstkey
#define Nextkey DohNextkey
#define Data DohData #define Data DohData
#define Char (char *) Data #define Char (char *) Data
#define Cmp DohCmp #define Cmp DohCmp
@ -349,8 +355,6 @@ extern void DohMemoryDebug(void);
#define SetDouble DohSetDouble #define SetDouble DohSetDouble
#define SetChar DohSetattr #define SetChar DohSetattr
#define SetVoid DohSetVoid #define SetVoid DohSetVoid
#define Firstitem DohFirstitem
#define Nextitem DohNextitem
#define Readline DohReadline #define Readline DohReadline
#define Replace DohReplace #define Replace DohReplace
#define Chop DohChop #define Chop DohChop
@ -378,6 +382,9 @@ extern void DohMemoryDebug(void);
#define Getmark DohGetmark #define Getmark DohGetmark
#define None DohNone #define None DohNone
#define Call DohCall #define Call DohCall
#define First DohFirst
#define Next DohNext
#define Iterator DohIterator
#endif #endif
#ifdef NIL #ifdef NIL

View file

@ -29,20 +29,16 @@ typedef struct {
DOH *(*doh_getattr)(DOH *obj, DOH *name); /* Get attribute */ DOH *(*doh_getattr)(DOH *obj, DOH *name); /* Get attribute */
int (*doh_setattr)(DOH *obj, DOH *name, DOH *value); /* Set attribute */ int (*doh_setattr)(DOH *obj, DOH *name, DOH *value); /* Set attribute */
int (*doh_delattr)(DOH *obj, DOH *name); /* Del attribute */ int (*doh_delattr)(DOH *obj, DOH *name); /* Del attribute */
DOH *(*doh_firstkey)(DOH *obj); /* First key */
DOH *(*doh_nextkey)(DOH *obj); /* Next key */
DOH *(*doh_keys)(DOH *obj); /* All keys as a list */ DOH *(*doh_keys)(DOH *obj); /* All keys as a list */
} DohHashMethods; } DohHashMethods;
/* List objects */ /* List objects */
typedef struct { typedef struct {
DOH *(*doh_getitem)(DOH *obj, int index); /* Get item */ DOH *(*doh_getitem)(DOH *obj, int index); /* Get item */
int (*doh_setitem)(DOH *obj, int index, DOH *value); /* Set item */ int (*doh_setitem)(DOH *obj, int index, DOH *value); /* Set item */
int (*doh_delitem)(DOH *obj, int index); /* Delete item */ int (*doh_delitem)(DOH *obj, int index); /* Delete item */
int (*doh_insitem)(DOH *obj, int index, DOH *value); /* Insert item */ int (*doh_insitem)(DOH *obj, int index, DOH *value); /* Insert item */
int (*doh_delslice)(DOH *obj, int sindex, int eindex); /* Delete slice */ int (*doh_delslice)(DOH *obj, int sindex, int eindex); /* Delete slice */
DOH *(*doh_firstitem)(DOH *obj); /* Iterators */
DOH *(*doh_nextitem)(DOH *obj);
} DohListMethods; } DohListMethods;
/* File methods */ /* File methods */
@ -87,6 +83,10 @@ typedef struct DohObjInfo {
/* Compare */ /* Compare */
int (*doh_cmp)(DOH *obj1, DOH *obj2); int (*doh_cmp)(DOH *obj1, DOH *obj2);
/* Iterators */
DohIterator (*doh_first)(DOH *obj);
DohIterator (*doh_next)(DohIterator );
/* Positional */ /* Positional */
void (*doh_setfile)(DOH *obj, DOHString_or_char *file); void (*doh_setfile)(DOH *obj, DOHString_or_char *file);
DOH *(*doh_getfile)(DOH *obj); DOH *(*doh_getfile)(DOH *obj);
@ -105,14 +105,15 @@ typedef struct {
void *data; /* Data pointer */ void *data; /* Data pointer */
DohObjInfo *type; DohObjInfo *type;
void *meta; /* Meta data */ void *meta; /* Meta data */
int flag_intern : 1; /* Interned object */ int flag_intern : 1; /* Interned object */
int flag_marked : 1; /* Mark flag. Used to avoid recursive loops in places */ int flag_marked : 1; /* Mark flag. Used to avoid recursive loops in places */
int flag_user : 1; /* User flag */ int flag_user : 1; /* User flag */
int flag_usermark : 1; /* User marked */ int flag_usermark : 1; /* User marked */
int refcount : 28; /* Reference count (max 16 million) */ int refcount : 28; /* Reference count (max 16 million) */
} DohBase; } DohBase;
/* Macros for decrefing and increfing (safe for null objects). */ /* Macros for decrefing and increfing (safe for null objects). */
#define Decref(a) if (a) ((DohBase *) a)->refcount-- #define Decref(a) if (a) ((DohBase *) a)->refcount--
#define Incref(a) if (a) ((DohBase *) a)->refcount++ #define Incref(a) if (a) ((DohBase *) a)->refcount++
#define Refcount(a) ((DohBase *) a)->refcount #define Refcount(a) ((DohBase *) a)->refcount
@ -124,7 +125,7 @@ typedef struct {
#define ObjType(a) ((DohBase *)a)->type #define ObjType(a) ((DohBase *)a)->type
extern DOH *DohObjMalloc(DohObjInfo *type, void *data); /* Allocate a DOH object */ extern DOH *DohObjMalloc(DohObjInfo *type, void *data); /* Allocate a DOH object */
extern void DohObjFree(DOH *ptr); /* Free a DOH object */ extern void DohObjFree(DOH *ptr); /* Free a DOH object */
#endif /* DOHINT_H */ #endif /* DOHINT_H */

View file

@ -214,6 +214,8 @@ static DohObjInfo DohFileType = {
0, /* doh_len */ 0, /* doh_len */
0, /* doh_hash */ 0, /* doh_hash */
0, /* doh_cmp */ 0, /* doh_cmp */
0, /* doh_first */
0, /* doh_next */
0, /* doh_setfile */ 0, /* doh_setfile */
0, /* doh_getfile */ 0, /* doh_getfile */
0, /* doh_setline */ 0, /* doh_setline */

View file

@ -28,9 +28,7 @@ typedef struct Hash {
int line; int line;
HashNode **hashtable; HashNode **hashtable;
int hashsize; int hashsize;
int currentindex;
int nitems; int nitems;
HashNode *current;
} Hash; } Hash;
/* Key interning structure */ /* Key interning structure */
@ -288,11 +286,6 @@ Hash_delattr(DOH *ho, DOH *k) {
} else { } else {
h->hashtable[hv] = n->next; h->hashtable[hv] = n->next;
} }
/* Need to check for iterator location */
if (n == h->current) {
h->current = prev; /* Move back to previous node. When next is called, will move to next node */
if (!h->current) h->currentindex--; /* No previous node. Move back one slot */
}
DelNode(n); DelNode(n);
h->nitems--; h->nitems--;
return 1; return 1;
@ -303,63 +296,53 @@ Hash_delattr(DOH *ho, DOH *k) {
return 0; return 0;
} }
/* General purpose iterators */ static DohIterator
static HashNode * Hash_firstiter(DOH *ho) {
hash_first(DOH *ho) { DohIterator iter;
Hash *h = (Hash *) ObjData(ho); Hash *h = (Hash *) ObjData(ho);
h->currentindex = 0; iter.object = ho;
h->current = 0; iter._current = 0;
while ((h->currentindex < h->hashsize) && !h->hashtable[h->currentindex]) iter.item = 0;
h->currentindex++; iter.key = 0;
if (h->currentindex >= h->hashsize) return 0; iter._index = 0; /* Index in hash table */
h->current = h->hashtable[h->currentindex]; while ((iter._index < h->hashsize) && !h->hashtable[iter._index])
return h->current; iter._index++;
if (iter._index >= h->hashsize) {
return iter;
}
iter._current = h->hashtable[iter._index];
iter.item = ((HashNode *) iter._current)->object;
iter.key = ((HashNode *) iter._current)->key;
/* Actually save the next slot in the hash. This makes it possible to
delete the item being iterated over without trashing the universe */
iter._current = ((HashNode*)iter._current)->next;
return iter;
} }
static HashNode * static DohIterator
hash_next(DOH *ho) { Hash_nextiter(DohIterator iter) {
Hash *h = (Hash *) ObjData(ho); Hash *h = (Hash *) ObjData(iter.object);
if (h->currentindex < 0) return hash_first(ho); if (!iter._current) {
iter._index++;
/* Try to move to the next entry */ while ((iter._index < h->hashsize) && !h->hashtable[iter._index]) {
if (h->current) { iter._index++;
h->current = h->current->next;
} }
if (h->current) { if (iter._index >= h->hashsize) {
return h->current; iter.item = 0;
iter.key = 0;
iter._current = 0;
return iter;
} }
h->currentindex++; iter._current = h->hashtable[iter._index];
while ((h->currentindex < h->hashsize) && !h->hashtable[h->currentindex]) }
h->currentindex++; iter.key = ((HashNode *) iter._current)->key;
if (h->currentindex >= h->hashsize) return 0; iter.item = ((HashNode *) iter._current)->object;
h->current = h->hashtable[h->currentindex];
return h->current;
}
/* ----------------------------------------------------------------------------- /* Store the next node to iterator on */
* Hash_firstkey() iter._current = ((HashNode*)iter._current)->next;
* return iter;
* Return first hash-table key.
* ----------------------------------------------------------------------------- */
static DOH *
Hash_firstkey(DOH *ho) {
HashNode *hn = hash_first(ho);
if (hn) return hn->key;
return 0;
}
/* -----------------------------------------------------------------------------
* Hash_nextkey()
*
* Return next hash table key.
* ----------------------------------------------------------------------------- */
static DOH *
Hash_nextkey(DOH *ho) {
HashNode *hn = hash_next(ho);
if (hn) return hn->key;
return 0;
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
@ -371,13 +354,11 @@ Hash_nextkey(DOH *ho) {
static DOH * static DOH *
Hash_keys(DOH *so) { Hash_keys(DOH *so) {
DOH *keys; DOH *keys;
DOH *k; Iterator i;
keys = NewList(); keys = NewList();
k = Firstkey(so); for (i = First(so); i.key; i = Next(i)) {
while (k) { Append(keys,i.key);
Append(keys,k);
k = Nextkey(so);
} }
return keys; return keys;
} }
@ -451,8 +432,6 @@ CopyHash(DOH *ho) {
for (i = 0; i < nh->hashsize; i++) { for (i = 0; i < nh->hashsize; i++) {
nh->hashtable[i] = 0; nh->hashtable[i] = 0;
} }
nh->currentindex = -1;
nh->current = 0;
nh->nitems = 0; nh->nitems = 0;
nh->line = h->line; nh->line = h->line;
nh->file = h->file; nh->file = h->file;
@ -512,8 +491,6 @@ static DohHashMethods HashHashMethods = {
Hash_getattr, Hash_getattr,
Hash_setattr, Hash_setattr,
Hash_delattr, Hash_delattr,
Hash_firstkey,
Hash_nextkey,
Hash_keys, Hash_keys,
}; };
@ -528,6 +505,8 @@ DohObjInfo DohHashType = {
Hash_len, /* doh_len */ Hash_len, /* doh_len */
0, /* doh_hash */ 0, /* doh_hash */
0, /* doh_cmp */ 0, /* doh_cmp */
Hash_firstiter, /* doh_first */
Hash_nextiter, /* doh_next */
Hash_setfile, /* doh_setfile */ Hash_setfile, /* doh_setfile */
Hash_getfile, /* doh_getfile */ Hash_getfile, /* doh_getfile */
Hash_setline, /* doh_setline */ Hash_setline, /* doh_setline */
@ -556,8 +535,6 @@ DohNewHash() {
for (i = 0; i < h->hashsize; i++) { for (i = 0; i < h->hashsize; i++) {
h->hashtable[i] = 0; h->hashtable[i] = 0;
} }
h->currentindex = -1;
h->current = 0;
h->nitems = 0; h->nitems = 0;
h->file = 0; h->file = 0;
h->line = 0; h->line = 0;

View file

@ -16,7 +16,6 @@ char cvsroot_list_c[] = "$Header$";
typedef struct List { typedef struct List {
int maxitems; /* Max size */ int maxitems; /* Max size */
int nitems; /* Num items */ int nitems; /* Num items */
int iter; /* Iterator */
DOH *file; DOH *file;
int line; int line;
DOH **items; DOH **items;
@ -46,7 +45,6 @@ CopyList(DOH *lo) {
nl->nitems = l->nitems; nl->nitems = l->nitems;
nl->maxitems = l->maxitems; nl->maxitems = l->maxitems;
nl->items = (void **) DohMalloc(l->maxitems*sizeof(void *)); nl->items = (void **) DohMalloc(l->maxitems*sizeof(void *));
nl->iter = 0;
for (i = 0; i < l->nitems; i++) { for (i = 0; i < l->nitems; i++) {
nl->items[i] = l->items[i]; nl->items[i] = l->items[i];
Incref(nl->items[i]); Incref(nl->items[i]);
@ -195,12 +193,19 @@ List_set(DOH *lo, int n, DOH *val) {
* Return the first item in the list. * Return the first item in the list.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
static DOH * static DohIterator
List_first(DOH *lo) { List_first(DOH *lo) {
List *l = (List *) ObjData(lo); DohIterator iter;
l->iter = 0; List *l = (List *) ObjData(lo);
if (l->iter >= l->nitems) return 0; iter.object = lo;
return l->items[l->iter]; iter._index = 0;
iter.key = 0;
if (l->nitems > 0) {
iter.item = l->items[0];
} else {
iter.item = 0;
}
return iter;
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
@ -209,12 +214,17 @@ List_first(DOH *lo) {
* Return the next item in the list. * Return the next item in the list.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
static DOH * static DohIterator
List_next(DOH *lo) { List_next(DohIterator iter) {
List *l = (List *) ObjData(lo); List *l = (List *) ObjData(iter.object);
l->iter++; iter._index = iter._index + 1;
if (l->iter >= l->nitems) return 0; if (iter._index >= l->nitems) {
return l->items[l->iter]; iter.item = 0;
iter.key = 0;
} else {
iter.item = l->items[iter._index];
}
return iter;
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
@ -300,8 +310,6 @@ static DohListMethods ListListMethods = {
List_remove, List_remove,
List_insert, List_insert,
0, /* delslice */ 0, /* delslice */
List_first,
List_next,
}; };
DohObjInfo DohListType = { DohObjInfo DohListType = {
@ -315,6 +323,8 @@ DohObjInfo DohListType = {
List_len, /* doh_len */ List_len, /* doh_len */
0, /* doh_hash */ 0, /* doh_hash */
0, /* doh_cmp */ 0, /* doh_cmp */
List_first, /* doh_first */
List_next, /* doh_next */
List_setfile, /* doh_setfile */ List_setfile, /* doh_setfile */
List_getfile, /* doh_getfile */ List_getfile, /* doh_getfile */
List_setline, /* doh_setline */ List_setline, /* doh_setline */
@ -346,7 +356,6 @@ DohNewList() {
for (i = 0; i < MAXLISTITEMS; i++) { for (i = 0; i < MAXLISTITEMS; i++) {
l->items[i] = 0; l->items[i] = 0;
} }
l->iter = 0;
l->file = 0; l->file = 0;
l->line = 0; l->line = 0;
return DohObjMalloc(&DohListType,l); return DohObjMalloc(&DohListType,l);

View file

@ -874,8 +874,6 @@ static DohListMethods StringListMethods = {
String_delitem, /* doh_delitem */ String_delitem, /* doh_delitem */
String_insert, /* doh_insitem */ String_insert, /* doh_insitem */
String_delslice, /* doh_delslice */ String_delslice, /* doh_delslice */
0, /* doh_first */
0, /* doh_next */
}; };
static DohFileMethods StringFileMethods = { static DohFileMethods StringFileMethods = {
@ -905,6 +903,8 @@ DohObjInfo DohStringType = {
String_len, /* doh_len */ String_len, /* doh_len */
String_hash, /* doh_hash */ String_hash, /* doh_hash */
String_cmp, /* doh_cmp */ String_cmp, /* doh_cmp */
0, /* doh_first */
0, /* doh_next */
String_setfile, /* doh_setfile */ String_setfile, /* doh_setfile */
String_getfile, /* doh_getfile */ String_getfile, /* doh_getfile */
String_setline, /* doh_setline */ String_setline, /* doh_setline */

View file

@ -69,6 +69,8 @@ static DohObjInfo DohVoidType = {
0, /* doh_len */ 0, /* doh_len */
0, /* doh_hash */ 0, /* doh_hash */
0, /* doh_cmp */ 0, /* doh_cmp */
0, /* doh_first */
0, /* doh_next */
0, /* doh_setfile */ 0, /* doh_setfile */
0, /* doh_getfile */ 0, /* doh_getfile */
0, /* doh_setline */ 0, /* doh_setline */

View file

@ -41,8 +41,10 @@ class Browser : public Dispatcher {
if (!Getmeta(obj,"visible")) return; if (!Getmeta(obj,"visible")) return;
String *os = NewString(""); String *os = NewString("");
String *k; String *k;
k = Firstkey(obj); Iterator ki;
while (k) { ki = First(obj);
while (ki.key) {
k = ki.key;
if ((Cmp(k,"nodeType") == 0) || (Cmp(k,"firstChild") == 0) || (Cmp(k,"lastChild") == 0) || if ((Cmp(k,"nodeType") == 0) || (Cmp(k,"firstChild") == 0) || (Cmp(k,"lastChild") == 0) ||
(Cmp(k,"parentNode") == 0) || (Cmp(k,"nextSibling") == 0) || (Cmp(k,"parentNode") == 0) || (Cmp(k,"nextSibling") == 0) ||
(Cmp(k,"previousSibling") == 0) || (*(Char(k)) == '$')) { (Cmp(k,"previousSibling") == 0) || (*(Char(k)) == '$')) {
@ -71,7 +73,7 @@ class Browser : public Dispatcher {
Printf(os,"<a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj,k), k, Getattr(obj,k)); Printf(os,"<a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj,k), k, Getattr(obj,k));
} }
} }
k = Nextkey(obj); ki = Next(ki);
} }
Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os)); Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
Delete(os); Delete(os);
@ -241,10 +243,12 @@ void raw_data(FILE *out, Node *obj) {
if (!obj) return; if (!obj) return;
if (DohIsMapping(obj)) { if (DohIsMapping(obj)) {
String *k; String *k;
Iterator ki;
String *os = NewString(""); String *os = NewString("");
Printf(os,"Hash {\n"); Printf(os,"Hash {\n");
k = Firstkey(obj); ki = First(obj);
while (k) { while (ki.key) {
k = ki.key;
DOH *o; DOH *o;
const char *trunc = ""; const char *trunc = "";
if (DohIsString(Getattr(obj,k))) { if (DohIsString(Getattr(obj,k))) {
@ -258,7 +262,7 @@ void raw_data(FILE *out, Node *obj) {
} else { } else {
Printf(os," <a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj,k), k, Getattr(obj,k)); Printf(os," <a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj,k), k, Getattr(obj,k));
} }
k = Nextkey(obj); ki = Next(ki);
} }
Printf(os,"}\n"); Printf(os,"}\n");
Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os)); Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));

View file

@ -1369,18 +1369,18 @@ CHICKEN::classHandler(Node *n)
String *base_class = NewString("<"); String *base_class = NewString("<");
List *baselist = Getattr(n,"bases"); List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) { if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist); Iterator base = First(baselist);
while (base) { while (base.item) {
String *bname = Copy(Getattr(base, "chicken:proxy")); String *bname = Copy(Getattr(base.item, "chicken:proxy"));
if (!bname) { if (!bname) {
base = Nextitem(baselist); base = Next(base);
continue; continue;
} }
namify(bname); namify(bname);
Printv(base_class,bname,NIL); Printv(base_class,bname,NIL);
Delete(bname); Delete(bname);
base = Nextitem(baselist); base = Next(base);
if (base) { if (base.item) {
Printf(base_class, "> <"); Printf(base_class, "> <");
} }
} }
@ -1879,12 +1879,12 @@ CHICKEN::chickenCode(String *code, const String *indent) {
List *clist = DohSplit(temp,'\n',-1); List *clist = DohSplit(temp,'\n',-1);
Delete(temp); Delete(temp);
int initial = 0; int initial = 0;
String *s; Iterator s;
/* Get the initial indentation */ /* Get the initial indentation */
for (s = Firstitem(clist); s; s = Nextitem(clist)) { for (s = First(clist); s.item; s = Next(s)) {
if (Len(s)) { if (Len(s.item)) {
char *c = Char(s); char *c = Char(s.item);
while (*c) { while (*c) {
if (!isspace(*c)) break; if (!isspace(*c)) break;
initial++; initial++;
@ -1896,15 +1896,15 @@ CHICKEN::chickenCode(String *code, const String *indent) {
} }
} }
} }
while (s) { while (s.item) {
if (Len(s) > initial) { if (Len(s.item) > initial) {
char *c = Char(s); char *c = Char(s.item);
c += initial; c += initial;
Printv(out,indent,c,"\n",NIL); Printv(out,indent,c,"\n",NIL);
} else { } else {
Printv(out,"\n",NIL); Printv(out,"\n",NIL);
} }
s = Nextitem(clist); s = Next(s);
} }
Delete(clist); Delete(clist);
return out; return out;
@ -1939,11 +1939,11 @@ CHICKEN::recurseSearch(const char *typemap, char *argname, Node *n)
/* recurse through base classes */ /* recurse through base classes */
List *baselist = Getattr(n,"bases"); List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) { if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist); Iterator base = First(baselist);
while (base) { while (base.item) {
tm = recurseSearch(typemap, argname, base); tm = recurseSearch(typemap, argname, base.item);
if (tm) break; if (tm) break;
base = Nextitem(baselist); base = Next(base);
} }
} }
return tm; return tm;

View file

@ -261,7 +261,7 @@ int Contracts::InheritAssertAppend(Node *n, Node *bases) {
} }
int Contracts::AssertModify(Node *n, int flag) { int Contracts::AssertModify(Node *n, int flag) {
String *str_assert, *expr, *tag_sync; String *str_assert, *expr = 0, *tag_sync;
List *list_assert; List *list_assert;
if (flag == 1) { /* preassert */ if (flag == 1) { /* preassert */
@ -286,7 +286,10 @@ int Contracts::AssertModify(Node *n, int flag) {
/* build up new assertion */ /* build up new assertion */
str_assert = NewString(""); str_assert = NewString("");
for (expr = Firstitem(list_assert); expr; expr = Nextitem(list_assert)) { Iterator ei;
for (ei = First(list_assert); ei.item; ei = Next(ei)) {
expr = ei.item;
if (Len(expr)) { if (Len(expr)) {
/* All sync staff are not complete and only experimental */ /* All sync staff are not complete and only experimental */
if (Strstr(expr, SWIG_BEFORE)) { /* before sync assertion */ if (Strstr(expr, SWIG_BEFORE)) { /* before sync assertion */
@ -324,7 +327,6 @@ int Contracts::AssertModify(Node *n, int flag) {
Delete(str_assert); Delete(str_assert);
Delete(list_assert); Delete(list_assert);
Delete(expr);
return SWIG_OK; return SWIG_OK;
} }

View file

@ -338,8 +338,8 @@ class CSHARP : public Language {
Printf(f_wrappers,"#endif\n"); Printf(f_wrappers,"#endif\n");
// Output a C# type wrapper class for each SWIG type // Output a C# type wrapper class for each SWIG type
for (String *swig_type = Firstkey(swig_types_hash); swig_type; swig_type = Nextkey(swig_types_hash)) { for (Iterator swig_type = First(swig_types_hash); swig_type.key; swig_type = Next(swig_type)) {
emitTypeWrapperClass(swig_type, Getattr(swig_types_hash, swig_type)); emitTypeWrapperClass(swig_type.key, swig_type.item);
} }
Delete(swig_types_hash); swig_types_hash = NULL; Delete(swig_types_hash); swig_types_hash = NULL;
@ -948,16 +948,16 @@ class CSHARP : public Language {
/* Deal with inheritance */ /* Deal with inheritance */
List *baselist = Getattr(n,"bases"); List *baselist = Getattr(n,"bases");
if (baselist) { if (baselist) {
Node *base = Firstitem(baselist); Iterator base = First(baselist);
c_baseclassname = Getattr(base,"name"); c_baseclassname = Getattr(base.item,"name");
baseclass = Copy(getProxyName(c_baseclassname)); baseclass = Copy(getProxyName(c_baseclassname));
if (baseclass){ if (baseclass){
c_baseclass = SwigType_namestr(Getattr(base,"name")); c_baseclass = SwigType_namestr(Getattr(base.item,"name"));
} }
base = Nextitem(baselist); base = Next(base);
if (base) { if (base.item) {
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, input_file, line_number, Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, input_file, line_number,
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#.\n", classDeclarationName, Getattr(base,"name")); "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#.\n", classDeclarationName, Getattr(base.item,"name"));
} }
} }
@ -1951,8 +1951,8 @@ class CSHARP : public Language {
// Add the exception classes to the node throws list, but don't duplicate if already in list // Add the exception classes to the node throws list, but don't duplicate if already in list
if (temp_classes_list && Len(temp_classes_list) > 0) { if (temp_classes_list && Len(temp_classes_list) > 0) {
for (String *cls = Firstitem(temp_classes_list); cls; cls = Nextitem(temp_classes_list)) { for (Iterator cls = First(temp_classes_list); cls.item; cls = Next(cls)) {
String *exception_class = NewString(cls); String *exception_class = NewString(cls.item);
Replaceall(exception_class," ",""); // remove spaces Replaceall(exception_class," ",""); // remove spaces
Replaceall(exception_class,"\t",""); // remove tabs Replaceall(exception_class,"\t",""); // remove tabs
if (Len(exception_class) > 0) { if (Len(exception_class) > 0) {
@ -1962,8 +1962,8 @@ class CSHARP : public Language {
// Don't duplicate the C# exception class in the throws clause // Don't duplicate the C# exception class in the throws clause
bool found_flag = false; bool found_flag = false;
for (String *item = Firstitem(throws_list); item; item = Nextitem(throws_list)) { for (Iterator item = First(throws_list); item.item; item = Next(item)) {
if (Strcmp(item, exception_class) == 0) if (Strcmp(item.item, exception_class) == 0)
found_flag = true; found_flag = true;
} }
if (!found_flag) if (!found_flag)
@ -1985,10 +1985,10 @@ class CSHARP : public Language {
// Add the throws clause into code // Add the throws clause into code
List *throws_list = Getattr(n,"csharp:throwslist"); List *throws_list = Getattr(n,"csharp:throwslist");
if (throws_list) { if (throws_list) {
String *cls = Firstitem(throws_list); Iterator cls = First(throws_list);
Printf(code, " throws %s", cls); Printf(code, " throws %s", cls.item);
while ( (cls = Nextitem(throws_list)) ) while ( (cls = Next(cls)).item)
Printf(code, ", %s", cls); Printf(code, ", %s", cls.item);
} }
} }

View file

@ -518,8 +518,8 @@ class JAVA : public Language {
Printf(f_wrappers,"#endif\n"); Printf(f_wrappers,"#endif\n");
// Output a Java type wrapper class for each SWIG type // Output a Java type wrapper class for each SWIG type
for (String *swig_type = Firstkey(swig_types_hash); swig_type; swig_type = Nextkey(swig_types_hash)) { for (Iterator swig_type = First(swig_types_hash); swig_type.key; swig_type = Next(swig_type)) {
emitTypeWrapperClass(swig_type, Getattr(swig_types_hash, swig_type)); emitTypeWrapperClass(swig_type.key, swig_type.item);
} }
/* Close all of the files */ /* Close all of the files */
@ -602,17 +602,18 @@ class JAVA : public Language {
UpcallData *udata; UpcallData *udata;
String *methodno; String *methodno;
Hash *new_udata; Hash *new_udata;
Iterator ui;
/* Do we know about this director class already? */ /* Do we know about this director class already? */
if ((udata = Getattr(dmethods_table, director_class)) != NULL) if ((udata = Getattr(dmethods_table, director_class)) != NULL)
return Getattr(udata, "methodoff"); return Getattr(udata, "methodoff");
/* Clearly not, so make sure we don't already know about the Java /* Clearly not, so make sure we don't already know about the Java
method and field descriptor signature */ method and field descriptor signature */
for (udata = Firstitem(dmethods_seq); udata != NULL; udata = Nextitem(dmethods_seq)) { for (ui = First(dmethods_seq); ui.item; ui = Next(ui)) {
if (!Cmp(Getattr(udata, "method"), method) && !Cmp(Getattr(udata, "fdesc"), signature)) { if (!Cmp(Getattr(ui.item, "method"), method) && !Cmp(Getattr(ui.item, "fdesc"), signature)) {
Setattr(dmethods_table, director_class, udata); Setattr(dmethods_table, director_class, ui.item);
return Getattr(udata, "methodoff"); return Getattr(ui.item, "methodoff");
} }
} }
@ -1472,16 +1473,16 @@ class JAVA : public Language {
/* Deal with inheritance */ /* Deal with inheritance */
List *baselist = Getattr(n,"bases"); List *baselist = Getattr(n,"bases");
if (baselist) { if (baselist) {
Node *base = Firstitem(baselist); Iterator base = First(baselist);
c_baseclassname = Getattr(base,"name"); c_baseclassname = Getattr(base.item,"name");
baseclass = Copy(getProxyName(c_baseclassname)); baseclass = Copy(getProxyName(c_baseclassname));
if (baseclass){ if (baseclass){
c_baseclass = SwigType_namestr(Getattr(base,"name")); c_baseclass = SwigType_namestr(Getattr(base.item,"name"));
} }
base = Nextitem(baselist); base = Next(base);
if (base) { if (base.item) {
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number, Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number,
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", classDeclarationName, Getattr(base,"name")); "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", classDeclarationName, Getattr(base.item,"name"));
} }
} }
@ -2422,8 +2423,8 @@ class JAVA : public Language {
// Add the exception classes to the node throws list, but don't duplicate if already in list // Add the exception classes to the node throws list, but don't duplicate if already in list
if (temp_classes_list && Len(temp_classes_list) > 0) { if (temp_classes_list && Len(temp_classes_list) > 0) {
for (String *cls = Firstitem(temp_classes_list); cls; cls = Nextitem(temp_classes_list)) { for (Iterator cls = First(temp_classes_list); cls.item; cls = Next(cls)) {
String *exception_class = NewString(cls); String *exception_class = NewString(cls.item);
Replaceall(exception_class," ",""); // remove spaces Replaceall(exception_class," ",""); // remove spaces
Replaceall(exception_class,"\t",""); // remove tabs Replaceall(exception_class,"\t",""); // remove tabs
if (Len(exception_class) > 0) { if (Len(exception_class) > 0) {
@ -2433,8 +2434,8 @@ class JAVA : public Language {
// Don't duplicate the Java exception class in the throws clause // Don't duplicate the Java exception class in the throws clause
bool found_flag = false; bool found_flag = false;
for (String *item = Firstitem(throws_list); item; item = Nextitem(throws_list)) { for (Iterator item = First(throws_list); item.item; item = Next(item)) {
if (Strcmp(item, exception_class) == 0) if (Strcmp(item.item, exception_class) == 0)
found_flag = true; found_flag = true;
} }
if (!found_flag) if (!found_flag)
@ -2456,10 +2457,10 @@ class JAVA : public Language {
// Add the throws clause into code // Add the throws clause into code
List *throws_list = Getattr(n,"java:throwslist"); List *throws_list = Getattr(n,"java:throwslist");
if (throws_list) { if (throws_list) {
String *cls = Firstitem(throws_list); Iterator cls = First(throws_list);
Printf(code, " throws %s", cls); Printf(code, " throws %s", cls.item);
while ( (cls = Nextitem(throws_list)) ) while ( (cls = Next(cls)).item)
Printf(code, ", %s", cls); Printf(code, ", %s", cls.item);
} }
} }
@ -2506,6 +2507,7 @@ class JAVA : public Language {
Wrapper *w = NewWrapper(); Wrapper *w = NewWrapper();
String *jni_imclass_name = makeValidJniName(imclass_name); String *jni_imclass_name = makeValidJniName(imclass_name);
UpcallData *udata; UpcallData *udata;
Iterator ui;
Printf(f_runtime, "static jclass __SWIG_jclass_%s = NULL;\n", imclass_name); Printf(f_runtime, "static jclass __SWIG_jclass_%s = NULL;\n", imclass_name);
Printf(f_runtime, "static jmethodID __SWIG_director_methids[%d];\n", n_dmethods); Printf(f_runtime, "static jmethodID __SWIG_director_methids[%d];\n", n_dmethods);
@ -2517,11 +2519,11 @@ class JAVA : public Language {
Printf(w->code, " const char *signature;\n"); Printf(w->code, " const char *signature;\n");
Printf(w->code, "} methods[%d] = {\n", n_dmethods); Printf(w->code, "} methods[%d] = {\n", n_dmethods);
udata = Firstitem(dmethods_seq); ui = First(dmethods_seq);
while ( udata) { while ( ui.item) {
Printf(w->code, " { \"%s\", \"%s\" }", Getattr(udata, "method"), Getattr(udata, "fdesc")); Printf(w->code, " { \"%s\", \"%s\" }", Getattr(ui.item, "method"), Getattr(ui.item, "fdesc"));
udata = Nextitem(dmethods_seq); ui = Next(ui);
if (udata) if (ui.item)
Putc(',', w->code); Putc(',', w->code);
Putc('\n', w->code); Putc('\n', w->code);
} }

View file

@ -1392,9 +1392,9 @@ int Language::unrollVirtualMethods(Node *n,
// recurse through all base classes to build the vtable // recurse through all base classes to build the vtable
List* bl = Getattr(n, "bases"); List* bl = Getattr(n, "bases");
if (bl) { if (bl) {
Node* bi; Iterator bi;
for (bi = Firstitem(bl); bi; bi = Nextitem(bl)) { for (bi = First(bl); bi.item; bi = Next(bi)) {
unrollVirtualMethods(bi, parent, vm, default_director, virtual_destructor); unrollVirtualMethods(bi.item, parent, vm, default_director, virtual_destructor);
} }
} }
// find the methods that need directors // find the methods that need directors
@ -1503,9 +1503,10 @@ int Language::classDirectorConstructors(Node *n) {
int Language::classDirectorMethods(Node *n) { int Language::classDirectorMethods(Node *n) {
Node *vtable = Getattr(n, "vtable"); Node *vtable = Getattr(n, "vtable");
Node *item; Node *item;
String *key; Iterator k;
for (key = Firstkey(vtable); key != 0; key = Nextkey(vtable)) {
item = Getattr(vtable, key); for (k = First(vtable); k.key; k = Next(k)) {
item = k.item;
String *method = Getattr(item, "methodNode"); String *method = Getattr(item, "methodNode");
String *fqname = Getattr(item, "fqName"); String *fqname = Getattr(item, "fqName");
if (classDirectorMethod(method, n, fqname) == SWIG_OK) { if (classDirectorMethod(method, n, fqname) == SWIG_OK) {
@ -1656,9 +1657,9 @@ int Language::classHandler(Node *n) {
List *methods = Getattr(n,"allocate:smartpointer"); List *methods = Getattr(n,"allocate:smartpointer");
cplus_mode = CPLUS_PUBLIC; cplus_mode = CPLUS_PUBLIC;
SmartPointer = CWRAP_SMART_POINTER; SmartPointer = CWRAP_SMART_POINTER;
Node *c; Iterator c;
for (c = Firstitem(methods); c; c= Nextitem(methods)) { for (c = First(methods); c.item; c= Next(c)) {
emit_one(c); emit_one(c.item);
} }
SmartPointer = 0; SmartPointer = 0;
} }

View file

@ -517,9 +517,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (Verbose) { if (Verbose) {
printf ("LibDir: %s\n", LibDir); printf ("LibDir: %s\n", LibDir);
List *sp = Swig_search_path(); List *sp = Swig_search_path();
String *s; Iterator s;
for (s = Firstitem(sp); s; s = Nextitem(sp)) { for (s = First(sp); s.item; s = Next(s)) {
Printf(stdout," %s\n", s); Printf(stdout," %s\n", s.item);
} }
} }
@ -648,9 +648,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (classes) { if (classes) {
Printf(stdout,"Classes\n"); Printf(stdout,"Classes\n");
Printf(stdout,"------------\n"); Printf(stdout,"------------\n");
String *key; Iterator ki;
for (key = Firstkey(classes); key; key = Nextkey(classes)) { for (ki = First(classes); ki.key; ki = Next(ki)) {
Printf(stdout,"%s\n", key); Printf(stdout,"%s\n", ki.key);
} }
} }
} }

View file

@ -1338,19 +1338,19 @@ public:
/* Handle up-casts in a nice way */ /* Handle up-casts in a nice way */
List *baselist = Getattr(n,"bases"); List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) { if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist); Iterator b;
while (base) { b = First(baselist);
String *bname = Getattr(base, "ocaml:ctor"); while (b.item) {
if (bname) { String *bname = Getattr(b.item, "ocaml:ctor");
Printv(f_class_ctors, if (bname) {
" \"::",bname,"\", (fun args -> " Printv(f_class_ctors,
"create_",bname,"_from_ptr raw_ptr) ;\n",NIL); " \"::",bname,"\", (fun args -> "
Printv( base_classes, "create_", bname, "_from_ptr ;\n", "create_",bname,"_from_ptr raw_ptr) ;\n",NIL);
NIL ); Printv( base_classes, "create_", bname, "_from_ptr ;\n",
} NIL );
base = Nextitem(baselist);
} }
b = Next(b);
}
} }
Replaceall(this_class_def,"$classname",classname); Replaceall(this_class_def,"$classname",classname);

View file

@ -315,16 +315,16 @@ public:
/* Patch the type table to reflect the names used by shadow classes */ /* Patch the type table to reflect the names used by shadow classes */
if (blessed) { if (blessed) {
Node *cls; Iterator cls;
for (cls = Firstitem(classlist); cls; cls = Nextitem(classlist)) { for (cls = First(classlist); cls.item; cls = Next(cls)) {
if (Getattr(cls,"perl5:proxy")) { if (Getattr(cls.item,"perl5:proxy")) {
SwigType *type = Copy(Getattr(cls,"classtype")); SwigType *type = Copy(Getattr(cls.item,"classtype"));
if (!type) continue; /* If unnamed class, no type will be found */ if (!type) continue; /* If unnamed class, no type will be found */
SwigType_add_pointer(type); SwigType_add_pointer(type);
String *mangle = NewStringf("\"%s\"", SwigType_manglestr(type)); String *mangle = NewStringf("\"%s\"", SwigType_manglestr(type));
String *rep = NewStringf("\"%s\"", Getattr(cls,"perl5:proxy")); String *rep = NewStringf("\"%s\"", Getattr(cls.item,"perl5:proxy"));
Replaceall(type_table,mangle,rep); Replaceall(type_table,mangle,rep);
Delete(mangle); Delete(mangle);
Delete(rep); Delete(rep);
@ -1139,9 +1139,9 @@ public:
if (have_operators) { if (have_operators) {
Printf(pm, "use overload\n"); Printf(pm, "use overload\n");
DOH *key; Iterator ki;
for (key = Firstkey(operators); key; key = Nextkey(operators)) { for (ki = First(operators); ki.key; ki = Next(ki)) {
char *name = Char(key); char *name = Char(ki.key);
// fprintf(stderr,"found name: <%s>\n", name); // fprintf(stderr,"found name: <%s>\n", name);
if (strstr(name, "operator_equal_to")) { if (strstr(name, "operator_equal_to")) {
Printv(pm, tab4, "\"==\" => sub { $_[0]->operator_equal_to($_[1])},\n",NIL); Printv(pm, tab4, "\"==\" => sub { $_[0]->operator_equal_to($_[1])},\n",NIL);
@ -1162,15 +1162,16 @@ public:
/* Handle inheritance */ /* Handle inheritance */
List *baselist = Getattr(n,"bases"); List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) { if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist); Iterator b;
while (base) { b = First(baselist);
String *bname = Getattr(base, "perl5:proxy"); while (b.item) {
String *bname = Getattr(b.item, "perl5:proxy");
if (!bname) { if (!bname) {
base = Nextitem(baselist); b = Next(b);
continue; continue;
} }
Printv(pm," ", bname, NIL); Printv(pm," ", bname, NIL);
base = Nextitem(baselist); b = Next(b);
} }
} }
Printf(pm, " );\n"); Printf(pm, " );\n");

View file

@ -143,15 +143,17 @@ static const char *php_header =
void void
SwigPHP_emit_resource_registrations() { SwigPHP_emit_resource_registrations() {
DOH *key; DOH *key;
Iterator ki;
String *destructor=0; String *destructor=0;
String *classname=0; String *classname=0;
String *shadow_classname=0; String *shadow_classname=0;
if (!zend_types) return; if (!zend_types) return;
key = Firstkey(zend_types);
if (key) Printf(s_oinit,"\n/* Register resource destructors for pointer types */\n"); ki = First(zend_types);
while (key) if (1 /* is pointer type*/) { if (ki.key) Printf(s_oinit,"\n/* Register resource destructors for pointer types */\n");
while (ki.key) if (1 /* is pointer type*/) {
key = ki.key;
Node *class_node; Node *class_node;
if ((class_node=Getattr(zend_types,key))) { if ((class_node=Getattr(zend_types,key))) {
// Write out destructor function header // Write out destructor function header
@ -187,7 +189,7 @@ SwigPHP_emit_resource_registrations() {
Printf(s_oinit,"SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", Printf(s_oinit,"SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n",
key,key); key,key);
} }
key = Nextkey(zend_types); ki = Next(ki);
} }
} }
@ -1458,24 +1460,23 @@ public:
if(baselist) { if(baselist) {
int class_count = 0; int class_count = 0;
Node *base = Firstitem(baselist); Iterator base = First(baselist);
while(base.item && Getattr(base.item,"feature:ignore")) base = Next(base);
while(base && Getattr(base,"feature:ignore")) base = Nextitem(baselist); if (base.item && is_shadow(Getattr(base.item, "name"))) {
if (base && is_shadow(Getattr(base, "name"))) {
class_count++; class_count++;
Printf(this_shadow_baseclass, "%s", Getattr(base, "name")); Printf(this_shadow_baseclass, "%s", Getattr(base.item, "name"));
} }
if (base) for(base = Nextitem(baselist); base; base = Nextitem(baselist)) { if (base.item) for(base = Next(base); base.item; base = Next(base)) {
if (Getattr(base,"feature:ignore")) continue; if (Getattr(base.item,"feature:ignore")) continue;
if(is_shadow(Getattr(base, "name"))) { if(is_shadow(Getattr(base.item, "name"))) {
class_count++; class_count++;
Printf(this_shadow_multinherit, "%s ", Getattr(base, "name")); Printf(this_shadow_multinherit, "%s ", Getattr(base.item, "name"));
} }
} }
if(class_count > 1) Printf(stderr, "Error: %s inherits from multiple base classes(%s %s). Multiple inheritance is not directly supported by PHP4, SWIG may support it at some point in the future.\n", shadow_classname, base, this_shadow_multinherit); if(class_count > 1) Printf(stderr, "Error: %s inherits from multiple base classes(%s %s). Multiple inheritance is not directly supported by PHP4, SWIG may support it at some point in the future.\n", shadow_classname, base.item, this_shadow_multinherit);
} }
/* Write out class init code */ /* Write out class init code */
@ -1493,7 +1494,8 @@ public:
String *s_propget=NewString(""); String *s_propget=NewString("");
String *s_propset=NewString(""); String *s_propset=NewString("");
List *baselist = Getattr(n, "bases"); List *baselist = Getattr(n, "bases");
Node *base = NULL; Iterator ki, base;
// If no constructor was generated (abstract class) we had better // If no constructor was generated (abstract class) we had better
// generate a constructor that raises an error about instantiating // generate a constructor that raises an error about instantiating
@ -1526,20 +1528,22 @@ public:
Printf(s_header,"static int _propset_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname); Printf(s_header,"static int _propset_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname);
Printf(s_propset,"static int _propset_%s(zend_property_reference *property_reference, pval *value) {\n", shadow_classname); Printf(s_propset,"static int _propset_%s(zend_property_reference *property_reference, pval *value) {\n", shadow_classname);
if (baselist) base=Firstitem(baselist);
else base=NULL; if (baselist) base=First(baselist);
while(base && Getattr(base,"feature:ignore")) base = Nextitem(baselist); else base.item = NULL;
key = Firstkey(shadow_set_vars); while(base.item && Getattr(base.item,"feature:ignore")) base = Next(base);
ki = First(shadow_set_vars);
key = ki.key;
// Print function header; we only need to find property name if there // Print function header; we only need to find property name if there
// are properties for this class to look up... // are properties for this class to look up...
if (key || ! base) { // or if we are base class and set it ourselves if (key || ! base.item) { // or if we are base class and set it ourselves
Printf(s_propset," /* get the property name */\n" Printf(s_propset," /* get the property name */\n"
" zend_llist_element *element = property_reference->elements_list->head;\n" " zend_llist_element *element = property_reference->elements_list->head;\n"
" zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n" " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"
" char *propname=Z_STRVAL_P(&(property->element));\n"); " char *propname=Z_STRVAL_P(&(property->element));\n");
} else { } else {
if (base) { if (base.item) {
Printf(s_propset," /* No extra properties for subclass %s */\n",shadow_classname); Printf(s_propset," /* No extra properties for subclass %s */\n",shadow_classname);
} else { } else {
Printf(s_propset," /* No properties for base class %s */\n",shadow_classname); Printf(s_propset," /* No properties for base class %s */\n",shadow_classname);
@ -1547,27 +1551,28 @@ public:
} }
scount=0; scount=0;
while (key) { while (ki.key) {
key = ki.key;
if (scount++) Printf(s_propset," else"); if (scount++) Printf(s_propset," else");
Printf(s_propset," if (strcmp(propname,\"%s\")==0) {\n" Printf(s_propset," if (strcmp(propname,\"%s\")==0) {\n"
" return _wrap_%s(property_reference, value);\n" " return _wrap_%s(property_reference, value);\n"
" }",Getattr(shadow_set_vars,key),key); " }",Getattr(shadow_set_vars,key),key);
key=Nextkey(shadow_set_vars); ki=Next(ki);
} }
if (scount) Printf(s_propset," else"); if (scount) Printf(s_propset," else");
// If there is a base class then chain it's handler else set directly // If there is a base class then chain it's handler else set directly
// try each base class handler, else set directly... // try each base class handler, else set directly...
if (base) { if (base.item) {
Printf(s_propset, " {\n /* chain to base class */\n"); Printf(s_propset, " {\n /* chain to base class */\n");
while(base) { while(base.item) {
Printf(s_propset," if (_propset_%s(property_reference, value)==SUCCESS) return SUCCESS;\n", Printf(s_propset," if (_propset_%s(property_reference, value)==SUCCESS) return SUCCESS;\n",
GetChar(base, "sym:name")); GetChar(base.item, "sym:name"));
base=Nextitem(baselist); base=Next(base);
while (base && Getattr(base,"feature:ignore")) base=Nextitem(baselist); while (base.item && Getattr(base.item,"feature:ignore")) base=Next(base);
} }
Printf(s_propset," }\n"); Printf(s_propset," }\n");
} }
@ -1597,20 +1602,22 @@ public:
Printf(s_header,"static int _propget_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname); Printf(s_header,"static int _propget_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname);
Printf(s_propget,"static int _propget_%s(zend_property_reference *property_reference, pval *value) {\n", shadow_classname); Printf(s_propget,"static int _propget_%s(zend_property_reference *property_reference, pval *value) {\n", shadow_classname);
if (baselist) base=Firstitem(baselist); if (baselist) base=First(baselist);
else base=NULL; else base.item=NULL;
while(base && Getattr(base,"feature:ignore")) base = Nextitem(baselist); while(base.item && Getattr(base.item,"feature:ignore")) base = Next(base);
key = Firstkey(shadow_get_vars); ki = First(shadow_get_vars);
key = ki.key;
// Print function header; we only need to find property name if there // Print function header; we only need to find property name if there
// are properties for this class to look up... // are properties for this class to look up...
if (key || !base ) { // or if we are base class... if (key || !base.item ) { // or if we are base class...
Printf(s_propget," /* get the property name */\n" Printf(s_propget," /* get the property name */\n"
" zend_llist_element *element = property_reference->elements_list->head;\n" " zend_llist_element *element = property_reference->elements_list->head;\n"
" zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n" " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"
" char *propname=Z_STRVAL_P(&(property->element));\n"); " char *propname=Z_STRVAL_P(&(property->element));\n");
} else { } else {
if (base) { if (base.item) {
Printf(s_propget," /* No extra properties for subclass %s */\n",shadow_classname); Printf(s_propget," /* No extra properties for subclass %s */\n",shadow_classname);
} else { } else {
Printf(s_propget," /* No properties for base class %s */\n",shadow_classname); Printf(s_propget," /* No properties for base class %s */\n",shadow_classname);
@ -1618,27 +1625,28 @@ public:
} }
gcount=0; gcount=0;
while (key) { while (ki.key) {
key = ki.key;
if (gcount++) Printf(s_propget," else"); if (gcount++) Printf(s_propget," else");
Printf(s_propget," if (strcmp(propname,\"%s\")==0) {\n" Printf(s_propget," if (strcmp(propname,\"%s\")==0) {\n"
" *value=_wrap_%s(property_reference);\n" " *value=_wrap_%s(property_reference);\n"
" return SUCCESS;\n" " return SUCCESS;\n"
" }",Getattr(shadow_get_vars,key),key); " }",Getattr(shadow_get_vars,key),key);
key=Nextkey(shadow_get_vars); ki=Next(ki);
} }
if (gcount) Printf(s_propget," else"); if (gcount) Printf(s_propget," else");
// If there is a base class then chain it's handler else return null // If there is a base class then chain it's handler else return null
if (base) { if (base.item) {
Printf(s_propget, " {\n /* chain to base class */\n"); Printf(s_propget, " {\n /* chain to base class */\n");
while(base) { while(base.item) {
Printf(s_propget," if (_propget_%s(property_reference, value)==SUCCESS) return SUCCESS;\n", Printf(s_propget," if (_propget_%s(property_reference, value)==SUCCESS) return SUCCESS;\n",
GetChar(base, "sym:name")); GetChar(base.item, "sym:name"));
base=Nextitem(baselist); base=Next(base);
while (base && Getattr(base,"feature:ignore")) base=Nextitem(baselist); while (base.item && Getattr(base.item,"feature:ignore")) base=Next(base);
} }
Printf(s_propget," }\n"); Printf(s_propget," }\n");
} }
@ -1651,13 +1659,13 @@ public:
Printv(s_wrappers,s_propget,s_propset,NIL); Printv(s_wrappers,s_propget,s_propset,NIL);
// Save class in class table // Save class in class table
if (baselist) base=Firstitem(baselist); if (baselist) base=First(baselist);
else base=NULL; else base.item=NULL;
while(base && Getattr(base,"feature:ignore")) base = Nextitem(baselist); while(base.item && Getattr(base.item,"feature:ignore")) base = Next(base);
if (base) { if (base.item) {
Printf(s_oinit,"if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,&ce_swig_%s,NULL))) zend_error(E_ERROR,\"Error registering wrapper for class %s\");\n", Printf(s_oinit,"if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,&ce_swig_%s,NULL))) zend_error(E_ERROR,\"Error registering wrapper for class %s\");\n",
shadow_classname,shadow_classname,GetChar(base, "sym:name"), shadow_classname); shadow_classname,shadow_classname,GetChar(base.item, "sym:name"), shadow_classname);
} else { } else {
Printf(s_oinit,"if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,NULL,NULL))) zend_error(E_ERROR,\"Error registering wrapper for class %s\");\n", Printf(s_oinit,"if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,NULL,NULL))) zend_error(E_ERROR,\"Error registering wrapper for class %s\");\n",
shadow_classname,shadow_classname, shadow_classname); shadow_classname,shadow_classname, shadow_classname);

View file

@ -642,9 +642,9 @@ public:
/* Handle inheritance */ /* Handle inheritance */
List *baselist = Getattr(n,"bases"); List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist) > 0) { if (baselist && Len(baselist) > 0) {
Node *base = Firstitem(baselist); Iterator base = First(baselist);
while (base) { while (base.item) {
String *basename = Getattr(base,"name"); String *basename = Getattr(base.item,"name");
SwigType *basetype = NewString(basename); SwigType *basetype = NewString(basename);
SwigType_add_pointer(basetype); SwigType_add_pointer(basetype);
SwigType_remember(basetype); SwigType_remember(basetype);
@ -652,7 +652,7 @@ public:
Printf(f_classInit, "low_inherit((struct program *) SWIGTYPE%s->clientdata, 0, 0, 0, 0, 0);\n", basemangle); Printf(f_classInit, "low_inherit((struct program *) SWIGTYPE%s->clientdata, 0, 0, 0, 0, 0);\n", basemangle);
Delete(basemangle); Delete(basemangle);
Delete(basetype); Delete(basetype);
base = Nextitem(baselist); base = Next(base);
} }
} else { } else {
Printf(f_classInit, "ADD_STORAGE(swig_object_wrapper);\n"); Printf(f_classInit, "ADD_STORAGE(swig_object_wrapper);\n");
@ -729,19 +729,19 @@ public:
void membervariableAccessors(List *membervariables) { void membervariableAccessors(List *membervariables) {
String *name; String *name;
Node *n; Iterator i;
bool need_setter; bool need_setter;
String *funcname; String *funcname;
/* If at least one of them is mutable, we need a setter */ /* If at least one of them is mutable, we need a setter */
need_setter = false; need_setter = false;
n = Firstitem(membervariables); i = First(membervariables);
while (n) { while (i.item) {
if (!Getattr(n, "feature:immutable")) { if (!Getattr(i.item, "feature:immutable")) {
need_setter = true; need_setter = true;
break; break;
} }
n = Nextitem(membervariables); i = Next(i);
} }
/* Create a function to set the values of the (mutable) variables */ /* Create a function to set the values of the (mutable) variables */
@ -752,10 +752,10 @@ public:
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL); Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n"); Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");
n = Firstitem(membervariables); i = First(membervariables);
while (n) { while (i.item) {
if (!Getattr(n, "feature:immutable")) { if (!Getattr(i.item, "feature:immutable")) {
name = Getattr(n, "name"); name = Getattr(i.item, "name");
funcname = Swig_name_wrapper(Swig_name_set(Swig_name_member(getClassPrefix(), name))); funcname = Swig_name_wrapper(Swig_name_set(Swig_name_member(getClassPrefix(), name)));
Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name); Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name);
Printf(wrapper->code, "%s(args);\n", funcname); Printf(wrapper->code, "%s(args);\n", funcname);
@ -763,7 +763,7 @@ public:
Printf(wrapper->code, "}\n"); Printf(wrapper->code, "}\n");
Delete(funcname); Delete(funcname);
} }
n = Nextitem(membervariables); i = Next(i);
} }
/* Close the function */ /* Close the function */
@ -775,7 +775,7 @@ public:
/* Register it with Pike */ /* Register it with Pike */
String *description = NewString("tStr tFloat, tVoid"); String *description = NewString("tStr tFloat, tVoid");
add_method(Firstitem(membervariables), "`->=", wname, description); add_method(First(membervariables).item, "`->=", wname, description);
Delete(description); Delete(description);
/* Clean up */ /* Clean up */
@ -791,16 +791,16 @@ public:
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL); Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n"); Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");
n = Firstitem(membervariables); i = First(membervariables);
while (n) { while (i.item) {
name = Getattr(n, "name"); name = Getattr(i.item, "name");
funcname = Swig_name_wrapper(Swig_name_get(Swig_name_member(getClassPrefix(), name))); funcname = Swig_name_wrapper(Swig_name_get(Swig_name_member(getClassPrefix(), name)));
Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name); Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name);
Printf(wrapper->code, "%s(args);\n", funcname); Printf(wrapper->code, "%s(args);\n", funcname);
Printf(wrapper->code, "return;\n"); Printf(wrapper->code, "return;\n");
Printf(wrapper->code, "}\n"); Printf(wrapper->code, "}\n");
Delete(funcname); Delete(funcname);
n = Nextitem(membervariables); i = Next(i);
} }
/* Close the function */ /* Close the function */
@ -812,7 +812,7 @@ public:
/* Register it with Pike */ /* Register it with Pike */
String *description = NewString("tStr, tMix"); String *description = NewString("tStr, tMix");
add_method(Firstitem(membervariables), "`->", wname, description); add_method(First(membervariables).item, "`->", wname, description);
Delete(description); Delete(description);
/* Clean up */ /* Clean up */

View file

@ -1781,16 +1781,17 @@ public:
String *base_class = NewString(""); String *base_class = NewString("");
List *baselist = Getattr(n,"bases"); List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) { if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist); Iterator b;
while (base) { b = First(baselist);
String *bname = Getattr(base, "python:proxy"); while (b.item) {
String *bname = Getattr(b.item, "python:proxy");
if (!bname) { if (!bname) {
base = Nextitem(baselist); b = Next(b);
continue; continue;
} }
Printv(base_class,bname,NIL); Printv(base_class,bname,NIL);
base = Nextitem(baselist); b = Next(b);
if (base) { if (b.item) {
Putc(',',base_class); Putc(',',base_class);
} }
} }
@ -2149,10 +2150,12 @@ public:
List *clist = DohSplit(temp,'\n',-1); List *clist = DohSplit(temp,'\n',-1);
Delete(temp); Delete(temp);
int initial = 0; int initial = 0;
String *s; String *s = 0;
Iterator si;
/* Get the initial indentation */ /* Get the initial indentation */
for (s = Firstitem(clist); s; s = Nextitem(clist)) {
for (si = First(clist); si.item; si = Next(si)) {
s = si.item;
if (Len(s)) { if (Len(s)) {
char *c = Char(s); char *c = Char(s);
while (*c) { while (*c) {
@ -2166,7 +2169,8 @@ public:
} }
} }
} }
while (s) { while (si.item) {
s = si.item;
if (Len(s) > initial) { if (Len(s) > initial) {
char *c = Char(s); char *c = Char(s);
c += initial; c += initial;
@ -2174,7 +2178,7 @@ public:
} else { } else {
Printv(out,"\n",NIL); Printv(out,"\n",NIL);
} }
s = Nextitem(clist); si = Next(si);
} }
Delete(clist); Delete(clist);
return out; return out;

View file

@ -511,19 +511,20 @@ public:
List *modules = Split(module,':',INT_MAX); List *modules = Split(module,':',INT_MAX);
if (modules != 0 && Len(modules) > 0) { if (modules != 0 && Len(modules) > 0) {
String *mv = 0; String *mv = 0;
String *m = Firstitem(modules); Iterator m;
while (m != 0) { m = First(modules);
if (Len(m) > 0) { while (m.item) {
if (Len(m.item) > 0) {
if (mv != 0) { if (mv != 0) {
Printv(f_init, tab4, modvar, Printv(f_init, tab4, modvar,
" = rb_define_module_under(", modvar, ", \"", m, "\");\n", NIL); " = rb_define_module_under(", modvar, ", \"", m.item, "\");\n", NIL);
} else { } else {
Printv(f_init, tab4, modvar, Printv(f_init, tab4, modvar,
" = rb_define_module(\"", m, "\");\n", NIL); " = rb_define_module(\"", m.item, "\");\n", NIL);
mv = NewString(modvar); mv = NewString(modvar);
} }
} }
m = Nextitem(modules); m = Next(m);
} }
Delete(mv); Delete(mv);
Delete(modules); Delete(modules);
@ -767,18 +768,18 @@ public:
List *modules = Split(mod_name,':',INT_MAX); List *modules = Split(mod_name,':',INT_MAX);
if (modules != 0 && Len(modules) > 0) { if (modules != 0 && Len(modules) > 0) {
String *last = 0; String *last = 0;
String *m = Firstitem(modules); Iterator m = First(modules);
while (m != 0) { while (m.item) {
if (Len(m) > 0) { if (Len(m.item) > 0) {
String *cap = NewString(m); String *cap = NewString(m.item);
(Char(cap))[0] = toupper((Char(cap))[0]); (Char(cap))[0] = toupper((Char(cap))[0]);
if (last != 0) { if (last != 0) {
Append(module, "::"); Append(module, "::");
} }
Append(module, cap); Append(module, cap);
last = m; last = m.item;
} }
m = Nextitem(modules); m = Next(m);
} }
if (feature == 0) { if (feature == 0) {
feature = Copy(last); feature = Copy(last);
@ -809,12 +810,12 @@ public:
if (aliasv) { if (aliasv) {
List *aliases = Split(aliasv,',',INT_MAX); List *aliases = Split(aliasv,',',INT_MAX);
if (aliases && Len(aliases) > 0) { if (aliases && Len(aliases) > 0) {
String *alias = Firstitem(aliases); Iterator alias = First(aliases);
while (alias) { while (alias.item) {
if (Len(alias) > 0) { if (Len(alias.item) > 0) {
Printv(klass->init, tab4, "rb_define_alias(", klass->vname, ", \"", alias, "\", \"", iname, "\");\n", NIL); Printv(klass->init, tab4, "rb_define_alias(", klass->vname, ", \"", alias.item, "\", \"", iname, "\");\n", NIL);
} }
alias = Nextitem(aliases); alias = Next(alias);
} }
} }
Delete(aliases); Delete(aliases);
@ -1707,12 +1708,12 @@ public:
if (mixin) { if (mixin) {
List *modules = Split(mixin,',',INT_MAX); List *modules = Split(mixin,',',INT_MAX);
if (modules && Len(modules) > 0) { if (modules && Len(modules) > 0) {
String *mod = Firstitem(modules); Iterator mod = First(modules);
while (mod) { while (mod.item) {
if (Len(mod) > 0) { if (Len(mod.item) > 0) {
Printf(klass->init, "rb_include_module(%s, rb_eval_string(\"%s\"));\n", klass->vname, mod); Printf(klass->init, "rb_include_module(%s, rb_eval_string(\"%s\"));\n", klass->vname, mod.item);
} }
mod = Nextitem(modules); mod = Next(mod);
} }
} }
Delete(modules); Delete(modules);
@ -1722,9 +1723,9 @@ public:
void handleBaseClasses(Node *n) { void handleBaseClasses(Node *n) {
List *baselist = Getattr(n,"bases"); List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) { if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist); Iterator base = First(baselist);
while (base) { while (base.item) {
String *basename = Getattr(base,"name"); String *basename = Getattr(base.item,"name");
String *basenamestr = SwigType_namestr(basename); String *basenamestr = SwigType_namestr(basename);
RClass *super = RCLASS(classes, Char(basenamestr)); RClass *super = RCLASS(classes, Char(basenamestr));
Delete(basenamestr); Delete(basenamestr);
@ -1747,14 +1748,14 @@ public:
} }
Delete(btype); Delete(btype);
} }
base = Nextitem(baselist); base = Next(base);
if (!multipleInheritance) { if (!multipleInheritance) {
/* Warn about multiple inheritance for additional base class(es) listed */ /* Warn about multiple inheritance for additional base class(es) listed */
while (base) { while (base.item) {
basename = Getattr(n,"name"); basename = Getattr(n,"name");
Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, input_file, line_number, Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, input_file, line_number,
"Warning for %s: Base %s ignored. Multiple inheritance is not supported in Ruby.\n", basename, basename); "Warning for %s: Base %s ignored. Multiple inheritance is not supported in Ruby.\n", basename, basename);
base = Nextitem(baselist); base = Next(base);
} }
} }
} }

View file

@ -258,13 +258,13 @@ public:
open_paren(NIL); open_paren(NIL);
for (; obj; obj = nextSibling(obj)) { for (; obj; obj = nextSibling(obj)) {
if (DohIsMapping(obj)) { if (DohIsMapping(obj)) {
DOH *k; Iterator k;
open_paren(NIL); open_paren(NIL);
for (k = Firstkey(obj); k; k = Nextkey(obj)) { for (k = First(obj); k.key; k = Next(k)) {
if (!internal_key_p(k)) { if (!internal_key_p(k.key)) {
DOH *value = Getattr(obj, k); DOH *value = Getattr(obj, k.key);
Sexp_print_as_keyword(k); Sexp_print_as_keyword(k.key);
Sexp_print_value_of_key(value, k); Sexp_print_value_of_key(value, k.key);
print_lazy_whitespace(); print_lazy_whitespace();
} }
} }
@ -295,16 +295,16 @@ public:
} }
else if (DohIsMapping(obj)) { else if (DohIsMapping(obj)) {
DOH *k; Iterator k;
open_paren(NIL); open_paren(NIL);
for (k = Firstkey(obj); k; k = Nextkey(obj)) { for (k = First(obj); k.key; k = Next(k)) {
if (!internal_key_p(k)) { if (!internal_key_p(k.key)) {
DOH *value = Getattr(obj, k); DOH *value = Getattr(obj, k.key);
flush_parens(); flush_parens();
open_paren(NIL); open_paren(NIL);
Sexp_print_doh(k); Sexp_print_doh(k.key);
Printf(out, " . "); Printf(out, " . ");
Sexp_print_value_of_key(value, k); Sexp_print_value_of_key(value, k.key);
close_paren(); close_paren();
} }
} }
@ -341,18 +341,18 @@ public:
void Sexp_print_plist_noparens(DOH *obj) void Sexp_print_plist_noparens(DOH *obj)
{ {
/* attributes map names to objects */ /* attributes map names to objects */
String *k; Iterator k;
bool first; bool first;
for (k = Firstkey(obj), first = true; k; k = Nextkey(obj), first=false) { for (k = First(obj), first = true; k.key; k = Next(k), first=false) {
if (!internal_key_p(k)) { if (!internal_key_p(k.key)) {
DOH *value = Getattr(obj, k); DOH *value = Getattr(obj, k.key);
flush_parens(); flush_parens();
if (!first) { if (!first) {
Printf(out, " "); Printf(out, " ");
} }
Sexp_print_as_keyword(k); Sexp_print_as_keyword(k.key);
/* Print value */ /* Print value */
Sexp_print_value_of_key(value, k); Sexp_print_value_of_key(value, k.key);
} }
} }
} }

View file

@ -661,17 +661,18 @@ public:
String *base_class = NewString(""); String *base_class = NewString("");
List *baselist = Getattr(n,"bases"); List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) { if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist); Iterator b;
while (base) { b = First(baselist);
String *bname = Getattr(base, "name"); while (b.item) {
if ((!bname) || Getattr(base,"feature:ignore") || (!Getattr(base,"module"))) { String *bname = Getattr(b.item, "name");
base = Nextitem(baselist); if ((!bname) || Getattr(b.item,"feature:ignore") || (!Getattr(b.item,"module"))) {
b = Next(b);
continue; continue;
} }
String *bmangle = Swig_name_mangle(bname); String *bmangle = Swig_name_mangle(bname);
Printv(f_wrappers,"extern swig_class _wrap_class_", bmangle, ";\n", NIL); Printv(f_wrappers,"extern swig_class _wrap_class_", bmangle, ";\n", NIL);
Printf(base_class,"&_wrap_class_%s",bmangle); Printf(base_class,"&_wrap_class_%s",bmangle);
base = Nextitem(baselist); b = Next(b);
Putc(',',base_class); Putc(',',base_class);
Delete(bmangle); Delete(bmangle);
} }

View file

@ -121,9 +121,9 @@ class TypePass : public Dispatcher {
while (nn) { while (nn) {
Swig_symbol_setscope(nn->symtab); Swig_symbol_setscope(nn->symtab);
SwigType_set_scope(nn->typescope); SwigType_set_scope(nn->typescope);
SwigType *t; Iterator t;
for (t = Firstitem(nn->normallist); t; t = Nextitem(nn->normallist)) { for (t = First(nn->normallist); t.item; t = Next(t)) {
normalize_type(t); normalize_type(t.item);
} }
Delete(nn->normallist); Delete(nn->normallist);
np = nn->next; np = nn->next;

View file

@ -137,10 +137,10 @@ public:
print_indent(0); print_indent(0);
Printf( out, "<attributelist id=\"%ld\" addr=\"%x\" >\n", ++id, obj ); Printf( out, "<attributelist id=\"%ld\" addr=\"%x\" >\n", ++id, obj );
indent_level += 4; indent_level += 4;
Iterator ki;
k = Firstkey(obj); ki = First(obj);
while (k) while (ki.key) {
{ k = ki.key;
if ((Cmp(k,"nodeType") == 0) if ((Cmp(k,"nodeType") == 0)
|| (Cmp(k,"firstChild") == 0) || (Cmp(k,"firstChild") == 0)
|| (Cmp(k,"lastChild") == 0) || (Cmp(k,"lastChild") == 0)
@ -202,7 +202,7 @@ public:
Delete(ck); Delete(ck);
} }
} }
k = Nextkey(obj); ki = Next(ki);
} }
indent_level -= 4; indent_level -= 4;
print_indent(0); print_indent(0);
@ -261,11 +261,11 @@ public:
print_indent(0); print_indent(0);
Printf( out, "<baselist id=\"%ld\" addr=\"%x\" >\n", ++id, p ); Printf( out, "<baselist id=\"%ld\" addr=\"%x\" >\n", ++id, p );
indent_level += 4; indent_level += 4;
String *s; Iterator s;
for (s = Firstitem(p); s; s = Nextitem(p)) for (s = First(p); s.item; s = Next(s))
{ {
print_indent(0); print_indent(0);
Printf( out, "<base name=\"%s\" id=\"%ld\" addr=\"%x\" />\n", s, ++id, s ); Printf( out, "<base name=\"%s\" id=\"%ld\" addr=\"%x\" />\n", s.item, ++id, s.item );
} }
indent_level -= 4; indent_level -= 4;
print_indent(0); print_indent(0);
@ -304,16 +304,16 @@ public:
Printf( out, "<%s id=\"%ld\" addr=\"%x\" >\n", markup, ++id, p ); Printf( out, "<%s id=\"%ld\" addr=\"%x\" >\n", markup, ++id, p );
Xml_print_attributes( p ); Xml_print_attributes( p );
indent_level += 4; indent_level += 4;
Node * n = Firstitem( p ); Iterator n = First(p);
while(n) while(n.key)
{ {
print_indent(0); print_indent(0);
Printf( out, "<%ssitem id=\"%ld\" addr=\"%x\" >\n", markup, ++id, n ); Printf( out, "<%ssitem id=\"%ld\" addr=\"%x\" >\n", markup, ++id, n.item );
Xml_print_attributes( n ); Xml_print_attributes( n.item );
Printf( out, "</%ssitem >\n", markup ); Printf( out, "</%ssitem >\n", markup );
print_indent(0); print_indent(0);
Printf( out, " />\n" ); Printf( out, " />\n" );
n = Nextkey(p); n = Next(n);
} }
indent_level -= 4; indent_level -= 4;
print_indent(0); print_indent(0);

View file

@ -725,13 +725,12 @@ expand_macro(String_or_char *name, List *args)
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
List *evaluate_args(List *x) { List *evaluate_args(List *x) {
String *a; Iterator i;
String *Preprocessor_replace(String *); String *Preprocessor_replace(String *);
List *nl = NewList(); List *nl = NewList();
for (a = Firstitem(x); a; a = Nextitem(x)) { for (i = First(x); i.item; i = Next(i)) {
Append(nl,Preprocessor_replace(a)); Append(nl,Preprocessor_replace(i.item));
} }
return nl; return nl;
} }

View file

@ -44,7 +44,7 @@ static int name_mangle(String *r) {
Replaceall(r,"::","_"); Replaceall(r,"::","_");
c = Char(r); c = Char(r);
while (*c) { while (*c) {
if (!isalnum(*c) && (*c != '_')) { if (!isalnum((int) *c) && (*c != '_')) {
special = 1; special = 1;
switch(*c) { switch(*c) {
case '+': case '+':
@ -480,7 +480,7 @@ Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType *dec
void void
Swig_name_object_inherit(Hash *namehash, String *base, String *derived) { Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
String *key; Iterator ki;
String *bprefix; String *bprefix;
String *dprefix; String *dprefix;
char *cbprefix; char *cbprefix;
@ -492,23 +492,23 @@ Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
dprefix = NewStringf("%s::",derived); dprefix = NewStringf("%s::",derived);
cbprefix = Char(bprefix); cbprefix = Char(bprefix);
plen = strlen(cbprefix); plen = strlen(cbprefix);
for (key = Firstkey(namehash); key; key = Nextkey(namehash)) { for (ki = First(namehash); ki.key; ki = Next(ki)) {
char *k = Char(key); char *k = Char(ki.key);
if (strncmp(k,cbprefix,plen) == 0) { if (strncmp(k,cbprefix,plen) == 0) {
Hash *n, *newh; Hash *n, *newh;
String *nkey, *okey; String *nkey;
Iterator oi;
nkey = NewStringf("%s%s",dprefix,k+plen); nkey = NewStringf("%s%s",dprefix,k+plen);
n = Getattr(namehash,key); n = ki.item;
newh = Getattr(namehash,nkey); newh = Getattr(namehash,nkey);
if (!newh) { if (!newh) {
newh = NewHash(); newh = NewHash();
Setattr(namehash,nkey,newh); Setattr(namehash,nkey,newh);
} }
for (okey = Firstkey(n); okey; okey = Nextkey(n)) { for (oi = First(n); oi.key; oi = Next(oi)) {
String *ovalue = Getattr(n,okey); if (!Getattr(newh,oi.key)) {
if (!Getattr(newh,okey)) { Setattr(newh,oi.key,Copy(oi.item));
Setattr(newh,okey,Copy(ovalue));
} }
} }
} }
@ -522,13 +522,14 @@ Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
static void merge_features(Hash *features, Node *n) { static void merge_features(Hash *features, Node *n) {
String *key; Iterator ki;
if (!features) return; if (!features) return;
for (key = Firstkey(features); key; key = Nextkey(features)) { for (ki = First(features); ki.key; ki = Next(ki)) {
if (Getattr(n,key)) { if (Getattr(n,ki.key)) {
continue; continue;
} }
Setattr(n,key,Copy(Getattr(features,key))); Setattr(n,ki.key,Copy(ki.item));
} }
} }

View file

@ -1118,15 +1118,15 @@ Swig_symbol_type_qualify(SwigType *t, Symtab *st) {
String *tprefix, *tsuffix; String *tprefix, *tsuffix;
SwigType *qprefix; SwigType *qprefix;
List *targs; List *targs;
String *tparm; Iterator ti;
tprefix = SwigType_templateprefix(e); tprefix = SwigType_templateprefix(e);
tsuffix = SwigType_templatesuffix(e); tsuffix = SwigType_templatesuffix(e);
qprefix = Swig_symbol_type_qualify(tprefix,st); qprefix = Swig_symbol_type_qualify(tprefix,st);
targs = SwigType_parmlist(e); targs = SwigType_parmlist(e);
Printf(qprefix,"<("); Printf(qprefix,"<(");
for (tparm = Firstitem(targs); tparm;) { for (ti = First(targs); ti.item;) {
String *qparm = Swig_symbol_type_qualify(tparm,st); String *qparm = Swig_symbol_type_qualify(ti.item,st);
/* Printf(stdout,"qparm = '%s', tparm = '%s'\n", qparm, tparm);*/ /* Printf(stdout,"qparm = '%s', tparm = '%s'\n", qparm, ti.item);*/
while (1) { while (1) {
/* It is possible for an integer to show up here. If so, we need to evaluate it */ /* It is possible for an integer to show up here. If so, we need to evaluate it */
{ {
@ -1155,8 +1155,8 @@ Swig_symbol_type_qualify(SwigType *t, Symtab *st) {
} }
} }
Append(qprefix,qparm); Append(qprefix,qparm);
tparm = Nextitem(targs); ti = Next(ti);
if (tparm) { if (ti.item) {
Putc(',',qprefix); Putc(',',qprefix);
} }
Delete(qparm); Delete(qparm);
@ -1175,14 +1175,14 @@ Swig_symbol_type_qualify(SwigType *t, Symtab *st) {
} }
Append(result,e); Append(result,e);
} else if (SwigType_isfunction(e)) { } else if (SwigType_isfunction(e)) {
Iterator pi;
List *parms = SwigType_parmlist(e); List *parms = SwigType_parmlist(e);
String *s = NewString("f("); String *s = NewString("f(");
String *p; pi = First(parms);
p = Firstitem(parms); while (pi.item) {
while (p) { Append(s,Swig_symbol_type_qualify(pi.item,st));
Append(s,Swig_symbol_type_qualify(p,st)); pi = Next(pi);
p = Nextitem(parms); if (pi.item) {
if (p) {
Append(s,","); Append(s,",");
} }
} }
@ -1269,7 +1269,7 @@ Swig_symbol_string_qualify(String *s, Symtab *st) {
r = NewString(""); r = NewString("");
c = Char(s); c = Char(s);
while (*c) { while (*c) {
if (isalpha(*c) || (*c == '_') || (*c == ':')) { if (isalpha((int)*c) || (*c == '_') || (*c == ':')) {
Putc(*c,id); Putc(*c,id);
have_id = 1; have_id = 1;
} else { } else {

View file

@ -70,13 +70,14 @@ static void print_indent(int l) {
void void
Swig_print_node(Node *obj) { Swig_print_node(Node *obj) {
String *k; Iterator ki;
Node *cobj; Node *cobj;
print_indent(0); print_indent(0);
Printf(stdout,"+++ %s ----------------------------------------\n", nodeType(obj)); Printf(stdout,"+++ %s ----------------------------------------\n", nodeType(obj));
k = Firstkey(obj); ki = First(obj);
while (k) { while (ki.key) {
String *k = ki.key;
if ((Cmp(k,"nodeType") == 0) || (Cmp(k,"firstChild") == 0) || (Cmp(k,"lastChild") == 0) || if ((Cmp(k,"nodeType") == 0) || (Cmp(k,"firstChild") == 0) || (Cmp(k,"lastChild") == 0) ||
(Cmp(k,"parentNode") == 0) || (Cmp(k,"nextSibling") == 0) || (Cmp(k,"parentNode") == 0) || (Cmp(k,"nextSibling") == 0) ||
(Cmp(k,"previousSibling") == 0) || (*(Char(k)) == '$')) { (Cmp(k,"previousSibling") == 0) || (*(Char(k)) == '$')) {
@ -99,7 +100,7 @@ Swig_print_node(Node *obj) {
Printf(stdout,"%-12s - 0x%x\n", k, Getattr(obj,k)); Printf(stdout,"%-12s - 0x%x\n", k, Getattr(obj,k));
} }
} }
k = Nextkey(obj); ki = Next(ki);
} }
cobj = firstChild(obj); cobj = firstChild(obj);
if (cobj) { if (cobj) {
@ -187,13 +188,11 @@ deleteNode(Node *n) {
Node * Node *
copyNode(Node *n) { copyNode(Node *n) {
String *key; Iterator ki;
DOH *v;
Node *c = NewHash(); Node *c = NewHash();
for (key = Firstkey(n); key; key = Nextkey(n)) { for (ki = First(n); ki.key; ki = Next(ki)) {
v = Getattr(n,key); if (DohIsString(ki.item)) {
if (DohIsString(v)) { Setattr(c,ki.key,Copy(ki.item));
Setattr(c,key,Copy(v));
} }
} }
Setfile(c,Getfile(n)); Setfile(c,Getfile(n));
@ -336,11 +335,11 @@ Swig_save(const char *ns, Node *n, ...) {
void void
Swig_restore(Node *n) { Swig_restore(Node *n) {
String *key;
char temp[512]; char temp[512];
int len; int len;
List *l; List *l;
String *ns; String *ns;
Iterator ki;
ns = Getattr(n,"view"); ns = Getattr(n,"view");
assert(ns); assert(ns);
@ -351,15 +350,15 @@ Swig_restore(Node *n) {
strcat(temp,":"); strcat(temp,":");
len = strlen(temp); len = strlen(temp);
for (key = Firstkey(n); key; key = Nextkey(n)) { for (ki = First(n); ki.key; ki = Next(ki)) {
if (Strncmp(temp,key,len) == 0) { if (Strncmp(temp,ki.key,len) == 0) {
Append(l,key); Append(l,ki.key);
} }
} }
for (key = Firstitem(l); key; key = Nextitem(l)) { for (ki = First(l); ki.item; ki = Next(ki)) {
DOH *obj = Getattr(n,key); DOH *obj = Getattr(n,ki.item);
Setattr(n,Char(key)+len,obj); Setattr(n,Char(ki.item)+len,obj);
Delattr(n,key); Delattr(n,ki.item);
} }
Delete(l); Delete(l);
} }

View file

@ -397,15 +397,14 @@ Swig_typemap_apply(ParmList *src, ParmList *dest) {
if (sm) { if (sm) {
/* Got a typemap. Need to only merge attributes for methods that match our signature */ /* Got a typemap. Need to only merge attributes for methods that match our signature */
String *key; Iterator ki;
match = 1; match = 1;
for (key = Firstkey(sm); key; key = Nextkey(sm)) { for (ki = First(sm); ki.key; ki = Next(ki)) {
/* Check for a signature match with the source signature */ /* Check for a signature match with the source signature */
if ((count_args(key) == narg) && (Strstr(key,ssig))) { if ((count_args(ki.key) == narg) && (Strstr(ki.key,ssig))) {
String *oldm; String *oldm;
/* A typemap we have to copy */ /* A typemap we have to copy */
String *nkey = Copy(key); String *nkey = Copy(ki.key);
Replace(nkey,ssig,dsig,DOH_REPLACE_ANY); Replace(nkey,ssig,dsig,DOH_REPLACE_ANY);
/* Make sure the typemap doesn't already exist in the target map */ /* Make sure the typemap doesn't already exist in the target map */
@ -415,7 +414,7 @@ Swig_typemap_apply(ParmList *src, ParmList *dest) {
String *code; String *code;
ParmList *locals; ParmList *locals;
ParmList *kwargs; ParmList *kwargs;
Hash *sm1 = Getattr(sm,key); Hash *sm1 = ki.item;
code = Getattr(sm1,"code"); code = Getattr(sm1,"code");
locals = Getattr(sm1,"locals"); locals = Getattr(sm1,"locals");
@ -474,14 +473,15 @@ Swig_typemap_clear_apply(Parm *parms) {
} }
if (tm) { if (tm) {
/* Clear typemaps that match our signature */ /* Clear typemaps that match our signature */
String *key, *key2; Iterator ki, ki2;
for (key = Firstkey(tm); key; key = Nextkey(tm)) {
if (Strncmp(key,"tmap:",5) == 0) { for (ki = First(tm); ki.key; ki = Next(ki)) {
int na = count_args(key); if (Strncmp(ki.key,"tmap:",5) == 0) {
if ((na == narg) && Strstr(key,tsig)) { int na = count_args(ki.key);
Hash *h = Getattr(tm,key); if ((na == narg) && Strstr(ki.key,tsig)) {
for (key2 = Firstkey(h); key2; key2 = Nextkey(h)) { Hash *h = ki.item;
Delattr(h,key2); for (ki2 = First(h); ki2.key; ki2 = Next(ki2)) {
Delattr(h,ki2.key);
} }
} }
} }
@ -1427,8 +1427,8 @@ static List *split_embedded(String *s) {
} }
if (*c == '(') level++; if (*c == '(') level++;
if (*c == ')') level--; if (*c == ')') level--;
if (isspace(*c) && leading) start++; if (isspace((int)*c) && leading) start++;
if (!isspace(*c)) leading = 0; if (!isspace((int)*c)) leading = 0;
c++; c++;
} }
return args; return args;
@ -1449,7 +1449,7 @@ static void split_var(String *s, String **name, String **value) {
*name = NewStringWithSize(c,eq-c); *name = NewStringWithSize(c,eq-c);
/* Look for $n variables */ /* Look for $n variables */
if (isdigit(*(c))) { if (isdigit((int)*(c))) {
/* Parse the value as a type */ /* Parse the value as a type */
String *v; String *v;
Parm *p; Parm *p;
@ -1552,9 +1552,9 @@ void replace_embedded_typemap(String *s, Wrapper *f) {
if (!Getattr(first,attr)) { if (!Getattr(first,attr)) {
/* Should be no more matches. Hack??? */ /* Should be no more matches. Hack??? */
/* Replace all of the remaining variables */ /* Replace all of the remaining variables */
String *key; Iterator ki;
for (key = Firstkey(vars); key; key = Nextkey(vars)) { for (ki = First(vars); ki.key; ki = Next(ki)) {
Replace(tm,key,Getattr(vars,key), DOH_REPLACE_ANY); Replace(tm,ki.key,ki.item, DOH_REPLACE_ANY);
} }
/* Do the replacement */ /* Do the replacement */
Replace(s,tmp,tm, DOH_REPLACE_ANY); Replace(s,tmp,tm, DOH_REPLACE_ANY);

View file

@ -695,9 +695,10 @@ ParmList *
SwigType_function_parms(SwigType *t) { SwigType_function_parms(SwigType *t) {
List *l = SwigType_parmlist(t); List *l = SwigType_parmlist(t);
Hash *p, *pp = 0, *firstp = 0; Hash *p, *pp = 0, *firstp = 0;
DOH *obj; Iterator o;
for (obj = Firstitem(l); obj; obj = Nextitem(l)) {
p = NewParm(obj,0); for (o = First(l); o.item; o = Next(o)) {
p = NewParm(o.item,0);
if (!firstp) firstp = p; if (!firstp) firstp = p;
if (pp) { if (pp) {
set_nextSibling(pp,p); set_nextSibling(pp,p);
@ -963,7 +964,7 @@ SwigType_strip_qualifiers(SwigType *t) {
static Hash *memoize_stripped = 0; static Hash *memoize_stripped = 0;
SwigType *r; SwigType *r;
List *l; List *l;
SwigType *e; Iterator ei;
if (!memoize_stripped) memoize_stripped = NewHash(); if (!memoize_stripped) memoize_stripped = NewHash();
r = Getattr(memoize_stripped,t); r = Getattr(memoize_stripped,t);
@ -971,9 +972,10 @@ SwigType_strip_qualifiers(SwigType *t) {
l = SwigType_split(t); l = SwigType_split(t);
r = NewString(""); r = NewString("");
for (e = Firstitem(l); e; e = Nextitem(l)) {
if (SwigType_isqualifier(e)) continue; for (ei = First(l);ei.item; ei = Next(ei)) {
Append(r,e); if (SwigType_isqualifier(ei.item)) continue;
Append(r,ei.item);
} }
Delete(l); Delete(l);
{ {

View file

@ -366,27 +366,26 @@ SwigType_attach_symtab(Symtab *sym) {
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
void SwigType_print_scope(Typetab *t) { void SwigType_print_scope(Typetab *t) {
String *key;
Hash *ttab; Hash *ttab;
String *tkey; Iterator i,j;
for (tkey = Firstkey(scopes); tkey; tkey = Nextkey(scopes)) { for (i = First(scopes); i.key; i = Next(i)) {
t = Getattr(scopes,tkey); t = i.item;
ttab = Getattr(t,"typetab"); ttab = Getattr(i.item,"typetab");
Printf(stdout,"Type scope '%s' (%x)\n", tkey, t); Printf(stdout,"Type scope '%s' (%x)\n", i.key, i.item);
{ {
List *inherit = Getattr(t,"inherit"); List *inherit = Getattr(i.item,"inherit");
if (inherit) { if (inherit) {
Typetab *it; Iterator j;
for (it = Firstitem(inherit); it; it = Nextitem(inherit)) { for (j = First(inherit); j.item; j = Next(j)) {
Printf(stdout," Inherits from '%s' (%x)\n", Getattr(it,"qname"), it); Printf(stdout," Inherits from '%s' (%x)\n", Getattr(j.item,"qname"), j.item);
} }
} }
} }
Printf(stdout,"-------------------------------------------------------------\n"); Printf(stdout,"-------------------------------------------------------------\n");
for (key = Firstkey(ttab); key; key = Nextkey(ttab)) { for (j = First(ttab); j.key; j = Next(j)) {
Printf(stdout,"%40s -> %s\n", key, Getattr(ttab,key)); Printf(stdout,"%40s -> %s\n", j.key, j.item);
} }
} }
} }
@ -860,14 +859,15 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
/* Template. We need to qualify template parameters as well as the template itself */ /* Template. We need to qualify template parameters as well as the template itself */
String *tprefix, *qprefix; String *tprefix, *qprefix;
String *tsuffix; String *tsuffix;
Iterator pi;
Parm *p; Parm *p;
List *parms = SwigType_parmlist(e); List *parms = SwigType_parmlist(e);
tprefix = SwigType_templateprefix(e); tprefix = SwigType_templateprefix(e);
tsuffix = SwigType_templatesuffix(e); tsuffix = SwigType_templatesuffix(e);
qprefix = SwigType_typedef_qualified(tprefix); qprefix = SwigType_typedef_qualified(tprefix);
Printv(qprefix,"<(",NIL); Printv(qprefix,"<(",NIL);
p = Firstitem(parms); pi = First(parms);
while (p) { while ((p = pi.item)) {
String *qt = SwigType_typedef_qualified(p); String *qt = SwigType_typedef_qualified(p);
if ((Strcmp(qt,p) == 0)) { /* && (!Swig_scopename_check(qt))) { */ if ((Strcmp(qt,p) == 0)) { /* && (!Swig_scopename_check(qt))) { */
/* No change in value. It is entirely possible that the parameter is an integer value. /* No change in value. It is entirely possible that the parameter is an integer value.
@ -911,8 +911,8 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
Append(qprefix,qt); Append(qprefix,qt);
} }
Delete(qt); Delete(qt);
p= Nextitem(parms); pi= Next(pi);
if (p) { if (pi.item) {
Append(qprefix,","); Append(qprefix,",");
} }
} }
@ -933,14 +933,14 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
} else if (SwigType_isfunction(e)) { } else if (SwigType_isfunction(e)) {
List *parms = SwigType_parmlist(e); List *parms = SwigType_parmlist(e);
String *s = NewString("f("); String *s = NewString("f(");
String *p; Iterator pi;
p = Firstitem(parms); pi = First(parms);
while (p) { while (pi.item) {
String *pq = SwigType_typedef_qualified(p); String *pq = SwigType_typedef_qualified(pi.item);
Append(s,pq); Append(s,pq);
Delete(pq); Delete(pq);
p = Nextitem(parms); pi = Next(pi);
if (p) { if (pi.item) {
Append(s,","); Append(s,",");
} }
} }
@ -1350,26 +1350,26 @@ List *SwigType_equivalent_mangle(String *ms, Hash *checked, Hash *found) {
Setattr(ch, ms, "1"); Setattr(ch, ms, "1");
mh = Getattr(r_mangled,ms); mh = Getattr(r_mangled,ms);
if (mh) { if (mh) {
String *key; Iterator ki;
key = Firstkey(mh); ki = First(mh);
while (key) { while (ki.key) {
Hash *rh; Hash *rh;
if (Getattr(ch,key)) { if (Getattr(ch,ki.key)) {
key = Nextkey(mh); ki = Next(ki);
continue; continue;
} }
Setattr(ch,key,"1"); Setattr(ch,ki.key,"1");
rh = Getattr(r_resolved,key); rh = Getattr(r_resolved,ki.key);
if (rh) { if (rh) {
String *rkey; Iterator rk;
rkey = Firstkey(rh); rk = First(rh);
while (rkey) { while (rk.key) {
Setattr(h,rkey,"1"); Setattr(h,rk.key,"1");
SwigType_equivalent_mangle(rkey,ch,h); SwigType_equivalent_mangle(rk.key,ch,h);
rkey = Nextkey(rh); rk = Next(rk);
} }
} }
key = Nextkey(mh); ki = Next(ki);
} }
} }
check_exit: check_exit:
@ -1404,24 +1404,24 @@ String *SwigType_clientdata_collect(String *ms, Hash *checked) {
Setattr(ch, ms, "1"); Setattr(ch, ms, "1");
mh = Getattr(r_mangled,ms); mh = Getattr(r_mangled,ms);
if (mh) { if (mh) {
String *key; Iterator ki;
key = Firstkey(mh); ki = First(mh);
while (key) { while (ki.key) {
Hash *rh; Hash *rh;
Setattr(ch,key,"1"); Setattr(ch,ki.key,"1");
clientdata = Getattr(r_clientdata,key); clientdata = Getattr(r_clientdata,ki.key);
if (clientdata) goto check_exit; if (clientdata) goto check_exit;
rh = Getattr(r_resolved,key); rh = Getattr(r_resolved,ki.key);
if (rh) { if (rh) {
String *rkey; Iterator rk;
rkey = Firstkey(rh); rk = First(rh);
while (rkey) { while (rk.key) {
clientdata = SwigType_clientdata_collect(rkey,ch); clientdata = SwigType_clientdata_collect(rk.key,ch);
if (clientdata) goto check_exit; if (clientdata) goto check_exit;
rkey = Nextkey(rh); rk = Next(rk);
} }
} }
key = Nextkey(mh); ki = Next(ki);
} }
} }
check_exit: check_exit:
@ -1515,48 +1515,49 @@ SwigType_issubtype(SwigType *t1, SwigType *t2) {
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
void SwigType_inherit_equiv(File *out) { void SwigType_inherit_equiv(File *out) {
String *rkey, *bkey, *ckey; String *ckey;
String *prefix, *base; String *prefix, *base;
Hash *sub; Hash *sub;
Hash *rh; Hash *rh;
List *rlist; List *rlist;
Iterator rk, bk, ck;
if (!conversions) conversions = NewHash(); if (!conversions) conversions = NewHash();
if (!subclass) subclass = NewHash(); if (!subclass) subclass = NewHash();
rkey = Firstkey(r_resolved); rk = First(r_resolved);
while (rkey) { while (rk.key) {
/* rkey is a fully qualified type. We strip all of the type constructors off of it just to get the base */ /* rkey is a fully qualified type. We strip all of the type constructors off of it just to get the base */
base = SwigType_base(rkey); base = SwigType_base(rk.key);
/* Check to see whether the base is recorded in the subclass table */ /* Check to see whether the base is recorded in the subclass table */
sub = Getattr(subclass,base); sub = Getattr(subclass,base);
Delete(base); Delete(base);
if (!sub) { if (!sub) {
rkey = Nextkey(r_resolved); rk = Next(rk);
continue; continue;
} }
/* This type has subclasses. We now need to walk through these subtypes and generate pointer converion functions */ /* This type has subclasses. We now need to walk through these subtypes and generate pointer converion functions */
rh = Getattr(r_resolved, rkey); rh = Getattr(r_resolved, rk.key);
rlist = NewList(); rlist = NewList();
for (ckey = Firstkey(rh); ckey; ckey = Nextkey(rh)) { for (ck = First(rh); ck.key; ck = Next(ck)) {
Append(rlist,ckey); Append(rlist,ck.key);
} }
/* Printf(stdout,"rkey = '%s'\n", rkey); /* Printf(stdout,"rk.key = '%s'\n", rk.key);
Printf(stdout,"rh = %x '%s'\n", rh,rh); */ Printf(stdout,"rh = %x '%s'\n", rh,rh); */
bkey = Firstkey(sub); bk = First(sub);
while (bkey) { while (bk.key) {
prefix= SwigType_prefix(rkey); prefix= SwigType_prefix(rk.key);
Append(prefix,bkey); Append(prefix,bk.key);
/* Printf(stdout,"set %x = '%s' : '%s'\n", rh, SwigType_manglestr(prefix),prefix); */ /* Printf(stdout,"set %x = '%s' : '%s'\n", rh, SwigType_manglestr(prefix),prefix); */
Setattr(rh,SwigType_manglestr(prefix),prefix); Setattr(rh,SwigType_manglestr(prefix),prefix);
ckey = NewStringf("%s+%s",SwigType_manglestr(prefix), SwigType_manglestr(rkey)); ckey = NewStringf("%s+%s",SwigType_manglestr(prefix), SwigType_manglestr(rk.key));
if (!Getattr(conversions,ckey)) { if (!Getattr(conversions,ckey)) {
String *convname = NewStringf("%sTo%s", SwigType_manglestr(prefix), SwigType_manglestr(rkey)); String *convname = NewStringf("%sTo%s", SwigType_manglestr(prefix), SwigType_manglestr(rk.key));
Printf(out,"static void *%s(void *x) {\n", convname); Printf(out,"static void *%s(void *x) {\n", convname);
Printf(out," return (void *)((%s) %s ((%s) x));\n", SwigType_lstr(rkey,0), Getattr(sub,bkey), SwigType_lstr(prefix,0)); Printf(out," return (void *)((%s) %s ((%s) x));\n", SwigType_lstr(rk.key,0), Getattr(sub,bk.key), SwigType_lstr(prefix,0));
Printf(out,"}\n"); Printf(out,"}\n");
Setattr(conversions,ckey,convname); Setattr(conversions,ckey,convname);
Delete(ckey); Delete(ckey);
@ -1565,39 +1566,40 @@ void SwigType_inherit_equiv(File *out) {
{ {
Hash *r = Getattr(r_resolved, prefix); Hash *r = Getattr(r_resolved, prefix);
if (r) { if (r) {
String *rrkey = Firstkey(r); Iterator rrk;
while (rrkey) { rrk=First(r);
String *rlkey; while (rrk.key) {
Iterator rlk;
String *rkeymangle; String *rkeymangle;
/* Make sure this name equivalence is not due to inheritance */ /* Make sure this name equivalence is not due to inheritance */
if (Cmp(prefix, Getattr(r,rrkey)) == 0) { if (Cmp(prefix, Getattr(r,rrk.key)) == 0) {
rkeymangle = SwigType_manglestr(rkey); rkeymangle = SwigType_manglestr(rk.key);
ckey = NewStringf("%s+%s", rrkey, rkeymangle); ckey = NewStringf("%s+%s", rrk.key, rkeymangle);
if (!Getattr(conversions, ckey)) { if (!Getattr(conversions, ckey)) {
Setattr(conversions, ckey, convname); Setattr(conversions, ckey, convname);
} }
Delete(ckey); Delete(ckey);
for (rlkey = Firstitem(rlist); rlkey; rlkey = Nextitem(rlist)) { for (rlk = First(rlist); rlk.item; rlk = Next(rlk)) {
ckey = NewStringf("%s+%s", rrkey, rlkey); ckey = NewStringf("%s+%s", rrk.key, rlk.item);
Setattr(conversions, ckey, convname); Setattr(conversions, ckey, convname);
Delete(ckey); Delete(ckey);
} }
Delete(rkeymangle); Delete(rkeymangle);
/* This is needed to pick up other alternative names for the same type. /* This is needed to pick up other alternative names for the same type.
Needed to make templates work */ Needed to make templates work */
Setattr(rh,rrkey,Getattr(r,rrkey)); Setattr(rh,rrk.key,rrk.item);
} }
rrkey = Nextkey(r); rrk = Next(rrk);
} }
} }
} }
Delete(convname); Delete(convname);
} }
Delete(prefix); Delete(prefix);
bkey = Nextkey(sub); bk = Next(bk);
} }
rkey = Nextkey(r_resolved); rk = Next(rk);
} }
} }
@ -1609,7 +1611,7 @@ void SwigType_inherit_equiv(File *out) {
void void
SwigType_emit_type_table(File *f_forward, File *f_table) { SwigType_emit_type_table(File *f_forward, File *f_table) {
DOH *key; Iterator ki;
String *types, *table; String *types, *table;
int i = 0; int i = 0;
@ -1643,36 +1645,37 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
table = NewString(""); table = NewString("");
types = NewString(""); types = NewString("");
Printf(table,"static swig_type_info *swig_types_initial[] = {\n"); Printf(table,"static swig_type_info *swig_types_initial[] = {\n");
key = Firstkey(r_mangled);
ki = First(r_mangled);
Printf(f_forward,"\n/* -------- TYPES TABLE (BEGIN) -------- */\n\n"); Printf(f_forward,"\n/* -------- TYPES TABLE (BEGIN) -------- */\n\n");
while (key) { while (ki.key) {
List *el; List *el;
String *en; Iterator ei;
String *cd; String *cd;
Printf(f_forward,"#define SWIGTYPE%s swig_types[%d] \n", key, i); Printf(f_forward,"#define SWIGTYPE%s swig_types[%d] \n", ki.key, i);
Printv(types,"static swig_type_info _swigt_", key, "[] = {", NIL); Printv(types,"static swig_type_info _swigt_", ki.key, "[] = {", NIL);
cd = SwigType_clientdata_collect(key,0); cd = SwigType_clientdata_collect(ki.key,0);
if (!cd) cd = "0"; if (!cd) cd = "0";
Printv(types,"{\"", key, "\", 0, \"", SwigType_str(Getattr(r_ltype,key),0),"\", ", cd, "},", NIL); Printv(types,"{\"", ki.key, "\", 0, \"", SwigType_str(Getattr(r_ltype,ki.key),0),"\", ", cd, "},", NIL);
el = SwigType_equivalent_mangle(key,0,0); el = SwigType_equivalent_mangle(ki.key,0,0);
for (en = Firstitem(el); en; en = Nextitem(el)) { for (ei = First(el); ei.item; ei = Next(ei)) {
String *ckey; String *ckey;
String *conv; String *conv;
ckey = NewStringf("%s+%s", en, key); ckey = NewStringf("%s+%s", ei.item, ki.key);
conv = Getattr(conversions,ckey); conv = Getattr(conversions,ckey);
if (conv) { if (conv) {
Printf(types,"{\"%s\", %s},", en, conv); Printf(types,"{\"%s\", %s},", ei.item, conv);
} else { } else {
Printf(types,"{\"%s\"},", en); Printf(types,"{\"%s\"},", ei.item);
} }
Delete(ckey); Delete(ckey);
} }
Delete(el); Delete(el);
Printf(types,"{0}};\n"); Printf(types,"{0}};\n");
Printv(table, "_swigt_", key, ", \n", NIL); Printv(table, "_swigt_", ki.key, ", \n", NIL);
key = Nextkey(r_mangled); ki = Next(ki);
i++; i++;
} }