Major refactoring of DOH List/Hash iterators. See CHANGES
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5101 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
768fa03144
commit
8ae4c60d39
35 changed files with 657 additions and 636 deletions
|
|
@ -44,7 +44,7 @@ static int name_mangle(String *r) {
|
|||
Replaceall(r,"::","_");
|
||||
c = Char(r);
|
||||
while (*c) {
|
||||
if (!isalnum(*c) && (*c != '_')) {
|
||||
if (!isalnum((int) *c) && (*c != '_')) {
|
||||
special = 1;
|
||||
switch(*c) {
|
||||
case '+':
|
||||
|
|
@ -480,7 +480,7 @@ Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType *dec
|
|||
|
||||
void
|
||||
Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
|
||||
String *key;
|
||||
Iterator ki;
|
||||
String *bprefix;
|
||||
String *dprefix;
|
||||
char *cbprefix;
|
||||
|
|
@ -492,23 +492,23 @@ Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
|
|||
dprefix = NewStringf("%s::",derived);
|
||||
cbprefix = Char(bprefix);
|
||||
plen = strlen(cbprefix);
|
||||
for (key = Firstkey(namehash); key; key = Nextkey(namehash)) {
|
||||
char *k = Char(key);
|
||||
for (ki = First(namehash); ki.key; ki = Next(ki)) {
|
||||
char *k = Char(ki.key);
|
||||
if (strncmp(k,cbprefix,plen) == 0) {
|
||||
Hash *n, *newh;
|
||||
String *nkey, *okey;
|
||||
|
||||
String *nkey;
|
||||
Iterator oi;
|
||||
|
||||
nkey = NewStringf("%s%s",dprefix,k+plen);
|
||||
n = Getattr(namehash,key);
|
||||
n = ki.item;
|
||||
newh = Getattr(namehash,nkey);
|
||||
if (!newh) {
|
||||
newh = NewHash();
|
||||
Setattr(namehash,nkey,newh);
|
||||
}
|
||||
for (okey = Firstkey(n); okey; okey = Nextkey(n)) {
|
||||
String *ovalue = Getattr(n,okey);
|
||||
if (!Getattr(newh,okey)) {
|
||||
Setattr(newh,okey,Copy(ovalue));
|
||||
for (oi = First(n); oi.key; oi = Next(oi)) {
|
||||
if (!Getattr(newh,oi.key)) {
|
||||
Setattr(newh,oi.key,Copy(oi.item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -522,13 +522,14 @@ Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void merge_features(Hash *features, Node *n) {
|
||||
String *key;
|
||||
Iterator ki;
|
||||
|
||||
if (!features) return;
|
||||
for (key = Firstkey(features); key; key = Nextkey(features)) {
|
||||
if (Getattr(n,key)) {
|
||||
for (ki = First(features); ki.key; ki = Next(ki)) {
|
||||
if (Getattr(n,ki.key)) {
|
||||
continue;
|
||||
}
|
||||
Setattr(n,key,Copy(Getattr(features,key)));
|
||||
Setattr(n,ki.key,Copy(ki.item));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1118,15 +1118,15 @@ Swig_symbol_type_qualify(SwigType *t, Symtab *st) {
|
|||
String *tprefix, *tsuffix;
|
||||
SwigType *qprefix;
|
||||
List *targs;
|
||||
String *tparm;
|
||||
Iterator ti;
|
||||
tprefix = SwigType_templateprefix(e);
|
||||
tsuffix = SwigType_templatesuffix(e);
|
||||
qprefix = Swig_symbol_type_qualify(tprefix,st);
|
||||
targs = SwigType_parmlist(e);
|
||||
Printf(qprefix,"<(");
|
||||
for (tparm = Firstitem(targs); tparm;) {
|
||||
String *qparm = Swig_symbol_type_qualify(tparm,st);
|
||||
/* Printf(stdout,"qparm = '%s', tparm = '%s'\n", qparm, tparm);*/
|
||||
for (ti = First(targs); ti.item;) {
|
||||
String *qparm = Swig_symbol_type_qualify(ti.item,st);
|
||||
/* Printf(stdout,"qparm = '%s', tparm = '%s'\n", qparm, ti.item);*/
|
||||
while (1) {
|
||||
/* 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);
|
||||
tparm = Nextitem(targs);
|
||||
if (tparm) {
|
||||
ti = Next(ti);
|
||||
if (ti.item) {
|
||||
Putc(',',qprefix);
|
||||
}
|
||||
Delete(qparm);
|
||||
|
|
@ -1175,14 +1175,14 @@ Swig_symbol_type_qualify(SwigType *t, Symtab *st) {
|
|||
}
|
||||
Append(result,e);
|
||||
} else if (SwigType_isfunction(e)) {
|
||||
Iterator pi;
|
||||
List *parms = SwigType_parmlist(e);
|
||||
String *s = NewString("f(");
|
||||
String *p;
|
||||
p = Firstitem(parms);
|
||||
while (p) {
|
||||
Append(s,Swig_symbol_type_qualify(p,st));
|
||||
p = Nextitem(parms);
|
||||
if (p) {
|
||||
pi = First(parms);
|
||||
while (pi.item) {
|
||||
Append(s,Swig_symbol_type_qualify(pi.item,st));
|
||||
pi = Next(pi);
|
||||
if (pi.item) {
|
||||
Append(s,",");
|
||||
}
|
||||
}
|
||||
|
|
@ -1269,7 +1269,7 @@ Swig_symbol_string_qualify(String *s, Symtab *st) {
|
|||
r = NewString("");
|
||||
c = Char(s);
|
||||
while (*c) {
|
||||
if (isalpha(*c) || (*c == '_') || (*c == ':')) {
|
||||
if (isalpha((int)*c) || (*c == '_') || (*c == ':')) {
|
||||
Putc(*c,id);
|
||||
have_id = 1;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -70,13 +70,14 @@ static void print_indent(int l) {
|
|||
|
||||
void
|
||||
Swig_print_node(Node *obj) {
|
||||
String *k;
|
||||
Iterator ki;
|
||||
Node *cobj;
|
||||
|
||||
print_indent(0);
|
||||
Printf(stdout,"+++ %s ----------------------------------------\n", nodeType(obj));
|
||||
k = Firstkey(obj);
|
||||
while (k) {
|
||||
ki = First(obj);
|
||||
while (ki.key) {
|
||||
String *k = ki.key;
|
||||
if ((Cmp(k,"nodeType") == 0) || (Cmp(k,"firstChild") == 0) || (Cmp(k,"lastChild") == 0) ||
|
||||
(Cmp(k,"parentNode") == 0) || (Cmp(k,"nextSibling") == 0) ||
|
||||
(Cmp(k,"previousSibling") == 0) || (*(Char(k)) == '$')) {
|
||||
|
|
@ -99,7 +100,7 @@ Swig_print_node(Node *obj) {
|
|||
Printf(stdout,"%-12s - 0x%x\n", k, Getattr(obj,k));
|
||||
}
|
||||
}
|
||||
k = Nextkey(obj);
|
||||
ki = Next(ki);
|
||||
}
|
||||
cobj = firstChild(obj);
|
||||
if (cobj) {
|
||||
|
|
@ -187,13 +188,11 @@ deleteNode(Node *n) {
|
|||
|
||||
Node *
|
||||
copyNode(Node *n) {
|
||||
String *key;
|
||||
DOH *v;
|
||||
Iterator ki;
|
||||
Node *c = NewHash();
|
||||
for (key = Firstkey(n); key; key = Nextkey(n)) {
|
||||
v = Getattr(n,key);
|
||||
if (DohIsString(v)) {
|
||||
Setattr(c,key,Copy(v));
|
||||
for (ki = First(n); ki.key; ki = Next(ki)) {
|
||||
if (DohIsString(ki.item)) {
|
||||
Setattr(c,ki.key,Copy(ki.item));
|
||||
}
|
||||
}
|
||||
Setfile(c,Getfile(n));
|
||||
|
|
@ -336,11 +335,11 @@ Swig_save(const char *ns, Node *n, ...) {
|
|||
|
||||
void
|
||||
Swig_restore(Node *n) {
|
||||
String *key;
|
||||
char temp[512];
|
||||
int len;
|
||||
List *l;
|
||||
String *ns;
|
||||
Iterator ki;
|
||||
|
||||
ns = Getattr(n,"view");
|
||||
assert(ns);
|
||||
|
|
@ -351,15 +350,15 @@ Swig_restore(Node *n) {
|
|||
strcat(temp,":");
|
||||
len = strlen(temp);
|
||||
|
||||
for (key = Firstkey(n); key; key = Nextkey(n)) {
|
||||
if (Strncmp(temp,key,len) == 0) {
|
||||
Append(l,key);
|
||||
for (ki = First(n); ki.key; ki = Next(ki)) {
|
||||
if (Strncmp(temp,ki.key,len) == 0) {
|
||||
Append(l,ki.key);
|
||||
}
|
||||
}
|
||||
for (key = Firstitem(l); key; key = Nextitem(l)) {
|
||||
DOH *obj = Getattr(n,key);
|
||||
Setattr(n,Char(key)+len,obj);
|
||||
Delattr(n,key);
|
||||
for (ki = First(l); ki.item; ki = Next(ki)) {
|
||||
DOH *obj = Getattr(n,ki.item);
|
||||
Setattr(n,Char(ki.item)+len,obj);
|
||||
Delattr(n,ki.item);
|
||||
}
|
||||
Delete(l);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -397,15 +397,14 @@ Swig_typemap_apply(ParmList *src, ParmList *dest) {
|
|||
|
||||
if (sm) {
|
||||
/* Got a typemap. Need to only merge attributes for methods that match our signature */
|
||||
String *key;
|
||||
|
||||
Iterator ki;
|
||||
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 */
|
||||
if ((count_args(key) == narg) && (Strstr(key,ssig))) {
|
||||
if ((count_args(ki.key) == narg) && (Strstr(ki.key,ssig))) {
|
||||
String *oldm;
|
||||
/* A typemap we have to copy */
|
||||
String *nkey = Copy(key);
|
||||
String *nkey = Copy(ki.key);
|
||||
Replace(nkey,ssig,dsig,DOH_REPLACE_ANY);
|
||||
|
||||
/* 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;
|
||||
ParmList *locals;
|
||||
ParmList *kwargs;
|
||||
Hash *sm1 = Getattr(sm,key);
|
||||
Hash *sm1 = ki.item;
|
||||
|
||||
code = Getattr(sm1,"code");
|
||||
locals = Getattr(sm1,"locals");
|
||||
|
|
@ -474,14 +473,15 @@ Swig_typemap_clear_apply(Parm *parms) {
|
|||
}
|
||||
if (tm) {
|
||||
/* Clear typemaps that match our signature */
|
||||
String *key, *key2;
|
||||
for (key = Firstkey(tm); key; key = Nextkey(tm)) {
|
||||
if (Strncmp(key,"tmap:",5) == 0) {
|
||||
int na = count_args(key);
|
||||
if ((na == narg) && Strstr(key,tsig)) {
|
||||
Hash *h = Getattr(tm,key);
|
||||
for (key2 = Firstkey(h); key2; key2 = Nextkey(h)) {
|
||||
Delattr(h,key2);
|
||||
Iterator ki, ki2;
|
||||
|
||||
for (ki = First(tm); ki.key; ki = Next(ki)) {
|
||||
if (Strncmp(ki.key,"tmap:",5) == 0) {
|
||||
int na = count_args(ki.key);
|
||||
if ((na == narg) && Strstr(ki.key,tsig)) {
|
||||
Hash *h = ki.item;
|
||||
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 (isspace(*c) && leading) start++;
|
||||
if (!isspace(*c)) leading = 0;
|
||||
if (isspace((int)*c) && leading) start++;
|
||||
if (!isspace((int)*c)) leading = 0;
|
||||
c++;
|
||||
}
|
||||
return args;
|
||||
|
|
@ -1449,7 +1449,7 @@ static void split_var(String *s, String **name, String **value) {
|
|||
*name = NewStringWithSize(c,eq-c);
|
||||
|
||||
/* Look for $n variables */
|
||||
if (isdigit(*(c))) {
|
||||
if (isdigit((int)*(c))) {
|
||||
/* Parse the value as a type */
|
||||
String *v;
|
||||
Parm *p;
|
||||
|
|
@ -1552,9 +1552,9 @@ void replace_embedded_typemap(String *s, Wrapper *f) {
|
|||
if (!Getattr(first,attr)) {
|
||||
/* Should be no more matches. Hack??? */
|
||||
/* Replace all of the remaining variables */
|
||||
String *key;
|
||||
for (key = Firstkey(vars); key; key = Nextkey(vars)) {
|
||||
Replace(tm,key,Getattr(vars,key), DOH_REPLACE_ANY);
|
||||
Iterator ki;
|
||||
for (ki = First(vars); ki.key; ki = Next(ki)) {
|
||||
Replace(tm,ki.key,ki.item, DOH_REPLACE_ANY);
|
||||
}
|
||||
/* Do the replacement */
|
||||
Replace(s,tmp,tm, DOH_REPLACE_ANY);
|
||||
|
|
|
|||
|
|
@ -695,9 +695,10 @@ ParmList *
|
|||
SwigType_function_parms(SwigType *t) {
|
||||
List *l = SwigType_parmlist(t);
|
||||
Hash *p, *pp = 0, *firstp = 0;
|
||||
DOH *obj;
|
||||
for (obj = Firstitem(l); obj; obj = Nextitem(l)) {
|
||||
p = NewParm(obj,0);
|
||||
Iterator o;
|
||||
|
||||
for (o = First(l); o.item; o = Next(o)) {
|
||||
p = NewParm(o.item,0);
|
||||
if (!firstp) firstp = p;
|
||||
if (pp) {
|
||||
set_nextSibling(pp,p);
|
||||
|
|
@ -963,7 +964,7 @@ SwigType_strip_qualifiers(SwigType *t) {
|
|||
static Hash *memoize_stripped = 0;
|
||||
SwigType *r;
|
||||
List *l;
|
||||
SwigType *e;
|
||||
Iterator ei;
|
||||
|
||||
if (!memoize_stripped) memoize_stripped = NewHash();
|
||||
r = Getattr(memoize_stripped,t);
|
||||
|
|
@ -971,9 +972,10 @@ SwigType_strip_qualifiers(SwigType *t) {
|
|||
|
||||
l = SwigType_split(t);
|
||||
r = NewString("");
|
||||
for (e = Firstitem(l); e; e = Nextitem(l)) {
|
||||
if (SwigType_isqualifier(e)) continue;
|
||||
Append(r,e);
|
||||
|
||||
for (ei = First(l);ei.item; ei = Next(ei)) {
|
||||
if (SwigType_isqualifier(ei.item)) continue;
|
||||
Append(r,ei.item);
|
||||
}
|
||||
Delete(l);
|
||||
{
|
||||
|
|
|
|||
|
|
@ -366,27 +366,26 @@ SwigType_attach_symtab(Symtab *sym) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void SwigType_print_scope(Typetab *t) {
|
||||
String *key;
|
||||
Hash *ttab;
|
||||
String *tkey;
|
||||
Iterator i,j;
|
||||
|
||||
for (tkey = Firstkey(scopes); tkey; tkey = Nextkey(scopes)) {
|
||||
t = Getattr(scopes,tkey);
|
||||
ttab = Getattr(t,"typetab");
|
||||
for (i = First(scopes); i.key; i = Next(i)) {
|
||||
t = i.item;
|
||||
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) {
|
||||
Typetab *it;
|
||||
for (it = Firstitem(inherit); it; it = Nextitem(inherit)) {
|
||||
Printf(stdout," Inherits from '%s' (%x)\n", Getattr(it,"qname"), it);
|
||||
Iterator j;
|
||||
for (j = First(inherit); j.item; j = Next(j)) {
|
||||
Printf(stdout," Inherits from '%s' (%x)\n", Getattr(j.item,"qname"), j.item);
|
||||
}
|
||||
}
|
||||
}
|
||||
Printf(stdout,"-------------------------------------------------------------\n");
|
||||
for (key = Firstkey(ttab); key; key = Nextkey(ttab)) {
|
||||
Printf(stdout,"%40s -> %s\n", key, Getattr(ttab,key));
|
||||
for (j = First(ttab); j.key; j = Next(j)) {
|
||||
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 */
|
||||
String *tprefix, *qprefix;
|
||||
String *tsuffix;
|
||||
Iterator pi;
|
||||
Parm *p;
|
||||
List *parms = SwigType_parmlist(e);
|
||||
tprefix = SwigType_templateprefix(e);
|
||||
tsuffix = SwigType_templatesuffix(e);
|
||||
qprefix = SwigType_typedef_qualified(tprefix);
|
||||
Printv(qprefix,"<(",NIL);
|
||||
p = Firstitem(parms);
|
||||
while (p) {
|
||||
pi = First(parms);
|
||||
while ((p = pi.item)) {
|
||||
String *qt = SwigType_typedef_qualified(p);
|
||||
if ((Strcmp(qt,p) == 0)) { /* && (!Swig_scopename_check(qt))) { */
|
||||
/* 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);
|
||||
}
|
||||
Delete(qt);
|
||||
p= Nextitem(parms);
|
||||
if (p) {
|
||||
pi= Next(pi);
|
||||
if (pi.item) {
|
||||
Append(qprefix,",");
|
||||
}
|
||||
}
|
||||
|
|
@ -933,14 +933,14 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
|
|||
} else if (SwigType_isfunction(e)) {
|
||||
List *parms = SwigType_parmlist(e);
|
||||
String *s = NewString("f(");
|
||||
String *p;
|
||||
p = Firstitem(parms);
|
||||
while (p) {
|
||||
String *pq = SwigType_typedef_qualified(p);
|
||||
Iterator pi;
|
||||
pi = First(parms);
|
||||
while (pi.item) {
|
||||
String *pq = SwigType_typedef_qualified(pi.item);
|
||||
Append(s,pq);
|
||||
Delete(pq);
|
||||
p = Nextitem(parms);
|
||||
if (p) {
|
||||
pi = Next(pi);
|
||||
if (pi.item) {
|
||||
Append(s,",");
|
||||
}
|
||||
}
|
||||
|
|
@ -1350,26 +1350,26 @@ List *SwigType_equivalent_mangle(String *ms, Hash *checked, Hash *found) {
|
|||
Setattr(ch, ms, "1");
|
||||
mh = Getattr(r_mangled,ms);
|
||||
if (mh) {
|
||||
String *key;
|
||||
key = Firstkey(mh);
|
||||
while (key) {
|
||||
Iterator ki;
|
||||
ki = First(mh);
|
||||
while (ki.key) {
|
||||
Hash *rh;
|
||||
if (Getattr(ch,key)) {
|
||||
key = Nextkey(mh);
|
||||
if (Getattr(ch,ki.key)) {
|
||||
ki = Next(ki);
|
||||
continue;
|
||||
}
|
||||
Setattr(ch,key,"1");
|
||||
rh = Getattr(r_resolved,key);
|
||||
Setattr(ch,ki.key,"1");
|
||||
rh = Getattr(r_resolved,ki.key);
|
||||
if (rh) {
|
||||
String *rkey;
|
||||
rkey = Firstkey(rh);
|
||||
while (rkey) {
|
||||
Setattr(h,rkey,"1");
|
||||
SwigType_equivalent_mangle(rkey,ch,h);
|
||||
rkey = Nextkey(rh);
|
||||
Iterator rk;
|
||||
rk = First(rh);
|
||||
while (rk.key) {
|
||||
Setattr(h,rk.key,"1");
|
||||
SwigType_equivalent_mangle(rk.key,ch,h);
|
||||
rk = Next(rk);
|
||||
}
|
||||
}
|
||||
key = Nextkey(mh);
|
||||
ki = Next(ki);
|
||||
}
|
||||
}
|
||||
check_exit:
|
||||
|
|
@ -1404,24 +1404,24 @@ String *SwigType_clientdata_collect(String *ms, Hash *checked) {
|
|||
Setattr(ch, ms, "1");
|
||||
mh = Getattr(r_mangled,ms);
|
||||
if (mh) {
|
||||
String *key;
|
||||
key = Firstkey(mh);
|
||||
while (key) {
|
||||
Iterator ki;
|
||||
ki = First(mh);
|
||||
while (ki.key) {
|
||||
Hash *rh;
|
||||
Setattr(ch,key,"1");
|
||||
clientdata = Getattr(r_clientdata,key);
|
||||
Setattr(ch,ki.key,"1");
|
||||
clientdata = Getattr(r_clientdata,ki.key);
|
||||
if (clientdata) goto check_exit;
|
||||
rh = Getattr(r_resolved,key);
|
||||
rh = Getattr(r_resolved,ki.key);
|
||||
if (rh) {
|
||||
String *rkey;
|
||||
rkey = Firstkey(rh);
|
||||
while (rkey) {
|
||||
clientdata = SwigType_clientdata_collect(rkey,ch);
|
||||
Iterator rk;
|
||||
rk = First(rh);
|
||||
while (rk.key) {
|
||||
clientdata = SwigType_clientdata_collect(rk.key,ch);
|
||||
if (clientdata) goto check_exit;
|
||||
rkey = Nextkey(rh);
|
||||
rk = Next(rk);
|
||||
}
|
||||
}
|
||||
key = Nextkey(mh);
|
||||
ki = Next(ki);
|
||||
}
|
||||
}
|
||||
check_exit:
|
||||
|
|
@ -1515,48 +1515,49 @@ SwigType_issubtype(SwigType *t1, SwigType *t2) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void SwigType_inherit_equiv(File *out) {
|
||||
String *rkey, *bkey, *ckey;
|
||||
String *ckey;
|
||||
String *prefix, *base;
|
||||
Hash *sub;
|
||||
Hash *rh;
|
||||
List *rlist;
|
||||
Iterator rk, bk, ck;
|
||||
|
||||
if (!conversions) conversions = NewHash();
|
||||
if (!subclass) subclass = NewHash();
|
||||
|
||||
rkey = Firstkey(r_resolved);
|
||||
while (rkey) {
|
||||
rk = First(r_resolved);
|
||||
while (rk.key) {
|
||||
/* 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 */
|
||||
sub = Getattr(subclass,base);
|
||||
Delete(base);
|
||||
if (!sub) {
|
||||
rkey = Nextkey(r_resolved);
|
||||
rk = Next(rk);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* 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();
|
||||
for (ckey = Firstkey(rh); ckey; ckey = Nextkey(rh)) {
|
||||
Append(rlist,ckey);
|
||||
for (ck = First(rh); ck.key; ck = Next(ck)) {
|
||||
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); */
|
||||
|
||||
bkey = Firstkey(sub);
|
||||
while (bkey) {
|
||||
prefix= SwigType_prefix(rkey);
|
||||
Append(prefix,bkey);
|
||||
bk = First(sub);
|
||||
while (bk.key) {
|
||||
prefix= SwigType_prefix(rk.key);
|
||||
Append(prefix,bk.key);
|
||||
/* Printf(stdout,"set %x = '%s' : '%s'\n", 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)) {
|
||||
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," 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");
|
||||
Setattr(conversions,ckey,convname);
|
||||
Delete(ckey);
|
||||
|
|
@ -1565,39 +1566,40 @@ void SwigType_inherit_equiv(File *out) {
|
|||
{
|
||||
Hash *r = Getattr(r_resolved, prefix);
|
||||
if (r) {
|
||||
String *rrkey = Firstkey(r);
|
||||
while (rrkey) {
|
||||
String *rlkey;
|
||||
Iterator rrk;
|
||||
rrk=First(r);
|
||||
while (rrk.key) {
|
||||
Iterator rlk;
|
||||
String *rkeymangle;
|
||||
|
||||
/* Make sure this name equivalence is not due to inheritance */
|
||||
if (Cmp(prefix, Getattr(r,rrkey)) == 0) {
|
||||
rkeymangle = SwigType_manglestr(rkey);
|
||||
ckey = NewStringf("%s+%s", rrkey, rkeymangle);
|
||||
if (Cmp(prefix, Getattr(r,rrk.key)) == 0) {
|
||||
rkeymangle = SwigType_manglestr(rk.key);
|
||||
ckey = NewStringf("%s+%s", rrk.key, rkeymangle);
|
||||
if (!Getattr(conversions, ckey)) {
|
||||
Setattr(conversions, ckey, convname);
|
||||
}
|
||||
Delete(ckey);
|
||||
for (rlkey = Firstitem(rlist); rlkey; rlkey = Nextitem(rlist)) {
|
||||
ckey = NewStringf("%s+%s", rrkey, rlkey);
|
||||
for (rlk = First(rlist); rlk.item; rlk = Next(rlk)) {
|
||||
ckey = NewStringf("%s+%s", rrk.key, rlk.item);
|
||||
Setattr(conversions, ckey, convname);
|
||||
Delete(ckey);
|
||||
}
|
||||
Delete(rkeymangle);
|
||||
/* This is needed to pick up other alternative names for the same type.
|
||||
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(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
|
||||
SwigType_emit_type_table(File *f_forward, File *f_table) {
|
||||
DOH *key;
|
||||
Iterator ki;
|
||||
String *types, *table;
|
||||
int i = 0;
|
||||
|
||||
|
|
@ -1643,36 +1645,37 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
|
|||
table = NewString("");
|
||||
types = NewString("");
|
||||
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");
|
||||
while (key) {
|
||||
while (ki.key) {
|
||||
List *el;
|
||||
String *en;
|
||||
Iterator ei;
|
||||
String *cd;
|
||||
|
||||
Printf(f_forward,"#define SWIGTYPE%s swig_types[%d] \n", key, i);
|
||||
Printv(types,"static swig_type_info _swigt_", key, "[] = {", NIL);
|
||||
Printf(f_forward,"#define SWIGTYPE%s swig_types[%d] \n", ki.key, i);
|
||||
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";
|
||||
Printv(types,"{\"", key, "\", 0, \"", SwigType_str(Getattr(r_ltype,key),0),"\", ", cd, "},", NIL);
|
||||
el = SwigType_equivalent_mangle(key,0,0);
|
||||
for (en = Firstitem(el); en; en = Nextitem(el)) {
|
||||
Printv(types,"{\"", ki.key, "\", 0, \"", SwigType_str(Getattr(r_ltype,ki.key),0),"\", ", cd, "},", NIL);
|
||||
el = SwigType_equivalent_mangle(ki.key,0,0);
|
||||
for (ei = First(el); ei.item; ei = Next(ei)) {
|
||||
String *ckey;
|
||||
String *conv;
|
||||
ckey = NewStringf("%s+%s", en, key);
|
||||
ckey = NewStringf("%s+%s", ei.item, ki.key);
|
||||
conv = Getattr(conversions,ckey);
|
||||
if (conv) {
|
||||
Printf(types,"{\"%s\", %s},", en, conv);
|
||||
Printf(types,"{\"%s\", %s},", ei.item, conv);
|
||||
} else {
|
||||
Printf(types,"{\"%s\"},", en);
|
||||
Printf(types,"{\"%s\"},", ei.item);
|
||||
}
|
||||
Delete(ckey);
|
||||
}
|
||||
Delete(el);
|
||||
Printf(types,"{0}};\n");
|
||||
Printv(table, "_swigt_", key, ", \n", NIL);
|
||||
key = Nextkey(r_mangled);
|
||||
Printv(table, "_swigt_", ki.key, ", \n", NIL);
|
||||
ki = Next(ki);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue