]> gitweb.factorcode.org Git - factor.git/blob - basis/cocoa/cocoa.factor
cocoa: cleanup ?-> syntax and implementation.
[factor.git] / basis / cocoa / cocoa.factor
1 ! Copyright (C) 2006, 2009 Slava Pestov
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs cocoa.messages compiler.units core-foundation.bundles
4 hashtables init io kernel lexer namespaces sequences vocabs ;
5 IN: cocoa
6
7 SYMBOL: sent-messages
8
9 sent-messages [ H{ } clone ] initialize
10
11 : remember-send ( selector -- )
12     dup sent-messages get set-at ;
13
14 SYNTAX: ->
15     scan-token dup remember-send
16     [ lookup-method suffix! ] [ suffix! ] bi \ send suffix! ;
17
18 SYNTAX: ?->
19     dup last cache-stubs
20     scan-token dup remember-send
21     suffix! \ send suffix! ;
22
23 SYNTAX: SEL:
24     scan-token dup remember-send
25     <selector> suffix! \ cocoa.messages:selector suffix! ;
26
27 SYMBOL: super-sent-messages
28
29 super-sent-messages [ H{ } clone ] initialize
30
31 : remember-super-send ( selector -- )
32     dup super-sent-messages get set-at ;
33
34 SYNTAX: SUPER->
35     scan-token dup remember-super-send
36     [ lookup-method suffix! ] [ suffix! ] bi \ super-send suffix! ;
37
38 SYMBOL: frameworks
39
40 frameworks [ V{ } clone ] initialize
41
42 [ frameworks get [ load-framework ] each ] "cocoa" add-startup-hook
43
44 SYNTAX: FRAMEWORK: scan-token [ load-framework ] [ frameworks get push ] bi ;
45
46 SYNTAX: IMPORT: scan-token [ ] import-objc-class ;
47
48 "Importing Cocoa classes..." print
49
50 "cocoa.classes" create-vocab drop
51
52 [
53     {
54         "NSAlert"
55         "NSAppleScript"
56         "NSApplication"
57         "NSArray"
58         "NSAutoreleasePool"
59         "NSBitmapImageRep"
60         "NSBundle"
61         "NSButton"
62         "NSColorSpace"
63         "NSCustomTouchBarItem"
64         "NSData"
65         "NSDictionary"
66         "NSError"
67         "NSEvent"
68         "NSException"
69         "NSMenu"
70         "NSMenuItem"
71         "NSMutableDictionary"
72         "NSNib"
73         "NSNotification"
74         "NSNotificationCenter"
75         "NSNumber"
76         "NSObject"
77         "NSOpenGLContext"
78         "NSOpenGLPixelFormat"
79         "NSOpenGLView"
80         "NSOpenPanel"
81         "NSPanel"
82         "NSPasteboard"
83         "NSPropertyListSerialization"
84         "NSResponder"
85         "NSSavePanel"
86         "NSScreen"
87         "NSString"
88         "NSTouchBar"
89         "NSTouchBarItem"
90         "NSView"
91         "NSWindow"
92         "NSWorkspace"
93     } [
94         [ ] import-objc-class
95     ] each
96 ] with-compilation-unit