From: John Benediktsson Date: Tue, 25 Jan 2022 17:33:49 +0000 (-0800) Subject: core/basis/extra: using STARTUP-HOOK: and SHUTDOWN-HOOK: X-Git-Tag: 0.99~1680 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=288d7e4a7aecc6dc0cd53656c26caf72a872fe2c core/basis/extra: using STARTUP-HOOK: and SHUTDOWN-HOOK: --- diff --git a/basis/channels/remote/remote.factor b/basis/channels/remote/remote.factor index ef0b3b15f1..2ba2da0a43 100644 --- a/basis/channels/remote/remote.factor +++ b/basis/channels/remote/remote.factor @@ -66,7 +66,7 @@ M: remote-channel to M: remote-channel from [ id>> from-message boa ] keep send-message ; -[ +STARTUP-HOOK: [ H{ } clone \ remote-channels set-global start-channel-node -] "channel-registry" add-startup-hook +] diff --git a/basis/cocoa/cocoa.factor b/basis/cocoa/cocoa.factor index 708381f633..01ee91007f 100644 --- a/basis/cocoa/cocoa.factor +++ b/basis/cocoa/cocoa.factor @@ -38,7 +38,7 @@ SYMBOL: frameworks frameworks [ V{ } clone ] initialize -[ frameworks get [ load-framework ] each ] "cocoa" add-startup-hook +STARTUP-HOOK: [ frameworks get [ load-framework ] each ] SYNTAX: FRAMEWORK: scan-token [ load-framework ] [ frameworks get push ] bi ; diff --git a/basis/command-line/command-line.factor b/basis/command-line/command-line.factor index 0bf66894f0..48518fe9d8 100644 --- a/basis/command-line/command-line.factor +++ b/basis/command-line/command-line.factor @@ -101,9 +101,9 @@ SYMBOL: main-vocab-hook main-vocab "run" set ] with-global ; -[ +STARTUP-HOOK: [ H{ } user-init-errors set-global default-cli-args -] "command-line" add-startup-hook +] { "debugger" "command-line" } "command-line.debugger" require-when diff --git a/basis/concurrency/distributed/distributed.factor b/basis/concurrency/distributed/distributed.factor index 8f3524697d..45afe537c1 100644 --- a/basis/concurrency/distributed/distributed.factor +++ b/basis/concurrency/distributed/distributed.factor @@ -77,7 +77,7 @@ M: thread (serialize) : stop-node ( -- ) f local-node get insecure>> send-remote-message ; -[ +STARTUP-HOOK: [ H{ } clone \ registered-remote-threads set-global H{ } clone \ thread-connections set-global -] "remote-thread-registry" add-startup-hook +] diff --git a/basis/core-foundation/fsevents/fsevents.factor b/basis/core-foundation/fsevents/fsevents.factor index fb216f55c4..c63ec926b2 100644 --- a/basis/core-foundation/fsevents/fsevents.factor +++ b/basis/core-foundation/fsevents/fsevents.factor @@ -174,10 +174,10 @@ SYMBOL: event-stream-callbacks : event-stream-counter ( -- n ) \ event-stream-counter counter ; -[ +STARTUP-HOOK: [ event-stream-callbacks [ [ drop expired? ] H{ } assoc-reject-as ] change-global -] "core-foundation" add-startup-hook +] : add-event-source-callback ( quot -- id ) event-stream-counter diff --git a/basis/core-foundation/run-loop/run-loop.factor b/basis/core-foundation/run-loop/run-loop.factor index fbd1ab4b5b..666d1043c4 100644 --- a/basis/core-foundation/run-loop/run-loop.factor +++ b/basis/core-foundation/run-loop/run-loop.factor @@ -102,8 +102,8 @@ SYMBOL: run-loop ] change-timers drop ; SYMBOL: thread-timer -[ f thread-timer set-global ] -"core-foundation.run-loop" add-startup-hook + +STARTUP-HOOK: [ f thread-timer set-global ] : (reset-thread-timer) ( timer -- ) sleep-time diff --git a/basis/core-text/core-text.factor b/basis/core-text/core-text.factor index 9b98890c80..fc5b9c7d6f 100644 --- a/basis/core-text/core-text.factor +++ b/basis/core-text/core-text.factor @@ -172,4 +172,4 @@ SYMBOL: cached-lines : cached-line ( font string -- line ) cached-lines get-global [ ] 2cache ; -[ cached-lines set-global ] "core-text" add-startup-hook +STARTUP-HOOK: [ cached-lines set-global ] diff --git a/basis/core-text/fonts/fonts.factor b/basis/core-text/fonts/fonts.factor index a91a52bf04..3900fc3823 100644 --- a/basis/core-text/fonts/fonts.factor +++ b/basis/core-text/fonts/fonts.factor @@ -118,7 +118,7 @@ MEMO: (cache-font-metrics) ( name size traits -- metrics ) : cache-font-metrics ( font -- metrics ) [ name>> ] [ size>> ] [ font-traits ] tri (cache-font-metrics) ; -[ +STARTUP-HOOK: [ \ (cache-font) reset-memoized \ (cache-font-metrics) reset-memoized -] "core-text.fonts" add-startup-hook +] diff --git a/basis/cpu/x86/features/features.factor b/basis/cpu/x86/features/features.factor index 3091620e93..358b87145a 100644 --- a/basis/cpu/x86/features/features.factor +++ b/basis/cpu/x86/features/features.factor @@ -164,8 +164,9 @@ HOOK: (cpuid) cpu ( rax rcx regs -- ) MEMO: enable-popcnt? ( -- ? ) popcnt? "disable-popcnt" get not and ; -[ { sse-version enable-popcnt? } [ reset-memoized ] each ] -"cpu.x86.features" add-startup-hook +STARTUP-HOOK: [ + { sse-version enable-popcnt? } [ reset-memoized ] each +] : sse-string ( version -- string ) { diff --git a/basis/environment/environment.factor b/basis/environment/environment.factor index f945d2933c..4647fb4578 100644 --- a/basis/environment/environment.factor +++ b/basis/environment/environment.factor @@ -34,10 +34,9 @@ HOOK: set-os-envs-pointer os ( malloc -- ) { [ os windows? ] [ "environment.windows" require ] } } cond -[ - "FACTOR_ROOTS" os-env - [ +STARTUP-HOOK: [ + "FACTOR_ROOTS" os-env [ os windows? ";" ":" ? split [ add-vocab-root ] each ] when* -] "environment" add-startup-hook +] diff --git a/basis/game/input/input.factor b/basis/game/input/input.factor index 204de8b9d7..3f92333cc5 100644 --- a/basis/game/input/input.factor +++ b/basis/game/input/input.factor @@ -36,10 +36,10 @@ M: f (reset-game-input) ; : reset-game-input ( -- ) (reset-game-input) ; -[ reset-game-input ] "game-input" add-startup-hook - PRIVATE> +STARTUP-HOOK: reset-game-input + ERROR: game-input-not-open ; : open-game-input ( -- ) @@ -48,6 +48,7 @@ ERROR: game-input-not-open ; ] unless game-input-opened [ 1 + ] change-global reset-mouse ; + : close-game-input ( -- ) game-input-opened [ dup zero? [ game-input-not-open ] when diff --git a/basis/io/backend/unix/freebsd/freebsd.factor b/basis/io/backend/unix/freebsd/freebsd.factor index 9c094679dc..38a66e0467 100644 --- a/basis/io/backend/unix/freebsd/freebsd.factor +++ b/basis/io/backend/unix/freebsd/freebsd.factor @@ -7,5 +7,4 @@ M: freebsd init-io freebsd set-io-backend -[ start-signal-pipe-thread ] -"io.backend.unix:signal-pipe-thread" add-startup-hook +STARTUP-HOOK: start-signal-pipe-thread diff --git a/basis/io/backend/unix/linux/linux.factor b/basis/io/backend/unix/linux/linux.factor index f3e123cd84..b52dba1a79 100644 --- a/basis/io/backend/unix/linux/linux.factor +++ b/basis/io/backend/unix/linux/linux.factor @@ -10,4 +10,4 @@ M: linux init-io linux set-io-backend -[ start-signal-pipe-thread ] "io.backend.unix:signal-pipe-thread" add-startup-hook +STARTUP-HOOK: start-signal-pipe-thread diff --git a/basis/io/backend/unix/macosx/macosx.factor b/basis/io/backend/unix/macosx/macosx.factor index 403b97b0ac..a87656238a 100644 --- a/basis/io/backend/unix/macosx/macosx.factor +++ b/basis/io/backend/unix/macosx/macosx.factor @@ -16,5 +16,4 @@ M: macosx init-io macosx set-io-backend -[ start-signal-pipe-thread ] -"io.backend.unix:signal-pipe-thread" add-startup-hook +STARTUP-HOOK: start-signal-pipe-thread diff --git a/basis/io/files/temp/temp.factor b/basis/io/files/temp/temp.factor index b1c18725c1..f6eb7b9f96 100644 --- a/basis/io/files/temp/temp.factor +++ b/basis/io/files/temp/temp.factor @@ -36,10 +36,10 @@ SYMBOL: current-cache-directory { [ os unix? ] [ "io.files.temp.unix" ] } } cond require -[ +STARTUP-HOOK: [ default-temp-directory dup make-directories current-temp-directory set-global default-cache-directory dup make-directories current-cache-directory set-global -] "io.files.temp" add-startup-hook +] diff --git a/basis/io/launcher/launcher.factor b/basis/io/launcher/launcher.factor index f82929fd15..7e5aac1e45 100644 --- a/basis/io/launcher/launcher.factor +++ b/basis/io/launcher/launcher.factor @@ -93,10 +93,10 @@ SYMBOL: wait-delay 5 wait-delay set-global [ wait-loop t ] "Process wait" spawn-server drop ; -[ +STARTUP-HOOK: [ H{ } clone processes set-global start-wait-thread -] "io.launcher" add-startup-hook +] : process-started ( process handle -- ) >>handle diff --git a/basis/io/sockets/sockets.factor b/basis/io/sockets/sockets.factor index 65e915b7f6..8c40b0d980 100644 --- a/basis/io/sockets/sockets.factor +++ b/basis/io/sockets/sockets.factor @@ -382,8 +382,7 @@ CONSTANT: datagram-size 65536 MEMO: ipv6-supported? ( -- ? ) [ "::1" 0 binary dispose t ] [ drop f ] recover ; -[ \ ipv6-supported? reset-memoized ] -"io.sockets:ipv6-supported?" add-startup-hook +STARTUP-HOOK: [ \ ipv6-supported? reset-memoized ] GENERIC: resolve-host ( addrspec -- seq ) diff --git a/basis/io/thread/thread.factor b/basis/io/thread/thread.factor index 8c069f440c..50a71ea04d 100644 --- a/basis/io/thread/thread.factor +++ b/basis/io/thread/thread.factor @@ -27,4 +27,4 @@ M: io-thread error-in-thread die drop rethrow ; : stop-io-thread ( -- ) f io-thread-running? set-global ; -[ start-io-thread ] "io.thread" add-startup-hook +STARTUP-HOOK: start-io-thread diff --git a/basis/logging/server/server.factor b/basis/logging/server/server.factor index 7326ea4b7c..a66697f1ea 100644 --- a/basis/logging/server/server.factor +++ b/basis/logging/server/server.factor @@ -105,7 +105,7 @@ CONSTANT: keep-logs 10 "Log server" spawn-server "log-server" set-global ; -[ +STARTUP-HOOK: [ H{ } clone log-files set-global log-server -] "logging" add-startup-hook +] diff --git a/basis/opengl/gl/extensions/extensions.factor b/basis/opengl/gl/extensions/extensions.factor index 4fbf78bac2..a3728d5175 100644 --- a/basis/opengl/gl/extensions/extensions.factor +++ b/basis/opengl/gl/extensions/extensions.factor @@ -19,7 +19,8 @@ SYMBOL: +gl-function-pointers+ : reset-gl-function-pointers ( -- ) 100 +gl-function-pointers+ set-global ; -[ reset-gl-function-pointers ] "opengl.gl" add-startup-hook +STARTUP-HOOK: reset-gl-function-pointers + reset-gl-function-pointers reset-gl-function-number-counter diff --git a/basis/opengl/opengl.factor b/basis/opengl/opengl.factor index ff2b36c50a..bb63cab678 100644 --- a/basis/opengl/opengl.factor +++ b/basis/opengl/opengl.factor @@ -253,4 +253,4 @@ MACRO: set-draw-buffers ( buffers -- quot ) GL_MODELVIEW glMatrixMode glLoadIdentity ; -[ f gl-scale-factor set-global ] "opengl" add-startup-hook +STARTUP-HOOK: [ f gl-scale-factor set-global ] diff --git a/basis/openssl/openssl.factor b/basis/openssl/openssl.factor index de15c2c97a..977f8d0f30 100644 --- a/basis/openssl/openssl.factor +++ b/basis/openssl/openssl.factor @@ -45,4 +45,4 @@ SINGLETON: openssl t ssl-initialized? set-global ] unless ; -[ f ssl-initialized? set-global ] "openssl" add-startup-hook +STARTUP-HOOK: [ f ssl-initialized? set-global ] diff --git a/basis/random/mersenne-twister/mersenne-twister.factor b/basis/random/mersenne-twister/mersenne-twister.factor index e93a264013..1e33514143 100644 --- a/basis/random/mersenne-twister/mersenne-twister.factor +++ b/basis/random/mersenne-twister/mersenne-twister.factor @@ -74,6 +74,6 @@ M: mersenne-twister random-32* : default-mersenne-twister ( -- mersenne-twister ) nano-count ; -[ +STARTUP-HOOK: [ default-mersenne-twister random-generator set-global -] "bootstrap.random" add-startup-hook +] diff --git a/basis/random/unix/unix.factor b/basis/random/unix/unix.factor index 060d1afe50..ab723bb7e0 100644 --- a/basis/random/unix/unix.factor +++ b/basis/random/unix/unix.factor @@ -17,7 +17,10 @@ M: unix-random random-bytes* HINTS: M\ unix-random random-bytes* { fixnum unix-random } ; -[ - "/dev/random" &dispose secure-random-generator set-global - "/dev/urandom" &dispose system-random-generator set-global -] "random.unix" add-startup-hook +STARTUP-HOOK: [ + "/dev/random" &dispose + secure-random-generator set-global + + "/dev/urandom" &dispose + system-random-generator set-global +] diff --git a/basis/random/windows/windows.factor b/basis/random/windows/windows.factor index a4611bf1bf..9f9aded4fb 100644 --- a/basis/random/windows/windows.factor +++ b/basis/random/windows/windows.factor @@ -56,7 +56,7 @@ M: windows-crypto-context random-bytes* [ first2 ] attempt-all ] [ 2drop f ] recover ; -[ +STARTUP-HOOK: [ { ${ MS_ENHANCED_PROV PROV_RSA_FULL } ${ MS_DEF_PROV PROV_RSA_FULL } @@ -66,4 +66,4 @@ M: windows-crypto-context random-bytes* ${ MS_STRONG_PROV PROV_RSA_FULL } ${ MS_ENH_RSA_AES_PROV PROV_RSA_AES } } try-crypto-providers secure-random-generator set-global -] "random.windows" add-startup-hook +] diff --git a/basis/threads/threads.factor b/basis/threads/threads.factor index c48a69ed87..c4ce4387fa 100644 --- a/basis/threads/threads.factor +++ b/basis/threads/threads.factor @@ -262,4 +262,4 @@ M: real sleep PRIVATE> -[ init-threads ] "threads" add-startup-hook +STARTUP-HOOK: init-threads diff --git a/basis/tools/crossref/crossref.factor b/basis/tools/crossref/crossref.factor index 3183f4ddae..66b48c2566 100644 --- a/basis/tools/crossref/crossref.factor +++ b/basis/tools/crossref/crossref.factor @@ -146,6 +146,6 @@ M: invalidate-crossref definitions-changed drop [ null? not ] [ not ] bi or [ f crossref set-global ] when ; -[ invalidate-crossref add-definition-observer ] "tools.crossref" add-startup-hook +STARTUP-HOOK: [ invalidate-crossref add-definition-observer ] PRIVATE> diff --git a/basis/tools/deprecation/deprecation.factor b/basis/tools/deprecation/deprecation.factor index c73d345a08..9d28480917 100644 --- a/basis/tools/deprecation/deprecation.factor +++ b/basis/tools/deprecation/deprecation.factor @@ -75,7 +75,6 @@ M: deprecation-observer definitions-changed [ [ check-deprecations ] each ] [ drop initialize-deprecation-notes ] if ; -[ deprecation-observer add-definition-observer ] -"tools.deprecation" add-startup-hook +STARTUP-HOOK: [ deprecation-observer add-definition-observer ] initialize-deprecation-notes diff --git a/basis/ui/text/pango/pango.factor b/basis/ui/text/pango/pango.factor index 38f285e80d..0714298d30 100644 --- a/basis/ui/text/pango/pango.factor +++ b/basis/ui/text/pango/pango.factor @@ -204,9 +204,9 @@ M: pango-renderer line-metrics [ cached-layout metrics>> ] if-empty ; -[ +STARTUP-HOOK: [ \ (cache-font-description) reset-memoized cached-layouts set-global -] "ui.text.pango" add-startup-hook +] pango-renderer font-renderer set-global diff --git a/basis/ui/tools/error-list/error-list.factor b/basis/ui/tools/error-list/error-list.factor index 0ac48742e5..05a1ead524 100644 --- a/basis/ui/tools/error-list/error-list.factor +++ b/basis/ui/tools/error-list/error-list.factor @@ -204,7 +204,7 @@ M: error-list-updater errors-changed \ show-error-list H{ { +nullary+ t } } define-command -[ +STARTUP-HOOK: [ f 100 milliseconds error-list-model set-global error-list-updater add-error-observer -] "ui.tools.error-list" add-startup-hook +] diff --git a/basis/ui/ui.factor b/basis/ui/ui.factor index 378e46907e..93abb0ba96 100644 --- a/basis/ui/ui.factor +++ b/basis/ui/ui.factor @@ -208,10 +208,10 @@ HOOK: close-window ui-backend ( gadget -- ) M: object close-window find-world [ ungraft ] when* ; -[ +STARTUP-HOOK: [ f ui-running set-global ui-notify-flag set-global -] "ui" add-startup-hook +] HOOK: resize-window ui-backend ( world dim -- ) M: object resize-window 2drop ; diff --git a/basis/vocabs/cache/cache.factor b/basis/vocabs/cache/cache.factor index 7a09dc4a8a..6a369d961c 100644 --- a/basis/vocabs/cache/cache.factor +++ b/basis/vocabs/cache/cache.factor @@ -34,7 +34,7 @@ M: cache-observer vocab-changed drop dup forgot-vocab? [ reset-vocab-cache ] [ drop ] if reset-disk-cache ; -[ +STARTUP-HOOK: [ f changed-vocabs set-global cache-observer add-vocab-observer -] "vocabs.cache" add-startup-hook +] diff --git a/basis/vocabs/refresh/monitor/monitor.factor b/basis/vocabs/refresh/monitor/monitor.factor index 3186c2e352..6e72df2b15 100644 --- a/basis/vocabs/refresh/monitor/monitor.factor +++ b/basis/vocabs/refresh/monitor/monitor.factor @@ -65,7 +65,7 @@ TR: convert-separators "/\\" ".." ; HS{ } clone changed-vocabs set-global loaded-vocab-names [ changed-vocab ] each ; -[ +STARTUP-HOOK: [ "-no-monitors" (command-line) member? [ [ drop ] add-vocab-root-hook set-global f changed-vocabs set-global @@ -74,4 +74,4 @@ TR: convert-separators "/\\" ".." ; vocab-roots get [ start-vocab-monitor ] each [ start-vocab-monitor ] add-vocab-root-hook set-global ] if -] "vocabs.refresh.monitor" add-startup-hook +] diff --git a/basis/windows/com/wrapper/wrapper.factor b/basis/windows/com/wrapper/wrapper.factor index 93cfe8f5f2..2f333b1004 100644 --- a/basis/windows/com/wrapper/wrapper.factor +++ b/basis/windows/com/wrapper/wrapper.factor @@ -140,7 +140,7 @@ unless +live-wrappers+ get-global [ (allocate-wrapper) ] each H{ } +wrapped-objects+ set-global ; -[ com-startup-hook ] "windows.com.wrapper" add-startup-hook +STARTUP-HOOK: com-startup-hook PRIVATE> diff --git a/basis/windows/directx/dinput/constants/constants.factor b/basis/windows/directx/dinput/constants/constants.factor index f7ab901417..5d95d6ae93 100644 --- a/basis/windows/directx/dinput/constants/constants.factor +++ b/basis/windows/directx/dinput/constants/constants.factor @@ -832,7 +832,7 @@ MACRO: ( dwFlags dwDataSize struct rgodf-array -- alien ) define-guid-constants define-format-constants ; -[ define-constants ] "windows.directx.dinput.constants" add-startup-hook +STARTUP-HOOK: define-constants : uninitialize ( variable quot -- ) '[ _ when* f ] change-global ; inline diff --git a/basis/windows/dropfiles/dropfiles.factor b/basis/windows/dropfiles/dropfiles.factor index 1c0e1dde48..0074f44716 100644 --- a/basis/windows/dropfiles/dropfiles.factor +++ b/basis/windows/dropfiles/dropfiles.factor @@ -62,6 +62,4 @@ IN: windows.dropfiles : reject-files ( -- ) world get world-reject-files ; -[ - f \ init-message-filter set-global -] "init-dropfiles" add-startup-hook +STARTUP-HOOK: [ f \ init-message-filter set-global ] diff --git a/basis/windows/fonts/fonts.factor b/basis/windows/fonts/fonts.factor index 8e61d2989a..8b09cd214d 100644 --- a/basis/windows/fonts/fonts.factor +++ b/basis/windows/fonts/fonts.factor @@ -39,10 +39,10 @@ MEMO:: (cache-font) ( name size bold? italic? -- HFONT ) { [ name>> ] [ size>> ] [ bold?>> ] [ italic?>> ] } cleave (cache-font) ; -[ +STARTUP-HOOK: [ \ (cache-font) reset-memoized \ windows-fonts reset-memoized -] "windows.fonts" add-startup-hook +] : TEXTMETRIC>metrics ( TEXTMETRIC -- metrics ) [ metrics new 0 >>width ] dip { diff --git a/basis/windows/gdiplus/gdiplus.factor b/basis/windows/gdiplus/gdiplus.factor index c7843d4f8e..607daa704d 100644 --- a/basis/windows/gdiplus/gdiplus.factor +++ b/basis/windows/gdiplus/gdiplus.factor @@ -1651,5 +1651,6 @@ DESTRUCTOR: stop-gdi+ SYMBOL: gdi-token -[ start-gdi+ gdi-token set-global ] "windows.gdiplus" add-startup-hook -[ gdi-token get-global [ stop-gdi+ ] when* ] "windows.gdiplus" add-shutdown-hook +STARTUP-HOOK: [ start-gdi+ gdi-token set-global ] + +SHUTDOWN-HOOK: [ gdi-token get-global [ stop-gdi+ ] when* ] diff --git a/basis/windows/uniscribe/uniscribe.factor b/basis/windows/uniscribe/uniscribe.factor index 326d17a9c0..299ef2f481 100644 --- a/basis/windows/uniscribe/uniscribe.factor +++ b/basis/windows/uniscribe/uniscribe.factor @@ -171,5 +171,4 @@ SYMBOL: cached-script-strings ] with-memory-dc ] unless image>> ; -[ cached-script-strings set-global ] -"windows.uniscribe" add-startup-hook +STARTUP-HOOK: [ cached-script-strings set-global ] diff --git a/basis/windows/winsock/winsock.factor b/basis/windows/winsock/winsock.factor index 7ac216e8ce..e548959c4f 100644 --- a/basis/windows/winsock/winsock.factor +++ b/basis/windows/winsock/winsock.factor @@ -526,5 +526,5 @@ ERROR: winsock-exception n string ; : shutdown-winsock ( -- ) WSACleanup winsock-return-check ; -[ init-winsock ] "windows.winsock" add-startup-hook -[ shutdown-winsock ] "windows.winsock" add-shutdown-hook +STARTUP-HOOK: init-winsock +SHUTDOWN-HOOK: shutdown-winsock diff --git a/core/alien/alien.factor b/core/alien/alien.factor index cb73df0c04..385fd606ae 100644 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -105,7 +105,7 @@ ERROR: callsite-not-compiled word ; ! cleared on startup. SYMBOL: callbacks -[ H{ } clone callbacks set-global ] "alien" add-startup-hook +STARTUP-HOOK: [ H{ } clone callbacks set-global ] ! Used by compiler.codegen to wrap callback bodies : do-callback ( callback-quot wait-quot: ( callback -- ) -- ) diff --git a/core/alien/strings/strings.factor b/core/alien/strings/strings.factor index 60b7eaa6ce..4202e10f5b 100644 --- a/core/alien/strings/strings.factor +++ b/core/alien/strings/strings.factor @@ -90,11 +90,11 @@ M: array symbol>string [ utf8 alien>string ] map ", " join ; : special-object>string ( n -- str ) special-object utf8 alien>string ; -[ +STARTUP-HOOK: [ OBJ-CPU special-object>string string>cpu \ cpu set-global OBJ-OS special-object>string string>os \ os set-global OBJ-VM-VERSION special-object>string \ vm-version set-global OBJ-VM-GIT-LABEL special-object>string \ vm-git-label set-global OBJ-VM-COMPILER special-object>string \ vm-compiler set-global OBJ-VM-COMPILE-TIME special-object>string \ vm-compile-time set-global -] "alien.strings" add-startup-hook +] diff --git a/core/compiler/units/units.factor b/core/compiler/units/units.factor index 3a50096a0b..07e2e23c21 100644 --- a/core/compiler/units/units.factor +++ b/core/compiler/units/units.factor @@ -91,12 +91,12 @@ SYMBOL: definition-observers GENERIC: definitions-changed ( set obj -- ) -[ V{ } clone definition-observers set-global ] -"compiler.units" add-startup-hook +STARTUP-HOOK: [ + V{ } clone definition-observers set-global -! This goes here because vocabs cannot depend on init -[ V{ } clone vocab-observers set-global ] -"vocabs" add-startup-hook + ! This goes here because vocabs cannot depend on init + V{ } clone vocab-observers set-global +] : add-definition-observer ( obj -- ) definition-observers get push ; diff --git a/core/destructors/destructors.factor b/core/destructors/destructors.factor index c50435fed1..acd6ef922d 100644 --- a/core/destructors/destructors.factor +++ b/core/destructors/destructors.factor @@ -90,13 +90,13 @@ PRIVATE> cleanup ] with-variables ; inline -[ +STARTUP-HOOK: [ HS{ } clone disposables set-global V{ } clone always-destructors set-global V{ } clone error-destructors set-global -] "destructors" add-startup-hook +] -[ +SHUTDOWN-HOOK: [ do-always-destructors do-error-destructors -] "destructors" add-shutdown-hook +] diff --git a/core/io/backend/backend.factor b/core/io/backend/backend.factor index 07d866b56a..b910e273dd 100644 --- a/core/io/backend/backend.factor +++ b/core/io/backend/backend.factor @@ -27,5 +27,4 @@ HOOK: normalize-path io-backend ( path -- path' ) io-backend set-global init-io init-stdio "io.files" startup-hooks get at call( -- ) ; -[ init-io embedded? [ init-stdio ] unless ] -"io.backend" add-startup-hook +STARTUP-HOOK: [ init-io embedded? [ init-stdio ] unless ] diff --git a/core/io/files/files.factor b/core/io/files/files.factor index 3190bc6884..da74c316c7 100644 --- a/core/io/files/files.factor +++ b/core/io/files/files.factor @@ -90,9 +90,9 @@ PRIVATE> ] map-find drop [ image-path parent-directory ] unless* "resource-path" set-global ; -[ +STARTUP-HOOK: [ cwd current-directory set-global OBJ-IMAGE special-object alien>native-string \ image-path set-global OBJ-EXECUTABLE special-object alien>native-string \ vm-path set-global init-resource-path -] "io.files" add-startup-hook +] diff --git a/core/source-files/errors/errors.factor b/core/source-files/errors/errors.factor index fd790dcb4c..4dbf64dd70 100644 --- a/core/source-files/errors/errors.factor +++ b/core/source-files/errors/errors.factor @@ -68,9 +68,7 @@ GENERIC: errors-changed ( observer -- ) SYMBOL: error-observers -[ - V{ } clone error-observers set-global -] "source-files.errors" add-startup-hook +STARTUP-HOOK: [ V{ } clone error-observers set-global ] : add-error-observer ( observer -- ) error-observers get push ; diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index 5c24341c45..5814657aee 100644 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -16,11 +16,10 @@ CONSTANT: default-vocab-roots { "resource:work" } -[ +STARTUP-HOOK: [ default-vocab-roots V{ } like vocab-roots set-global - [ drop ] add-vocab-root-hook set-global -] "vocabs.loader" add-startup-hook +] : add-vocab-root ( root -- ) trim-tail-separators dup vocab-roots get ?adjoin diff --git a/extra/audio/gadget/gadget.factor b/extra/audio/gadget/gadget.factor index 7ef80c9340..dbf194ba32 100644 --- a/extra/audio/gadget/gadget.factor +++ b/extra/audio/gadget/gadget.factor @@ -16,11 +16,11 @@ CONSTANT: pause-label-image-path "vocab:audio/gadget/pause.png" SYMBOLS: play-label-image pause-label-image gadget-audio-engine ; -[ +STARTUP-HOOK: [ f play-label-image set-global f pause-label-image set-global f gadget-audio-engine set-global -] "audio.gadget" add-startup-hook +] : initialize-audio-gadgets ( -- ) gadget-audio-engine get-global [ diff --git a/extra/mason/updates/updates.factor b/extra/mason/updates/updates.factor index d92d307e94..f75cdf74b6 100644 --- a/extra/mason/updates/updates.factor +++ b/extra/mason/updates/updates.factor @@ -10,10 +10,10 @@ C: sources SYMBOLS: latest-sources last-built-sources ; -[ +STARTUP-HOOK: [ f latest-sources set-global f last-built-sources set-global -] "mason.updates" add-startup-hook +] : latest-boot-image ( -- boot-image ) target-boot-image-name diff --git a/extra/python/python.factor b/extra/python/python.factor index 0a20ed6d4e..fa6f41db96 100644 --- a/extra/python/python.factor +++ b/extra/python/python.factor @@ -115,5 +115,5 @@ ERROR: missing-type type ; : python-dll-loaded? ( -- ? ) "Py_IsInitialized" "python" dlsym? ; -[ python-dll-loaded? [ py-initialize ] when ] "python" add-startup-hook -[ python-dll-loaded? [ py-finalize ] when ] "python" add-shutdown-hook +STARTUP-HOOK: [ python-dll-loaded? [ py-initialize ] when ] +SHUTDOWN-HOOK: [ python-dll-loaded? [ py-finalize ] when ] diff --git a/extra/site-watcher/site-watcher.factor b/extra/site-watcher/site-watcher.factor index 16deccc8ee..b287ad653f 100644 --- a/extra/site-watcher/site-watcher.factor +++ b/extra/site-watcher/site-watcher.factor @@ -9,7 +9,7 @@ SYMBOL: site-watcher-frequency 5 minutes site-watcher-frequency set-global SYMBOL: running-site-watcher -[ f running-site-watcher set-global ] "site-watcher" add-startup-hook +STARTUP-HOOK: [ f running-site-watcher set-global ]