From 005319da1ad432ee19edb52183e2af305be232ea Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 9 Jan 2008 01:36:11 -0500 Subject: [PATCH] Load fixes for Mac OS X-related libraries --- extra/bootstrap/ui/tools/tools.factor | 2 - .../cocoa/application/application-docs.factor | 17 ++++- extra/cocoa/application/application.factor | 4 ++ extra/cocoa/cocoa-docs.factor | 15 +---- extra/cocoa/cocoa-tests.factor | 6 +- extra/cocoa/cocoa.factor | 63 +++++++++---------- extra/cocoa/dialogs/dialogs-docs.factor | 3 +- extra/cocoa/messages/messages-docs.factor | 3 +- extra/cocoa/messages/messages.factor | 4 +- extra/cocoa/nibs/nibs-docs.factor | 3 +- extra/cocoa/pasteboard/pasteboard-docs.factor | 3 +- .../cocoa/subclassing/subclassing-docs.factor | 4 +- extra/cocoa/subclassing/subclassing.factor | 15 +++-- extra/cocoa/types/types-docs.factor | 3 +- extra/cocoa/views/views-docs.factor | 3 +- extra/cocoa/windows/windows-docs.factor | 3 +- .../core-foundation-docs.factor | 4 +- .../parser-combinators-docs.factor | 3 +- extra/tools/profiler/profiler-docs.factor | 10 +-- 19 files changed, 87 insertions(+), 81 deletions(-) diff --git a/extra/bootstrap/ui/tools/tools.factor b/extra/bootstrap/ui/tools/tools.factor index 9dde428e72..af715966b3 100644 --- a/extra/bootstrap/ui/tools/tools.factor +++ b/extra/bootstrap/ui/tools/tools.factor @@ -8,5 +8,3 @@ USING: kernel vocabs vocabs.loader sequences system ; "ui.cocoa.tools" require ] when ] when - -macosx? [ "ui.tools.deploy" require ] when diff --git a/extra/cocoa/application/application-docs.factor b/extra/cocoa/application/application-docs.factor index edca5ca70e..ad2f8ffbd9 100644 --- a/extra/cocoa/application/application-docs.factor +++ b/extra/cocoa/application/application-docs.factor @@ -1,5 +1,18 @@ -USING: cocoa.application debugger quotations help.markup -help.syntax strings alien core-foundation ; +USING: debugger quotations help.markup help.syntax strings alien +core-foundation ; +IN: cocoa.application + +HELP: +{ $values { "str" string } { "alien" alien } } +{ $description "Allocates an autoreleased " { $snippet "CFString" } "." } ; + +{ CF>string } related-words + +HELP: +{ $values { "seq" "a sequence of " { $link alien } " instances" } { "alien" alien } } +{ $description "Allocates an autoreleased " { $snippet "CFArray" } "." } ; + +{ } related-words HELP: with-autorelease-pool { $values { "quot" quotation } } diff --git a/extra/cocoa/application/application.factor b/extra/cocoa/application/application.factor index 43df84f4aa..709d318e63 100644 --- a/extra/cocoa/application/application.factor +++ b/extra/cocoa/application/application.factor @@ -5,6 +5,10 @@ cocoa cocoa.classes cocoa.runtime sequences threads debugger init inspector kernel.private ; IN: cocoa.application +: ( str -- alien ) -> autorelease ; + +: ( seq -- alien ) -> autorelease ; + : NSApplicationDelegateReplySuccess 0 ; : NSApplicationDelegateReplyCancel 1 ; : NSApplicationDelegateReplyFailure 2 ; diff --git a/extra/cocoa/cocoa-docs.factor b/extra/cocoa/cocoa-docs.factor index b2da1c93be..30602db40b 100644 --- a/extra/cocoa/cocoa-docs.factor +++ b/extra/cocoa/cocoa-docs.factor @@ -1,5 +1,6 @@ -USING: cocoa cocoa.messages help.markup help.syntax strings +USING: cocoa.messages help.markup help.syntax strings alien core-foundation ; +IN: cocoa HELP: -> { $syntax "-> selector" } @@ -15,18 +16,6 @@ HELP: SUPER-> { send super-send POSTPONE: -> POSTPONE: SUPER-> } related-words -HELP: -{ $values { "str" string } { "alien" alien } } -{ $description "Allocates an autoreleased " { $snippet "CFString" } "." } ; - -{ CF>string } related-words - -HELP: -{ $values { "seq" "a sequence of " { $link alien } " instances" } { "alien" alien } } -{ $description "Allocates an autoreleased " { $snippet "CFArray" } "." } ; - -{ } related-words - ARTICLE: "objc-calling" "Calling Objective C code" "Before an Objective C class can be used, it must be imported; by default, a small set of common classes are imported automatically, but additional classes can be imported as needed." { $subsection import-objc-class } diff --git a/extra/cocoa/cocoa-tests.factor b/extra/cocoa/cocoa-tests.factor index 03e3ebe445..1f94c051b7 100644 --- a/extra/cocoa/cocoa-tests.factor +++ b/extra/cocoa/cocoa-tests.factor @@ -12,8 +12,6 @@ CLASS: { [ data-gc "x" set 2drop ] } ; -recompile - : test-foo Foo -> alloc -> init dup 1.0 2.0 101.0 102.0 -> foo: @@ -36,13 +34,11 @@ CLASS: { [ 2drop test-foo "x" get ] } ; -recompile - Bar [ -> alloc -> init dup -> bar "x" set -> release -] compile-1 +] compile-call [ 1 ] [ "x" get NSRect-x ] unit-test [ 2 ] [ "x" get NSRect-y ] unit-test diff --git a/extra/cocoa/cocoa.factor b/extra/cocoa/cocoa.factor index 60fb0c7e15..387da32549 100755 --- a/extra/cocoa/cocoa.factor +++ b/extra/cocoa/cocoa.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: compiler io kernel cocoa.runtime cocoa.subclassing cocoa.messages cocoa.types sequences words vocabs parser -core-foundation namespaces assocs hashtables ; +core-foundation namespaces assocs hashtables definitions ; IN: cocoa : (remember-send) ( selector variable -- ) @@ -32,37 +32,36 @@ SYMBOL: super-sent-messages { "cocoa" "cocoa.runtime" "cocoa.messages" "cocoa.subclassing" -} [ words ] map concat compile-batch +} [ words ] map concat compile "Importing Cocoa classes..." print -{ - "NSApplication" - "NSArray" - "NSAutoreleasePool" - "NSBundle" - "NSError" - "NSEvent" - "NSException" - "NSMenu" - "NSMenuItem" - "NSNib" - "NSNotification" - "NSNotificationCenter" - "NSObject" - "NSOpenGLContext" - "NSOpenGLPixelFormat" - "NSOpenGLView" - "NSOpenPanel" - "NSPasteboard" - "NSResponder" - "NSSavePanel" - "NSView" - "NSWindow" - "NSWorkspace" -} [ - [ ] import-objc-class -] each -: ( str -- alien ) -> autorelease ; - -: ( seq -- alien ) -> autorelease ; +[ + { + "NSApplication" + "NSArray" + "NSAutoreleasePool" + "NSBundle" + "NSError" + "NSEvent" + "NSException" + "NSMenu" + "NSMenuItem" + "NSNib" + "NSNotification" + "NSNotificationCenter" + "NSObject" + "NSOpenGLContext" + "NSOpenGLPixelFormat" + "NSOpenGLView" + "NSOpenPanel" + "NSPasteboard" + "NSResponder" + "NSSavePanel" + "NSView" + "NSWindow" + "NSWorkspace" + } [ + [ ] import-objc-class + ] each +] with-compilation-unit diff --git a/extra/cocoa/dialogs/dialogs-docs.factor b/extra/cocoa/dialogs/dialogs-docs.factor index 5f14282cf2..798d8aa135 100644 --- a/extra/cocoa/dialogs/dialogs-docs.factor +++ b/extra/cocoa/dialogs/dialogs-docs.factor @@ -1,4 +1,5 @@ -USING: cocoa.dialogs help.markup help.syntax ; +USING: help.markup help.syntax ; +IN: cocoa.dialogs HELP: { $values { "panel" "an " { $snippet "NSOpenPanel" } } } diff --git a/extra/cocoa/messages/messages-docs.factor b/extra/cocoa/messages/messages-docs.factor index 6a36ee761c..f78981c923 100644 --- a/extra/cocoa/messages/messages-docs.factor +++ b/extra/cocoa/messages/messages-docs.factor @@ -1,4 +1,5 @@ -USING: cocoa.messages help.markup help.syntax strings alien ; +USING: help.markup help.syntax strings alien ; +IN: cocoa.messages HELP: send { $values { "args..." "method arguments" } { "receiver" alien } { "selector" string } { "return..." "value returned by method, if any" } } diff --git a/extra/cocoa/messages/messages.factor b/extra/cocoa/messages/messages.factor index 54ddbaa0cf..dcf499304b 100755 --- a/extra/cocoa/messages/messages.factor +++ b/extra/cocoa/messages/messages.factor @@ -16,7 +16,7 @@ IN: cocoa.messages : sender-stub ( method function -- word ) [ sender-stub-name f dup ] 2keep over first large-struct? [ "_stret" append ] when - make-sender define-compound dup compile ; + make-sender define ; SYMBOL: message-senders SYMBOL: super-message-senders @@ -196,7 +196,7 @@ H{ : define-objc-class-word ( name quot -- ) [ over , , \ unless-defined , dup , \ objc-class , - ] [ ] make >r "cocoa.classes" create r> define-compound ; + ] [ ] make >r "cocoa.classes" create r> define ; : import-objc-class ( name quot -- ) 2dup unless-defined diff --git a/extra/cocoa/nibs/nibs-docs.factor b/extra/cocoa/nibs/nibs-docs.factor index a6972016a7..ff53cb0b58 100644 --- a/extra/cocoa/nibs/nibs-docs.factor +++ b/extra/cocoa/nibs/nibs-docs.factor @@ -1,4 +1,5 @@ -USING: help.markup help.syntax cocoa.nibs strings ; +USING: help.markup help.syntax strings ; +IN: cocoa.nibs HELP: load-nib { $values { "name" string } } diff --git a/extra/cocoa/pasteboard/pasteboard-docs.factor b/extra/cocoa/pasteboard/pasteboard-docs.factor index afd5ea2020..ca64b1e136 100644 --- a/extra/cocoa/pasteboard/pasteboard-docs.factor +++ b/extra/cocoa/pasteboard/pasteboard-docs.factor @@ -1,4 +1,5 @@ -USING: cocoa.pasteboard help.markup help.syntax strings ; +USING: help.markup help.syntax strings ; +IN: cocoa.pasteboard HELP: pasteboard-string? { $values { "pasteboard" "an " { $snippet "NSPasteBoard" } } { "?" "a boolean" } } diff --git a/extra/cocoa/subclassing/subclassing-docs.factor b/extra/cocoa/subclassing/subclassing-docs.factor index b3c22b12bc..6924777d3d 100644 --- a/extra/cocoa/subclassing/subclassing-docs.factor +++ b/extra/cocoa/subclassing/subclassing-docs.factor @@ -1,5 +1,5 @@ -USING: cocoa.subclassing help.markup help.syntax strings alien -hashtables ; +USING: help.markup help.syntax strings alien hashtables ; +IN: cocoa.subclassing HELP: define-objc-class { $values { "hash" hashtable } { "imeth" "a sequence of instance method definitions" } } diff --git a/extra/cocoa/subclassing/subclassing.factor b/extra/cocoa/subclassing/subclassing.factor index d918bf29ca..f4d51b19d4 100755 --- a/extra/cocoa/subclassing/subclassing.factor +++ b/extra/cocoa/subclassing/subclassing.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types arrays assocs combinators compiler hashtables kernel libc math namespaces parser sequences words -cocoa.messages cocoa.runtime ; +cocoa.messages cocoa.runtime definitions ; IN: cocoa.subclassing : init-method ( method alien -- ) @@ -86,7 +86,9 @@ IN: cocoa.subclassing ] [ ] make define-temp ; : prepare-methods ( methods -- methods ) - [ first4 prepare-method 3array ] map ; + [ + [ first4 prepare-method 3array ] map + ] with-compilation-unit ; : redefine-objc-methods ( imeth name -- ) dup class-exists? [ @@ -102,16 +104,13 @@ SYMBOL: +superclass+ : define-objc-class ( imeth hash -- ) clone [ prepare-methods + +name+ get "cocoa.classes" create drop +name+ get 2dup redefine-objc-methods swap [ +protocols+ get , +superclass+ get , +name+ get , , \ (define-objc-class) , ] [ ] make import-objc-class ] bind ; -: define-objc-class-early ( hash -- ) - +name+ swap at "cocoa.classes" create drop ; - : CLASS: - parse-definition unclip >r parsed r> - >hashtable dup define-objc-class-early parsed - \ define-objc-class parsed ; parsing + parse-definition unclip + >hashtable define-objc-class ; parsing diff --git a/extra/cocoa/types/types-docs.factor b/extra/cocoa/types/types-docs.factor index 7f53d5f78e..0c4b01a476 100644 --- a/extra/cocoa/types/types-docs.factor +++ b/extra/cocoa/types/types-docs.factor @@ -1,4 +1,5 @@ -USING: cocoa.types math help.markup help.syntax ; +USING: math help.markup help.syntax ; +IN: cocoa.types HELP: { $values { "x" real } { "y" real } { "w" real } { "h" real } { "rect" "an " { $snippet "NSRect" } } } diff --git a/extra/cocoa/views/views-docs.factor b/extra/cocoa/views/views-docs.factor index 7e844005e6..a1cd792436 100644 --- a/extra/cocoa/views/views-docs.factor +++ b/extra/cocoa/views/views-docs.factor @@ -1,4 +1,5 @@ -USING: cocoa.views help.syntax help.markup ; +USING: help.syntax help.markup ; +IN: cocoa.views HELP: { $values { "pixelfmt" "an " { $snippet "NSOpenGLPixelFormat" } } } diff --git a/extra/cocoa/windows/windows-docs.factor b/extra/cocoa/windows/windows-docs.factor index 1cf49e38bb..39bd631b19 100644 --- a/extra/cocoa/windows/windows-docs.factor +++ b/extra/cocoa/windows/windows-docs.factor @@ -1,4 +1,5 @@ -USING: cocoa.windows help.markup help.syntax ; +USING: help.markup help.syntax ; +IN: cocoa.windows HELP: { $values { "rect" "an " { $snippet "NSRect" } } { "window" "an " { $snippet "NSWindow" } } } diff --git a/extra/core-foundation/core-foundation-docs.factor b/extra/core-foundation/core-foundation-docs.factor index 9914ffea19..ef8f5842a2 100644 --- a/extra/core-foundation/core-foundation-docs.factor +++ b/extra/core-foundation/core-foundation-docs.factor @@ -1,5 +1,5 @@ -USING: core-foundation alien strings arrays help.markup -help.syntax ; +USING: alien strings arrays help.markup help.syntax ; +IN: core-foundation HELP: CF>array { $values { "alien" "a " { $snippet "CFArray" } } { "array" "an array of " { $link alien } " instances" } } diff --git a/extra/parser-combinators/parser-combinators-docs.factor b/extra/parser-combinators/parser-combinators-docs.factor index 7b575e4da9..774069d5a5 100755 --- a/extra/parser-combinators/parser-combinators-docs.factor +++ b/extra/parser-combinators/parser-combinators-docs.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2006 Chris Double. ! See http://factorcode.org/license.txt for BSD license. -USING: help.markup help.syntax parser-combinators ; +USING: help.markup help.syntax ; +IN: parser-combinators HELP: list-of { $values diff --git a/extra/tools/profiler/profiler-docs.factor b/extra/tools/profiler/profiler-docs.factor index feb6abbbb1..a8c700b490 100644 --- a/extra/tools/profiler/profiler-docs.factor +++ b/extra/tools/profiler/profiler-docs.factor @@ -3,13 +3,13 @@ quotations io strings words definitions ; IN: tools.profiler ARTICLE: "profiling" "Profiling code" -"The " { $vocab-link "tools.profiler" } " vocabulary implements a simple call counting profiler. The profiler has three main limitations:" +"The " { $vocab-link "tools.profiler" } " vocabulary implements a simple call counting profiler. The profiler is completely accurate with words which are compiled with the non-optimizing compiler. Some optimizations performed by the optimizing compiler can inhibit accurate call counting, however:" { $list - "Calls to primitives are not counted." - { "Calls to " { $link POSTPONE: inline } " words from words compiled with the optimizing compiler are not counted." } - "Certain types of tail-recursive words compiled with the optimizing compiler will only count the initial invocation of the word, not every tail call." + "The optimizing compiler open-codes certain primitives with inline machine code, and in some cases optimizes them out altogether; this includes stack shuffling operations, conditionals, and many object allocation operations." + { "Calls to " { $link POSTPONE: inline } " words are not counted.." } + "Tail-recursive loops will only count the initial invocation of the word, not every tail call." } -"Quotations can be passed to a combinator which calls them with word call counting enabled:" +"Quotations can be passed to a combinator which calls them with the profiler enabled:" { $subsection profile } "After a quotation has been profiled, call counts can be presented in various ways:" { $subsection profile. }