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

Diff of /struct.lisp

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

revision 3 by rklochkov, Fri May 4 11:25:20 2012 UTC revision 4 by rklochkov, Mon May 7 17:27:22 2012 UTC
# Line 99  or may be cons (class-name . struct-name Line 99  or may be cons (class-name . struct-name
99                      (setf (foreign-slot-value res class slot) val))))                      (setf (foreign-slot-value res class slot) val))))
100                (foreign-slot-names class))                (foreign-slot-names class))
101          res)          res)
102        (slot-value object 'pointer)))        (pointer object)))
103    
104  (defun struct->clos (class struct &optional object)  (defun struct->clos (class struct &optional object)
105    (let ((res (or object (make-instance class))))    (unless object
106      (setf (slot-value res 'value) nil)      (return-from struct->clos
107      (mapc (lambda (slot)        (unless (null-pointer-p struct)
108              (setf (getf (slot-value res 'value) slot)          (make-instance class :pointer struct))))
109                    (foreign-slot-value struct class slot)))    (if (slot-boundp object 'value)
110            (foreign-slot-names class))        (progn
111      res))          (setf (slot-value object 'value) nil)
112            (mapc (lambda (slot)
113                    (setf (getf (slot-value object 'value) slot)
114                          (foreign-slot-value struct class slot)))
115                  (foreign-slot-names class)))
116          (setf (pointer object) struct))
117      ;(break)
118      object)
119    
120    
121    
122    

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

  ViewVC Help
Powered by ViewVC 1.1.5