<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    I understood I should add the change to std::function in
    ovms_command only to the for-v3.3 branch, so Chris didn't take that
    into account yet.<br>
    <br>
    Regards,<br>
    Michael<br>
    <br>
    <br>
    <div class="moz-cite-prefix">Am 25.09.20 um 15:22 schrieb Mark
      Webb-Johnson:<br>
    </div>
    <blockquote type="cite"
      cite="mid:0392EF42-AB70-4E96-8425-A221A530A0B6@webb-johnson.net">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      Wow. That would have taken me hours to work out. Thanks.
      <div class=""><br class="">
      </div>
      <div class="">Any idea why it compiled in master, but not in
        for-v3.3?</div>
      <div class=""><br class="">
      </div>
      <div class="">Regards, Mark.<br class="">
        <div><br class="">
          <blockquote type="cite" class="">
            <div class="">On 25 Sep 2020, at 9:10 PM, Michael Balzer
              <<a href="mailto:dexter@expeedo.de" class=""
                moz-do-not-send="true">dexter@expeedo.de</a>> wrote:</div>
            <br class="Apple-interchange-newline">
            <div class="">
              <meta http-equiv="Content-Type" content="text/html;
                charset=UTF-8" class="">
              <div class=""> Mark,<br class="">
                <br class="">
                the issue is, there are ambiguous overloads of these
                methods in their classes, and the compiler doesn't know
                which one to pick.<br class="">
                <br class="">
                -
                <a class="moz-txt-link-freetext"
href="https://stackoverflow.com/questions/10111042/wrap-overloaded-function-via-stdfunction"
                  moz-do-not-send="true">https://stackoverflow.com/questions/10111042/wrap-overloaded-function-via-stdfunction</a><br
                  class="">
                -
                <a class="moz-txt-link-freetext"
href="https://stackoverflow.com/questions/30393285/stdfunction-fails-to-distinguish-overloaded-functions"
                  moz-do-not-send="true">https://stackoverflow.com/questions/30393285/stdfunction-fails-to-distinguish-overloaded-functions</a><br
                  class="">
                <br class="">
                I prefer to keep my command stub names distinguished
                from their implementation counterparts, but apparently
                that doesn't apply to all of us ;-)<br class="">
                <br class="">
                Coming C++ versions may be smart enough to deduce the
                method to pick from the expected signature.<br class="">
                <br class="">
                For now, the compiler needs a hint here. I've added two
                preprocessor macros to make these hints readable.<br
                  class="">
                <br class="">
                Regards,<br class="">
                Michael<br class="">
                <br class="">
                <br class="">
                <div class="moz-cite-prefix">Am 25.09.20 um 08:07
                  schrieb Mark Webb-Johnson:<br class="">
                </div>
                <blockquote type="cite"
                  cite="mid:69619FE9-B978-4C50-AD51-F99FB2CCBB29@webb-johnson.net"
                  class="">
                  <meta http-equiv="Content-Type" content="text/html;
                    charset=UTF-8" class="">
                  @Michael,
                  <div class=""><br class="">
                  </div>
                  <div class="">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:</div>
                  <div class=""><br class="">
                  </div>
                  <blockquote style="margin: 0 0 0 40px; border: none;
                    padding: 0px;" class="">
                    <div class="">components/retools_testerpresent/src/retools_testerpresent.cpp</div>
                    <div class="">components/vehicle_mgev/src/vehicle_mgev.cpp</div>
                  </blockquote>
                  <div class="">
                    <div class=""><br class="">
                    </div>
                    <div class="">Both in the RegisterCommand function
                      call with the static class member function as a
                      parameter. Not sure if that new way is used
                      elsewhere?</div>
                    <div class=""><br class="">
                    </div>
                    <div class="">Example compiler output is:</div>
                    <div class=""><br class="">
                    </div>
                  </div>
                  <blockquote style="margin: 0 0 0 40px; border: none;
                    padding: 0px;" class="">
                    <div class="">
                      <div class=""><font class="" face="Andale Mono"><span
                            style="font-style: normal; font-size: 12px;"
                            class="">CXX
                            build/retools_testerpresent/src/retools_testerpresent.o</span></font></div>
                      <div class=""><font class="" face="Andale Mono"><span
                            style="font-style: normal; font-size: 12px;"
                            class="">.../components/retools_testerpresent/src/retools_testerpresent.cpp:
                            In constructor
                            'OvmsReToolsTesterPresentInit::OvmsReToolsTesterPresentInit()':</span></font></div>
                      <div class=""><font class="" face="Andale Mono"><span
                            style="font-style: normal; font-size: 12px;"
                            class="">.../components/retools_testerpresent/src/retools_testerpresent.cpp:140:5:
                            error: no matching function for call to
                            'OvmsCommand::RegisterCommand(const char
                            [6], const char [48], <unresolved
                            overloaded function type>, const char
                            [23], int, int)'</span></font></div>
                      <div class=""><font class="" face="Andale Mono"><span
                            style="font-style: normal; font-size: 12px;"
                            class="">     );</span></font></div>
                      <div class=""><font class="" face="Andale Mono"><span
                            style="font-style: normal; font-size: 12px;"
                            class="">     ^</span></font></div>
                      <div class=""><font class="" face="Andale Mono"><span
                            style="font-style: normal; font-size: 12px;"
                            class=""><br class="">
                          </span></font></div>
                      <div class=""><font class="" face="Andale Mono">
                          <div class=""><span style="font-size: 12px;"
                              class="">CXX
                              build/vehicle_mgev/src/vehicle_mgev.o</span></div>
                          <div class=""><span style="font-size: 12px;"
                              class="">.../components/vehicle_mgev/src/vehicle_mgev.cpp:
                              In constructor
                              'OvmsVehicleMgEv::OvmsVehicleMgEv()':</span></div>
                          <div class=""><span style="font-size: 12px;"
                              class="">.../components/vehicle_mgev/src/vehicle_mgev.cpp:143:5:
                              error: no matching function for call to
                              'OvmsCommandApp::RegisterCommand(const
                              char [8], const char [15], <unresolved
                              overloaded function type>)'</span></div>
                          <div class=""><span style="font-size: 12px;"
                              class="">     );</span></div>
                          <div class=""><span style="font-size: 12px;"
                              class="">     ^mand(const char* name,
                              const char* title,</span></div>
                          <div style="font-size: 12px;" class="">       
                                      ^</div>
                        </font></div>
                    </div>
                  </blockquote>
                  <div class="">
                    <div class=""><br class="">
                    </div>
                    <div class="">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.</div>
                    <div class=""><br class="">
                    </div>
                    <div class="">Can you help?</div>
                    <div class=""><br class="">
                    </div>
                    <div class="">Thanks, Mark.</div>
                    <div class=""><br class="">
                    </div>
                    <div class="">
                      <blockquote type="cite" class="">
                        <div class="">On 12 Sep 2020, at 5:12 AM,
                          Michael Balzer <<a
                            href="mailto:dexter@expeedo.de" class=""
                            moz-do-not-send="true">dexter@expeedo.de</a>>
                          wrote:</div>
                        <br class="Apple-interchange-newline">
                        <div class="">
                          <div class="">Mark,<br class="">
                            <br class="">
                            Am 11.09.20 um 18:11 schrieb Michael Balzer:<br
                              class="">
                            <blockquote type="cite" class="">
                              <blockquote type="cite" class="">I agree
                                it is not necessary; my suggestion is
                                purely to clean it up<br class="">
                                and enhance functionality. The problem
                                at the moment is that<br class="">
                                OvmsCommand execute callbacks can only
                                be to function callbacks (not<br
                                  class="">
                                objects). It doesn’t even use the c++
                                bind function callback<br class="">
                                mechanism (like notification, etc, for
                                example). It is what it is,<br class="">
                                and changing now is very hard.<br
                                  class="">
                              </blockquote>
                              <br class="">
                              That slipped my attention, but upgrading
                              OvmsCommand to accept any<br class="">
                              function type should be simply changing
                              m_execute and m_validate to<br class="">
                              std::function, or do I miss something?<br
                                class="">
                            </blockquote>
                            <br class="">
                            Just did this locally, works perfectly.
                            Shall I push the change or have<br class="">
                            you begun working on ovms_command?<br
                              class="">
                            <br class="">
                            If so, it's really just exchanging the
                            function signatures for these types:<br
                              class="">
                            <br class="">
                            typedef std::function<void(int,
                            OvmsWriter*, OvmsCommand*, int, const<br
                              class="">
                            char* const*)>
                            OvmsCommandExecuteCallback_t;<br class="">
                            typedef std::function<int(OvmsWriter*,
                            OvmsCommand*, int, const char*<br class="">
                            const*, bool)>
                            OvmsCommandValidateCallback_t;<br class="">
                            <br class="">
                            Patch attached.<br class="">
                            <br class="">
                            Regards,<br class="">
                            Michael<br class="">
                            <br class="">
                            -- <br class="">
                            Michael Balzer * Helkenberger Weg 9 *
                            D-58256 Ennepetal<br class="">
                            Fon 02333 / 833 5735 * Handy 0176 / 206 989
                            26<br class="">
                            <br class="">
                            <span
                              id="cid:C485C3D9-D7D0-413F-A1D9-F85EA4B87851"
                              class=""><ovmscommand.patch></span>_______________________________________________<br
                              class="">
                            OvmsDev mailing list<br class="">
                            <a
                              href="mailto:OvmsDev@lists.openvehicles.com"
                              class="" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a><br
                              class="">
                            <a class="moz-txt-link-freetext"
                              href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev"
                              moz-do-not-send="true">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a><br
                              class="">
                          </div>
                        </div>
                      </blockquote>
                    </div>
                    <br class="">
                  </div>
                  <br class="">
                  <fieldset class="mimeAttachmentHeader"></fieldset>
                  <pre class="moz-quote-pre" wrap="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
</pre>
                </blockquote>
                <br class="">
                <pre class="moz-signature" cols="72">-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26</pre>
              </div>
              _______________________________________________<br
                class="">
              OvmsDev mailing list<br class="">
              <a href="mailto:OvmsDev@lists.openvehicles.com" class=""
                moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a><br
                class="">
              <a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a><br
                class="">
            </div>
          </blockquote>
        </div>
        <br class="">
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com">OvmsDev@lists.openvehicles.com</a>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26</pre>
  </body>
</html>