Browse Source

express: make PointerTo directly initializable from nullptr

rdb 7 years ago
parent
commit
be282627a8

+ 3 - 0
dtool/src/interrogate/interfaceMakerPythonNative.cxx

@@ -5451,6 +5451,9 @@ write_function_instance(ostream &out, FunctionRemap *remap,
         if (TypeManager::is_reference_count(obj_type)) {
           // We use a PointerTo to handle the management here.  It's cleaner
           // that way.
+          if (default_expr == " = 0" || default_expr == " = nullptr") {
+            default_expr.clear();
+          }
           if (TypeManager::is_const_pointer_to_anything(type)) {
             extra_convert
               << "CPT(" << class_name << ") " << param_name << "_this"

+ 2 - 0
panda/src/express/pointerTo.h

@@ -71,6 +71,7 @@ public:
   typedef typename PointerToBase<T>::To To;
 PUBLISHED:
   ALWAYS_INLINE constexpr PointerTo() noexcept = default;
+  ALWAYS_INLINE explicit constexpr PointerTo(std::nullptr_t) noexcept {}
   ALWAYS_INLINE PointerTo(To *ptr) noexcept;
   INLINE PointerTo(const PointerTo<T> &copy);
 
@@ -132,6 +133,7 @@ public:
   typedef typename PointerToBase<T>::To To;
 PUBLISHED:
   ALWAYS_INLINE constexpr ConstPointerTo() noexcept = default;
+  ALWAYS_INLINE explicit constexpr ConstPointerTo(std::nullptr_t) noexcept {}
   ALWAYS_INLINE ConstPointerTo(const To *ptr) noexcept;
   INLINE ConstPointerTo(const PointerTo<T> &copy);
   INLINE ConstPointerTo(const ConstPointerTo<T> &copy);