diff --git a/examples/cocoa-speech.factor b/examples/cocoa-speech.factor index b75813e221..e78f4ccdfa 100644 --- a/examples/cocoa-speech.factor +++ b/examples/cocoa-speech.factor @@ -12,20 +12,12 @@ USING: alien compiler kernel objc sequences words ; ! Define classes and messages : init-cocoa "NSObject" define-objc-class - "NSString" define-objc-class "NSSpeechSynthesizer" define-objc-class ; parsing init-cocoa USING: objc-NSString objc-NSObject objc-NSSpeechSynthesizer ; -: NSASCIIStringEncoding 1 ; inline - -! A utility -: ( string -- alien ) - NSString [alloc] - swap NSASCIIStringEncoding [initWithCString:encoding:] ; - ! A utility : ( voice -- synth ) NSSpeechSynthesizer [alloc] swap [initWithVoice:] ; @@ -33,7 +25,7 @@ USING: objc-NSString objc-NSObject objc-NSSpeechSynthesizer ; ! Call the TTS API : speech-test f - "Hello from Factor" + "Hello from Factor" [startSpeakingString:] ; ! As usual, alien invoke words need to be compiled diff --git a/examples/cocoa-webkit.factor b/examples/cocoa-webkit.factor index 8585126f8f..695ca63b67 100644 --- a/examples/cocoa-webkit.factor +++ b/examples/cocoa-webkit.factor @@ -21,8 +21,6 @@ FUNCTION: void* CFStringCreateWithCString ( void* allocator, char* cStr, int enc FUNCTION: void* CFBundleCreate ( void* allocator, void* bundleURL ) ; compiled -FUNCTION: void* CFBundleGetFunctionPointerForName ( void* bundle, void* functionName ) ; compiled - FUNCTION: bool CFBundleLoadExecutable ( void* bundle ) ; compiled FUNCTION: void CFRelease ( void* cf ) ; compiled @@ -51,7 +49,7 @@ FUNCTION: void CFRelease ( void* cf ) ; compiled CFBundleLoadExecutable drop { "NSObject" "NSWindow" - "NSURLRequest" "NSApplication" "%NSURL" + "NSURLRequest" "NSApplication" "WebView" "WebFrame" } [ dup define-objc-class "objc-" swap append use+ ] each ; parsing diff --git a/library/alien/primitive-types.factor b/library/alien/primitive-types.factor index 53dbd2fe85..e84381d622 100644 --- a/library/alien/primitive-types.factor +++ b/library/alien/primitive-types.factor @@ -26,7 +26,7 @@ math namespaces ; [ set-alien-unsigned-8 ] "setter" set 8 "width" set 8 "align" set - [ "box_unsinged_8" %box ] "boxer" set + [ "box_unsigned_8" %box ] "boxer" set [ "unbox_unsigned_8" %unbox ] "unboxer" set ] "ulonglong" define-primitive-type diff --git a/library/bootstrap/boot-stage1.factor b/library/bootstrap/boot-stage1.factor index 3100d0587c..ec71154fff 100644 --- a/library/bootstrap/boot-stage1.factor +++ b/library/bootstrap/boot-stage1.factor @@ -144,9 +144,6 @@ vectors words ; "/library/alien/syntax.factor" "/library/alien/malloc.factor" - "/library/alien/objective-c/runtime.factor" - "/library/alien/objective-c/utils.factor" - "/library/io/buffer.factor" "/library/cli.factor" diff --git a/library/bootstrap/boot-stage2.factor b/library/bootstrap/boot-stage2.factor index e1d346734c..09398d2ad1 100644 --- a/library/bootstrap/boot-stage2.factor +++ b/library/bootstrap/boot-stage2.factor @@ -14,7 +14,7 @@ sequences sequences-internals words ; "/library/win32/load.factor" run-resource ] when ] when - + "Compiling base..." print flush { @@ -34,6 +34,10 @@ sequences sequences-internals words ; "Initializing native I/O..." print flush "native-io" get [ init-io ] when + + os "macosx" = [ + "/library/cocoa/load.factor" run-resource + ] when ] when [ @@ -45,10 +49,10 @@ sequences sequences-internals words ; "Building cross-referencing database..." print H{ } clone crossref set -recrossref - -"Setting the resource path..." print -cwd global [ "resource-path" set ] bind +recrossref + +"Setting the resource path..." print +cwd global "resource-path" set-global [ compiled? ] word-subset length number>string write " compiled words" print diff --git a/library/alien/objective-c/runtime.factor b/library/cocoa/objc-runtime.factor similarity index 100% rename from library/alien/objective-c/runtime.factor rename to library/cocoa/objc-runtime.factor diff --git a/library/alien/objective-c/utils.factor b/library/cocoa/objc-utils.factor similarity index 95% rename from library/alien/objective-c/utils.factor rename to library/cocoa/objc-utils.factor index 3822fb4da4..c7cc67e3bf 100644 --- a/library/alien/objective-c/utils.factor +++ b/library/cocoa/objc-utils.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2006 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. IN: objc -USING: alien arrays hashtables kernel lists math namespaces -parser sequences words ; +USING: alien arrays errors hashtables kernel lists math +namespaces parser sequences words ; TUPLE: selector name object ; @@ -85,6 +85,7 @@ C: selector ( name -- sel ) [ set-selector-name ] keep ; [ method-list>seq % (objc-methods) ] [ 2drop ] if* ; : objc-methods ( class -- seq ) + [ "Null pointer passed to objc-methods" throw ] unless* [ f (objc-methods) ] { } make ; : instance-methods ( classname -- seq ) diff --git a/library/compiler/compiler.factor b/library/compiler/compiler.factor index 5837a87893..94942f0fe3 100644 --- a/library/compiler/compiler.factor +++ b/library/compiler/compiler.factor @@ -29,9 +29,12 @@ sequences words ; : try-compile ( word -- ) [ compile ] [ error. drop ] recover ; -: compile-all ( -- ) - [ f "no-effect" set-word-prop ] each-word - [ try-compile ] each-word ; +: compile-vocabs ( vocabs -- ) + [ words ] map concat + dup [ f "no-effect" set-word-prop ] each + [ try-compile ] each ; + +: compile-all ( -- ) vocabs compile-vocabs ; : recompile ( word -- ) dup update-xt compile ;