pBLADE - Perl interface to the BLADE library.
use BLADE;
Provides an interface to the BLADE library. See http://www.thestuff.net/bob/projects/blade for more information.
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.
CORBA_char*
The C datatype blade_env* is represented as a Perl object blessed into the BLADEENV class. One obtains a BLADEENV 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 BLADEENV, then the following two lines are equivalent:
blade_env*
BLADEENV
blade_page_init()
$blade
blade_hr( $blade ); # traditional function name $blade->hr; # pBLADE's additional OO interface
The C blade_env struct datatype has several data which application programmers might find useful. These data are made available to BLADEENV objects via various methods. The methods are listed below.
blade_env
blade_page(), 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 that 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:
blade_page()
blade_obj_simple_init()
blade_theme_simple_init()
\@ARGV
@ARGV
# # Initialize BLADE, get returned BLADEENV object. # libblade may modify @ARGV in this case. # my $blade = blade_page_init(\@ARGV, '', 'en');
The C datatype blade_hash* is represented in pBLADE as a Perl object blessed into the BLADEHASH class. One obtains such an object from blade_hash_new(), blade_hash_dup() and blade_web_vars_get_all().
blade_hash*
BLADEHASH
blade_hash_new()
blade_hash_dup()
blade_web_vars_get_all()
blade_page(), 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.
blade_run()
The Perl subroutine referenced, when called, will be given arguments just as one would expect from the C function prototypes. Also in these functions, 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.
$data
An example:
blade_obj_simple_init(\@ARGV, \&draw, undef); blade_orb_run(); sub draw { my ($blade, $name, $args, $data) = @_; $blade->disp('Hello World'); }
Pete Ratzlaff <pratzlaff@cfa.harvard.edu>
perl(1).
To install BLADE, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BLADE
CPAN shell
perl -MCPAN -e shell install BLADE
For more information on module installation, please visit the detailed CPAN module installation guide.