Reimplement copy().

The old implementation used the serialization framework, which is
going away. This is a new standalone implementation that should also
be quite a bit faster.

WIP: Not fully implemented and tested yet.
This commit is contained in:
Robin Sommer 2017-06-14 07:23:37 -07:00
parent 49908ac865
commit b9dad02615
3 changed files with 244 additions and 24 deletions

View file

@ -0,0 +1,27 @@
# @TEST-EXEC: bro -b %INPUT >out
# @TEST-EXEC: btest-diff out
function check(o1: any, o2: any, equal: bool, expect_same: bool)
{
local expect_msg = (equal ? "ok" : "FAIL0");
local same = same_object(o1, o2);
if ( expect_same && ! same )
expect_msg = "FAIL1";
if ( ! expect_same && same )
expect_msg = "FAIL2";
print fmt("orig=%s (%s) clone=%s (%s) equal=%s same_object=%s (%s)", o1, type_name(o1), o2, type_name(o2), equal, same, expect_msg);
}
event zeek_init()
{
local i1 = -42;
local i2 = copy(i1);
check(i1, i2, i1 == i2, T);
local s1 = "Foo";
local s2 = copy(s1);
check(s1, s2, s1 == s2, F);
}