|
517 | 517 | (sci-ns-refers* ctx sci-ns) |
518 | 518 | (sci-ns-imports* ctx sci-ns)))) |
519 | 519 |
|
520 | | -(defn sci-ns-unmap [ctx sci-ns sym] |
521 | | - (assert (symbol? sym)) ; protects :aliases, :imports, :obj, etc. |
522 | | - (swap! (:env ctx) |
523 | | - (fn [env] |
524 | | - (let [name (sci-ns-name ctx sci-ns)] |
525 | | - (update-in env [:namespaces name] |
526 | | - (fn [the-ns-map] |
527 | | - (cond (contains? (:refers the-ns-map) sym) |
528 | | - (-> (update the-ns-map :refers dissoc sym) |
529 | | - ;; remove lingering var that may have been |
530 | | - ;; overwritten before, see #637 |
531 | | - (dissoc the-ns-map sym)) |
532 | | - (contains? the-ns-map sym) |
533 | | - (dissoc the-ns-map sym) |
534 | | - (or |
535 | | - (contains? (:imports env) sym) |
536 | | - (contains? (:imports the-ns-map) sym)) |
537 | | - ;; nil marks the imported class as unmapped |
538 | | - (update the-ns-map :imports assoc sym nil) |
539 | | - :else the-ns-map)))))) |
| 520 | +(defn sci-ns-unmap [sci-ns sym] |
| 521 | + (let [ctx (store/get-ctx)] |
| 522 | + (assert (symbol? sym)) ; protects :aliases, :imports, :obj, etc. |
| 523 | + (swap! (:env ctx) |
| 524 | + (fn [env] |
| 525 | + (let [name (sci-ns-name ctx sci-ns)] |
| 526 | + (update-in env [:namespaces name] |
| 527 | + (fn [the-ns-map] |
| 528 | + (cond (contains? (:refers the-ns-map) sym) |
| 529 | + (-> (update the-ns-map :refers dissoc sym) |
| 530 | + ;; remove lingering var that may have been |
| 531 | + ;; overwritten before, see #637 |
| 532 | + (dissoc the-ns-map sym)) |
| 533 | + (contains? the-ns-map sym) |
| 534 | + (dissoc the-ns-map sym) |
| 535 | + (or |
| 536 | + (contains? (:imports env) sym) |
| 537 | + (contains? (:imports the-ns-map) sym)) |
| 538 | + ;; nil marks the imported class as unmapped |
| 539 | + (update the-ns-map :imports assoc sym nil) |
| 540 | + :else the-ns-map))))))) |
540 | 541 | nil) |
541 | 542 |
|
542 | 543 | (defn sci-ns-unalias [ctx sci-ns sym] |
|
1511 | 1512 | 'ns-publics (copy-var sci-ns-publics clojure-core-ns {:name 'ns-publics}) |
1512 | 1513 | 'ns-refers (copy-var sci-ns-refers clojure-core-ns {:name 'ns-refers}) |
1513 | 1514 | 'ns-map (copy-var sci-ns-map clojure-core-ns {:name 'ns-map}) |
1514 | | - 'ns-unmap (copy-var sci-ns-unmap clojure-core-ns {:ctx true :name 'ns-unmap}) |
| 1515 | + 'ns-unmap (copy-var sci-ns-unmap clojure-core-ns {:name 'ns-unmap}) |
1515 | 1516 | 'ns-unalias (copy-var sci-ns-unalias clojure-core-ns {:ctx true :name 'ns-unalias}) |
1516 | 1517 | 'ns-name (copy-var sci-ns-name clojure-core-ns {:name 'ns-name :ctx true}) |
1517 | 1518 | 'odd? (copy-core-var odd?) |
|
0 commit comments