[lucy-dev] [GitHub] lucy-clownfish pull request #79: Allow Perl subclasses to use hashrefs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[lucy-dev] [GitHub] lucy-clownfish pull request #79: Allow Perl subclasses to use hashrefs

asfgit
GitHub user nwellnhof opened a pull request:

    https://github.com/apache/lucy-clownfish/pull/79

    Allow Perl subclasses to use hashrefs

    If a parent class without ivars is subclassed from Perl, don't store
    the pointer to the Clownfish object in the SV, but use a hashref as
    underlying Perl object. This allows Perl subclasses to store their own
    ivars directly in the hashref without having to resort to inside-out
    objects.
   
    This requires to create a host object wrapper whenever an object is
    constructed or a Clownfish method is invoked. A similar approach can
    be used by other host languages without class-based inheritance.
   
    The perl_to_cfish functions now use Class_fetch and an is_a check based
    on the Clownfish parent class pointer instead of calling sv_derived_from.
    I haven't checked whether there's a performance impact, but this might
    actually be faster than the old code.
   
    The old inside-out approach is still supported by overloading scalar
    dereferencing for host object wrappers.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/nwellnhof/lucy-clownfish host-obj-wrapper

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/lucy-clownfish/pull/79.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #79
   
----
commit 0bfeb23eccec3519d2bf72126c5c9aea7464c4c8
Author: Nick Wellnhofer <[hidden email]>
Date:   2017-03-06T12:26:59Z

    Allow Perl subclasses to use hashrefs
   
    If a parent class without ivars is subclassed from Perl, don't store
    the pointer to the Clownfish object in the SV, but use a hashref as
    underlying Perl object. This allows Perl subclasses to store their own
    ivars directly in the hashref without having to resort to inside-out
    objects.
   
    This requires to create a host object wrapper whenever an object is
    constructed or a Clownfish method is invoked. A similar approach can
    be used by other host languages without class-based inheritance.
   
    The perl_to_cfish functions now use Class_fetch and an is_a check based
    on the Clownfish parent class pointer instead of calling sv_derived_from.
    I haven't checked whether there's a performance impact, but this might
    actually be faster than the old code.
   
    The old inside-out approach is still supported by overloading scalar
    dereferencing for host object wrappers.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[lucy-dev] [GitHub] lucy-clownfish pull request #79: Allow Perl subclasses to use hashrefs

asfgit
Github user asfgit closed the pull request at:

    https://github.com/apache/lucy-clownfish/pull/79


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---