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
This commit is contained in:
parent
709d683926
commit
d93dc0f8e2
10 changed files with 32 additions and 32 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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")) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 ");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue