From: Marcelo M. <mar...@us...> - 2005-11-27 09:58:38
|
Update of /cvsroot/swig/SWIG/Source/Swig In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27923/Source/Swig Modified Files: swig.h symbol.c typemap.c Log Message: add direct HashCheckAttr Index: typemap.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/typemap.c,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** typemap.c 27 Nov 2005 02:58:24 -0000 1.49 --- typemap.c 27 Nov 2005 09:58:26 -0000 1.50 *************** *** 662,666 **** unstripped = ctype; ctype = SwigType_strip_qualifiers(ctype); ! if (Strcmp(ctype,unstripped) != 0) continue; /* Types are different */ Delete(ctype); ctype = unstripped; --- 662,666 ---- unstripped = ctype; ctype = SwigType_strip_qualifiers(ctype); ! if (!StringEqual(ctype,unstripped)) continue; /* Types are different */ Delete(ctype); ctype = unstripped; *************** *** 1326,1330 **** } ! if (checkAttribute(tm,k_type,k_SWIGTYPE)) { sprintf(temp,"%s:SWIGTYPE", Char(op)); Setattr(node,tmop_name(temp),k_one); --- 1326,1330 ---- } ! if (HashCheckAttr(tm,k_type,k_SWIGTYPE)) { sprintf(temp,"%s:SWIGTYPE", Char(op)); Setattr(node,tmop_name(temp),k_one); *************** *** 1500,1504 **** } ! if (checkAttribute(tm,k_type,k_SWIGTYPE)) { sprintf(temp,"%s:SWIGTYPE", Char(op)); Setattr(p,tmop_name(temp),k_one); --- 1500,1504 ---- } ! if (HashCheckAttr(tm,k_type,k_SWIGTYPE)) { sprintf(temp,"%s:SWIGTYPE", Char(op)); Setattr(p,tmop_name(temp),k_one); Index: symbol.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/symbol.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** symbol.c 27 Nov 2005 02:58:24 -0000 1.32 --- symbol.c 27 Nov 2005 09:58:26 -0000 1.33 *************** *** 176,179 **** --- 176,181 ---- /* common attribute keys, to avoid calling find_key all the times */ + + static String *k_allowstypedef = 0; static String *k_cdecl = 0; static String *k_coloncolon = 0; *************** *** 183,189 **** --- 185,193 ---- static String *k_csymtab = 0; static String *k_decl = 0; + static String *k_empty = 0; static String *k_enumitem = 0; static String *k_inherit = 0; static String *k_name = 0; + static String *k_namespace = 0; static String *k_nodetype = 0; static String *k_parentnode = 0; *************** *** 197,201 **** --- 201,210 ---- static String *k_symsymtab = 0; static String *k_symtab = 0; + static String *k_symtypename = 0; + static String *k_symweak = 0; + static String *k_template = 0; + static String *k_templateparm = 0; static String *k_templateparms = 0; + static String *k_templatetype = 0; static String *k_type = 0; static String *k_typedef = 0; *************** *** 210,214 **** Printf(stdout, "DUMPING SYMTABLE start =======================================\n"); { ! Hash* cst = Getattr(current_symtab, "csymtab"); Swig_print_tree(cst); /* --- 219,223 ---- Printf(stdout, "DUMPING SYMTABLE start =======================================\n"); { ! Hash* cst = Getattr(current_symtab, k_csymtab); Swig_print_tree(cst); /* *************** *** 228,231 **** --- 237,241 ---- void Swig_symbol_init() { + k_allowstypedef = NewString("allows_typedef"); k_cdecl = NewString("cdecl"); k_coloncolon = NewString("::"); *************** *** 235,241 **** --- 245,253 ---- k_csymtab = NewString("csymtab"); k_decl = NewString("decl"); + k_empty = NewString("empty"); k_enumitem = NewString("enumitem"); k_inherit = NewString("inherit"); k_name = NewString("name"); + k_namespace = NewString("namespace"); k_nodetype = NewString("nodeType"); k_parentnode = NewString("parentNode"); *************** *** 249,253 **** --- 261,270 ---- k_symsymtab = NewString("sym:symtab"); k_symtab = NewString("symtab"); + k_symtypename = NewString("sym:typename"); + k_symweak = NewString("sym:weak"); + k_template = NewString("template"); + k_templateparm = NewString("templateparm"); k_templateparms = NewString("templateparms"); + k_templatetype = NewString("templatetype"); k_type = NewString("type"); k_typedef = NewString("typedef"); *************** *** 265,269 **** /* Set the global scope */ symtabs = NewHash(); ! Setattr(symtabs,"",current_symtab); global_scope = current_symtab; } --- 282,286 ---- /* Set the global scope */ symtabs = NewHash(); ! Setattr(symtabs,k_empty,current_symtab); global_scope = current_symtab; } *************** *** 278,282 **** Swig_symbol_setscopename(const String_or_char *name) { String *qname; ! assert(!Getattr(current_symtab,k_name)); Setattr(current_symtab,k_name,name); --- 295,299 ---- Swig_symbol_setscopename(const String_or_char *name) { String *qname; ! /* assert(!Getattr(current_symtab,k_name)); */ Setattr(current_symtab,k_name,name); *************** *** 310,314 **** Swig_symbol_getscope(const String_or_char *name) { if (!symtabs) return 0; ! if (Strcmp(name,k_coloncolon) == 0) name = ""; return Getattr(symtabs,name); } --- 327,331 ---- Swig_symbol_getscope(const String_or_char *name) { if (!symtabs) return 0; ! if (StringEqual(k_coloncolon,(String_or_char *)name)) name = k_empty; return Getattr(symtabs,name); } *************** *** 497,501 **** String *cname = NewString(name); String *dname = Swig_symbol_template_deftype(cname,0); ! if (Strcmp(dname,name)) { Swig_symbol_cadd(dname, n); } --- 514,518 ---- String *cname = NewString(name); String *dname = Swig_symbol_template_deftype(cname,0); ! if (!StringEqual(dname,name)) { Swig_symbol_cadd(dname, n); } *************** *** 509,526 **** cn = Getattr(ccurrent,name); ! if (cn && (Getattr(cn,"sym:typename"))) { /* The node in the C symbol table is a typename. Do nothing */ /* We might append the symbol at the end */ append = n; ! } else if (cn && (Getattr(cn,"sym:weak"))) { /* The node in the symbol table is weak. Replace it */ Setattr(ccurrent,name, n); ! } else if (cn && (Getattr(n,"sym:weak"))) { /* The node being added is weak. Don't worry about it */ ! } else if (cn && (Getattr(n,"sym:typename"))) { /* The node being added is a typename. We definitely add it */ Setattr(ccurrent,name,n); append = cn; ! } else if (cn && (Strcmp(nodeType(cn),"templateparm") == 0)) { Swig_error(Getfile(n),Getline(n), "Declaration of '%s' shadows template parameter,\n", --- 526,543 ---- cn = Getattr(ccurrent,name); ! if (cn && (Getattr(cn,k_symtypename))) { /* The node in the C symbol table is a typename. Do nothing */ /* We might append the symbol at the end */ append = n; ! } else if (cn && (Getattr(cn,k_symweak))) { /* The node in the symbol table is weak. Replace it */ Setattr(ccurrent,name, n); ! } else if (cn && (Getattr(n,k_symweak))) { /* The node being added is weak. Don't worry about it */ ! } else if (cn && (Getattr(n,k_symtypename))) { /* The node being added is a typename. We definitely add it */ Setattr(ccurrent,name,n); append = cn; ! } else if (cn && (HashCheckAttr(cn, k_nodetype, k_templateparm))) { Swig_error(Getfile(n),Getline(n), "Declaration of '%s' shadows template parameter,\n", *************** *** 568,572 **** { Node *td = n; ! while (td && (Strcmp(nodeType(td),k_cdecl) == 0) && (checkAttribute(td,k_storage,k_typedef))) { SwigType *type; Node *td1; --- 585,589 ---- { Node *td = n; ! while (td && HashCheckAttr(td,k_nodetype,k_cdecl) && HashCheckAttr(td,k_storage,k_typedef)) { SwigType *type; Node *td1; *************** *** 592,599 **** */ ! if (td1 && checkAttribute(td1,k_storage,k_typedef)) { String *st = Getattr(td1,k_type); String *sn = Getattr(td,k_name); ! if (st && sn && (Strcmp(st, sn) == 0)) { Symtab *sc = Getattr(current_symtab,k_parentnode); if (sc) td1 = Swig_symbol_clookup(type,sc); --- 609,616 ---- */ ! if (td1 && HashCheckAttr(td1,k_storage,k_typedef)) { String *st = Getattr(td1,k_type); String *sn = Getattr(td,k_name); ! if (st && sn && StringEqual(st, sn)) { Symtab *sc = Getattr(current_symtab,k_parentnode); if (sc) td1 = Swig_symbol_clookup(type,sc); *************** *** 684,688 **** definition of Foo would replace the entry if it appeared later. */ ! if (c && Getattr(c,"sym:weak")) { c = 0; } --- 701,705 ---- definition of Foo would replace the entry if it appeared later. */ ! if (c && Getattr(c,k_symweak)) { c = 0; } *************** *** 699,703 **** /* Check for namespaces */ ! if ((Strcmp(nodeType(n),nodeType(c)) == 0) && ((Strcmp(nodeType(n),"namespace") == 0))) { Node *cl, *pcl = 0; cl = c; --- 716,721 ---- /* Check for namespaces */ ! String *ntype = Getattr(n, k_nodetype); ! if ((StringEqual(ntype,Getattr(c,k_nodetype))) && ((StringEqual(ntype,k_namespace)))) { Node *cl, *pcl = 0; cl = c; *************** *** 712,717 **** return n; } ! if (Getattr(n,"allows_typedef")) nt = 1; ! if (Getattr(c,"allows_typedef")) ct = 1; if (nt || ct) { Node *td, *other; --- 730,735 ---- return n; } ! if (Getattr(n,k_allowstypedef)) nt = 1; ! if (Getattr(c,k_allowstypedef)) ct = 1; if (nt || ct) { Node *td, *other; *************** *** 732,736 **** /* Make sure the other node is a typedef */ s = Getattr(other,k_storage); ! if (!s || (Strcmp(s,k_typedef))) return c; /* No. This is a conflict */ /* Hmmm. This appears to be okay. Make sure the symbol table refers to the allow_type node */ --- 750,754 ---- /* Make sure the other node is a typedef */ s = Getattr(other,k_storage); ! if (!s || (!StringEqual(s,k_typedef))) return c; /* No. This is a conflict */ /* Hmmm. This appears to be okay. Make sure the symbol table refers to the allow_type node */ *************** *** 749,760 **** { String *nt1, *nt2; ! nt1 = nodeType(n); ! if (Strcmp(nt1,"template") == 0) nt1 = Getattr(n,"templatetype"); ! nt2 = nodeType(c); ! if (Strcmp(nt2,"template") == 0) nt2 = Getattr(c,"templatetype"); ! if (Strcmp(nt1,"using") == 0) u1 = 1; ! if (Strcmp(nt2,"using") == 0) u2 = 1; ! if ((Strcmp(nt1,nt2) != 0) && !(u1 || u2)) return c; } if (!(u1 || u2)) { --- 767,778 ---- { String *nt1, *nt2; ! nt1 = Getattr(n,k_nodetype); ! if (StringEqual(nt1,k_template)) nt1 = Getattr(n,k_templatetype); ! nt2 = Getattr(c,k_nodetype); ! if (StringEqual(nt2,k_template)) nt2 = Getattr(c,k_templatetype); ! if (StringEqual(nt1,k_using)) u1 = 1; ! if (StringEqual(nt2,k_using)) u2 = 1; ! if ((!StringEqual(nt1,nt2)) && !(u1 || u2)) return c; } if (!(u1 || u2)) { *************** *** 780,785 **** /* Okay. Walk down the list of symbols and see if we get a declarator match */ { ! int n_template = (Strcmp(nodeType(n),"template") == 0) && (Strcmp(Getattr(n,"templatetype"),k_cdecl) == 0); ! int n_plain_cdecl = (Strcmp(nodeType(n),k_cdecl) == 0); cn = c; pn = 0; --- 798,804 ---- /* Okay. Walk down the list of symbols and see if we get a declarator match */ { ! String *nt = Getattr(n,k_nodetype); ! int n_template = StringEqual(nt,k_template) && HashCheckAttr(n,k_templatetype,k_cdecl); ! int n_plain_cdecl = StringEqual(nt,k_cdecl); cn = c; pn = 0; *************** *** 791,796 **** /* Now check we don't have a non-templated function overloaded by a templated function with same params, * eg void foo(); template<typename> void foo(); */ ! int cn_template = (Strcmp(nodeType(cn),"template") == 0) && (Strcmp(Getattr(cn,"templatetype"),k_cdecl) == 0); ! int cn_plain_cdecl = (Strcmp(nodeType(cn),k_cdecl) == 0); if (!((n_template && cn_plain_cdecl) || (cn_template && n_plain_cdecl))) { /* found a conflict */ --- 810,816 ---- /* Now check we don't have a non-templated function overloaded by a templated function with same params, * eg void foo(); template<typename> void foo(); */ ! String *cnt = Getattr(cn,k_nodetype); ! int cn_template = StringEqual(cnt,k_template) && HashCheckAttr(cn,k_templatetype,k_cdecl); ! int cn_plain_cdecl = StringEqual(cnt,k_cdecl); if (!((n_template && cn_plain_cdecl) || (cn_template && n_plain_cdecl))) { /* found a conflict */ *************** *** 884,888 **** Setmark(symtab,0); dname = Swig_symbol_template_deftype(name,symtab); ! if (Strcmp(name,dname)) { n = symbol_lookup(dname, symtab, check); } --- 904,908 ---- Setmark(symtab,0); dname = Swig_symbol_template_deftype(name,symtab); ! if (!StringEqual(dname,name)) { n = symbol_lookup(dname, symtab, check); } *************** *** 978,982 **** hsym = current_symtab; } else { ! if (!checkAttribute(n,k_nodetype,k_symboltable)) { n = Getattr(n,k_symsymtab); } --- 998,1002 ---- hsym = current_symtab; } else { ! if (!HashCheckAttr(n,k_nodetype,k_symboltable)) { n = Getattr(n,k_symsymtab); } *************** *** 1017,1024 **** } /* Check if s is a 'using' node */ ! while (s && checkAttribute(s,k_nodetype,k_using)) { String *uname = Getattr(s,k_uname); Symtab *un = Getattr(s,k_symsymtab); ! Node *ss = (Strcmp(name,uname) || (un != n)) ? Swig_symbol_clookup(uname, un) : 0; /* avoid infinity loop */ if (!ss) { --- 1037,1044 ---- } /* Check if s is a 'using' node */ ! while (s && HashCheckAttr(s,k_nodetype,k_using)) { String *uname = Getattr(s,k_uname); Symtab *un = Getattr(s,k_symsymtab); ! Node *ss = (!StringEqual(name,uname) || (un != n)) ? Swig_symbol_clookup(uname, un) : 0; /* avoid infinity loop */ if (!ss) { *************** *** 1048,1052 **** hsym = current_symtab; } else { ! if (!checkAttribute(n,k_nodetype,k_symboltable)) { n = Getattr(n,k_symsymtab); } --- 1068,1072 ---- hsym = current_symtab; } else { ! if (!HashCheckAttr(n,k_nodetype,k_symboltable)) { n = Getattr(n,k_symsymtab); } *************** *** 1087,1091 **** } /* Check if s is a 'using' node */ ! while (s && checkAttribute(s,k_nodetype,k_using)) { Node *ss; ss = Swig_symbol_clookup(Getattr(s,k_uname), Getattr(s,k_symsymtab)); --- 1107,1111 ---- } /* Check if s is a 'using' node */ ! while (s && HashCheckAttr(s,k_nodetype,k_using)) { Node *ss; ss = Swig_symbol_clookup(Getattr(s,k_uname), Getattr(s,k_symsymtab)); *************** *** 1111,1115 **** h = ccurrent; } else { ! if (!checkAttribute(n,k_nodetype,k_symboltable)) { n = Getattr(n,k_symsymtab); } --- 1131,1135 ---- h = ccurrent; } else { ! if (!HashCheckAttr(n,k_nodetype,k_symboltable)) { n = Getattr(n,k_symsymtab); } *************** *** 1135,1139 **** if (!s) return 0; /* Check if s is a 'using' node */ ! while (s && checkAttribute(s,k_nodetype,k_using)) { Node *ss = Swig_symbol_clookup_local(Getattr(s,k_uname), Getattr(s,k_symsymtab)); if (!ss) { --- 1155,1159 ---- if (!s) return 0; /* Check if s is a 'using' node */ ! while (s && HashCheckAttr(s,k_nodetype,k_using)) { Node *ss = Swig_symbol_clookup_local(Getattr(s,k_uname), Getattr(s,k_symsymtab)); if (!ss) { *************** *** 1158,1162 **** h = ccurrent; } else { ! if (!checkAttribute(n,k_nodetype,k_symboltable)) { n = Getattr(n,k_symsymtab); } --- 1178,1182 ---- h = ccurrent; } else { ! if (!HashCheckAttr(n,k_nodetype,k_symboltable)) { n = Getattr(n,k_symsymtab); } *************** *** 1182,1186 **** if (!s) return 0; /* Check if s is a 'using' node */ ! while (s && checkAttribute(s,k_nodetype,k_using)) { Node *ss = Swig_symbol_clookup_local_check(Getattr(s,k_uname), Getattr(s,k_symsymtab),checkfunc); if (!ss && !checkfunc) { --- 1202,1206 ---- if (!s) return 0; /* Check if s is a 'using' node */ ! while (s && HashCheckAttr(s,k_nodetype,k_using)) { Node *ss = Swig_symbol_clookup_local_check(Getattr(s,k_uname), Getattr(s,k_symsymtab),checkfunc); if (!ss && !checkfunc) { *************** *** 1294,1298 **** Swig_symbol_qualified(Node *n) { Hash *symtab; ! if (checkAttribute(n,k_nodetype,k_symboltable)) { symtab = n; } else { --- 1314,1318 ---- Swig_symbol_qualified(Node *n) { Hash *symtab; ! if (HashCheckAttr(n,k_nodetype,k_symboltable)) { symtab = n; } else { *************** *** 1327,1331 **** Printf(stderr,"node type %s\n", Getattr(n,k_name), type); #endif ! return !checkAttribute(n, k_nodetype, k_constructor); } --- 1347,1351 ---- Printf(stderr,"node type %s\n", Getattr(n,k_name), type); #endif ! return !HashCheckAttr(n, k_nodetype, k_constructor); } *************** *** 1343,1347 **** targs = SwigType_parmlist(e); tempn = Swig_symbol_clookup_local(tprefix,st); ! tscope = tempn ? Getattr(tempn,"sym:symtab") : 0; Printf(qprefix,"<("); for (ti = First(targs); ti.item;) { --- 1363,1367 ---- targs = SwigType_parmlist(e); tempn = Swig_symbol_clookup_local(tprefix,st); ! tscope = tempn ? Getattr(tempn,k_symsymtab) : 0; Printf(qprefix,"<("); for (ti = First(targs); ti.item;) { *************** *** 1524,1528 **** } nt = Getattr(n,k_nodetype); ! if (Strcmp(nt,k_using) == 0) { String *uname = Getattr(n,k_uname); if (uname) { --- 1544,1548 ---- } nt = Getattr(n,k_nodetype); ! if (StringEqual(nt,k_using)) { String *uname = Getattr(n,k_uname); if (uname) { *************** *** 1538,1544 **** } } ! if (Strcmp(nt,k_cdecl) == 0) { String *storage = Getattr(n,k_storage); ! if (storage && (Strcmp(storage,k_typedef) == 0)) { SwigType *decl; SwigType *rt; --- 1558,1564 ---- } } ! if (StringEqual(nt,k_cdecl)) { String *storage = Getattr(n,k_storage); ! if (storage && (StringEqual(storage,k_typedef))) { SwigType *decl; SwigType *rt; *************** *** 1747,1757 **** #ifdef SWIG_DEBUG ! Printf(stderr,"deftype type %s %s %s\n", tprefix, targs, ! tsuffix); #endif Append(tprefix,"<("); Swig_symbol_template_defargs(tparms, tnargs,tscope,tsdecl); p = tparms; ! tscope = Getattr(tempn,"sym:symtab"); while (p) { SwigType *ptype = Getattr(p,k_type); --- 1767,1776 ---- #ifdef SWIG_DEBUG ! Printf(stderr,"deftype type %s %s %s\n", tprefix, targs,tsuffix); #endif Append(tprefix,"<("); Swig_symbol_template_defargs(tparms, tnargs,tscope,tsdecl); p = tparms; ! tscope = tsdecl; while (p) { SwigType *ptype = Getattr(p,k_type); *************** *** 1810,1814 **** if (n) { String *nt = Getattr(n,k_nodetype); ! if (Strcmp(nt,k_enumitem) == 0) { /* An enum item. Generate a fully qualified name */ String *qn = Swig_symbol_qualified(n); --- 1829,1833 ---- if (n) { String *nt = Getattr(n,k_nodetype); ! if (StringEqual(nt,k_enumitem)) { /* An enum item. Generate a fully qualified name */ String *qn = Swig_symbol_qualified(n); *************** *** 1823,1827 **** break; } ! } else if ((Strcmp(nt,k_cdecl) == 0)) { String *nv = Getattr(n,k_value); if (nv) { --- 1842,1846 ---- break; } ! } else if ((StringEqual(nt,k_cdecl))) { String *nv = Getattr(n,k_value); if (nv) { Index: swig.h =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/swig.h,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** swig.h 24 Nov 2005 00:53:31 -0000 1.106 --- swig.h 27 Nov 2005 09:58:26 -0000 1.107 *************** *** 538,541 **** --- 538,546 ---- extern int Swig_director_mode(); + + /* -- template init -- */ + extern void SwigType_template_init(); + + #ifdef __cplusplus } |