&on_change wrapup: documentation, tests, whitespacing

Adds documentation, fixes a whitespace issues, fixes compiler warning on
some Linux system, extends test.
This commit is contained in:
Johanna Amann 2020-02-05 14:15:14 -08:00
parent b6a244f784
commit b1040f88c9
5 changed files with 10 additions and 6 deletions

2
doc

@ -1 +1 @@
Subproject commit 87b63d810d345172084d15c9c7feb132688456fe Subproject commit 7ee302e3d78a3fc759610664cefd15e0578b557f

View file

@ -1969,7 +1969,7 @@ void TableVal::CallChangeFunc(const Val* index, Val* old_value, OnChangeType tpe
const Func* f = thefunc->AsFunc(); const Func* f = thefunc->AsFunc();
val_list vl { Ref() }; val_list vl { Ref() };
EnumVal* type; EnumVal* type = nullptr;
switch ( tpe ) switch ( tpe )
{ {
case element_new: case element_new:

View file

@ -2,7 +2,10 @@ inserting
change_function, a, 1, 5, TABLE_ELEMENT_NEW change_function, a, 1, 5, TABLE_ELEMENT_NEW
set_change, hi, TABLE_ELEMENT_NEW set_change, hi, TABLE_ELEMENT_NEW
changing changing
change_function, a, 1, 5, TABLE_ELEMENT_CHANGED change_function, a, 1, 6, TABLE_ELEMENT_CHANGED
deleting deleting
change_function, a, 1, 5, TABLE_ELEMENT_REMOVED change_function, a, 1, 7, TABLE_ELEMENT_REMOVED
set_change, hi, TABLE_ELEMENT_REMOVED set_change, hi, TABLE_ELEMENT_REMOVED
{
[a, 1] = 8
}

View file

@ -6,7 +6,7 @@ module TestModule;
function change_function(t: table[string, int] of count, tpe: TableChange, idxa: string, idxb: int, val: count) function change_function(t: table[string, int] of count, tpe: TableChange, idxa: string, idxb: int, val: count)
{ {
print "change_function", idxa, idxb, val, tpe; print "change_function", idxa, idxb, val, tpe;
t[idxa, idxb] = val; t[idxa, idxb] = val+1;
} }
function set_change(t: set[string], tpe: TableChange, idx: string) function set_change(t: set[string], tpe: TableChange, idx: string)
@ -27,4 +27,5 @@ event zeek_init()
print "deleting"; print "deleting";
delete t["a", 1]; delete t["a", 1];
delete s["hi"]; delete s["hi"];
print t;
} }