mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 18:48:20 +00:00
Use static_cast instead of dynamic_cast for Val conversions
This commit is contained in:
parent
4962986df1
commit
99e719318b
1 changed files with 4 additions and 4 deletions
|
@ -216,7 +216,7 @@ UNDERLYING_ACCESSOR_DECL(TypeVal, zeek::Type*, AsType)
|
||||||
// Since we're converting from "this", make sure the type requested is a pointer.
|
// Since we're converting from "this", make sure the type requested is a pointer.
|
||||||
static_assert(std::is_pointer<T>());
|
static_assert(std::is_pointer<T>());
|
||||||
|
|
||||||
auto v = dynamic_cast<T>(this);
|
auto v = static_cast<T>(this);
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
reporter->InternalError("Failed dynamic_cast between Val types");
|
reporter->InternalError("Failed dynamic_cast between Val types");
|
||||||
|
|
||||||
|
@ -1263,7 +1263,7 @@ public:
|
||||||
auto GetFieldAs(int field) const -> std::invoke_result_t<decltype(&T::Get), T>
|
auto GetFieldAs(int field) const -> std::invoke_result_t<decltype(&T::Get), T>
|
||||||
{
|
{
|
||||||
auto& field_ptr = GetField(field);
|
auto& field_ptr = GetField(field);
|
||||||
auto field_val_ptr = dynamic_cast<T*>(field_ptr.get());
|
auto field_val_ptr = static_cast<T*>(field_ptr.get());
|
||||||
if ( ! field_val_ptr )
|
if ( ! field_val_ptr )
|
||||||
reporter->InternalError("Typecast failed in TableVal::GetFieldAs");
|
reporter->InternalError("Typecast failed in TableVal::GetFieldAs");
|
||||||
|
|
||||||
|
@ -1274,7 +1274,7 @@ public:
|
||||||
auto GetFieldAs(const char* field) const -> std::invoke_result_t<decltype(&T::Get), T>
|
auto GetFieldAs(const char* field) const -> std::invoke_result_t<decltype(&T::Get), T>
|
||||||
{
|
{
|
||||||
auto& field_ptr = GetField(field);
|
auto& field_ptr = GetField(field);
|
||||||
auto field_val_ptr = dynamic_cast<T*>(field_ptr.get());
|
auto field_val_ptr = static_cast<T*>(field_ptr.get());
|
||||||
if ( ! field_val_ptr )
|
if ( ! field_val_ptr )
|
||||||
reporter->InternalError("Typecast failed in TableVal::GetFieldAs");
|
reporter->InternalError("Typecast failed in TableVal::GetFieldAs");
|
||||||
|
|
||||||
|
@ -1520,7 +1520,7 @@ private:
|
||||||
|
|
||||||
#define UNDERLYING_ACCESSOR_DEF(ztype, ctype, name) \
|
#define UNDERLYING_ACCESSOR_DEF(ztype, ctype, name) \
|
||||||
inline ctype Val::name() const \
|
inline ctype Val::name() const \
|
||||||
{ return dynamic_cast<const ztype*>(this)->Get(); }
|
{ return static_cast<const ztype*>(this)->Get(); }
|
||||||
|
|
||||||
UNDERLYING_ACCESSOR_DEF(detail::IntValImplementation, bro_int_t, AsInt)
|
UNDERLYING_ACCESSOR_DEF(detail::IntValImplementation, bro_int_t, AsInt)
|
||||||
UNDERLYING_ACCESSOR_DEF(BoolVal, bool, AsBool)
|
UNDERLYING_ACCESSOR_DEF(BoolVal, bool, AsBool)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue