Question about FLI:WITH-DYNAMIC-FOREIGN-OBJECTS
Hello,
If I have the following definitions :
(fli:define-c-struct (mt-timestamp (:foreign-name "xxx"))
(year mt-short)
(month mt-short)
(day mt-short)
(hour mt-short)
(minute mt-short)
(second mt-short)
(microsecs mt-integer))
(fli:define-c-typedef (mt-timestamp (:foreign-name "xxx"))
(:struct mt-timestamp))
(defclass mh-timestamp ()
((fs :initform (let ((fs (fli:allocate-dynamic-foreign-object :type 'mt-
timestamp)))
(setf (fli:foreign-slot-value fs 'microsecs) 0)
(setf (fli:foreign-slot-value fs 'second) 0)
(setf (fli:foreign-slot-value fs 'minute) 0)
(setf (fli:foreign-slot-value fs 'hour) 0)
(setf (fli:foreign-slot-value fs 'day) 1)
(setf (fli:foreign-slot-value fs 'month) 1)
(setf (fli:foreign-slot-value fs 'year) 2003)
fs
)
))
)
I suppose, that if I write in the listener
CL-USER 77 > (fli:with-dynamic-foreign-objects () (setq x (make-instance 'mh-
timestamp)) x)
#<MH-TIMESTAMP 205F28E4>
CL-USER 78 > (inspect x)
#<MH-TIMESTAMP 205F28E4> is a MH-TIMESTAMP
FS #<Pointer to type MT-TIMESTAMP = #x007C4208>
I see that the pointer 'FS is not NIL.
Why? I have allocated it with 'FLI:WITH-DYNAMIC-FOREIGN-OBJECTS and now I'm out
of its scope.
If I further write:
CL-USER 13 > (fli:with-dynamic-foreign-objects () (setq x (make-instance 'mh-
timestamp)) x)
#<MH-TIMESTAMP 205E9B14>
CL-USER 14 > (fli:foreign-slot-value (slot-value x 'fs) 'year)
2003
CL-USER 15 > (fli:foreign-slot-value (slot-value x 'fs) 'year)
2003
CL-USER 16 > x
#<MH-TIMESTAMP 205E9B14>
CL-USER 17 > (fli:foreign-slot-value (slot-value x 'fs) 'year)
2003
But if I start now the graphical inspector I see meaningless values for the
slots of 'FS
CL-USER 18 > x
#<MH-TIMESTAMP 205E9B14>
CL-USER 19 > :gi
CL-USER 20 > (fli:foreign-slot-value (slot-value x 'fs) 'year)
221619568
What does this mean?
Can somebody help me to see what I'm missing in my understanding about CLOS and
FLI?
With best regards