Method Catalog Extensions File

 

Some of the capabilities of CodeGen require that you provide additional information about a method catalogs interfaces, methods and parameters, beyond what can be specified in the catalog itself. To achieve this CodeGen allows you to provide this additional information as necessary by creating and naming a special JSON file. The structure of the file looks like this:

 

[

  {

    "InterfaceName": "",

    "CustomExpansionTokens": [

      {

        "Name": "",

        "Value": ""

      }

    ],

    "CustomExpressionTokens": [

      ""

    ],

    "Methods": [

      {

        "MethodName": "",

        "CustomExpansionTokens": [

          {

            "Name": "",

            "Value": ""

          }

        ],

        "CustomExpressionTokens": [

          ""

        ],

        "Parameters": [

          {

            "ParameterName": "",

            "CustomExpansionTokens": [

              {

                "Name": "",

                "Value": ""

              }

            ],

            "CustomExpressionTokens": [

              ""

            ]

         }

       ]

     }

   ]

 }

]

 

As you can see the file contains an array of objects, each of which relates to an interface defined in your method catalog. Each interface has a property named InterfaceName that allows you to specify the name of the associated interface in the method catalog.

 

From that point on everything is optional, you only need specify as much information as you need in order to define the custom tokens that are required to activate whatever piece of CodeGen functionality you are trying to use.

 

For example, if you need to specify a custom expression SAVE_RESULT_TO_CONTEXT and a custom expansion token SAVE_BUFFER_NAME with a value of OpsBufferValue, for method ops_buffer_read in interface asp, your JSON file would need to look like this:

 

[

  {

    "InterfaceName": "asp",

    "Methods": [

      {

        "MethodName": "ops_buffer_read",

        "CustomExpressionTokens": [

          "SAVE_RESULT_TO_CONTEXT"

        ],

        "CustomExpansionTokens": [

          {

            "Name": "SAVE_BUFFER_NAME",

            "Value": "OpsBufferValue"

          }

        ]     

      }

    ]

  }

]

 

Once you have created your JSON file you can specify its use during code generation via the -smcext command line option.

 

To use the SAVE_RESULT_TO_CONTEXT expression in a template file you would use expression syntax like <IF CUSTOM_METHOD_SAVE_RESULT_TO_CONTEXT>. Note that the expression will only evaluate to true for methods that have the custom expression defined in the extensions file, all other methods will evaluate to false.

 

To use the SAVE_BUFFER_NAME expansion token in a template file you would use a syntax like <SAVE_BUFFER_NAME>. Note that the expansion to the associated value (OpsBufferValue) will only occur when processing methods that have the custom expansion token definedin the extensions file, no value will be inserted for other methods.

 

Note that custom expression and expansion token names are not case sensitive, always being converted to uppercase for comparison, but the case of expansion token values is preserved and inserted exactly as typed.

 

 

 

 


Copyright © 2021  Synergex International, Inc.