Deprecate global Val pointers in NetVar.h

All of these have fairly niche uses, so better maintained as
lookup/static closer to the usage site.
This commit is contained in:
Jon Siwek 2020-05-12 00:01:40 -07:00
parent c0986f0739
commit d34b24e776
13 changed files with 83 additions and 49 deletions

View file

@ -52,7 +52,9 @@ extern Val* opt_internal_val(const char* name); // returns nil if not defined
extern double opt_internal_double(const char* name);
extern bro_int_t opt_internal_int(const char* name);
extern bro_uint_t opt_internal_unsigned(const char* name);
[[deprecated("Remove in v4.1. Use lookup_ID() or zeek::lookup_val().")]]
extern StringVal* opt_internal_string(const char* name);
[[deprecated("Remove in v4.1. Use lookup_ID() or zeek::lookup_val().")]]
extern TableVal* opt_internal_table(const char* name); // nil if not defined
[[deprecated("Remove in v4.1. Use lookup_ID(), zeek::lookup_val(), and/or TableVal::ToPureListVal().")]]
@ -96,6 +98,16 @@ IntrusivePtr<T> lookup_type(const char* name)
*/
const IntrusivePtr<Val>& lookup_val(const char* name);
/**
* Lookup an ID by its name and return its value (as cast to @c T).
* A fatal occurs if the ID does not exist.
* @param name The identifier name to lookup
* @return The current value of the identifier.
*/
template<class T>
IntrusivePtr<T> lookup_val(const char* name)
{ return cast_intrusive<T>(lookup_val(name)); }
/**
* Lookup an ID by its name and return its value. A fatal occurs if the ID
* does not exist or if it is not "const".