[Openmcl-devel] ObjC object initialization weirdness

Ron Garret ron at flownet.com
Sun Dec 21 14:30:48 PST 2014


Welcome to Clozure Common Lisp Version 1.10-r16304M  (DarwinX8664)!

; Get access to PDF documents
? (objc:load-framework "Quartz" :quartz)
NIL

; If we try to make a PDFDocument using make-instance, something goes wrong
; Notice the resulting document has zero pages
? (make-instance ns:pdf-document :with-url
  (make-instance ns:ns-url :with-string
    #@"http://www.flownet.com/ron/specials.pdf"))
#<PDF-DOCUMENT PDFDocument, number of pages: 0
 (#x6080002074E0)>

; If we build the PDFDocument manually, then it works
? (setf url (make-instance ns:ns-url :with-string
            #@"http://www.flownet.com/ron/specials.pdf"))
#<NS-URL http://www.flownet.com/ron/specials.pdf (#x600000274B00)>
? (#/initWithURL: (#/alloc ns:pdf-document) url)
#<PDF-DOCUMENT PDFDocument, number of pages: 9
 (#x608000209B10)>

; Here’s the really weird part.  If we re-load the Quartz framework...
? (objc:load-framework "Quartz" :quartz)
NIL

; … then make-instnce starts doing the Right Thing
? (make-instance ns:pdf-document :with-url
  (make-instance ns:ns-url :with-string
    #@"http://www.flownet.com/ron/specials.pdf"))
#<PDF-DOCUMENT PDFDocument, number of pages: 9
 (#x608000209AA0)>




More information about the Openmcl-devel mailing list