File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 367367 `(binding [*cljs-warning-handlers* ~handlers]
368368 ~@body)))
369369
370+ (defn- repeat-char [c n]
371+ (loop [ret c n n]
372+ (if (pos? n)
373+ (recur (str ret c) (dec n))
374+ ret)))
375+
376+ (defn- hex-format [s pad]
377+ #? (:clj (str " _u" (format (str " %0" pad " x" ) (int (first s))) " _" )
378+ :cljs (let [hex (.toString (.charCodeAt s 0 ) 16 )
379+ len (. hex -length)
380+ hex (if (< len pad)
381+ (str (repeat-char " 0" (- pad len)) hex)
382+ hex)]
383+ (str " _u" hex " _" ))))
384+
370385(defn gen-constant-id [value]
371386 (let [prefix (cond
372387 (keyword? value) " cst$kw$"
384399 (string/replace " -" " _DASH_" )
385400 (munge )
386401 (string/replace " ." " $" )
387- (string/replace #"(?i)[^a-z0-9$_]"
388- #(str " _u" (format " %04x" (int (first %))) " _" ))))]
402+ (string/replace #"(?i)[^a-z0-9$_]" #(hex-format % 4 ))))]
389403 (symbol (str prefix name))))
390404
391405(defn- register-constant!
You can’t perform that action at this time.
0 commit comments