aboutsummaryrefslogtreecommitdiff
path: root/clojurescript
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2008-11-21 03:38:01 +0000
committerChouser <chouser@n01se.net>2008-11-21 03:38:01 +0000
commite0c68ea35298096ccd0e633c9ff8382aabfa1c35 (patch)
tree939e69512febdb267eb9d31614a773da73c6f89c /clojurescript
parentff585557a4614c83a2d1cb89ebd4466fa87f7158 (diff)
Moving clojurescript toward deployment of repl demo
Diffstat (limited to 'clojurescript')
-rw-r--r--clojurescript/avoid-java-in-clojure-core.patch48
-rw-r--r--clojurescript/repl/repl.cljs2
-rw-r--r--clojurescript/repl/repl.js125
-rw-r--r--clojurescript/tojs.clj35
4 files changed, 78 insertions, 132 deletions
diff --git a/clojurescript/avoid-java-in-clojure-core.patch b/clojurescript/avoid-java-in-clojure-core.patch
index 6dd714d3..8e76eea9 100644
--- a/clojurescript/avoid-java-in-clojure-core.patch
+++ b/clojurescript/avoid-java-in-clojure-core.patch
@@ -1,4 +1,4 @@
-commit f04a9322495cc7d02d9f2aa3e4e066e5829df6b7
+commit 2fd9fcb876effe15a10ceadda7649f89fa0c7bb1
Author: Chouser <chouser@n01se.net>
Date: Sun Nov 16 01:02:30 2008 -0500
@@ -74,7 +74,7 @@ index 05c8abc..0f04558 100644
\ No newline at end of file
+(def #^{:private true} print-initialized true)
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
-index c0174c0..8376f13 100644
+index 1e74fef..982205c 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -319,7 +319,7 @@
@@ -164,7 +164,7 @@ index c0174c0..8376f13 100644
(let [latch (new java.util.concurrent.CountDownLatch (count agents))
count-down (fn [agent] (. latch (countDown)) agent)]
(doseq [agent agents]
-@@ -1798,6 +1798,7 @@
+@@ -1801,6 +1801,7 @@
(import '(java.lang.reflect Array))
@@ -172,16 +172,16 @@ index c0174c0..8376f13 100644
(defn alength
"Returns the length of the Java array. Works on arrays of all
-@@ -1817,7 +1818,7 @@
+@@ -1820,7 +1821,7 @@
{:inline (fn [a i] `(. clojure.lang.RT (aget ~a ~i)))
:inline-arities #{2}}
([array idx]
-- (. Array (get array idx)))
-+ (RT/aget array idx))
+- (clojure.lang.Reflector/prepRet (. Array (get array idx))))
++ (clojure.lang.Reflector/prepRet (RT/aget array idx)))
([array idx & idxs]
(apply aget (aget array idx) idxs)))
-@@ -1827,7 +1828,7 @@
+@@ -1830,7 +1831,7 @@
{:inline (fn [a i v] `(. clojure.lang.RT (aset ~a ~i ~v)))
:inline-arities #{3}}
([array idx val]
@@ -190,7 +190,7 @@ index c0174c0..8376f13 100644
val)
([array idx idx2 & idxv]
(apply aset (aget array idx) idx2 idxv)))
-@@ -1995,6 +1996,10 @@
+@@ -1998,6 +1999,10 @@
"Returns a set of the distinct elements of coll."
[coll] (apply hash-set coll))
@@ -201,7 +201,7 @@ index c0174c0..8376f13 100644
(defn #^{:private true}
filter-key [keyfn pred amap]
(loop [ret {} es (seq amap)]
-@@ -2027,7 +2032,7 @@
+@@ -2030,7 +2035,7 @@
the-ns [x]
(if (instance? clojure.lang.Namespace x)
x
@@ -210,7 +210,7 @@ index c0174c0..8376f13 100644
(defn ns-name
"Returns the name of the namespace, a symbol."
-@@ -2060,7 +2065,7 @@
+@@ -2063,7 +2068,7 @@
(defn ns-imports
"Returns a map of the import mappings for the namespace."
[ns]
@@ -219,7 +219,7 @@ index c0174c0..8376f13 100644
(defn refer
"refers to all public vars of ns, subject to filters.
-@@ -2078,7 +2083,8 @@
+@@ -2081,7 +2086,8 @@
to a symbol different from the var's name, in order to prevent
clashes. Use :use in the ns macro in preference to calling this directly."
[ns-sym & filters]
@@ -229,7 +229,7 @@ index c0174c0..8376f13 100644
fs (apply hash-map filters)
nspublics (ns-publics ns)
rename (or (:rename fs) {})
-@@ -2207,7 +2213,7 @@
+@@ -2210,7 +2216,7 @@
true)
(= firstb :as) (pb ret (second bs) gvec)
:else (if seen-rest?
@@ -238,7 +238,7 @@ index c0174c0..8376f13 100644
(recur (pb ret firstb (list `nth gvec n nil))
(inc n)
(rest bs)
-@@ -2238,7 +2244,7 @@
+@@ -2241,7 +2247,7 @@
(symbol? b) (-> bvec (conj b) (conj v))
(vector? b) (pvec bvec b v)
(map? b) (pmap bvec b v)
@@ -247,7 +247,7 @@ index c0174c0..8376f13 100644
process-entry (fn [bvec b] (pb bvec (key b) (val b)))]
(if (every? symbol? (keys bmap))
bindings
-@@ -2385,7 +2391,7 @@
+@@ -2388,7 +2394,7 @@
StringWriter. Returns the string created by any nested printing
calls."
[& body]
@@ -256,7 +256,7 @@ index c0174c0..8376f13 100644
(binding [*out* s#]
~@body
(str s#))))
-@@ -2431,7 +2437,7 @@
+@@ -2434,7 +2440,7 @@
logical true."
[x]
`(when-not ~x
@@ -265,7 +265,7 @@ index c0174c0..8376f13 100644
(defn test
"test [v] finds fn at key :test in var metadata and calls it,
-@@ -2503,7 +2509,7 @@
+@@ -2506,7 +2512,7 @@
(defn rand
"Returns a random floating point number between 0 (inclusive) and
1 (exclusive)."
@@ -274,7 +274,7 @@ index c0174c0..8376f13 100644
([n] (* n (rand))))
(defn rand-int
-@@ -2613,7 +2619,7 @@
+@@ -2616,7 +2622,7 @@
"Reads the file named by f into a string and returns it."
[#^String f]
(with-open [r (new java.io.BufferedReader (new java.io.FileReader f))]
@@ -283,7 +283,7 @@ index c0174c0..8376f13 100644
(loop [c (. r (read))]
(if (neg? c)
(str sb)
-@@ -2897,10 +2903,6 @@
+@@ -2900,10 +2906,6 @@
(send-off agt fill)
(drain))))
@@ -294,7 +294,7 @@ index c0174c0..8376f13 100644
(defn alter-var-root
"Atomically alters the root binding of var v by applying f to its
current value plus any args"
-@@ -2986,7 +2988,7 @@
+@@ -2989,7 +2991,7 @@
relationships."
([tag] (descendants global-hierarchy tag))
([h tag] (if (class? tag)
@@ -303,7 +303,7 @@ index c0174c0..8376f13 100644
(not-empty (get (:descendants h) tag)))))
(defn derive
-@@ -3013,9 +3015,9 @@
+@@ -3016,9 +3018,9 @@
(or
(when-not (contains? (tp tag) parent)
(when (contains? (ta tag) parent)
@@ -315,7 +315,7 @@ index c0174c0..8376f13 100644
{:parents (assoc (:parents h) tag (conj (get tp tag #{}) parent))
:ancestors (tf (:ancestors h) tag td parent ta)
:descendants (tf (:descendants h) parent ta tag td)})
-@@ -3142,7 +3144,7 @@
+@@ -3148,7 +3150,7 @@
[pred fmt & args]
(when pred
(let [message (apply format fmt args)
@@ -325,7 +325,7 @@ index c0174c0..8376f13 100644
boring? #(not= (.getMethodName %) "doInvoke")
trace (into-array (drop 2 (drop-while boring? raw-trace)))]
diff --git a/src/jvm/clojure/lang/RT.java b/src/jvm/clojure/lang/RT.java
-index dc4451a..9d7e31f 100644
+index f6139d1..fab9304 100644
--- a/src/jvm/clojure/lang/RT.java
+++ b/src/jvm/clojure/lang/RT.java
@@ -35,6 +35,8 @@ public class RT{
@@ -337,7 +337,7 @@ index dc4451a..9d7e31f 100644
//simple-symbol->class
final static IPersistentMap DEFAULT_IMPORTS = map(
// Symbol.create("RT"), "clojure.lang.RT",
-@@ -1058,6 +1060,10 @@ static public double doubleCast(double x){
+@@ -1060,6 +1062,10 @@ static public double doubleCast(double x){
return x;
}
@@ -348,7 +348,7 @@ index dc4451a..9d7e31f 100644
static public IPersistentMap map(Object... init){
if(init != null && init.length == 2)
return new PersistentArrayMap(init);
-@@ -1780,4 +1786,43 @@ static public int alength(Object xs){
+@@ -1792,4 +1798,43 @@ static public int alength(Object xs){
return Array.getLength(xs);
}
diff --git a/clojurescript/repl/repl.cljs b/clojurescript/repl/repl.cljs
index acf0178f..353f3280 100644
--- a/clojurescript/repl/repl.cljs
+++ b/clojurescript/repl/repl.cljs
@@ -82,7 +82,7 @@
(when (== (.keyCode e) 13)
(set! (-> :status elems .src) "clojure-logo-anim-03.gif")
(append-dom (:scripts elems)
- [:script {:src (str "http://localhost:8081/"
+ [:script {:src (str "http://localhost/proj/cgi-proxy/cgi-proxy.cgi?"
(-> :input elems .value escape
(.replace #"\+" "%2b")))}])))))
diff --git a/clojurescript/repl/repl.js b/clojurescript/repl/repl.js
index 50132f6a..2a33b531 100644
--- a/clojurescript/repl/repl.js
+++ b/clojurescript/repl/repl.js
@@ -1,145 +1,88 @@
-
-//======
-//(ns jsrepl)
-//---
-(function __user_fn_398(){
+(function(){
return (clojure.core.in_ns.apply(null,[clojure.core.symbol("jsrepl")]),
clojure.core.refer.apply(null,[clojure.core.symbol("clojure.core")]))}).apply(null,[]);
-
-//======
-//(def append-dom)
-//---
-(function __jsrepl_fn_404(){
+(function(){
return (clojure.JS.def(jsrepl,"append_dom",null))}).apply(null,[]);
-
-//======
-//(defn dom [o] (if (coll? o) (let [[tag attrs & body] o] (if (keyword? tag) (let [elem (.createElement document (name tag))] (when (map? attrs) (doseq [[k v] attrs] (when v (.setAttribute elem (name k) v)))) [(append-dom elem (if (map? attrs) body (cons attrs body)))]) (mapcat dom o))) (when o [(.createTextNode document (str o))])))
-//---
-(function __jsrepl_fn_407(){
-return (clojure.JS.def(jsrepl,"dom",(function __jsrepl_fn_407_dom_409(o_1){
+(function(){
+return (clojure.JS.def(jsrepl,"dom",(function(o_1){
var elem_6,v_10,body_5,attrs_4,tag_3,sq__2972_7,k_9,vec__412_8,vec__411_2;
return (((clojure.core.coll_QMARK_.apply(null,[o_1]))?(((vec__411_2=o_1),
(tag_3=clojure.core.nth.apply(null,[vec__411_2,(0),null])),
(attrs_4=clojure.core.nth.apply(null,[vec__411_2,(1),null])),
(body_5=clojure.core.nthrest.apply(null,[vec__411_2,(2)])),
((clojure.core.keyword_QMARK_.apply(null,[tag_3]))?(((elem_6=(clojure.JS.resolveVar("document",jsrepl)).createElement(clojure.core.name.apply(null,[tag_3]))),
-((clojure.core.map_QMARK_.apply(null,[attrs_4]))?(((function __loop(){var _rtn,_cnt;(sq__2972_7=clojure.core.seq.apply(null,[attrs_4]));do{_cnt=0;
+((clojure.core.map_QMARK_.apply(null,[attrs_4]))?(((function(){var _rtn,_cnt;(sq__2972_7=clojure.core.seq.apply(null,[attrs_4]));do{_cnt=0;
_rtn=((sq__2972_7)?(((vec__412_8=clojure.core.first.apply(null,[sq__2972_7])),
(k_9=clojure.core.nth.apply(null,[vec__412_8,(0),null])),
(v_10=clojure.core.nth.apply(null,[vec__412_8,(1),null])),
((true)?(((true)?(((v_10)?((elem_6).setAttribute(clojure.core.name.apply(null,[k_9]),v_10)):(null))):(null)),
(_cnt=1,_rtn=[clojure.core.rest.apply(null,[sq__2972_7])],sq__2972_7=_rtn[0])):(null)))):(null))}while(_cnt);return _rtn;})())):(null)),
clojure.JS.lit_vector([jsrepl.append_dom.apply(null,[elem_6,((clojure.core.map_QMARK_.apply(null,[attrs_4]))?(body_5):(clojure.core.cons.apply(null,[attrs_4,body_5])))])]))):(clojure.core.mapcat.apply(null,[jsrepl.dom,o_1]))))):(((o_1)?(clojure.JS.lit_vector([(clojure.JS.resolveVar("document",jsrepl)).createTextNode(clojure.core.str.apply(null,[o_1]))])):(null)))))})))}).apply(null,[]);
-
-//======
-//(defn append-dom [parent v] (doseq [i (dom v)] (.appendChild parent i)) parent)
-//---
-(function __jsrepl_fn_415(){
-return (clojure.JS.def(jsrepl,"append_dom",(function __jsrepl_fn_415_append_dom_417(parent_1,v_2){
+(function(){
+return (clojure.JS.def(jsrepl,"append_dom",(function(parent_1,v_2){
var sq__2972_3,i_4;
-return (((function __loop(){var _rtn,_cnt;(sq__2972_3=clojure.core.seq.apply(null,[jsrepl.dom.apply(null,[v_2])]));do{_cnt=0;
+return (((function(){var _rtn,_cnt;(sq__2972_3=clojure.core.seq.apply(null,[jsrepl.dom.apply(null,[v_2])]));do{_cnt=0;
_rtn=((sq__2972_3)?(((i_4=clojure.core.first.apply(null,[sq__2972_3])),
((true)?(((true)?((parent_1).appendChild(i_4)):(null)),
(_cnt=1,_rtn=[clojure.core.rest.apply(null,[sq__2972_3])],sq__2972_3=_rtn[0])):(null)))):(null))}while(_cnt);return _rtn;})()),
parent_1)})))}).apply(null,[]);
-
-//======
-//(def elems)
-//---
-(function __jsrepl_fn_421(){
+(function(){
return (clojure.JS.def(jsrepl,"elems",null))}).apply(null,[]);
-
-//======
-//(def lastval)
-//---
-(function __jsrepl_fn_424(){
+(function(){
return (clojure.JS.def(jsrepl,"lastval",null))}).apply(null,[]);
-
-//======
-//(def *print-class* nil)
-//---
-(function __jsrepl_fn_427(){
+(function(){
return (clojure.JS.def(jsrepl,"_STAR_print_class_STAR_",null))}).apply(null,[]);
-
-//======
-//(defn repl-print [text] (let [log (:log elems)] (doseq [line (.split text #"\n")] (append-dom log [:div {:class (str "cg " (when *print-class* (str " " *print-class*)))} line])) (set! (.scrollTop log) (.scrollHeight log))))
-//---
-(function __jsrepl_fn_430(){
-return (clojure.JS.def(jsrepl,"repl_print",(function __jsrepl_fn_430_repl_print_432(text_1){
-var sq__2972_3,log_2,line_4;
+(function(){
+return (clojure.JS.def(jsrepl,"repl_print",(function(text_1){
+var line_4,sq__2972_3,log_2;
return (((log_2=clojure.core.keyword("","log").apply(null,[jsrepl.elems])),
-((function __loop(){var _rtn,_cnt;(sq__2972_3=clojure.core.seq.apply(null,[(text_1).split((/\n/))]));do{_cnt=0;
+((function(){var _rtn,_cnt;(sq__2972_3=clojure.core.seq.apply(null,[(text_1).split((/\n/))]));do{_cnt=0;
_rtn=((sq__2972_3)?(((line_4=clojure.core.first.apply(null,[sq__2972_3])),
((true)?(((true)?(jsrepl.append_dom.apply(null,[log_2,clojure.JS.lit_vector([clojure.core.keyword("","div"),clojure.core.hash_map(clojure.core.keyword("","class"),clojure.core.str.apply(null,["cg ",((jsrepl._STAR_print_class_STAR_)?(clojure.core.str.apply(null,[" ",jsrepl._STAR_print_class_STAR_])):(null))])),line_4])])):(null)),
(_cnt=1,_rtn=[clojure.core.rest.apply(null,[sq__2972_3])],sq__2972_3=_rtn[0])):(null)))):(null))}while(_cnt);return _rtn;})()),
(log_2.scrollTop=clojure.JS.getOrRun(log_2,"scrollHeight"))))})))}).apply(null,[]);
-
-//======
-//(defn postexpr [] (append-dom (:log elems) [:table [:tbody [:tr [:td {:class "cg"} "user=> "] [:td (-> :input elems .value (.replace #"\n$" ""))]]]]) (set! (-> :scripts elems .innerHTML) "") (set! (-> :input elems .value) ""))
-//---
-(function __jsrepl_fn_436(){
-return (clojure.JS.def(jsrepl,"postexpr",(function __jsrepl_fn_436_postexpr_438(){
+(function(){
+return (clojure.JS.def(jsrepl,"postexpr",(function(){
return (jsrepl.append_dom.apply(null,[clojure.core.keyword("","log").apply(null,[jsrepl.elems]),clojure.JS.lit_vector([clojure.core.keyword("","table"),clojure.JS.lit_vector([clojure.core.keyword("","tbody"),clojure.JS.lit_vector([clojure.core.keyword("","tr"),clojure.JS.lit_vector([clojure.core.keyword("","td"),clojure.core.hash_map(clojure.core.keyword("","class"),"cg"),"user=> "]),clojure.JS.lit_vector([clojure.core.keyword("","td"),(clojure.JS.getOrRun(jsrepl.elems.apply(null,[clojure.core.keyword("","input")]),"value")).replace((/\n$/),"")])])])])]),
(jsrepl.elems.apply(null,[clojure.core.keyword("","scripts")]).innerHTML=""),
(jsrepl.elems.apply(null,[clojure.core.keyword("","input")]).value=""))})))}).apply(null,[]);
-// Skipping: (defmacro print-with-class [c m] (clojure.core/concat (clojure.core/list (quote clojure.core/binding)) (clojure.core/list (clojure.core/apply clojure.core/vector (clojure.core/concat (clojure.core/list (quote jsrepl/*print-class*)) (clojure.core/list c)))) (clojure.core/list (clojure.core/concat (clojure.core/list (quote clojure.core/println)) (clojure.core/list m)))))
-
-//======
-//(defn show-state [url] (set! (-> :status elems .src) url))
-//---
-(function __jsrepl_fn_451(){
-return (clojure.JS.def(jsrepl,"show_state",(function __jsrepl_fn_451_show_state_453(url_1){
+(function(){
+return (clojure.JS.def(jsrepl,"show_state",(function(url_1){
return ((jsrepl.elems.apply(null,[clojure.core.keyword("","status")]).src=url_1))})))}).apply(null,[]);
-
-//======
-//(defn state [status msg] (cond (= status "incomplete") (show-state "dots.png") (= status "done") (prn lastval) (= status "error") (do (postexpr) (show-state "blank.gif") (print-with-class "err" msg)) (= status "compiled") (do (postexpr) (setTimeout (fn* [] (show-state "blank.gif")) 0))))
-//---
-(function __jsrepl_fn_457(){
-return (clojure.JS.def(jsrepl,"state",(function __jsrepl_fn_457_state_459(status_1,msg_2){
+(function(){
+return (clojure.JS.def(jsrepl,"state",(function(status_1,msg_2){
return (((clojure.lang.Util.equal(status_1,"incomplete"))?(jsrepl.show_state.apply(null,["dots.png"])):(((clojure.lang.Util.equal(status_1,"done"))?(clojure.core.prn.apply(null,[jsrepl.lastval])):(((clojure.lang.Util.equal(status_1,"error"))?(jsrepl.postexpr.apply(null,[]),
jsrepl.show_state.apply(null,["blank.gif"]),
clojure.lang.Var.pushThreadBindings(clojure.core.hash_map.apply(null,[jsrepl._var__STAR_print_class_STAR_,"err"])),
-(function __try(){try{var _rtn=(clojure.core.println.apply(null,[msg_2]))}
+(function(){try{var _rtn=(clojure.core.println.apply(null,[msg_2]))}
finally{clojure.lang.Var.popThreadBindings()}return _rtn})()):(((clojure.lang.Util.equal(status_1,"compiled"))?(jsrepl.postexpr.apply(null,[]),
-clojure.JS.resolveVar("setTimeout",jsrepl).apply(null,[(function __jsrepl_fn_457_state_459_fn_461(){
+clojure.JS.resolveVar("setTimeout",jsrepl).apply(null,[(function(){
return (jsrepl.show_state.apply(null,["blank.gif"]))}),(0)])):(null)))))))))})))}).apply(null,[]);
-
-//======
-//(defn err [e] (print-with-class "err" e) (set! *e e))
-//---
-(function __jsrepl_fn_466(){
-return (clojure.JS.def(jsrepl,"err",(function __jsrepl_fn_466_err_468(e_1){
+(function(){
+return (clojure.JS.def(jsrepl,"err",(function(e_1){
return (clojure.lang.Var.pushThreadBindings(clojure.core.hash_map.apply(null,[jsrepl._var__STAR_print_class_STAR_,"err"])),
-(function __jsrepl_fn_466_err_468_fn_470(){
-return ((function __try(){try{var _rtn=(clojure.core.println.apply(null,[e_1]))}
+(function(){
+return ((function(){try{var _rtn=(clojure.core.println.apply(null,[e_1]))}
finally{clojure.lang.Var.popThreadBindings()}return _rtn})())}).apply(null,[]),
clojure.core._var__STAR_e.set(e_1))})))}).apply(null,[]);
-
-//======
-//(set! *print-length* 103)
-//---
-(function __jsrepl_fn_475(){
+(function(){
return (clojure.core._var__STAR_print_length_STAR_.set((103)))}).apply(null,[]);
-
-//======
-//(set! (.onload window) (fn [] (set! elems (into {} (for [n (quote (log input status scripts))] [(keyword n) (.getElementById document (str n))]))) (set! (.print window) repl-print) (set! (.onkeypress (:input elems)) (fn [e] (let [e (or e event)] (when (== (.keyCode e) 13) (set! (-> :status elems .src) "clojure-logo-anim-03.gif") (append-dom (:scripts elems) [:script {:src (str "http://localhost:8081/" (-> :input elems .value escape (.replace #"\+" "%2b")))}]))))) (println "ClojureScript") (.focus (:input elems))))
-//---
-(function __jsrepl_fn_478(){
-return ((clojure.JS.resolveVar("window",jsrepl).onload=(function __jsrepl_fn_478_fn_480(){
+(function(){
+return ((clojure.JS.resolveVar("window",jsrepl).onload=(function(){
var iter__3425_1;
-return (jsrepl._var_elems.set(clojure.core.into.apply(null,[clojure.lang.PersistentHashMap.EMPTY,((iter__3425_1=(function __jsrepl_fn_478_fn_480_iter_482_484(s__483_1){
+return (jsrepl._var_elems.set(clojure.core.into.apply(null,[clojure.lang.PersistentHashMap.EMPTY,((iter__3425_1=(function(s__483_1){
var n_2,iter__482_0=arguments.callee;
return (((clojure.core.seq.apply(null,[s__483_1]))?(((n_2=clojure.core.first.apply(null,[s__483_1])),
-((true)?((new clojure.lang.LazyCons((function __jsrepl_fn_478_fn_480_iter_482_484_fn_486(G__485_1){switch(arguments.length){
+((true)?((new clojure.lang.LazyCons((function(G__485_1){switch(arguments.length){
case 0:return (clojure.JS.lit_vector([clojure.core.keyword.apply(null,[n_2]),(clojure.JS.resolveVar("document",jsrepl)).getElementById(clojure.core.str.apply(null,[n_2]))]))}
return (iter__482_0.apply(null,[clojure.core.rest.apply(null,[s__483_1])]))})))):(null)))):(null)))})),
iter__3425_1.apply(null,[clojure.JS.lit_list([clojure.core.symbol("log"),clojure.core.symbol("input"),clojure.core.symbol("status"),clojure.core.symbol("scripts")])]))])),
(clojure.JS.resolveVar("window",jsrepl).print=jsrepl.repl_print),
-(clojure.core.keyword("","input").apply(null,[jsrepl.elems]).onkeypress=(function __jsrepl_fn_478_fn_480_fn_491(e_1){
+(clojure.core.keyword("","input").apply(null,[jsrepl.elems]).onkeypress=(function(e_1){
var or__2371_2,e_2;
return (((e_2=((or__2371_2=e_1),
((or__2371_2)?(or__2371_2):(clojure.JS.resolveVar("event",jsrepl))))),
((clojure.lang.Numbers.equiv(clojure.JS.getOrRun(e_2,"keyCode"),(13)))?((jsrepl.elems.apply(null,[clojure.core.keyword("","status")]).src="clojure-logo-anim-03.gif"),
-jsrepl.append_dom.apply(null,[clojure.core.keyword("","scripts").apply(null,[jsrepl.elems]),clojure.JS.lit_vector([clojure.core.keyword("","script"),clojure.core.hash_map(clojure.core.keyword("","src"),clojure.core.str.apply(null,["http://localhost:8081/",(clojure.JS.resolveVar("escape",jsrepl).apply(null,[clojure.JS.getOrRun(jsrepl.elems.apply(null,[clojure.core.keyword("","input")]),"value")])).replace((/\+/),"%2b")]))])])):(null))))})),
+jsrepl.append_dom.apply(null,[clojure.core.keyword("","scripts").apply(null,[jsrepl.elems]),clojure.JS.lit_vector([clojure.core.keyword("","script"),clojure.core.hash_map(clojure.core.keyword("","src"),clojure.core.str.apply(null,["http://localhost/proj/cgi-proxy/cgi-proxy.cgi?",(clojure.JS.resolveVar("escape",jsrepl).apply(null,[clojure.JS.getOrRun(jsrepl.elems.apply(null,[clojure.core.keyword("","input")]),"value")])).replace((/\+/),"%2b")]))])])):(null))))})),
clojure.core.println.apply(null,["ClojureScript"]),
clojure.JS.getOrRun(clojure.core.keyword("","input").apply(null,[jsrepl.elems]),"focus"))})))}).apply(null,[]);
diff --git a/clojurescript/tojs.clj b/clojurescript/tojs.clj
index 7197629b..ba8800bf 100644
--- a/clojurescript/tojs.clj
+++ b/clojurescript/tojs.clj
@@ -8,7 +8,7 @@
; Reads Clojure code and emits equivalent JavaScript
-(ns tojs
+(ns clojurescript.tojs
(:import (clojure.lang Compiler Compiler$C Compiler$BodyExpr
Compiler$DefExpr Compiler$InstanceMethodExpr)
(java.io BufferedReader InputStreamReader StringReader PrintWriter)
@@ -397,7 +397,7 @@
(try
(print "HTTP/1.0 200 OK\nContent-Type: text/javascript\n\n")
(let [line1 (-> socket .getInputStream ds/reader .readLine)
- [_ url] (re-find #"^GET /(.*?) HTTP" line1)
+ [_ url] (re-find #"^GET /\?(.*?) HTTP" line1)
codestr (URLDecoder/decode url)
js (with-out-str (filetojs (StringReader. codestr)))]
(println "jsrepl.state('compiled');try{")
@@ -417,17 +417,20 @@
(doseq [file ["clojure/core.clj" "clojure/core-print.clj"]]
(filetojs (.getResourceAsStream (clojure.lang.RT/baseLoader) file)))))
-(with-command-line *command-line-args*
- "tojs -- Compile ClojureScript to JavaScript"
- [[simple? "Runs some simple built-in tests"]
- [serve "Starts a repl server on the given port" 8081]
- [mkcore? "Generates a core.js file"]
- [v? "Includes extra fn names and comments in js"]
- filenames]
- (binding [*debug-fn-names* v? *debug-comments* v?]
- (cond
- simple? (simple-tests)
- serve (start-server (Integer/parseInt serve))
- mkcore? (mkcore)
- :else (doseq [filename filenames]
- (filetojs filename)))))
+(defn main [& args]
+ (with-command-line args
+ "tojs -- Compile ClojureScript to JavaScript"
+ [[simple? "Runs some simple built-in tests"]
+ [serve "Starts a repl server on the given port" 8081]
+ [mkcore? "Generates a core.js file"]
+ [v? "Includes extra fn names and comments in js"]
+ filenames]
+ (binding [*debug-fn-names* v? *debug-comments* v?]
+ (cond
+ simple? (simple-tests)
+ serve (start-server (Integer/parseInt serve))
+ mkcore? (mkcore)
+ :else (doseq [filename filenames]
+ (filetojs filename))))))
+
+(when-not *compile-files* (apply main *command-line-args*))