[
https://issues.apache.org/jira/browse/LUCY-27?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Marvin Humphrey updated LUCY-27:
--------------------------------
Attachment: XSBind.c
XSBind.h
XSBind.h and XSBind.c define C routines used by the
Boilerplater::Binding::Perl and friends for converting back and forth between
Perl data structures and Lucy data structures.
The default conversion routines perform deep conversion on data structures as
they cross the from Lucy to Perl: Lucy Hash objects become Perl hashes, Lucy
VArrays become perl VArrays, CharBufs are converted to UTF-8-enabled Perl
scalars. This means that, for example, when you invoke Seg_Fetch_Metadata from
Perl-space, you will get back an ordinary Perl hash rather than a perl-wrapped
Lucy::Obj::Hash object.
{code}
my $metadata = $segment->fetch_metadata("lexicon");
die "unrecognized format" if $metadata->{format} > 2;
{code}
In general, it would be more efficient to just return the Lucy objects, but
that yields an inferior interface for Perl users.
Another approach would be to return the Lucy objects but give them a more
user-friendly surface via Perl overloading and tied variables. However, it is
my experience that overloaded and tied variables are difficult to troubleshoot
and breed a lot of bugs.
There are two cases where I think overloading can be effective: hashref
overloading on Doc objects and stringification overloading on Err objects;
perhaps other cases will present themselves in time. However, I think
enabling overloading for a few isolated cases makes more sense than relying on
it as a core technology for moving data back and forth between Perl-space and
Lucy-space.
> Boilerplater Perl bindings
> --------------------------
>
> Key: LUCY-27
> URL: https://issues.apache.org/jira/browse/LUCY-27
> Project: Lucy
> Issue Type: Sub-task
> Components: Boilerplater
> Reporter: Marvin Humphrey
> Attachments: Class.pm, Constructor.pm, Method.pm, Perl.pm,
> Subroutine.pm, TypeMap.pm, XSBind.c, XSBind.h
>
>
> Iterate over the classes, methods, etc. in a Boilerplater::Hierarchy,
> auto-generating binding code to bridge Perl-space and C-space.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.