summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/python/vpp_papi/vpp_papi.py
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2020-12-03 21:06:28 -0500
committerOle Tr�an <otroan@employees.org>2020-12-04 12:14:34 +0000
commit3825d93afeed42e62e41f743df69058511c51079 (patch)
tree5affb734a1f5750c085c74df20ee07c61a87a676 /src/vpp-api/python/vpp_papi/vpp_papi.py
parenta51f9b3747d3e065b4bc7bb46aea8df11719b6cd (diff)
papi: add support for enumflag part 1 of 2
Allow for papi to accept the new enumflag type. Change-Id: I8d8dc8fdb122e9a1b1881f5b2558635c75e4a299 Type: feature Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com> (cherry picked from commit 299abebe2942b4c78b85f9f3b8843f8213bf1efe)
Diffstat (limited to 'src/vpp-api/python/vpp_papi/vpp_papi.py')
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_papi.py24
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:])