Determine the data type of UDR arguments
With the MI_FPARAM structure, you can write UDRs that operate over a type hierarchy, rather than on a single type. At run time, the routine can examine the MI_FPARAM structure to determine what data types were passed to the current invocation of the routine.
Argument array | Contents |
---|---|
Argument-type array | Each element is a pointer to a type identifier (MI_TYPEID) that indicates the data type of the argument. |
Argument-length array | Each element is the integer length of the data type for each argument. |
Argument-scale array | Each element is the integer scale in the fixed-point
argument. The default value of the scale elements is zero. Therefore, any arguments that do not have a fixed-point data type have a scale value of zero. |
Argument-precision array | Each element is the integer precision in the fixed-point
or floating-point argument. The default value of the precision elements is zero. Therefore, any arguments that have neither fixed-point nor floating-point data types have a precision value of zero. |
Parameter-null array | Each element is either MI_FALSE or MI_TRUE:
|
Use the appropriate MI_FPARAM accessor function in Argument information in an MI_FPARAM structure to access the desired argument array.
1
of
these arrays holds the argument information for the second argument
of the UDR. mi_integer my_func(arg0, arg1, arg2, fparam_ptr)
MI_DATUM arg0;
MI_DATUM arg1;
MI_DATUM arg2;
MI_FPARAM *fparam_ptr;
{
MI_TYPEID *arg_type;
mi_integer arg_len;
...
arg_type = mi_fp_argtype(fparam_ptr, 1);
arg_len = mi_fp_arglen(fparam_ptr, 1);
To obtain the number of arguments passed to the UDR (which is also
the number of elements in the argument arrays), use the mi_fp_nargs() function.
For the argument arrays of the MI_FPARAM structure in the preceding
code fragment, mi_fp_nargs() would return a value
of 3
. The mi_fp_setnargs() function
stores the number of routine arguments in the MI_FPARAM structure.