mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +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"
|
||||
|
||||
static struct {
|
||||
static struct
|
||||
{
|
||||
const char* bif_type;
|
||||
const char* zeek_type;
|
||||
const char* c_type;
|
||||
|
@ -17,12 +18,14 @@ static struct {
|
|||
const char* cast_smart;
|
||||
const char* constructor;
|
||||
const char* ctor_smart;
|
||||
} 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) \
|
||||
{bif_type, zeek_type, c_type, c_type_smart, accessor, accessor_smart, cast_smart, constructor, ctor_smart},
|
||||
} 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) \
|
||||
{bif_type, zeek_type, c_type, c_type_smart, accessor, \
|
||||
accessor_smart, cast_smart, constructor, ctor_smart},
|
||||
#include "bif_type.def"
|
||||
#undef DEFINE_BIF_TYPE
|
||||
};
|
||||
};
|
||||
|
||||
extern const char* arg_list_name;
|
||||
|
||||
|
@ -52,16 +55,12 @@ BuiltinFuncArg::BuiltinFuncArg(const char* arg_name, const char* arg_type_str,
|
|||
|
||||
void BuiltinFuncArg::PrintZeek(FILE* fp)
|
||||
{
|
||||
fprintf(fp, "%s: %s%s %s", name, builtin_func_arg_type[type].zeek_type,
|
||||
type_str, attr_str);
|
||||
fprintf(fp, "%s: %s%s %s", name, builtin_func_arg_type[type].zeek_type, type_str, attr_str);
|
||||
}
|
||||
|
||||
void BuiltinFuncArg::PrintCDef(FILE* fp, int n)
|
||||
{
|
||||
fprintf(fp,
|
||||
"\t%s %s = (%s) (",
|
||||
builtin_func_arg_type[type].c_type,
|
||||
name,
|
||||
fprintf(fp, "\t%s %s = (%s) (", builtin_func_arg_type[type].c_type, name,
|
||||
builtin_func_arg_type[type].c_type);
|
||||
|
||||
char buf[1024];
|
||||
|
|
|
@ -2,25 +2,24 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
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) \
|
||||
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) \
|
||||
id,
|
||||
#include "bif_type.def"
|
||||
#undef DEFINE_BIF_TYPE
|
||||
};
|
||||
};
|
||||
|
||||
extern const char* builtin_func_arg_type_bro_name[];
|
||||
|
||||
class BuiltinFuncArg {
|
||||
class BuiltinFuncArg
|
||||
{
|
||||
public:
|
||||
BuiltinFuncArg(const char* arg_name, int arg_type);
|
||||
BuiltinFuncArg(const char* arg_name, const char* arg_type_str,
|
||||
const char* arg_attr_str = "");
|
||||
BuiltinFuncArg(const char* arg_name, const char* arg_type_str, const char* arg_attr_str = "");
|
||||
|
||||
void SetAttrStr(const char* arg_attr_str)
|
||||
{
|
||||
attr_str = arg_attr_str;
|
||||
};
|
||||
void SetAttrStr(const char* arg_attr_str) { attr_str = arg_attr_str; };
|
||||
|
||||
const char* Name() const { return name; }
|
||||
int Type() const { return type; }
|
||||
|
@ -35,4 +34,4 @@ protected:
|
|||
int type;
|
||||
const char* type_str;
|
||||
const char* attr_str;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
//
|
||||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include "module_util.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
static int streq(const char* s1, const char* s2)
|
||||
{
|
||||
return ! strcmp(s1, s2);
|
||||
|
@ -24,7 +25,7 @@ string extract_module_name(const char* name)
|
|||
return module_name;
|
||||
}
|
||||
|
||||
string extract_var_name(const char *name)
|
||||
string extract_var_name(const char* name)
|
||||
{
|
||||
string var_name = name;
|
||||
string::size_type pos = var_name.rfind("::");
|
||||
|
@ -35,14 +36,13 @@ string extract_var_name(const char *name)
|
|||
if ( pos + 2 > var_name.size() )
|
||||
return string("");
|
||||
|
||||
return var_name.substr(pos+2);
|
||||
return var_name.substr(pos + 2);
|
||||
}
|
||||
|
||||
string normalized_module_name(const char* module_name)
|
||||
{
|
||||
int mod_len;
|
||||
if ( (mod_len = strlen(module_name)) >= 2 &&
|
||||
streq(module_name + mod_len - 2, "::") )
|
||||
if ( (mod_len = strlen(module_name)) >= 2 && streq(module_name + mod_len - 2, "::") )
|
||||
mod_len -= 2;
|
||||
|
||||
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)
|
||||
{
|
||||
if ( ! module_name || streq(module_name, GLOBAL_MODULE_NAME) ||
|
||||
strstr(var_name, "::") )
|
||||
if ( ! module_name || streq(module_name, GLOBAL_MODULE_NAME) || strstr(var_name, "::") )
|
||||
{
|
||||
if ( streq(GLOBAL_MODULE_NAME, extract_module_name(var_name).c_str()) )
|
||||
return extract_var_name(var_name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue