[Openmcl-devel] Setting a toplevel function for build-application
Pascal J. Bourguignon
pascal.bourguignon at ubudu.com
Mon Sep 16 09:27:20 UTC 2013
Ron Garret <ron at flownet.com> writes:
> I can't figure out how to set a toplevel function for build-application. The docs say:
> "The best source of information about writing your own toplevel is the
> Clozure CL source code, especially the implementations of
> TOPLEVEL-FUNCTION in "ccl/level-1/l1-application.lisp"
> In that file there is no example of calling build-application, but there is a (generic) function called toplevel-function.
> If I do this:
> (build-application :name "testapp" :directory #P"~/Desktop/" :copy-ide-resources t)
> the resulting application (mostly) works fine , but if I do this:
> (build-application :name "testapp" :directory #P"~/Desktop/" :copy-ide-resources t
> :toplevel-function 'toplevel-function)
> The resulting application crashes with hundreds of console message like this:
> 9/14/13 12:45:08 PM [0x0-0x3ae9ae6].com.clozure.store.ccl-x8664 > While executing: #<CCL::STANDARD-KERNEL-METHOD NO-APPLICABLE-METHOD (T)>, in process toplevel(8).
> 9/14/13 12:45:08 PM [0x0-0x3ae9ae6].com.clozure.store.ccl-x8664 > Error: There is no applicable method for the generic function:
> 9/14/13 12:45:08 PM [0x0-0x3ae9ae6].com.clozure.store.ccl-x8664 > #<STANDARD-GENERIC-FUNCTION CCL::UI-OBJECT-DO-OPERATION #x3020000BC73F>
> 9/14/13 12:45:08 PM [0x0-0x3ae9ae6].com.clozure.store.ccl-x8664 > when called with arguments:
> 9/14/13 12:45:08 PM [0x0-0x3ae9ae6].com.clozure.store.ccl-x8664 > (#<A Dead Mac Pointer> :BREAK-OPTIONS-STRING T)
> Clues appreciated.
> What I'm actually trying to do is build a standalone application that
> just opens a webkit window and does nothing else (i.e. no listener).
> But I want to do it programmatically, without a nib file.
>  Actually, the resulting application complains about not being able to find the header directory, but that's easy to fix.
For a GUI application, I use :toplevel-function nil (but then I guess
that defaults to the toplevel-function generic function in
The initialization of a Cocoa application is done thru the NSApplication
Of course, saving an image kills all the Objective-C objects, so you
have to use the various hooks (ccl:*lisp-cleanup-functions*
ccl:def-load-pointers ccl:*lisp-startup-functions*) available to clean
up and restore those Objective-C objects.
I have code to "archive" and "unarchive" Objective-C objects (including
circular references), but it's very fresh, let's say it's at the proof
of concept stage, but it can indeed transport eg. menus across saved
images (some work/debugging is still needed to complete the reviving of
objects like windows: the objects are unarchived, but they need to be
re-mapped on screen, and so on). cf. files wrapper.lisp
objc-persistent.lisp system.lisp etc.
So far, the trick is that lisp code should re-instanciate explicitely
all the Objective-C objects when the application is relaunched.
Senior Software Engineer
Ubudu SAS http://www.ubudu.com/
More information about the Openmcl-devel