mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 09:08:20 +00:00

This largely copies over Spicy's `.clang-format` configuration file. The one place where we deviate is header include order since Zeek depends on headers being included in a certain order.
37 lines
1.4 KiB
C++
37 lines
1.4 KiB
C++
// See the file "COPYING" in the main distribution directory for copyright.
|
|
|
|
// Utility functions for compile-to-C++ compiler.
|
|
|
|
#pragma once
|
|
|
|
#include "zeek/script_opt/ProfileFunc.h"
|
|
|
|
namespace zeek::detail {
|
|
|
|
// Conversions to strings.
|
|
inline std::string Fmt(int i) { return std::to_string(i); }
|
|
inline std::string Fmt(p_hash_type u) { return std::to_string(u) + "ULL"; }
|
|
extern std::string Fmt(double d);
|
|
|
|
// Returns the prefix for the scoping used by the compiler.
|
|
extern std::string scope_prefix(const std::string& scope);
|
|
|
|
// Same, but for scopes identified with numbers.
|
|
extern std::string scope_prefix(int scope);
|
|
|
|
// True if the given function is compilable to C++. If it isn't, and
|
|
// the second argument is non-nil, then on return it points to text
|
|
// explaining why not.
|
|
extern bool is_CPP_compilable(const ProfileFunc* pf, const char** reason = nullptr);
|
|
|
|
// Helper utilities for file locking, to ensure that hash files
|
|
// don't receive conflicting writes due to concurrent compilations.
|
|
extern void lock_file(const std::string& fname, FILE* f);
|
|
extern void unlock_file(const std::string& fname, FILE* f);
|
|
|
|
// For the given byte array / string, returns a version expanded
|
|
// with escape sequences in order to represent it as a C++ string.
|
|
extern std::string CPPEscape(const char* b, int len);
|
|
inline std::string CPPEscape(const char* s) { return CPPEscape(s, strlen(s)); }
|
|
|
|
} // namespace zeek::detail
|