Tim Wojtulewicz
d3ac12da68
bifcl: Fix clang-tidy warnings
2025-08-28 12:14:09 -07:00
Tim Wojtulewicz
22d82edc74
bifcl: Run clang-format on c++ code embedded in builtin-func.{l,y}
2025-08-28 12:14:09 -07:00
Tim Wojtulewicz
d8d8772342
bifcl: Add NOLINT for clang-tidy performance-enum-size to generated headers
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
c63a220579
bifcl: Add missing include of cinttypes
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
867d91b535
bifcl: Some other minor cleanup
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
23a5e46b8e
bifcl: Minor cleanup of include files
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
7026938082
bifcl: Pass boolean false to BuiltinFunc constructor instead of zero
...
This fixes a modernize-use-bool-literals clang-tidy warning in the
generated code.
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
2f97833acd
bifcl: Switch namespacing in generated code to C++-17-style nested namespaces
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
dac04be859
bifcl: Make BIFs just return ValPtr directly instead of BifReturnVal
2025-08-20 08:52:25 -07:00
Arne Welzel
e7cce57f2b
bifcl: Render runtime type checks for var_args bifs
...
Currently, Zeek disables any static type checking for var_arg bifs.
However, the generated preamble for var_args bifs assume that
typed positional arguments are correctly typed and blindly calls
the type converters on them. This easily triggers abort()s at runtime
currently when a script mistakenly uses the wrong types for var_arg
bifs. For example, calling publish_rr() with a port instead of a string
causes a hard-abort with Zeek 5.0.8.
$ zeek -e 'Cluster::publish_rr(Cluster::Pool(), 80/tcp)'
fatal error in <no location>: Val::CONVERTER (port/string) (80/tcp)
Aborted (core dumped)
Extend bifcl so that for var_arg functions and the types that bifcl understands,
we render a runtime type check and explicit early return to avoid the abort().
For any/other types, the implementer of the bif continuous to be responsible
for type checking.
This isn't solving the var_args situation generally, but avoids some
ad-hoc fixes trickling in current bif implementations.
Some references:
https://github.com/zeek/zeek/issues/1523
https://github.com/zeek/zeek/issues/2425
https://github.com/zeek/zeek/issues/2935
https://github.com/zeek/zeek/pull/2950
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
8e295df115
bifcl: Other minor cleanups
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
8662b29ac6
bifcl: Use bools for boolean comparisons
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
224a42e1f0
bifcl: Use nullptrs for pointer initializations
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
f69f9e06e1
bifcl: Use full path to filename in #line directives in generated code
...
This fixes the DWARF information gets output by the compiler, and allows debuggers
to use the full path name to display contextual information when a session stops
inside of BIF code.
2025-08-20 08:52:25 -07:00
Benjamin Bannier
09d3268740
bifcl: Keep zeekygen comments close to their definitions
...
The Yacc grammar treats comments like other whitespace and when seeing
the first definition in a file would previously emit all whitespace
before emitting the `export` section containing the definition. This
lead to the first definition being separated from their zeekygen
documention (separated by `export {`).
With this patch we start the export section before emitting whitespace.
While this might now pull more "whitespace" into the exported part, it
avoids breaking the association between zeekygen comments and
definitions.
Closes #15 .
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
e080c5c6b2
bifcl: Remove remaining uses of Bro naming
2025-08-20 08:52:25 -07:00
Vern Paxson
2f3f7e9ce2
bifcl: trimmed & regularized some minor variable naming
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
02fe78a03f
bifcl: Allow analyzer to be passed as nullptr for enqueue methods
...
This allows the methods to be used in contexts where the analyzer ID
is not available or when the ID doesn't matter, such as in packet
analyzers.
2025-08-20 08:52:25 -07:00
Tim Wojtulewicz
279d5f3fad
bifcl: Remove v4.1 deprecation warnings
2025-08-20 08:52:25 -07:00
Jon Siwek
fbc98f4dd5
bifcl: Postpone initialization of constants for subdir BIFs
2025-08-20 08:52:24 -07:00
Tim Wojtulewicz
74d21a40e4
bifcl: SOURCE_LOCAL is part of the zeek::util::detail namespace now
2025-08-20 08:52:24 -07:00
Tim Wojtulewicz
5c94ea02c5
bifcl: Move BifReturnVal to zeek::detail namespace
2025-08-20 08:52:24 -07:00
Tim Wojtulewicz
cffecc5033
bifcl: Move event code to zeek namespace, rename mgr to event_mgr
2025-08-20 08:52:24 -07:00
Tim Wojtulewicz
caf565c539
bifcl: Move base analyzer classes to zeek namespace
2025-08-20 08:52:24 -07:00
Tim Wojtulewicz
6204542b5a
bifcl: Review cleanup
2025-08-20 08:52:24 -07:00
Tim Wojtulewicz
ff7b41ff12
bifcl: Move BuiltinFunc to zeek namespace
2025-08-20 08:52:24 -07:00
Tim Wojtulewicz
13dac12521
bifcl: Move Frame to the zeek::detail namespace
2025-08-20 08:52:24 -07:00
Tim Wojtulewicz
0597535149
bifcl: Move all Val classes to the zeek namespaces
2025-08-20 08:52:24 -07:00
Tim Wojtulewicz
79bbe9a7bf
bifcl: Move IntrusivePtr to the zeek namespace
2025-08-20 08:52:24 -07:00
Tim Wojtulewicz
73fb715657
bifcl: Update namespace for *Type classes
2025-08-20 08:52:24 -07:00
Tim Wojtulewicz
6813ddaaa9
bifcl: Update namespace for plugin::Plugin and plugin::BifItem classes
2025-08-20 08:52:24 -07:00
Jon Siwek
23b4af393f
bifcl: Switch zeek: 🆔 :lookup to zeek: 🆔 :find
2025-08-20 08:52:24 -07:00
Jon Siwek
2ef1aacd36
bifcl: Use zeek::BifEvent:: for enqueue_ functions instead of BifEvent::
...
The old BifEvent::generate_ functions were already deprecated
2025-08-20 08:52:24 -07:00
Jon Siwek
4c2fb01981
bifcl: Deprecate BifFunc:: declarations, replace with zeek::BifFunc::
...
Also changes name of function slightly, example: bro_fmt -> fmt_bif.
2025-08-20 08:52:24 -07:00
Jon Siwek
d72884064a
bifcl: Deprecate names in BifConst, replace with zeek::BifConst
...
Some Val* types are also replaced with IntrusivePtr
2025-08-20 08:52:24 -07:00
Jon Siwek
620680d878
bifcl: Deprecate all BroType* in BifType:: namespace
...
Replaced with equivalently named IntrusivePtr in zeek::BifType::
2025-08-20 08:52:24 -07:00
Jon Siwek
36dec9dbb5
bifcl: Change internal_handler() usage
2025-08-20 08:52:24 -07:00
Jon Siwek
59e86c6ea0
bifcl: Renaming/scoping of lookup functions
2025-08-20 08:52:24 -07:00
Jon Siwek
53d6f6665e
bifcl: Replace deprecated use of internal_const_val()
2025-08-20 08:52:24 -07:00
Jon Siwek
719b8082ca
bifcl: Update deprecated use of internal_type()
2025-08-20 08:52:24 -07:00
Jon Siwek
b29ecfd822
bifcl: Deprecate BifEvent::generate_*, add BifEvent::enqueue_*
2025-08-20 08:52:24 -07:00
Jon Siwek
7958f7854c
bifcl: Return nullptr instead of 0 in BIF error conditions
2025-08-20 08:52:24 -07:00
Jon Siwek
9a3ac5de98
bifcl: Change BIFs to return a wrapper object
...
That allows implicit conversion from either Val* or IntrusivePtr<T>
2025-08-20 08:52:24 -07:00
Jon Siwek
e5c62c01a4
bifcl: Support multiple/alternate event prototype definitions
2025-08-20 08:52:24 -07:00
Jon Siwek
b6b094b43a
bifcl: Don't pass a TimerMgr to EventMgr::Enqueue()
2025-08-20 08:52:24 -07:00
Jon Siwek
de453419d7
bifcl: Use EventMgr::Enqueue() instead of QueueEventFast()
2025-08-20 08:52:24 -07:00
Jon Siwek
163a86fc4e
bifcl: Move BIF function arguments from val_list to vector of IntrusivePtr
2025-08-20 08:52:24 -07:00
Daniel Thayer
3ce42f2f35
bifcl: Rename Bro to Zeek
2025-08-20 08:52:24 -07:00
Jon Siwek
3b8932ff01
bifcl: Update codegen to use faster val_list and event queue API
2025-08-20 08:52:24 -07:00
Daniel Thayer
a95808bc6b
bifcl: Change file extension of auto-generated script files
...
Changed ".bro" file extension to ".zeek".
2025-08-20 08:52:24 -07:00