Skip to content

Commit

Permalink
Change xref var to get-xref function; delete xref-ready-evt
Browse files Browse the repository at this point in the history
The ready event, although not used, wasn't implemented correctly.

Although moot now, better to set this up to work correctly if needed
someday.
  • Loading branch information
greghendershott committed Nov 18, 2024
1 parent c5bee68 commit b54ada5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions racket/commands/help.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
(->identifier how str stx->uri-string))

(define (stx->uri-string stx)
(define xref (get-xref))
(match (and xref (xref-binding->definition-tag xref stx 0))
[(? tag? tag)
(define-values (path anchor) (xref-tag->path+anchor xref tag))
Expand Down
9 changes: 5 additions & 4 deletions racket/scribble.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@

(define/contract (binding->path+anchor stx)
(-> identifier? (or/c #f (cons/c path-string? (or/c #f string?))))
(let* ([tag (xref-binding->definition-tag xref stx 0)]
(let* ([xref (get-xref)]
[tag (xref-binding->definition-tag xref stx 0)]
[p+a (and tag (tag->path+anchor xref tag))])
p+a))

Expand Down Expand Up @@ -72,7 +73,7 @@

(define/contract (identifier->bluebox stx)
(-> identifier? (or/c #f string?))
(match (xref-binding->definition-tag xref stx 0)
(match (xref-binding->definition-tag (get-xref) stx 0)
[(? tag? tag) (get-bluebox-string tag)]
[_ #f]))

Expand Down Expand Up @@ -169,7 +170,7 @@
(let ([ht (exported-index-desc*-extras desc)])
(or (hash-ref ht 'hidden? #f)
(hash-ref ht 'constructor? #f))))))
(for* ([entry (in-list (xref-index xref))]
(for* ([entry (in-list (xref-index (get-xref)))]
[desc (in-value (entry-desc entry))]
#:when desc
#:unless (hide-desc? desc)
Expand All @@ -181,7 +182,7 @@
root)

(define (doc-trie-value desc term tag)
(define-values (path anchor) (xref-tag->path+anchor xref tag))
(define-values (path anchor) (xref-tag->path+anchor (get-xref) tag))
(define (method-what)
(cond
[(method-tag? tag)
Expand Down
14 changes: 9 additions & 5 deletions racket/xref.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@

(require setup/xref)

(provide xref
xref-ready-evt)
(provide get-xref)

(define xref-ready-evt never-evt)
(define xref (begin0 (load-collections-xref)
(set! xref-ready-evt always-evt)))
;; A single xref instance for all our modules to share.
;;
;; Will block safely until ready, if used from e.g. delay/thread or
;; delay/idle (which, although we're not doing now, we've done before,
;; and might do again someday).
(define sema (make-semaphore 1))
(define xref (call-with-semaphore sema load-collections-xref))
(define (get-xref) (call-with-semaphore sema (λ () xref)))

0 comments on commit b54ada5

Please sign in to comment.