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:
parent
1cf599bccb
commit
8a40327aa8
10 changed files with 149 additions and 74 deletions
|
|
@ -485,9 +485,10 @@ static void add_symbols(Node *n) {
|
|||
SetFlag(n,"deleted");
|
||||
SetFlag(n,"feature:ignore");
|
||||
}
|
||||
{
|
||||
String *refqualifier = Getattr(n, "refqualifier");
|
||||
if (SwigType_isrvalue_reference(refqualifier) && Strcmp(symname, "$ignore") != 0) {
|
||||
if (SwigType_isrvalue_reference(Getattr(n, "refqualifier"))) {
|
||||
/* Ignore rvalue ref-qualifiers by default
|
||||
* Use Getattr instead of GetFlag to handle explicit ignore and explicit not ignore */
|
||||
if (!(Getattr(n, "feature:ignore") || Strncmp(symname, "$ignore", 7) == 0)) {
|
||||
SWIG_WARN_NODE_BEGIN(n);
|
||||
Swig_warning(WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED, Getfile(n), Getline(n),
|
||||
"Method with rvalue ref-qualifier %s ignored.\n", Swig_name_decl(n));
|
||||
|
|
|
|||
|
|
@ -1024,6 +1024,15 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
|
|||
}
|
||||
}
|
||||
|
||||
if (!self && SwigType_isrvalue_reference(Getattr(n, "refqualifier"))) {
|
||||
String *memory_header = NewString("<memory>");
|
||||
Setfile(memory_header, Getfile(n));
|
||||
Setline(memory_header, Getline(n));
|
||||
Swig_fragment_emit(memory_header);
|
||||
self = NewString("std::move(*this).");
|
||||
Delete(memory_header);
|
||||
}
|
||||
|
||||
call = Swig_cmethod_call(explicitcall_name ? explicitcall_name : name, p, self, explicit_qualifier, director_type);
|
||||
cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue