Hi all,

I've got a very small Clojure task I need to get done.  If needed, I am 
willing to pay someone for it.  I expect would be less than an hour's work, 
but am not stuck on that =)

*Simple Summary*

I have a small, proprietary clojure library I am trying to embed in NodeJS 
via the node-java <https://github.com/joeferner/node-java> module.  I need 
help because the translation of types is a bit too arcane for me (as I'm 
new to both Clojure and Java).

*Details*

The node-java module needs to access a java class.  I already figured out 
how to export a class (using :gen-class and building with lein uberjar). 
 Node-java recognizes the class and is able to call the (static) functions. 
 

Unfortunately, I can't figure out how to define the *right* method 
signatures for the static functions.  I have made several good-ish guesses 
that have gotten me pretty close, but to no avail!  I need someone to 
bridge that gap for me and help me figure out the method signatures.

An example invocation of the function (from the unit tests) looks like this:

(def arg1 (clojure.core/vector 2.1 0.5 -0.7))

(def arg2 (clojure.core/vector 

    [1.1 1.4 2.4]

    [2.1 3.4 8.4]
    [7.3 0.8 4.4]
    [5.1 1.6 3.4]))

(myfunc arg1 arg2)


And the (myfunc arg1 arg2) returns things like (list 2.35120 4.298419).

My best guess for the method signature so far has been in the :gen-class 
method export

#^{:static true} [score ["[Ljava.lang.Number;" "[Ljava.lang.Object;"] 
"[[Ljava.lang.Number;"]


Then I can call the static method from javascript this way:

java.classpath.push('./path/to/my.jar');

const score = java.import('my.clojureClass');

score.myMethodSync([1.3,2,3,4.1,5,6], [[1.3,2],[3,4.4]]);


But I get this error:

Error: Error running static method
clojure.lang.ExceptionInfo: low data exception: too few values in data 
{:data [#<Integer[] [Ljava.lang.Integer;@3315d2d7>], :context [#<Object[] 
[Ljava.lang.Object;@5fa07e12>]}


Because the clojure method throws an error if the first argument has fewer 
than 3 values.  But, of course, it doesn't... it has 6 values.  So 
something's getting lost in translation.  Here's the part that throws the 
error.

(if (< (count data) 3)
  (throw (ex-info "low data exception: too few values in data"
                  {:data data :context context}))


 which leads me to believe that the JS array is being (count)ed as a single 
object, rather than an array of values.


Any help is greatly appreciated!  As I said before, if needed I'm happy to 
communicate with someone privately to try to get it done quickly and, time 
being of the essence, am very willing to pay for one's time.



Thanks,

-Sir Robert 





-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to