Cast support functions

If you specified a cast support function when you created a cast, BladeSmith generates the cast support function in the udr.c file.

The generated code

BladeSmith generates only templates for cast support functions.

The generated function declares the routine, its return type, and arguments. In addition to the arguments you specified when creating the function, these functions also have an MI_FPARAM argument, which is not used by the generated code.

Complete the code

To complete the code for cast support functions, you must:
  • Add your declarations, if necessary.
  • Remove the call to mi_db_error_raise(), which raises an error stating that the routine is not implemented.
  • Convert one data type to the other.
  • Store the return value in the Gen_RetVal argument.

In a cast support function, you might convert from one binary representation to another, if the data types involved in the cast have differing binary representations. Alternatively, you might perform a calculation to convert one data type to another.

Example

The Creating Distinct Types and Casts exercise in the tutorial uses cast support functions.