Revert " Add export macro helper for properly reexpor vars."

This reverts commit 9ca6830267.
This commit is contained in:
Andrey Antukh 2020-12-01 11:33:52 +01:00
parent 9ca6830267
commit 45da7df4b4
3 changed files with 48 additions and 61 deletions

View file

@ -7,13 +7,10 @@
(ns app.common.data (ns app.common.data
"Data manipulation and query helper functions." "Data manipulation and query helper functions."
(:refer-clojure :exclude [concat read-string hash-map]) (:refer-clojure :exclude [concat read-string hash-map])
#?(:cljs
(:require-macros [app.common.data]))
(:require (:require
[clojure.set :as set] [clojure.set :as set]
[linked.set :as lks] [linked.set :as lks]
[app.common.math :as mth] [app.common.math :as mth]
#?(:clj [cljs.analyzer.api :as aapi])
#?(:cljs [cljs.reader :as r] #?(:cljs [cljs.reader :as r]
:clj [clojure.edn :as r]) :clj [clojure.edn :as r])
#?(:cljs [cljs.core :as core] #?(:cljs [cljs.core :as core]
@ -284,20 +281,3 @@
valid and the number otherwise." valid and the number otherwise."
[v] [v]
(if (or (not v) (mth/nan? v)) 0 v)) (if (or (not v) (mth/nan? v)) 0 v))
(defmacro export
"A helper macro that allows reexport a var in a current namespace."
[v]
(let [sym (symbol (name v))
mdata (aapi/resolve &env v)
andsym (symbol "&")
arglists (second (get-in mdata [:meta :arglists]))]
(if (pos? (count arglists))
`(def
~(with-meta sym (:meta mdata))
(fn ~@(for [args arglists]
(if (some #(= andsym %) args)
(let [[sargs dargs] (split-with #(not= andsym %) args)]
`([~@sargs ~@dargs] (apply ~v ~@sargs ~@(rest dargs))))
`([~@args] (~v ~@args))))))
`(def ~(with-meta sym (:meta mdata)) ~v))))

View file

@ -9,16 +9,16 @@
(ns app.common.geom.shapes (ns app.common.geom.shapes
(:require (:require
[app.common.data :as d] [clojure.spec.alpha :as s]
[app.common.spec :as us]
[app.common.geom.matrix :as gmt] [app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
[app.common.geom.shapes.common :as gco] [app.common.geom.shapes.common :as gco]
[app.common.geom.shapes.path :as gsp]
[app.common.geom.shapes.rect :as gpr]
[app.common.geom.shapes.transforms :as gtr] [app.common.geom.shapes.transforms :as gtr]
[app.common.geom.shapes.rect :as gpr]
[app.common.geom.shapes.path :as gsp]
[app.common.math :as mth] [app.common.math :as mth]
[app.common.spec :as us] [app.common.data :as d]))
[clojure.spec.alpha :as s]))
;; --- Relative Movement ;; --- Relative Movement
@ -252,17 +252,22 @@
;; EXPORTS ;; EXPORTS
(d/export gco/center-shape) (defn center-shape [shape] (gco/center-shape shape))
(d/export gco/center-selrect) (defn center-selrect [selrect] (gco/center-selrect selrect))
(d/export gco/center-rect) (defn center-rect [rect] (gco/center-rect rect))
(d/export gpr/rect->selrect)
(d/export gpr/rect->points) (defn rect->selrect [rect] (gpr/rect->selrect rect))
(d/export gpr/points->selrect) (defn rect->points [rect] (gpr/rect->points rect))
(d/export gtr/transform-shape) (defn points->selrect [points] (gpr/points->selrect points))
(d/export gtr/transform-matrix)
(d/export gtr/transform-point-center) (defn transform-shape [shape] (gtr/transform-shape shape))
(d/export gtr/transform-rect) (defn transform-matrix
([shape] (gtr/transform-matrix shape))
([shape options] (gtr/transform-matrix shape options)))
(defn transform-point-center [point center transform] (gtr/transform-point-center point center transform))
(defn transform-rect [rect mtx] (gtr/transform-rect rect mtx))
;; PATHS ;; PATHS
(d/export gsp/content->points) (defn content->points [content] (gsp/content->points content))
(d/export gsp/content->selrect) (defn content->selrect [content] (gsp/content->selrect content))

View file

@ -1576,36 +1576,38 @@
;; Transform ;; Transform
(d/export dwt/start-rotate) (def start-rotate dwt/start-rotate)
(d/export dwt/start-resize) (def start-resize dwt/start-resize)
(d/export dwt/start-move-selected) (def start-move-selected dwt/start-move-selected)
(d/export dwt/move-selected) (def move-selected dwt/move-selected)
(d/export dwt/set-rotation)
(d/export dwt/set-modifiers) (def set-rotation dwt/set-rotation)
(d/export dwt/apply-modifiers) (def set-modifiers dwt/set-modifiers)
(def apply-modifiers dwt/apply-modifiers)
;; Persistence ;; Persistence
(d/export dwp/set-file-shared) (def set-file-shared dwp/set-file-shared)
(d/export dwp/fetch-shared-files) (def fetch-shared-files dwp/fetch-shared-files)
(d/export dwp/link-file-to-library) (def link-file-to-library dwp/link-file-to-library)
(d/export dwp/unlink-file-from-library) (def unlink-file-from-library dwp/unlink-file-from-library)
(d/export dwp/upload-media-objects) (def upload-media-objects dwp/upload-media-objects)
;; Selection ;; Selection
(d/export dws/select-shape) (def select-shape dws/select-shape)
(d/export dws/select-all) (def select-all dws/select-all)
(d/export dws/deselect-all) (def deselect-all dws/deselect-all)
(d/export dwc/select-shapes) (def select-shapes dwc/select-shapes)
(d/export dws/duplicate-selected) (def duplicate-selected dws/duplicate-selected)
(d/export dws/handle-selection) (def handle-selection dws/handle-selection)
(d/export dws/select-inside-group) (def select-inside-group dws/select-inside-group)
(d/export dwd/select-for-drawing) (def select-for-drawing dwd/select-for-drawing)
(d/export dwc/clear-edition-mode) (def clear-edition-mode dwc/clear-edition-mode)
(d/export dwc/add-shape) (def add-shape dwc/add-shape)
(d/export dwc/start-edition-mode) (def start-edition-mode dwc/start-edition-mode)
(d/export dwdp/start-path-edit)
(defn start-path-edit [id] (dwdp/start-path-edit id))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Shortcuts ;; Shortcuts