r50277 - in /branches/upstream/libjavascript-perl/current: CREDITS Changes JavaScript.xs META.yml Makefile.PL PJS_Call.c PJS_Exceptions.c PJS_PerlSub.c 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:44:31 UTC 2010


Author: jawnsy-guest
Date: Tue Jan  5 18:44:25 2010
New Revision: 50277

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

Modified:
    branches/upstream/libjavascript-perl/current/CREDITS
    branches/upstream/libjavascript-perl/current/Changes
    branches/upstream/libjavascript-perl/current/JavaScript.xs
    branches/upstream/libjavascript-perl/current/META.yml
    branches/upstream/libjavascript-perl/current/Makefile.PL
    branches/upstream/libjavascript-perl/current/PJS_Call.c
    branches/upstream/libjavascript-perl/current/PJS_Exceptions.c
    branches/upstream/libjavascript-perl/current/PJS_PerlSub.c
    branches/upstream/libjavascript-perl/current/lib/JavaScript.pm
    branches/upstream/libjavascript-perl/current/lib/JavaScript/Context.pm
    branches/upstream/libjavascript-perl/current/t/29-exceptions.t

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

Modified: branches/upstream/libjavascript-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/Changes?rev=50277&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/Changes (original)
+++ branches/upstream/libjavascript-perl/current/Changes Tue Jan  5 18:44:25 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: branches/upstream/libjavascript-perl/current/JavaScript.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/JavaScript.xs?rev=50277&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/JavaScript.xs (original)
+++ branches/upstream/libjavascript-perl/current/JavaScript.xs Tue Jan  5 18:44:25 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: branches/upstream/libjavascript-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/META.yml?rev=50277&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/META.yml (original)
+++ branches/upstream/libjavascript-perl/current/META.yml Tue Jan  5 18:44:25 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: branches/upstream/libjavascript-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/Makefile.PL?rev=50277&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/Makefile.PL (original)
+++ branches/upstream/libjavascript-perl/current/Makefile.PL Tue Jan  5 18:44:25 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: branches/upstream/libjavascript-perl/current/PJS_Call.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/PJS_Call.c?rev=50277&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_Call.c (original)
+++ branches/upstream/libjavascript-perl/current/PJS_Call.c Tue Jan  5 18:44:25 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: branches/upstream/libjavascript-perl/current/PJS_Exceptions.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/PJS_Exceptions.c?rev=50277&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_Exceptions.c (original)
+++ branches/upstream/libjavascript-perl/current/PJS_Exceptions.c Tue Jan  5 18:44:25 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: branches/upstream/libjavascript-perl/current/PJS_PerlSub.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/PJS_PerlSub.c?rev=50277&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_PerlSub.c (original)
+++ branches/upstream/libjavascript-perl/current/PJS_PerlSub.c Tue Jan  5 18:44:25 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: 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=50277&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/lib/JavaScript.pm (original)
+++ branches/upstream/libjavascript-perl/current/lib/JavaScript.pm Tue Jan  5 18:44:25 2010
@@ -23,7 +23,7 @@
 
 our %EXPORT_TAGS = ( all => [@EXPORT_OK] );
 
-our $VERSION = "1.14";
+our $VERSION = "1.15";
 
 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=50277&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/lib/JavaScript/Context.pm (original)
+++ branches/upstream/libjavascript-perl/current/lib/JavaScript/Context.pm Tue Jan  5 18:44:25 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: branches/upstream/libjavascript-perl/current/t/29-exceptions.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/t/29-exceptions.t?rev=50277&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/t/29-exceptions.t (original)
+++ branches/upstream/libjavascript-perl/current/t/29-exceptions.t Tue Jan  5 18:44:25 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