CCL可可桥“你好世界”不工作?

时间:2017-05-12 14:16:27

标签: macos cocoa common-lisp ccl

我正在尝试运行Clozure为CCL-Cocoa桥提供的“hello world”脚本:

https://trac.clozure.com/ccl/wiki/CocoaBridge

  

加载包含这些表格的文件,评估(show-red-window),你会看到一个红色的窗口。

red-window.ccl
(in-package "CL-USER")

(require "COCOA")

(defclass red-view (ns:ns-view)
  ()
  (:metaclass ns:+ns-object))

(objc:defmethod (#/drawRect: :void) ((self red-view) (rect :<NSR>ect))
  (#/set (#/redColor ns:ns-color))
  (#_NSRectFill (#/bounds self)))

(defun show-red-window ()
  (ccl::with-autorelease-pool
   (let* ((rect (ns:make-ns-rect 0 0 300 300))
      (w (make-instance 'ns:ns-window
                :with-content-rect rect
                :style-mask (logior #$NSTitledWindowMask
                           #$NSClosableWindowMask
                           #$NSMiniaturizableWindowMask)
                :backing #$NSBackingStoreBuffered
                :defer t)))
     (#/setTitle: w #@"Red")
     (#/setContentView: w (#/autorelease (make-instance 'red-view)))
     (#/center w)
     (#/orderFront: w nil)
     (#/contentView w))))

但是当我运行ccl64并输入

(load "red-window.ccl")
(show-red-window)

我只是在终端上获得此输出:

#<RED-VIEW <RedView: 0x4cd530> (#x4CD530)>

似乎没有其他事情发生。

我错过了什么吗?我是CL和Cocoa的新手。

1 个答案:

答案 0 :(得分:1)

尝试

(gui:execute-in-gui #'(lambda () (show-red-window)))

带有红色窗口示例的页面最后更新10年前。 One of the other examples 13天前last modified pgmpy Python package包括gui:execute-in-gui