/[cffi-objects]/freeable.lisp
ViewVC logotype

Diff of /freeable.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4 by rklochkov, Mon May 7 17:27:22 2012 UTC revision 5 by rklochkov, Sun Jul 29 15:15:41 2012 UTC
# Line 21  You should call FREE-RETURNED-IF-NEEDED Line 21  You should call FREE-RETURNED-IF-NEEDED
21  appropriate places of your CFFI translators")))  appropriate places of your CFFI translators")))
22    
23  (defgeneric free-ptr (type ptr)  (defgeneric free-ptr (type ptr)
24    (:documentation "Called to free ptr, unless overriden free-sent-ptr or free-returned-ptr.")    (:documentation "Called to free ptr, unless overriden free-sent-ptr
25    or free-returned-ptr.")
26    (:method (type ptr)    (:method (type ptr)
27      (foreign-free ptr)))      (foreign-free ptr)))
28    
29  (defgeneric free-sent-ptr (type ptr)  (defgeneric free-sent-ptr (type ptr param)
30    (:method ((type freeable-base) ptr)    (:method ((type freeable-base) ptr param)
31      (format t "Free-sent-ptr: ~a ~a ~%" type ptr)      (declare (ignore param))
32    ;    (format t "Free-sent-ptr: ~a ~a ~%" type ptr)
33      (unless (null-pointer-p ptr)      (unless (null-pointer-p ptr)
34        (free-ptr type ptr))))        (free-ptr type ptr))))
35    
36  (defgeneric free-returned-ptr (type ptr)  (defgeneric free-returned-ptr (type ptr)
37    (:method ((type freeable-base) ptr)    (:method ((type freeable-base) ptr)
38      (format t "Free-returned-ptr: ~a ~a ~%" type ptr)  ;    (format t "Free-returned-ptr: ~a ~a ~%" type ptr)
39      (unless (null-pointer-p ptr)      (unless (null-pointer-p ptr)
40        (free-ptr type ptr))))        (free-ptr type ptr))))
41    
42  (defun free-sent-if-needed (type ptr)  (defun free-sent-if-needed (type ptr param)
43    (when (member (object-free type) '(t :all :container :no-transfer))    (when (member (object-free type) '(t :all :container :no-transfer))
44      (free-sent-ptr type ptr)))      (free-sent-ptr type ptr param)))
45    
46  (defun free-returned-if-needed (type ptr)  (defun free-returned-if-needed (type ptr)
47    (when (member (object-free type) '(t :all :container :transfer))    (when (member (object-free type) '(t :all :container :transfer))
# Line 49  appropriate places of your CFFI translat Line 51  appropriate places of your CFFI translat
51    (:documentation "Mixing to auto-set translators"))    (:documentation "Mixing to auto-set translators"))
52    
53  (defmethod free-translated-object :after (ptr (type freeable) param)  (defmethod free-translated-object :after (ptr (type freeable) param)
54    (declare (ignore param))    (free-sent-if-needed type ptr param))
   (free-sent-if-needed type ptr))  
55    
56  (defmethod translate-from-foreign :after (ptr (type freeable))  (defmethod translate-from-foreign :after (ptr (type freeable))
57    (free-returned-if-needed type ptr))    (free-returned-if-needed type ptr))

Legend:
Removed from v.4  
changed lines
  Added in v.5

  ViewVC Help
Powered by ViewVC 1.1.5