aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2019-08-01 10:31:49 +0200
committerVratko Polak <vrpolak@cisco.com>2019-08-01 10:31:49 +0200
commit7520e17bfa7d5ad69fe3559506ce9b71a66852ae (patch)
tree104e5e2cb576943ad71388a4741e44446359a862 /src/tools
parent3efcd0d7c3e73b812dece730396cf8816951d8ad (diff)
vppapigen: revert "implement reversible repr's"
The previous change seems to affect all CRCs. Type: fix Fixes: b504777e7f1c9728e65b874284b4dfd39359c8a8. Change-Id: I65e27ce22020e5ebc764b5a51b5fc84992ddb40a Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'src/tools')
-rwxr-xr-xsrc/tools/vppapigen/vppapigen.py49
1 files changed, 15 insertions, 34 deletions
diff --git a/src/tools/vppapigen/vppapigen.py b/src/tools/vppapigen/vppapigen.py
index 94696aec68d..8ae991c9c95 100755
--- a/src/tools/vppapigen/vppapigen.py
+++ b/src/tools/vppapigen/vppapigen.py
@@ -134,10 +134,6 @@ class Service():
self.stream = stream
self.events = [] if events is None else events
- def __repr__(self):
- return "Service(caller={!r}, reply={!r}, events={!r}, stream={!r})".\
- format(self.caller, self.reply, self.events, self.stream)
-
class Typedef():
def __init__(self, name, flags, block):
@@ -155,28 +151,24 @@ class Typedef():
global_type_add(name, self)
def __repr__(self):
- return "Typedef(name={!r}, flags={!r}, block={!r})".format(
- self.name, self.flags, self.block)
+ return self.name + str(self.flags) + str(self.block)
class Using():
def __init__(self, name, alias):
self.name = name
- # save constructor values for repr()
- self._alias = alias
-
if isinstance(alias, Array):
- a = {'type': alias.fieldtype,
- 'length': alias.length}
+ a = { 'type': alias.fieldtype, # noqa: E201
+ 'length': alias.length } # noqa: E202
else:
- a = {'type': alias.fieldtype}
+ a = { 'type': alias.fieldtype } # noqa: E201,E202
self.alias = a
self.crc = str(alias).encode()
global_type_add(name, self)
def __repr__(self):
- return "Using(name={!r}, alias={!r})".format(self.name, self._alias)
+ return self.name + str(self.alias)
class Union():
@@ -190,7 +182,7 @@ class Union():
global_type_add(name, self)
def __repr__(self):
- return "Union(name={!r}, block={!r})".format(self.name, self.block)
+ return str(self.block)
class Define():
@@ -221,8 +213,7 @@ class Define():
block.remove(b)
def __repr__(self):
- return "Define(name={!r}, flags={!r}, block={!r})".format(
- self.name, self.flags, self.block)
+ return self.name + str(self.flags) + str(self.block)
class Enum():
@@ -243,8 +234,7 @@ class Enum():
global_type_add(name, self)
def __repr__(self):
- return "Enum(name={!r}, block={!r}, enumtype={!r})".format(
- self.name, self.block, self.enumtype)
+ return self.name + str(self.block)
class Import():
@@ -267,7 +257,7 @@ class Import():
self.result = parser.parse_file(fd, None)
def __repr__(self):
- return "Import(filename={!r})".format(self.filename)
+ return self.filename
class Option():
@@ -276,7 +266,7 @@ class Option():
self.crc = str(option).encode()
def __repr__(self):
- return "Option({!r})".format(self.option)
+ return str(self.option)
def __getitem__(self, index):
return self.option[index]
@@ -286,11 +276,6 @@ class Array():
def __init__(self, fieldtype, name, length):
self.type = 'Array'
self.fieldtype = fieldtype
-
- # save constructor values for repr()
- self._name = name
- self._length = length
-
self.fieldname = name
if type(length) is str:
self.lengthfield = length
@@ -300,8 +285,8 @@ class Array():
self.lengthfield = None
def __repr__(self):
- return "Array(fieldtype={!r}, name={!r}, length={!r})".format(
- self.fieldtype, self._name, self._length)
+ return str([self.fieldtype, self.fieldname, self.length,
+ self.lengthfield])
class Field():
@@ -312,8 +297,7 @@ class Field():
self.limit = limit
def __repr__(self):
- return "Field(fieldtype={!r}, name={!r}, limit={!r})".format(
- self.fieldtype, self.fieldname, self.limit)
+ return str([self.fieldtype, self.fieldname])
class Coord(object):
@@ -533,13 +517,13 @@ class VPPAPIParser(object):
if len(p) == 2:
p[0] = p[1]
else:
- p[0] = {**p[1], **p[2]}
+ p[0] = { **p[1], **p[2] }
def p_field_option(self, p):
'''field_option : ID '=' assignee ','
| ID '=' assignee
'''
- p[0] = {p[1]: p[3]}
+ p[0] = { p[1]: p[3] }
def p_declaration(self, p):
'''declaration : type_specifier ID ';'
@@ -782,7 +766,6 @@ def dirlist_add(dirs):
def dirlist_get():
return dirlist
-
def foldup_blocks(block, crc):
for b in block:
# Look up CRC in user defined types
@@ -796,13 +779,11 @@ def foldup_blocks(block, crc):
pass
return crc
-
def foldup_crcs(s):
for f in s:
f.crc = foldup_blocks(f.block,
binascii.crc32(f.crc))
-
#
# Main
#
\ (__clang_major__ == (major) && __clang_minor__ >= (minor))) #else /* disable all warning customization for all other compilers */ #define COMPILER_VERSION_GTE(maj, min) 0 #endif /* '#' needs to preceed a macro parameter */ #define WARN_TOSTR(x) #x /* * Macros to toggle off/on warnings * * Start by silencing pragma warnings so that we can explicitly silence * a warning introduced on some compiler version and not get a warning on older * versions of that same compiler. * * gcc corresponding warning is "Wpargma" * clang corresponding warning is "Wunknown-warning-option" * * For example, Wtautological-compare is introduced in gcc-6 and this would * trigger a Wpargma warning on gcc-5. * * Example usage to disable -Wtautological-compare warning: * WARN_OFF(tautological-compare) * if (...) { * WARN_ON(tautological-compare) * ; // conditional code * } */ #if defined(__GNUC__) && COMPILER_VERSION_GTE(4, 6) /* * GCC option to locally ignore warning was introduced in gcc-4.6 * gcc.gnu.org/gcc-4.6/changes.html */ #define WARN_PRAGMA(x) _Pragma (WARN_TOSTR (GCC diagnostic x)) #define WARN_OFF(x) \ WARN_PRAGMA (push) WARN_PRAGMA (ignored "-Wpragmas") \ WARN_PRAGMA (push) WARN_PRAGMA (ignored WARN_TOSTR (-W##x)) #define WARN_ON(x) \ WARN_PRAGMA (pop) \ WARN_PRAGMA (pop) #elif defined(__clang__) && COMPILER_VERSION_GTE(3, 3) /* * clang option to locally ignore warning was introduced in clang-3.3 * releases.llvm.org/3.3/tools/clang/docs/UsersManual.html#controlling-diagnostics-via-pragmas */ #define WARN_PRAGMA(x) _Pragma (WARN_TOSTR (clang diagnostic x)) #define WARN_OFF(x) \ WARN_PRAGMA (push) WARN_PRAGMA (ignored "-Wunknown-warning-option") \ WARN_PRAGMA (push) WARN_PRAGMA (ignored WARN_TOSTR (-W##x)) #define WARN_ON(x) \ WARN_PRAGMA (pop) \ WARN_PRAGMA (pop) #else /* Ignore WARN_* instruction for all other compilers */ #define WARN_OFF(x) #define WARN_ON(x) #endif /* * Clang supports a wider range of warnings than gcc. * Use those specific macros for the warnings that are only supported by clang */ #ifdef __clang__ #define WARN_OFF_CLANG(x) WARN_OFF (x) #define WARN_ON_CLANG(x) WARN_ON (x) #else #define WARN_OFF_CLANG(x) #define WARN_ON_CLANG(x) #endif /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */ #endif /* __included_warnings_h__ */