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 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_hr( $blade );   # traditional function name

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

blade_env* fields

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.

links( )
colors( )
tags( )
web_vars( )
web_root( )
header( )
sysconfdir( )
bladeconfdir( )
web_page_name( )
page_name( )
web_context( )
user( )
passwd( )

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 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:

# 
# Initialize BLADE, get returned BLADEENV 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 BLADEHASH class. One obtains such an object from blade_hash_new(), blade_hash_dup() and blade_web_vars_get_all().

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).