ffi/com: repairs, including `mysterx' compatibility

Restore MysterX-style handling of parameterzied properties in
`com-get-property'.  It turns out that the original `com-get-property'
handles parameterized properties by allowing a list in place of a
property-name string, and that handling got lost in the re-write.

Fix the name of `com-get-active-from-from-coclass'.

Fix arity checking for optional arguments.

Closes PR 13603
Closes PR 13604
This commit is contained in:
Matthew Flatt 2013-03-31 08:06:44 -06:00
parent 2412611c07
commit 6e40caa7e2
4 changed files with 35 additions and 12 deletions

View File

@ -1946,8 +1946,8 @@
[t (adjust-any-... args t)])
(unless (<= (for/fold ([n 0]) ([v (in-list (cadr t))])
(if (and (pair? v) (eq? (car v) 'opt))
(add1 n)
n))
n
(add1 n)))
(length args)
(length (cadr t)))
(error 'com-invoke "bad argument count for ~s" name))
@ -2047,7 +2047,16 @@
(define com-get-property
(case-lambda
[(obj name)
(do-com-invoke 'com-get-property obj name null INVOKE_PROPERTYGET)]
(cond
[(string? name)
(do-com-invoke 'com-get-property obj name null INVOKE_PROPERTYGET)]
[(and (list? name)
(pair? name)
(string? (car name)))
(do-com-invoke 'com-get-property obj (car name) (cdr name) INVOKE_PROPERTYGET)]
[else
(raise-argument-error 'com-get-property "(or/c string? (cons/c string? list))"
name)])]
[(obj name1 . more-names)
(check-com-obj 'com-get-property obj)
(define names (cons name1 more-names))

View File

@ -12,7 +12,7 @@
cocreate-instance-from-progid
cci/progid
get-active-object-from-coclass
com-get-active-object-from-coclass
gao/coclass
coclass
@ -81,10 +81,10 @@
(define (cci/progid progid [where 'local])
(cocreate-instance-from-progid progid where))
(define (get-active-object-from-coclass coclass)
(com-get-active-object (coclass->clsid* 'get-active-object-from-coclass coclass)))
(define (com-get-active-object-from-coclass coclass)
(com-get-active-object (coclass->clsid* 'com-get-active-object-from-coclass coclass)))
(define (gao/coclass coclass)
(get-active-object-from-coclass coclass))
(com-get-active-object-from-coclass coclass))
(define (coclass obj)
(clsid->coclass (com-object-clsid obj)))

View File

@ -117,12 +117,19 @@ Like @racket[cocreate-instance-from-coclass], but using a ProgID.}
property in @racket[obj/type]. See @secref["com-types"] for
information on the symbols.}
@defproc[(com-get-property [obj com-object?] [property string?] ...+)
@defproc[(com-get-property [obj com-object?]
[property (or/c string?
(cons/c string? list?))]
...+)
any/c]{
Returns the value of the final property by following the indicated
path of @racket[property]s, where each intermediate property is a
COM object.}
path of @racket[property]s, where each intermediate property must be a
COM object.
Each @racket[property] is either a property-name string or a list
that starts with a property-name string and continues with arguments
for a parameterized property.}
@defproc[(com-set-properties [obj/type (or/c com-object? com-type?)])
(listof string?)]{

View File

@ -230,12 +230,19 @@ argument.}
symbols.}
@defproc[(com-get-property [obj com-object?] [property string?] ...+)
@defproc[(com-get-property [obj com-object?]
[property (or/c string?
(cons/c string? list?))]
...+)
any/c]{
Returns the value of the final property by following the indicated
path of @racket[property]s, where each intermediate property must be a
COM object.}
COM object.
Each @racket[property] is either a property-name string or a list
that starts with a property-name string and continues with arguments
for a parameterized property.}
@defproc[(com-get-property* [obj com-object?] [property string?] [v any/c] ...)
any/c]{