diff options
author | Sverker Eriksson <[email protected]> | 2015-11-20 19:45:29 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2016-04-07 18:41:47 +0200 |
commit | 539ce190ba8f8842c24b17f3257c44cd850d7e01 (patch) | |
tree | 44fdc375d19068ca9434f943bb3d23bdfe79c570 /lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPort.java | |
parent | 9c80b9ec06fc0ca89dcc8d797a2dbc408a162098 (diff) | |
download | otp-539ce190ba8f8842c24b17f3257c44cd850d7e01.tar.gz otp-539ce190ba8f8842c24b17f3257c44cd850d7e01.tar.bz2 otp-539ce190ba8f8842c24b17f3257c44cd850d7e01.zip |
jinterface: Support 32-bit creation values
Diffstat (limited to 'lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPort.java')
-rw-r--r-- | lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPort.java | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPort.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPort.java index a6198d56cc..16c8d2ed85 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPort.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPort.java @@ -26,6 +26,7 @@ public class OtpErlangPort extends OtpErlangObject { // don't change this! private static final long serialVersionUID = 4037115468007644704L; + private final int tag; private final String node; private final int id; private final int creation; @@ -42,6 +43,7 @@ public class OtpErlangPort extends OtpErlangObject { private OtpErlangPort(final OtpSelf self) { final OtpErlangPort p = self.createPort(); + tag = p.tag; id = p.id; creation = p.creation; node = p.node; @@ -62,6 +64,7 @@ public class OtpErlangPort extends OtpErlangObject { throws OtpErlangDecodeException { final OtpErlangPort p = buf.read_port(); + tag = p.tag; node = p.node(); id = p.id(); creation = p.creation(); @@ -77,13 +80,45 @@ public class OtpErlangPort extends OtpErlangObject { * an arbitrary number. Only the low order 28 bits will be used. * * @param creation - * another arbitrary number. Only the low order 2 bits will be - * used. + * another arbitrary number. Only the low order 2 bits will be used. */ public OtpErlangPort(final String node, final int id, final int creation) { - this.node = node; - this.id = id & 0xfffffff; // 28 bits - this.creation = creation & 0x03; // 2 bits + this(OtpExternal.portTag, node, id, creation); + } + + /** + * Create an Erlang port from its components. + * + * @param tag + * the external format to be compliant with. + * OtpExternal.portTag where only a subset of the bits are used (see other constructor) + * OtpExternal.newPortTag where all 32 bits of id and creation are significant. + * newPortTag can only be decoded by OTP-19 and newer. + * @param node + * the nodename. + * + * @param id + * an arbitrary number. Only the low order 28 bits will be used. + * + * @param creation + * another arbitrary number. + */ + public OtpErlangPort(final int tag, final String node, final int id, + final int creation) { + this.tag = tag; + this.node = node; + if (tag == OtpExternal.portTag) { + this.id = id & 0xfffffff; // 28 bits + this.creation = creation & 0x3; // 2 bits + } + else { + this.id = id; + this.creation = creation; + } + } + + protected int tag() { + return tag; } /** @@ -132,7 +167,7 @@ public class OtpErlangPort extends OtpErlangObject { */ @Override public void encode(final OtpOutputStream buf) { - buf.write_port(node, id, creation); + buf.write_port(this); } /** |