From cbdd80277ee2ba0e59b98566cbdad944805dd177 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 20 Jun 2016 16:08:58 -0700 Subject: [PATCH] factor: CLASS: ; to CLASS< CLASS>. More cleanups --- core/modern/modern.factor | 5 ++--- ffi/cocoa/cocoa-tests.factor | 12 ++++++------ ffi/cocoa/subclassing/subclassing-docs.factor | 14 +++++++------- ffi/cocoa/subclassing/subclassing.factor | 6 ++++-- .../game/input/demos/key-caps/key-caps.factor | 4 ++-- frameworks/game/input/scancodes/scancodes.factor | 2 +- frameworks/gpu/util/util.factor | 4 ++-- frameworks/ui/backend/cocoa/cocoa.factor | 4 ++-- frameworks/ui/backend/cocoa/tools/tools.factor | 8 ++++---- frameworks/ui/backend/cocoa/views/views.factor | 9 +++++---- frameworks/ui/gadgets/frames/frames.factor | 6 +++--- tools/pdf/values/values.factor | 2 +- tools/text-to-pdf/text-to-pdf.factor | 2 +- tools/tools/completion/completion.factor | 4 ++-- tools/tools/deploy/test/14/14.factor | 4 ++-- 15 files changed, 44 insertions(+), 42 deletions(-) diff --git a/core/modern/modern.factor b/core/modern/modern.factor index 320bf8cfe7..c4da4312ec 100644 --- a/core/modern/modern.factor +++ b/core/modern/modern.factor @@ -539,12 +539,11 @@ CONSTANT: factor-lexing-rules { ! } case ; inline ![[ - vocab-roots get [ vocabs-from reject-some-paths ] map concat { "specialized-arrays" "specialized-vectors" "math.blas.matrices" "math.blas.vectors" "math.vectors.simd" - "math.vectors.simd.cords" + "math.vectors.simd.cords" "game.debug" } diff -[ modern-source-path dup . path>literals ] map-zip +[ modern-source-path dup . path>literals ] map-zip ]] \ No newline at end of file diff --git a/ffi/cocoa/cocoa-tests.factor b/ffi/cocoa/cocoa-tests.factor index b4ac0eb94a..785d2762b4 100644 --- a/ffi/cocoa/cocoa-tests.factor +++ b/ffi/cocoa/cocoa-tests.factor @@ -3,11 +3,11 @@ cocoa.types compiler.test core-graphics.types kernel math memory namespaces tools.test ; in: cocoa.tests -CLASS: Foo < NSObject +CLASS< Foo < NSObject METHOD: void foo: NSRect rect [ gc rect "x" set ] ; -; +CLASS> : test-foo ( -- ) Foo send\ alloc send\ init @@ -21,9 +21,9 @@ CLASS: Foo < NSObject { 101.0 } [ "x" get CGRect-w ] unit-test { 102.0 } [ "x" get CGRect-h ] unit-test -CLASS: Bar < NSObject +CLASS< Bar < NSObject METHOD: NSRect bar [ test-foo "x" get ] ; -; +CLASS> { } [ Bar [ @@ -39,11 +39,11 @@ CLASS: Bar < NSObject { 102.0 } [ "x" get CGRect-h ] unit-test ! Make sure that we can add methods -CLASS: Bar < NSObject +CLASS< Bar < NSObject METHOD: NSRect bar [ test-foo "x" get ] ; METHOD: int babb: int x [ x sq ] ; -; +CLASS> { 144 } [ Bar [ diff --git a/ffi/cocoa/subclassing/subclassing-docs.factor b/ffi/cocoa/subclassing/subclassing-docs.factor index 64111d4724..f3954eac9d 100644 --- a/ffi/cocoa/subclassing/subclassing-docs.factor +++ b/ffi/cocoa/subclassing/subclassing-docs.factor @@ -1,23 +1,23 @@ USING: help.markup help.syntax strings alien hashtables ; in: cocoa.subclassing -HELP: \ CLASS: -{ $syntax "CLASS: name < superclass protocols... imeth... ;" } -{ $values { "name" "a new class name" } { "superclass" "a superclass name" } { "protocols" "zero or more protocol names" } { "imeth" "instance method definitions using " { $link postpone\ METHOD: } } } -{ $description "Defines a new Objective C class. Instance methods are defined with the " { $link postpone\ METHOD: } " parsing word." +HELP: \ CLASS< +{ $syntax "CLASS< name < superclass protocols... imeth... CLASS>" } +{ $values { "name" "a new class name" } { "superclass" "a superclass name" } { "protocols" "zero or more protocol names" } { "imeth" "instance method definitions using " { $link \ METHOD: } } } +{ $description "Defines a new Objective C class. Instance methods are defined with the " { $link \ METHOD: } " parsing word." $nl "This word is preferred to calling " { $link define-objc-class } ", because it creates a class word in the " { $vocab-link "cocoa.classes" } " vocabulary at parse time, allowing code to refer to the class word in the same source file where the class is defined." } ; -{ define-objc-class postpone\ CLASS: postpone\ METHOD: } related-words +{ define-objc-class \ CLASS< \ METHOD: } related-words HELP: \ METHOD: { $syntax "METHOD: return foo: type1 arg1 bar: type2 arg2 baz: ... [ body ] ;" } { $values { "return" "a C type name" } { "type1" "a C type name" } { "arg1" "a local variable name" } { "body" "arbitrary code" } } -{ $description "Defines a method inside of a " { $link postpone\ CLASS: } " form." } ; +{ $description "Defines a method inside of a " { $link \ CLASS< } " form." } ; ARTICLE: "objc-subclassing" "Subclassing Objective C classes" "Objective C classes can be subclassed, with new methods defined in Factor, using parsing words:" -{ $subsections postpone\ CLASS: postpone\ METHOD: } +{ $subsections \ CLASS< \ METHOD: } "Objective C class definitions are saved in the image. If the image is saved and Factor is restarted with the saved image, custom class definitions are made available to the Objective C runtime when they are first accessed from within Factor." ; about: "objc-subclassing" diff --git a/ffi/cocoa/subclassing/subclassing.factor b/ffi/cocoa/subclassing/subclassing.factor index 6467a5a27c..abad5b5cfd 100644 --- a/ffi/cocoa/subclassing/subclassing.factor +++ b/ffi/cocoa/subclassing/subclassing.factor @@ -74,11 +74,13 @@ C: cocoa-protocol ; SYNTAX: \ cocoa-protocol: scan-token suffix! ; -SYNTAX: \ CLASS: +defer: \ CLASS> delimiter + +SYNTAX: \ CLASS< scan-token "<" expect scan-token - \ ; parse-until [ cocoa-protocol? ] partition + \ CLASS> parse-until [ cocoa-protocol? ] partition [ [ name>> ] map ] dip define-objc-class ; : (parse-selector) ( -- ) diff --git a/frameworks/game/input/demos/key-caps/key-caps.factor b/frameworks/game/input/demos/key-caps/key-caps.factor index e636013e4a..7d2f93cc8c 100644 --- a/frameworks/game/input/demos/key-caps/key-caps.factor +++ b/frameworks/game/input/demos/key-caps/key-caps.factor @@ -51,7 +51,7 @@ CONSTANT: key-locations H{ { key-p { { 105 25 } { 10 10 } } } { key-lbracket { { 115 25 } { 10 10 } } } { key-rbracket { { 125 25 } { 10 10 } } } - { key-\ { { 135 25 } { 15 10 } } } + { \ key-\ { { 135 25 } { 15 10 } } } { key-caps-lock { { 0 35 } { 20 10 } } } { key-a { { 20 35 } { 10 10 } } } @@ -63,7 +63,7 @@ CONSTANT: key-locations H{ { key-j { { 80 35 } { 10 10 } } } { key-k { { 90 35 } { 10 10 } } } { key-l { { 100 35 } { 10 10 } } } - { key-; { { 110 35 } { 10 10 } } } + { key-semi { { 110 35 } { 10 10 } } } { key-' { { 120 35 } { 10 10 } } } { key-return { { 130 35 } { 20 10 } } } diff --git a/frameworks/game/input/scancodes/scancodes.factor b/frameworks/game/input/scancodes/scancodes.factor index 83908d486b..834e174d85 100644 --- a/frameworks/game/input/scancodes/scancodes.factor +++ b/frameworks/game/input/scancodes/scancodes.factor @@ -51,7 +51,7 @@ CONSTANT: key-lbracket 0x002f ; CONSTANT: key-rbracket 0x0030 ; CONSTANT: key-\ 0x0031 ; CONSTANT: key-#-non-us 0x0032 ; -CONSTANT: key-; 0x0033 ; +CONSTANT: key-semi 0x0033 ; CONSTANT: key-' 0x0034 ; CONSTANT: key-backtick 0x0035 ; CONSTANT: key-, 0x0036 ; diff --git a/frameworks/gpu/util/util.factor b/frameworks/gpu/util/util.factor index f8fc0b0243..e507ff59bf 100644 --- a/frameworks/gpu/util/util.factor +++ b/frameworks/gpu/util/util.factor @@ -44,7 +44,7 @@ CONSTANT: environment-cube-map-mv-matrices { 0.0 0.0 1.0 0.0 } { 0.0 0.0 0.0 1.0 } } } - } + } ; GLSL-SHADER: window-vertex-shader vertex-shader attribute vec2 vertex; @@ -104,7 +104,7 @@ CONSTANT: window-vertexes -1.0 1.0 1.0 -1.0 1.0 1.0 - } + } ; : ( -- buffer ) window-vertexes diff --git a/frameworks/ui/backend/cocoa/cocoa.factor b/frameworks/ui/backend/cocoa/cocoa.factor index f145d0bd89..6560069a22 100644 --- a/frameworks/ui/backend/cocoa/cocoa.factor +++ b/frameworks/ui/backend/cocoa/cocoa.factor @@ -201,9 +201,9 @@ M: cocoa-ui-backend system-alert } cleave ] [ 2drop ] if* ; -CLASS: FactorApplicationDelegate < NSObject +CLASS< FactorApplicationDelegate < NSObject METHOD: void applicationDidUpdate: id obj [ reset-thread-timer ] ; -; +CLASS> : install-app-delegate ( -- ) NSApp FactorApplicationDelegate install-delegate ; diff --git a/frameworks/ui/backend/cocoa/tools/tools.factor b/frameworks/ui/backend/cocoa/tools/tools.factor index 696515ca06..5bc338ec1b 100644 --- a/frameworks/ui/backend/cocoa/tools/tools.factor +++ b/frameworks/ui/backend/cocoa/tools/tools.factor @@ -21,7 +21,7 @@ in: ui.backend.cocoa.tools image-path save-panel [ save-image ] when* ; ! Handle Open events from the Finder -CLASS: FactorWorkspaceApplicationDelegate < FactorApplicationDelegate +CLASS< FactorWorkspaceApplicationDelegate < FactorApplicationDelegate METHOD: void application: id app openFiles: id files [ files finder-run-files ] ; @@ -46,7 +46,7 @@ CLASS: FactorWorkspaceApplicationDelegate < FactorApplicationDelegate METHOD: id switchDarkTheme: id app [ dark-mode f ] ; METHOD: id refreshAll: id app [ [ refresh-all ] \ refresh-all call-listener f ] ; -; +CLASS> : install-app-delegate ( -- ) NSApp FactorWorkspaceApplicationDelegate install-delegate ; @@ -57,7 +57,7 @@ CLASS: FactorWorkspaceApplicationDelegate < FactorApplicationDelegate dup [ quot call( string -- result/f ) ] when [ pboard set-pasteboard-string ] when* ; -CLASS: FactorServiceProvider < NSObject +CLASS< FactorServiceProvider < NSObject METHOD: void evalInListener: id pboard userData: id userData error: id error [ pboard error [ eval-listener f ] do-service ] ; @@ -67,7 +67,7 @@ CLASS: FactorServiceProvider < NSObject pboard error [ [ (eval>string) ] with-interactive-vocabs ] do-service ] ; -; +CLASS> : register-services ( -- ) NSApp diff --git a/frameworks/ui/backend/cocoa/views/views.factor b/frameworks/ui/backend/cocoa/views/views.factor index b25b49759e..b24b31edb3 100644 --- a/frameworks/ui/backend/cocoa/views/views.factor +++ b/frameworks/ui/backend/cocoa/views/views.factor @@ -160,7 +160,7 @@ CONSTANT: selector>action H{ selector>action at [ swap world-focus parents-handle-gesture? t ] [ drop f f ] if* ; -CLASS: FactorView < NSOpenGLView +CLASS< FactorView < NSOpenGLView cocoa-protocol: NSTextInput METHOD: void prepareOpenGL [ @@ -364,7 +364,8 @@ CLASS: FactorView < NSOpenGLView self remove-observer self super-send\ dealloc ] ; -; + +CLASS> : sync-refresh-to-screen ( GLView -- ) send\ openGLContext send\ CGLContextObj NSOpenGLCPSwapInterval 1 int @@ -376,7 +377,7 @@ CLASS: FactorView < NSOpenGLView : save-position ( world window -- ) send\ frame CGRect-top-left 2array >>window-loc drop ; -CLASS: FactorWindowDelegate < NSObject +CLASS< FactorWindowDelegate < NSObject METHOD: void windowDidMove: id notification [ @@ -422,7 +423,7 @@ CLASS: FactorWindowDelegate < NSObject [ 1.0 > retina? set-global ] bi ] [ drop ] if ] ; -; +CLASS> : install-window-delegate ( window -- ) FactorWindowDelegate install-delegate ; diff --git a/frameworks/ui/gadgets/frames/frames.factor b/frameworks/ui/gadgets/frames/frames.factor index bf8fd6e984..dc78ee8a3c 100644 --- a/frameworks/ui/gadgets/frames/frames.factor +++ b/frameworks/ui/gadgets/frames/frames.factor @@ -17,17 +17,17 @@ M: glue pref-dim* drop { 0 0 } ; : ( cols rows -- grid ) swap '[ _ [ ] replicate ] replicate ; -: (fill- ( frame grid-layout quot1 quot2 -- pref-dim gap filled-cell dims ) +: fill- ( frame grid-layout quot1 quot2 -- pref-dim gap filled-cell dims ) [ '[ [ dim>> ] [ gap>> ] [ filled-cell>> ] tri _ tri@ ] dip ] dip call ; inline : available-space ( pref-dim gap dims -- avail ) length 1 + * [-] ; inline -: -center) ( pref-dim gap filled-cell dims -- ) +: -center ( pref-dim gap filled-cell dims -- ) [ nip available-space ] [ [ remove-nth sum [-] ] [ set-nth ] 2bi ] 2bi ; inline -: (fill-center) ( frame grid-layout quot1 quot2 -- ) (fill- -center) ; inline +: (fill-center) ( frame grid-layout quot1 quot2 -- ) fill- -center ; inline : fill-center ( frame grid-layout -- ) [ [ first ] [ column-widths>> ] (fill-center) ] diff --git a/tools/pdf/values/values.factor b/tools/pdf/values/values.factor index f536602d36..5f31afbcbe 100644 --- a/tools/pdf/values/values.factor +++ b/tools/pdf/values/values.factor @@ -19,7 +19,7 @@ PRIVATE< { char: \t "\\t" } { char: \\ "\\\\" } { char: \( "\\(" } - { char: ) "\\)" } + { char: \) "\\)" } } escape-string-by ; PRIVATE> diff --git a/tools/text-to-pdf/text-to-pdf.factor b/tools/text-to-pdf/text-to-pdf.factor index 8cff6dbbcf..8d6ca7b257 100644 --- a/tools/text-to-pdf/text-to-pdf.factor +++ b/tools/text-to-pdf/text-to-pdf.factor @@ -18,7 +18,7 @@ PRIVATE< { char: \t "\\t" } { char: \\ "\\\\" } { char: \( "\\(" } - { char: ) "\\)" } + { char: \) "\\)" } } escape-string-by "(" ")" surround ; : pdf-object ( str n -- str' ) diff --git a/tools/tools/completion/completion.factor b/tools/tools/completion/completion.factor index 639e81c7d4..76f5da6ca6 100644 --- a/tools/tools/completion/completion.factor +++ b/tools/tools/completion/completion.factor @@ -125,11 +125,11 @@ PRIVATE< [ 2 tail* ?first (complete-single-vocab?) ] [ drop f ] if ] if ; -: chop-; ( seq -- seq' ) +: chop-semi ( seq -- seq' ) { ";" } split1-last [ ] [ ] ?if ; : complete-vocab-list? ( tokens -- ? ) - chop-; 1 short head* "USING:" swap member? ; + chop-semi 1 short head* "USING:" swap member? ; PRIVATE> diff --git a/tools/tools/deploy/test/14/14.factor b/tools/tools/deploy/test/14/14.factor index 22b444026c..5f470e21d7 100644 --- a/tools/tools/deploy/test/14/14.factor +++ b/tools/tools/deploy/test/14/14.factor @@ -6,13 +6,13 @@ kernel math ; FROM: alien.c-types => float ; in: tools.deploy.test.14 -CLASS: Bar < NSObject +CLASS< Bar < NSObject METHOD: float bar: NSRect rect [ rect origin>> [ x>> ] [ y>> ] bi + rect size>> [ w>> ] [ h>> ] bi + + ] ; -; +CLASS> : main ( -- ) Bar send\ alloc send\ init