r48023 - in /branches/upstream/libjavascript-perl/current: ./ lib/ lib/JavaScript/ t/
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Tue Dec 1 00:49:59 UTC 2009
Author: jawnsy-guest
Date: Tue Dec 1 00:49:52 2009
New Revision: 48023
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=48023
Log:
[svn-upgrade] Integrating new upstream version, libjavascript-perl (1.13)
Added:
branches/upstream/libjavascript-perl/current/._Changes (with props)
branches/upstream/libjavascript-perl/current/._Makefile.PL (with props)
branches/upstream/libjavascript-perl/current/lib/._JavaScript.pm (with props)
branches/upstream/libjavascript-perl/current/lib/JavaScript/Generator.pm
branches/upstream/libjavascript-perl/current/t/36-generator.t
Modified:
branches/upstream/libjavascript-perl/current/CREDITS
branches/upstream/libjavascript-perl/current/Changes
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_Common.h
branches/upstream/libjavascript-perl/current/PJS_Runtime.c
branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c
branches/upstream/libjavascript-perl/current/lib/JavaScript.pm
branches/upstream/libjavascript-perl/current/t/23-unicode.t
Added: branches/upstream/libjavascript-perl/current/._Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/._Changes?rev=48023&op=file
==============================================================================
Binary file - no diff available.
Propchange: branches/upstream/libjavascript-perl/current/._Changes
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: branches/upstream/libjavascript-perl/current/._Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/._Makefile.PL?rev=48023&op=file
==============================================================================
Binary file - no diff available.
Propchange: branches/upstream/libjavascript-perl/current/._Makefile.PL
------------------------------------------------------------------------------
svn:executable = *
Propchange: branches/upstream/libjavascript-perl/current/._Makefile.PL
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: branches/upstream/libjavascript-perl/current/CREDITS
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/CREDITS?rev=48023&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/CREDITS (original)
+++ branches/upstream/libjavascript-perl/current/CREDITS Tue Dec 1 00:49:52 2009
@@ -15,6 +15,10 @@
Toru Yamaguchi
Daniel Burke
Gavin Carr
+Salvador Ortiz Garcia
+Sergey Zhuravlev
+Apachez
+Dominic Mitchell
-- 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=48023&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/Changes (original)
+++ branches/upstream/libjavascript-perl/current/Changes Tue Dec 1 00:49:52 2009
@@ -1,5 +1,12 @@
Revision history for Perl extension JavaScript.
+1.13 2009-11-30
+ - Fixes compilation issues agains SM from MacPorts. [rt.cpan.org #48702] (Dominic Mitchell)
+ - Fixes compilation issues on Win32 (Apachez)
+ - Don't try to reinit UTF8 cstrings if already done as that'll assert libjs
+ - Don't consume the elements of arrays when converting to JS. [rt.cpan.org #46356] (Sergey Zhuravlev)
+ - Added support for Generators (James Duncan)
+
1.12 2009-04-04
- Guard against stack corruption (Salvador Ortiz Garcia)
- 64-bit build issues (Salvador Ortiz Garcia)
Modified: branches/upstream/libjavascript-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/MANIFEST?rev=48023&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/MANIFEST (original)
+++ branches/upstream/libjavascript-perl/current/MANIFEST Tue Dec 1 00:49:52 2009
@@ -19,6 +19,7 @@
lib/JavaScript/Context.pm
lib/JavaScript/Error.pm
lib/JavaScript/Function.pm
+lib/JavaScript/Generator.pm
lib/JavaScript/PerlArray.pm
lib/JavaScript/PerlHash.pm
lib/JavaScript/Runtime.pm
@@ -88,6 +89,7 @@
t/33-perlhash.t
t/34-options.t
t/35-regexp.t
+t/36-generator.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=48023&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/META.yml (original)
+++ branches/upstream/libjavascript-perl/current/META.yml Tue Dec 1 00:49:52 2009
@@ -1,25 +1,15 @@
--- #YAML:1.0
-name: JavaScript
-version: 1.12
-abstract: Perl extension for executing embedded JavaScript
-author:
+name: JavaScript
+version: 1.13
+abstract: Perl extension for executing embedded JavaScript
+license: perl
+author:
- Claes Jakobsson <claesjac at cpan.org>
-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.50
+generated_by: ExtUtils::MakeMaker version 6.42
+distribution_type: module
+requires:
+ Test::Exception: 0
+ Test::More: 0
meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.4.html
- version: 1.4
+ url: http://module-build.sourceforge.net/META-spec-v1.3.html
+ version: 1.3
Modified: branches/upstream/libjavascript-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/Makefile.PL?rev=48023&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/Makefile.PL (original)
+++ branches/upstream/libjavascript-perl/current/Makefile.PL Tue Dec 1 00:49:52 2009
@@ -17,7 +17,7 @@
my $path_separator = ":";
if($^O eq "MSWin32") {
- push @defines, "XP_PC";
+ push @defines, "XP_WIN";
$path_separator = ";";
} else {
push @defines, "XP_UNIX";
@@ -83,9 +83,9 @@
}
-# test for DarwinPorts
-if (-d "/opt/local/include/spidermonkey") {
- push @incs, "/opt/local/include/spidermonkey";
+# test for MacPorts
+if (-d "/opt/local/include/js") {
+ push @incs, "/opt/local/include/js", "/opt/local/include/nspr";
push @libs, "/opt/local/lib";
}
@@ -175,10 +175,10 @@
close $test_script;
my $exe = tmpnam();;
- my $cc = join(" ", $Config{cc}, $libs, @ccflags, "-l${lib}", "-o", $exe, (map { "-I$_" } @incs), "test_js.c");
+ my $cc = join(" ", $Config{cc}, @ccflags, "-o", $exe, "test_js.c", "-I.", (map { "-I$_" } @incs), $libs, "-l${lib}" );
qx($cc);
if ($?) {
- print "Failed compiling test_js.c. ABORTING\n";
+ print "Failed compiling test_js.c. ABORTING\n\n$cc\n";
exit 0;
}
unlink("test_js.c");
@@ -200,6 +200,11 @@
}
# Write makefile
+my $libs_flags = "";
+if($^O eq "MSWin32") {
+ $libs_flags = ":nosearch";
+}
+
WriteMakefile(
NAME => "JavaScript",
VERSION_FROM => "lib/JavaScript.pm",
@@ -210,7 +215,7 @@
ABSTRACT_FROM => "lib/JavaScript.pm", # retrieve abstract from module
AUTHOR => "Claes Jakobsson <claesjac\@cpan.org>",
CCFLAGS => join(" ", @ccflags),
- LIBS => ["$libs -l${lib}"], # e.g., "-lm"
+ LIBS => ["$libs_flags $libs -l${lib}"], # e.g., "-lm"
INC => join(" ", map { "-I$_" } @incs),
LICENSE => "perl",
OBJECT => q/$(O_FILES)/,
Modified: branches/upstream/libjavascript-perl/current/PJS_Common.h
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/PJS_Common.h?rev=48023&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_Common.h (original)
+++ branches/upstream/libjavascript-perl/current/PJS_Common.h Tue Dec 1 00:49:52 2009
@@ -36,6 +36,11 @@
*/
#define PJS_FUNCTION_PACKAGE "JavaScript::Function"
+/*! @define PJS_GENERATOR_PACKAGE
+ @abstract Perl package to bless Generators into
+*/
+#define PJS_GENERATOR_PACKAGE "JavaScript::Generator"
+
/*! @define PJS_BOXED_PACKAGE
@abstract Perl package to bless boxed values into
*/
Modified: branches/upstream/libjavascript-perl/current/PJS_Runtime.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/PJS_Runtime.c?rev=48023&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_Runtime.c (original)
+++ branches/upstream/libjavascript-perl/current/PJS_Runtime.c Tue Dec 1 00:49:52 2009
@@ -59,6 +59,10 @@
}
/* Create a runtime */
+#if defined(JS_C_STRINGS_ARE_UTF8) && JS_VERSION >= 180
+static bool initialized_utf8_cstrings = FALSE;
+#endif
+
PJS_Runtime *
PJS_CreateRuntime(int maxbytes) {
PJS_Runtime *runtime;
@@ -68,8 +72,11 @@
croak("Failed to allocate memoery for PJS_Runtime");
}
-#ifdef JS_C_STRINGS_ARE_UTF8 && JS_VERSION >= 180
- JS_SetCStringsAreUTF8();
+#if defined(JS_C_STRINGS_ARE_UTF8) && JS_VERSION >= 180
+ if (initialized_utf8_cstrings == FALSE) {
+ JS_SetCStringsAreUTF8();
+ initialized_utf8_cstrings = TRUE;
+ }
#endif
runtime->rt = JS_NewRuntime(maxbytes);
Modified: branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c?rev=48023&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c (original)
+++ branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c Tue Dec 1 00:49:52 2009
@@ -36,7 +36,7 @@
/* XXX: test this more */
ref = *av_fetch((AV *) SvRV(SvRV(ref)), 0, 0);
}
-
+
if (sv_isobject(ref)) { /* blessed */
PJS_Context *pcx;
PJS_Class *pjsc;
@@ -51,6 +51,12 @@
return JS_TRUE;
}
+ if (strcmp(name, PJS_GENERATOR_PACKAGE) == 0) {
+ JSObject *obj = INT2PTR(JSObject *, SvIV((SV *) SvRV(PJS_call_perl_method("content", ref, NULL))));
+ *rval = OBJECT_TO_JSVAL(obj);
+ return JS_TRUE;
+ }
+
/* ugly hack, this needs to be nicer */
if((pcx = PJS_GET_CONTEXT(cx)) == NULL) {
*rval = JSVAL_VOID;
@@ -208,7 +214,7 @@
av_length = av_len(av);
for(cnt = 0; cnt <= av_length; cnt++) {
jsval value;
- if (PJS_ConvertPerlToJSType(cx, seen, obj, av_shift(av), &value) == JS_FALSE) {
+ if (PJS_ConvertPerlToJSType(cx, seen, obj, *(av_fetch(av, cnt, 0)), &value) == JS_FALSE) {
*rval = JSVAL_VOID;
return JS_FALSE;
}
@@ -356,7 +362,9 @@
}
else if (OBJ_IS_NATIVE(object) &&
(OBJ_GET_CLASS(cx, object)->flags & JSCLASS_HAS_PRIVATE) &&
- (strcmp(OBJ_GET_CLASS(cx, object)->name, "Error") != 0)) {
+ (strcmp(OBJ_GET_CLASS(cx, object)->name, "Error") != 0) &&
+ (strcmp(OBJ_GET_CLASS(cx, object)->name, "Generator") != 0)
+ ) {
/* Object with a private means the actual perl object is there */
/* This is kludgy because function is also object with private,
we need to turn this to use hidden property on object */
@@ -366,6 +374,27 @@
return JS_TRUE;
}
}
+ else if (OBJ_IS_NATIVE(object) &&
+ (OBJ_GET_CLASS(cx, object)->flags & JSCLASS_HAS_PRIVATE) &&
+ (strcmp(OBJ_GET_CLASS(cx, object)->name, "Generator") == 0)
+ ){
+ SV *content = sv_2mortal(newRV_noinc(newSViv(PTR2IV(object))));
+ SV *pcx = sv_2mortal(newSViv(PTR2IV(PJS_GET_CONTEXT(cx))));
+ jsval *x;
+
+ Newz(1, x, 1, jsval);
+ if (x == NULL) {
+ croak("Failed to allocate memory for jsval");
+ }
+ *x = v;
+ JS_AddRoot(cx, (void *)x);
+
+ sv_setsv(*sv, PJS_call_perl_method("new",
+ newSVpv(PJS_GENERATOR_PACKAGE, 0),
+ content, pcx,
+ sv_2mortal(newSViv(PTR2IV(x))), NULL));
+ return JS_TRUE;
+ }
destroy_hv = 0;
if (!seen) {
Added: 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=48023&op=file
==============================================================================
Binary file - no diff available.
Propchange: branches/upstream/libjavascript-perl/current/lib/._JavaScript.pm
------------------------------------------------------------------------------
svn:executable = *
Propchange: branches/upstream/libjavascript-perl/current/lib/._JavaScript.pm
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
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=48023&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/lib/JavaScript.pm (original)
+++ branches/upstream/libjavascript-perl/current/lib/JavaScript.pm Tue Dec 1 00:49:52 2009
@@ -23,7 +23,7 @@
our %EXPORT_TAGS = ( all => [@EXPORT_OK] );
-our $VERSION = "1.12";
+our $VERSION = "1.13";
our $MAXBYTES = 1024 ** 2;
@@ -33,6 +33,7 @@
require JavaScript::Function;
require JavaScript::Runtime;
require JavaScript::Script;
+require JavaScript::Generator;
sub get_engine_version {
my $version_str = js_get_engine_version();
Added: branches/upstream/libjavascript-perl/current/lib/JavaScript/Generator.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/lib/JavaScript/Generator.pm?rev=48023&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/lib/JavaScript/Generator.pm (added)
+++ branches/upstream/libjavascript-perl/current/lib/JavaScript/Generator.pm Tue Dec 1 00:49:52 2009
@@ -1,0 +1,20 @@
+package JavaScript::Generator;
+
+use strict;
+use warnings;
+
+use base 'JavaScript::Boxed';
+
+my $NF = undef;
+
+sub next {
+ my $self = shift;
+
+ ## this just gives a function we can use to do all the hard work...
+ my $NF ||= $self->context->eval(q!function(aGenerator) { var n = aGenerator.next(); return n; }!);
+
+ return $NF->( $self );
+}
+
+
+1;
Modified: branches/upstream/libjavascript-perl/current/t/23-unicode.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/t/23-unicode.t?rev=48023&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/t/23-unicode.t (original)
+++ branches/upstream/libjavascript-perl/current/t/23-unicode.t Tue Dec 1 00:49:52 2009
@@ -8,7 +8,7 @@
use JavaScript;
if (JavaScript->does_handle_utf8) {
- plan tests => 8;
+ plan tests => 9;
}
else {
plan skip_all => "No unicode support in SpiderMonkey";
@@ -43,4 +43,6 @@
$context->bind_value( uhash => { "\x{2668}" => 1 } );
is( $context->eval(q{uhash[ucopy]}), 1, "unicode hash keys from perl" );
-
+# Creating another runtime should work
+my $rt2 = JavaScript::Runtime->new();
+ok(1);
Added: branches/upstream/libjavascript-perl/current/t/36-generator.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjavascript-perl/current/t/36-generator.t?rev=48023&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/t/36-generator.t (added)
+++ branches/upstream/libjavascript-perl/current/t/36-generator.t Tue Dec 1 00:49:52 2009
@@ -1,0 +1,38 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use JavaScript;
+
+my (undef, $version) = JavaScript->get_engine_version();
+
+if ($version lt "1.7.0") {
+ plan skip_all => "No generator support in SM";
+}
+else {
+ plan tests => 10;
+}
+
+my $rt = JavaScript::Runtime->new;
+my $cx = $rt->create_context;
+$cx->set_version("1.7");
+my $f = $cx->eval(q!
+function fib() {
+ var i = 0, j = 1;
+ while (true) {
+ yield i;
+ var t = i;
+ i = j;
+ j += t;
+ }
+}
+var y = fib();
+y;
+!);
+
+for my $v (qw(0 1 1 2 3 5 8 13 21 34)) {
+ is($f->next, $v);
+}
More information about the Pkg-perl-cvs-commits
mailing list