On Thu, Mar 19, 2020 at 07:09:32AM -0500, Eric Blake wrote:
Thinking about this more, maybe the real problem is that all
language bindings that have to wrap scripts (OCaml and Rust are
exceptions as they directly call into the C code; but lua, perl,
python, ruby, tcl, and sh all fit into the category I'm describing)
MUST define .can_FOO at the C level because they don't know a priori
whether the script they will be loading will also provide a .can_FOO
callback, so we have a lot of duplicated code in each language
binding.
Life might be easier if we change the C contract for the .can_FOO
callbacks to support the special return value of -2 to behave the
same as if .can_FOO were missing. In a way, it would make it easier
for the remaining languages to behave more like sh's special MISSING
return value (sh is an oddball because we can't even probe whether
.FOO is missing so .can_FOO is mandatory in the script; but in eval,
python, etc, it's easy to implement a C binding for .can_FOO that
introspects the script). I'll spin up a v2 patch along those lines,
so we can compare the difference.
What problem are we actually trying to solve here? If it calls the
can_* functions in the plugin more than once it's not a big deal.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top