r24596 - in /trunk/libjavascript-perl: Changes JavaScript.xs MANIFEST META.yml debian/changelog lib/JavaScript.pm lib/JavaScript/Context.pm t/34-options.t
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Mon Aug 25 03:03:53 UTC 2008
Author: gregoa
Date: Mon Aug 25 03:03:50 2008
New Revision: 24596
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=24596
Log:
New upstream release.
Added:
trunk/libjavascript-perl/t/34-options.t
- copied unchanged from r24595, branches/upstream/libjavascript-perl/current/t/34-options.t
Modified:
trunk/libjavascript-perl/Changes
trunk/libjavascript-perl/JavaScript.xs
trunk/libjavascript-perl/MANIFEST
trunk/libjavascript-perl/META.yml
trunk/libjavascript-perl/debian/changelog
trunk/libjavascript-perl/lib/JavaScript.pm
trunk/libjavascript-perl/lib/JavaScript/Context.pm
Modified: trunk/libjavascript-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/Changes?rev=24596&op=diff
==============================================================================
--- trunk/libjavascript-perl/Changes (original)
+++ trunk/libjavascript-perl/Changes Mon Aug 25 03:03:50 2008
@@ -1,5 +1,9 @@
Revision history for Perl extension JavaScript.
+1.11 2008-08-23
+ - Added get_options, has_options and toggle_options so one can enable stuff like strict mode and JIT compilation
+ if the underlying SpiderMonkey supports it (TraceMonkey ftw!).
+
1.10 2008-08-11
- Warn user that JS_THREADSAFE is not what's recommended.
- Added a native PerlHash type that encapsulates a Perl hash reference in JavaScript.
Modified: trunk/libjavascript-perl/JavaScript.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/JavaScript.xs?rev=24596&op=diff
==============================================================================
--- trunk/libjavascript-perl/JavaScript.xs (original)
+++ trunk/libjavascript-perl/JavaScript.xs Mon Aug 25 03:03:50 2008
@@ -426,7 +426,21 @@
OUTPUT:
RETVAL
-
+U32
+jsc_get_options(cx)
+ PJS_Context *cx;
+ CODE:
+ RETVAL = JS_GetOptions(cx->cx);
+ OUTPUT:
+ RETVAL
+
+void
+jsc_toggle_options(cx, options)
+ PJS_Context *cx;
+ U32 options;
+ CODE:
+ JS_ToggleOptions(cx->cx, options);
+
MODULE = JavaScript PACKAGE = JavaScript::Script
jsval
Modified: trunk/libjavascript-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/MANIFEST?rev=24596&op=diff
==============================================================================
--- trunk/libjavascript-perl/MANIFEST (original)
+++ trunk/libjavascript-perl/MANIFEST Mon Aug 25 03:03:50 2008
@@ -84,6 +84,7 @@
t/31-version.t
t/32-perlarray.t
t/33-perlhash.t
+t/34-options.t
t/99-bottles-of-beer.t
t/lib/DummyClass.pm
t/pod-coverage.t
Modified: trunk/libjavascript-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/META.yml?rev=24596&op=diff
==============================================================================
--- trunk/libjavascript-perl/META.yml (original)
+++ trunk/libjavascript-perl/META.yml Mon Aug 25 03:03:50 2008
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: JavaScript
-version: 1.10
+version: 1.11
abstract: Perl extension for executing embedded JavaScript
license: perl
author:
Modified: trunk/libjavascript-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/debian/changelog?rev=24596&op=diff
==============================================================================
--- trunk/libjavascript-perl/debian/changelog (original)
+++ trunk/libjavascript-perl/debian/changelog Mon Aug 25 03:03:50 2008
@@ -1,4 +1,4 @@
-libjavascript-perl (1.10-1) UNRELEASED; urgency=low
+libjavascript-perl (1.11-1) UNRELEASED; urgency=low
TODO:
the packaging should be ok, but there are many compiler warnings.
Modified: trunk/libjavascript-perl/lib/JavaScript.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/lib/JavaScript.pm?rev=24596&op=diff
==============================================================================
--- trunk/libjavascript-perl/lib/JavaScript.pm (original)
+++ trunk/libjavascript-perl/lib/JavaScript.pm Mon Aug 25 03:03:50 2008
@@ -23,7 +23,7 @@
our %EXPORT_TAGS = ( all => [@EXPORT_OK] );
-our $VERSION = "1.10";
+our $VERSION = "1.11";
our $MAXBYTES = 1024 ** 2;
Modified: trunk/libjavascript-perl/lib/JavaScript/Context.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/lib/JavaScript/Context.pm?rev=24596&op=diff
==============================================================================
--- trunk/libjavascript-perl/lib/JavaScript/Context.pm (original)
+++ trunk/libjavascript-perl/lib/JavaScript/Context.pm Mon Aug 25 03:03:50 2008
@@ -319,6 +319,44 @@
1;
}
+
+{
+ my %options_by_tag = (
+ strict => 1,
+ xml => 1 << 6,
+ jit => 1 << 11,
+ );
+
+ sub get_options {
+ my ($self) = @_;
+ my $options = jsc_get_options($self->{_impl});
+ return grep { $options & $options_by_tag{$_} } keys %options_by_tag;
+ }
+
+ sub has_options {
+ my $self = shift;
+
+ my %options = map { $_ => 1 } $self->get_options;
+
+ !exists $options{$_} && return 0 for @_;
+
+ return 1;
+ }
+
+ sub toggle_options {
+ my $self = shift;
+
+ my $options = 0;
+ for (@_) {
+ $options |= 1 if exists $options_by_tag{lc $_};
+ }
+
+ jsc_toggle_options($self->{_impl}, $options);
+
+ 1;
+ }
+}
+
sub _destroy {
my $self = shift;
return unless $self->{'_impl'};
@@ -519,8 +557,42 @@
A list of these can be found at L<http://developer.mozilla.org/en/docs/JSVersion> but may vary
depending on the version of your runtime.
+=item get_options ( )
+
+Returns a list of the options currently enabled on the context.
+
+=item has_options ( OPTION, ... )
+
+Tests if the options are eneabled on the context.
+
+=item toggle_options ( OPTION, ... )
+
+Toggles the options on the context.
+
=back
+=head2 OPTIONS
+
+A number of options can be set on contexts. The following are understood (case-insensitive):
+
+=over 4
+
+=item strict
+
+Warn on dubious practice.
+
+=item xml
+
+ECMAScript for XML (E4X) support: parse E<lt>!-- --E<gt> as a token, not backward compatible with the comment-hiding hack used in HTML script tags.
+
+=item jit
+
+Enable JIT compilation. Requires a SpiderMonkey with TraceMonkey.
+
+=back
+
+(Descriptions copied from jsapi.h and thus copyrighted under its license)
+
=begin PRIVATE
=head1 PRIVATE INTERFACE
@@ -587,6 +659,14 @@
Set the version of the context to the one specified in version.
+=item jsc_get_options ( PJS_Context *context )
+
+Returns the options set on the undelying JSContext
+
+=item jsc_toggle_options ( PJS_Context *context, U32 options )
+
+Toggle the options on the underlying JSContext
+
=back
=end PRIVATE
More information about the Pkg-perl-cvs-commits
mailing list