Currently, custom pointer types in extension-defined API functions are not validated by REAPER before being called nor with ValidatePtr.
For example: BR_EnvFree expects a BR_Envelope* but no explicit error is thrown if it receives anything else (unlike built-in REAPER types, which are checked).
Expected:
Code:
reaper.BR_EnvFree(reaper.GetMasterTrack(), false)
--> 'reaper.BR_EnvFree' argument 1: expected BR_Envelope*
reaper.ValidatePtr(reaper.GetMasterTrack(), 'BR_Envelope*')
--> false
Possible implementation on the extension side:
Code:
typedef struct
{
const char *name;
bool (*Validate)(void *ptr);
} custom_type_register_t;
custom_type_register_t br_env{"BR_Envelope*", &ValidateSWSPtr<BR_Envelope>};
plugin_register("custom_type", (void *)&br_env);