Search in sources :

Example 1 with Signature

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;
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) Signature(org.erlide.util.erlang.Signature) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) SignatureException(org.erlide.util.erlang.SignatureException)

Example 2 with Signature

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));
}
Also used : Signature(org.erlide.util.erlang.Signature) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) Test(org.junit.Test)

Example 3 with Signature

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));
}
Also used : Signature(org.erlide.util.erlang.Signature) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) Test(org.junit.Test)

Example 4 with Signature

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));
}
Also used : Signature(org.erlide.util.erlang.Signature) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) Test(org.junit.Test)

Example 5 with Signature

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));
}
Also used : Signature(org.erlide.util.erlang.Signature) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) Test(org.junit.Test)

Aggregations

Signature (org.erlide.util.erlang.Signature)7 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)6 Test (org.junit.Test)6 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 SignatureException (org.erlide.util.erlang.SignatureException)1