]> gitweb.factorcode.org Git - factor.git/commitdiff
Cocoa: support method redefinition
authorslava <slava@factorcode.org>
Sat, 14 Oct 2006 00:37:14 +0000 (00:37 +0000)
committerslava <slava@factorcode.org>
Sat, 14 Oct 2006 00:37:14 +0000 (00:37 +0000)
TODO.FACTOR.txt
library/compiler/alien/objc/subclassing.factor
library/ui/cocoa/callback.factor
library/ui/cocoa/services.factor
library/ui/cocoa/test/cocoa.factor
library/ui/cocoa/ui.factor
library/ui/cocoa/view-utils.factor
library/ui/cocoa/window-utils.factor
library/ui/gadgets/lists.factor

index b51c04905d382390f824e604fb1199979cd9bdcf..4f3317d188b321d4ee4d9b4329b39ec7cefd59b5 100644 (file)
@@ -1,11 +1,14 @@
 - auto-invoke code gc
 - fix alien-callback/SEH bug on win32
-- x11: scroll up/down wiggles caret
+- live search: timer delay would be nice
+- help responder has no way to access { "foo" "bar" }
+- httpd search tools
+- polish OS X menu bar code
+- list selection broken
 
 + ui:
 
 - completion is not ideal: eg, search for "buttons"
-- live search: timer delay would be nice
 - some way of intercepting all gestures
 - slider needs to be modelized
 - better help result ranking
@@ -28,7 +31,6 @@
     space
 - grid slows down with 2000 lines
 - see if its possible to only repaint dirty regions
-- polish OS X menu bar code
 - structure editor
 
 + module system:
@@ -46,7 +48,6 @@
 + compiler/ffi:
 
 - more compact relocation info
-- cocoa: support real redefinition
 - relocation should not cons at all
 - stdcall callbacks
 - [ [ dup call ] dup call ] infer hangs
@@ -85,6 +86,4 @@
 
 + httpd:
 
-- help responder has no way to access { "foo" "bar" }
-- httpd search tools
 - remaining HTML issues need fixing
index 927984a1523649c0cb8836a3a8640727752d8b5d..06319a8279eb2fbadb4c39980611e4bd8f90aabc 100644 (file)
@@ -19,9 +19,8 @@ libc math namespaces sequences strings words ;
     dup length dup <empty-method-list> -rot
     [ pick method-list@ objc-method-nth init-method ] 2each ;
 
-: <method-lists> ( methods -- lists )
-    <method-list> alien-address
-    "void*" <malloc-object> [ 0 set-alien-unsigned-cell ] keep ;
+: define-objc-methods ( class methods -- )
+    <method-list> class_addMethods ;
 
 : <objc-class> ( name info -- class )
     "objc-class" <malloc-object>
@@ -42,23 +41,23 @@ libc math namespaces sequences strings words ;
     dup objc-class-super-class objc-class-instance-size
     swap set-objc-class-instance-size ;
 
-: <meta-class> ( methods superclass name -- class )
+: <meta-class> ( superclass name -- class )
     CLS_META <objc-class>
     [ >r dup objc-class-isa r> set-objc-class-super-class ] keep
     [ >r meta-meta-class r> set-objc-class-isa ] keep
-    [ >r <method-lists> r> set-objc-class-methodLists ] keep
     dup copy-instance-size ;
 
-: <new-class> ( methods metaclass superclass name -- class )
+: <new-class> ( metaclass superclass name -- class )
     CLS_CLASS <objc-class>
     [ set-objc-class-super-class ] keep
     [ set-objc-class-isa ] keep
-    [ >r <method-lists> r> set-objc-class-methodLists ] keep
     dup copy-instance-size ;
 
-: (define-objc-class) ( imeth cmeth superclass name -- )
-    >r objc-class r> [ <meta-class> ] 2keep <new-class>
-    objc_addClass ;
+: (define-objc-class) ( superclass name imeth -- )
+    >r
+    >r objc-class r>
+    [ <meta-class> ] 2keep <new-class> dup objc_addClass
+    r> <method-list> class_addMethods ;
 
 : encode-types ( return types -- encoding )
     >r 1array r> append
@@ -78,8 +77,11 @@ libc math namespaces sequences strings words ;
 : prepare-methods ( methods -- methods )
     [ first4 prepare-method 3array ] map ;
 
-: define-objc-class ( superclass name imeth cmeth -- )
-    pick >r
-    [ prepare-methods ] 2apply
-    [ 2array % 2array % \ (define-objc-class) , ] [ ] make
-    r> swap import-objc-class ;
+: redefine-objc-methods ( name imeth -- )
+    >r objc_getClass r> define-objc-methods ;
+
+: define-objc-class ( superclass name imeth -- )
+    prepare-methods
+    over class-exists? [ 2dup redefine-objc-methods ] when
+    over >r [ 3array % \ (define-objc-class) , ] [ ] make r>
+    swap import-objc-class ;
index 9f7c2ee628e4862e15685598acff900c4ddc394f..0e1e12624ce7915a8a1aacc861a623a31ce02ca8 100644 (file)
@@ -25,7 +25,7 @@ reset-callbacks
             SUPER-> dealloc
         ]
     }
-} { } define-objc-class
+} define-objc-class
 
 : <FactorCallback> ( quot -- id )
     FactorCallback -> alloc -> init
index cf24e1d94158d1cf53f9075f0e65b2257c4a65b0..6de687981986231e8343b48e8281c4bca45ae40d 100644 (file)
@@ -39,7 +39,7 @@ parser prettyprint styles gadgets-listener gadgets-workspace ;
         { "id" "SEL" "id" "id" "void*" }
         [ nip [ eval>string ] do-service 2drop ]
     }
-} { } define-objc-class
+} define-objc-class
 
 : register-services ( -- )
     NSApp
index 040954daf2c281a013ca56dc65d1ba4c8ea7ed1a..dda189c2a58c54a262e558927f59d84c9ba9d036 100644 (file)
@@ -7,7 +7,6 @@ USING: cocoa compiler kernel objc namespaces objc-classes test memory ;
 
 "NSObject" "Foo"
 { { "foo:" "void" { "id" "SEL" "NSRect" } [ full-gc "x" set 2drop ] } }
-{ }
 define-objc-class
 
 : test-foo
@@ -24,7 +23,6 @@ test-foo
 
 "NSObject" "Bar"
 { { "bar" "NSRect" { "id" "SEL" } [ 2drop test-foo "x" get ] } }
-{ }
 define-objc-class
 
 Bar [
index 57d4b6623ea9d917f605ea75db1efb8fd7971df2..e7a455a517755e49e9c79a2c57e33f8e626a68d3 100644 (file)
@@ -19,7 +19,7 @@ hashtables kernel memory namespaces objc sequences errors freetype ;
     { "application:openFiles:" "void" { "id" "SEL" "id" "id" }
         [ >r 3drop r> finder-run-files ]
     }
-} { } define-objc-class
+} define-objc-class
 
 : install-app-delegate ( -- )
     NSApp FactorApplicationDelegate install-delegate ;
index 50ed465501b056c27cce1386782c33bfb4230347..3b3d22f46480fc40f2c98c4249b871a81be83ce4 100644 (file)
@@ -272,7 +272,7 @@ opengl sequences ;
             SUPER-> dealloc
         ]
     }
-} { } define-objc-class
+} define-objc-class
 
 : <FactorView> ( world -- view )
     FactorView over rect-dim <GLView> [ register-window ] keep ;
index 8752b579cd0f0790c568547ae87345f2dd38a789..76d93e2db209616c8499fd6347b2eddedf371f00 100644 (file)
@@ -77,7 +77,7 @@ USING: arrays gadgets kernel math objc sequences ;
             2nip -> object -> contentView window unfocus-world
         ]
     }
-} { } define-objc-class
+} define-objc-class
 
 : install-window-delegate ( window -- )
     FactorWindowDelegate install-delegate ;
index 8329b1130793f6a94f262c2fe001f62adf00f748..c35b09c0ec061014deefa75c256f9b0d1778e1b1 100644 (file)
@@ -31,7 +31,9 @@ M: list model-changed
 
 M: list draw-gadget*
     dup list-color gl-color
-    selected-rect [ rect-bounds gl-fill-rect ] when* ;
+    selected-rect [
+        rect-bounds >r origin get v+ r> gl-fill-rect
+    ] when* ;
 
 M: list focusable-child* drop t ;