In the latest build, I've tried to finish work with pcre2_set_callout
, but I've encountered a show stopper.
I'm passing ObjPtr(Me)
for the third parameter of pcre2_set_callout
, but the value I'm receiving in my callback function is completely different, meaning I can't convert it back to an object instance. The strange thing is that the same approach works fine in pcre2_callout_enumerate
. Not sure what is going on.
The PCRE2 API declares the two methods as follows:
int pcre2_set_callout(pcre2_match_context *mcontext, int (*callout_function)(pcre2_callout_block *), void *callout_data);
int pcre2_callout_enumerate(const pcre2_code *code, int (*callback)(pcre2_callout_enumerate_block *, void *), void *callout_data);
As you can see they both take a third parameter void *callout_data
.
I've declared the 2 functions in VB as follows:
Private Declare Function pcre2_callout_enumerate Lib "pcre2-16.dll" Alias "_pcre2_callout_enumerate_16@12" (ByVal p_CompiledRegexHandle As Long, ByVal p_CalloutAddress As Long, ByRef p_CalloutDataPointer As Long) As Long
Private Declare Function pcre2_set_callout Lib "pcre2-16.dll" Alias "_pcre2_set_callout_16@12" (ByVal p_MatchContextHandle As Long, ByVal p_CalloutAddress As Long, ByRef p_CalloutDataPointer As Long) As Long
So as you can see, both declares take a final ByRef Long to which I pass ObjPtr(Me).
In my enumerate callout callback function, the ObJPtr value arrives correctly, and I can create an object reference from it without issue.
In my match callout callback, the value comes back completely different, so an attempt to create an object reference crashes the program.
Anyone have any idea what I am doing wrong?