mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
Merge branch 'master' into topic/gilbert/plugin-api-tweak
Conflicts: testing/btest/Baseline/plugins.api-version-mismatch/output testing/btest/Baseline/plugins.hooks/output testing/btest/plugins/api-version-mismatch.sh
This commit is contained in:
commit
7eadcad674
139 changed files with 3194 additions and 1385 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "config.h"
|
||||
#include "analyzer/Component.h"
|
||||
|
@ -26,34 +27,6 @@ class Manager;
|
|||
class Component;
|
||||
class Plugin;
|
||||
|
||||
/**
|
||||
* In certain cases, functions may have well-defined return types but still return NULL values (e.g. delayed functions, opaque types).
|
||||
* Thus, it's necessary to explicitly define whether or not a plugin has handled a function in addition to recording the value it has
|
||||
* returned.
|
||||
*
|
||||
* Plugins' function handlers return a result of this type.
|
||||
*/
|
||||
struct ValWrapper {
|
||||
Val* value; //< value being wrapped by this object
|
||||
bool processed; //< true if execution should *STOP* (read: the plugin is replacing a method), and false if execution should *CONTINUE* (read: bro should execute a method)
|
||||
|
||||
/**
|
||||
Wrapper for a specific value. If we're setting a value, we assume we've processed something.
|
||||
|
||||
@param value value to be wrapped
|
||||
*/
|
||||
ValWrapper(Val* value)
|
||||
: value(value), processed(true) { }
|
||||
|
||||
/**
|
||||
Wrapper for a specific value. If we're setting 'processed', we assume there's a reason we're not setting a Val and set that to NULL.
|
||||
|
||||
@param processed whether or not an execution of a function was handled by the plugin
|
||||
*/
|
||||
ValWrapper(bool processed)
|
||||
: value(NULL), processed(processed) { }
|
||||
};
|
||||
|
||||
/**
|
||||
* Hook types that a plugin may define. Each label maps to the corresponding
|
||||
* virtual method in \a Plugin.
|
||||
|
@ -238,9 +211,9 @@ public:
|
|||
HookArgument(void* p) { type = VOIDP; arg.voidp = p; }
|
||||
|
||||
/**
|
||||
* Constructor with a ValWrapper argument.
|
||||
* Constructor with a wrapped Val argument.
|
||||
*/
|
||||
HookArgument(ValWrapper* a) { type = WRAPPED_VAL; arg.wrapper = a; }
|
||||
HookArgument(std::pair<Val*, bool> a) { type = WRAPPED_VAL; wrapper = a; }
|
||||
|
||||
/**
|
||||
* Constructor with a Frame argument.
|
||||
|
@ -293,7 +266,7 @@ public:
|
|||
* Returns the value for a Bro wrapped value argument. The argument's type must
|
||||
* match accordingly.
|
||||
*/
|
||||
const ValWrapper* AsValWrapper() const { assert(type == VAL_WRAPPER); return arg.wrapper; }
|
||||
const std::pair<Val*, bool> AsValWrapper() const { assert(type == VAL_WRAPPER); return wrapper; }
|
||||
|
||||
/**
|
||||
* Returns the value for a Bro frame argument. The argument's type must
|
||||
|
@ -335,11 +308,11 @@ private:
|
|||
const Frame* frame;
|
||||
int int_;
|
||||
const Val* val;
|
||||
const ValWrapper* wrapper;
|
||||
const val_list* vals;
|
||||
const void* voidp;
|
||||
} arg;
|
||||
|
||||
std::pair<Val*, bool> wrapper; // Outside union because it has dtor.
|
||||
std::string arg_string; // Outside union because it has dtor.
|
||||
};
|
||||
|
||||
|
@ -620,14 +593,13 @@ protected:
|
|||
* in place as long as it ensures matching types and correct reference
|
||||
* counting.
|
||||
*
|
||||
* @return If the plugin handled the call, a ValWrapper with the
|
||||
* @return If the plugin handled the call, a std::pair<Val*, bool> with the
|
||||
* processed flag set to true, and a value set on the object with
|
||||
* a+1 reference count containing the result value to pass back to the
|
||||
* interpreter. If the plugin did not handle the call, it may either
|
||||
* return NULL *or* return a ValWrapper with the processed flag set to
|
||||
* 'false'.
|
||||
* interpreter. If the plugin did not handle the call, it must
|
||||
* return a ValWrapper with the processed flag set to 'false'.
|
||||
*/
|
||||
virtual ValWrapper* HookCallFunction(const Func* func, Frame *parent, val_list* args);
|
||||
virtual std::pair<Val*, bool> HookCallFunction(const Func* func, Frame *parent, val_list* args);
|
||||
|
||||
/**
|
||||
* Hook into raising events. Whenever the script interpreter is about
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue