summaryrefslogtreecommitdiffstats
path: root/vpp-api
diff options
context:
space:
mode:
authorChristophe Fontaine <christophe.fontaine@qosmos.com>2016-12-09 15:53:47 +0100
committerOle Trøan <otroan@employees.org>2016-12-13 16:24:21 +0000
commit04f4b78ce25a38ca3feef7d454ad20705b379941 (patch)
treefffea859cf6b0b1ea46ccea192b0616f1fbb9ec1 /vpp-api
parentcdab4bde04eab3250b8b4f8b42fcf1dc9a4d2af3 (diff)
vpp_papi: Add help() support for python interactive mode
The python api 1.3 removed the ability to call 'help' in interactive mode. example: > help(vpp.sw_interface_span_enable_disable) Help on function sw_interface_span_enable_disable in module vpp_papi.vpp_papi: sw_interface_span_enable_disable(**kwargs) u16 _vl_msg_id, u32 client_index, u32 context, u32 sw_if_index_from, u32 sw_if_index_to, u8 state Change-Id: Iea1944fdc862482490174ff966592cf3c8208a98 Signed-off-by: Christophe Fontaine <christophe.fontaine@qosmos.com>
Diffstat (limited to 'vpp-api')
-rw-r--r--vpp-api/python/vpp_papi/vpp_papi.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/vpp-api/python/vpp_papi/vpp_papi.py b/vpp-api/python/vpp_papi/vpp_papi.py
index 312aa335572..8e7b7f66ff5 100644
--- a/vpp-api/python/vpp_papi/vpp_papi.py
+++ b/vpp-api/python/vpp_papi/vpp_papi.py
@@ -223,29 +223,38 @@ class VPP():
raise ValueError('Duplicate message name: ' + name)
args = collections.OrderedDict()
+ argtypes = collections.OrderedDict()
fields = []
msg = {}
for f in msgdef:
if type(f) is dict and 'crc' in f:
msg['crc'] = f['crc']
continue
+ field_type = f[0]
field_name = f[1]
args[field_name] = self.__struct(*f)
+ argtypes[field_name] = field_type
fields.append(field_name)
msg['return_tuple'] = collections.namedtuple(name, fields,
rename = True)
self.messages[name] = msg
self.messages[name]['args'] = args
+ self.messages[name]['argtypes'] = argtypes
return self.messages[name]
def add_type(self, name, typedef):
self.add_message('vl_api_' + name + '_t', typedef)
- def make_function(self, i, msgdef, multipart, async):
+ def make_function(self, name, i, msgdef, multipart, async):
if (async):
- return lambda **kwargs: (self._call_vpp_async(i, msgdef, multipart, **kwargs))
+ f = lambda **kwargs: (self._call_vpp_async(i, msgdef, multipart, **kwargs))
else:
- return lambda **kwargs: (self._call_vpp(i, msgdef, multipart, **kwargs))
+ f = lambda **kwargs: (self._call_vpp(i, msgdef, multipart, **kwargs))
+ args = self.messages[name]['args']
+ argtypes = self.messages[name]['argtypes']
+ f.__name__ = str(name)
+ f.__doc__ = ", ".join(["%s %s" % (argtypes[k], k) for k in args.keys()])
+ return f
def _register_functions(self, async=False):
self.id_names = [None] * (self.vpp_dictionary_maxid + 1)
@@ -260,7 +269,7 @@ class VPP():
self.id_msgdef[i] = msgdef
self.id_names[i] = name
multipart = True if name.find('_dump') > 0 else False
- setattr(self, name, self.make_function(i, msgdef, multipart, async))
+ setattr(self, name, self.make_function(name, i, msgdef, multipart, async))
def _write (self, buf):
if not self.connected:
ighlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
# Copyright (c) 2017 Cisco Systems, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

vppplugins_LTLIBRARIES += memif_plugin.la
vppapitestplugins_LTLIBRARIES += memif_test_plugin.la

memif_plugin_la_LIBADD =
memif_plugin_la_SOURCES = memif/memif.c   \
	memif/memif_api.c                 \
	memif/cli.c                       \
	memif/node.c                      \
	memif/device.c                    \
	memif/socket.c                    \
	memif/memif_plugin.api.h

memif_test_plugin_la_SOURCES = \
  memif/memif_test.c memif/memif_plugin.api.h

noinst_HEADERS += memif/memif.h

nobase_apiinclude_HEADERS +=              \
		  memif/memif_all_api_h.h \
		  memif/memif_msg_enum.h  \
		  memif/memif.api.h

API_FILES += memif/memif.api

if CPU_X86_64
memif_multiversioning_sources = 					\
	memif/node.c						\
	memif/device.c

if CC_SUPPORTS_AVX2
###############################################################
# AVX2
###############################################################
memif_plugin_avx2_la_SOURCES = $(memif_multiversioning_sources)
memif_plugin_avx2_la_CFLAGS =					\
	$(AM_CFLAGS)  @CPU_AVX2_FLAGS@				\
	-DCLIB_MARCH_VARIANT=avx2
noinst_LTLIBRARIES += memif_plugin_avx2.la
memif_plugin_la_LIBADD += memif_plugin_avx2.la
endif

if CC_SUPPORTS_AVX512
###############################################################
# AVX512
###############################################################
memif_plugin_avx512_la_SOURCES = $(memif_multiversioning_sources)
memif_plugin_avx512_la_CFLAGS =					\
	$(AM_CFLAGS) @CPU_AVX512_FLAGS@				\
	-DCLIB_MARCH_VARIANT=avx512
noinst_LTLIBRARIES += memif_plugin_avx512.la
memif_plugin_la_LIBADD += memif_plugin_avx512.la
endif
endif

# vi:syntax=automake