r19706 - in /branches/upstream/libjavascript-perl/current: ./ lib/ lib/JavaScript/ t/ t/lib/
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Thu May 8 19:36:14 UTC 2008
Author: gregoa
Date: Thu May 8 19:36:14 2008
New Revision: 19706
URL: http://svn.debian.org/wsvn/?sc=1&rev=19706
Log:
[svn-upgrade] Integrating new upstream version, libjavascript-perl (1.08)
Added:
branches/upstream/libjavascript-perl/current/t/30-refcount.t
branches/upstream/libjavascript-perl/current/t/lib/
branches/upstream/libjavascript-perl/current/t/lib/DummyClass.pm
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/Makefile.PL
branches/upstream/libjavascript-perl/current/PJS_Class.c
branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c
branches/upstream/libjavascript-perl/current/README
branches/upstream/libjavascript-perl/current/lib/JavaScript.pm
branches/upstream/libjavascript-perl/current/lib/JavaScript/Context.pm
branches/upstream/libjavascript-perl/current/t/04-prototypes.t
branches/upstream/libjavascript-perl/current/t/05-deep-assign.t
Modified: branches/upstream/libjavascript-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/Changes?rev=19706&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/Changes (original)
+++ branches/upstream/libjavascript-perl/current/Changes Thu May 8 19:36:14 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: branches/upstream/libjavascript-perl/current/JavaScript.xs
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/JavaScript.xs?rev=19706&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/JavaScript.xs (original)
+++ branches/upstream/libjavascript-perl/current/JavaScript.xs Thu May 8 19:36:14 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: branches/upstream/libjavascript-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/MANIFEST?rev=19706&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/MANIFEST (original)
+++ branches/upstream/libjavascript-perl/current/MANIFEST Thu May 8 19:36:14 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: branches/upstream/libjavascript-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/META.yml?rev=19706&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/META.yml (original)
+++ branches/upstream/libjavascript-perl/current/META.yml Thu May 8 19:36:14 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: branches/upstream/libjavascript-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/Makefile.PL?rev=19706&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/Makefile.PL (original)
+++ branches/upstream/libjavascript-perl/current/Makefile.PL Thu May 8 19:36:14 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: branches/upstream/libjavascript-perl/current/PJS_Class.c
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/PJS_Class.c?rev=19706&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_Class.c (original)
+++ branches/upstream/libjavascript-perl/current/PJS_Class.c Thu May 8 19:36:14 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: branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c?rev=19706&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c (original)
+++ branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c Thu May 8 19:36:14 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: branches/upstream/libjavascript-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/README?rev=19706&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/README (original)
+++ branches/upstream/libjavascript-perl/current/README Thu May 8 19:36:14 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: branches/upstream/libjavascript-perl/current/lib/JavaScript.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/lib/JavaScript.pm?rev=19706&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/lib/JavaScript.pm (original)
+++ branches/upstream/libjavascript-perl/current/lib/JavaScript.pm Thu May 8 19:36:14 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: branches/upstream/libjavascript-perl/current/lib/JavaScript/Context.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/lib/JavaScript/Context.pm?rev=19706&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/lib/JavaScript/Context.pm (original)
+++ branches/upstream/libjavascript-perl/current/lib/JavaScript/Context.pm Thu May 8 19:36:14 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: branches/upstream/libjavascript-perl/current/t/04-prototypes.t
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/t/04-prototypes.t?rev=19706&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/t/04-prototypes.t (original)
+++ branches/upstream/libjavascript-perl/current/t/04-prototypes.t Thu May 8 19:36:14 2008
@@ -13,7 +13,7 @@
my $cx1 = $rt1->create_context();
$cx1->bind_class(name => "foo",
- constructor => sub {},
+ constructor => sub { },
package => 'main',
);
Modified: branches/upstream/libjavascript-perl/current/t/05-deep-assign.t
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/t/05-deep-assign.t?rev=19706&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/t/05-deep-assign.t (original)
+++ branches/upstream/libjavascript-perl/current/t/05-deep-assign.t Thu May 8 19:36:14 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" );
Added: branches/upstream/libjavascript-perl/current/t/30-refcount.t
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/t/30-refcount.t?rev=19706&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/t/30-refcount.t (added)
+++ branches/upstream/libjavascript-perl/current/t/30-refcount.t Thu May 8 19:36:14 2008
@@ -1,0 +1,35 @@
+#!/usr/bin/perl
+
+use lib "t/lib";
+use strict;
+use warnings;
+
+use Test::More tests => 4;
+
+use B qw(svref_2object);
+use JavaScript;
+use DummyClass;
+
+my $rt = JavaScript::Runtime->new();
+
+{
+ my $sv;
+ {
+ my $cx = $rt->create_context();
+ $cx->bind_class(name => "DummyClass");
+
+ my $o = DummyClass->new;
+ $sv = svref_2object($o);
+ is($sv->REFCNT, 1);
+
+ $cx->eval("function foo_global(obj) { ref = obj }");
+ $cx->call(foo_global => $o);
+ is($sv->REFCNT, 2);
+
+ $cx->eval("function foo_local(obj) { var ref = obj }");
+ $cx->call(foo_local => $o);
+ is($sv->REFCNT, 2);
+ }
+
+ is($sv->REFCNT, 1);
+}
Added: branches/upstream/libjavascript-perl/current/t/lib/DummyClass.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/t/lib/DummyClass.pm?rev=19706&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/t/lib/DummyClass.pm (added)
+++ branches/upstream/libjavascript-perl/current/t/lib/DummyClass.pm Thu May 8 19:36:14 2008
@@ -1,0 +1,12 @@
+package DummyClass;
+
+use strict;
+use warnings;
+
+sub new {
+ my $pkg = shift;
+ my $self = bless {}, $pkg;
+ return $self;
+}
+
+1;
More information about the Pkg-perl-cvs-commits
mailing list