Improve nullptr constant wrapping

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@13842 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2012-09-20 19:09:38 +00:00
commit ecac2d2a68
6 changed files with 13 additions and 7 deletions

View file

@ -282,8 +282,7 @@ class DerivedClass: public BaseClass {
<H3><a name="Cpp0x_Null_pointer_constant"></a>7.2.11 Null pointer constant</H3>
<p>SWIG correctly maps the std::nullptr constant to the null pointer
constant in the target language.</p>
<p>The <tt>nullptr</tt> constant is largely unimportant in wrappers. In the few places it has an effect, it is treated like <tt>NULL</tt>.</p>
<H3><a name="Cpp0x_Strongly_typed_enumerations"></a>7.2.12 Strongly typed enumerations</H3>

View file

@ -4,13 +4,19 @@
%module cpp0x_null_pointer_constant
%feature("autodoc") A::NullPtrMethod; // Triggers conversion of nullptr to None, nil etc in target language
%feature("compactdefaultargs") A::NullPtrMethod;
%inline %{
#include <cstddef>
const int *const MyIntegerPtr = nullptr;
class A {
public:
A() : _myA(std::nullptr) { }
A() : _myA(nullptr) { }
A *_myA;
void NullPtrMethod(double *ptr = nullptr) {}
};
%}

View file

@ -390,7 +390,7 @@ public:
Append(decl_str, tex_name);
if (value) {
if (Strcmp(value, "NULL") == 0)
if (Strcmp(value, "NULL") == 0 || Strcmp(value, "nullptr") == 0)
value = NewString("nil");
else if (Strcmp(value, "true") == 0 || Strcmp(value, "TRUE") == 0)
value = NewString("true");

View file

@ -1345,6 +1345,7 @@ public:
}
}
if (Strcmp(value, "NULL") == 0 ||
Strcmp(value, "nullptr") == 0 ||
Strcmp(value, "0") == 0 ||
Strcmp(value, "0L") == 0) {
Clear(value);

View file

@ -1444,7 +1444,7 @@ public:
return NewString("True");
if (Strcmp(v, "false")==0 || Strcmp(v, "FALSE")==0)
return NewString("False");
if (Strcmp(v, "NULL")==0)
if (Strcmp(v, "NULL")==0 || Strcmp(v, "nullptr")==0)
return NewString("None");
}
return 0;

View file

@ -384,7 +384,7 @@ private:
}
if (value) {
if (Strcmp(value, "NULL") == 0)
if (Strcmp(value, "NULL") == 0 || Strcmp(value, "nullptr") == 0)
value = NewString("nil");
else if (Strcmp(value, "true") == 0 || Strcmp(value, "TRUE") == 0)
value = NewString("true");