Merge branch 'master' into gsoc2009-matevz
parser.y still to be fixed up Conflicts: Doc/Devel/engineering.html Examples/Makefile.in Lib/allegrocl/allegrocl.swg Lib/csharp/csharp.swg Lib/csharp/enums.swg Lib/csharp/enumsimple.swg Lib/csharp/enumtypesafe.swg Lib/java/java.swg Lib/python/pydocs.swg Lib/r/rtype.swg Source/Include/swigwarn.h Source/Modules/octave.cxx Source/Modules/python.cxx Source/Modules/ruby.cxx Source/Swig/scanner.c Source/Swig/stype.c Source/Swig/swig.h configure.ac
This commit is contained in:
commit
e805d5f925
1074 changed files with 54339 additions and 20134 deletions
|
|
@ -16,8 +16,6 @@
|
|||
* and other information needed for compilation.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_typepass_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
|
||||
|
|
@ -40,7 +38,14 @@ class TypePass:private Dispatcher {
|
|||
Hash *classhash;
|
||||
List *normalize;
|
||||
|
||||
TypePass() {
|
||||
TypePass() :
|
||||
inclass(0),
|
||||
module(0),
|
||||
importmode(0),
|
||||
nsname(0),
|
||||
nssymname(0),
|
||||
classhash(0),
|
||||
normalize(0) {
|
||||
}
|
||||
|
||||
/* Normalize a type. Replaces type with fully qualified version */
|
||||
|
|
@ -175,21 +180,26 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
}
|
||||
if (Strcmp(nodeType(bcls), "classforward") != 0) {
|
||||
Swig_error(Getfile(cls), Getline(cls), "'%s' does not have a valid base class.\n", Getattr(cls, "name"));
|
||||
Swig_error(Getfile(bcls), Getline(bcls), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
|
||||
Swig_error(Getfile(bname), Getline(bname), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
|
||||
Swig_error(Getfile(bcls), Getline(bcls), "See definition of '%s'.\n", SwigType_namestr(bname));
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(cls), Getline(cls), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bname), Getline(bname), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bcls), Getline(bcls), "Only forward declaration '%s' was found.\n", SwigType_namestr(bname));
|
||||
clsforward = 1;
|
||||
}
|
||||
bcls = 0;
|
||||
} else {
|
||||
if (Getattr(bcls, "typepass:visit")) {
|
||||
if (!ilist)
|
||||
ilist = alist = NewList();
|
||||
Append(ilist, bcls);
|
||||
if (!Getattr(bcls, "feature:onlychildren")) {
|
||||
if (!ilist)
|
||||
ilist = alist = NewList();
|
||||
Append(ilist, bcls);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname));
|
||||
}
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Base class '%s' undefined.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "'%s' must be defined before it is used as a base class.\n", SwigType_namestr(bname));
|
||||
}
|
||||
}
|
||||
|
|
@ -202,10 +212,9 @@ class TypePass:private Dispatcher {
|
|||
if (!bcls) {
|
||||
if (!clsforward) {
|
||||
if (ispublic && !Getmeta(bname, "already_warned")) {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
|
||||
if (Strchr(bname, '<')) {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Maybe you forgot to instantiate '%s' using %%template.\n",
|
||||
SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Maybe you forgot to instantiate '%s' using %%template.\n", SwigType_namestr(bname));
|
||||
}
|
||||
Setmeta(bname, "already_warned", "1");
|
||||
}
|
||||
|
|
@ -255,12 +264,17 @@ class TypePass:private Dispatcher {
|
|||
Delete(smartnamestr);
|
||||
/* setup inheritance relationship between smart pointer templates */
|
||||
SwigType_inherit(smart, bsmart, 0, convcode);
|
||||
if (!GetFlag(bclass, "feature:smartptr"))
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name")));
|
||||
Delete(convcode);
|
||||
Delete(bsmart);
|
||||
Delete(smart);
|
||||
} else {
|
||||
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, clsname);
|
||||
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname));
|
||||
}
|
||||
} else {
|
||||
if (GetFlag(bclass, "feature:smartptr"))
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name")));
|
||||
}
|
||||
if (!importmode) {
|
||||
String *btype = Copy(bname);
|
||||
|
|
@ -275,7 +289,7 @@ class TypePass:private Dispatcher {
|
|||
Symtab *st = Getattr(cls, "symtab");
|
||||
Symtab *bst = Getattr(bclass, "symtab");
|
||||
if (st == bst) {
|
||||
Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", Getattr(cls, "name"));
|
||||
Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", SwigType_namestr(Getattr(cls, "name")));
|
||||
continue;
|
||||
}
|
||||
Symtab *s = Swig_symbol_current();
|
||||
|
|
@ -395,20 +409,27 @@ class TypePass:private Dispatcher {
|
|||
String *nname = 0;
|
||||
String *fname = 0;
|
||||
String *scopename = 0;
|
||||
String *template_default_expanded = 0;
|
||||
|
||||
normalize = NewList();
|
||||
|
||||
if (name) {
|
||||
if (SwigType_istemplate(name)) {
|
||||
// We need to fully resolve the name to make templates work correctly */
|
||||
// We need to fully resolve the name and expand default template parameters to make templates work correctly */
|
||||
Node *cn;
|
||||
fname = SwigType_typedef_resolve_all(name);
|
||||
if (Strcmp(fname, name) != 0 && (cn = Swig_symbol_clookup_local(fname, 0))) {
|
||||
SwigType *resolved_name = SwigType_typedef_resolve_all(name);
|
||||
SwigType *deftype_name = Swig_symbol_template_deftype(resolved_name, 0);
|
||||
fname = Copy(resolved_name);
|
||||
if (!Equal(resolved_name, deftype_name))
|
||||
template_default_expanded = Copy(deftype_name);
|
||||
if (!Equal(fname, name) && (cn = Swig_symbol_clookup_local(fname, 0))) {
|
||||
if ((n == cn)
|
||||
|| (Strcmp(nodeType(cn), "template") == 0)
|
||||
|| (Getattr(cn, "feature:onlychildren") != 0)
|
||||
|| (Getattr(n, "feature:onlychildren") != 0)) {
|
||||
Swig_symbol_cadd(fname, n);
|
||||
if (template_default_expanded)
|
||||
Swig_symbol_cadd(template_default_expanded, n);
|
||||
SwigType_typedef_class(fname);
|
||||
scopename = Copy(fname);
|
||||
} else {
|
||||
|
|
@ -421,6 +442,8 @@ class TypePass:private Dispatcher {
|
|||
SwigType_typedef_class(fname);
|
||||
scopename = Copy(fname);
|
||||
}
|
||||
Delete(deftype_name);
|
||||
Delete(resolved_name);
|
||||
} else {
|
||||
if ((CPlusPlus) || (unnamed)) {
|
||||
SwigType_typedef_class(name);
|
||||
|
|
@ -440,7 +463,7 @@ class TypePass:private Dispatcher {
|
|||
SwigType_typedef(unnamed, tdname);
|
||||
}
|
||||
|
||||
if (nsname) {
|
||||
if (nsname && name) {
|
||||
nname = NewStringf("%s::%s", nsname, name);
|
||||
String *tdname = Getattr(n, "tdname");
|
||||
if (tdname) {
|
||||
|
|
@ -470,6 +493,13 @@ class TypePass:private Dispatcher {
|
|||
Delete(ts);
|
||||
Setattr(n, "module", module);
|
||||
|
||||
// When a fully qualified templated type with default parameters is used in the parsed code,
|
||||
// the following additional symbols and scopes are needed for successful lookups
|
||||
if (template_default_expanded) {
|
||||
Swig_symbol_alias(template_default_expanded, Getattr(n, "symtab"));
|
||||
SwigType_scope_alias(template_default_expanded, Getattr(n, "typescope"));
|
||||
}
|
||||
|
||||
/* Normalize deferred types */
|
||||
{
|
||||
normal_node *nn = new normal_node();
|
||||
|
|
@ -489,6 +519,7 @@ class TypePass:private Dispatcher {
|
|||
Setattr(n, "name", nname);
|
||||
Delete(nname);
|
||||
}
|
||||
Delete(fname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -518,18 +549,10 @@ class TypePass:private Dispatcher {
|
|||
|
||||
virtual int classforwardDeclaration(Node *n) {
|
||||
|
||||
/* Temporary hack. Can't do inside a class because it breaks
|
||||
C nested structure wrapping */
|
||||
|
||||
/* Can't do inside a C struct because it breaks C nested structure wrapping */
|
||||
if ((!inclass) || (CPlusPlus)) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *nname;
|
||||
SwigType_typedef_class(name);
|
||||
if (nsname) {
|
||||
nname = NewStringf("%s::%s", nsname, name);
|
||||
Setattr(n, "name", nname);
|
||||
}
|
||||
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -547,12 +570,9 @@ class TypePass:private Dispatcher {
|
|||
if (alias) {
|
||||
Typetab *ts = Getattr(n, "typescope");
|
||||
if (!ts) {
|
||||
Node *ns;
|
||||
/* Create a empty scope for the alias */
|
||||
ns = Getattr(n, "namespace");
|
||||
if (ns) {
|
||||
SwigType_scope_alias(name, Getattr(ns, "typescope"));
|
||||
}
|
||||
/* Create an empty scope for the alias */
|
||||
Node *ns = Getattr(n, "namespace");
|
||||
SwigType_scope_alias(name, Getattr(ns, "typescope"));
|
||||
ts = Getattr(ns, "typescope");
|
||||
Setattr(n, "typescope", ts);
|
||||
}
|
||||
|
|
@ -684,11 +704,6 @@ class TypePass:private Dispatcher {
|
|||
normalize_parms(Getattr(n, "parms"));
|
||||
normalize_parms(Getattr(n, "throws"));
|
||||
|
||||
/* If in a namespace, patch the class name */
|
||||
if (nsname) {
|
||||
String *nname = NewStringf("%s::%s", nsname, Getattr(n, "name"));
|
||||
Setattr(n, "name", nname);
|
||||
}
|
||||
clean_overloaded(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -697,12 +712,7 @@ class TypePass:private Dispatcher {
|
|||
* destructorDeclaration()
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual int destructorDeclaration(Node *n) {
|
||||
/* If in a namespace, patch the class name */
|
||||
if (nsname) {
|
||||
String *nname = NewStringf("%s::%s", nsname, Getattr(n, "name"));
|
||||
Setattr(n, "name", nname);
|
||||
}
|
||||
virtual int destructorDeclaration(Node *) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -874,7 +884,22 @@ class TypePass:private Dispatcher {
|
|||
|
||||
// Use enumDeclaration() to do all the hard work.
|
||||
// Note that no children can be emitted in a forward declaration as there aren't any.
|
||||
return enumDeclaration(n);
|
||||
int result = enumDeclaration(n);
|
||||
if (result == SWIG_OK) {
|
||||
// Detect when the real enum matching the forward enum declaration has not been parsed/declared
|
||||
SwigType *ty = SwigType_typedef_resolve_all(Getattr(n, "type"));
|
||||
Replaceall(ty, "enum ", "");
|
||||
Node *nn = Swig_symbol_clookup(ty, 0);
|
||||
|
||||
String *nodetype = nn ? nodeType(nn) : 0;
|
||||
if (nodetype) {
|
||||
if (Equal(nodetype, "enumforward")) {
|
||||
SetFlag(nn, "enumMissing");
|
||||
} // if a real enum was declared this would be an "enum" node type
|
||||
}
|
||||
Delete(ty);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
|
|
@ -996,6 +1021,7 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
Node *nn = copyNode(c);
|
||||
Delattr(nn, "access"); // access might be different from the method in the base class
|
||||
Setattr(nn, "access", Getattr(n, "access"));
|
||||
if (!Getattr(nn, "sym:name"))
|
||||
Setattr(nn, "sym:name", symname);
|
||||
|
||||
|
|
@ -1058,11 +1084,11 @@ class TypePass:private Dispatcher {
|
|||
* which is hacked. */
|
||||
if (Getattr(n, "sym:overloaded"))
|
||||
{
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
show_overloaded(n);
|
||||
#endif
|
||||
int cnt = 0;
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
Node *debugnode = n;
|
||||
show_overloaded(n);
|
||||
#endif
|
||||
if (!firstChild(n)) {
|
||||
// Remove from overloaded list ('using' node does not actually end up adding in any methods)
|
||||
Node *ps = Getattr(n, "sym:previousSibling");
|
||||
|
|
@ -1109,14 +1135,16 @@ show_overloaded(n);
|
|||
Setattr(ns, "sym:previousSibling", pp);
|
||||
Setattr(pp, "sym:nextSibling", ns);
|
||||
}
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
debugnode = firstoverloaded;
|
||||
#endif
|
||||
}
|
||||
Delattr(n, "sym:previousSibling");
|
||||
Delattr(n, "sym:nextSibling");
|
||||
Delattr(n, "sym:overloaded");
|
||||
Delattr(n, "sym:overname");
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
show_overloaded(debugnode);
|
||||
show_overloaded(debugnode);
|
||||
#endif
|
||||
clean_overloaded(n); // Needed?
|
||||
}
|
||||
|
|
@ -1129,6 +1157,11 @@ show_overloaded(debugnode);
|
|||
SwigType_typedef_using(uname);
|
||||
} else if (Strcmp(ntype, "enum") == 0) {
|
||||
SwigType_typedef_using(Getattr(n, "uname"));
|
||||
} else if (Strcmp(ntype, "template") == 0) {
|
||||
/*
|
||||
Printf(stdout, "usingDeclaration template %s --- %s\n", Getattr(n, "name"), Getattr(n, "uname"));
|
||||
SwigType_typedef_using(Getattr(n, "uname"));
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue