Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
papi: add support for enumflag part 1 of 2
[vpp.git]
/
src
/
vpp-api
/
python
/
vpp_papi
/
vpp_papi.py
diff --git
a/src/vpp-api/python/vpp_papi/vpp_papi.py
b/src/vpp-api/python/vpp_papi/vpp_papi.py
index
e22b88b
..
b4d4686
100644
(file)
--- 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
import atexit
import time
from . vpp_format import verify_enum_hint
-from . vpp_serializer import VPPType, VPPEnumType, VPPUnionType
+from . vpp_serializer import VPPType, VPPEnumType, VPP
EnumFlagType, VPP
UnionType
from . vpp_serializer import VPPMessage, vpp_get_type, VPPTypeAlias
try:
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',
logger.addHandler(logging.NullHandler())
__all__ = ('FuncWrapper', 'VPP', 'VppApiDynamicMethodHolder',
- 'VppEnum', 'VppEnumType',
+ 'VppEnum', 'VppEnumType',
'VppEnumFlag',
'VPPIOError', 'VPPRuntimeError', 'VPPValueError',
'VPPApiClient', )
'VPPIOError', 'VPPRuntimeError', 'VPPValueError',
'VPPApiClient', )
@@
-72,6
+72,11
@@
class VppEnum:
pass
pass
+@metaclass(VppEnumType)
+class VppEnumFlag:
+ pass
+
+
def vpp_atexit(vpp_weakref):
"""Clean up VPP connection on shutdown."""
vpp_instance = vpp_weakref()
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()
vpp_instance.disconnect()
-
-
def add_convenience_methods():
# provide convenience methods to IP[46]Address.vapi_af
def _vapi_af(self):
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
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'
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
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:])
elif v['type'] == 'union':
try:
VPPUnionType(t[0], t[1:])