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 367
367
`(binding [*cljs-warning-handlers* ~handlers]
368
368
~@body)))
369
369
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
+
370
385
(defn gen-constant-id [value]
371
386
(let [prefix (cond
372
387
(keyword? value) " cst$kw$"
384
399
(string/replace " -" " _DASH_" )
385
400
(munge )
386
401
(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 ))))]
389
403
(symbol (str prefix name))))
390
404
391
405
(defn- register-constant!
You can’t perform that action at this time.
0 commit comments