Menu ▾ ▴

#320 External Code Generation not backward compatible

QM
closed
None
1
2023-01-04
2022-11-22
Dan
No

Step 1

With QP Bundle Version 6.9.3 and QM Version 5.1.1, create a simple class:

<?xml version="1.0" encoding="UTF-8"?>
<model version="5.1.1" links="0">
 <framework name="qpcpp"/>
 <package name="Simple" stereotype="0x00">
  <class name="Class">
   <operation name="Process" type="void" visibility="0x00" properties="0x00">
    <code>// process here</code>
   </operation>
  </class>
 </package>
 <directory name=".">
  <file name="SimpleClass.External.5.1.1.cpp">
   <text>$declare(Simple::Class)
$define(Simple::Class)
</text>
  </file>
 </directory>
</model>

Check the "external" check box for the source file. Here is the generated code:

//.$file${.::SimpleClass.External.5.1.1.cpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: model.5.1.1.qm
// File:  ${.::SimpleClass.External.5.1.1.cpp}
//
// This code has been generated by QM 5.1.1 <www.state-machine.com/qm/>.
// DO NOT EDIT SECTIONS BETWEEN THE COMMENTS "$...vvv".."$end...^^^".
// All your changes in these sections will be lost.
//
// This program is open source software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published
// by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
//.$endhead${.::SimpleClass.External.5.1.1.cpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//.$declare${Simple::Class} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//.${Simple::Class} ..........................................................
class Class {
public:
    void Process();
};
//.$enddecl${Simple::Class} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//. Check for the minimum required QP version
#if (QP_VERSION < 690U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpcpp version 6.9.0 or higher required
#endif
//.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//.$define${Simple::Class} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//.${Simple::Class} ..........................................................
//.${Simple::Class::Process} .................................................
void Class::Process() {
    // process here
}
//.$enddef${Simple::Class} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Step 2

With QP Bundle Version 7.1.3 and QM Version 5.2.3, create a simple class:

<?xml version="1.0" encoding="UTF-8"?>
<model version="5.2.3" links="0">
 <framework name="qpcpp"/>
 <package name="Simple" stereotype="0x00">
  <class name="Class">
   <operation name="Process" type="void" visibility="0x00" properties="0x00">
    <code>// process here</code>
   </operation>
  </class>
 </package>
 <directory name=".">
  <file name="SimpleClass.External.5.2.3.cpp">
   <text>$declare(Simple::Class)
$define(Simple::Class)
</text>
  </file>
 </directory>
</model>

Check the "external" check box for the source file. Here is the generated code:

//$file${.::SimpleClass.External.5.2.3.cpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: model.5.2.3.qm
// File:  ${.::SimpleClass.External.5.2.3.cpp}
//
// This code has been generated by QM 5.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT SECTIONS BETWEEN THE COMMENTS "$...vvv".."$end...^^^".
// All your changes in these sections will be lost.
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This generated code is open source software: you can redistribute it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation.
//
// This code is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// NOTE:
// Alternatively, this generated code may be distributed under the terms
// of Quantum Leaps commercial licenses, which expressly supersede the GNU
// General Public License and are specifically designed for licensees
// interested in retaining the proprietary status of their code.
//
// Contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${.::SimpleClass.External.5.2.3.cpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//$declare${Simple::Class} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

//${Simple::Class} ...........................................................
class Class {
public:
    void Process();
}; // class Class
//$enddecl${Simple::Class} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// Check for the minimum required QP version
#if (QP_VERSION < 690U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpcpp version 6.9.0 or higher required
#endif
//$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$define${Simple::Class} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

//${Simple::Class} ...........................................................

//${Simple::Class::Process} ..................................................
void Class::Process() {
    // process here
}
//$enddef${Simple::Class} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Step 3

Open up the QM model originally created by QM Version 5.1.1 with the latest QM Version 5.2.3. Generate the source code:

//$file${.::SimpleClass.External.5.1.1.cpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: model.5.1.1.qm
// File:  ${.::SimpleClass.External.5.1.1.cpp}
//
// This code has been generated by QM 5.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT SECTIONS BETWEEN THE COMMENTS "$...vvv".."$end...^^^".
// All your changes in these sections will be lost.
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This generated code is open source software: you can redistribute it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation.
//
// This code is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// NOTE:
// Alternatively, this generated code may be distributed under the terms
// of Quantum Leaps commercial licenses, which expressly supersede the GNU
// General Public License and are specifically designed for licensees
// interested in retaining the proprietary status of their code.
//
// Contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${.::SimpleClass.External.5.1.1.cpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//.$file${.::SimpleClass.External.5.1.1.cpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: model.5.1.1.qm
// File:  ${.::SimpleClass.External.5.1.1.cpp}
//
// This code has been generated by QM 5.1.1 <www.state-machine.com/qm/>.
// DO NOT EDIT SECTIONS BETWEEN THE COMMENTS "$...vvv".."$end...^^^".
// All your changes in these sections will be lost.
//
// This program is open source software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published
// by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
//.$endhead${.::SimpleClass.External.5.1.1.cpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//.$declare${Simple::Class} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//.${Simple::Class} ..........................................................
class Class {
public:
    void Process();
};
//.$enddecl${Simple::Class} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//. Check for the minimum required QP version
#if (QP_VERSION < 690U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpcpp version 6.9.0 or higher required
#endif
//.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//.$define${Simple::Class} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//.${Simple::Class} ..........................................................
//.${Simple::Class::Process} .................................................
void Class::Process() {
    // process here
}
//.$enddef${Simple::Class} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Note the extra file header generated even though no changes were made to the Simple Class in the QM tool.

Step 4

Add another comment line in the Class::Process() function, "// process more here". Generate the code again. The new line of code is not generated. From the Log Console:

INFO> Code generation started (1:25:10 pm)
INFO> File: SimpleClass.External.5.1.1.cpp
INFO> Code generation ended (time elapsed 0.001s)
INFO> 0 file(s) generated, 1 file(s) processed, 0 error(s) and 0 warning(s)

Step 5 - Workaround

Deselect the "external" check box. Open up the file, SimpleClass.External.5.1.1.cpp, in the QM Editor. "Redo" the Simple Class code generation by writing the following:

$declare(Simple::Class)
$define(Simple::Class)

Select "external" check box and regenerate the source again:

//$file${.::SimpleClass.External.5.1.1.cpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: model.5.1.1.qm
// File:  ${.::SimpleClass.External.5.1.1.cpp}
//
// This code has been generated by QM 5.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT SECTIONS BETWEEN THE COMMENTS "$...vvv".."$end...^^^".
// All your changes in these sections will be lost.
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This generated code is open source software: you can redistribute it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation.
//
// This code is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// NOTE:
// Alternatively, this generated code may be distributed under the terms
// of Quantum Leaps commercial licenses, which expressly supersede the GNU
// General Public License and are specifically designed for licensees
// interested in retaining the proprietary status of their code.
//
// Contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${.::SimpleClass.External.5.1.1.cpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//$declare${Simple::Class} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

//${Simple::Class} ...........................................................
class Class {
public:
    void Process();
}; // class Class
//$enddecl${Simple::Class} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// Check for the minimum required QP version
#if (QP_VERSION < 690U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpcpp version 6.9.0 or higher required
#endif
//$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$define${Simple::Class} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

//${Simple::Class} ...........................................................

//${Simple::Class::Process} ..................................................
void Class::Process() {
    // process here
    // process more here
}
//$enddef${Simple::Class} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Summary

If you compare the QM Version 5.1.1 delimiters to the new QM Version 5.2.3 delimiters, they are different. That is the old is:

//.$file${.::SimpleClass.External.5.1.1.cpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

And the new is:

//$file${.::SimpleClass.External.5.1.1.cpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

The old delimiter has a "." between "//" and "$". My guess is the new QM Version 5.2.3 doesn't handle the "//.$" and only looks for "//$".

Discussion

  • Quantum Leaps

    Quantum Leaps - 2023-01-04
    • status: open --> closed
    • assigned_to: Quantum Leaps
     
  • Quantum Leaps

    Quantum Leaps - 2023-01-04

    Fixed in QM 5.2.3.
    --MMS

     

Anonymous
Anonymous

Add attachments
Cancel