diff --git a/CHANGES.current b/CHANGES.current index 39157d37f..1f0dd3807 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2022-07-20: wsfulton + [C#, Java] Ensure the order of interfaces generated in proxy interfaces for the + %interface family of macros is the same as that parsed from the bases in C++. + 2022-07-20: jicks, Ingener74, olly #422 [Python] Fix mishandling of a Python class inheriting from multiple SWIG-wrapped director classes. diff --git a/Examples/test-suite/java/multiple_inheritance_interfaces_runme.java b/Examples/test-suite/java/multiple_inheritance_interfaces_runme.java index 35a872c1c..df3e217fd 100644 --- a/Examples/test-suite/java/multiple_inheritance_interfaces_runme.java +++ b/Examples/test-suite/java/multiple_inheritance_interfaces_runme.java @@ -46,17 +46,17 @@ public class multiple_inheritance_interfaces_runme { checkBaseAndInterfaces(IC.class, true, "", new String[] {"IA", "IB"}); checkBaseAndInterfaces(A.class, false, "", new String[] {"IA"}); checkBaseAndInterfaces(B.class, false, "", new String[] {"IB"}); - checkBaseAndInterfaces(C.class, false, "", new String[] {"IA", "IB", "IC"}); - checkBaseAndInterfaces(D.class, false, "", new String[] {"IA", "IB", "IC"}); + checkBaseAndInterfaces(C.class, false, "", new String[] {"IC", "IA", "IB"}); + checkBaseAndInterfaces(D.class, false, "", new String[] {"IC", "IA", "IB"}); checkBaseAndInterfaces(E.class, false, "D", new String[] {}); checkBaseAndInterfaces(IJ.class, true, "", new String[] {}); checkBaseAndInterfaces(IK.class, true, "", new String[] {"IJ"}); checkBaseAndInterfaces(IL.class, true, "", new String[] {"IK"}); checkBaseAndInterfaces(J.class, false, "", new String[] {"IJ"}); - checkBaseAndInterfaces(K.class, false, "", new String[] {"IJ", "IK"}); - checkBaseAndInterfaces(L.class, false, "", new String[] {"IJ", "IK", "IL"}); - checkBaseAndInterfaces(M.class, false, "", new String[] {"IJ", "IK", "IL"}); + checkBaseAndInterfaces(K.class, false, "", new String[] {"IK", "IJ"}); + checkBaseAndInterfaces(L.class, false, "", new String[] {"IL", "IK", "IJ"}); + checkBaseAndInterfaces(M.class, false, "", new String[] {"IL", "IK", "IJ"}); checkBaseAndInterfaces(P.class, false, "", new String[] {}); checkBaseAndInterfaces(IQ.class, true, "", new String[] {}); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 294f7c20f..554c2ce56 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1699,10 +1699,9 @@ public: * addInterfaceNameAndUpcasts() * ----------------------------------------------------------------------------- */ - void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, Hash *base_list, SwigType *c_classname) { - List *keys = Keys(base_list); - for (Iterator it = First(keys); it.item; it = Next(it)) { - Node *base = Getattr(base_list, it.item); + void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, List *base_list, SwigType *c_classname) { + for (Iterator it = First(base_list); it.item; it = Next(it)) { + Node *base = it.item; SwigType *c_baseclassname = Getattr(base, "name"); String *interface_name = Getattr(base, "interface:name"); if (Len(interface_list)) @@ -1729,7 +1728,6 @@ public: Delete(cptr_method_name); Delete(interface_code); } - Delete(keys); } /* ----------------------------------------------------------------------------- @@ -1825,7 +1823,7 @@ public: } } } - Hash *interface_bases = Getattr(n, "interface:bases"); + List *interface_bases = Getattr(n, "interface:bases"); if (interface_bases) addInterfaceNameAndUpcasts(smart, interface_list, interface_upcasts, interface_bases, c_classname); diff --git a/Source/Modules/interface.cxx b/Source/Modules/interface.cxx index c0c059019..f6a57eefb 100644 --- a/Source/Modules/interface.cxx +++ b/Source/Modules/interface.cxx @@ -29,10 +29,9 @@ static bool interface_feature_enabled = false; static List *collect_interface_methods(Node *n) { List *methods = NewList(); - if (Hash *bases = Getattr(n, "interface:bases")) { - List *keys = Keys(bases); - for (Iterator base = First(keys); base.item; base = Next(base)) { - Node *cls = Getattr(bases, base.item); + if (List *bases = Getattr(n, "interface:bases")) { + for (Iterator base = First(bases); base.item; base = Next(base)) { + Node *cls = base.item; if (cls == n) continue; for (Node *child = firstChild(cls); child; child = nextSibling(child)) { @@ -55,7 +54,6 @@ static List *collect_interface_methods(Node *n) { } } } - Delete(keys); } return methods; } @@ -64,11 +62,11 @@ static List *collect_interface_methods(Node *n) { * collect_interface_bases * ----------------------------------------------------------------------------- */ -static void collect_interface_bases(Hash *bases, Node *n) { +static void collect_interface_bases(List *bases, Node *n) { if (GetFlag(n, "feature:interface")) { String *name = Getattr(n, "interface:name"); if (!Getattr(bases, name)) - Setattr(bases, name, n); + Append(bases, n); } if (List *baselist = Getattr(n, "bases")) { @@ -106,7 +104,7 @@ static void collect_interface_base_classes(Node *n) { } } - Hash *interface_bases = NewHash(); + List *interface_bases = NewList(); collect_interface_bases(interface_bases, n); if (Len(interface_bases) == 0) Delete(interface_bases); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index ea7e4607a..3396a1a6e 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1840,10 +1840,9 @@ public: * addInterfaceNameAndUpcasts() * ----------------------------------------------------------------------------- */ - void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, Hash *base_list, SwigType *c_classname) { - List *keys = Keys(base_list); - for (Iterator it = First(keys); it.item; it = Next(it)) { - Node *base = Getattr(base_list, it.item); + void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, List *base_list, SwigType *c_classname) { + for (Iterator it = First(base_list); it.item; it = Next(it)) { + Node *base = it.item; SwigType *c_baseclassname = Getattr(base, "name"); String *interface_name = Getattr(base, "interface:name"); if (Len(interface_list)) @@ -1870,7 +1869,6 @@ public: Delete(cptr_method_name); Delete(interface_code); } - Delete(keys); } /* ----------------------------------------------------------------------------- @@ -1976,7 +1974,7 @@ public: } } - Hash *interface_bases = Getattr(n, "interface:bases"); + List *interface_bases = Getattr(n, "interface:bases"); if (interface_bases) addInterfaceNameAndUpcasts(smart, interface_list, interface_upcasts, interface_bases, c_classname);