Add unignore for rvalue ref-qualifiers

Use std::move on this pointer as the default approach to supporting
rvalue ref-qualifiers if a user really wants to wrap.

std::move requires <memory> headers so add swigfragments.swg for all
languages to use common fragments. Just header file fragments for now.
This commit is contained in:
William S Fulton 2017-08-25 19:08:09 +01:00
commit 8a40327aa8
10 changed files with 149 additions and 74 deletions

View file

@ -562,6 +562,7 @@ CPP11_TEST_CASES += \
cpp11_null_pointer_constant \
cpp11_raw_string_literals \
cpp11_ref_qualifiers \
cpp11_ref_qualifiers_rvalue_unignore \
cpp11_result_of \
cpp11_rvalue_reference \
cpp11_rvalue_reference2 \

View file

@ -0,0 +1,15 @@
%module cpp11_ref_qualifiers_rvalue_unignore
// This is a minimal test that does not include any C++ headers to make sure the required
// <memory> header is generated from a fragment for the generated std::move call
// m1 and m2 are ignored by default, unignore them
%feature("ignore", "0") RefQualifier::m1() &&;
%feature("ignore", "0") RefQualifier::m2() const &&;
%inline %{
struct RefQualifier {
void m1() && {}
void m2() const && {}
};
%}

View file

@ -18,5 +18,11 @@ public:
void h_ignored() &&;
void i_ignored() &&;
void j_ignored() const &&;
void i_ignored() &&;
};
%feature("ignore", "0") Unignore::k_unignored() const &&;
struct Unignore {
void k_unignored() const &&;
};

View file

@ -0,0 +1,20 @@
import cpp11_ref_qualifiers_rvalue_unignore.*;
public class cpp11_ref_qualifiers_rvalue_unignore_runme {
static {
try {
System.loadLibrary("cpp11_ref_qualifiers_rvalue_unignore");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) {
new RefQualifier().m1();
new RefQualifier().m2();
}
}

View file

@ -0,0 +1,4 @@
import cpp11_ref_qualifiers_rvalue_unignore
cpp11_ref_qualifiers_rvalue_unignore.RefQualifier().m1()
cpp11_ref_qualifiers_rvalue_unignore.RefQualifier().m2()