فهرست منبع

Merge pull request #289 from 16bit-ykiko/fix-capsule

update capsule.
BLUELOVETH 1 سال پیش
والد
کامیت
8d0e304ecd
1فایلهای تغییر یافته به همراه5 افزوده شده و 1 حذف شده
  1. 5 1
      include/pybind11/internal/types.h

+ 5 - 1
include/pybind11/internal/types.h

@@ -53,7 +53,7 @@ public:
     static type of() {
         return type_visitor::type<T>();
     }
-    
+
     static type of(const handle& obj) { return type(vm->_t(obj.ptr())); }
 };
 
@@ -368,6 +368,10 @@ public:
     template <typename T>
     capsule(T&& value) : object(create(std::forward<T>(value))) {}
 
+    capsule(void* ptr, void (*destructor)(void*) = nullptr) : object(create(ptr, destructor)) {}
+
+    void* data() const { return self().ptr; }
+
     template <typename T>
     T& cast() const {
         return *static_cast<T*>(self().ptr);