diff options
Diffstat (limited to 'src/vpp-api/python/vpp_papi/vpp_papi.py')
-rw-r--r-- | src/vpp-api/python/vpp_papi/vpp_papi.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_papi.py b/src/vpp-api/python/vpp_papi/vpp_papi.py index e22b88bc3f6..b4d46861832 100644 --- a/src/vpp-api/python/vpp_papi/vpp_papi.py +++ b/src/vpp-api/python/vpp_papi/vpp_papi.py @@ -31,7 +31,7 @@ import weakref import atexit import time from . vpp_format import verify_enum_hint -from . vpp_serializer import VPPType, VPPEnumType, VPPUnionType +from . vpp_serializer import VPPType, VPPEnumType, VPPEnumFlagType, VPPUnionType from . vpp_serializer import VPPMessage, vpp_get_type, VPPTypeAlias try: @@ -48,7 +48,7 @@ logger = logging.getLogger('vpp_papi') logger.addHandler(logging.NullHandler()) __all__ = ('FuncWrapper', 'VPP', 'VppApiDynamicMethodHolder', - 'VppEnum', 'VppEnumType', + 'VppEnum', 'VppEnumType', 'VppEnumFlag', 'VPPIOError', 'VPPRuntimeError', 'VPPValueError', 'VPPApiClient', ) @@ -72,6 +72,11 @@ class VppEnum: pass +@metaclass(VppEnumType) +class VppEnumFlag: + pass + + def vpp_atexit(vpp_weakref): """Clean up VPP connection on shutdown.""" vpp_instance = vpp_weakref() @@ -80,8 +85,6 @@ def vpp_atexit(vpp_weakref): vpp_instance.disconnect() - - def add_convenience_methods(): # provide convenience methods to IP[46]Address.vapi_af def _vapi_af(self): @@ -281,7 +284,12 @@ class VPPApiJSONFiles: types[t[0]] = {'type': 'enum', 'data': t} except KeyError: pass - + try: + for t in api['enumflags']: + t[0] = 'vl_api_' + t[0] + '_t' + types[t[0]] = {'type': 'enum', 'data': t} + except KeyError: + pass try: for t in api['unions']: t[0] = 'vl_api_' + t[0] + '_t' @@ -318,6 +326,12 @@ class VPPApiJSONFiles: VPPEnumType(t[0], t[1:]) except ValueError: unresolved[k] = v + if not vpp_get_type(k): + if v['type'] == 'enumflag': + try: + VPPEnumFlagType(t[0], t[1:]) + except ValueError: + unresolved[k] = v elif v['type'] == 'union': try: VPPUnionType(t[0], t[1:]) |