libxml-raku / LibXML-raku

Raku bindings to the libxml2 native library
Artistic License 2.0
11 stars 5 forks source link

Make LibXML::Item use :config for boxing #97

Closed vrurg closed 1 year ago

vrurg commented 1 year ago

Any config supplied by upstream was previously ignored and class mapping was expected to be done by LibXML::Node. This resulted in limited abilities of user code in controlling how boxing is done. See #94.

Note that LibXML::Node still does its own class mapping because this is the point of final decision and in many cases it is invoked directly.

vrurg commented 1 year ago

Following #94 and this comment in particular. For caching to work properly, i.e. for a LibXML::Node subclass to be able to intercept the box method, it is necessary that LibXML::Item.box calls that subclass' box instead of directly referring to LibXML::Node. This PR makes it possible.

An alternative would be to modify class mapping on the global configuration object and pointing it into a some kind of proxy-class which would then re-dispatch the call to an appropriate class, but that adds an extra call to the call chain.