On 31/07/2014 15:25, Nick Wellnhofer wrote:
On 31/07/2014 04:00, Marvin Humphrey wrote:
It is still important to come up with a general solution to the problem
of autogenerated bindings which do not behave quite right. Our current
hack -- using CFC to autogenerate a "private" helper (i.e. prepended
with an underscore) and then creating a wrapper with the "real" name --
has been revealed as unworkable. However, that hack is still used in
many places -- see much of Lucy.pm and Clownfish.pm.
Clownfish.pm seems to be OK. There are no such aliases, only a couple of
helper functions that are called from C.
Having a closer look, there are two cases where Clownfish uses Perl wrappers:
String#Clone and VArray#Clone. But the XSUBs aren't excluded so we have both
an XSub and a Perl sub. This looks like a bug.
Regarding the hand-rolled XS, there's another subtle issue that I encountered
when working on callbacks for excluded methods. For hand-rolled XS methods, we
call '$binding->exclude_method' to tell CFC not to autogenerate an XSUB for
us. But that's not enough to determine whether callbacks for overriding from
Perl should be allowed. There are cases where we want callbacks to work, like
Query#Make_Compiler. But in other cases, the hand-rolled XS has incompatible
parameters so overriding would break. So the API should look like:
# Don't generate XSUB and callback. A method with the same name
# can be defined via custom XS or Perl but callbacks won't work.
$binding->exclude_method(...);
# Don't generate XSUB but create callback.
$binding->exclude_xsub(...);
There's also a third case where we want to autogenerate an XSUB but no
callback. I can't think of an immediate use case, but at some point, we might
want to allow custom callbacks.
I created a branch overridden_exclusions laying some groundwork and
consolidating some code. The only effective change for now is that the XSUBs
for To_Host are removed, so I think it's safe to merge.
Nick