On Wed, Nov 18, 2020 at 4:38 AM <[email protected]> wrote:
> > I think that generating the python code makes the most sense. The body
> of the code can still defer to the dynamically generated object, since it's
> not available until runtime anyway, but the user no longer has to resort to
> using lambdas because of the deferred bindings.
>
> Could you ellaborate for why you need to use lambdas?
>
Today, in the tests, all references to vpp_papi.<foo> have to happen after
connect, otherwise they don't exist. Let's say I want to set up a test and
use an enum from vpp_papi, it may not exist due to the deferred binding.
Instead, you have to wrap it in a lamba so that it is evaluated at use time
instead of at module load time. You could also make it a @property and
force it evaluated at run time.
> [SNIP]
> >
> > but the typedefs could become data classes and the encode/decode methods
> in the test code become unnecessary.
>
> What are you thinking about regarding the encode/decode in tests?
> E.g. for the IP address ones, they can just be deleted. Without any
> changes to PAPI...
>
> As an example:
class VppGbpContractNextHop():
def __init__(self, mac, bd, ip, rd):
self.mac = mac
self.ip = ip
self.bd = bd
self.rd = rd
def encode(self):
return {'ip': self.ip,
'mac': self.mac.packed,
'bd_id': self.bd.bd.bd_id,
'rd_id': self.rd.rd_id}
> > vl_api_ip_ecn_t.IP_API_ECN_NONE could become ip_ecn.NONE
> >
> > The IDE's could then provide type checking and auto completion. (So one
> would know that NONE was an option without referring to the sources.)
> >
> > We would need to play around with it to see how well it works.
>
> That seems like a good idea.
> Let me give you a quick Python plugin for vppapigen that does this.
>
> The packaging is going to be a challenge I guess.
>
> The packaging could be as simple as we write the files to a folder in
vpp_papi, or we could have its own setup.py and make it a plugin to
vpp_papi.
> Best regards,
> Ole
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#18083): https://lists.fd.io/g/vpp-dev/message/18083
Mute This Topic: https://lists.fd.io/mt/78229638/21656
Group Owner: [email protected]
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-