Skip to content
Browse files

Coercion functions from Clojure to Java

  • Loading branch information...
1 parent 7015f72 commit 55a875672d5f0059dc413161e0e9de37da558393 @videlalvaro committed Aug 14, 2010
Showing with 14 additions and 9 deletions.
  1. +14 −9 src/closerl/core.clj
View
23 src/closerl/core.clj
@@ -133,15 +133,20 @@
(defmethod as-seq OtpErlangTuple [o] (seq (.elements o)))
+;;Clojure to OtpErlang coercion
+
+(defn otp-double [v] (OtpErlangDouble. (double v)))
(defn otp-long [v] (OtpErlangLong. (long v)))
+
+(defn otp-string [#^String v] (OtpErlangString. v))
+
+(defn otp-binary [#^String v] (OtpErlangBinary. (.getBytes v)))
+
+(defn otp-atom [v] (OtpErlangAtom. v))
+
(defn otp-tuple [& args]
- (let [msg (into-array OtpErlangObject args)
- ]
- (OtpErlangTuple. msg)
- ))
-
-;OtpErlangObject[] msg = new OtpErlangObject[2];
-;msg[0] = mbox.self();
-;msg[1] = new OtpErlangAtom("hello, world");
-;OtpErlangTuple tuple = new OtpErlangTuple(msg);
+ (OtpErlangTuple. (into-array OtpErlangObject args)))
+
+(defn otp-list [& args]
+ (OtpErlangList. (into-array OtpErlangObject args)))

0 comments on commit 55a8756

Please sign in to comment.
Something went wrong with that request. Please try again.