The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Clownfish::CFC::Binding::Perl::TypeMap - Convert between Clownfish and Perl via XS.

DESCRIPTION

TypeMap serves up C code fragments for translating between Perl data structures and Clownfish data structures. The functions to_perl() and from_perl() achieve this for individual types; write_xs_typemap() exports all types using the XS "typemap" format documented in perlxs.

FUNCTIONS

from_perl

    my $expression = from_perl( $type, $xs_var );

Return an expression which converts from a Perl scalar to a variable of type $type.

  • type - A Clownfish::CFC::Type, which will be used to select the mapping code.

  • xs_var - The C name of the Perl scalar from which we are extracting a value.

to_perl

    my $c_code = to_perl( $type, $cf_var );

Return an expression converts from a variable of type $type to a Perl scalar.

  • type - A Clownfish::CFC::Type, which will be used to select the mapping code.

  • cf_var - The name of the variable from which we are extracting a value.

CLASS METHODS

write_xs_typemap

    Clownfish::CFC::Binding::Perl::Typemap->write_xs_typemap(
        hierarchy => $hierarchy,
    );

Auto-generate a "typemap" file that adheres to the conventions documented in perlxs.

We generate this file on the fly rather than maintain a static copy because we want an entry for each Clownfish type so that we can differentiate between them when checking arguments. Keeping the entries up-to-date manually as classes come and go would be a pain.