r50281 - in /trunk/libjavascript-perl: CREDITS Changes JavaScript.xs META.yml Makefile.PL PJS_Call.c PJS_Exceptions.c PJS_PerlSub.c debian/changelog debian/copyright lib/JavaScript.pm lib/JavaScript/Context.pm t/29-exceptions.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Tue Jan 5 18:48:55 UTC 2010


Author: jawnsy-guest
Date: Tue Jan  5 18:48:49 2010
New Revision: 50281

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=50281
Log:
* New upstream release
* Refresh copyright to new DEP5 format

Modified:
    trunk/libjavascript-perl/CREDITS
    trunk/libjavascript-perl/Changes
    trunk/libjavascript-perl/JavaScript.xs
    trunk/libjavascript-perl/META.yml
    trunk/libjavascript-perl/Makefile.PL
    trunk/libjavascript-perl/PJS_Call.c
    trunk/libjavascript-perl/PJS_Exceptions.c
    trunk/libjavascript-perl/PJS_PerlSub.c
    trunk/libjavascript-perl/debian/changelog
    trunk/libjavascript-perl/debian/copyright
    trunk/libjavascript-perl/lib/JavaScript.pm
    trunk/libjavascript-perl/lib/JavaScript/Context.pm
    trunk/libjavascript-perl/t/29-exceptions.t

Modified: trunk/libjavascript-perl/CREDITS
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/CREDITS?rev=50281&op=diff
==============================================================================
--- trunk/libjavascript-perl/CREDITS (original)
+++ trunk/libjavascript-perl/CREDITS Tue Jan  5 18:48:49 2010
@@ -19,6 +19,7 @@
 Sergey Zhuravlev
 Apachez
 Dominic Mitchell
+Scott McWhirter
 
 -- And it wouldn't be possible without the extraordinary works by
 

Modified: trunk/libjavascript-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/Changes?rev=50281&op=diff
==============================================================================
--- trunk/libjavascript-perl/Changes (original)
+++ trunk/libjavascript-perl/Changes Tue Jan  5 18:48:49 2010
@@ -1,5 +1,11 @@
 Revision history for Perl extension JavaScript.
 
+1.15  2010-01-04
+	- It's now possible to set a pending exception in the context from Perl space (Scott McWhirter)
+	- can now set JS_LIB_NAME in environment prior to running perl Makefile.PL 
+	  so that different library name can be specified (James)
+	- binding a value explicitly unsets $@ after it tests to see if something has been bound. (James)
+	
 1.14  2009-12-01
 	- No functional changes, just a re-dist. (Damn you OS X for preserving resource forks when I don't want it...)
 	

Modified: trunk/libjavascript-perl/JavaScript.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/JavaScript.xs?rev=50281&op=diff
==============================================================================
--- trunk/libjavascript-perl/JavaScript.xs (original)
+++ trunk/libjavascript-perl/JavaScript.xs Tue Jan  5 18:48:49 2010
@@ -230,6 +230,25 @@
         RETVAL
 
 void
+jsc_set_pending_exception(cx, exception)
+    JavaScript::Context cx;
+    SV                  *exception;
+    PREINIT:
+        jsval       js_exception;
+        JSObject    *pobj;
+    CODE:
+        sv_setsv(ERRSV, &PL_sv_undef);
+        JS_ClearPendingException(PJS_GetJSContext(cx));
+        pobj = JS_GetGlobalObject(PJS_GetJSContext(cx));
+
+        if(PJS_ConvertPerlToJSType(PJS_GetJSContext(cx), NULL, pobj, exception, &js_exception) == JS_FALSE) {
+            js_exception = JSVAL_VOID;
+            XSRETURN_UNDEF;
+        }
+
+        JS_SetPendingException(PJS_GetJSContext(cx), js_exception);
+
+void
 jsc_unbind_value(cx, parent, name)
     JavaScript::Context cx;
     char                *parent;
@@ -287,8 +306,11 @@
         JS_DestroyScript(jcx, script);
 #else
         ok = JS_EvaluateScript(jcx, gobj, source, strlen(source), name, 1, &rval);
-        if (ok == JS_FALSE) {
+        if (ok == JS_FALSE || JS_IsExceptionPending(jcx) == JS_TRUE) {
             PJS_report_exception(cx);
+        }
+        else {
+            sv_setsv(ERRSV, &PL_sv_undef);
         }
 #endif
         if (ok == JS_FALSE) {

Modified: trunk/libjavascript-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/META.yml?rev=50281&op=diff
==============================================================================
--- trunk/libjavascript-perl/META.yml (original)
+++ trunk/libjavascript-perl/META.yml Tue Jan  5 18:48:49 2010
@@ -1,15 +1,25 @@
 --- #YAML:1.0
-name:                JavaScript
-version:             1.14
-abstract:            Perl extension for executing embedded JavaScript
-license:             perl
-author:              
+name:               JavaScript
+version:            1.15
+abstract:           Perl extension for executing embedded JavaScript
+author:
     - Claes Jakobsson <claesjac at cpan.org>
-generated_by:        ExtUtils::MakeMaker version 6.42
-distribution_type:   module
-requires:     
-    Test::Exception:               0
-    Test::More:                    0
+license:            perl
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    Test::Exception:  0
+    Test::More:       0
+resources:
+    repository:  svn://svn.versed.se/public/Perl/modules/JavaScript
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.56
 meta-spec:
-    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
-    version: 1.3
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Modified: trunk/libjavascript-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/Makefile.PL?rev=50281&op=diff
==============================================================================
--- trunk/libjavascript-perl/Makefile.PL (original)
+++ trunk/libjavascript-perl/Makefile.PL Tue Jan  5 18:48:49 2010
@@ -143,6 +143,8 @@
         push @defines, "JS_ENABLE_E4X";     
     }
 }
+
+if ($ENV{JS_LIB_NAME}) { $lib = $ENV{JS_LIB_NAME} }
 
 # Write JavaScript_Env.h
 open my $header, ">JavaScript_Env.h" || die $!;

Modified: trunk/libjavascript-perl/PJS_Call.c
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/PJS_Call.c?rev=50281&op=diff
==============================================================================
--- trunk/libjavascript-perl/PJS_Call.c (original)
+++ trunk/libjavascript-perl/PJS_Call.c Tue Jan  5 18:48:49 2010
@@ -130,7 +130,7 @@
     
     /* Clear $@ */
     sv_setsv(ERRSV, &PL_sv_undef);
-
+    
     av = (AV *) SvRV(args);
     arg_count = av_len(av);
 
@@ -155,7 +155,7 @@
         return JS_FALSE;
     }
 
-    return JS_TRUE;
+    return JS_IsExceptionPending(PJS_GetJSContext(pcx)) ? JS_FALSE : JS_TRUE;
 }
 
 JSBool perl_call_jsfunc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
@@ -169,7 +169,7 @@
     }
     
     code = JSVAL_TO_PRIVATE(tmp);
-    if (perl_call_sv_with_jsvals(cx, obj, code, NULL, argc, argv, rval) < 0) {
+    if (perl_call_sv_with_jsvals(cx, obj, code, NULL, argc, argv, rval) < 0 || JS_IsExceptionPending(cx)) {
         return JS_FALSE;
     }
     

Modified: trunk/libjavascript-perl/PJS_Exceptions.c
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/PJS_Exceptions.c?rev=50281&op=diff
==============================================================================
--- trunk/libjavascript-perl/PJS_Exceptions.c (original)
+++ trunk/libjavascript-perl/PJS_Exceptions.c Tue Jan  5 18:48:49 2010
@@ -18,7 +18,7 @@
     if (JSVALToSV(PJS_GetJSContext(pcx), NULL, val, &ERRSV) == JS_FALSE) {
         croak("Failed to convert error object to perl object");
     }
-
+    
     JS_ClearPendingException(PJS_GetJSContext(pcx));
     
     /* convert internal JS parser exceptions into JavaScript::Error objects. */

Modified: trunk/libjavascript-perl/PJS_PerlSub.c
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/PJS_PerlSub.c?rev=50281&op=diff
==============================================================================
--- trunk/libjavascript-perl/PJS_PerlSub.c (original)
+++ trunk/libjavascript-perl/PJS_PerlSub.c Tue Jan  5 18:48:49 2010
@@ -131,7 +131,7 @@
     if (self != NULL) {
         IV tmp = SvIV((SV *) SvRV((SV *) self));
         PJS_PerlSub *sub = INT2PTR(PJS_PerlSub *, tmp);
-        if (perl_call_sv_with_jsvals(cx, obj, sub->cv, NULL, argc, argv, rval) < 0) {
+        if (perl_call_sv_with_jsvals(cx, obj, sub->cv, NULL, argc, argv, rval) < 0 || JS_IsExceptionPending(cx)) {
             return JS_FALSE;
         }
         

Modified: trunk/libjavascript-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/debian/changelog?rev=50281&op=diff
==============================================================================
--- trunk/libjavascript-perl/debian/changelog (original)
+++ trunk/libjavascript-perl/debian/changelog Tue Jan  5 18:48:49 2010
@@ -1,3 +1,10 @@
+libjavascript-perl (1.15-1) UNRELEASED; urgency=low
+
+  * New upstream release
+  * Refresh copyright to new DEP5 format
+
+ -- Jonathan Yu <jawnsy at cpan.org>  Tue, 05 Jan 2010 13:48:11 -0500
+
 libjavascript-perl (1.14-1) unstable; urgency=low
 
   [ Jonathan Yu ]

Modified: trunk/libjavascript-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/debian/copyright?rev=50281&op=diff
==============================================================================
--- trunk/libjavascript-perl/debian/copyright (original)
+++ trunk/libjavascript-perl/debian/copyright Tue Jan  5 18:48:49 2010
@@ -1,34 +1,36 @@
-Format-Specification:
-    http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=196
-Upstream-Maintainer: Claes Jakobsson <claesjac at cpan.org>
-Upstream-Source: http://search.cpan.org/dist/JavaScript/
-Upstream-Name: JavaScript
+Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=59
+Maintainer: Claes Jakobsson <claesjac at cpan.org>
+Source: http://search.cpan.org/dist/JavaScript/
+Name: JavaScript
 
 Files: *
 Copyright: 2001-2008, Claes Jakobsson <claesjac at cpan.org>
-License-Alias: Perl
-License: Artistic | GPL-1+
-
-Files: lib/Test/JavaScript/More.pm
-Copyright: 2007, Fotango and Claes Jakobsson <claesjac at cpan.org>. 
-License-Alias: Perl
-License: Artistic | GPL-1+
+License: Artistic or GPL-1+
 
 Files: debian/*
-Copyright: 2004-2008, various members of the Debian Perl Group.
- Cf. debian/changelog for details.
-License: Artistic | GPL-1+
+Copyright: 2010, Jonathan Yu <jawnsy at cpan.org>
+ 2009, Tim Retout <tim at retout.co.uk>
+ 2008-2009, gregor herrmann <gregoa at debian.org>
+ 2005-2009, Krzysztof Krzyzaniak (eloy) <eloy at debian.org>
+ 2008, Niko Tyni <ntyni at debian.org>
+ 2008, Roberto C. Sanchez <roberto at connexer.com>
+ 2005-2007, Niko Tyni <ntyni at iki.fi>
+ 2004, Daniel Ruoso <daniel at ruoso.com>
+ 2004, Joachim Breitner <nomeata at debian.org>
+License: Artistic or GPL-1+
 
 License: Artistic
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the Artistic License, which comes with Perl.
-    On Debian GNU/Linux systems, the complete text of the Artistic License
-    can be found in /usr/share/common-licenses/Artistic
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the Artistic License, which comes with Perl.
+ .
+ On Debian GNU/Linux systems, the complete text of the Artistic License
+ can be found in `/usr/share/common-licenses/Artistic'
 
 License: GPL-1+
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by 
-    the Free Software Foundation; either version 1, or (at your option)
-    any later version.
-    On Debian GNU/Linux systems, the complete text of the GNU General
-    Public License can be found in `/usr/share/common-licenses/GPL'
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 1, or (at your option)
+ any later version.
+ .
+ On Debian GNU/Linux systems, the complete text of the GNU General
+ Public License can be found in `/usr/share/common-licenses/GPL'

Modified: trunk/libjavascript-perl/lib/JavaScript.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/lib/JavaScript.pm?rev=50281&op=diff
==============================================================================
--- trunk/libjavascript-perl/lib/JavaScript.pm (original)
+++ trunk/libjavascript-perl/lib/JavaScript.pm Tue Jan  5 18:48:49 2010
@@ -23,7 +23,7 @@
 
 our %EXPORT_TAGS = ( all => [@EXPORT_OK] );
 
-our $VERSION = "1.14";
+our $VERSION = "1.15";
 
 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=50281&op=diff
==============================================================================
--- trunk/libjavascript-perl/lib/JavaScript/Context.pm (original)
+++ trunk/libjavascript-perl/lib/JavaScript/Context.pm Tue Jan  5 18:48:49 2010
@@ -33,6 +33,17 @@
     $name ||= "$caller[0] line $caller[2]";
     
     my $rval = jsc_eval($self, $source, $name);
+
+    return $rval;
+}
+
+sub set_pending_exception {
+    my ($self, $exception) = @_;
+
+    if(!defined($exception)){
+        return;
+    }
+    my $rval = jsc_set_pending_exception($self, $exception); 
 
     return $rval;
 }
@@ -273,6 +284,8 @@
             croak "${name} already exists, unbind it first" if $num == $#paths;
 
             next;
+        } else {
+          $@ = undef;
         }
         
         jsc_bind_value($self, $parent,

Modified: trunk/libjavascript-perl/t/29-exceptions.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/t/29-exceptions.t?rev=50281&op=diff
==============================================================================
--- trunk/libjavascript-perl/t/29-exceptions.t (original)
+++ trunk/libjavascript-perl/t/29-exceptions.t Tue Jan  5 18:48:49 2010
@@ -11,7 +11,7 @@
     plan skip_all => "Engine version 1.7 or later require" if $version < 1.7;
 }
 
-plan tests => 17;
+plan tests => 26;
 
 my $runtime = new JavaScript::Runtime();
 my $context = $runtime->create_context();
@@ -117,8 +117,56 @@
 EOP
 is($@, "bar" );
 
+$ret =
+$context->eval(<<EOP);
+try {
+  throw "foo";
+}
+catch (e) {
+}
+1;
+EOP
+is($@, undef);
 
 $context->bind_class(constructor => sub { die "Can't create"; }, name => 'CantCreate');
 $ret = 
 $context->eval("var f = new CantCreate");
-like($@, qr/Can't create/);
+like($@, qr/Can't create/);
+
+$context->set_pending_exception("erple");
+$context->eval("function(){ }");
+like($@, qr/erple/);
+$context->eval("function(){ };\n");
+is($@, undef);
+
+$context->set_pending_exception();
+$context->eval("function(){ };\n");
+is($@, undef);
+
+{
+    my $thing = sub {
+        $context->set_pending_exception('bleh');
+    };
+    $context->bind_value(flibble => $thing);
+
+    $context->eval("flibble();\n");
+    like($@, qr{bleh});
+    $context->eval("flibble();\n");
+    like($@, qr{bleh});
+
+    $context->eval("function(){ };\n");
+    is($@, undef);
+    $context->eval("try { flibble(); } catch(e){ e = undefined }");
+    is($@, undef);
+}
+
+{
+    my $thing = sub {
+        $context->eval("throw 'yarghle';");
+        like($@, qr{yarghle});
+    };
+    $context->bind_value(yargh => $thing);
+    $context->eval("(function(){ yargh();})()");
+}
+
+undef $context;




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