problems getting objective-C pointer values in lisp
I am having problems getting objective-C pointer values in lisp.
In the example below, I trying to access a boolean value using the
new Tiger QTKit (quicktime kit).
I choose a call that would return a boolean value . However, calls to
invoke and invoke-bool give me both pointers. They return the same
pointer and I imagine this is good. I have tried fli:deference
without success.
Any pointers (no pun intended) to some solution?
Thanks
Bruno
#|
QTMovieHasDurationAttribute
The duration setting; the value for this key is of type NSNumber,
interpreted as a BOOL. This value is YES if the movie has a duration.
(Some types of movies, for instance QuickTime VR movies, have no
duration.)
CL-USER 62 > (qtmovie-has-duration? (choose-qtmovie-file))
qt-movie pointer #<Pointer: OBJC:OBJC-OBJECT-POINTER = #x07BFF7F0>
qt-movie from pointer #<QT-MOVIE 100D14EB>
invoke-bool #<Pointer: OBJC:OBJC-OBJECT-POINTER = #xA0727964>
invoke #<Pointer: OBJC:OBJC-OBJECT-POINTER = #xA0727964>
object from pointer NIL
pointer type :VOID
dereference #<Pointer to type :VOID = #x00300B10>
|#
(objc:ensure-objc-initialized
:modules
'("/System/Library/Frameworks/Foundation.framework/Versions/C/
Foundation"
"/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa"
"/System/Library/Frameworks/QuickTime.framework/Versions/A/
QuickTime"
"/System/Library/Frameworks/QTKit.framework/Versions/A/QTKit"))
(objc:define-objc-class qt-movie ()
()
(:objc-class-name "My-QTMovie")
(:objc-superclass-name "QTMovie"))
(defmethod init-qtmovie-with-file ((qt-movie qt-movie) file-pathname)
(let ((url (objc:invoke "NSURL" "fileURLWithPath:"
(namestring file-pathname))))
(objc:invoke (objc:invoke "My-QTMovie" "alloc")
"initWithURL:error:" url nil)
qt-movie))
(defun choose-qtmovie-file (&optional (default-directory #P"~/Movies/"))
(when-let (file-pathaname (capi:prompt-for-file
"QuicktTime file"
:pathname default-directory
:filters '("mov" "*.mov" "mid" "*.mid"
"mp4" "*.mp4")))
(init-qtmovie-with-file (make-instance 'qt-movie) file-pathaname)))
(defmethod qtmovie-has-duration? ((qt-movie qt-movie))
(format t "qt-movie pointer ~S~%"
(objc:objc-object-pointer qt-movie))
(format t "qt-movie from pointer ~S~%"
(objc:objc-object-from-pointer (objc:objc-object-pointer
qt-movie)))
(format t "invoke-bool ~S~%"
(objc:invoke-bool (objc:objc-object-pointer qt-movie)
"attributeForKey:" "QTMovieHasDurationAttribute"))
(format t "invoke ~S~%"
(objc:invoke (objc:objc-object-pointer qt-movie)
"attributeForKey:" "QTMovieHasDurationAttribute"))
(format t "object from pointer ~S~%"
(objc:objc-object-from-pointer (objc:invoke (objc:objc-
object-pointer qt-movie) "attributeForKey:"
"QTMovieHasDurationAttribute")))
(format t "pointer type ~S~%"
(fli:pointer-element-type (objc:invoke (objc:objc-object-
pointer qt-movie) "attributeForKey:" "QTMovieHasDurationAttribute")))
(format t "dereference ~S~%"
(fli:dereference (objc:invoke (objc:objc-object-pointer
qt-movie) "attributeForKey:" "QTMovieHasDurationAttribute")
:type '(:pointer :void) :copy-foreign-
object nil))
)