Updating tests and tweaking HookArgument to include Frame support.

* Add frame support to HookArgument, since it's a new argument to HookCallFunction
* Fix test in api-version-mismatch to remove absolute paths from output
* Update test plugin to use new HookCallFunction interface
This commit is contained in:
Gilbert Clark 2014-10-02 19:23:59 -04:00
parent 0104d7147d
commit 70c7258dfa
7 changed files with 879 additions and 899 deletions

View file

@ -83,6 +83,13 @@ void HookArgument::Describe(ODesc* d) const
d->Add("<null>");
break;
case FRAME:
if ( arg.frame )
arg.frame->Describe(d);
else
d->Add("<null>");
break;
case FUNC:
if ( arg.func )
d->Add(arg.func->Name());
@ -106,21 +113,6 @@ void HookArgument::Describe(ODesc* d) const
d->Add("<null>");
break;
case WRAPPED_VAL:
if ( arg.wrapper )
{
d->Add("wrapped(");
if(arg.wrapper->value)
{
arg.wrapper->value->Describe(d);
}
else
d->Add("<null>");
d->Add(")");
}
break;
case VAL_LIST:
if ( arg.vals )
{
@ -139,6 +131,26 @@ void HookArgument::Describe(ODesc* d) const
case VOIDP:
d->Add("<void ptr>");
break;
case WRAPPED_VAL:
if ( arg.wrapper )
{
d->Add("wrapped(");
if(arg.wrapper->value)
{
arg.wrapper->value->Describe(d);
}
else
d->Add("<null>");
d->Add(")");
}
else
{
d->Add("<null>");
}
break;
}
}

View file

@ -184,7 +184,7 @@ public:
* Type of the argument.
*/
enum Type {
BOOL, DOUBLE, EVENT, FUNC, INT, STRING, VAL, WRAPPED_VAL, VAL_LIST, VOID, VOIDP,
BOOL, DOUBLE, EVENT, FRAME, FUNC, INT, STRING, VAL, VAL_LIST, VOID, VOIDP, WRAPPED_VAL
};
/**
@ -242,6 +242,11 @@ public:
*/
HookArgument(ValWrapper* a) { type = WRAPPED_VAL; arg.wrapper = a; }
/**
* Constructor with a Frame argument.
*/
HookArgument(Frame* f) { type = FRAME; arg.frame = f; }
/**
* Returns the value for a boolen argument. The argument's type must
* match accordingly.
@ -290,6 +295,12 @@ public:
*/
const ValWrapper* AsValWrapper() const { assert(type == VAL_WRAPPER); return arg.wrapper; }
/**
* Returns the value for a Bro frame argument. The argument's type must
* match accordingly.
*/
const Frame* AsFrame() const { assert(type == FRAME); return arg.frame; }
/**
* Returns the value for a list of Bro values argument. The argument's type must
* match accordingly.
@ -321,6 +332,7 @@ private:
double double_;
const Event* event;
const Func* func;
const Frame* frame;
int int_;
const Val* val;
const ValWrapper* wrapper;