David Leadbeater > JavaScript-V8-0.06 > JavaScript::V8::Context

Download:
JavaScript-V8-0.06.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  11
Open  4
View/Report Bugs
Source   Latest Release: JavaScript-V8-0.07

NAME ^

JavaScript::V8::Context - An object in which we can execute JavaScript

SYNOPSIS ^

  use JavaScript::V8;

  # Create a runtime and a context
  my $context = JavaScript::V8::Context->new();

  # Add a function which we can call from JavaScript
  $context->bind_function(print => sub { print @_ });

  my $result = $context->eval($source);

INTERFACE ^

bind ( name => $scalar )

Converts the given scalar value (array ref, code ref, or hash ref) to a v8 value and binds it in this context.

bind_function ( $name => $subroutine_ref )

DEPRECATED. This is just an alias for bind.

eval ( $source )

Evaluates the JavaScript code given in $source and returns the result from the last statement.

If there is a compilation error (such as a syntax error) or an uncaught exception is thrown in JavaScript, this method returns undef and $@ is set.

syntax highlighting: