From f87943409c8ae2e9f6ed81e7a1cfc5109c16f31a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 10 Jul 2010 01:23:07 +0200 Subject: Split Term code to individual class sources --- src/Port.vala | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Port.vala (limited to 'src/Port.vala') diff --git a/src/Port.vala b/src/Port.vala new file mode 100644 index 0000000..b67c808 --- /dev/null +++ b/src/Port.vala @@ -0,0 +1,46 @@ +namespace Eva { + public class Port : Object, Term { + public string node {get; construct;} + public uint id {get; construct;} + public uint creation {get; construct;} + + public Port(Erl.Port port) { + this.create(array_to_string(port.node, Erl.MAXATOMLEN), port.id, port.creation); + } + + private Port.create(string node0, uint id0, uint creation0) { + Object(node: node0, id: id0, creation: creation0); + } + + public string to_string() { + return "#Port"; + } + + protected bool do_match(Term o, Gee.Map vars, Gee.Map aliases) { + if(o is Var) { + return o.do_match(this, vars, aliases); + } + + if(!(o is Port)) + return false; + + Port p = o as Port; + + return (node == p.node && id == p.id && creation == p.creation); + } + + public void encode(Erl.Buffer buffer) { + Erl.Port port = Erl.Port(); + char[]? nodedata = string_to_array(node); + assert(nodedata != null); + + Memory.copy(port.node, nodedata, int.min(Erl.MAXATOMLEN, nodedata.length)); + port.node[int.min(Erl.MAXATOMLEN, nodedata.length)] = 0; + + port.id = id; + port.creation = creation; + + buffer.encode_port(port); + } + } +} -- cgit v1.2.3