atomic mode for objc methods; doc tweaks

svn: r13022
This commit is contained in:
Matthew Flatt 2009-01-06 19:52:40 +00:00
parent 9281b6f2b5
commit 090c73647f
4 changed files with 22 additions and 13 deletions

View File

@ -118,13 +118,13 @@ Defines each @scheme[class-id] to the class (a value with FFI type
(eval:alts (import-class NSString) (void)) (eval:alts (import-class NSString) (void))
]} ]}
@defform/subs[#:literals (+ -) @defform/subs[#:literals (+ - +a -a)
(define-objc-class class-id superclass-expr (define-objc-class class-id superclass-expr
[field-id ...] [field-id ...]
method) method)
([method (mode result-ctype-expr (method-id) body ...+) ([method (mode result-ctype-expr (method-id) body ...+)
(mode result-ctype-expr (arg ...+) body ...+)] (mode result-ctype-expr (arg ...+) body ...+)]
[mode + -] [mode + - +a -a]
[arg (code:line method-id [ctype-expr arg-id])])]{ [arg (code:line method-id [ctype-expr arg-id])])]{
Defines @scheme[class-id] as a new, registered Objective-C class (of Defines @scheme[class-id] as a new, registered Objective-C class (of
@ -138,10 +138,12 @@ directly when the method @scheme[body]s. Outside the object, they can
be referenced and set with @scheme[get-ivar] and @scheme[set-ivar!]. be referenced and set with @scheme[get-ivar] and @scheme[set-ivar!].
Each @scheme[method] adds or overrides a method to the class (when Each @scheme[method] adds or overrides a method to the class (when
@scheme[mode] is @scheme[-]) to be called on instances, or it adds a @scheme[mode] is @scheme[-] or @scheme[-a]) to be called on instances,
method to the meta-class (when @scheme[mode] is @scheme[+]) to be or it adds a method to the meta-class (when @scheme[mode] is
called on the class itself. All result and argument types must be @scheme[+] or @scheme[+a]) to be called on the class itself. All
declared using FFI C types (@seeCtype). result and argument types must be declared using FFI C types
(@seeCtype). When @scheme[mode] is @scheme[+a] or @scheme[-a], the
method is called in atomic mode (see @scheme[_cprocedure]).
If a @scheme[method] is declared with a single @scheme[method-id] and If a @scheme[method] is declared with a single @scheme[method-id] and
no arguments, then @scheme[method-id] must not end with no arguments, then @scheme[method-id] must not end with

View File

@ -364,7 +364,7 @@
;; Given a dealloc extension: ;; Given a dealloc extension:
#'() #'()
;; Need to add one explicitly: ;; Need to add one explicitly:
#'((- _void (dealloc) (void)))))]) #'((-a _void (dealloc) (void)))))])
(syntax/loc stx (syntax/loc stx
(begin (begin
(define superclass-id superclass) (define superclass-id superclass)
@ -454,10 +454,13 @@
(syntax-case #'m () (syntax-case #'m ()
[(kind result-type (id arg ...) body0 body ...) [(kind result-type (id arg ...) body0 body ...)
(or (free-identifier=? #'kind #'+) (or (free-identifier=? #'kind #'+)
(free-identifier=? #'kind #'-)) (free-identifier=? #'kind #'-)
(free-identifier=? #'kind #'+a)
(free-identifier=? #'kind #'-a))
(let ([id #'id] (let ([id #'id]
[args (syntax->list #'(arg ...))] [args (syntax->list #'(arg ...))]
[in-class? (free-identifier=? #'kind #'+)]) [in-class? (or (free-identifier=? #'kind #'+)
(free-identifier=? #'kind #'+a))])
(when (null? args) (when (null? args)
(unless (identifier? id) (unless (identifier? id)
(raise-syntax-error #f (raise-syntax-error #f
@ -485,7 +488,9 @@
'())] '())]
[in-cls (if in-class? [in-cls (if in-class?
#'(object_getClass cls) #'(object_getClass cls)
#'cls)]) #'cls)]
[atomic? (or (free-identifier=? #'kind #'+a)
(free-identifier=? #'kind #'-a))])
(syntax/loc stx (syntax/loc stx
(let ([rt result-type] (let ([rt result-type]
[arg-id arg-type] ...) [arg-id arg-type] ...)
@ -498,7 +503,7 @@
[super-tell do-super-tell]) [super-tell do-super-tell])
body0 body ... body0 body ...
dealloc-body ...))) dealloc-body ...)))
(_fun _id _id arg-type ... -> rt) (_fun #:atomic? atomic? _id _id arg-type ... -> rt)
(generate-layout rt (list arg-id ...)))))))))] (generate-layout rt (list arg-id ...)))))))))]
[else (raise-syntax-error #f [else (raise-syntax-error #f
"bad method form" "bad method form"

View File

@ -334,7 +334,7 @@ this procedure type and called from foreign code, then the PLT Scheme
process is put into atomic mode while evaluating the Scheme procedure process is put into atomic mode while evaluating the Scheme procedure
body. In atomic mode, other Scheme threads do not run, so the Scheme body. In atomic mode, other Scheme threads do not run, so the Scheme
code must not call any function that potentially synchronizes with code must not call any function that potentially synchronizes with
other threads, otherwise it may deadlock. In addition, the Scheme code other threads, or else it may deadlock. In addition, the Scheme code
must not perform any potentially blocking operation (such as I/O), it must not perform any potentially blocking operation (such as I/O), it
must not raise an uncaught exception, it must not perform any escaping must not raise an uncaught exception, it must not perform any escaping
continuation jumps, and its non-tail recursion must be minimal to continuation jumps, and its non-tail recursion must be minimal to

View File

@ -128,7 +128,9 @@ type. The property value must be a list of three procedures:
@scheme[equal?] to ensure that data cycles are handled @scheme[equal?] to ensure that data cycles are handled
properly and to work with @scheme[equal?/recur] (but beware properly and to work with @scheme[equal?/recur] (but beware
that an arbitrary function can be provided to that an arbitrary function can be provided to
@scheme[equal?/recur]). @scheme[equal?/recur] for recursive checks, which means that
arguments provided to the predicate might be exposed to
arbitrary code).
The @scheme[_equal-proc] is called for a pair of structures The @scheme[_equal-proc] is called for a pair of structures
only when they are not @scheme[eq?], and only when they both only when they are not @scheme[eq?], and only when they both