r24032 - in /branches/upstream/libjavascript-perl/current: ./ dev_tests/ lib/ lib/JavaScript/ lib/Test/JavaScript/ t/

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Sat Aug 9 23:28:16 UTC 2008


Author: gregoa
Date: Sat Aug  9 23:28:07 2008
New Revision: 24032

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=24032
Log:
[svn-upgrade] Integrating new upstream version, libjavascript-perl (1.09)

Added:
    branches/upstream/libjavascript-perl/current/dev_tests/
    branches/upstream/libjavascript-perl/current/dev_tests/bad_eval.pl
    branches/upstream/libjavascript-perl/current/dev_tests/bind_value.pl
    branches/upstream/libjavascript-perl/current/dev_tests/cx_leaktest.pl
    branches/upstream/libjavascript-perl/current/dev_tests/leaktest.pl
    branches/upstream/libjavascript-perl/current/dev_tests/memory_consumption.pl
    branches/upstream/libjavascript-perl/current/dev_tests/refs.pl
    branches/upstream/libjavascript-perl/current/dev_tests/returns.pl
    branches/upstream/libjavascript-perl/current/dev_tests/roundtrip.pl
    branches/upstream/libjavascript-perl/current/t/31-version.t
Modified:
    branches/upstream/libjavascript-perl/current/Changes
    branches/upstream/libjavascript-perl/current/JavaScript.xs
    branches/upstream/libjavascript-perl/current/MANIFEST
    branches/upstream/libjavascript-perl/current/META.yml
    branches/upstream/libjavascript-perl/current/PJS_Context.c
    branches/upstream/libjavascript-perl/current/PJS_Context.h
    branches/upstream/libjavascript-perl/current/lib/JavaScript.pm
    branches/upstream/libjavascript-perl/current/lib/JavaScript/Context.pm
    branches/upstream/libjavascript-perl/current/lib/JavaScript/Runtime.pm
    branches/upstream/libjavascript-perl/current/lib/Test/JavaScript/More.pm
    branches/upstream/libjavascript-perl/current/typemap

Modified: branches/upstream/libjavascript-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/Changes?rev=24032&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/Changes (original)
+++ branches/upstream/libjavascript-perl/current/Changes Sat Aug  9 23:28:07 2008
@@ -1,10 +1,17 @@
 Revision history for Perl extension JavaScript.
 
-1.08 Thu May 8 2008
+1.09  2008-08-03
+    - It's now possible to set and get the version of JS our context is dealing with since in
+      some cases such as using 'let' and 'yield' we actually have to specify that we want
+      1.7 features.
+    - Fix a bunch of small pod issues. [rt.cpan.org #30333]
+    - Fix Changes (this file) to use ISO 8601 dates
+    
+1.08  2008-05-08
     - Fixes Makefile.PL issues which made it fail on various platforms when trying to compile test app.
     - Added option to skip building of test app. Set environment variable JS_FORCE to a true value.
     
-1.07 Tue May 6 2008
+1.07  2008-05-06
     - Makefile.PL should abort with exit code 0 if conditions are not met instead of exit code 1.
     - Don't increase refcount for object originating from Perl (James Duncan).
     - Make bind_value croak if trying to rebind an already existing property.
@@ -13,13 +20,13 @@
     - Fix longtime memory leak caused by decreasing refcount on RV instead of on the 
       SV the RV references. [rt.cpan.org #35571]
     
-1.06 Fri Apr 18 2008
+1.06  2008-04-18
     - Objects returned when creating constructor for bound classes should not increment
       refcount because this causes the objects to never be freed (James Duncan)
     - Docs stated argument constructor could be omitted in bind_class which wasn't the case and 
       so now it can and a default constructor will be created.
       
-1.05 Tue Apr 1 2008
+1.05  2008-04-01
     - Drop support for error handlers
     - This module now requires SpiderMonkey 1.7 or later.
     - Makefile.PL now compiles a small test to see if libs and headers can be found
@@ -27,7 +34,7 @@
     - Drop support for Perl 5.6.x and earlier because we need some API symbols not available there 
       and they don't support unicode properly either. [rt.cpan.org #31114]
       
-1.04 Sat Nov 17 2007
+1.04  2007-11-17
     - Skip exception tests on engines less than 1.7 since these seem to be broken.
     - Free memory allocated by JS_smprintf when converting from utf8 strings (spotted by Ash Berlin)
     - Don't call js_ValueToXMLString but instead call JS method "toXMLString" on the object [rt.cpan.org #26411]
@@ -45,7 +52,7 @@
     - Split up giant .XS file into smaller pieces
     - Added CREDITS to MANIFEST so it's bundled with the distribution
     
-1.03 Wed Feb 21 2007
+1.03  2007-02-21
     - Honor value of JS_ENABLE_E4X
     - Improved README
     - Added CREDITS
@@ -64,27 +71,27 @@
     - Allow building with debug symbols (set JS_DEBUG to a true value) (Fotango)
     - Allow setting JS_THREADSAFE and JS_UTF8 to true/false to avoid the prompts (Fotango)
 
-1.02 Mon Feb 12 2007
+1.02  2007-02-17
     - Makefile.PL now generates a JavaScript_Env.h that sets correct defines and includes correct headers
     - Structs, macros etc are now in a JavaScript.h
     - Header files and typemap is now installed with module
     - Added ext field (void *) to PJS_Runtime and PJS_Context that can be used custom stuff
             
-1.01 Mon Feb 12 2007
+1.01  2007-02-12
     - Added support for detecting DarwinPorts [rt.cpan.org #14910]
     - Added missing test for converting JavaScript booleans -> Perl
     - Integrated patch that fixes compilation problems on Debian (Toru Yamaguchi, Daniel Burke)
     - Cleaned up TODO
 
-1.00 Mon Sep 4 2006
+1.00  2006-09-04
     - Release of 1.00
 
-1.00_02 Sat Aug 19 2006
+1.00_02  2006-08-19
     - Incorporated patch to support new SpiderMokey installation-scheme in Debian [rt.cpan.org #18152]
     - Passing ERRSV to SVToJSVAL doesn't seem to be safe so we'll pass a copy instead (Tom Insam)
     - Cleaning up some internal function names
 
-1.00_01 Tue Jul 11 2006
+1.00_01  2006-07-11
     - Fixed invocation of methods on objects
     - Added support for "static" methods of classes, i.e. "Test.foo(...)" should now work
     - Added support for "static" properties of classes, i.e. "Test.bar = 10"; should now work
@@ -101,13 +108,13 @@
         - Lots or more tests
         - And lots more
 
-0.55 Wed Jun 30 9:05:00 CET 2005
+0.55  2005-06-30
     - Fixed error handling (patch by G. Allen Morris III)
 
-0.54 Tue Jun 29 11:50:00 CET 2005
+0.54  2005-06-29
     - Make Makefile.PL play happy games with Gentoo (patch by sungo)
 
-0.53 Fri Mar 18 19:49:25 CET 2005 (Joost Diepenmaat)
+0.53  2005-03-18
     - Added JS_THREADSAFE define, which fixed bug on perl 5.8.5
       thread-multi linux
     - added tests for debian spidermonkey libs (debian users can
@@ -119,20 +126,20 @@
       to run on perl 5.8.6 threaded and unthreaded)
     - Fixed a couple of alloc()s
     
-0.52 Sat Aug 11 22:47:00 2001
+0.52  2001-08-11
     - Added can method to JavaScript::Context
     - Removed the need of passing the JSClass name to bind_object
     - Fixed issues with package
     - Fixed return from call
     - Brought docs up to sync with implementation
 
-0.51 Thu Jul 26 12:01:00 2001
+0.51  2001-07-26
     - Changed new_context to create_context to match documentation
     - Changed create_context to not try and take named arguments
 
-0.5 Wed Jul 25 14:20:10 2001
+0.5   2001-06-25
     - First public release
     
-0.01 Mon Mar 19 09:51:10 2001
+0.01  2001-03-19
     - original version; created by h2xs 1.21 with options
         -f -n JavaScript

Modified: branches/upstream/libjavascript-perl/current/JavaScript.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/JavaScript.xs?rev=24032&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/JavaScript.xs (original)
+++ branches/upstream/libjavascript-perl/current/JavaScript.xs Sat Aug  9 23:28:07 2008
@@ -3,6 +3,10 @@
 #include "XSUB.h"
 
 #include "JavaScript.h"
+
+#ifndef FUN_OBJECT(fun)
+#define FUN_OBJECT(fun) (jsval)(fun->object)
+#endif
 
 MODULE = JavaScript     PACKAGE = JavaScript
 PROTOTYPES: DISABLE
@@ -119,6 +123,21 @@
     OUTPUT:
         RETVAL
 
+const char *
+jsc_get_version(cx)
+    PJS_Context *cx;
+    CODE:
+        RETVAL = JS_VersionToString(JS_GetVersion(PJS_GetJSContext(cx)));
+    OUTPUT:
+        RETVAL
+
+void
+jsc_set_version(cx, version)
+    PJS_Context *cx;
+    const char *version;
+    CODE:
+        JS_SetVersion(PJS_GetJSContext(cx), JS_StringToVersion(version));
+        
 void
 jsc_set_branch_handler(cx, handler)
     PJS_Context *cx;
@@ -294,7 +313,7 @@
             tmp = SvIV((SV*)SvRV(PJS_call_perl_method("content", function, NULL)));
             func = INT2PTR(JSFunction *, tmp);
 
-            if (PJS_call_javascript_function(cx, (jsval) (func->object), args, &rval) == JS_FALSE) {
+            if (PJS_call_javascript_function(cx, FUN_OBJECT(func), args, &rval) == JS_FALSE) {
                 /* Exception was thrown */
                 XSRETURN_UNDEF;
             }

Modified: branches/upstream/libjavascript-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/MANIFEST?rev=24032&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/MANIFEST (original)
+++ branches/upstream/libjavascript-perl/current/MANIFEST Sat Aug  9 23:28:07 2008
@@ -26,6 +26,14 @@
 PJS_Types.h
 README
 TODO
+dev_tests/bad_eval.pl
+dev_tests/bind_value.pl
+dev_tests/cx_leaktest.pl
+dev_tests/leaktest.pl
+dev_tests/memory_consumption.pl
+dev_tests/refs.pl
+dev_tests/returns.pl
+dev_tests/roundtrip.pl
 lib/JavaScript.pm
 lib/JavaScript/Boxed.pm
 lib/JavaScript/Context.pm
@@ -64,6 +72,7 @@
 t/28-test-javascript-more.t
 t/29-exceptions.t
 t/30-refcount.t
+t/31-version.t
 t/99-bottles-of-beer.t
 t/lib/DummyClass.pm
 t/pod-coverage.t

Modified: branches/upstream/libjavascript-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/META.yml?rev=24032&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/META.yml (original)
+++ branches/upstream/libjavascript-perl/current/META.yml Sat Aug  9 23:28:07 2008
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:                JavaScript
-version:             1.08
+version:             1.09
 abstract:            Perl extension for executing embedded JavaScript
 license:             perl
 author:              

Modified: branches/upstream/libjavascript-perl/current/PJS_Context.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/PJS_Context.c?rev=24032&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_Context.c (original)
+++ branches/upstream/libjavascript-perl/current/PJS_Context.c Sat Aug  9 23:28:07 2008
@@ -221,11 +221,11 @@
     return status;
 }
 
-JSContext *
+/*JSContext *
 PJS_GetJSContext(PJS_Context *fromContext) {
     if (fromContext != NULL) {
         return fromContext->cx;
     }
     
     return NULL;
-}
+}*/

Modified: branches/upstream/libjavascript-perl/current/PJS_Context.h
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/PJS_Context.h?rev=24032&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_Context.h (original)
+++ branches/upstream/libjavascript-perl/current/PJS_Context.h Sat Aug  9 23:28:07 2008
@@ -88,8 +88,10 @@
     @param fromContext The context to search in
     @result A pointer to the underlying JSContext
 */
-PJS_EXTERN JSContext *
-PJS_GetJSContext(PJS_Context *fromContext);
+#define PJS_GetJSContext(fromContext) (fromContext->cx)
+
+/*PJS_EXTERN JSContext *
+PJS_GetJSContext(PJS_Context *fromContext);*/
 
 /*! @function PJS_GetClassByName
     @abstract Retrieve a bound class from a context

Added: branches/upstream/libjavascript-perl/current/dev_tests/bad_eval.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/dev_tests/bad_eval.pl?rev=24032&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/dev_tests/bad_eval.pl (added)
+++ branches/upstream/libjavascript-perl/current/dev_tests/bad_eval.pl Sat Aug  9 23:28:07 2008
@@ -1,0 +1,9 @@
+#!/usr/bin/perl
+
+use JavaScript;
+
+my $rt = JavaScript::Runtime->new();
+my $cx = $rt->create_context();
+$cx->eval( "foo } bar {" );
+warn $@;
+

Added: branches/upstream/libjavascript-perl/current/dev_tests/bind_value.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/dev_tests/bind_value.pl?rev=24032&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/dev_tests/bind_value.pl (added)
+++ branches/upstream/libjavascript-perl/current/dev_tests/bind_value.pl Sat Aug  9 23:28:07 2008
@@ -1,0 +1,19 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use JavaScript;
+
+my $rt = JavaScript::Runtime->new();
+my $cx = $rt->create_context();
+
+$cx->bind_function(write => sub { print @_, "\n"; });
+
+$cx->eval("foo = 1; write(foo)");
+
+$cx->bind_value(foo => 10);
+
+$cx->eval("write(foo)");
+
+JavaScript::dump_sv_report_used();

Added: branches/upstream/libjavascript-perl/current/dev_tests/cx_leaktest.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/dev_tests/cx_leaktest.pl?rev=24032&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/dev_tests/cx_leaktest.pl (added)
+++ branches/upstream/libjavascript-perl/current/dev_tests/cx_leaktest.pl Sat Aug  9 23:28:07 2008
@@ -1,0 +1,80 @@
+#!perl
+
+use strict;
+use warnings;
+use Devel::Leak::Object qw(GLOBAL_bless);
+use JavaScript qw(:all);
+
+{
+  package ThisObjectWillLeak;
+
+  sub new {
+    my($class, $num) = @_;
+    return bless { n => $num }, $class;
+  }
+
+  sub whoami {
+    my $self = shift;
+    return "Leaky object #$self->{n}";
+  }
+}
+
+{
+  package ThisObjectWillNotLeak;
+
+  sub new {
+    my($class, $num) = @_;
+    return bless { n => $num }, $class;
+  }
+
+  sub whoami {
+    my $self = shift;
+    return "Sealed object #$self->{n}";
+  }
+}
+
+our $rt;
+our $cx;
+
+sub dont_leak_an_object {
+  my $sealed = ThisObjectWillNotLeak->new(shift);
+  $cx->bind_object(sealed => $sealed);
+  return;
+}
+
+sub leak_an_object {
+  my $leaky = ThisObjectWillLeak->new(shift);
+  return $leaky;
+}
+
+sub write {
+  my $msg = shift;
+  print "$msg\n";
+}
+
+foreach my $cxloop (1 .. 5) {
+  print "Context #$cxloop\n";
+  $rt = JavaScript::Runtime->new;
+  $cx = JavaScript::Context->new($rt);
+
+  foreach my $i ('ThisObjectWillLeak', 'ThisObjectWillNotLeak') {
+    $cx->bind_class(
+      name => $i,
+      constructor => sub {},
+      methods => { whoami => $i->can('whoami') },
+      flags => JS_CLASS_NO_INSTANCE,
+      package => $i
+    );
+  }
+
+  $cx->bind_function(leak_an_object => \&leak_an_object);
+  $cx->bind_function(dont_leak_an_object => \&dont_leak_an_object);
+  $cx->bind_function(write => \&write);
+
+  foreach my $i (1 .. 10) {
+    $cx->eval("leaky = leak_an_object($i)");
+    $cx->eval("dont_leak_an_object($i)");
+    $cx->eval("write(leaky.whoami())");
+    $cx->eval("write(sealed.whoami())");
+  }
+}

Added: branches/upstream/libjavascript-perl/current/dev_tests/leaktest.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/dev_tests/leaktest.pl?rev=24032&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/dev_tests/leaktest.pl (added)
+++ branches/upstream/libjavascript-perl/current/dev_tests/leaktest.pl Sat Aug  9 23:28:07 2008
@@ -1,0 +1,76 @@
+#!perl
+
+use strict;
+use warnings;
+use Devel::Leak::Object qw(GLOBAL_bless);
+use JavaScript qw(:all);
+
+{
+  package ThisObjectWillLeak;
+
+  sub new {
+    my($class, $num) = @_;
+    return bless { n => $num }, $class;
+  }
+
+  sub whoami {
+    my $self = shift;
+    return "Leaky object #$self->{n}";
+  }
+}
+
+{
+  package ThisObjectWillNotLeak;
+
+  sub new {
+    my($class, $num) = @_;
+    return bless { n => $num }, $class;
+  }
+
+  sub whoami {
+    my $self = shift;
+    return "Sealed object #$self->{n}";
+  }
+}
+
+our $rt = JavaScript::Runtime->new;
+our $cx = JavaScript::Context->new($rt);
+
+sub dont_leak_an_object {
+  my $sealed = ThisObjectWillNotLeak->new(shift);
+  $cx->bind_object(sealed => $sealed);
+  return;
+}
+
+sub leak_an_object {
+  my $leaky = ThisObjectWillLeak->new(shift);
+  return $leaky;
+}
+
+sub write {
+  my $msg = shift;
+  print "$msg\n";
+}
+
+foreach my $i ('ThisObjectWillLeak', 'ThisObjectWillNotLeak') {
+  $cx->bind_class(
+    name => $i,
+    constructor => sub {},
+    methods => { whoami => $i->can('whoami') },
+    flags => JS_CLASS_NO_INSTANCE,
+    package => $i
+  );
+}
+
+$cx->bind_function(leak_an_object => \&leak_an_object);
+$cx->bind_function(dont_leak_an_object => \&dont_leak_an_object);
+$cx->bind_function(write => \&write);
+
+foreach my $i (1 .. 10) {
+  $cx->eval("leaky = leak_an_object($i)");
+  $cx->eval("dont_leak_an_object($i)");
+  $cx->eval("write(leaky.whoami())");
+  $cx->eval("write(sealed.whoami())");
+}
+
+JavaScript::dump_sv_report_used();

Added: branches/upstream/libjavascript-perl/current/dev_tests/memory_consumption.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/dev_tests/memory_consumption.pl?rev=24032&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/dev_tests/memory_consumption.pl (added)
+++ branches/upstream/libjavascript-perl/current/dev_tests/memory_consumption.pl Sat Aug  9 23:28:07 2008
@@ -1,0 +1,29 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use JavaScript;
+
+print $$, "\n";
+
+my $rt = JavaScript::Runtime->new();
+my $cx = $rt->create_context();
+
+my $r = {};
+$cx->bind_function(returns_array_ref => sub { return [1..10]; });
+$cx->bind_function(writeln => sub { print @_, "\n" });
+
+{
+    $cx->eval(q/
+for (var i = 0; i < 200001; i++) {
+    var v = returns_array_ref();
+    if (i % 10000 == 0) {
+        writeln("Created " + i + " array refs");
+    }
+}
+/);
+}
+
+# Wait for ok
+<>;

Added: branches/upstream/libjavascript-perl/current/dev_tests/refs.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/dev_tests/refs.pl?rev=24032&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/dev_tests/refs.pl (added)
+++ branches/upstream/libjavascript-perl/current/dev_tests/refs.pl Sat Aug  9 23:28:07 2008
@@ -1,0 +1,17 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Devel::Peek qw(Dump);
+use JavaScript;
+
+my $v = {};
+
+my $rt = JavaScript::Runtime->new();
+my $cx = $rt->create_context();
+
+$cx->bind_function(dump => sub { my $y = shift;  });
+$cx->call(dump => {});
+
+JavaScript::dump_sv_report_used();

Added: branches/upstream/libjavascript-perl/current/dev_tests/returns.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/dev_tests/returns.pl?rev=24032&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/dev_tests/returns.pl (added)
+++ branches/upstream/libjavascript-perl/current/dev_tests/returns.pl Sat Aug  9 23:28:07 2008
@@ -1,0 +1,13 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use JavaScript;
+
+my $rt = JavaScript::Runtime->new();
+my $cx = $rt->create_context();
+
+$cx->bind_function(return_simple => sub { []; });
+
+$cx->eval("v = return_simple(); undef");

Added: branches/upstream/libjavascript-perl/current/dev_tests/roundtrip.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/dev_tests/roundtrip.pl?rev=24032&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/dev_tests/roundtrip.pl (added)
+++ branches/upstream/libjavascript-perl/current/dev_tests/roundtrip.pl Sat Aug  9 23:28:07 2008
@@ -1,0 +1,62 @@
+use strict;
+use warnings;
+use JavaScript;
+
+my $rt = JavaScript::Runtime->new;
+my $cx = $rt->create_context;
+
+$cx->bind_class(
+ 'package'   => 'Foo',
+ 'name'      => 'Foo',
+ constructor => sub {
+   return Foo->new;
+ },
+ properties        => {},
+ static_methods    => {
+   'list' => sub { my $self = shift; return $self->list; },
+ }
+);
+
+{
+ my $fn = $cx->eval("function t() { return Foo.list();  } t;" );
+ my $v = $fn->();
+ use Devel::Peek qw(Dump);
+
+ Dump($v);
+ 
+ my $v2 = Foo->list();
+ Dump($v2);
+ 
+}
+
+print "destruction should be done\n";
+
+sub END {
+ print "should be really done now\n";
+}
+
+package Foo;
+
+sub new {
+ my $class = shift;
+ my $self  = {};
+ #$one ||=
+ bless $self, $class;
+}
+
+sub list {
+ my $class = shift;
+ my @objs;
+ for (1..2) {
+   push @objs, $class->new;
+ }
+# return [{}];
+ return \@objs;
+}
+
+sub DESTROY {
+ print "object going boom!\n";
+}
+
+JavaScript::dump_sv_report_used();
+1;

Modified: branches/upstream/libjavascript-perl/current/lib/JavaScript.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/lib/JavaScript.pm?rev=24032&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/lib/JavaScript.pm (original)
+++ branches/upstream/libjavascript-perl/current/lib/JavaScript.pm Sat Aug  9 23:28:07 2008
@@ -23,7 +23,7 @@
 
 our %EXPORT_TAGS = ( all => [@EXPORT_OK] );
 
-our $VERSION = '1.08';
+our $VERSION = '1.09';
 
 our $MAXBYTES = 1024 ** 2;
 

Modified: branches/upstream/libjavascript-perl/current/lib/JavaScript/Context.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/lib/JavaScript/Context.pm?rev=24032&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/lib/JavaScript/Context.pm (original)
+++ branches/upstream/libjavascript-perl/current/lib/JavaScript/Context.pm Sat Aug  9 23:28:07 2008
@@ -310,6 +310,17 @@
     return $script;
 }
 
+sub get_version {
+    my ($self, $version) = @_;
+    return jsc_get_version($self->{_impl});
+}
+
+sub set_version {
+    my ($self, $version) = @_;
+    jsc_set_version($self->{_impl}, $version);
+    1;
+}
+
 sub _destroy {
     my $self = shift;
     return unless $self->{'_impl'};
@@ -496,6 +507,19 @@
 
 The handler is called when a script branches backwards during execution, when a function returns and the end of the script. To continue execution the handler must return a true value. To abort execution either throw an exception or return a false value.
 
+=item get_version ( )
+
+Returns the runtime version of the context as a string, for exmaple C<1.7> or or C<ECMAv3>.
+
+=item set_version ( $version )
+
+Sets the runtime version of the context to that specified in the string I<$version>. Some features 
+such as C<let> and C<yield> might not be enabled by default and thus must be turned on by 
+specifying what JS version we're using.
+
+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.
+
 =back
 
 =begin PRIVATE
@@ -556,6 +580,14 @@
 
 Attaches a branch handler to the context. No check is made to see if I<handler> is a valid SVt_PVCV.
 
+=item jsc_get_version ( PJS_Context *context )
+
+Returns the version of the context as a string, for example "1.7"
+
+=item jsc_set_version ( PJS_Context *context, const char *version) 
+
+Set the version of the context to the one specified in version.
+
 =back
 
 =end PRIVATE

Modified: branches/upstream/libjavascript-perl/current/lib/JavaScript/Runtime.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/lib/JavaScript/Runtime.pm?rev=24032&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/lib/JavaScript/Runtime.pm (original)
+++ branches/upstream/libjavascript-perl/current/lib/JavaScript/Runtime.pm Sat Aug  9 23:28:07 2008
@@ -124,7 +124,7 @@
 
 =head1 NAME
 
-JavaScript::Runtime -
+JavaScript::Runtime - Runs contexts
 
 =head1 DESCRIPTION
 

Modified: branches/upstream/libjavascript-perl/current/lib/Test/JavaScript/More.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/lib/Test/JavaScript/More.pm?rev=24032&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/lib/Test/JavaScript/More.pm (original)
+++ branches/upstream/libjavascript-perl/current/lib/Test/JavaScript/More.pm Sat Aug  9 23:28:07 2008
@@ -112,6 +112,7 @@
 1;
 
 __END__
+
 =head1 NAME
 
 Test::JavaScript::More - test javascript code

Added: branches/upstream/libjavascript-perl/current/t/31-version.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/t/31-version.t?rev=24032&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/t/31-version.t (added)
+++ branches/upstream/libjavascript-perl/current/t/31-version.t Sat Aug  9 23:28:07 2008
@@ -1,0 +1,35 @@
+#!perl
+
+use Test::More tests => 4;
+
+use strict;
+use warnings;
+
+use JavaScript;
+
+my $rt = JavaScript::Runtime->new();
+my $cx = $rt->create_context();
+
+my $v = $cx->get_version();
+
+my $src = q/
+var x = 5;
+var y = 0;
+
+let (x = x + 10, y = 12) {
+    v = x + y;
+};
+/;
+
+$cx->eval($src);
+ok($@);
+
+$cx->set_version("1.7");
+$v = $cx->get_version();
+is($v, "1.7");
+$cx->eval($src);
+ok(!$@);
+
+$cx->set_version("1.5");
+$v = $cx->get_version();
+is($v, "1.5");

Modified: branches/upstream/libjavascript-perl/current/typemap
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/typemap?rev=24032&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/typemap (original)
+++ branches/upstream/libjavascript-perl/current/typemap Sat Aug  9 23:28:07 2008
@@ -7,6 +7,7 @@
 jsval                   jsval
 
 OUTPUT
+
 jsval
     {
         SV *orz = sv_newmortal();




More information about the Pkg-perl-cvs-commits mailing list