aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2017-03-15 09:30:37 +0100
committerStig Bjørlykke <stig@bjorlykke.org>2017-03-15 17:32:30 +0000
commit0156f22c62c1d955724ae44ca607c95e2944aa26 (patch)
tree1e0daf66f537b59f2e320b28459bd1371188d56c /epan/wslua
parentb8ede14d44b4fb165787a000bc3f6962f285d23b (diff)
Lua: Merge sep and str tables into base
Also add documentation strings to the base values. Change-Id: I00ac8f154fdd0382106ed27d740e16956520be97 Reviewed-on: https://code.wireshark.org/review/20554 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'epan/wslua')
-rwxr-xr-xepan/wslua/make-init-lua.pl28
-rw-r--r--epan/wslua/template-init.lua6
-rw-r--r--epan/wslua/wslua_proto_field.c33
3 files changed, 22 insertions, 45 deletions
diff --git a/epan/wslua/make-init-lua.pl b/epan/wslua/make-init-lua.pl
index 27ea5806e6..45035e1f5c 100755
--- a/epan/wslua/make-init-lua.pl
+++ b/epan/wslua/make-init-lua.pl
@@ -39,8 +39,6 @@ my $frametypes_table = '';
my $wtap_rec_types_table = '';
my $wtap_presence_flags_table = '';
my $bases_table = '';
-my $str_type_table = '';
-my $byte_sep_table = '';
my $encodings = '';
my $expert_pi = '';
my $expert_pi_tbl = '';
@@ -58,8 +56,6 @@ my %replacements = %{{
WTAP_REC_TYPES => \$wtap_rec_types_table,
WTAP_PRESENCE_FLAGS => \$wtap_presence_flags_table,
BASES => \$bases_table,
- STRING_TYPES => \$str_type_table,
- BYTE_SEPARATORS => \$byte_sep_table,
ENCODINGS => \$encodings,
EXPERT => \$expert_pi,
EXPERT_TABLE => \$expert_pi_tbl,
@@ -169,8 +165,6 @@ $frametypes_table =~ s/,\n$/\n}\n/msi;
#
$bases_table = "-- Display Bases\nbase = {\n";
-$str_type_table = "-- String Types\nstr = {\n";
-$byte_sep_table = "-- Byte Separators\nsep = {\n";
$encodings = "-- Encodings\n";
$expert_pi = "-- Expert flags and facilities (deprecated - see 'expert' table below)\n";
$expert_pi_tbl = "-- Expert flags and facilities\nexpert = {\n";
@@ -186,22 +180,14 @@ my $skip_this = 0;
while(<PROTO_H>) {
$skip_this = 0;
- if (/^\s+BASE_([A-Z_]+)[ ]*=[ ]*([0-9]+)[, ]+/ ) {
- $bases_table .= "\t[\"$1\"] = $2,\n";
+ if (/^\s+(?:BASE|STR|SEP)_([A-Z_]+)[ ]*=[ ]*([0-9]+)[,\s]+(?:\/\*\*< (.*?) \*\/)?/) {
+ $bases_table .= "\t[\"$1\"] = $2, -- $3\n";
}
- if (/^#define\s+BASE_(UNIT_STRING)[ ]*((0x)?[0-9]+) / ) {
+ if (/^#define\s+BASE_(UNIT_STRING)[ ]*((?:0x)?[0-9]+)[ ]+(?:\/\*\*< (.*?) \*\/)?/) {
# Handle BASE_UNIT_STRING as a valid base value in Lua
my $num = hex($2);
- $bases_table .= "\t[\"$1\"] = $num,\n";
- }
-
- if (/^\s+STR_([A-Z_]+)[ ]*=[ ]*([0-9]+),/ ) {
- $str_type_table .= "\t[\"$1\"] = $2,\n";
- }
-
- if (/^\s+SEP_([A-Z_]+)[ ]*=[ ]*([0-9]+),/ ) {
- $byte_sep_table .= "\t[\"$1\"] = $2,\n";
+ $bases_table .= "\t[\"$1\"] = $num, -- $3\n";
}
if (/^.define\s+PI_SEVERITY_MASK /) {
@@ -264,10 +250,8 @@ while(<STAT_GROUPS>) {
close STAT_GROUPS;
-$bases_table .= "}\n\n";
-$str_type_table .= "}\n\n";
-$byte_sep_table .= "}\n\n";
-$encodings .= "\n\n";
+$bases_table .= "}\n";
+$encodings .= "\n";
$expert_pi .= "\n";
$expert_pi_severity .= "\t},\n";
$expert_pi_group .= "\t},\n";
diff --git a/epan/wslua/template-init.lua b/epan/wslua/template-init.lua
index cf87acb32f..9f853b4c3a 100644
--- a/epan/wslua/template-init.lua
+++ b/epan/wslua/template-init.lua
@@ -130,12 +130,6 @@ end
%BASES%
--- the following table is since 2.4
-%STRING_TYPES%
-
--- the following table is since 2.4
-%BYTE_SEPARATORS%
-
%ENCODINGS%
%EXPERT%
diff --git a/epan/wslua/wslua_proto_field.c b/epan/wslua/wslua_proto_field.c
index cba174d9d6..44e0d354cc 100644
--- a/epan/wslua/wslua_proto_field.c
+++ b/epan/wslua/wslua_proto_field.c
@@ -107,14 +107,13 @@ static const struct field_display_string_t base_displays[] = {
{"base.HEX_DEC", BASE_HEX_DEC},
{"base.UNIT_STRING", BASE_UNIT_STRING},
/* String types */
- {"str.ASCII", STR_ASCII},
- {"str.UNICODE", STR_UNICODE},
+ {"base.ASCII", STR_ASCII},
+ {"base.UNICODE", STR_UNICODE},
/* Byte separators */
- {"sep.NONE", SEP_NONE},
- {"sep.DOT", SEP_DOT},
- {"sep.DASH", SEP_DASH},
- {"sep.COLON", SEP_COLON},
- {"sep.SPACE", SEP_SPACE},
+ {"base.DOT", SEP_DOT},
+ {"base.DASH", SEP_DASH},
+ {"base.COLON", SEP_COLON},
+ {"base.SPACE", SEP_SPACE},
/* for FT_BOOLEAN, how wide the parent bitfield is */
{"8",8},
{"16",16},
@@ -546,7 +545,7 @@ WSLUA_CONSTRUCTOR ProtoField_new(lua_State* L) {
case FT_STRING:
case FT_STRINGZ:
if (base != STR_ASCII && base != STR_UNICODE) {
- WSLUA_OPTARG_ERROR(ProtoField_new,BASE,"Display must be either str.ASCII or str.UNICODE");
+ WSLUA_OPTARG_ERROR(ProtoField_new,BASE,"Display must be either base.ASCII or base.UNICODE");
return 0;
}
if (mask) {
@@ -556,8 +555,8 @@ WSLUA_CONSTRUCTOR ProtoField_new(lua_State* L) {
break;
case FT_BYTES:
case FT_UINT_BYTES:
- if (base != SEP_NONE && (base < SEP_DOT || base > SEP_SPACE)) {
- WSLUA_OPTARG_ERROR(ProtoField_new,BASE,"Display must be either sep.NONE, sep.DOT, sep.DASH, sep.COLON or sep.SPACE");
+ if (base != BASE_NONE && (base < SEP_DOT || base > SEP_SPACE)) {
+ WSLUA_OPTARG_ERROR(ProtoField_new,BASE,"Display must be either base.NONE, base.DOT, base.DASH, base.COLON or base.SPACE");
return 0;
}
if (mask) {
@@ -1068,12 +1067,12 @@ static int ProtoField_other_display(lua_State* L,enum ftenum type) {
base = (unsigned)luaL_optinteger(L,3,BASE_NONE);
if (type == FT_STRING || type == FT_STRINGZ) {
if (base != STR_ASCII && base != STR_UNICODE) {
- luaL_argerror(L, 3, "Display must be either str.ASCII or str.UNICODE");
+ luaL_argerror(L, 3, "Display must be either base.ASCII or base.UNICODE");
return 0;
}
} else if (type == FT_BYTES || type == FT_UINT_BYTES) {
- if (base != SEP_NONE && (base < SEP_DOT || base > SEP_SPACE)) {
- luaL_argerror(L, 3, "Display must be either sep.NONE, sep.DOT, sep.DASH, sep.COLON or sep.SPACE");
+ if (base != BASE_NONE && (base < SEP_DOT || base > SEP_SPACE)) {
+ luaL_argerror(L, 3, "Display must be either base.NONE, base.DOT, base.DASH, base.COLON or base.SPACE");
return 0;
}
}
@@ -1108,28 +1107,28 @@ static int ProtoField_other_display(lua_State* L,enum ftenum type) {
/* _WSLUA_CONSTRUCTOR_ ProtoField_string Creates a `ProtoField` of a string value. */
/* WSLUA_ARG_Protofield_string_ABBR Abbreviated name of the field (the string used in filters). */
/* WSLUA_OPTARG_Protofield_string_NAME Actual name of the field (the string that appears in the tree). */
-/* WSLUA_OPTARG_Protofield_string_DISPLAY One of `str.ASCII` or `str.UNICODE`. */
+/* WSLUA_OPTARG_Protofield_string_DISPLAY One of `base.ASCII` or `base.UNICODE`. */
/* WSLUA_OPTARG_Protofield_string_DESC Description of the field. */
/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
/* _WSLUA_CONSTRUCTOR_ ProtoField_stringz Creates a `ProtoField` of a zero-terminated string value. */
/* WSLUA_ARG_Protofield_stringz_ABBR Abbreviated name of the field (the string used in filters). */
/* WSLUA_OPTARG_Protofield_stringz_NAME Actual name of the field (the string that appears in the tree). */
-/* WSLUA_OPTARG_Protofield_stringz_DISPLAY One of `str.ASCII` or `str.UNICODE`. */
+/* WSLUA_OPTARG_Protofield_stringz_DISPLAY One of `base.ASCII` or `base.UNICODE`. */
/* WSLUA_OPTARG_Protofield_stringz_DESC Description of the field. */
/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
/* _WSLUA_CONSTRUCTOR_ ProtoField_bytes Creates a `ProtoField` for an arbitrary number of bytes. */
/* WSLUA_ARG_Protofield_bytes_ABBR Abbreviated name of the field (the string used in filters). */
/* WSLUA_OPTARG_Protofield_bytes_NAME Actual name of the field (the string that appears in the tree). */
-/* WSLUA_OPTARG_Protofield_bytes_DISPLAY One of `sep.NONE`, `sep.DOT`, `sep.DASH`, `sep.COLON` or `sep.SPACE`. */
+/* WSLUA_OPTARG_Protofield_bytes_DISPLAY One of `base.NONE`, `base.DOT`, `base.DASH`, `base.COLON` or `base.SPACE`. */
/* WSLUA_OPTARG_Protofield_bytes_DESC Description of the field. */
/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */
/* _WSLUA_CONSTRUCTOR_ ProtoField_ubytes Creates a `ProtoField` for an arbitrary number of unsigned bytes. */
/* WSLUA_ARG_Protofield_ubytes_ABBR Abbreviated name of the field (the string used in filters). */
/* WSLUA_OPTARG_Protofield_ubytes_NAME Actual name of the field (the string that appears in the tree). */
-/* WSLUA_OPTARG_Protofield_ubytes_DISPLAY One of `sep.NONE`, `sep.DOT`, `sep.DASH`, `sep.COLON` or `sep.SPACE`. */
+/* WSLUA_OPTARG_Protofield_ubytes_DISPLAY One of `base.NONE`, `base.DOT`, `base.DASH`, `base.COLON` or `base.SPACE`. */
/* WSLUA_OPTARG_Protofield_ubytes_DESC Description of the field. */
/* _WSLUA_RETURNS_ A `ProtoField` object to be added to a table set to the `Proto.fields` attribute. */