mirror of https://github.com/swig/swig
%interface family of macros no longer add variable wrappers
The getter/setter methods used for wrapping methods are no longer added to the interface class. Closes #1524 Also add in testcase for enums.
This commit is contained in:
parent
63bbf642f4
commit
598736a6b2
|
@ -7,6 +7,15 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.1.0 (in progress)
|
||||
===========================
|
||||
|
||||
2022-03-12: wsfulton
|
||||
#1524 %interface family of macros no longer contain the getter/setter
|
||||
methods for wrapping variables. The interface only contains
|
||||
virtual and non-virtual instance methods, that is, no static methods.
|
||||
Enums are also no longer added to the interface (affects Java only where
|
||||
they were missing from the proxy class, C# never had them in the interface).
|
||||
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2022-03-12: wsfulton
|
||||
#1277 Fixes for the family of %interface macros, %interface,
|
||||
%interface_impl and %interface_custom fixes for overloaded methods
|
||||
|
|
|
@ -3546,6 +3546,12 @@ will be excluded from the interface and there will not be an additional method
|
|||
added to the proxy class implementing that interface.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The Java interface only ever contains virtual and non-virtual instance methods from the wrapped C++ class.
|
||||
Any static methods, enums or variables in the wrapped C++ class are not supported and are not added to the interface.
|
||||
They are of course still available in the Java proxy class.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Wherever a class marked as an interface is used, such as the <tt>UseBases</tt> method in the example,
|
||||
the interface name is used as the type in the Java layer:
|
||||
|
|
|
@ -83,5 +83,7 @@ public class multiple_inheritance_interfaces_runme {
|
|||
d.ia(10);
|
||||
d.ia("bye");
|
||||
d.ia("bye", false);
|
||||
|
||||
UndesirablesSwigImpl.UndesiredStaticMethod(UndesirablesSwigImpl.UndesiredEnum.UndesiredEnum1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,5 +74,7 @@ public class multiple_inheritance_interfaces_runme {
|
|||
d.ia(10);
|
||||
d.ia("bye");
|
||||
d.ia("bye", false);
|
||||
|
||||
UndesirablesSwigImpl.UndesiredStaticMethod(UndesirablesSwigImpl.UndesiredEnum.UndesiredEnum1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,33 @@ struct V : S {};
|
|||
struct W : T {};
|
||||
%}
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
%interface_impl(Undesirables);
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
// Don't put variables and enums into interface
|
||||
class Undesirables
|
||||
{
|
||||
public:
|
||||
Undesirables() : UndesiredVariable() {}
|
||||
virtual ~Undesirables() {}
|
||||
virtual void Method(int i) = 0;
|
||||
|
||||
enum UndesiredEnum { UndesiredEnum1, UndesiredEnum2 };
|
||||
static void UndesiredStaticMethod(UndesiredEnum e) {}
|
||||
int UndesiredVariable;
|
||||
static int UndesiredStaticVariable;
|
||||
static const int UndesiredStaticConstVariable = 0;
|
||||
};
|
||||
|
||||
int Undesirables::UndesiredStaticVariable = 0;
|
||||
|
||||
struct UndesirablesDerived : Undesirables {
|
||||
virtual void Method(int i) {}
|
||||
};
|
||||
%}
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
%interface_impl(BaseOverloaded);
|
||||
#endif
|
||||
|
|
|
@ -2323,7 +2323,7 @@ public:
|
|||
String *pre_code = NewString("");
|
||||
String *post_code = NewString("");
|
||||
String *terminator_code = NewString("");
|
||||
bool is_interface = GetFlag(parentNode(n), "feature:interface")
|
||||
bool is_interface = GetFlag(parentNode(n), "feature:interface") && !checkAttribute(n, "kind", "variable")
|
||||
&& !static_flag && Getattr(n, "interface:owner") == 0;
|
||||
|
||||
if (!proxy_flag)
|
||||
|
|
|
@ -2459,7 +2459,7 @@ public:
|
|||
bool setter_flag = false;
|
||||
String *pre_code = NewString("");
|
||||
String *post_code = NewString("");
|
||||
bool is_interface = GetFlag(parentNode(n), "feature:interface")
|
||||
bool is_interface = GetFlag(parentNode(n), "feature:interface") && !checkAttribute(n, "kind", "variable")
|
||||
&& !static_flag && Getattr(n, "interface:owner") == 0;
|
||||
|
||||
if (!proxy_flag)
|
||||
|
|
Loading…
Reference in New Issue