The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

pBLADE - Perl interface to the BLADE library.

SYNOPSIS

  use BLADE;

DESCRIPTION

Provides an interface to the BLADE library. See http://www.thestuff.net/bob/projects/blade for more information.

API

Most functions from libblade are available, and the arguments are identical to those one would use in the C language.

Functions in the C library that accept arguments of type CORBA_char* should be given normal Perl strings. Likewise, any function that returns a CORBA_char* in C, will instead return a normal Perl string in pBLADE.

The C datatype blade_env* is represented as a Perl object blessed into the blade_envPtr class. One obtains a blade_envPtr object by calling blade_page_init(), which is then suitable for passing to any other functions that would require a blade_env* in the C library. Such functions may also be used in an object-oriented manner, with the leading 'blade_' stripped off. For example, if $blade is an object of type blade_envPtr, then the following two lines are equivalent:

        blade_hr( $blade );   # traditional function name

        $blade->hr;           # pBLADE's additional OO interface

Functions requiring (int *argc, char **argv)

blade_page_init(), blade_obj_simple_init() and blade_theme_simple_init() in libblade expect to be given the command-line argument count and values, in the event the any of them are of use to libblade. In pBLADE, however, these arguments are replaced with a single array reference, usually \@ARGV, representing the command line arguments given to the Perl script. Note that @ARGV may come back modified if libblade found any of the arguments to its liking. An example:

        # 
        # Initialize BLADE, get returned blade_envPtr object.
        # libblade may modify @ARGV in this case.
        #
        my $blade = blade_page_init(\@ARGV, '', 'en');

BLADE hashes

The C datatype blade_hash* is represented in pBLADE as a Perl object blessed into the blade_hashPtr class. One obtains such an object from blade_hash_new(), blade_hash_dup() and blade_web_vars_get_all().

The destructor for the blade_hashPtr class automatically calls blade_hash_free() when the object goes out of context.

Callbacks

blade_run(), blade_obj_simple_init() and blade_theme_simple_init() each require callbacks to be specified. In C, these are the addresses of functions of certain types. In pBLADE, these are Perl code references.

The Perl subroutine referenced, when called, will be given arguments just as one would expect from the C function prototypes. Also, in the case of blade_obj_simple_init() and blade_theme_simple_init(), another argument, $data is given which is a Perl scalar that will be passed to the callback function. Use undef if you don't wish to use this feature.

An example:

        blade_obj_simple_init(\@ARGV, \&draw, undef);
        blade_orb_run();

        sub draw {
            my ($blade, $name, $args, $data) = @_;
            $blade->disp('Hello World');
        }

AUTHOR

Pete Ratzlaff <pratzlaff\@cfa.harvard.edu>

SEE ALSO

perl(1).