[cffi-objects-cvs] r9 -

rklochkov at common-lisp.net rklochkov at common-lisp.net
Fri Aug 24 19:26:54 UTC 2012


Author: rklochkov
Date: Fri Aug 24 12:26:53 2012
New Revision: 9

Log:
Fixed FREE-PTR generic. First param is a symbol

Modified:
   freeable.lisp
   redefines.lisp
   struct.lisp

Modified: freeable.lisp
==============================================================================
--- freeable.lisp	Sun Aug 12 10:36:30 2012	(r8)
+++ freeable.lisp	Fri Aug 24 12:26:53 2012	(r9)
@@ -22,28 +22,27 @@
 
 (defgeneric free-ptr (type ptr)
   (:documentation "Called to free ptr, unless overriden free-sent-ptr 
-or free-returned-ptr.")
+or free-returned-ptr. TYPE should be specialized with EQL")
   (:method (type ptr)
     (foreign-free ptr)))
 
-(defgeneric free-sent-ptr (type ptr param)
-  (:method ((type freeable-base) ptr param)
-    (declare (ignore param))
+(defgeneric free-sent-ptr (cffi-type ptr param)
+  (:method ((cffi-type freeable-base) ptr param)
     (unless (null-pointer-p ptr)
-      (free-ptr type ptr))))
+      (free-ptr (type-of cffi-type) ptr))))
 
-(defgeneric free-returned-ptr (type ptr)
-  (:method ((type freeable-base) ptr)
+(defgeneric free-returned-ptr (cffi-type ptr)
+  (:method ((cffi-type freeable-base) ptr)
     (unless (null-pointer-p ptr)
-      (free-ptr type ptr))))
+      (free-ptr (type-of cffi-type) ptr))))
 
-(defun free-sent-if-needed (type ptr param)
-  (when (fst-free-to-foreign-p type)
-    (free-sent-ptr type ptr param)))
-
-(defun free-returned-if-needed (type ptr)
-  (when (fst-free-from-foreign-p type)
-    (free-returned-ptr type ptr)))
+(defun free-sent-if-needed (cffi-type ptr param)
+  (when (fst-free-to-foreign-p cffi-type)
+    (free-sent-ptr cffi-type ptr param)))
+
+(defun free-returned-if-needed (cffi-type ptr)
+  (when (fst-free-from-foreign-p cffi-type)
+    (free-returned-ptr cffi-type ptr)))
 
 (defclass freeable (freeable-base) ()
   (:documentation "Mixing to auto-set translators"))

Modified: redefines.lisp
==============================================================================
--- redefines.lisp	Sun Aug 12 10:36:30 2012	(r8)
+++ redefines.lisp	Fri Aug 24 12:26:53 2012	(r9)
@@ -24,7 +24,7 @@
 (defmethod translate-to-foreign ((value string) (type cffi-keyword))
   (foreign-string-alloc value))
 
-(defmethod free-ptr ((type cffi-keyword) ptr)
+(defmethod free-ptr ((type (eql 'cffi-keyword)) ptr)
   (foreign-string-free ptr))
 
 (define-foreign-type cffi-pathname (freeable)

Modified: struct.lisp
==============================================================================
--- struct.lisp	Sun Aug 12 10:36:30 2012	(r8)
+++ struct.lisp	Fri Aug 24 12:26:53 2012	(r9)
@@ -127,13 +127,14 @@
   ()
   (:actual-type :pointer))
 
-(defmethod free-ptr ((type cffi-struct) ptr)
-  (free-struct (object-class type) ptr))
-
 (defmethod free-sent-ptr ((type cffi-struct) ptr place)
   (when (and (slot-boundp place 'value) (not (null-pointer-p ptr)))
     (free-struct (object-class type) ptr)))
 
+(defmethod free-returned-ptr ((type cffi-struct) ptr)
+  (unless (null-pointer-p ptr)
+    (free-struct (object-class type) ptr)))
+
 
 (defmethod foreign-type-size ((type cffi-struct))
   "Return the size in bytes of a foreign typedef."




More information about the cffi-objects-cvs mailing list