Improve interface feature checks
Use common code for missing feature:interface:name attribute checks Check that all base classes are also marked as interfaces
This commit is contained in:
parent
67f38e8124
commit
c33b4dc34e
3 changed files with 18 additions and 8 deletions
|
|
@ -2071,10 +2071,6 @@ public:
|
|||
if (Getattr(n, "feature:interface")) {
|
||||
interface_class_code = NewStringEmpty();
|
||||
String *interface_name = Getattr(n, "feature:interface:name");
|
||||
if (!interface_name) {
|
||||
Swig_error(Getfile(n), Getline(n), "Interface %s has no name attribute", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
String *output_directory = outputDirectory(nspace);
|
||||
f_interface = getOutputFile(output_directory, interface_name);
|
||||
addOpenNamespace(nspace, f_interface);
|
||||
|
|
|
|||
|
|
@ -2148,10 +2148,6 @@ public:
|
|||
if (Getattr(n, "feature:interface")) {
|
||||
interface_class_code = NewStringEmpty();
|
||||
String *interface_name = Getattr(n, "feature:interface:name");
|
||||
if (!interface_name) {
|
||||
Swig_error(Getfile(n), Getline(n), "Interface %s has no name attribute", proxy_class_name);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
String *output_directory = outputDirectory(nspace);
|
||||
String *filen = NewStringf("%s%s.java", output_directory, interface_name);
|
||||
f_interface = NewFile(filen, "w", SWIG_output_files());
|
||||
|
|
|
|||
|
|
@ -3883,6 +3883,24 @@ static void collect_interface_bases(Hash *bases, Node *n) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void collect_interface_base_classes(Node *n) {
|
||||
if (Getattr(n, "feature:interface")) {
|
||||
if (!Getattr(n, "feature:interface:name")) {
|
||||
Swig_error(Getfile(n), Getline(n), "The interface feature for '%s' is missing the name attribute.\n", SwigType_namestr(Getattr(n, "name")));
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
// check all bases are also interfaces
|
||||
if (List *baselist = Getattr(n, "bases")) {
|
||||
for (Iterator base = First(baselist); base.item; base = Next(base)) {
|
||||
if (!GetFlag(base.item, "feature:ignore")) {
|
||||
if (!Getattr(base.item, "feature:interface")) {
|
||||
Swig_error(Getfile(n), Getline(n), "Base class '%s' of '%s' is not similarly marked as an interface.\n", SwigType_namestr(Getattr(base.item, "name")), SwigType_namestr(Getattr(n, "name")));
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Hash *interface_bases = NewHash();
|
||||
collect_interface_bases(interface_bases, n);
|
||||
if (Len(interface_bases) == 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue