r19708 - in /trunk/libjavascript-perl: Changes JavaScript.xs MANIFEST META.yml Makefile.PL PJS_Class.c PJS_TypeConversion.c README debian/changelog lib/JavaScript.pm lib/JavaScript/Context.pm t/04-prototypes.t t/05-deep-assign.t t/30-refcount.t t/lib/

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Thu May 8 19:39:01 UTC 2008


Author: gregoa
Date: Thu May  8 19:39:00 2008
New Revision: 19708

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=19708
Log:
New upstream release.

Added:
    trunk/libjavascript-perl/t/30-refcount.t
      - copied unchanged from r19707, branches/upstream/libjavascript-perl/current/t/30-refcount.t
    trunk/libjavascript-perl/t/lib/
      - copied from r19707, branches/upstream/libjavascript-perl/current/t/lib/
Modified:
    trunk/libjavascript-perl/Changes
    trunk/libjavascript-perl/JavaScript.xs
    trunk/libjavascript-perl/MANIFEST
    trunk/libjavascript-perl/META.yml
    trunk/libjavascript-perl/Makefile.PL
    trunk/libjavascript-perl/PJS_Class.c
    trunk/libjavascript-perl/PJS_TypeConversion.c
    trunk/libjavascript-perl/README
    trunk/libjavascript-perl/debian/changelog
    trunk/libjavascript-perl/lib/JavaScript.pm
    trunk/libjavascript-perl/lib/JavaScript/Context.pm
    trunk/libjavascript-perl/t/04-prototypes.t
    trunk/libjavascript-perl/t/05-deep-assign.t

Modified: trunk/libjavascript-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/Changes?rev=19708&op=diff
==============================================================================
--- trunk/libjavascript-perl/Changes (original)
+++ trunk/libjavascript-perl/Changes Thu May  8 19:39:00 2008
@@ -1,6 +1,19 @@
 Revision history for Perl extension JavaScript.
 
-1.06 ...
+1.08 Thu May 8 2008
+    - 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
+    - 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.
+    - bind_value (object|function) will now throw an error if the target already exists. [rt.cpan.org #35572]
+    - Added unbind_value to remove objects, functions and value from the context. [rt.cpan.org #35572]
+    - 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
     - 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 

Modified: trunk/libjavascript-perl/JavaScript.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/JavaScript.xs?rev=19708&op=diff
==============================================================================
--- trunk/libjavascript-perl/JavaScript.xs (original)
+++ trunk/libjavascript-perl/JavaScript.xs Thu May  8 19:39:00 2008
@@ -194,6 +194,34 @@
         RETVAL = val;
     OUTPUT:
         RETVAL
+
+void
+jsc_unbind_value(cx, parent, name)
+    PJS_Context     *cx;
+    char            *parent;
+    char            *name;
+    PREINIT:
+        jsval val, pval;
+        JSObject *gobj, *pobj;
+    CODE:
+        gobj = JS_GetGlobalObject(PJS_GetJSContext(cx));
+
+        if (strlen(parent)) {
+            JS_EvaluateScript(PJS_GetJSContext(cx), gobj, parent, strlen(parent), "", 1, &pval);
+            pobj = JSVAL_TO_OBJECT(pval);
+        }
+        else {
+            pobj = JS_GetGlobalObject(PJS_GetJSContext(cx));
+        }
+        /* TODO: Get property first and if it's an object decrease its refcount 
+        if (JS_GetProperty(PJS_GetJSContext(cx), pobj, name, &val) == JS_FALSE) {
+            croak("No property '%s' exists", name);
+        }
+        */
+        
+        if (JS_DeleteProperty(PJS_GetJSContext(cx), pobj, name) == JS_FALSE) {
+            croak("Failed to unbind %s", name);
+        }
 
 jsval 
 jsc_eval(cx, source, name)

Modified: trunk/libjavascript-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/MANIFEST?rev=19708&op=diff
==============================================================================
--- trunk/libjavascript-perl/MANIFEST (original)
+++ trunk/libjavascript-perl/MANIFEST Thu May  8 19:39:00 2008
@@ -63,7 +63,9 @@
 t/27-supports.t
 t/28-test-javascript-more.t
 t/29-exceptions.t
+t/30-refcount.t
 t/99-bottles-of-beer.t
+t/lib/DummyClass.pm
 t/pod-coverage.t
 t/pod.t
 typemap

Modified: trunk/libjavascript-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/META.yml?rev=19708&op=diff
==============================================================================
--- trunk/libjavascript-perl/META.yml (original)
+++ trunk/libjavascript-perl/META.yml Thu May  8 19:39:00 2008
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:                JavaScript
-version:             1.06
+version:             1.08
 abstract:            Perl extension for executing embedded JavaScript
 license:             perl
 author:              

Modified: trunk/libjavascript-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/Makefile.PL?rev=19708&op=diff
==============================================================================
--- trunk/libjavascript-perl/Makefile.PL (original)
+++ trunk/libjavascript-perl/Makefile.PL Thu May  8 19:39:00 2008
@@ -92,6 +92,7 @@
 # Override with $ENV{JS_LIB} and $ENV{JS_INC}
 if (exists $ENV{JS_LIB}) {
     @libs = get_paths($ENV{JS_LIB});
+    $ENV{DYLD_LIBRARY_PATH} = $ENV{LD_LIBRARY_PATH} = $ENV{JS_LIB};
     $lib = "js";
 }
 if (exists $ENV{JS_INC}) {
@@ -152,9 +153,10 @@
 
 close $header;
 
-# Try a small compile to determine if we can find libs and headers
-open my $test_script, ">test_js.c" || die $!;
-print $test_script <<'END_OF_SOURCE';
+unless ($ENV{JS_FORCE}) {
+    # Try a small compile to determine if we can find libs and headers
+    open(my $test_script, ">", "test_js.c") || die $!;
+    print $test_script <<'END_OF_SOURCE';
 #include <stdio.h>
 #include "JavaScript_Env.h"
 
@@ -162,26 +164,32 @@
     printf("%s", JS_GetImplementationVersion());
 }
 END_OF_SOURCE
-close $test_script;
-my $exe = tmpnam();
-system($Config{cc}, $libs, @ccflags, "-l${lib}", "-o", $exe, (map { "-I$_" } @incs), "test_js.c");
-if ($?) {
-    print "Failed compiling test_js.c. ABORTING\n";
-    exit 1;
-}
-unlink("test_js.c");
-
-# Get js version and require 1.7 or later
-my ($engine, $version, $date) = split/\s+/, qx($exe);
-my ($v2) = $version =~ /^(\d+\.\d+)/;
-if ($v2 < 1.7) {
-    if (prompt("I require SpiderMonkey version 1.7 or later but found ${version}. Try anyways? [y/N]", "N") ne "y") {
-        exit 1;
-    }
-}
-
-# Dispose temp stuff
-unlink($exe);
+    close $test_script;
+
+    my $exe = tmpnam();;
+    my $cc = join(" ", $Config{cc}, $libs, @ccflags, "-l${lib}", "-o", $exe, (map { "-I$_" } @incs), "test_js.c");
+    qx($cc);
+    if ($?) {
+        print "Failed compiling test_js.c. ABORTING\n";
+        exit 0;
+    }
+    unlink("test_js.c");
+
+    # Get js version and require 1.7 or later
+    my ($engine, $version, $date) = split/\s+/, qx($exe);
+    my ($v2) = $version =~ /^(\d+\.\d+)/;
+    if ($v2 < 1.7) {
+        if (prompt("I require SpiderMonkey version 1.7 or later but found ${version}. Try anyways? [y/N]", "N") ne "y") {
+            exit 0;
+        }
+    }
+
+    # Dispose temp stuff
+    unlink($exe);
+}
+else {
+    print "Skipping build test since JS_FORCE is set\n";
+}
 
 # Write makefile
 WriteMakefile(

Modified: trunk/libjavascript-perl/PJS_Class.c
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/PJS_Class.c?rev=19708&op=diff
==============================================================================
--- trunk/libjavascript-perl/PJS_Class.c (original)
+++ trunk/libjavascript-perl/PJS_Class.c Thu May  8 19:39:00 2008
@@ -172,7 +172,9 @@
     void *ptr = JS_GetPrivate(cx, obj);
 
     if(ptr != NULL) {
-        SvREFCNT_dec((SV *) ptr);
+        if (SvTYPE((SV *) ptr) == SVt_RV) {
+            SvREFCNT_dec(SvRV((SV *) ptr));
+        }
     }
 }
 

Modified: trunk/libjavascript-perl/PJS_TypeConversion.c
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/PJS_TypeConversion.c?rev=19708&op=diff
==============================================================================
--- trunk/libjavascript-perl/PJS_TypeConversion.c (original)
+++ trunk/libjavascript-perl/PJS_TypeConversion.c Thu May  8 19:39:00 2008
@@ -348,7 +348,6 @@
                    we need to turn this to use hidden property on object */
                 SV *priv = (SV *)JS_GetPrivate(cx, object);
                 if (priv && SvROK(priv)) {
-                    SvREFCNT_inc(priv);
                     sv_setsv(*sv, priv);
                     return JS_TRUE;
                 }

Modified: trunk/libjavascript-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/README?rev=19708&op=diff
==============================================================================
--- trunk/libjavascript-perl/README (original)
+++ trunk/libjavascript-perl/README Thu May  8 19:39:00 2008
@@ -51,6 +51,10 @@
 
 Where do look for headers and libraries can be specified using JS_LIB and JS_INC environment variables. They accept a colon (:) separated list.
 
+The Makefile.PL will try to build a small test to determine if the libraries and headers can be used as well as checking what 
+spidermonkey library is used. We require at least 1.7 but it *might* work on 1.6. If you don't want these test to be performed 
+set the environment variable JS_FORCE to a true value before running Makefile.PL.
+
 When ready invoke the following to build and install this module:
 
 > perl Makefile.PL

Modified: trunk/libjavascript-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/debian/changelog?rev=19708&op=diff
==============================================================================
--- trunk/libjavascript-perl/debian/changelog (original)
+++ trunk/libjavascript-perl/debian/changelog Thu May  8 19:39:00 2008
@@ -1,3 +1,9 @@
+libjavascript-perl (1.08-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- gregor herrmann <gregoa at debian.org>  Thu, 08 May 2008 21:36:48 +0200
+
 libjavascript-perl (1.06-2) unstable; urgency=low
 
   * debian/rules: touch Makefile before $(MAKE) realclean to avoid Makefile

Modified: trunk/libjavascript-perl/lib/JavaScript.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/lib/JavaScript.pm?rev=19708&op=diff
==============================================================================
--- trunk/libjavascript-perl/lib/JavaScript.pm (original)
+++ trunk/libjavascript-perl/lib/JavaScript.pm Thu May  8 19:39:00 2008
@@ -23,7 +23,7 @@
 
 our %EXPORT_TAGS = ( all => [@EXPORT_OK] );
 
-our $VERSION = '1.06';
+our $VERSION = '1.08';
 
 our $MAXBYTES = 1024 ** 2;
 
@@ -203,7 +203,7 @@
 
 =head1 LICENCE AND COPYRIGHT
 
-Copyright (c) 2001 - 2007, Claes Jakobsson C<< <claesjac at cpan.org> >>. All rights reserved.
+Copyright (c) 2001 - 2008, Claes Jakobsson C<< <claesjac at cpan.org> >>. All rights reserved.
 
 This module is free software; you can redistribute it and/or
 modify it under the same terms as Perl itself. See L<perlartistic>.

Modified: trunk/libjavascript-perl/lib/JavaScript/Context.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/lib/JavaScript/Context.pm?rev=19708&op=diff
==============================================================================
--- trunk/libjavascript-perl/lib/JavaScript/Context.pm (original)
+++ trunk/libjavascript-perl/lib/JavaScript/Context.pm Thu May  8 19:39:00 2008
@@ -271,12 +271,27 @@
         my $parent = join('.', @paths[0..$num-1]);
         my $abs = join('.', @paths[0..$num]);
 
-        next if $self->eval($abs);
+        if($self->eval($abs)) {
+            # We don't want to be able to rebind without unbinding first
+            croak "${name} already exists, unbind it first" if $num == $#paths;
+
+            next;
+        }
+        
         jsc_bind_value($self->{_impl}, $parent,
                        $paths[$num], $num == $#paths ? $object : {});
     }
     
     return;
+}
+
+sub unbind_value {
+    my ($self, $name, $object, $opt) = @_;
+
+    my @paths = split /\./, $name;
+    $name = pop @paths;
+    my $parent = join(".", @paths);
+    jsc_unbind_value($self->{_impl}, $parent, $name);
 }
 
 sub set_branch_handler {
@@ -432,7 +447,11 @@
 
 =item bind_value ( $name => $value )
 
-Defines a value with a given name and value.
+Defines a value with a given name and value. Trying to redefine an already existing property throws an exception.
+
+=item unbind_value ( $name )
+
+Removed a property from the context or a specified object.
 
 =item call ( $name, @arguments )
 
@@ -529,6 +548,10 @@
 
 Defines a new named property in I<parent> with the value of I<object>.
 
+=item jsc_unbind_value ( PJS_Context *context, char *parent, char *name)
+
+Removes a new named property in I<parent>.
+
 =item jsc_set_branch_handler ( PJS_Context *context, SV *handler )
 
 Attaches a branch handler to the context. No check is made to see if I<handler> is a valid SVt_PVCV.

Modified: trunk/libjavascript-perl/t/04-prototypes.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/t/04-prototypes.t?rev=19708&op=diff
==============================================================================
--- trunk/libjavascript-perl/t/04-prototypes.t (original)
+++ trunk/libjavascript-perl/t/04-prototypes.t Thu May  8 19:39:00 2008
@@ -13,7 +13,7 @@
 my $cx1 = $rt1->create_context();
 
 $cx1->bind_class(name => "foo",
-                constructor => sub {},
+                constructor => sub { },
                 package => 'main',
             );
 

Modified: trunk/libjavascript-perl/t/05-deep-assign.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjavascript-perl/t/05-deep-assign.t?rev=19708&op=diff
==============================================================================
--- trunk/libjavascript-perl/t/05-deep-assign.t (original)
+++ trunk/libjavascript-perl/t/05-deep-assign.t Thu May  8 19:39:00 2008
@@ -1,6 +1,6 @@
 #!perl
 
-use Test::More tests => 10;
+use Test::More tests => 18;
 
 use strict;
 use warnings;
@@ -27,3 +27,14 @@
 is( $cx1->eval(q!egg.yolk.spam!), 'got me?', "beans are off" );
 is( $cx1->eval(q!egg.spam.spam!), 'urrrgh', "beans are off" );
 
+throws_ok { $cx1->bind_value( 'spam' => "urrgh" ); } qr/spam already exists, unbind it first/;
+throws_ok { $cx1->bind_value( 'egg.yolk.spam' => "got me again?" ); } qr/egg.yolk.spam already exists, unbind it first/;
+
+lives_ok { $cx1->unbind_value("spam"); };
+lives_ok { $cx1->unbind_value("egg.yolk.spam") };
+
+lives_ok { $cx1->bind_value( spam => 1 ) };
+lives_ok { $cx1->bind_value( 'egg.yolk.spam' => 2 ) };
+
+is( $cx1->eval(q!spam!), 1, "got 1" );
+is( $cx1->eval(q!egg.yolk.spam!), 2, "got 2" );




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