diff --git a/CHANGES.current b/CHANGES.current index 5386a7d36..1e88a89d4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,18 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2020-09-25: wsfulton + [C#, Java] #1874 Add ability to change the modifiers for the interface + generated when using the %interface macros. + + For C# use the 'csinterfacemodifiers' typemap. + For Java use the 'javainterfacemodifiers' typemap. + + For example: + + %typemap(csinterfacemodifiers) X "internal interface" + + 2020-09-24: geefr [C#] #1868 Fix wchar_t* csvarout typemap for member variable wrappers. diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index ef4c0104d..fe8f7c4bd 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -240,6 +240,7 @@ javabody -> csbody javafinalize -> csfinalize javadestruct -> csdisposing and csdispose javadestruct_derived -> csdisposing_derived and csdispose_derived +javainterfacemodifiers -> csinterfacemodifiers javainterfacecode -> csinterfacecode diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index b9234b24f..2f55f5b04 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -6610,6 +6610,15 @@ Below shows an example modifying the finalizer, assuming the delete met +
%typemap(javainterfacemodifiers)
++Compatibility note: This typemap was added in SWIG-4.1.0. +
+ +%typemap(javainterfacecode, declaration="...", cptrmethod="...")
@@ -6709,7 +6718,7 @@ The "javaimports" typemap is ignored if the enum class is wrapped by an inner Ja
[ javaimports typemap ]
-public interface [ javainterfacename ] {
+[ javainterfacemodifiers typemap ] [ javainterfacename ] {
[ javainterfacecode:cptrmethod typemap attribute ]
... interface declarations ...
}
diff --git a/Examples/test-suite/multiple_inheritance_interfaces.i b/Examples/test-suite/multiple_inheritance_interfaces.i
index 2972922fb..b7069647b 100644
--- a/Examples/test-suite/multiple_inheritance_interfaces.i
+++ b/Examples/test-suite/multiple_inheritance_interfaces.i
@@ -64,3 +64,31 @@ struct DerivedOverloaded : public BaseOverloaded {
virtual void identical_overload(int i, const PTypedef &p = PTypedef()) {}
};
%}
+
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+%interface(Space::X)
+#endif
+
+// Test the csinterfacemodifiers and javainterfacemodifiers typemaps.
+#if defined(SWIGCSHARP)
+/* change access from default "public class" to "internal class" */
+%typemap(csclassmodifiers) InternalAccess "internal class"
+/* The following modifiers are also needed with the above access modifier change */
+%typemap(csclassmodifiers) Space::X "internal class"
+%typemap(csinterfacemodifiers) Space::X "internal interface"
+#elif defined(SWIGJAVA)
+%typemap(javaclassmodifiers) InternalAccess "final /*notpublic*/ class"
+%typemap(javaclassmodifiers) Space::X "final class"
+%typemap(javainterfacemodifiers) Space::X "/*notpublic*/ interface"
+#endif
+
+%inline %{
+struct InternalAccess {};
+namespace Space {
+ class X {
+ public:
+ virtual void x(const InternalAccess& date) const = 0;
+ };
+}
+%}
diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg
index ecc1983a7..0e180f576 100644
--- a/Lib/csharp/csharp.swg
+++ b/Lib/csharp/csharp.swg
@@ -894,6 +894,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(csinterfaces) SWIGTYPE "global::System.IDisposable"
%typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(csinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(csinterfacemodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public interface"
// csbody typemaps... these are in macros so that the visibility of the methods can be easily changed by users.
diff --git a/Lib/java/java.swg b/Lib/java/java.swg
index e9309331a..8f95f3a3b 100644
--- a/Lib/java/java.swg
+++ b/Lib/java/java.swg
@@ -1196,6 +1196,7 @@ Swig::LocalRefGuard $1_refguard(jenv, $input); }
%typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(javainterfacemodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public interface"
/* javabody typemaps */
diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h
index a08693ac8..8362cc08e 100644
--- a/Source/Include/swigwarn.h
+++ b/Source/Include/swigwarn.h
@@ -277,6 +277,7 @@
#define WARN_JAVA_TYPEMAP_DIRECTORIN_NODESC 824
#define WARN_JAVA_NO_DIRECTORCONNECT_ATTR 825
#define WARN_JAVA_NSPACE_WITHOUT_PACKAGE 826
+#define WARN_JAVA_TYPEMAP_INTERFACEMODIFIERS_UNDEF 847
/* please leave 810-829 free for Java */
@@ -297,6 +298,7 @@
#define WARN_CSHARP_EXCODE 844
#define WARN_CSHARP_CANTHROW 845
#define WARN_CSHARP_NO_DIRECTORCONNECT_ATTR 846
+#define WARN_CSHARP_TYPEMAP_INTERFACEMODIFIERS_UNDEF 847
/* please leave 830-849 free for C# */
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index 27cc65b32..5fef4caef 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -2050,7 +2050,8 @@ public:
void emitInterfaceDeclaration(Node *n, String *interface_name, File *f_interface) {
Printv(f_interface, typemapLookup(n, "csimports", Getattr(n, "classtypeobj"), WARN_NONE), "\n", NIL);
- Printf(f_interface, "public interface %s", interface_name);
+ Printv(f_interface, typemapLookup(n, "csinterfacemodifiers", Getattr(n, "classtypeobj"), WARN_CSHARP_TYPEMAP_INTERFACEMODIFIERS_UNDEF), NIL);
+ Printf(f_interface, " %s", interface_name);
if (List *baselist = Getattr(n, "bases")) {
String *bases = 0;
for (Iterator base = First(baselist); base.item; base = Next(base)) {
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index 231c6c0cb..7c8bed480 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -2145,7 +2145,8 @@ public:
}
Printv(f_interface, typemapLookup(n, "javaimports", Getattr(n, "classtypeobj"), WARN_NONE), "\n", NIL);
- Printf(f_interface, "public interface %s", interface_name);
+ Printv(f_interface, typemapLookup(n, "javainterfacemodifiers", Getattr(n, "classtypeobj"), WARN_JAVA_TYPEMAP_INTERFACEMODIFIERS_UNDEF), NIL);
+ Printf(f_interface, " %s", interface_name);
if (List *baselist = Getattr(n, "bases")) {
String *bases = 0;
for (Iterator base = First(baselist); base.item; base = Next(base)) {