Don’t Pass the Buck to the Runtime!July 20, 2017
“D” is for DeveloperSeptember 20, 2017
We are pleased to announce the release of CodeGen 5.2.1 which includes several new features that significantly extend the possibilities for what can be generated. The core goal for this release was to introduce new features that make it possible to sub-divide the processing of large loops into smaller units of code, and by doing so make it possible to achieve new things, especially when working with very large structures.
For example, the reference code that demonstrates how to implement the replication of ISAM data to a relational database (https://github.com/SteveIves/SqlReplicationIoHooks) previously had a restriction that it could only deal with files (tables) with up to 252 fields (columns). The underlying reason for this related to the maximum number of arguments that can be passed to an external routine, %SSC_BIND in this case. The restriction of 252 available data parameters to %SSC_BIND meant that bad code would be produced for any structure with more than that number of fields. Now however, using some of the new features in CodeGen 5.2.1, the template has been re-structured so that %SSC_BIND will be called multiple times if necessary, removing the previous restriction.
But that’s just one example, there are doubtless many more. Here are the release notes for the new version:
- We added several a new generic expression token <IF COUNTER_n_op_value> that allows you to write conditional template code based on testing the current value of the two internal template counters against a simple numeric expression. Here is an example of using this new expression:
<IF CODEGEN_COUNTER_1_EQ_10> Code to include for every 10th item </IF>
- We added several new loop utility expression tokens that allow you to write conditional template code based on the total number of items that will be processed by a loop, the number of items that have already been processed, or how many remain to be processed, either including or excluding the current item. The new expressions are <IF PROCESSED_EXCLUSIVE_op_value>, <IF PROCESSED_INCLUSIVE_op_value>, <IF REMAINING_EXCLUSIVE_op_value>, <IF REMAINING_INCLUSIVE_op_value> and <IF TOTAL_ITEMS_op_value>. Here is an example of using one of these new expressions:
<IF TOTAL_ITEMS_LT_50> Code for a small number of items. <ELSE> Code for a larger number of items. </IF>
- We added several new loop utility expansion tokens that allow you to insert into generated code the total number of items that will be processed by a loop, the number of items that have already been processed, and the number that are still to be processed, either including or excluding the current item. The new expansion tokens are <PROCESSED_EXCLUSIVE>, <PROCESSED_INCLUSIVE>, <REMAINING_EXCLUSIVE>, <REMAINING_EXCLUSIVE_MAX_n>, <REMAINING_INCLUSIVE>, <REMAINING_INCLUSIVE_MAX_n> and <TOTAL_ITEMS>.
- We added a new file header token <REQUIRES_CODEGEN_VERSION> that allows you to specify the minimum version of CodeGen that is required to successfully process a template. Here is an example of using one this new expression:
- We made a minor correction to the documentation of the -f l command line option. The documentation previously stated that this option caused fields marked as “Excluded by Language” to be EXCLUDED from field loop processing, but actually such fields are excluded by default. The -f l command line option actually suppresses this behavior, causing such fields to be INCLUDED in field loop processing.
- This version of CodeGen was built with Synergy/DE 10.3.3c and requires a minimum Synergy run-time version of 10.1.1.
The latest version of CodeGen can always be downloaded here.