From d93dc0f8e23eb9fb18841bf50b2b505e61ff5a94 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 24 Nov 2012 14:13:58 +0000 Subject: [PATCH] Distinguish between an "abstract" attribute on a class containing a list of abstract members and an "abstract" flag on pure virtual methods - renamed former to "abstracts" git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13935 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 10 +++++----- Source/Modules/allocate.cxx | 24 ++++++++++++------------ Source/Modules/csharp.cxx | 2 +- Source/Modules/d.cxx | 2 +- Source/Modules/java.cxx | 2 +- Source/Modules/lang.cxx | 12 ++++++------ Source/Modules/php.cxx | 6 +++--- Source/Modules/python.cxx | 2 +- Source/Modules/tcl8.cxx | 2 +- Source/Swig/cwrap.c | 2 +- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 2774014ab..cd3d73eca 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -740,7 +740,7 @@ static List *pure_abstract(Node *n) { abs = NewList(); } Append(abs,n); - Setattr(n,"abstract","1"); + SetFlag(n,"abstract"); } } } else if (Cmp(nodeType(n),"destructor") == 0) { @@ -749,7 +749,7 @@ static List *pure_abstract(Node *n) { abs = NewList(); } Append(abs,n); - Setattr(n,"abstract","1"); + SetFlag(n,"abstract"); } } n = nextSibling(n); @@ -3002,7 +3002,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va if (Strcmp(nodeType(templnode),"class") == 0) { /* Identify pure abstract methods */ - Setattr(templnode,"abstract", pure_abstract(firstChild(templnode))); + Setattr(templnode,"abstracts", pure_abstract(firstChild(templnode))); /* Set up inheritance in symbol table */ { @@ -3574,7 +3574,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { inclass = 0; /* Check for pure-abstract class */ - Setattr($$,"abstract", pure_abstract($7)); + Setattr($$,"abstracts", pure_abstract($7)); /* This bit of code merges in a previously defined %extend directive (if any) */ @@ -3737,7 +3737,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { unnamed = Getattr($$,"unnamed"); /* Check for pure-abstract class */ - Setattr($$,"abstract", pure_abstract($5)); + Setattr($$,"abstracts", pure_abstract($5)); n = new_node("cdecl"); Setattr(n,"name",$7.id); diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx index 8c8450312..91fad132f 100644 --- a/Source/Modules/allocate.cxx +++ b/Source/Modules/allocate.cxx @@ -43,7 +43,7 @@ extern "C" { SwigType *decl1 = SwigType_typedef_resolve_all(decl); SwigType *decl2 = SwigType_pop_function(decl1); if (Strcmp(decl2, search_decl) == 0) { - if (!Getattr(n, "abstract")) { + if (!GetFlag(n, "abstract")) { Delete(decl1); Delete(decl2); return 1; @@ -327,7 +327,7 @@ class Allocate:public Dispatcher { Swig_symbol_setscope(oldtab); return ret; } - List *abstract = Getattr(base, "abstract"); + List *abstract = Getattr(base, "abstracts"); if (abstract) { int dabstract = 0; int len = Len(abstract); @@ -348,15 +348,15 @@ class Allocate:public Dispatcher { Delete(base_decl); if (!dn) { - List *nabstract = Getattr(n, "abstract"); + List *nabstract = Getattr(n, "abstracts"); if (!nabstract) { nabstract = NewList(); - Setattr(n, "abstract", nabstract); + Setattr(n, "abstracts", nabstract); Delete(nabstract); } Append(nabstract, nn); - if (!Getattr(n, "abstract:firstnode")) { - Setattr(n, "abstract:firstnode", nn); + if (!Getattr(n, "abstracts:firstnode")) { + Setattr(n, "abstracts:firstnode", nn); } dabstract = base != n; } @@ -596,18 +596,18 @@ Allocate(): /* Check if the class is abstract via inheritance. This might occur if a class didn't have any pure virtual methods of its own, but it didn't implement all of the pure methods in a base class */ - if (!Getattr(n, "abstract") && is_abstract_inherit(n)) { + if (!Getattr(n, "abstracts") && is_abstract_inherit(n)) { if (((Getattr(n, "allocate:public_constructor") || (!GetFlag(n, "feature:nodefault") && !Getattr(n, "allocate:has_constructor"))))) { if (!GetFlag(n, "feature:notabstract")) { - Node *na = Getattr(n, "abstract:firstnode"); + Node *na = Getattr(n, "abstracts:firstnode"); if (na) { Swig_warning(WARN_TYPE_ABSTRACT, Getfile(n), Getline(n), "Class '%s' might be abstract, " "no constructors generated,\n", SwigType_namestr(Getattr(n, "name"))); Swig_warning(WARN_TYPE_ABSTRACT, Getfile(na), Getline(na), "Method %s might not be implemented.\n", Swig_name_decl(na)); - if (!Getattr(n, "abstract")) { + if (!Getattr(n, "abstracts")) { List *abstract = NewList(); Append(abstract, na); - Setattr(n, "abstract", abstract); + Setattr(n, "abstracts", abstract); Delete(abstract); } } @@ -618,7 +618,7 @@ Allocate(): if (!Getattr(n, "allocate:has_constructor")) { /* No constructor is defined. We need to check a few things */ /* If class is abstract. No default constructor. Sorry */ - if (Getattr(n, "abstract")) { + if (Getattr(n, "abstracts")) { Delattr(n, "allocate:default_constructor"); } if (!Getattr(n, "allocate:default_constructor")) { @@ -639,7 +639,7 @@ Allocate(): } } if (!Getattr(n, "allocate:has_copy_constructor")) { - if (Getattr(n, "abstract")) { + if (Getattr(n, "abstracts")) { Delattr(n, "allocate:copy_constructor"); } if (!Getattr(n, "allocate:copy_constructor")) { diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 619fb7ebd..c54475029 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3512,7 +3512,7 @@ public: Symtab *symtab = Getattr(n, "sym:symtab"); Node *typenode = Swig_symbol_clookup(resolved_typename, symtab); - if (SwigType_ispointer(returntype) || (typenode && Getattr(typenode, "abstract"))) { + if (SwigType_ispointer(returntype) || (typenode && Getattr(typenode, "abstracts"))) { /* initialize pointers to something sane. Same for abstract classes when a reference is returned. */ Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index a1a454bd0..1ea74eb6b 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -1984,7 +1984,7 @@ public: Symtab *symtab = Getattr(n, "sym:symtab"); Node *typenode = Swig_symbol_clookup(resolved_typename, symtab); - if (SwigType_ispointer(returntype) || (typenode && Getattr(typenode, "abstract"))) { + if (SwigType_ispointer(returntype) || (typenode && Getattr(typenode, "abstracts"))) { /* initialize pointers to something sane. Same for abstract classes when a reference is returned. */ Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index d59ca8bd6..cd8cfe543 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -3583,7 +3583,7 @@ public: Symtab *symtab = Getattr(n, "sym:symtab"); Node *typenode = Swig_symbol_clookup(resolved_typename, symtab); - if (SwigType_ispointer(returntype) || (typenode && Getattr(typenode, "abstract"))) { + if (SwigType_ispointer(returntype) || (typenode && Getattr(typenode, "abstracts"))) { /* initialize pointers to something sane. Same for abstract classes when a reference is returned. */ Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 002a1fdd7..043473bc6 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2649,18 +2649,18 @@ static String *get_director_ctor_code(Node *n, String *director_ctor_code, Strin int use_director = Swig_directorclass(n); if (use_director) { Node *pn = Swig_methodclass(n); - abstract = Getattr(pn, "abstract"); + abstract = Getattr(pn, "abstracts"); if (director_prot_ctor_code) { int is_notabstract = GetFlag(pn, "feature:notabstract"); int is_abstract = abstract && !is_notabstract; if (is_protected(n) || is_abstract) { director_ctor = director_prot_ctor_code; abstract = Copy(abstract); - Delattr(pn, "abstract"); + Delattr(pn, "abstracts"); } else { if (is_notabstract) { abstract = Copy(abstract); - Delattr(pn, "abstract"); + Delattr(pn, "abstracts"); } else { abstract = 0; } @@ -2696,7 +2696,7 @@ int Language::constructorHandler(Node *n) { Delete(mrename); Swig_restore(n); if (abstract) - Setattr(Swig_methodclass(n), "abstract", abstract); + Setattr(Swig_methodclass(n), "abstracts", abstract); return SWIG_OK; } @@ -2718,7 +2718,7 @@ int Language::copyconstructorHandler(Node *n) { Delete(mrename); Swig_restore(n); if (abstract) - Setattr(Swig_methodclass(n), "abstract", abstract); + Setattr(Swig_methodclass(n), "abstracts", abstract); return SWIG_OK; } @@ -3436,7 +3436,7 @@ int Language::abstractClassTest(Node *n) { if (Getattr(n, "allocate:nonew")) return 1; /* now check for the rest */ - List *abstract = Getattr(n, "abstract"); + List *abstract = Getattr(n, "abstracts"); if (!abstract) return 0; int labs = Len(abstract); diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 986911a12..149b3cd83 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1698,9 +1698,9 @@ public: Printf(output, "\t\t$r=%s;\n", invoke); if (Len(ret_types) == 1) { /* If d is abstract we can't create a new wrapper type d. */ - Node * d_class = classLookup(d); + Node *d_class = classLookup(d); int is_abstract = 0; - if (Getattr(d_class, "abstract")) { + if (Getattr(d_class, "abstracts")) { is_abstract = 1; } if (newobject || !is_abstract) { @@ -2020,7 +2020,7 @@ done: base.item = NULL; } - if (Getattr(n, "abstract") && !GetFlag(n, "feature:notabstract")) { + if (Getattr(n, "abstracts") && !GetFlag(n, "feature:notabstract")) { Printf(s_phpclasses, "abstract "); } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 5dc2cb8be..43d306b09 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3794,7 +3794,7 @@ public: if (!have_constructor) { if (!builtin) Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"", "No constructor defined", - (Getattr(n, "abstract") ? " - class is abstract" : ""), "\")\n", NIL); + (Getattr(n, "abstracts") ? " - class is abstract" : ""), "\")\n", NIL); } else if (fastinit && !builtin) { Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index a4f29183c..91e74f4ca 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -942,7 +942,7 @@ public: Printv(f_shadow, " constructor { } {\n", NIL); Printv(f_shadow, " # This constructor will fail if called directly\n", NIL); Printv(f_shadow, " if { [info class] == \"::", class_name, "\" } {\n", NIL); - Printv(f_shadow, " error \"No constructor for class ", class_name, (Getattr(n, "abstract") ? " - class is abstract" : ""), "\"\n", NIL); + Printv(f_shadow, " error \"No constructor for class ", class_name, (Getattr(n, "abstracts") ? " - class is abstract" : ""), "\"\n", NIL); Printv(f_shadow, " }\n", NIL); Printv(f_shadow, " }\n", NIL); } diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index a032de746..063ab9858 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -1165,7 +1165,7 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String /* if a C++ director class exists, create it rather than the original class */ if (use_director) { Node *parent = Swig_methodclass(n); - int abstract = Getattr(parent, "abstract") != 0; + int abstract = Getattr(parent, "abstracts") != 0; String *name = Getattr(parent, "sym:name"); String *directorname = NewStringf("SwigDirector_%s", name); String *action = NewStringEmpty();