Author image Marvin Humphrey
and 1 contributors

NAME

Clownfish::Binding::Perl::Subroutine - Abstract base binding for a Clownfish::Function.

SYNOPSIS

    # Abstract base class.

DESCRIPTION

This class is used to generate binding code for invoking Clownfish's functions and methods across the Perl/C barrier.

METHODS

new

    my $binding = $subclass->SUPER::new(
        param_list         => $param_list,           # required
        alias              => 'pinch',               # required
        class_name         => 'Crustacean::Claw',    # required
        retval_type        => $type,                 # required
        use_labeled_params => 1,                     # default: false
    );

Abstract constructor.

  • param_list - A Clownfish::ParamList.

  • alias - The local, unqualified name for the Perl subroutine that will be used to invoke the function.

  • class_name - The name of the Perl class that the subroutine belongs to.

  • retval_type - The return value's Type.

  • use_labeled_params - True if the binding should take hash-style labeled parameters, false if it should take positional arguments.

xsub_def

Abstract method which must return C code (not XS code) defining the Perl XSUB.

var_declarations

Generate C code containing declarations for subroutine-specific automatic variables needed by the XSUB.

get_class_name use_labeled_params

Accessors.

perl_name

Returns the fully-qualified perl sub name.

c_name

Returns the fully-qualified name of the C function that implements the XSUB.

c_name_list

Returns a string containing the names of arguments to feed to bound C function, joined by commas.

params_hash_def

Return Perl code initializing a package-global hash where all the keys are the names of labeled params. The hash's name consists of the the binding's perl_name() plus "_PARAMS".

COPYRIGHT AND LICENSE

Copyright 2008-2011 Marvin Humphrey

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.