mirror of https://github.com/swig/swig
%interface regression fix for multiple inheritance and common bases
Regressio introduced in 7592722
.
Closes #2875
This commit is contained in:
parent
5c01f7c536
commit
61dffc06d1
|
@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.3.0 (in progress)
|
||||
===========================
|
||||
|
||||
2024-09-07: wsfulton
|
||||
#2875 Fix swig-4.1.0 regression using the %interface family of macros
|
||||
for multiple inheritance and common bases.
|
||||
|
||||
2024-09-06: olly
|
||||
[Python] Stop documenting to define SWIG_FILE_WITH_INIT - this does
|
||||
not actually do anything (and apparently never has!)
|
||||
|
|
|
@ -68,6 +68,13 @@ public class multiple_inheritance_interfaces_runme {
|
|||
checkBaseAndInterfaces(V.class, false, "S", new String[] {});
|
||||
checkBaseAndInterfaces(W.class, false, "T", new String[] {});
|
||||
|
||||
checkBaseAndInterfaces(IV1SwigInterface.class, true, "", new String[] {"IA"});
|
||||
checkBaseAndInterfaces(IV2SwigInterface.class, true, "", new String[] {"IA"});
|
||||
checkBaseAndInterfaces(IV1.class, false, "", new String[] {"IV1SwigInterface", "IA"});
|
||||
checkBaseAndInterfaces(IV2.class, false, "", new String[] {"IV2SwigInterface", "IA"});
|
||||
checkBaseAndInterfaces(V3.class, false, "", new String[] {"V3SwigInterface", "IV1SwigInterface", "IA", "IV2SwigInterface"});
|
||||
checkBaseAndInterfaces(V3SwigInterface.class, true, "", new String[] {"IV1SwigInterface", "IV2SwigInterface"});
|
||||
|
||||
// overloaded methods check
|
||||
D d = new D();
|
||||
d.ia();
|
||||
|
|
|
@ -49,6 +49,17 @@ struct V : S {};
|
|||
struct W : T {};
|
||||
%}
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
%interface(IV1)
|
||||
%interface(IV2)
|
||||
%interface(V3)
|
||||
#endif
|
||||
%inline %{
|
||||
struct IV1 : virtual IA {};
|
||||
struct IV2 : virtual IA {};
|
||||
struct V3 : IV1, IV2 {};
|
||||
%}
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
%interface_impl(Undesirables);
|
||||
#endif
|
||||
|
|
|
@ -207,7 +207,8 @@ int DohCmp(const DOH *obj1, const DOH *obj2) {
|
|||
b2info = b2->type;
|
||||
if ((b1info == b2info) && (b1info->doh_cmp))
|
||||
return (b1info->doh_cmp) (b1, b2);
|
||||
return 1;
|
||||
/* finally compare pointers */
|
||||
return b1 < b2 ? -1 : b1 == b2 ? 0 : 1;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
@ -64,8 +64,7 @@ static List *collect_interface_methods(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))
|
||||
if (!Swig_item_in_list(bases, n))
|
||||
Append(bases, n);
|
||||
}
|
||||
|
||||
|
@ -82,10 +81,11 @@ static void collect_interface_bases(List *bases, Node *n) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* collect_interface_base_classes()
|
||||
*
|
||||
* Create a hash containing all the classes up the inheritance hierarchy
|
||||
* Create a list containing all the classes up the inheritance hierarchy
|
||||
* marked with feature:interface (including this class n).
|
||||
* Stops going up the inheritance chain as soon as a class is found without
|
||||
* feature:interface.
|
||||
* Remove duplicate bases (in the event of multiple inheritance).
|
||||
* The idea is to find all the base interfaces that a class must implement.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
|
|
@ -1436,21 +1436,23 @@ int Swig_is_generated_overload(Node *n) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_item_in_list()
|
||||
*
|
||||
* If the input name is the name of an item in the list, return the item
|
||||
* If the input item is in the list, return the item.
|
||||
* Note: uses DohCmp for comparisons so for a List of String *, Strcmp is ultimately
|
||||
* used for item comparisons to determine if a string is in the list.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Node *Swig_item_in_list(List *list, const_String_or_char_ptr name) {
|
||||
Node *item = 0;
|
||||
Node *Swig_item_in_list(List *list, const DOH *item) {
|
||||
Node *found_item = 0;
|
||||
if (list) {
|
||||
Iterator it;
|
||||
for (it = First(list); it.item; it = Next(it)) {
|
||||
if (Strcmp(name, it.item) == 0) {
|
||||
item = it.item;
|
||||
if (DohCmp(item, it.item) == 0) {
|
||||
found_item = it.item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return item;
|
||||
return found_item;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
@ -343,7 +343,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
|
||||
extern int Swig_value_wrapper_mode(int mode);
|
||||
extern int Swig_is_generated_overload(Node *n);
|
||||
extern Node *Swig_item_in_list(List *list, const String *name);
|
||||
extern Node *Swig_item_in_list(List *list, const DOH *item);
|
||||
|
||||
typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat;
|
||||
|
||||
|
|
Loading…
Reference in New Issue