128
128
Swig_symbol_setscope(currentsym);
131
131
/* generate C++ inheritance type-relationships */
132
void cplus_inherit_types(Node *first, Node *cls, String *clsname, String *cast = 0) {
132
void cplus_inherit_types_impl(Node *first, Node *cls, String*clsname,
133
const char *bases, const char *baselist,
134
int ispublic, String *cast = 0) {
134
136
if (first == cls) return; /* The Marcelo check */
135
137
if (!cls) cls = first;
137
List *ilist = Getattr(cls,"bases");
139
List *ilist = Getattr(cls,bases);
139
List *nlist = Getattr(cls,"baselist");
141
List *nlist = Getattr(cls,baselist);
141
143
int len = Len(nlist);
178
180
if (Strcmp(nodeType(bcls),"classforward") != 0) {
179
Swig_error(Getfile(bname),Getline(bname),"'%s' is not a class. \n",bname);
181
Swig_error(Getfile(cls),Getline(cls),"'%s' does not have a valid base class.\n", Getattr(cls,"name"));
182
Swig_error(Getfile(bcls),Getline(bcls),"'%s' is not a valid base class.\n", bname);
181
Swig_warning(WARN_TYPE_INCOMPLETE,Getfile(bname),Getline(bname),"Base class '%s' is incomplete.\n", bname);
184
Swig_warning(WARN_TYPE_INCOMPLETE,Getfile(cls),Getline(cls),"Base class '%s' is incomplete.\n", bname);
185
Swig_warning(WARN_TYPE_INCOMPLETE,Getfile(bcls),Getline(bcls),"Only forward declaration '%s' was found.\n", bname);
197
202
if (tname) Delete(tname);
199
204
if (!clsforward) {
200
if (!Getmeta(bname,"already_warned")) {
201
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname),Getline(bname),"Nothing known about class '%s'. Ignored.\n", SwigType_namestr(bname));
205
if (ispublic && !Getmeta(bname,"already_warned")) {
206
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls),Getline(cls),"Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
202
207
if (Strchr(bname,'<')) {
203
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Maybe you forgot to instantiate '%s' using %%template.\n", SwigType_namestr(bname));
208
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Maybe you forgot to instantiate '%s' using %%template.\n", SwigType_namestr(bname));
205
210
Setmeta(bname,"already_warned","1");
241
246
/* Recursively hit base classes */
242
247
String *newcast = NewStringf("(%s *)%s", SwigType_namestr(Getattr(bclass,"name")), cast);
243
cplus_inherit_types(first,bclass,clsname, newcast);
248
cplus_inherit_types_impl(first,bclass,clsname,bases,baselist,ispublic,newcast);
248
/* Clean overloaded list. Removes templates, friends, ignored, and errors */
250
void clean_overloaded(Node *n) {
251
Node *nn = Getattr(n,"sym:overloaded");
255
if ((Strcmp(nodeType(nn),"template") == 0) ||
256
(Getattr(nn,"feature:ignore")) ||
257
(Getattr(nn,"error")) ||
258
// (checkAttribute(nn,"storage","friend")) ||
259
((Strcmp(nodeType(nn),"using") == 0) && !firstChild(nn))) {
260
/* Remove from overloaded list */
261
Node *ps = Getattr(nn,"sym:previousSibling");
262
Node *ns = Getattr(nn,"sym:nextSibling");
264
Setattr(ps,"sym:nextSibling",ns);
267
Setattr(ns,"sym:previousSibling",ps);
269
Delattr(nn,"sym:previousSibling");
270
Delattr(nn,"sym:nextSibling");
271
Delattr(nn,"sym:overloaded");
274
} else if ((Strcmp(nodeType(nn),"using") == 0)) {
275
/* A possibly dangerous parse tree hack. We're going to
276
cut the parse tree node out and stick in the resolved
277
using declarations */
279
Node *ps = Getattr(nn,"sym:previousSibling");
280
Node *ns = Getattr(nn,"sym:nextSibling");
281
Node *un = firstChild(nn);
288
Node *ppn = Getattr(pn,"sym:nextSibling");
289
Setattr(pn,"sym:overloaded",first);
290
Setattr(pn,"sym:overname", NewStringf("%s_%d", Getattr(nn,"sym:overname"), cnt++));
295
Setattr(ps,"sym:nextSibling",un);
296
Setattr(un,"sym:previousSibling",ps);
299
Setattr(ns,"sym:previousSibling", pn);
300
Setattr(pn,"sym:nextSibling",ns);
304
Setattr(nn,"sym:overloaded",first);
307
if (!first) first = nn;
308
Setattr(nn,"sym:overloaded",first);
253
void append_list(List *lb, List *la) {
255
for (Iterator bi = First(la); bi.item; bi = Next(bi)) {
310
nn = Getattr(nn,"sym:nextSibling");
312
if (!first || (first && !Getattr(first,"sym:nextSibling"))) {
313
Delattr(n,"sym:overloaded");
261
void cplus_inherit_types(Node *first, Node *cls, String *clsname, String *cast = 0) {
262
cplus_inherit_types_impl(first, cls, clsname, "bases", "baselist", 1, cast);
263
cplus_inherit_types_impl(first, cls, clsname, "protectedbases","protectedbaselist", 0, cast);
264
cplus_inherit_types_impl(first, cls, clsname, "privatebases" ,"privatebaselist", 0, cast);
266
if (!cls) cls = first;
268
List *allbases = NewList();
269
append_list(allbases,Getattr(cls,"bases"));
270
append_list(allbases,Getattr(cls,"protectedbases"));
271
append_list(allbases,Getattr(cls,"privatebases"));
273
Setattr(cls,"allbases",allbases);
739
701
String *name = Getattr(n,"name");
742
// Correct the name to contain the fully qualified scopename
743
706
// Add a typedef to the type table so that we can use 'enum Name' as well as just 'Name'
744
707
if (nsname || inclass) {
709
// But first correct the name and tdname to contain the fully qualified scopename
746
710
if (nsname && inclass) {
747
nname = NewStringf("%s::%s::%s", nsname, Getattr(inclass,"name"), name);
711
scope = NewStringf("%s::%s", nsname, Getattr(inclass,"name"));
748
712
} else if (nsname) {
749
nname = NewStringf("%s::%s", nsname, name);
713
scope = NewStringf("%s", nsname);
750
714
} else if (inclass) {
751
nname = NewStringf("%s::%s", Getattr(inclass,"name"), name);
715
scope = NewStringf("%s", Getattr(inclass,"name"));
718
String *nname = NewStringf("%s::%s", scope, name);
753
719
Setattr(n,"name",nname);
721
String *tdname = Getattr(n,"tdname");
723
tdname = NewStringf("%s::%s", scope, tdname);
724
Setattr(n,"tdname",tdname);
754
727
SwigType *t = NewStringf("enum %s", nname);
755
728
SwigType_typedef(t,name);
758
730
SwigType *t = NewStringf("enum %s", name);
759
731
SwigType_typedef(t,name);
736
String *tdname = Getattr(n,"tdname");
737
String *unnamed = Getattr(n,"unnamed");
738
String *storage = Getattr(n,"storage");
740
// Construct enumtype - for declaring an enum of this type with SwigType_ltype() etc
741
String *enumtype = 0;
742
if (unnamed && tdname && (Cmp(storage,"typedef") == 0)) {
743
enumtype = Copy(Getattr(n,"tdname"));
745
enumtype = NewStringf("%s%s", CPlusPlus ? "" : "enum ", Getattr(n,"name"));
748
enumtype = Copy(Getattr(n,"type"));
750
Setattr(n,"enumtype",enumtype);
763
752
emit_children(n);