Skip to content

Commit

Permalink
[svg] remove cljx dependency, switch to clj1.7 reader conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed May 25, 2015
1 parent 73c034c commit 781783c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 61 deletions.
2 changes: 1 addition & 1 deletion geom-meshops/src/slicing.org
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
[clojure.java.io :as io]
[thi.ng.math.core :as m]
[thi.ng.dstruct.core :as d]
[thi.ng.common.data.intervaltree :as it]
[thi.ng.dstruct.intervaltree :as it]
[thi.ng.math.macros :as mm])
(:import
(java.awt.image BufferedImage)
Expand Down
52 changes: 25 additions & 27 deletions geom-svg/src/core.org
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ libraries available and we don't want to be prescriptive here and
introduce uneccessary dependencies.

#+BEGIN_SRC clojure :noweb-ref svg
,#+clj
(defn serialize
^String [svg] (str xml-preamble (html {:mode :xml} svg)))
#?@(:clj
[(defn serialize
^String [svg] (str xml-preamble (html {:mode :xml} svg)))

,#+clj
(defn serialize-as-byte-array
^bytes [svg] (.getBytes (serialize svg) "UTF-8"))
(defn serialize-as-byte-array
^bytes [svg] (.getBytes (serialize svg) "UTF-8"))])
#+END_SRC

** Attribute conversion
Expand Down Expand Up @@ -411,18 +410,17 @@ Btw. This example can be run from the REPL via this command:
;; CLJS walk differs to clojure's impl and doesn't work for defrecords
;; hence we provide a custom version here...

,#+cljs
(defn walk
[inner outer form]
(cond
(seq? form) (outer (doall (map inner form)))
(vector? form) (outer (mapv inner form))
:else (outer form)))
#?@(:cljs
[(defn walk
[inner outer form]
(cond
(seq? form) (outer (doall (map inner form)))
(vector? form) (outer (mapv inner form))
:else (outer form)))

,#+cljs
(defn postwalk
[f form]
(walk (partial postwalk f) f form))
(defn postwalk
[f form]
(walk (partial postwalk f) f form))])

(defn all-as-svg
[form]
Expand All @@ -433,18 +431,18 @@ Btw. This example can be run from the REPL via this command:

** Complete namespace: svg.core

#+BEGIN_SRC clojure :tangle ../babel/src/cljx/thi/ng/geom/svg/core.cljx :noweb yes :mkdirp yes :padline no
#+BEGIN_SRC clojure :tangle ../babel/src/thi/ng/geom/svg/core.cljc :noweb yes :mkdirp yes :padline no
(ns thi.ng.geom.svg.core
(:require
[thi.ng.geom.core :as g]
[thi.ng.geom.core.utils :as gu]
[thi.ng.geom.core.vector :refer [vec2]]
[thi.ng.geom.core.matrix :as mat :refer [M32]]
[thi.ng.common.data.core :as d]
[thi.ng.common.math.core :as m]
[thi.ng.common.stringformat :as f]
[thi.ng.dstruct.core :as d]
[thi.ng.math.core :as m]
[thi.ng.strf.core :as f]
[thi.ng.color.core :as col]
#+clj [hiccup.core :refer [html]]))
#?(:clj [hiccup.core :refer [html]])))

<<const>>

Expand All @@ -461,16 +459,16 @@ Btw. This example can be run from the REPL via this command:

** Complete namespace: svg.adapter

#+BEGIN_SRC clojure :tangle ../babel/src/cljx/thi/ng/geom/svg/adapter.cljx :noweb yes :mkdirp yes :padline no
#+BEGIN_SRC clojure :tangle ../babel/src/thi/ng/geom/svg/adapter.cljc :noweb yes :mkdirp yes :padline no
(ns thi.ng.geom.svg.adapter
(:require
[thi.ng.geom.svg.core :as svg]
[thi.ng.geom.core :as g]
[thi.ng.geom.types]
,#+clj [clojure.walk :refer [postwalk]])
,#+clj
(:import
[thi.ng.geom.types Circle2 Line2 LineStrip2 Polygon2 Rect2 Triangle2]))
#?(:clj [clojure.walk :refer [postwalk]]))
#?(:clj
(:import
[thi.ng.geom.types Circle2 Line2 LineStrip2 Polygon2 Rect2 Triangle2])))

<<adapter>>
#+END_SRC
12 changes: 6 additions & 6 deletions geom-svg/src/examples.org
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ is defined in its own namespace and can be loaded from the REPL via:
[thi.ng.geom.svg.core :as svg]
[thi.ng.geom.svg.shaders :as shader]
[thi.ng.geom.svg.renderer :as render]
[thi.ng.common.math.core :as m]
[thi.ng.math.core :as m]
[clojure.java.io :as io]))

(def width 640)
Expand Down Expand Up @@ -91,7 +91,7 @@ is defined in its own namespace and can be loaded from the REPL via:
[thi.ng.geom.svg.core :as svg]
[thi.ng.geom.svg.shaders :as shader]
[thi.ng.geom.svg.renderer :as render]
[thi.ng.common.math.core :as m]))
[thi.ng.math.core :as m]))

(def width 640)
(def height 480)
Expand Down Expand Up @@ -196,8 +196,8 @@ is defined in its own namespace and can be loaded from the REPL via:
[thi.ng.geom.core :as g]
[thi.ng.geom.core.vector :refer [vec2]]
[thi.ng.geom.svg.core :as svg]
[thi.ng.common.math.core :as m]
[thi.ng.macromath.core :as mm]))
[thi.ng.math.core :as m]
[thi.ng.math.macros :as mm]))

(defn spiral
[center start end r1 r2 steps]
Expand Down Expand Up @@ -232,8 +232,8 @@ is defined in its own namespace and can be loaded from the REPL via:
[thi.ng.geom.core.vector :refer [vec2]]
[thi.ng.geom.core.matrix :refer [M32]]
[thi.ng.geom.svg.core :as svg]
[thi.ng.common.math.core :as m]
[thi.ng.macromath.core :as mm]))
[thi.ng.math.core :as m]
[thi.ng.math.macros :as mm]))

(defn spiral
[center start end r1 r2 steps]
Expand Down
34 changes: 9 additions & 25 deletions geom-svg/src/index.org
Original file line number Diff line number Diff line change
Expand Up @@ -66,40 +66,24 @@ target/geom-svg-<<conf-version()>>.js
:min-lein-version "2.4.0"

:dependencies [<<dep-clj>>
<<dep-cljs>>
[thi.ng/geom-core "<<conf-version()>>"]
[thi.ng/geom-types "<<conf-version()>>"]
[thi.ng/geom-meshops "<<conf-version()>>"]
<<dep-color>>
<<dep-hiccup>>]

:source-paths ["src/cljx"]
:test-paths ["<<conf-gen-test-path>>"]
:source-paths ["src"]
:test-paths ["test"]

:profiles {:dev {:dependencies [<<dep-cljs>>
<<dep-criterium>>]
:plugins [<<dep-cljx>>
<<dep-cljsbuild>>
:profiles {:dev {:dependencies [<<dep-criterium>>]
:plugins [<<dep-cljsbuild>>
<<dep-cljs-test>>]
:global-vars {*warn-on-reflection* true}
:jvm-opts ^:replace []
:auto-clean false
:prep-tasks [["cljx" "once"]]
:aliases {"cleantest" ["do" "clean," "cljx" "once," "test," "cljsbuild" "test"]}}}

:cljx {:builds [{:source-paths ["src/cljx"]
:output-path "<<conf-gen-source-path>>"
:rules :clj}
{:source-paths ["src/cljx"]
:output-path "<<conf-gen-source-path>>"
:rules :cljs}
{:source-paths ["test/cljx"]
:output-path "<<conf-gen-test-path>>"
:rules :clj}
{:source-paths ["test/cljx"]
:output-path "<<conf-gen-test-path>>"
:rules :cljs}]}

:cljsbuild {:builds [{:source-paths ["<<conf-gen-source-path>>" "<<conf-gen-test-path>>"]
:aliases {"cleantest" ["do" "clean," "test," "cljsbuild" "test"]}}}

:cljsbuild {:builds [{:source-paths ["src" "test"]
:id "simple"
:compiler {:output-to "<<cljs-artefact-path>>"
:optimizations :whitespace
Expand Down Expand Up @@ -140,7 +124,7 @@ symbol =version= holding the version string defined above:

*** Version namespace :noexport:

#+BEGIN_SRC clojure :tangle ../babel/src/cljx/thi/ng/geom/svg/version.cljx :noweb yes :mkdirp yes :padline no
#+BEGIN_SRC clojure :tangle ../babel/src/thi/ng/geom/svg/version.cljc :noweb yes :mkdirp yes :padline no
(ns thi.ng.geom.svg.version)
(def version "<<conf-version()>>")
#+END_SRC
Expand Down
2 changes: 1 addition & 1 deletion geom-svg/src/renderer.org
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

** Complete namespace definition

#+BEGIN_SRC clojure :tangle ../babel/src/cljx/thi/ng/geom/svg/renderer.cljx :noweb yes :mkdirp yes :padline no
#+BEGIN_SRC clojure :tangle ../babel/src/thi/ng/geom/svg/renderer.cljc :noweb yes :mkdirp yes :padline no
(ns thi.ng.geom.svg.renderer
(:require
[thi.ng.geom.core :as g]
Expand Down
2 changes: 1 addition & 1 deletion geom-svg/src/shaders.org
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

** Complete namespace definition

#+BEGIN_SRC clojure :tangle ../babel/src/cljx/thi/ng/geom/svg/shaders.cljx :noweb yes :mkdirp yes :padline no
#+BEGIN_SRC clojure :tangle ../babel/src/thi/ng/geom/svg/shaders.cljc :noweb yes :mkdirp yes :padline no
(ns thi.ng.geom.svg.shaders
(:require
[thi.ng.geom.core :as g]
Expand Down

0 comments on commit 781783c

Please sign in to comment.