diff --git a/src/spicy/runtime-support.h b/src/spicy/runtime-support.h index 78d82d3897..bea66d8d40 100644 --- a/src/spicy/runtime-support.h +++ b/src/spicy/runtime-support.h @@ -502,8 +502,8 @@ template ValPtr to_val(const hilti::rt::Map& s, const TypePtr& target); template ValPtr to_val(const hilti::rt::Set& s, const TypePtr& target); -template -ValPtr to_val(const hilti::rt::Vector& v, const TypePtr& target); +template +ValPtr to_val(const hilti::rt::Vector& v, const TypePtr& target); template ValPtr to_val(const std::optional& t, const TypePtr& target); template @@ -695,8 +695,8 @@ inline ValPtr to_val(const hilti::rt::Time& t, const TypePtr& target) { * Converts a Spicy-side vector to a Zeek value. The result is returned with * ref count +1. */ -template -inline ValPtr to_val(const hilti::rt::Vector& v, const TypePtr& target) { +template +inline ValPtr to_val(const hilti::rt::Vector& v, const TypePtr& target) { if ( target->Tag() != TYPE_VECTOR && target->Tag() != TYPE_LIST ) throw ParameterMismatch("expected vector or list", target); diff --git a/testing/btest/Baseline/spicy.type-converter/output b/testing/btest/Baseline/spicy.type-converter/output index b533a678f5..98e0df6aed 100644 --- a/testing/btest/Baseline/spicy.type-converter/output +++ b/testing/btest/Baseline/spicy.type-converter/output @@ -1,5 +1,5 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -[$a=b"SSH-2", $b=11824, $c=11599, $d=3.14, $e=1.2.3.4, $f=2001:db8::1428:57ab, $g=True, $h="MyString", $i=2011-01-19T05:31:50.500000000Z, $j=4.000000s, $r=[$i=11, $s=(not set)], $s={1, 2, 3}, $t=(47, "foo"), $v=[b"A", b"B", b"C"], $l=[b"A", b"B", b"C"], $m={1: "A", 2: "B", 3: "C"}] +[$a=b"SSH-2", $b=11824, $c=11599, $d=3.14, $e=1.2.3.4, $f=2001:db8::1428:57ab, $g=True, $h="MyString", $i=2011-01-19T05:31:50.500000000Z, $j=4.000000s, $k=Enum::B, $r=[$i=11, $s=(not set)], $s={1, 2, 3}, $t=(47, "foo"), $v=[b"A", b"B", b"C"], $l=[b"A", b"B", b"C"], $m={1: "A", 2: "B", 3: "C"}, $n=[Enum::A, Enum::B]] [orig_h=192.150.186.169, orig_p=49244/tcp, resp_h=131.159.14.23, resp_p=22/tcp, proto=6] T SSH-2 @@ -12,6 +12,7 @@ T MyString XXXXXXXXXX.XXXXXX 4.000000, interval +Conv::Enum_B [i=11, s=] { 2, @@ -26,3 +27,4 @@ XXXXXXXXXX.XXXXXX [1] = A, [3] = C } +[Conv::Enum_A, Conv::Enum_B] diff --git a/testing/btest/spicy/type-converter.zeek b/testing/btest/spicy/type-converter.zeek index 1c9104e2ce..f4be4602c4 100644 --- a/testing/btest/spicy/type-converter.zeek +++ b/testing/btest/spicy/type-converter.zeek @@ -12,6 +12,8 @@ event zeek_init() { module Conv; +public type Enum = enum { A, B = 2, C }; + public type Test = unit { a: bytes &size=5; b: int16; @@ -23,6 +25,7 @@ public type Test = unit { h: bytes &size=1 &convert="MyString"; i: bytes &size=1 &convert=time(1295415110.5); j: bytes &size=1 &convert=interval(4.0); + k: bytes &size=1 &convert=Enum(2); var r: MyStruct = [$i = 11]; var s: set = set(1,2,3); @@ -30,6 +33,7 @@ public type Test = unit { var v: vector = vector(b"A", b"B", b"C"); var l: vector = vector(b"A", b"B", b"C"); var m: map = map(1: "A", 2: "B", 3: "C"); + var n: vector = [Enum::A, Enum::B]; on %done { print self; } }; @@ -59,12 +63,14 @@ on Conv::Test -> event conv::test($conn, self.h, self.i, self.j, + self.k, self.r, self.s, self.t, self.v, self.l, - self.m + self.m, + self.n ); @TEST-END-FILE @@ -86,12 +92,14 @@ event conv::test(x: connection, h: string, i: time, j: interval, + k: Conv::Enum, r: MyRecord, s: set[count], t: MyRecord, v: vector of string, l: vector of string, - m: table[int] of string + m: table[int] of string, + n: vector of Conv::Enum ) { print x$id; @@ -106,10 +114,12 @@ event conv::test(x: connection, print h; print i; print fmt("%f", j), type_name(j); # print as float as interval format differs between versions + print k; print r; print s; print t; print v; print l; print m; + print n; }