mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 09:08:20 +00:00
Move zeekygen code to zeek::zeekygen::detail namespace
This commit is contained in:
parent
80ebb4b67a
commit
5a2ac84eee
23 changed files with 213 additions and 105 deletions
16
src/Type.cc
16
src/Type.cc
|
@ -1056,8 +1056,7 @@ void RecordType::DescribeFieldsReST(ODesc* d, bool func_args) const
|
||||||
if ( func_args )
|
if ( func_args )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
using zeekygen::IdentifierInfo;
|
zeek::zeekygen::detail::IdentifierInfo* doc = zeek::detail::zeekygen_mgr->GetIdentifierInfo(GetName());
|
||||||
IdentifierInfo* doc = zeekygen_mgr->GetIdentifierInfo(GetName());
|
|
||||||
|
|
||||||
if ( ! doc )
|
if ( ! doc )
|
||||||
{
|
{
|
||||||
|
@ -1076,7 +1075,7 @@ void RecordType::DescribeFieldsReST(ODesc* d, bool func_args) const
|
||||||
field_from_script != type_from_script )
|
field_from_script != type_from_script )
|
||||||
{
|
{
|
||||||
d->PushIndent();
|
d->PushIndent();
|
||||||
d->Add(zeekygen::redef_indication(field_from_script).c_str());
|
d->Add(zeek::zeekygen::detail::redef_indication(field_from_script).c_str());
|
||||||
d->PopIndent();
|
d->PopIndent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1096,7 +1095,7 @@ void RecordType::DescribeFieldsReST(ODesc* d, bool func_args) const
|
||||||
{
|
{
|
||||||
string s = cmnts[i];
|
string s = cmnts[i];
|
||||||
|
|
||||||
if ( zeekygen::prettify_params(s) )
|
if ( zeek::zeekygen::detail::prettify_params(s) )
|
||||||
d->NL();
|
d->NL();
|
||||||
|
|
||||||
d->Add(s.c_str());
|
d->Add(s.c_str());
|
||||||
|
@ -1260,7 +1259,7 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name,
|
||||||
if ( deprecation )
|
if ( deprecation )
|
||||||
id->MakeDeprecated({zeek::NewRef{}, deprecation});
|
id->MakeDeprecated({zeek::NewRef{}, deprecation});
|
||||||
|
|
||||||
zeekygen_mgr->Identifier(std::move(id));
|
zeek::detail::zeekygen_mgr->Identifier(std::move(id));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1377,8 +1376,7 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const
|
||||||
else
|
else
|
||||||
d->Add(zeek::util::fmt(".. zeek:enum:: %s %s", it->second.c_str(), GetName().c_str()));
|
d->Add(zeek::util::fmt(".. zeek:enum:: %s %s", it->second.c_str(), GetName().c_str()));
|
||||||
|
|
||||||
using zeekygen::IdentifierInfo;
|
zeek::zeekygen::detail::IdentifierInfo* doc = zeek::detail::zeekygen_mgr->GetIdentifierInfo(it->second);
|
||||||
IdentifierInfo* doc = zeekygen_mgr->GetIdentifierInfo(it->second);
|
|
||||||
|
|
||||||
if ( ! doc )
|
if ( ! doc )
|
||||||
{
|
{
|
||||||
|
@ -1393,7 +1391,7 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const
|
||||||
if ( doc->GetDeclaringScript() )
|
if ( doc->GetDeclaringScript() )
|
||||||
enum_from_script = doc->GetDeclaringScript()->Name();
|
enum_from_script = doc->GetDeclaringScript()->Name();
|
||||||
|
|
||||||
IdentifierInfo* type_doc = zeekygen_mgr->GetIdentifierInfo(GetName());
|
zeek::zeekygen::detail::IdentifierInfo* type_doc = zeek::detail::zeekygen_mgr->GetIdentifierInfo(GetName());
|
||||||
|
|
||||||
if ( type_doc && type_doc->GetDeclaringScript() )
|
if ( type_doc && type_doc->GetDeclaringScript() )
|
||||||
type_from_script = type_doc->GetDeclaringScript()->Name();
|
type_from_script = type_doc->GetDeclaringScript()->Name();
|
||||||
|
@ -1403,7 +1401,7 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const
|
||||||
{
|
{
|
||||||
d->NL();
|
d->NL();
|
||||||
d->PushIndent();
|
d->PushIndent();
|
||||||
d->Add(zeekygen::redef_indication(enum_from_script).c_str());
|
d->Add(zeek::zeekygen::detail::redef_indication(enum_from_script).c_str());
|
||||||
d->PopIndent();
|
d->PopIndent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
src/parse.y
22
src/parse.y
|
@ -1032,7 +1032,7 @@ type_decl:
|
||||||
$$ = new zeek::TypeDecl($1, {zeek::AdoptRef{}, $3}, std::move(attrs));
|
$$ = new zeek::TypeDecl($1, {zeek::AdoptRef{}, $3}, std::move(attrs));
|
||||||
|
|
||||||
if ( in_record > 0 && cur_decl_type_id )
|
if ( in_record > 0 && cur_decl_type_id )
|
||||||
zeekygen_mgr->RecordField(cur_decl_type_id, $$, ::filename);
|
zeek::detail::zeekygen_mgr->RecordField(cur_decl_type_id, $$, ::filename);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -1067,7 +1067,7 @@ decl:
|
||||||
TOK_MODULE TOK_ID ';'
|
TOK_MODULE TOK_ID ';'
|
||||||
{
|
{
|
||||||
zeek::detail::current_module = $2;
|
zeek::detail::current_module = $2;
|
||||||
zeekygen_mgr->ModuleUsage(::filename, zeek::detail::current_module);
|
zeek::detail::zeekygen_mgr->ModuleUsage(::filename, zeek::detail::current_module);
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_EXPORT '{' { is_export = true; } decl_list '}'
|
| TOK_EXPORT '{' { is_export = true; } decl_list '}'
|
||||||
|
@ -1079,7 +1079,7 @@ decl:
|
||||||
add_global(id, {zeek::AdoptRef{}, $3}, $4, {zeek::AdoptRef{}, $5},
|
add_global(id, {zeek::AdoptRef{}, $3}, $4, {zeek::AdoptRef{}, $5},
|
||||||
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$6},
|
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$6},
|
||||||
VAR_REGULAR);
|
VAR_REGULAR);
|
||||||
zeekygen_mgr->Identifier(std::move(id));
|
zeek::detail::zeekygen_mgr->Identifier(std::move(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_OPTION def_global_id opt_type init_class opt_init opt_attr ';'
|
| TOK_OPTION def_global_id opt_type init_class opt_init opt_attr ';'
|
||||||
|
@ -1088,7 +1088,7 @@ decl:
|
||||||
add_global(id, {zeek::AdoptRef{}, $3}, $4, {zeek::AdoptRef{}, $5},
|
add_global(id, {zeek::AdoptRef{}, $3}, $4, {zeek::AdoptRef{}, $5},
|
||||||
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$6},
|
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$6},
|
||||||
VAR_OPTION);
|
VAR_OPTION);
|
||||||
zeekygen_mgr->Identifier(std::move(id));
|
zeek::detail::zeekygen_mgr->Identifier(std::move(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_CONST def_global_id opt_type init_class opt_init opt_attr ';'
|
| TOK_CONST def_global_id opt_type init_class opt_init opt_attr ';'
|
||||||
|
@ -1097,7 +1097,7 @@ decl:
|
||||||
add_global(id, {zeek::AdoptRef{}, $3}, $4, {zeek::AdoptRef{}, $5},
|
add_global(id, {zeek::AdoptRef{}, $3}, $4, {zeek::AdoptRef{}, $5},
|
||||||
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$6},
|
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$6},
|
||||||
VAR_CONST);
|
VAR_CONST);
|
||||||
zeekygen_mgr->Identifier(std::move(id));
|
zeek::detail::zeekygen_mgr->Identifier(std::move(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_REDEF global_id opt_type init_class opt_init opt_attr ';'
|
| TOK_REDEF global_id opt_type init_class opt_init opt_attr ';'
|
||||||
|
@ -1107,18 +1107,18 @@ decl:
|
||||||
add_global(id, {zeek::AdoptRef{}, $3}, $4, init,
|
add_global(id, {zeek::AdoptRef{}, $3}, $4, init,
|
||||||
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$6},
|
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$6},
|
||||||
VAR_REDEF);
|
VAR_REDEF);
|
||||||
zeekygen_mgr->Redef(id.get(), ::filename, $4, std::move(init));
|
zeek::detail::zeekygen_mgr->Redef(id.get(), ::filename, $4, std::move(init));
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_REDEF TOK_ENUM global_id TOK_ADD_TO '{'
|
| TOK_REDEF TOK_ENUM global_id TOK_ADD_TO '{'
|
||||||
{ parser_redef_enum($3); zeekygen_mgr->Redef($3, ::filename); }
|
{ parser_redef_enum($3); zeek::detail::zeekygen_mgr->Redef($3, ::filename); }
|
||||||
enum_body '}' ';'
|
enum_body '}' ';'
|
||||||
{
|
{
|
||||||
// Zeekygen already grabbed new enum IDs as the type created them.
|
// Zeekygen already grabbed new enum IDs as the type created them.
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_REDEF TOK_RECORD global_id
|
| TOK_REDEF TOK_RECORD global_id
|
||||||
{ cur_decl_type_id = $3; zeekygen_mgr->Redef($3, ::filename); }
|
{ cur_decl_type_id = $3; zeek::detail::zeekygen_mgr->Redef($3, ::filename); }
|
||||||
TOK_ADD_TO '{'
|
TOK_ADD_TO '{'
|
||||||
{ ++in_record; }
|
{ ++in_record; }
|
||||||
type_decl_list
|
type_decl_list
|
||||||
|
@ -1135,14 +1135,14 @@ decl:
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_TYPE global_id ':'
|
| TOK_TYPE global_id ':'
|
||||||
{ cur_decl_type_id = $2; zeekygen_mgr->StartType({zeek::NewRef{}, $2}); }
|
{ cur_decl_type_id = $2; zeek::detail::zeekygen_mgr->StartType({zeek::NewRef{}, $2}); }
|
||||||
type opt_attr ';'
|
type opt_attr ';'
|
||||||
{
|
{
|
||||||
cur_decl_type_id = 0;
|
cur_decl_type_id = 0;
|
||||||
zeek::IntrusivePtr id{zeek::AdoptRef{}, $2};
|
zeek::IntrusivePtr id{zeek::AdoptRef{}, $2};
|
||||||
add_type(id.get(), {zeek::AdoptRef{}, $5},
|
add_type(id.get(), {zeek::AdoptRef{}, $5},
|
||||||
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$6});
|
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$6});
|
||||||
zeekygen_mgr->Identifier(std::move(id));
|
zeek::detail::zeekygen_mgr->Identifier(std::move(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
| func_hdr { func_hdr_location = @1; } func_body
|
| func_hdr { func_hdr_location = @1; } func_body
|
||||||
|
@ -1177,7 +1177,7 @@ func_hdr:
|
||||||
zeek::FUNC_FLAVOR_FUNCTION, 0, {zeek::NewRef{}, $3},
|
zeek::FUNC_FLAVOR_FUNCTION, 0, {zeek::NewRef{}, $3},
|
||||||
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$4});
|
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$4});
|
||||||
$$ = $3;
|
$$ = $3;
|
||||||
zeekygen_mgr->Identifier(std::move(id));
|
zeek::detail::zeekygen_mgr->Identifier(std::move(id));
|
||||||
}
|
}
|
||||||
| TOK_EVENT event_id func_params opt_attr
|
| TOK_EVENT event_id func_params opt_attr
|
||||||
{
|
{
|
||||||
|
|
|
@ -140,7 +140,7 @@ ComponentManager<T, C>::ComponentManager(const std::string& arg_module, const st
|
||||||
{
|
{
|
||||||
auto id = zeek::detail::install_ID(local_id.c_str(), module.c_str(), true, true);
|
auto id = zeek::detail::install_ID(local_id.c_str(), module.c_str(), true, true);
|
||||||
add_type(id.get(), tag_enum_type, nullptr);
|
add_type(id.get(), tag_enum_type, nullptr);
|
||||||
zeekygen_mgr->Identifier(std::move(id));
|
zeek::detail::zeekygen_mgr->Identifier(std::move(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class C>
|
template <class T, class C>
|
||||||
|
|
10
src/scan.l
10
src/scan.l
|
@ -146,19 +146,19 @@ ESCSEQ (\\([^\n]|[0-7]+|x[[:xdigit:]]+))
|
||||||
%%
|
%%
|
||||||
|
|
||||||
##!.* {
|
##!.* {
|
||||||
zeekygen_mgr->SummaryComment(::filename, yytext + 3);
|
zeek::detail::zeekygen_mgr->SummaryComment(::filename, yytext + 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
##<.* {
|
##<.* {
|
||||||
std::string hint(cur_enum_type && last_id_tok ?
|
std::string hint(cur_enum_type && last_id_tok ?
|
||||||
make_full_var_name(zeek::detail::current_module.c_str(), last_id_tok) : "");
|
make_full_var_name(zeek::detail::current_module.c_str(), last_id_tok) : "");
|
||||||
|
|
||||||
zeekygen_mgr->PostComment(yytext + 3, hint);
|
zeek::detail::zeekygen_mgr->PostComment(yytext + 3, hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
##.* {
|
##.* {
|
||||||
if ( yytext[2] != '#' )
|
if ( yytext[2] != '#' )
|
||||||
zeekygen_mgr->PreComment(yytext + 2);
|
zeek::detail::zeekygen_mgr->PreComment(yytext + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#{OWS}@no-test.* return TOK_NO_TEST;
|
#{OWS}@no-test.* return TOK_NO_TEST;
|
||||||
|
@ -332,7 +332,7 @@ when return TOK_WHEN;
|
||||||
std::string loader = ::filename; // load_files may change ::filename, save copy
|
std::string loader = ::filename; // load_files may change ::filename, save copy
|
||||||
std::string loading = find_relative_script_file(new_file);
|
std::string loading = find_relative_script_file(new_file);
|
||||||
(void) load_files(new_file);
|
(void) load_files(new_file);
|
||||||
zeekygen_mgr->ScriptDependency(loader, loading);
|
zeek::detail::zeekygen_mgr->ScriptDependency(loader, loading);
|
||||||
}
|
}
|
||||||
|
|
||||||
@load-sigs{WS}{FILE} {
|
@load-sigs{WS}{FILE} {
|
||||||
|
@ -647,7 +647,7 @@ static int load_files(const char* orig_file)
|
||||||
// this @load was done when we're finished processing it.
|
// this @load was done when we're finished processing it.
|
||||||
file_stack.push_back(new FileInfo(zeek::detail::current_module));
|
file_stack.push_back(new FileInfo(zeek::detail::current_module));
|
||||||
|
|
||||||
zeekygen_mgr->Script(file_path);
|
zeek::detail::zeekygen_mgr->Script(file_path);
|
||||||
|
|
||||||
DBG_LOG(zeek::DBG_SCRIPTS, "Loading %s", file_path.c_str());
|
DBG_LOG(zeek::DBG_SCRIPTS, "Loading %s", file_path.c_str());
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,8 @@ zeek::input::Manager* zeek::input_mgr = nullptr;
|
||||||
zeek::input::Manager*& input_mgr = zeek::input_mgr;
|
zeek::input::Manager*& input_mgr = zeek::input_mgr;
|
||||||
zeek::file_analysis::Manager* zeek::file_mgr = nullptr;
|
zeek::file_analysis::Manager* zeek::file_mgr = nullptr;
|
||||||
zeek::file_analysis::Manager*& file_mgr = zeek::file_mgr;
|
zeek::file_analysis::Manager*& file_mgr = zeek::file_mgr;
|
||||||
zeekygen::Manager* zeekygen_mgr = nullptr;
|
zeek::zeekygen::detail::Manager* zeek::detail::zeekygen_mgr = nullptr;
|
||||||
|
zeek::zeekygen::detail::Manager*& zeekygen_mgr = zeek::detail::zeekygen_mgr;
|
||||||
zeek::iosource::Manager* zeek::iosource_mgr = nullptr;
|
zeek::iosource::Manager* zeek::iosource_mgr = nullptr;
|
||||||
zeek::iosource::Manager*& iosource_mgr = zeek::iosource_mgr;
|
zeek::iosource::Manager*& iosource_mgr = zeek::iosource_mgr;
|
||||||
zeek::Broker::Manager* zeek::broker_mgr = nullptr;
|
zeek::Broker::Manager* zeek::broker_mgr = nullptr;
|
||||||
|
@ -320,7 +321,7 @@ void terminate_bro()
|
||||||
|
|
||||||
zeek::plugin_mgr->FinishPlugins();
|
zeek::plugin_mgr->FinishPlugins();
|
||||||
|
|
||||||
delete zeekygen_mgr;
|
delete zeek::detail::zeekygen_mgr;
|
||||||
delete zeek::analyzer_mgr;
|
delete zeek::analyzer_mgr;
|
||||||
delete zeek::file_mgr;
|
delete zeek::file_mgr;
|
||||||
// broker_mgr, timer_mgr, and supervisor are deleted via iosource_mgr
|
// broker_mgr, timer_mgr, and supervisor are deleted via iosource_mgr
|
||||||
|
@ -551,7 +552,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
||||||
zeek::detail::timer_mgr = new zeek::detail::PQ_TimerMgr();
|
zeek::detail::timer_mgr = new zeek::detail::PQ_TimerMgr();
|
||||||
|
|
||||||
auto zeekygen_cfg = options.zeekygen_config_file.value_or("");
|
auto zeekygen_cfg = options.zeekygen_config_file.value_or("");
|
||||||
zeekygen_mgr = new zeekygen::Manager(zeekygen_cfg, bro_argv[0]);
|
zeek::detail::zeekygen_mgr = new zeek::zeekygen::detail::Manager(zeekygen_cfg, bro_argv[0]);
|
||||||
|
|
||||||
add_essential_input_file("base/init-bare.zeek");
|
add_essential_input_file("base/init-bare.zeek");
|
||||||
add_essential_input_file("base/init-frameworks-and-bifs.zeek");
|
add_essential_input_file("base/init-frameworks-and-bifs.zeek");
|
||||||
|
@ -600,7 +601,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
||||||
zeek::plugin_mgr->InitPreScript();
|
zeek::plugin_mgr->InitPreScript();
|
||||||
zeek::analyzer_mgr->InitPreScript();
|
zeek::analyzer_mgr->InitPreScript();
|
||||||
zeek::file_mgr->InitPreScript();
|
zeek::file_mgr->InitPreScript();
|
||||||
zeekygen_mgr->InitPreScript();
|
zeek::detail::zeekygen_mgr->InitPreScript();
|
||||||
|
|
||||||
bool missing_plugin = false;
|
bool missing_plugin = false;
|
||||||
|
|
||||||
|
@ -670,7 +671,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
||||||
zeek::iosource_mgr->InitPostScript();
|
zeek::iosource_mgr->InitPostScript();
|
||||||
zeek::log_mgr->InitPostScript();
|
zeek::log_mgr->InitPostScript();
|
||||||
zeek::plugin_mgr->InitPostScript();
|
zeek::plugin_mgr->InitPostScript();
|
||||||
zeekygen_mgr->InitPostScript();
|
zeek::detail::zeekygen_mgr->InitPostScript();
|
||||||
zeek::broker_mgr->InitPostScript();
|
zeek::broker_mgr->InitPostScript();
|
||||||
zeek::detail::timer_mgr->InitPostScript();
|
zeek::detail::timer_mgr->InitPostScript();
|
||||||
zeek::event_mgr.InitPostScript();
|
zeek::event_mgr.InitPostScript();
|
||||||
|
@ -706,7 +707,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
||||||
|
|
||||||
zeek::reporter->InitOptions();
|
zeek::reporter->InitOptions();
|
||||||
KeyedHash::InitOptions();
|
KeyedHash::InitOptions();
|
||||||
zeekygen_mgr->GenerateDocs();
|
zeek::detail::zeekygen_mgr->GenerateDocs();
|
||||||
|
|
||||||
if ( options.pcap_filter )
|
if ( options.pcap_filter )
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,9 +10,10 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
using namespace zeekygen;
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
static TargetFactory create_target_factory()
|
static TargetFactory create_target_factory()
|
||||||
{
|
{
|
||||||
TargetFactory rval;
|
TargetFactory rval;
|
||||||
|
@ -98,5 +99,7 @@ time_t Config::GetModificationTime() const
|
||||||
if ( file.empty() )
|
if ( file.empty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return zeekygen::get_mtime(file);
|
return get_mtime(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include <time.h> // for time_t
|
#include <time.h> // for time_t
|
||||||
|
|
||||||
namespace zeekygen {
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
class Info;
|
class Info;
|
||||||
|
|
||||||
|
@ -60,4 +60,11 @@ private:
|
||||||
TargetFactory target_factory;
|
TargetFactory target_factory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
||||||
|
namespace zeekygen {
|
||||||
|
|
||||||
|
using Config [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::Config.")]] = zeek::zeekygen::detail::Config;
|
||||||
|
using Info [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::Info.")]] = zeek::zeekygen::detail::Info;
|
||||||
|
|
||||||
} // namespace zeekygen
|
} // namespace zeekygen
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
#include "Expr.h"
|
#include "Expr.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace zeekygen;
|
|
||||||
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
IdentifierInfo::IdentifierInfo(zeek::detail::IDPtr arg_id, ScriptInfo* script)
|
IdentifierInfo::IdentifierInfo(zeek::detail::IDPtr arg_id, ScriptInfo* script)
|
||||||
: Info(),
|
: Info(),
|
||||||
|
@ -120,7 +121,7 @@ string IdentifierInfo::DoReStructuredText(bool roles_only) const
|
||||||
{
|
{
|
||||||
string s = comments[i];
|
string s = comments[i];
|
||||||
|
|
||||||
if ( zeekygen::prettify_params(s) )
|
if ( prettify_params(s) )
|
||||||
d.NL();
|
d.NL();
|
||||||
|
|
||||||
d.Add(s.c_str());
|
d.Add(s.c_str());
|
||||||
|
@ -156,3 +157,5 @@ IdentifierInfo::RecordField::~RecordField()
|
||||||
{
|
{
|
||||||
delete field;
|
delete field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
ZEEK_FORWARD_DECLARE_NAMESPACED(TypeDecl, zeek);
|
ZEEK_FORWARD_DECLARE_NAMESPACED(TypeDecl, zeek);
|
||||||
|
|
||||||
namespace zeekygen {
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
class ScriptInfo;
|
class ScriptInfo;
|
||||||
|
|
||||||
|
@ -182,4 +182,11 @@ private:
|
||||||
ScriptInfo* declaring_script;
|
ScriptInfo* declaring_script;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
||||||
|
namespace zeekygen {
|
||||||
|
|
||||||
|
using IdentifierInfo [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::IdentifierInfo.")]] = zeek::zeekygen::detail::IdentifierInfo;
|
||||||
|
using ScriptInfo [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::ScriptInfo.")]] = zeek::zeekygen::detail::ScriptInfo;
|
||||||
|
|
||||||
} // namespace zeekygen
|
} // namespace zeekygen
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
namespace zeekygen {
|
namespace zeek::zeekygen::detail{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base class for any thing that Zeekygen can document.
|
* Abstract base class for any thing that Zeekygen can document.
|
||||||
|
@ -67,4 +67,10 @@ private:
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
||||||
|
namespace zeekygen {
|
||||||
|
|
||||||
|
using Info [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::Info.")]] = zeek::zeekygen::detail::Info;
|
||||||
|
|
||||||
} // namespace zeekygen
|
} // namespace zeekygen
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
// See the file "COPYING" in the main distribution directory for copyright.
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
#include "Manager.h"
|
#include "Manager.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "plugin/Manager.h"
|
#include "plugin/Manager.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "Info.h"
|
#include "Info.h"
|
||||||
|
@ -9,12 +13,10 @@
|
||||||
#include "IdentifierInfo.h"
|
#include "IdentifierInfo.h"
|
||||||
#include "Expr.h"
|
#include "Expr.h"
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
using namespace zeekygen;
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
static void DbgAndWarn(const char* msg)
|
static void DbgAndWarn(const char* msg)
|
||||||
{
|
{
|
||||||
if ( zeek::reporter->Errors() )
|
if ( zeek::reporter->Errors() )
|
||||||
|
@ -457,3 +459,5 @@ string Manager::GetEnumTypeName(const string& id) const
|
||||||
map<string, string>::const_iterator it = enum_mappings.find(id);
|
map<string, string>::const_iterator it = enum_mappings.find(id);
|
||||||
return it == enum_mappings.end() ? "" : it->second;
|
return it == enum_mappings.end() ? "" : it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
|
@ -16,11 +16,10 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
ZEEK_FORWARD_DECLARE_NAMESPACED(TypeDecl, zeek);
|
ZEEK_FORWARD_DECLARE_NAMESPACED(TypeDecl, zeek);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(PackageInfo, zeek, zeekygen, detail);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(ScriptInfoInfo, zeek, zeekygen, detail);
|
||||||
|
|
||||||
namespace zeekygen {
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
class PackageInfo;
|
|
||||||
class ScriptInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of info objects. Just a wrapper around std::map to improve code
|
* Map of info objects. Just a wrapper around std::map to improve code
|
||||||
|
@ -262,6 +261,18 @@ bool Manager::IsUpToDate(const std::string& target_file,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
|
extern zeek::zeekygen::detail::Manager* zeekygen_mgr;
|
||||||
|
|
||||||
|
} // namespace zeek::detail
|
||||||
|
|
||||||
|
namespace zeekygen {
|
||||||
|
|
||||||
|
using Manager [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::Manager.")]] = zeek::zeekygen::detail::Manager;
|
||||||
|
|
||||||
} // namespace zeekygen
|
} // namespace zeekygen
|
||||||
|
|
||||||
extern zeekygen::Manager* zeekygen_mgr;
|
extern zeek::zeekygen::detail::Manager*& zeekygen_mgr [[deprecated("Remove in v4.1. Use zeek::detail::zeekygen_mgr.")]];
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace zeekygen;
|
|
||||||
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
PackageInfo::PackageInfo(const string& arg_name)
|
PackageInfo::PackageInfo(const string& arg_name)
|
||||||
: Info(),
|
: Info(),
|
||||||
|
@ -54,5 +55,7 @@ time_t PackageInfo::DoGetModificationTime() const
|
||||||
if ( readme_file.empty() )
|
if ( readme_file.empty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return zeekygen::get_mtime(readme_file);
|
return get_mtime(readme_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include <time.h> // for time_t
|
#include <time.h> // for time_t
|
||||||
|
|
||||||
namespace zeekygen {
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information about a Zeek script package.
|
* Information about a Zeek script package.
|
||||||
|
@ -46,4 +46,10 @@ private:
|
||||||
std::vector<std::string> readme;
|
std::vector<std::string> readme;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
||||||
|
namespace zeekygen {
|
||||||
|
|
||||||
|
using PackageInfo [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::PackageInfo.")]] = zeek::zeekygen::detail::PackageInfo;
|
||||||
|
|
||||||
} // namespace zeekygen
|
} // namespace zeekygen
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace zeekygen;
|
|
||||||
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
ReStructuredTextTable::ReStructuredTextTable(size_t arg_num_cols)
|
ReStructuredTextTable::ReStructuredTextTable(size_t arg_num_cols)
|
||||||
: num_cols(arg_num_cols), rows(), longest_row_in_column()
|
: num_cols(arg_num_cols), rows(), longest_row_in_column()
|
||||||
|
@ -66,3 +67,5 @@ string ReStructuredTextTable::AsString(char border) const
|
||||||
rval += MakeBorder(longest_row_in_column, border);
|
rval += MakeBorder(longest_row_in_column, border);
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace zeekygen {
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A reST table with arbitrary number of columns.
|
* A reST table with arbitrary number of columns.
|
||||||
|
@ -47,4 +47,10 @@ private:
|
||||||
std::vector<size_t> longest_row_in_column;
|
std::vector<size_t> longest_row_in_column;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
||||||
|
namespace zeekygen {
|
||||||
|
|
||||||
|
using ReStructuredTextTable [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::ReStructuredTextTable.")]] = zeek::zeekygen::detail::ReStructuredTextTable;
|
||||||
|
|
||||||
} // namespace zeekygen
|
} // namespace zeekygen
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
#include "Type.h"
|
#include "Type.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace zeekygen;
|
|
||||||
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
bool IdInfoComp::operator ()(const IdentifierInfo* lhs,
|
bool IdInfoComp::operator ()(const IdentifierInfo* lhs,
|
||||||
const IdentifierInfo* rhs) const
|
const IdentifierInfo* rhs) const
|
||||||
|
@ -27,11 +28,11 @@ static vector<string> summary_comment(const vector<string>& cmnts)
|
||||||
|
|
||||||
for ( size_t i = 0; i < cmnts.size(); ++i )
|
for ( size_t i = 0; i < cmnts.size(); ++i )
|
||||||
{
|
{
|
||||||
size_t end = zeekygen::end_of_first_sentence(cmnts[i]);
|
size_t end = end_of_first_sentence(cmnts[i]);
|
||||||
|
|
||||||
if ( end == string::npos )
|
if ( end == string::npos )
|
||||||
{
|
{
|
||||||
if ( zeekygen::is_all_whitespace(cmnts[i]) )
|
if ( is_all_whitespace(cmnts[i]) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
rval.push_back(cmnts[i]);
|
rval.push_back(cmnts[i]);
|
||||||
|
@ -89,7 +90,7 @@ static string make_summary(const string& heading, char underline, char border,
|
||||||
add_summary_rows(d, summary_comment((*it)->GetComments()), &table);
|
add_summary_rows(d, summary_comment((*it)->GetComments()), &table);
|
||||||
}
|
}
|
||||||
|
|
||||||
return zeekygen::make_heading(heading, underline) + table.AsString(border)
|
return make_heading(heading, underline) + table.AsString(border)
|
||||||
+ "\n";
|
+ "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ static string make_redef_summary(const string& heading, char underline,
|
||||||
add_summary_rows(d, summary_comment(iit->comments), &table);
|
add_summary_rows(d, summary_comment(iit->comments), &table);
|
||||||
}
|
}
|
||||||
|
|
||||||
return zeekygen::make_heading(heading, underline) + table.AsString(border)
|
return make_heading(heading, underline) + table.AsString(border)
|
||||||
+ "\n";
|
+ "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +129,7 @@ static string make_details(const string& heading, char underline,
|
||||||
if ( id_list.empty() )
|
if ( id_list.empty() )
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
string rval = zeekygen::make_heading(heading, underline);
|
string rval = make_heading(heading, underline);
|
||||||
|
|
||||||
for ( id_info_list::const_iterator it = id_list.begin();
|
for ( id_info_list::const_iterator it = id_list.begin();
|
||||||
it != id_list.end(); ++it )
|
it != id_list.end(); ++it )
|
||||||
|
@ -146,7 +147,7 @@ static string make_redef_details(const string& heading, char underline,
|
||||||
if ( id_set.empty() )
|
if ( id_set.empty() )
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
string rval = zeekygen::make_heading(heading, underline);
|
string rval = make_heading(heading, underline);
|
||||||
|
|
||||||
for ( id_info_set::const_iterator it = id_set.begin();
|
for ( id_info_set::const_iterator it = id_set.begin();
|
||||||
it != id_set.end(); ++it )
|
it != id_set.end(); ++it )
|
||||||
|
@ -181,7 +182,7 @@ void ScriptInfo::DoInitPostScript()
|
||||||
IdentifierInfo* info = it->second;
|
IdentifierInfo* info = it->second;
|
||||||
auto* id = info->GetID();
|
auto* id = info->GetID();
|
||||||
|
|
||||||
if ( ! zeekygen::is_public_api(id) )
|
if ( ! is_public_api(id) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( id->IsType() )
|
if ( id->IsType() )
|
||||||
|
@ -278,7 +279,7 @@ string ScriptInfo::DoReStructuredText(bool roles_only) const
|
||||||
string rval;
|
string rval;
|
||||||
|
|
||||||
rval += ":tocdepth: 3\n\n";
|
rval += ":tocdepth: 3\n\n";
|
||||||
rval += zeekygen::make_heading(name, '=');
|
rval += make_heading(name, '=');
|
||||||
|
|
||||||
for ( string_set::const_iterator it = module_usages.begin();
|
for ( string_set::const_iterator it = module_usages.begin();
|
||||||
it != module_usages.end(); ++it )
|
it != module_usages.end(); ++it )
|
||||||
|
@ -332,7 +333,7 @@ string ScriptInfo::DoReStructuredText(bool roles_only) const
|
||||||
|
|
||||||
//rval += zeek::util::fmt(":Source File: :download:`/scripts/%s`\n", name.c_str());
|
//rval += zeek::util::fmt(":Source File: :download:`/scripts/%s`\n", name.c_str());
|
||||||
rval += "\n";
|
rval += "\n";
|
||||||
rval += zeekygen::make_heading("Summary", '~');
|
rval += make_heading("Summary", '~');
|
||||||
rval += make_summary("Runtime Options", '#', '=', options);
|
rval += make_summary("Runtime Options", '#', '=', options);
|
||||||
rval += make_summary("Redefinable Options", '#', '=', redef_options);
|
rval += make_summary("Redefinable Options", '#', '=', redef_options);
|
||||||
rval += make_summary("Constants", '#', '=', constants);
|
rval += make_summary("Constants", '#', '=', constants);
|
||||||
|
@ -343,7 +344,7 @@ string ScriptInfo::DoReStructuredText(bool roles_only) const
|
||||||
rval += make_summary("Hooks", '#', '=', hooks);
|
rval += make_summary("Hooks", '#', '=', hooks);
|
||||||
rval += make_summary("Functions", '#', '=', functions);
|
rval += make_summary("Functions", '#', '=', functions);
|
||||||
rval += "\n";
|
rval += "\n";
|
||||||
rval += zeekygen::make_heading("Detailed Interface", '~');
|
rval += make_heading("Detailed Interface", '~');
|
||||||
rval += make_details("Runtime Options", '#', options);
|
rval += make_details("Runtime Options", '#', options);
|
||||||
rval += make_details("Redefinable Options", '#', redef_options);
|
rval += make_details("Redefinable Options", '#', redef_options);
|
||||||
rval += make_details("Constants", '#', constants);
|
rval += make_details("Constants", '#', constants);
|
||||||
|
@ -359,19 +360,19 @@ string ScriptInfo::DoReStructuredText(bool roles_only) const
|
||||||
|
|
||||||
time_t ScriptInfo::DoGetModificationTime() const
|
time_t ScriptInfo::DoGetModificationTime() const
|
||||||
{
|
{
|
||||||
time_t most_recent = zeekygen::get_mtime(path);
|
time_t most_recent = get_mtime(path);
|
||||||
|
|
||||||
for ( string_set::const_iterator it = dependencies.begin();
|
for ( string_set::const_iterator it = dependencies.begin();
|
||||||
it != dependencies.end(); ++it )
|
it != dependencies.end(); ++it )
|
||||||
{
|
{
|
||||||
Info* info = zeekygen_mgr->GetScriptInfo(*it);
|
Info* info = zeek::detail::zeekygen_mgr->GetScriptInfo(*it);
|
||||||
|
|
||||||
if ( ! info )
|
if ( ! info )
|
||||||
{
|
{
|
||||||
for (const string& ext : zeek::util::script_extensions)
|
for (const string& ext : zeek::util::script_extensions)
|
||||||
{
|
{
|
||||||
string pkg_name = *it + "/__load__" + ext;
|
string pkg_name = *it + "/__load__" + ext;
|
||||||
info = zeekygen_mgr->GetScriptInfo(pkg_name);
|
info = zeek::detail::zeekygen_mgr->GetScriptInfo(pkg_name);
|
||||||
if ( info )
|
if ( info )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -390,3 +391,5 @@ time_t ScriptInfo::DoGetModificationTime() const
|
||||||
|
|
||||||
return most_recent;
|
return most_recent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "zeek-config.h"
|
||||||
#include "Info.h"
|
#include "Info.h"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -12,17 +13,17 @@
|
||||||
|
|
||||||
#include <time.h> // for time_t
|
#include <time.h> // for time_t
|
||||||
|
|
||||||
namespace zeekygen {
|
ZEEK_FORWARD_DECLARE_NAMESPACED(IdentifierInfo, zeek, zeekygen, detail);
|
||||||
|
|
||||||
class IdentifierInfo;
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
struct IdInfoComp {
|
struct IdInfoComp {
|
||||||
bool operator() (const IdentifierInfo* lhs,
|
bool operator() (const IdentifierInfo* lhs,
|
||||||
const IdentifierInfo* rhs) const;
|
const IdentifierInfo* rhs) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::set<IdentifierInfo*, IdInfoComp> id_info_set;
|
using id_info_set = std::set<IdentifierInfo*, IdInfoComp>;
|
||||||
typedef std::list<IdentifierInfo*> id_info_list;
|
using id_info_list = std::list<IdentifierInfo*>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information about a Bro script.
|
* Information about a Bro script.
|
||||||
|
@ -119,4 +120,13 @@ private:
|
||||||
id_info_set redefs;
|
id_info_set redefs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
||||||
|
namespace zeekygen {
|
||||||
|
|
||||||
|
using ScriptInfo [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::ScriptInfo.")]] = zeek::zeekygen::detail::ScriptInfo;
|
||||||
|
using id_info_set [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::id_info_set.")]] = zeek::zeekygen::detail::id_info_set;
|
||||||
|
using id_info_list [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::id_info_list.")]] = zeek::zeekygen::detail::id_info_list;
|
||||||
|
using IdInfoComp [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::IdInfoComp.")]] = zeek::zeekygen::detail::IdInfoComp;
|
||||||
|
|
||||||
} // namespace zeekygen
|
} // namespace zeekygen
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace zeekygen;
|
|
||||||
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
static void write_plugin_section_heading(FILE* f, const zeek::plugin::Plugin* p)
|
static void write_plugin_section_heading(FILE* f, const zeek::plugin::Plugin* p)
|
||||||
{
|
{
|
||||||
|
@ -125,7 +126,7 @@ static void write_plugin_bif_items(FILE* f, const zeek::plugin::Plugin* p,
|
||||||
|
|
||||||
for ( it = bifitems.begin(); it != bifitems.end(); ++it )
|
for ( it = bifitems.begin(); it != bifitems.end(); ++it )
|
||||||
{
|
{
|
||||||
zeekygen::IdentifierInfo* doc = zeekygen_mgr->GetIdentifierInfo(
|
IdentifierInfo* doc = zeek::detail::zeekygen_mgr->GetIdentifierInfo(
|
||||||
it->GetID());
|
it->GetID());
|
||||||
|
|
||||||
if ( doc )
|
if ( doc )
|
||||||
|
@ -140,7 +141,7 @@ static void WriteAnalyzerTagDefn(FILE* f, const string& module)
|
||||||
{
|
{
|
||||||
string tag_id = module + "::Tag";
|
string tag_id = module + "::Tag";
|
||||||
|
|
||||||
zeekygen::IdentifierInfo* doc = zeekygen_mgr->GetIdentifierInfo(tag_id);
|
IdentifierInfo* doc = zeek::detail::zeekygen_mgr->GetIdentifierInfo(tag_id);
|
||||||
|
|
||||||
if ( ! doc )
|
if ( ! doc )
|
||||||
zeek::reporter->InternalError("Zeekygen failed analyzer tag lookup: %s",
|
zeek::reporter->InternalError("Zeekygen failed analyzer tag lookup: %s",
|
||||||
|
@ -247,7 +248,7 @@ void AnalyzerTarget::DoFindDependencies(const std::vector<Info *>& infos)
|
||||||
|
|
||||||
void AnalyzerTarget::DoGenerate() const
|
void AnalyzerTarget::DoGenerate() const
|
||||||
{
|
{
|
||||||
if ( zeekygen_mgr->IsUpToDate(Name(), vector<Info*>()) )
|
if ( zeek::detail::zeekygen_mgr->IsUpToDate(Name(), vector<Info*>()) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( Pattern() != "*" )
|
if ( Pattern() != "*" )
|
||||||
|
@ -341,8 +342,8 @@ void PackageTarget::DoFindDependencies(const vector<Info*>& infos)
|
||||||
|
|
||||||
void PackageTarget::DoGenerate() const
|
void PackageTarget::DoGenerate() const
|
||||||
{
|
{
|
||||||
if ( zeekygen_mgr->IsUpToDate(Name(), script_deps) &&
|
if ( zeek::detail::zeekygen_mgr->IsUpToDate(Name(), script_deps) &&
|
||||||
zeekygen_mgr->IsUpToDate(Name(), pkg_deps) )
|
zeek::detail::zeekygen_mgr->IsUpToDate(Name(), pkg_deps) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TargetFile file(Name());
|
TargetFile file(Name());
|
||||||
|
@ -390,7 +391,7 @@ void PackageIndexTarget::DoFindDependencies(const vector<Info*>& infos)
|
||||||
|
|
||||||
void PackageIndexTarget::DoGenerate() const
|
void PackageIndexTarget::DoGenerate() const
|
||||||
{
|
{
|
||||||
if ( zeekygen_mgr->IsUpToDate(Name(), pkg_deps) )
|
if ( zeek::detail::zeekygen_mgr->IsUpToDate(Name(), pkg_deps) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TargetFile file(Name());
|
TargetFile file(Name());
|
||||||
|
@ -485,7 +486,7 @@ void ScriptTarget::DoGenerate() const
|
||||||
vector<ScriptInfo*> dep;
|
vector<ScriptInfo*> dep;
|
||||||
dep.push_back(script_deps[i]);
|
dep.push_back(script_deps[i]);
|
||||||
|
|
||||||
if ( zeekygen_mgr->IsUpToDate(target_filename, dep) )
|
if ( zeek::detail::zeekygen_mgr->IsUpToDate(target_filename, dep) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
TargetFile file(target_filename);
|
TargetFile file(target_filename);
|
||||||
|
@ -518,7 +519,7 @@ void ScriptTarget::DoGenerate() const
|
||||||
|
|
||||||
// Target is a single file, all matching scripts get written there.
|
// Target is a single file, all matching scripts get written there.
|
||||||
|
|
||||||
if ( zeekygen_mgr->IsUpToDate(Name(), script_deps) )
|
if ( zeek::detail::zeekygen_mgr->IsUpToDate(Name(), script_deps) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TargetFile file(Name());
|
TargetFile file(Name());
|
||||||
|
@ -529,7 +530,7 @@ void ScriptTarget::DoGenerate() const
|
||||||
|
|
||||||
void ScriptSummaryTarget::DoGenerate() const
|
void ScriptSummaryTarget::DoGenerate() const
|
||||||
{
|
{
|
||||||
if ( zeekygen_mgr->IsUpToDate(Name(), script_deps) )
|
if ( zeek::detail::zeekygen_mgr->IsUpToDate(Name(), script_deps) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TargetFile file(Name());
|
TargetFile file(Name());
|
||||||
|
@ -554,7 +555,7 @@ void ScriptSummaryTarget::DoGenerate() const
|
||||||
|
|
||||||
void ScriptIndexTarget::DoGenerate() const
|
void ScriptIndexTarget::DoGenerate() const
|
||||||
{
|
{
|
||||||
if ( zeekygen_mgr->IsUpToDate(Name(), script_deps) )
|
if ( zeek::detail::zeekygen_mgr->IsUpToDate(Name(), script_deps) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TargetFile file(Name());
|
TargetFile file(Name());
|
||||||
|
@ -585,7 +586,7 @@ void IdentifierTarget::DoFindDependencies(const vector<Info*>& infos)
|
||||||
|
|
||||||
void IdentifierTarget::DoGenerate() const
|
void IdentifierTarget::DoGenerate() const
|
||||||
{
|
{
|
||||||
if ( zeekygen_mgr->IsUpToDate(Name(), id_deps) )
|
if ( zeek::detail::zeekygen_mgr->IsUpToDate(Name(), id_deps) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TargetFile file(Name());
|
TargetFile file(Name());
|
||||||
|
@ -593,3 +594,5 @@ void IdentifierTarget::DoGenerate() const
|
||||||
for ( size_t i = 0; i < id_deps.size(); ++i )
|
for ( size_t i = 0; i < id_deps.size(); ++i )
|
||||||
fprintf(file.f, "%s\n\n", id_deps[i]->ReStructuredText().c_str());
|
fprintf(file.f, "%s\n\n", id_deps[i]->ReStructuredText().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
|
@ -2,17 +2,19 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "zeek-config.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
namespace zeekygen {
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Info, zeek, zeekygen, detail);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(PackageInfo, zeek, zeekygen, detail);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(ScriptInfo, zeek, zeekygen, detail);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(IdentifierInfo, zeek, zeekygen, detail);
|
||||||
|
|
||||||
class Info;
|
namespace zeek::zeekygen::detail {
|
||||||
class PackageInfo;
|
|
||||||
class ScriptInfo;
|
|
||||||
class IdentifierInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class to create files in arbitrary file paths and automatically
|
* Helper class to create files in arbitrary file paths and automatically
|
||||||
|
@ -383,4 +385,21 @@ private:
|
||||||
std::vector<IdentifierInfo*> id_deps;
|
std::vector<IdentifierInfo*> id_deps;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
||||||
|
namespace zeekygen {
|
||||||
|
|
||||||
|
using TargetFile [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::TargetFile.")]] = zeek::zeekygen::detail::TargetFile;
|
||||||
|
using Target [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::Target.")]] = zeek::zeekygen::detail::Target;
|
||||||
|
using TargetFactory [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::TargetFactory.")]] = zeek::zeekygen::detail::TargetFactory;
|
||||||
|
using AnalyzerTarget [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::AnalyzerTarget.")]] = zeek::zeekygen::detail::AnalyzerTarget;
|
||||||
|
using ProtoAnalyzerTarget [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::ProtoAnalyzerTarget.")]] = zeek::zeekygen::detail::ProtoAnalyzerTarget;
|
||||||
|
using FileAnalyzerTarget [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::FileAnalyzerTarget.")]] = zeek::zeekygen::detail::FileAnalyzerTarget;
|
||||||
|
using PackageTarget [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::PackageTarget.")]] = zeek::zeekygen::detail::PackageTarget;
|
||||||
|
using PackageIndexTarget [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::PackageIndexTarget.")]] = zeek::zeekygen::detail::PackageIndexTarget;
|
||||||
|
using ScriptTarget [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::ScriptTarget.")]] = zeek::zeekygen::detail::ScriptTarget;
|
||||||
|
using ScriptSummaryTarget [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::ScriptSummaryTarget.")]] = zeek::zeekygen::detail::ScriptSummaryTarget;
|
||||||
|
using ScriptIndexTarget [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::ScriptIndexTarget.")]] = zeek::zeekygen::detail::ScriptIndexTarget;
|
||||||
|
using IdentifierTarget [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::IdentifierTarget.")]] = zeek::zeekygen::detail::IdentifierTarget;
|
||||||
|
|
||||||
} // namespace zeekygen
|
} // namespace zeekygen
|
||||||
|
|
|
@ -9,10 +9,11 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
using namespace zeekygen;
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
bool zeekygen::prettify_params(string& s)
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
|
bool prettify_params(string& s)
|
||||||
{
|
{
|
||||||
size_t identifier_start_pos = 0;
|
size_t identifier_start_pos = 0;
|
||||||
bool in_identifier = false;
|
bool in_identifier = false;
|
||||||
|
@ -78,13 +79,13 @@ bool zeekygen::prettify_params(string& s)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool zeekygen::is_public_api(const zeek::detail::ID* id)
|
bool is_public_api(const zeek::detail::ID* id)
|
||||||
{
|
{
|
||||||
return (id->Scope() == zeek::detail::SCOPE_GLOBAL) ||
|
return (id->Scope() == zeek::detail::SCOPE_GLOBAL) ||
|
||||||
(id->Scope() == zeek::detail::SCOPE_MODULE && id->IsExport());
|
(id->Scope() == zeek::detail::SCOPE_MODULE && id->IsExport());
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t zeekygen::get_mtime(const string& filename)
|
time_t get_mtime(const string& filename)
|
||||||
{
|
{
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
|
@ -95,12 +96,12 @@ time_t zeekygen::get_mtime(const string& filename)
|
||||||
return s.st_mtime;
|
return s.st_mtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
string zeekygen::make_heading(const string& heading, char underline)
|
string make_heading(const string& heading, char underline)
|
||||||
{
|
{
|
||||||
return heading + "\n" + string(heading.size(), underline) + "\n";
|
return heading + "\n" + string(heading.size(), underline) + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t zeekygen::end_of_first_sentence(const string& s)
|
size_t end_of_first_sentence(const string& s)
|
||||||
{
|
{
|
||||||
size_t rval = 0;
|
size_t rval = 0;
|
||||||
|
|
||||||
|
@ -121,7 +122,7 @@ size_t zeekygen::end_of_first_sentence(const string& s)
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool zeekygen::is_all_whitespace(const string& s)
|
bool is_all_whitespace(const string& s)
|
||||||
{
|
{
|
||||||
for ( size_t i = 0; i < s.size(); ++i )
|
for ( size_t i = 0; i < s.size(); ++i )
|
||||||
if ( ! isspace(s[i]) )
|
if ( ! isspace(s[i]) )
|
||||||
|
@ -130,8 +131,10 @@ bool zeekygen::is_all_whitespace(const string& s)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string zeekygen::redef_indication(const string& from_script)
|
string redef_indication(const string& from_script)
|
||||||
{
|
{
|
||||||
return zeek::util::fmt("(present if :doc:`/scripts/%s` is loaded)",
|
return zeek::util::fmt("(present if :doc:`/scripts/%s` is loaded)",
|
||||||
from_script.c_str());
|
from_script.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include "zeek-config.h"
|
||||||
|
|
||||||
#include <time.h> // for time_t
|
#include <time.h> // for time_t
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace zeek::detail { class ID; }
|
ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||||
using ID [[deprecated("Remove in v4.1. Use zeek::detail::ID instead")]] = zeek::detail::ID;
|
|
||||||
|
|
||||||
namespace zeekygen {
|
namespace zeek::zeekygen::detail {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform content of a Zeekygen comment which may contain function
|
* Transform content of a Zeekygen comment which may contain function
|
||||||
|
@ -64,4 +64,16 @@ bool is_all_whitespace(const std::string& s);
|
||||||
*/
|
*/
|
||||||
std::string redef_indication(const std::string& from_script);
|
std::string redef_indication(const std::string& from_script);
|
||||||
|
|
||||||
|
} // namespace zeek::zeekygen::detail
|
||||||
|
|
||||||
|
namespace zeekygen {
|
||||||
|
|
||||||
|
constexpr auto prettify_params [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::prettify_params.")]] = zeek::zeekygen::detail::prettify_params;
|
||||||
|
constexpr auto is_public_api [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::is_public_api.")]] = zeek::zeekygen::detail::is_public_api;
|
||||||
|
constexpr auto get_mtime [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::get_mtime.")]] = zeek::zeekygen::detail::get_mtime;
|
||||||
|
constexpr auto make_heading [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::make_heading.")]] = zeek::zeekygen::detail::make_heading;
|
||||||
|
constexpr auto end_of_first_sentence [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::end_of_first_sentence.")]] = zeek::zeekygen::detail::end_of_first_sentence;
|
||||||
|
constexpr auto is_all_whitespace [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::is_all_whitespace.")]] = zeek::zeekygen::detail::is_all_whitespace;
|
||||||
|
constexpr auto redef_indication [[deprecated("Remove in v4.1. Use zeek::zeekygen::detail::redef_indication.")]] = zeek::zeekygen::detail::redef_indication;
|
||||||
|
|
||||||
} // namespace zeekygen
|
} // namespace zeekygen
|
||||||
|
|
|
@ -25,7 +25,7 @@ static zeek::StringValPtr comments_to_val(const vector<string>& comments)
|
||||||
function get_identifier_comments%(name: string%): string
|
function get_identifier_comments%(name: string%): string
|
||||||
%{
|
%{
|
||||||
using namespace zeekygen;
|
using namespace zeekygen;
|
||||||
IdentifierInfo* d = zeekygen_mgr->GetIdentifierInfo(name->CheckString());
|
zeek::zeekygen::detail::IdentifierInfo* d = zeek::detail::zeekygen_mgr->GetIdentifierInfo(name->CheckString());
|
||||||
|
|
||||||
if ( ! d )
|
if ( ! d )
|
||||||
return zeek::val_mgr->EmptyString();
|
return zeek::val_mgr->EmptyString();
|
||||||
|
@ -45,7 +45,7 @@ function get_identifier_comments%(name: string%): string
|
||||||
function get_script_comments%(name: string%): string
|
function get_script_comments%(name: string%): string
|
||||||
%{
|
%{
|
||||||
using namespace zeekygen;
|
using namespace zeekygen;
|
||||||
ScriptInfo* d = zeekygen_mgr->GetScriptInfo(name->CheckString());
|
zeek::zeekygen::detail::ScriptInfo* d = zeek::detail::zeekygen_mgr->GetScriptInfo(name->CheckString());
|
||||||
|
|
||||||
if ( ! d )
|
if ( ! d )
|
||||||
return zeek::val_mgr->EmptyString();
|
return zeek::val_mgr->EmptyString();
|
||||||
|
@ -63,7 +63,7 @@ function get_script_comments%(name: string%): string
|
||||||
function get_package_readme%(name: string%): string
|
function get_package_readme%(name: string%): string
|
||||||
%{
|
%{
|
||||||
using namespace zeekygen;
|
using namespace zeekygen;
|
||||||
PackageInfo* d = zeekygen_mgr->GetPackageInfo(name->CheckString());
|
zeek::zeekygen::detail::PackageInfo* d = zeek::detail::zeekygen_mgr->GetPackageInfo(name->CheckString());
|
||||||
|
|
||||||
if ( ! d )
|
if ( ! d )
|
||||||
return zeek::val_mgr->EmptyString();
|
return zeek::val_mgr->EmptyString();
|
||||||
|
@ -90,7 +90,7 @@ function get_record_field_comments%(name: string%): string
|
||||||
|
|
||||||
string id = accessor.substr(0, i);
|
string id = accessor.substr(0, i);
|
||||||
|
|
||||||
IdentifierInfo* d = zeekygen_mgr->GetIdentifierInfo(id);
|
zeek::zeekygen::detail::IdentifierInfo* d = zeek::detail::zeekygen_mgr->GetIdentifierInfo(id);
|
||||||
|
|
||||||
if ( ! d )
|
if ( ! d )
|
||||||
return zeek::val_mgr->EmptyString();
|
return zeek::val_mgr->EmptyString();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue