Internal: Replacing/Overriding System Call Keywords
Anonym
A customer is converting from PV-Wave code to IDL and has noticed that some IDL functions have the same name and function as their PV-Wave counterparts, but different keywords. Their core objective is to, as far as possible, make IDL compatible with the existing code rather than trawl through 12 years of code for everyone in their organization (well, community in fact). So in this case, they simply want to know if they can introduce a "wrapper" C function to intercept calls to a function (e.g. STRMATCH) and modify the keywords on-the-fly.
It is impossible to modify system routine keywords, because they are, for the most part, hard coded in each routine. To get around this the user can create a new argv, argc, argk in their wrapper/hook routine and pass this to the internal routine. It's a little work, but it will allow them to translate the interface they want to the interface of the underlying IDL system routine. The overriding of IDL system calls is documented Chapter 18 of the External Development Guide under "Enabling and Disabling System Routines".
As an example, if the function takes two arguments and one keyword called "FOLD_CASE" (as per STRMATCH), the parameters will be as follows:
Argc = 3
Argv = a three element array of IDL_VPTRs Argk = /0/0FOLD_CASE/0 (where "/0" represents NULL)
So, for a simple keyword replacement, you could write the function wrapper to modify the argk and pass the arguments to the real IDL function. The argk string array uses NULLs to separate the strings. This needs to also be in sync with normal parameters (argv), which will have a empty (NULLNULL) point in the string to identify an entry in argv as a normal parameter.
Internally this is done in a variety of places (when we call into the interpreter from C mostly). The bridges and the property bag object do all kinds of magic here.
A caveat: Some experienced IDL experts think that biting the bullet once by the customer to adjust their code to normal IDL syntax would be preferable. Otherwise the customer will probably experience difficulty with IDL upgrades when those upgrades require that the customer's community must rebuild and redistribute their PV-Wave bridge DLMs with each IDL release.