mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Smaller compile fixes for the new opaque serialization.
Also remove the non-existing clone function for EntrypyVals - which now can just use serialization :)
This commit is contained in:
parent
a50b06d6c1
commit
618f0802f4
8 changed files with 21 additions and 29 deletions
|
@ -41,8 +41,8 @@ const std::string& OpaqueMgr::TypeID(const OpaqueVal* v) const
|
||||||
auto x = _types.find(v->OpaqueName());
|
auto x = _types.find(v->OpaqueName());
|
||||||
|
|
||||||
if ( x == _types.end() )
|
if ( x == _types.end() )
|
||||||
reporter->InternalError(fmt("OpaqueMgr::TypeID: opaque type %s not registered",
|
reporter->InternalError("OpaqueMgr::TypeID: opaque type %s not registered",
|
||||||
v->OpaqueName()));
|
v->OpaqueName());
|
||||||
|
|
||||||
return x->first;
|
return x->first;
|
||||||
}
|
}
|
||||||
|
@ -122,11 +122,11 @@ BroType* OpaqueVal::UnserializeType(const broker::data& data)
|
||||||
|
|
||||||
ID* id = global_scope()->Lookup(name->c_str());
|
ID* id = global_scope()->Lookup(name->c_str());
|
||||||
if ( ! id )
|
if ( ! id )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
BroType* t = id->AsType();
|
BroType* t = id->AsType();
|
||||||
if ( ! t )
|
if ( ! t )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return t->Ref();
|
return t->Ref();
|
||||||
}
|
}
|
||||||
|
@ -644,12 +644,6 @@ EntropyVal::EntropyVal() : OpaqueVal(entropy_type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Val* EntropyVal::DoClone(CloneState* state)
|
|
||||||
{
|
|
||||||
// Fixme
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EntropyVal::Feed(const void* data, size_t size)
|
bool EntropyVal::Feed(const void* data, size_t size)
|
||||||
{
|
{
|
||||||
state.add(data, size);
|
state.add(data, size);
|
||||||
|
|
|
@ -21,14 +21,12 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return's a unique ID for the type of an opaque value.
|
* Return's a unique ID for the type of an opaque value.
|
||||||
|
* @param v opaque value to return type for; its class must have been
|
||||||
* @param v opaque value to return type for; it's classmust have been
|
|
||||||
* registered with the manager, otherwise this method will abort
|
* registered with the manager, otherwise this method will abort
|
||||||
* execugtion.
|
* execution.
|
||||||
*
|
*
|
||||||
* @return type ID, which can used with *Instantiate()* to create a
|
* @return type ID, which can used with *Instantiate()* to create a
|
||||||
* new
|
* new instance of the same type.
|
||||||
* instnace of the same type.
|
|
||||||
*/
|
*/
|
||||||
const std::string& TypeID(const OpaqueVal* v) const;
|
const std::string& TypeID(const OpaqueVal* v) const;
|
||||||
|
|
||||||
|
@ -66,8 +64,8 @@ private:
|
||||||
/** Macro to insert into an OpaqueVal-derived class's declaration. */
|
/** Macro to insert into an OpaqueVal-derived class's declaration. */
|
||||||
#define DECLARE_OPAQUE_VALUE(T) \
|
#define DECLARE_OPAQUE_VALUE(T) \
|
||||||
friend class OpaqueMgr::Register<T>; \
|
friend class OpaqueMgr::Register<T>; \
|
||||||
broker::data DoSerialize() const; \
|
broker::data DoSerialize() const override; \
|
||||||
bool DoUnserialize(const broker::data& data); \
|
bool DoUnserialize(const broker::data& data) override; \
|
||||||
const char* OpaqueName() const override { return #T; } \
|
const char* OpaqueName() const override { return #T; } \
|
||||||
static OpaqueVal* OpaqueInstantiate() { return new T(); }
|
static OpaqueVal* OpaqueInstantiate() { return new T(); }
|
||||||
|
|
||||||
|
@ -90,7 +88,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Serializes the value into a Broker representation.
|
* Serializes the value into a Broker representation.
|
||||||
*
|
*
|
||||||
* @return the broker representatio, or an error if serialization
|
* @return the broker representation, or an error if serialization
|
||||||
* isn't supported or failed.
|
* isn't supported or failed.
|
||||||
*/
|
*/
|
||||||
broker::expected<broker::data> Serialize() const;
|
broker::expected<broker::data> Serialize() const;
|
||||||
|
@ -244,8 +242,6 @@ class EntropyVal : public OpaqueVal {
|
||||||
public:
|
public:
|
||||||
EntropyVal();
|
EntropyVal();
|
||||||
|
|
||||||
Val* DoClone(CloneState* state) override;
|
|
||||||
|
|
||||||
bool Feed(const void* data, size_t size);
|
bool Feed(const void* data, size_t size);
|
||||||
bool Get(double *r_ent, double *r_chisq, double *r_mean,
|
bool Get(double *r_ent, double *r_chisq, double *r_mean,
|
||||||
double *r_montepicalc, double *r_scc);
|
double *r_montepicalc, double *r_scc);
|
||||||
|
|
|
@ -1183,7 +1183,8 @@ IMPLEMENT_OPAQUE_VALUE(bro_broker::VectorIterator)
|
||||||
|
|
||||||
broker::data bro_broker::VectorIterator::DoSerialize() const
|
broker::data bro_broker::VectorIterator::DoSerialize() const
|
||||||
{
|
{
|
||||||
return broker::vector{dat, it - dat.begin()};
|
broker::integer difference = it - dat.begin();
|
||||||
|
return broker::vector{dat, difference};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bro_broker::VectorIterator::DoUnserialize(const broker::data& data)
|
bool bro_broker::VectorIterator::DoUnserialize(const broker::data& data)
|
||||||
|
@ -1193,7 +1194,7 @@ bool bro_broker::VectorIterator::DoUnserialize(const broker::data& data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto x = caf::get_if<broker::vector>(&(*v)[0]);
|
auto x = caf::get_if<broker::vector>(&(*v)[0]);
|
||||||
auto y = caf::get_if<broker::vector::difference_type>(&(*v)[1]);
|
auto y = caf::get_if<broker::integer>(&(*v)[1]);
|
||||||
|
|
||||||
dat = *x;
|
dat = *x;
|
||||||
it = dat.begin() + *y;
|
it = dat.begin() + *y;
|
||||||
|
@ -1204,7 +1205,8 @@ IMPLEMENT_OPAQUE_VALUE(bro_broker::RecordIterator)
|
||||||
|
|
||||||
broker::data bro_broker::RecordIterator::DoSerialize() const
|
broker::data bro_broker::RecordIterator::DoSerialize() const
|
||||||
{
|
{
|
||||||
return broker::vector{dat, it - dat.begin()};
|
broker::integer difference = it - dat.begin();
|
||||||
|
return broker::vector{dat, difference};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bro_broker::RecordIterator::DoUnserialize(const broker::data& data)
|
bool bro_broker::RecordIterator::DoUnserialize(const broker::data& data)
|
||||||
|
@ -1214,7 +1216,7 @@ bool bro_broker::RecordIterator::DoUnserialize(const broker::data& data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto x = caf::get_if<broker::vector>(&(*v)[0]);
|
auto x = caf::get_if<broker::vector>(&(*v)[0]);
|
||||||
auto y = caf::get_if<broker::vector::difference_type>(&(*v)[1]);
|
auto y = caf::get_if<broker::integer>(&(*v)[1]);
|
||||||
|
|
||||||
dat = *x;
|
dat = *x;
|
||||||
it = dat.begin() + *y;
|
it = dat.begin() + *y;
|
||||||
|
|
|
@ -543,7 +543,7 @@ std::unique_ptr<BitVector> BitVector::Unserialize(const broker::data& data)
|
||||||
bv->bits.push_back(*x);
|
bv->bits.push_back(*x);
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::move(bv);
|
return bv;
|
||||||
}
|
}
|
||||||
|
|
||||||
BitVector::size_type BitVector::lowest_bit(block_type block)
|
BitVector::size_type BitVector::lowest_bit(block_type block)
|
||||||
|
|
|
@ -70,7 +70,7 @@ std::unique_ptr<BloomFilter> BloomFilter::Unserialize(const broker::data& data)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
bf->hasher = hasher_.release();
|
bf->hasher = hasher_.release();
|
||||||
return std::move(bf);
|
return bf;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t BasicBloomFilter::M(double fp, size_t capacity)
|
size_t BasicBloomFilter::M(double fp, size_t capacity)
|
||||||
|
|
|
@ -234,7 +234,7 @@ std::unique_ptr<CardinalityCounter> CardinalityCounter::Unserialize(const broker
|
||||||
cc->buckets.push_back(*x);
|
cc->buckets.push_back(*x);
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::move(cc);
|
return cc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -179,7 +179,7 @@ std::unique_ptr<CounterVector> CounterVector::Unserialize(const broker::data& da
|
||||||
auto cv = std::unique_ptr<CounterVector>(new CounterVector());
|
auto cv = std::unique_ptr<CounterVector>(new CounterVector());
|
||||||
cv->width = *width;
|
cv->width = *width;
|
||||||
cv->bits = bits.release();
|
cv->bits = bits.release();
|
||||||
return std::move(cv);
|
return cv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ std::unique_ptr<Hasher> Hasher::Unserialize(const broker::data& data)
|
||||||
// their own. They reconstruct all their information from their
|
// their own. They reconstruct all their information from their
|
||||||
// constructors' arguments.
|
// constructors' arguments.
|
||||||
|
|
||||||
return std::move(hasher);
|
return hasher;
|
||||||
}
|
}
|
||||||
|
|
||||||
UHF::UHF()
|
UHF::UHF()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue