Commits

Meikel Brandmeyer  committed fc45a5b

Add stringification of message parts

  • Participants
  • Parent commits 30a486e

Comments (0)

Files changed (1)

File nrepl-client/nrepl-client/nrepl-client.factor

 ! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 ! THE SOFTWARE.
 
-USING: accessors combinators io kernel math math.parser sequences uuid ;
+USING: accessors combinators io io.encodings.utf8 io.sockets kernel
+    math math.parser sequences strings uuid ;
 IN: nrepl-client
 
+: stringify ( string -- newstring )
+    [ { { [ dup CHAR: " = ] [ drop { CHAR: \ CHAR: " } >string ] }
+        { [ dup CHAR: \ = ] [ drop { CHAR: \ CHAR: \ } >string ] }
+        [ 1string ] } cond ] { } map-as "" concat-as ;
+
 TUPLE: message id code stdin ;
 : <message> ( code stdin -- message )
     uuid1 2over message boa swap drop swap drop ;
 
 : send-message ( message -- response )
     "3"        print
-    "\"id\""   print "\"" write dup id>>    write "\"" print
-    "\"code\"" print "\"" write dup code>>  write "\"" print
-    "\"in\""   print "\"" write dup stdin>> write "\"" print
+    "\"id\""   print "\"" write dup id>>    stringify write "\"" print
+    "\"code\"" print "\"" write dup code>>  stringify write "\"" print
+    "\"in\""   print "\"" write dup stdin>> stringify write "\"" print
+    flush
     id>> <response> ;