[Ovmsdev] Duktape Persistent Function References
casner at acm.org
Sat Sep 12 05:31:31 HKT 2020
Like Mark, I did not think the change would be simple. I've used
functional objects before, but was not aware of std::function. I am
still not quite sure how a vanilla function pointer matches this
type; I need to think about that more carefully.
Having the typedefs is a good idea even if we weren't using
On Fri, 11 Sep 2020, Michael Balzer wrote:
> Am 11.09.20 um 18:11 schrieb Michael Balzer:
> >> I agree it is not necessary; my suggestion is purely to clean it up
> >> and enhance functionality. The problem at the moment is that
> >> OvmsCommand execute callbacks can only be to function callbacks (not
> >> objects). It doesn't even use the c++ bind function callback
> >> mechanism (like notification, etc, for example). It is what it is,
> >> and changing now is very hard.
> > That slipped my attention, but upgrading OvmsCommand to accept any
> > function type should be simply changing m_execute and m_validate to
> > std::function, or do I miss something?
> Just did this locally, works perfectly. Shall I push the change or have
> you begun working on ovms_command?
> If so, it's really just exchanging the function signatures for these types:
> typedef std::function<void(int, OvmsWriter*, OvmsCommand*, int, const
> char* const*)> OvmsCommandExecuteCallback_t;
> typedef std::function<int(OvmsWriter*, OvmsCommand*, int, const char*
> const*, bool)> OvmsCommandValidateCallback_t;
> Patch attached.
> Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
> Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
More information about the OvmsDev