On Jun 7, 2013, at 02:00 , Marvin Humphrey <[email protected]> wrote:
> There's a problem in the way that we specify Perl bindings for clownfish
> methods. The default is to lowercase the name of the Clownfish method (`Load`
> => 'load') but we also allow aliases (`Load` => `_load`). That
> information is not preserved once the shared object is built, so derived
> parcels are not getting it and generate the default instead.
>
> We need a way to pass this metadata, e.g. from Clownfish to Lucy. The easiest
> technique seems to be to embed it in the shared object and have CFC `use
> Clownfish` then extract it.
Looking at the code in CFCPerlClass_method_bindings where we need the metadata
from other parcels, it turns out that the same problem applies to "excluded"
methods.
I think the best place to store that information is in the Method objects. The
bootstraping code in boot.c could add method aliases and exclusions like this:
VTable_Add_Host_Method_Alias(LUCY_OBJ, "Load", "_load");
VTable_Exclude_Host_Method(LUCY_HASH, "Store");
Then the Lucy build process could use the VTable registry to tell CFC about the
metadata. If we do it in Perl, we don't have to care about dynamically loading
the shared object:
use Clownfish;
my @vtables = Clownfish::VTable->vtables_from_parcel('Clownfish');
for my $vtable (@vtables) {
my $class =
Clownfish::CFC::Model::Class->fetch_singleton($vtable->get_name);
for my $method (@{ $vtable->get_methods }) {
if ($method->is_excluded_from_host) {
$class->exclude_host_method($method->get_name);
}
else {
my $alias = $method->get_host_alias;
if (defined($alias)) {
$class->add_host_method_alias($method->get_name, $alias);
}
}
}
}
We'd need a few extensions to our metadata system but that should be useful
later. As I indicated on IRC, I've been thinking about storing method
signatures in the Method objects. That should make it possible to extend
Clownfish parcels without the parcel's CFH files. Only the DSO and the
generated C headers would be required.
By the way, I'm really in favor of renaming Clownfish::VTable to
Clownfish::Class.
Nick