[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 [1], 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[90745]	> 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[90745]	> Error: There is no applicable method for the generic function:
> 9/14/13 12:45:08 PM	[0x0-0x3ae9ae6].com.clozure.store.ccl-x8664[90745]	>          #<STANDARD-GENERIC-FUNCTION CCL::UI-OBJECT-DO-OPERATION #x3020000BC73F>
> 9/14/13 12:45:08 PM	[0x0-0x3ae9ae6].com.clozure.store.ccl-x8664[90745]	>        when called with arguments:
> 9/14/13 12:45:08 PM	[0x0-0x3ae9ae6].com.clozure.store.ccl-x8664[90745]	>          (#<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.
>
> rg
>
> [1] 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
l1-applications).


The initialization of a Cocoa application is done thru the NSApplication
instance anyways.


Of course, saving an image kills all the Objective-C objects, so you
have to use the various hooks (ccl:*lisp-cleanup-functions*
ccl:*save-exit-functions* ccl:*restore-lisp-functions*
ccl:def-load-pointers ccl:*lisp-startup-functions*) available to clean
up and restore those Objective-C objects.

In
https://gitorious.org/patchwork/patchwork/source/881de93680c96ddd88cbf5ce43764e6843e6327a:src/mclgui
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.


-- 
__Pascal Bourguignon__
Senior Software Engineer
Ubudu SAS http://www.ubudu.com/




More information about the Openmcl-devel mailing list