<div dir="ltr">Hi Alex!<div><br></div><div style>Nice work! I like the API. </div><div style><br></div><div style>We have some similar extensions to jinterfaces in erlide, which I didn't got around to publishing as a standalone library. If you feel like checking it out, it's at <a href="https://github.com/erlide/erlide/tree/pu/org.erlide.util/src/org/erlide/util/erlang">https://github.com/erlide/erlide/tree/pu/org.erlide.util/src/org/erlide/util/erlang</a>. If you think that these are useful or interesting, we can look at how to integrate them. </div>
<div><br></div><div style>Some differences are that I implemented pattern matching with something like</div><div style> <span style="font-family:'courier new',monospace">Bindings b = match("{ping, From:p, Message:l}", someInput); </span><br>
</div><div style><font face="courier new, monospace"> // ':p' means is_pid and ':l' means is_list</font></div><div style><font face="courier new, monospace"> OtpErlangPid pid = b.getPid("From");</font></div>
<div style><font face="courier new, monospace"> Collection<OtpErlangObject> msg = b.getList("Message");</font></div><div style>which I find easier to read, but is a bit difficult to extend (for example with more advanced guards, which you can add easily). <br>
</div><div style><br></div><div style>I also chose to convert terms to Java objects by using a type signature, à la printf. It is used for doing nicer looking RPCs to Erlang, for example <font face="courier new, monospace">rpc.call("mod", "fun", "ssolxi", ...args)</font> will convert the args to (in order) two strings, a list of whatever ('x') and an integer.</div>
<div style><br></div><div style>There is also a format function that looks like printf or io:format, but produces OtpErlangObjects instead:</div><div style><font face="courier new, monospace">format("{hello, ~s, ~a, ~b}", "foo", "bar", "baz") --> {hello, "foo", bar, <<"baz">>} </font></div>
<div style><br></div><div style>regards,<br></div><div style>Vlad</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 18, 2013 at 11:25 PM, Alex Arnon <span dir="ltr"><<a href="mailto:alex.arnon@gmail.com" target="_blank">alex.arnon@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hi All,<br><br></div>I am releasing the first version of Helperl, a convenience wrapper for JInterface.<br>
<br></div><div>Project home page (at Bit Bucket): <a href="https://bitbucket.org/alexarnon/helperl" target="_blank">https://bitbucket.org/alexarnon/helperl</a><br>
</div><div><br></div>The idea was to try and make JInterface usage almost pleasant, because really guys, that API is still rocking all the hotness of Java 1.4.<br><br></div><div>Helperl has been successfully used in integration experiments. However, it is the first released version, and should be considered Alpha quality.<br>
</div><div><br></div>Examples:<br><br></div>* Construction of simple types, lists and tuples:<br><br><span style="font-family:courier new,monospace">--------------------<br><br></span></div><div><span style="font-family:courier new,monospace">12345 <- erl(12345)<br>
<br><<"hello">> <- erl("hello")<br><br></span></div><div><span style="font-family:courier new,monospace">'hello' <- eAtom("hello")<br><br></span></div>
<div><span style="font-family:courier new,monospace">[12345, 'qwerty'] <- erl(12345, eAtom("qwerty"))<br><br></span></div><div><span style="font-family:courier new,monospace">{ping, [123, 456]} <- eTuple(eAtom("ping"), erl(123, 456))<br>
</span></div><div><br><span style="font-family:courier new,monospace">--------------------<br><br></span><br>* Pattern matching:<br><br></div><div>Match {ping, From, Message} where is_pid(From) and is_list(Message), and extract the values.<br>
<br></div><div><br><span style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">--------------------<br><br></span> CompositePattern p = <br> pAnd(<br> pTuple( eAtom("ping"), p_("From"), p_("Message") ),<br>
</span></div><div><span style="font-family:courier new,monospace"> pIsPid("From"),<br></span></div><div><span style="font-family:courier new,monospace"> pIsList("Message") );<br>
<br>
</span></div><div><span style="font-family:courier new,monospace"> Map<String, OtpErlangObject> result = p.match(someInput);<br><br></span></div><div><span style="font-family:courier new,monospace"> if (result == null) {<br>
</span></div><div><span style="font-family:courier new,monospace"> // No match.<br></span></div><div><span style="font-family:courier new,monospace"> } else {<br></span></div><div><span style="font-family:courier new,monospace"> // Extract!<br>
</span></div><div><span style="font-family:courier new,monospace"> OtpErlangObject from = result.get("From");<br></span></div><div><span style="font-family:courier new,monospace"> OtpErlangObject message = result.get("Message");<br>
<br> // ...<br> }<br><br>--------------------</span><br><br>To download the source code and jars, please look at the Bit Bucket repo, or check out Maven Central, using:<br><br><span style="font-family:courier new,monospace"> <dependency><br>
<groupId>net.shambolica.helperl</groupId><br> <artifactId>helperl</artifactId><br> <version>0.2.0</version><br> </dependency></span><br><br>Note that the Maven artifact has a dependency on JInterface 1.5.6.<br>
<br></div><div>Please feel free to provide feedback!<br><br><br></div><div>Cheers,<br>Alex.<br><br></div></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>