#23: cleanup up most of AOT cljs warnings.. [still have some]

This commit is contained in:
anatoly 2015-12-15 09:41:09 -05:00
parent dc5b6c2614
commit c1be3c377e
5 changed files with 43 additions and 49 deletions

1
.gitignore vendored
View file

@ -7,6 +7,7 @@ pom.xml.asc
dev/resources/public/js/* dev/resources/public/js/*
figwheel_server.log figwheel_server.log
build.xml build.xml
doo-index.html
*.jar *.jar
*.class *.class
/.lein-* /.lein-*

View file

@ -10,7 +10,7 @@
:profiles {:dev {:source-paths ["dev" "dev/clj"] :profiles {:dev {:source-paths ["dev" "dev/clj"]
:dependencies [[org.clojure/clojure "1.7.0"] :dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.170"] [org.clojure/clojurescript "1.7.170"]; :classifier "aot"]
[datascript "0.13.3"] [datascript "0.13.3"]
[hiccups "0.3.0"] [hiccups "0.3.0"]
[com.andrewmcveigh/cljs-time "0.3.14"] [com.andrewmcveigh/cljs-time "0.3.14"]

View file

@ -1,9 +1,8 @@
(ns mount.core (ns mount.core
#?(:clj (:require [mount.tools.macro :refer [on-error throw-runtime] :as macro]) #?(:clj (:require [mount.tools.macro :refer [on-error throw-runtime] :as macro])
:cljs (:require [mount.tools.macro :as macro] :cljs (:require [mount.tools.macro :as macro]))
[mount.tools.cljs :as cljs])) #?(:cljs (:require-macros [mount.core]
#?(:cljs (:require-macros [mount.tools.macro :refer [on-error throw-runtime]] [mount.tools.macro :refer [on-error throw-runtime]])))
[mount.core :refer [defstate]])))
(defonce ^:private -args (atom :no-args)) ;; mostly for command line args and external files (defonce ^:private -args (atom :no-args)) ;; mostly for command line args and external files
(defonce ^:private state-seq (atom 0)) (defonce ^:private state-seq (atom 0))
@ -36,8 +35,7 @@
(defn- pounded? [f] (defn- pounded? [f]
(let [pound "(fn* [] "] ;;TODO: think of a better (i.e. typed) way to distinguish #(f params) from (fn [params] (...))) (let [pound "(fn* [] "] ;;TODO: think of a better (i.e. typed) way to distinguish #(f params) from (fn [params] (...)))
#?(:clj (.startsWith (str f) pound) (.startsWith (str f) pound)))
:cljs (cljs/starts-with? (str f) pound))))
(defn unpound [f] (defn unpound [f]
(if (pounded? f) (if (pounded? f)
@ -128,6 +126,7 @@
(up name state (atom #{}))) (up name state (atom #{})))
@inst))) @inst)))
#?(:clj
(defmacro defstate [state & body] (defmacro defstate [state & body]
(let [[state params] (macro/name-with-attributes state body) (let [[state params] (macro/name-with-attributes state body)
{:keys [start stop suspend resume] :as lifecycle} (apply hash-map params) {:keys [start stop suspend resume] :as lifecycle} (apply hash-map params)
@ -146,7 +145,7 @@
(def ~state (DerefableState. ~state-name)) (def ~state (DerefableState. ~state-name))
((var update-meta!) [~state-name] (assoc ~s-meta :inst (atom (NotStartedState. ~state-name)) ((var update-meta!) [~state-name] (assoc ~s-meta :inst (atom (NotStartedState. ~state-name))
:var (var ~state))) :var (var ~state)))
(var ~state))))) (var ~state))))))
(defn in-cljc-mode [] (defn in-cljc-mode []
(reset! mode :cljc)) (reset! mode :cljc))
@ -182,7 +181,7 @@
#?(:cljs #?(:cljs
(defn var-to-str [v] (defn var-to-str [v]
(if (var? v) (if (instance? cljs.core.Var v)
(let [{:keys [ns name]} (meta v)] (let [{:keys [ns name]} (meta v)]
(with-ns ns name)) (with-ns ns name))
v))) v)))

View file

@ -1,9 +0,0 @@
(ns mount.tools.cljs
(:require [cljs.analyzer :as ana]
[goog.string :as gstring]))
(defn this-ns []
ana/*cljs-ns*)
(defn starts-with? [s pre]
(gstring/startsWith s pre))

View file

@ -1,16 +1,19 @@
(ns mount.tools.macro) (ns mount.tools.macro
#?(:cljs (:require-macros [mount.tools.macro])))
#?(:clj
(defmacro on-error [msg f] (defmacro on-error [msg f]
`(try `(try
~f ~f
(catch #?(:clj Throwable (catch #?(:clj Throwable
:cljs :default) t# :cljs :default) t#
(throw #?(:clj (RuntimeException. ~msg t#) (throw #?(:clj (RuntimeException. ~msg t#)
:cljs (js/Error (str ~msg (.-stack t#)))))))) :cljs (js/Error (str ~msg (.-stack t#)))))))))
#?(:clj
(defmacro throw-runtime [msg] (defmacro throw-runtime [msg]
`(throw #?(:clj (RuntimeException. ~msg) `(throw #?(:clj (RuntimeException. ~msg)
:cljs (js/Error (str ~msg))))) :cljs (js/Error (str ~msg))))))
;; this is a one to one copy from https://github.com/clojure/tools.macro ;; this is a one to one copy from https://github.com/clojure/tools.macro
;; to avoid a lib dependency for a single function ;; to avoid a lib dependency for a single function