diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-07-10 01:23:07 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-07-10 01:23:07 +0200 |
commit | f87943409c8ae2e9f6ed81e7a1cfc5109c16f31a (patch) | |
tree | ded56a166ef4648061379bab6c65bc40e5d01f8d /src/Binary.vala | |
parent | 2fc49125e73554d68b4ee8874b9f84725b6f2157 (diff) | |
download | eva-f87943409c8ae2e9f6ed81e7a1cfc5109c16f31a.tar eva-f87943409c8ae2e9f6ed81e7a1cfc5109c16f31a.zip |
Split Term code to individual class sources
Diffstat (limited to 'src/Binary.vala')
-rw-r--r-- | src/Binary.vala | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/Binary.vala b/src/Binary.vala new file mode 100644 index 0000000..3ac988a --- /dev/null +++ b/src/Binary.vala @@ -0,0 +1,38 @@ +namespace Eva { + public class Binary : Object, Term { + public void* value {get; private set;} + public long len {get; private set;} + + public Binary(char[] v) { + value = Memory.dup(v, (uint)(sizeof(char)*v.length)); + len = v.length; + } + + public string to_string() { + return "#Bin"; + } + + protected bool do_match(Term o, Gee.Map<string, Term> vars, Gee.Map<string, string> aliases) { + if(o is Var) { + return o.do_match(this, vars, aliases); + } + + if(o is Binary) { + Binary b = o as Binary; + + if(b.len != len) + return false; + + return (Memory.cmp(value, b.value, len) == 0); + } + else { + return false; + } + } + + + public void encode(Erl.Buffer buffer) { + buffer.encode_binary((char*)value, len); + } + } +} |