[PATCH v6 36/42] codegen: Allows to specify wireshark name for enumerators

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 python_modules/dissector.py    | 2 +-
 python_modules/ptypes.py       | 4 ++++
 python_modules/spice_parser.py | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/python_modules/dissector.py b/python_modules/dissector.py
index 6b8ee03..1dddfc4 100644
--- a/python_modules/dissector.py
+++ b/python_modules/dissector.py
@@ -738,7 +738,7 @@ def write_flags_func(writer, t, ws, tree, ti):
 
         desc = t.descs[v] if t.descs[v] else t.names[v]
         hf = HF(name, desc)
-        hf.ws_name = '%s_%s' % (t.name, t.names[v].lower())
+        hf.ws_name = '%s_%s' % (t.name, t.names[v].lower()) if not t.ws_names[v] else t.ws_names[v]
         hf.f_type = 'FT_BOOLEAN'
         hf.base = str(bits)
         hf.vals = 'TFS(&tfs_set_notset)'
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index f1796b5..90a925f 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -328,9 +328,11 @@ class EnumBaseType(Type):
         names = {}
         values = {}
         descs = {}
+        ws_names = {}
         for v in enums:
             name = v[0]
             desc = v[1][1]
+            ws_name = None if len(v[1]) < 3 else v[1][2]
             if len(v) > 2:
                 value = v[2]
             else:
@@ -340,11 +342,13 @@ class EnumBaseType(Type):
             assert value not in names
             names[value] = name
             descs[value] = desc
+            ws_names[value] = ws_name
             values[name] = value
 
         self.names = names
         self.values = values
         self.descs = descs
+        self.ws_names = ws_names
 
         self.attributes = fix_attributes(attribute_list)
 
diff --git a/python_modules/spice_parser.py b/python_modules/spice_parser.py
index 5326e59..3fde843 100644
--- a/python_modules/spice_parser.py
+++ b/python_modules/spice_parser.py
@@ -124,7 +124,7 @@ def SPICE_BNF():
                      int32_ ^ uint32_ ^ int64_ ^ uint64_ ^
                      typename).setName("type")
 
-        flagsBody = enumBody = Group(lbrace + delimitedList(Group (enumname + Optional(Group(ws_desc), default=[None,None]) + Optional(equals + integer))) + Optional(comma) + rbrace)
+        flagsBody = enumBody = Group(lbrace + delimitedList(Group (enumname + Optional(Group(ws | ws_desc), default=[None,None]) + Optional(equals + integer))) + Optional(comma) + rbrace)
 
         messageSpec = Group(message_ + messageBody + attributes).setParseAction(lambda toks: ptypes.MessageType(None, toks[0][1], toks[0][2])) | typename
 
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]