From 7df9b774e93b174c6a38f144daa2b848677dac8d Mon Sep 17 00:00:00 2001 From: slava Date: Wed, 15 Mar 2006 20:58:22 +0000 Subject: [PATCH] UI bootstrapped in --- TODO.FACTOR.txt | 2 +- library/cocoa/load.factor | 1 + library/cocoa/subclassing.factor | 27 ++++++++++++++++----------- library/cocoa/ui.factor | 8 ++++---- library/compiler/compiler.factor | 12 +++++------- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 31da3a409d..0662a224d6 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -28,9 +28,9 @@ + ui/help: +- unregister notifications in dealloc - segfault when closing window - wheel mouse is a bit funny -- bootstrap in the ui - changelog in the UI - make the UI look better, something like this: http://twb.ath.cx/~twb/darcs/OBSOLETE/factor/final.html diff --git a/library/cocoa/load.factor b/library/cocoa/load.factor index f5cddd6078..5896c419a4 100644 --- a/library/cocoa/load.factor +++ b/library/cocoa/load.factor @@ -10,6 +10,7 @@ USING: compiler io parser sequences words ; "/library/cocoa/application-utils.factor" "/library/cocoa/window-utils.factor" "/library/cocoa/view-utils.factor" + "/library/cocoa/ui.factor" } [ run-resource ] each diff --git a/library/cocoa/subclassing.factor b/library/cocoa/subclassing.factor index 1afa2a212e..c231027dff 100644 --- a/library/cocoa/subclassing.factor +++ b/library/cocoa/subclassing.factor @@ -2,19 +2,11 @@ ! See http://factorcode.org/license.txt for BSD license. IN: objc USING: alien arrays compiler hashtables kernel kernel-internals -libc math namespaces sequences strings ; - -: encode-types ( return types -- encoding ) - >r 1array r> append - [ [ alien>objc-types get hash % CHAR: 0 , ] each ] "" make ; - -: prepare-method ( { name return types quot } -- sel type imp ) - [ first3 encode-types ] keep - [ 1 swap tail % \ alien-callback , ] [ ] make ; +libc math namespaces sequences strings words ; : init-method ( method alien -- ) - >r prepare-method r> - [ >r compile-1 r> set-objc-method-imp ] keep + >r first3 r> + [ >r execute r> set-objc-method-imp ] keep [ >r r> set-objc-method-types ] keep >r sel_registerName r> set-objc-method-name ; @@ -68,7 +60,20 @@ libc math namespaces sequences strings ; >r objc-class r> [ ] 2keep objc_addClass ; +: encode-types ( return types -- encoding ) + >r 1array r> append + [ [ alien>objc-types get hash % CHAR: 0 , ] each ] "" make ; + +: prepare-method ( { name ret types quot } -- { name type imp } ) + [ first3 encode-types ] keep + [ 1 swap tail % \ alien-callback , ] [ ] make compile-quot + 3array ; + +: prepare-methods ( methods -- methods ) + [ prepare-method ] map ; + : define-objc-class ( superclass name imeth cmeth -- ) pick >r + [ prepare-methods ] 2apply [ 2array % 2array % \ (define-objc-class) , ] [ ] make r> swap import-objc-class ; diff --git a/library/cocoa/ui.factor b/library/cocoa/ui.factor index 1c93dff46d..0964c5d55e 100644 --- a/library/cocoa/ui.factor +++ b/library/cocoa/ui.factor @@ -157,13 +157,13 @@ IN: shells [ [ init-world - + world get ui-title - + listener-application - + NSApplication [sharedApplication] [finishLaunching] - + event-loop ] with-cocoa ] with-freetype ; diff --git a/library/compiler/compiler.factor b/library/compiler/compiler.factor index ce6379fdf6..5b725db26e 100644 --- a/library/compiler/compiler.factor +++ b/library/compiler/compiler.factor @@ -39,10 +39,8 @@ sequences words ; : recompile ( word -- ) dup update-xt compile ; -: compile-1 ( quot -- ) - #! Compute and call a quotation. - "compile" get [ - gensym [ swap define-compound ] keep dup compile execute - ] [ - call - ] if ; +: compile-quot ( quot -- word ) + gensym [ swap define-compound ] keep + "compile" get [ dup compile ] when ; + +: compile-1 ( quot -- ) compile-quot execute ;