mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
bifcl: Add clang-format and run it on everything
This commit is contained in:
parent
552be424c4
commit
3a18b2144c
3 changed files with 30 additions and 33 deletions
|
@ -7,7 +7,8 @@ using namespace std;
|
||||||
|
|
||||||
#include "bif_arg.h"
|
#include "bif_arg.h"
|
||||||
|
|
||||||
static struct {
|
static struct
|
||||||
|
{
|
||||||
const char* bif_type;
|
const char* bif_type;
|
||||||
const char* zeek_type;
|
const char* zeek_type;
|
||||||
const char* c_type;
|
const char* c_type;
|
||||||
|
@ -18,8 +19,10 @@ static struct {
|
||||||
const char* constructor;
|
const char* constructor;
|
||||||
const char* ctor_smart;
|
const char* ctor_smart;
|
||||||
} builtin_func_arg_type[] = {
|
} builtin_func_arg_type[] = {
|
||||||
#define DEFINE_BIF_TYPE(id, bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, constructor, ctor_smart) \
|
#define DEFINE_BIF_TYPE(id, bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, \
|
||||||
{bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, constructor, ctor_smart},
|
cast_smart, constructor, ctor_smart) \
|
||||||
|
{bif_type, zeek_type, c_type, c_type_smart, accessor, \
|
||||||
|
accessor_smart, cast_smart, constructor, ctor_smart},
|
||||||
#include "bif_type.def"
|
#include "bif_type.def"
|
||||||
#undef DEFINE_BIF_TYPE
|
#undef DEFINE_BIF_TYPE
|
||||||
};
|
};
|
||||||
|
@ -52,16 +55,12 @@ BuiltinFuncArg::BuiltinFuncArg(const char* arg_name, const char* arg_type_str,
|
||||||
|
|
||||||
void BuiltinFuncArg::PrintZeek(FILE* fp)
|
void BuiltinFuncArg::PrintZeek(FILE* fp)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%s: %s%s %s", name, builtin_func_arg_type[type].zeek_type,
|
fprintf(fp, "%s: %s%s %s", name, builtin_func_arg_type[type].zeek_type, type_str, attr_str);
|
||||||
type_str, attr_str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuiltinFuncArg::PrintCDef(FILE* fp, int n)
|
void BuiltinFuncArg::PrintCDef(FILE* fp, int n)
|
||||||
{
|
{
|
||||||
fprintf(fp,
|
fprintf(fp, "\t%s %s = (%s) (", builtin_func_arg_type[type].c_type, name,
|
||||||
"\t%s %s = (%s) (",
|
|
||||||
builtin_func_arg_type[type].c_type,
|
|
||||||
name,
|
|
||||||
builtin_func_arg_type[type].c_type);
|
builtin_func_arg_type[type].c_type);
|
||||||
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
enum builtin_func_arg_type {
|
enum builtin_func_arg_type
|
||||||
#define DEFINE_BIF_TYPE(id, bif_type, bro_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, constructor, ctor_smart) \
|
{
|
||||||
|
#define DEFINE_BIF_TYPE(id, bif_type, bro_type, c_type, c_type_smart, accessor, accessor_smart, \
|
||||||
|
cast_smart, constructor, ctor_smart) \
|
||||||
id,
|
id,
|
||||||
#include "bif_type.def"
|
#include "bif_type.def"
|
||||||
#undef DEFINE_BIF_TYPE
|
#undef DEFINE_BIF_TYPE
|
||||||
|
@ -11,16 +13,13 @@ enum builtin_func_arg_type {
|
||||||
|
|
||||||
extern const char* builtin_func_arg_type_bro_name[];
|
extern const char* builtin_func_arg_type_bro_name[];
|
||||||
|
|
||||||
class BuiltinFuncArg {
|
class BuiltinFuncArg
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
BuiltinFuncArg(const char* arg_name, int arg_type);
|
BuiltinFuncArg(const char* arg_name, int arg_type);
|
||||||
BuiltinFuncArg(const char* arg_name, const char* arg_type_str,
|
BuiltinFuncArg(const char* arg_name, const char* arg_type_str, const char* arg_attr_str = "");
|
||||||
const char* arg_attr_str = "");
|
|
||||||
|
|
||||||
void SetAttrStr(const char* arg_attr_str)
|
void SetAttrStr(const char* arg_attr_str) { attr_str = arg_attr_str; };
|
||||||
{
|
|
||||||
attr_str = arg_attr_str;
|
|
||||||
};
|
|
||||||
|
|
||||||
const char* Name() const { return name; }
|
const char* Name() const { return name; }
|
||||||
int Type() const { return type; }
|
int Type() const { return type; }
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
//
|
//
|
||||||
// See the file "COPYING" in the main distribution directory for copyright.
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <string.h>
|
|
||||||
#include "module_util.h"
|
#include "module_util.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
static int streq(const char* s1, const char* s2)
|
static int streq(const char* s1, const char* s2)
|
||||||
{
|
{
|
||||||
return ! strcmp(s1, s2);
|
return ! strcmp(s1, s2);
|
||||||
|
@ -41,8 +42,7 @@ string extract_var_name(const char *name)
|
||||||
string normalized_module_name(const char* module_name)
|
string normalized_module_name(const char* module_name)
|
||||||
{
|
{
|
||||||
int mod_len;
|
int mod_len;
|
||||||
if ( (mod_len = strlen(module_name)) >= 2 &&
|
if ( (mod_len = strlen(module_name)) >= 2 && streq(module_name + mod_len - 2, "::") )
|
||||||
streq(module_name + mod_len - 2, "::") )
|
|
||||||
mod_len -= 2;
|
mod_len -= 2;
|
||||||
|
|
||||||
return string(module_name, mod_len);
|
return string(module_name, mod_len);
|
||||||
|
@ -50,8 +50,7 @@ string normalized_module_name(const char* module_name)
|
||||||
|
|
||||||
string make_full_var_name(const char* module_name, const char* var_name)
|
string make_full_var_name(const char* module_name, const char* var_name)
|
||||||
{
|
{
|
||||||
if ( ! module_name || streq(module_name, GLOBAL_MODULE_NAME) ||
|
if ( ! module_name || streq(module_name, GLOBAL_MODULE_NAME) || strstr(var_name, "::") )
|
||||||
strstr(var_name, "::") )
|
|
||||||
{
|
{
|
||||||
if ( streq(GLOBAL_MODULE_NAME, extract_module_name(var_name).c_str()) )
|
if ( streq(GLOBAL_MODULE_NAME, extract_module_name(var_name).c_str()) )
|
||||||
return extract_var_name(var_name);
|
return extract_var_name(var_name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue