[Ovmsdev] Duktape Persistent Function References
mark at webb-johnson.net
Fri Sep 25 14:07:09 HKT 2020
I’ve tried merging this (along with all the other recent changes in master) into the for-v3.3 branch, but am now getting compilation errors. The two files with issues are:
Both in the RegisterCommand function call with the static class member function as a parameter. Not sure if that new way is used elsewhere?
Example compiler output is:
.../components/retools_testerpresent/src/retools_testerpresent.cpp: In constructor 'OvmsReToolsTesterPresentInit::OvmsReToolsTesterPresentInit()':
.../components/retools_testerpresent/src/retools_testerpresent.cpp:140:5: error: no matching function for call to 'OvmsCommand::RegisterCommand(const char , const char , <unresolved overloaded function type>, const char , int, int)'
.../components/vehicle_mgev/src/vehicle_mgev.cpp: In constructor 'OvmsVehicleMgEv::OvmsVehicleMgEv()':
.../components/vehicle_mgev/src/vehicle_mgev.cpp:143:5: error: no matching function for call to 'OvmsCommandApp::RegisterCommand(const char , const char , <unresolved overloaded function type>)'
^mand(const char* name, const char* title,
I tried for a while, but can’t see what is wrong. Perhaps some missing header file? Anyway, I’ve committed the merge of master into for-v3.3 (even though it doesn’t compile) and just commented out those registrations in my local copy.
Can you help?
> On 12 Sep 2020, at 5:12 AM, Michael Balzer <dexter at expeedo.de> 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
> OvmsDev mailing list
> OvmsDev at lists.openvehicles.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the OvmsDev