Claes Jakobsson > JavaScript > JavaScript

Download:
JavaScript-1.16.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  25
Open  12
View/Report Bugs
Module Version: 1.16   Source  

NAME ^

JavaScript - Perl extension for executing embedded JavaScript

SYNOPSIS ^

  use JavaScript;

  my $rt = JavaScript::Runtime->new();
  my $cx = $rt->create_context();

  $cx->bind_function(write => sub { print @_; });

  $cx->eval(q/
    for (i = 99; i > 0; i--) {
        write(i + " bottle(s) of beer on the wall, " + i + " bottle(s) of beer\n");
        write("Take 1 down, pass it around, ");
        if (i > 1) {
            write((i - 1) + " bottle(s) of beer on the wall.");
        }
        else {
            write("No more bottles of beer on the wall!");
        }
    }
  /);

DESCRIPTION ^

Always thought JavaScript was for web-applications only? well, think again...

This modules gives you the power of embedded JavaScript in your Perl applications. You can write your subroutines, classes and so forth in Perl and make them callable from JavaScript. Variables such as primitive types, objects and functions are automagically converted between the different environments. If you return a JavaScript function you can call it as a normal code-reference from Perl.

JavaScript is a great as an embedded language because it has no I/O, no IPC and pretty much anything else that can interfer with the system. It's also an easy yet powerfull language that zillions of developers worldwide knows.

Note that this module is not a JavaScript compiler/interpreter written in Perl but an interface to the SpiderMonkey engine used in the Mozilla-family of browsers.

INTERFACE ^

CLASS METHODS

create_runtime ( ... )

Shortcut for JavaScript::Runtime-new(...)>.

get_engine_version

In scalar context it returns a string describing the engine such as JavaScript-C 1.5 2004-09-24.

In list context it returns the separate parts of the string - engine, version and date of build.

does_support_utf8
does_handle_utf8

Returns a true value if SpiderMonkey is compiled with support for UTF8 strings and if we're using it. does_handle_utf8 is also supported for backwards compability.

does_support_e4x

Returns a true value if we have compiled support for E4X.

does_support_threading

Returns a true value if we have compiled support for threading.

supports ( @features )

Checks if all features given in @features are present. Is case insensitive. Supported keys are e4x, utf8 and threading. Extensions to this module may provide additional keys by implementing a method that begins with does_support_.

SUPPORT ^

There is a mailing-list available at http://lists.cpan.org/showlist.cgi?name=perl-javascript.

You may subscribe to the list by sending an empty e-mail to perl-javascript-subscribe@perl.org

CREDITS ^

See CREDITS

BUGS AND LIMITATIONS ^

Please report any bugs or feature requests to bug-javascript@rt.cpan.org, or through the web interface at http://rt.cpan.org.

AUTHOR ^

Claes Jakobsson <claesjac@cpan.org>

LICENCE AND COPYRIGHT ^

Copyright (c) 2001 - 2008, Claes Jakobsson <claesjac@cpan.org>. All rights reserved.

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

DISCLAIMER OF WARRANTY ^

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

syntax highlighting: