use of org.erlide.util.erlang.Signature in project erlide_eclipse by erlang.
the class OtpRpc method convertArgs.
private OtpErlangObject[] convertArgs(final String signature, final Object... args) throws SignatureException {
final Object[] args0 = args == null ? new OtpErlangObject[] {} : args;
Signature[] type;
type = Signature.parse(signature);
if (type == null) {
type = new Signature[args0.length];
for (int i = 0; i < args0.length; i++) {
type[i] = new Signature('x');
}
}
if (type.length != args0.length) {
throw new SignatureException("Signature doesn't match parameter number: " + type.length + "/" + args0.length);
}
final OtpErlangObject[] args1 = new OtpErlangObject[args0.length];
for (int i = 0; i < args1.length; i++) {
args1[i] = TypeConverter.java2erlang(args0[i], type[i]);
}
return args1;
}
use of org.erlide.util.erlang.Signature in project erlide_eclipse by erlang.
the class TypeConverterTest method parseSignature_3.
@Test
public void parseSignature_3() throws SignatureException {
final String sig = "2axd";
final Signature[] result = Signature.parse(sig);
final String expect = "[t(a,x), d]";
assertTrue(Arrays.toString(result).equals(expect));
}
use of org.erlide.util.erlang.Signature in project erlide_eclipse by erlang.
the class TypeConverterTest method parseSignature_5.
@Test
public void parseSignature_5() throws SignatureException {
final String sig = "32sadax";
final Signature[] result = Signature.parse(sig);
final String expect = "[t(t(s,a),d,a), x]";
assertTrue(Arrays.toString(result).equals(expect));
}
use of org.erlide.util.erlang.Signature in project erlide_eclipse by erlang.
the class TypeConverterTest method parseSignature_1.
@Test
public void parseSignature_1() throws SignatureException {
final String sig = "aslsilpfd";
final Signature[] result = Signature.parse(sig);
final String expect = "[a, s, l(s), i, l(p), f, d]";
Assert.assertEquals(expect, Arrays.toString(result));
}
use of org.erlide.util.erlang.Signature in project erlide_eclipse by erlang.
the class TypeConverterTest method parseSignature_2.
@Test
public void parseSignature_2() throws SignatureException {
final String sig = "llxi";
final Signature[] result = Signature.parse(sig);
final String expect = "[l(l(x)), i]";
assertTrue(Arrays.toString(result).equals(expect));
}
Aggregations