r18266 - in /branches/upstream/libjavascript-perl/current: Changes JavaScript.h JavaScript.xs MANIFEST META.yml PJS_Call.c PJS_Call.h PJS_Context.c PJS_Exceptions.h PJS_Runtime.h PJS_TypeConversion.c calls.c t/29-exceptions.t
gregoa-guest at users.alioth.debian.org
gregoa-guest at users.alioth.debian.org
Wed Apr 2 17:26:51 UTC 2008
Author: gregoa-guest
Date: Wed Apr 2 17:26:51 2008
New Revision: 18266
URL: http://svn.debian.org/wsvn/?sc=1&rev=18266
Log:
Load /tmp/perl/libjavascript-perl-1.04/ into
branches/upstream/libjavascript-perl/current.
Added:
branches/upstream/libjavascript-perl/current/PJS_Call.c
branches/upstream/libjavascript-perl/current/PJS_Call.h
Removed:
branches/upstream/libjavascript-perl/current/calls.c
Modified:
branches/upstream/libjavascript-perl/current/Changes
branches/upstream/libjavascript-perl/current/JavaScript.h
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/PJS_Context.c
branches/upstream/libjavascript-perl/current/PJS_Exceptions.h
branches/upstream/libjavascript-perl/current/PJS_Runtime.h
branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c
branches/upstream/libjavascript-perl/current/t/29-exceptions.t
Modified: branches/upstream/libjavascript-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/Changes?rev=18266&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/Changes (original)
+++ branches/upstream/libjavascript-perl/current/Changes Wed Apr 2 17:26:51 2008
@@ -1,6 +1,7 @@
Revision history for Perl extension JavaScript.
-1.04 Tue Apr 17 2007
+1.04 Sat Nov 17 2007
+ - Skip exception tests on engines less than 1.7 since these seem to be broken.
- Free memory allocated by JS_smprintf when converting from utf8 strings (spotted by Ash Berlin)
- Don't call js_ValueToXMLString but instead call JS method "toXMLString" on the object [rt.cpan.org #26411]
- Convert 64bit Perl ints to JSDouble if they are too big to fit in JS ints [rt.cpan.org #26474] (Niko Tyni)
Modified: branches/upstream/libjavascript-perl/current/JavaScript.h
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/JavaScript.h?rev=18266&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/JavaScript.h (original)
+++ branches/upstream/libjavascript-perl/current/JavaScript.h Wed Apr 2 17:26:51 2008
@@ -18,6 +18,7 @@
#include "JavaScript_Env.h"
+#include "PJS_Call.h"
#include "PJS_Types.h"
#include "PJS_Runtime.h"
#include "PJS_Context.h"
@@ -28,40 +29,6 @@
#include "PJS_TypeConversion.h"
#include "PJS_Common.h"
-/* Function prototypes */
-
-/* pjs_property.c */
-
-/* pjs_function.c */
-
-/* pjs_class.c */
-PJS_EXTERN JSBool
-perl_call_jsfunc(JSContext *, JSObject *, uintN , jsval *, jsval *);
-
-PJS_EXTERN JSBool
-PJS_call_javascript_function(PJS_Context *, jsval , SV *, jsval *);
-
-PJS_EXTERN I32
-perl_call_sv_with_jsvals(JSContext *, JSObject *, SV *, SV *, uintN , jsval *, jsval *);
-
-PJS_EXTERN I32
-perl_call_sv_with_jsvals_rsv(JSContext *, JSObject *, SV *, SV *, uintN , jsval *, SV **);
-
-PJS_EXTERN SV *
-PJS_call_perl_method(const char *, ...);
-
-PJS_EXTERN void
-PJS_report_exception(PJS_Context *);
-
-PJS_EXTERN JSBool
-PJS_invoke_perl_function(JSContext *, JSObject *, uintN, jsval *, jsval *);
-
-PJS_EXTERN JSTrapStatus
-PJS_trap_handler(JSContext *, JSScript *, jsbytecode *, jsval *, void *);
-
-PJS_EXTERN JSTrapStatus
-PJS_perl_trap_handler(JSContext *, JSScript *, jsbytecode *, jsval *, void *);
-
#ifdef __cplusplus
}
#endif
Modified: branches/upstream/libjavascript-perl/current/JavaScript.xs
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/JavaScript.xs?rev=18266&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/JavaScript.xs (original)
+++ branches/upstream/libjavascript-perl/current/JavaScript.xs Wed Apr 2 17:26:51 2008
@@ -265,8 +265,10 @@
jsc_free_root(cx, root)
PJS_Context *cx;
SV *root;
- CODE:
- jsval *x = INT2PTR(jsval *, SvIV(root));
+ PREINIT:
+ jsval *x;
+ CODE:
+ x = INT2PTR(jsval *, SvIV(root));
JS_RemoveRoot(PJS_GetJSContext(cx), x);
jsval
@@ -334,6 +336,7 @@
AV *av;
SV *val, *value;
IV tmp;
+ JSObject *jsobj;
CODE:
tmp = SvIV((SV *) SvRV(PJS_call_perl_method("content", afunc, NULL)));
func = INT2PTR(JSFunction *,tmp);
@@ -349,7 +352,7 @@
if (PJS_ConvertPerlToJSType(PJS_GetJSContext(cx), NULL, JS_GetGlobalObject(PJS_GetJSContext(cx)), rcx, &context) == JS_FALSE) {
croak("cannot convert JS context to JSVAL");
}
- JSObject *jsobj = JSVAL_TO_OBJECT(context);
+ jsobj = JSVAL_TO_OBJECT(context);
if (strlen(class) > 0) {
if( JS_GetProperty(PJS_GetJSContext(cx), JS_GetGlobalObject(PJS_GetJSContext(cx)), class, &aval) == JS_FALSE ) {
Modified: branches/upstream/libjavascript-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/MANIFEST?rev=18266&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/MANIFEST (original)
+++ branches/upstream/libjavascript-perl/current/MANIFEST Wed Apr 2 17:26:51 2008
@@ -1,39 +1,39 @@
+CREDITS
Changes
+JavaScript.h
+JavaScript.xs
MANIFEST
+META.yml
Makefile.PL
+PJS_Call.c
+PJS_Call.h
+PJS_Class.c
+PJS_Class.h
+PJS_Common.h
+PJS_Context.c
+PJS_Context.h
+PJS_Exceptions.c
+PJS_Exceptions.h
+PJS_Function.c
+PJS_Function.h
+PJS_Property.c
+PJS_Property.h
+PJS_Runtime.c
+PJS_Runtime.h
+PJS_Script.h
+PJS_TypeConversion.c
+PJS_TypeConversion.h
+PJS_Types.h
README
-CREDITS
TODO
lib/JavaScript.pm
+lib/JavaScript/Boxed.pm
lib/JavaScript/Context.pm
-lib/JavaScript/Boxed.pm
lib/JavaScript/Error.pm
lib/JavaScript/Function.pm
lib/JavaScript/Runtime.pm
lib/JavaScript/Script.pm
lib/Test/JavaScript/More.pm
-JavaScript.xs
-PJS_Context.c
-PJS_Context.h
-PJS_Exceptions.h
-PJS_Exceptions.c
-PJS_Property.c
-PJS_Property.h
-PJS_Class.c
-PJS_Class.h
-PJS_Function.c
-PJS_Function.h
-PJS_Script.h
-PJS_Types.h
-calls.c
-exceptions.c
-PJS_TypeConversion.c
-PJS_TypeConversion.h
-PJS_Runtime.c
-PJS_Runtime.h
-PJS_Common.h
-JavaScript.h
-typemap
t/00-init.t
t/01-types-from-js.t
t/02-types-from-perl.t
@@ -41,8 +41,8 @@
t/04-prototypes.t
t/05-deep-assign.t
t/06-bind-object.t
+t/07-eval-file.js
t/07-eval-file.t
-t/07-eval-file.js
t/08-can.t
t/09-script.t
t/10-round-trip.t
@@ -65,6 +65,6 @@
t/28-test-javascript-more.t
t/29-exceptions.t
t/99-bottles-of-beer.t
+t/pod-coverage.t
t/pod.t
-t/pod-coverage.t
-META.yml Module meta-data (added by MakeMaker)
+typemap
Modified: branches/upstream/libjavascript-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/META.yml?rev=18266&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/META.yml (original)
+++ branches/upstream/libjavascript-perl/current/META.yml Wed Apr 2 17:26:51 2008
@@ -1,12 +1,15 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
-name: JavaScript
-version: 1.00
-version_from: lib/JavaScript.pm
-installdirs: site
-requires:
+--- #YAML:1.0
+name: JavaScript
+version: 1.04
+abstract: Perl extension for executing embedded JavaScript
+license: perl
+generated_by: ExtUtils::MakeMaker version 6.36
+distribution_type: module
+requires:
Test::Exception: 0
Test::More: 0
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.2.html
+ version: 1.2
+author:
+ - Claes Jakobsson <claesjac at cpan.org>
Added: branches/upstream/libjavascript-perl/current/PJS_Call.c
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/PJS_Call.c?rev=18266&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_Call.c (added)
+++ branches/upstream/libjavascript-perl/current/PJS_Call.c Wed Apr 2 17:26:51 2008
@@ -1,0 +1,171 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#include "JavaScript_Env.h"
+
+#include "PJS_Call.h"
+#include "PJS_Context.h"
+#include "PJS_TypeConversion.h"
+
+SV *PJS_call_perl_method(const char *method, ...) {
+ dSP;
+ va_list ap;
+ SV *arg, *ret = sv_newmortal();
+ int rcount;
+
+ ENTER;
+ SAVETMPS;
+ PUSHMARK(SP);
+ va_start(ap, method);
+ while ((arg = va_arg(ap, SV*)) != NULL) {
+ XPUSHs(arg);
+ }
+
+ PUTBACK;
+
+ rcount = perl_call_method(method, G_SCALAR);
+
+ SPAGAIN;
+
+ sv_setsv(ret, POPs);
+
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
+
+ return ret;
+}
+
+I32 perl_call_sv_with_jsvals_rsv(JSContext *cx, JSObject *obj, SV *code, SV *caller, uintN argc, jsval *argv, SV **rsv) {
+ dSP;
+ I32 rcount = 0;
+ int arg;
+
+ if (SvROK(code) && SvTYPE(SvRV(code)) == SVt_PVCV) {
+ ENTER ;
+ SAVETMPS ;
+ PUSHMARK(SP) ;
+
+ if (caller) {
+ XPUSHs(caller);
+ }
+
+ for (arg = 0; arg < argc; arg++) {
+ SV *sv = sv_newmortal();
+ JSVALToSV(cx, NULL, argv[arg], &sv);
+ XPUSHs(sv);
+ }
+
+ PUTBACK ;
+
+ rcount = perl_call_sv(SvRV(code), G_SCALAR|G_EVAL);
+
+ SPAGAIN ;
+
+ if(rcount) {
+ int i;
+ /* XXX: this is wrong */
+ for (i = 0; i < rcount; ++i) {
+ if (rsv) {
+ *rsv = POPs;
+ SvREFCNT_inc(*rsv);
+ }
+ }
+ }
+ else {
+ }
+
+ if (SvTRUE(ERRSV)) {
+ jsval rval;
+ SV* cp = sv_mortalcopy( ERRSV );
+ if (PJS_ConvertPerlToJSType(cx, NULL, obj, cp, &rval) != JS_FALSE) {
+ JS_SetPendingException(cx, rval);
+ rcount = -1;
+
+ /* ERRSV is now converted into JS space. If it leaves again,
+ we'll turn it into a perl exception, so we can drop the
+ perl-space error here. */
+ sv_setsv(ERRSV, &PL_sv_undef);
+ }
+ else {
+ croak("Can't convert perl error into JSVAL");
+ }
+ }
+
+ PUTBACK ;
+ FREETMPS ;
+ LEAVE ;
+ }
+ else {
+ warn("not a coderef");
+ }
+
+ return rcount;
+}
+
+I32 perl_call_sv_with_jsvals(JSContext *cx, JSObject *obj, SV *code, SV *caller, uintN argc, jsval *argv, jsval *rval) {
+ SV *rsv;
+ I32 rcount = perl_call_sv_with_jsvals_rsv(cx, obj, code, caller, argc, argv, rval ? &rsv : NULL);
+
+ if (rval) {
+ PJS_ConvertPerlToJSType(cx, NULL, obj, rsv, rval);
+ }
+
+ return rcount;
+}
+
+JSBool PJS_call_javascript_function(PJS_Context *pcx, jsval func, SV *args, jsval *rval) {
+ jsval *arg_list;
+ SV *val;
+ AV *av;
+ int arg_count, i;
+ JSFunction *js_fun;
+
+ /* Clear $@ */
+ sv_setsv(ERRSV, &PL_sv_undef);
+
+ av = (AV *) SvRV(args);
+ arg_count = av_len(av);
+
+ Newz(1, arg_list, arg_count + 1, jsval);
+ if (arg_list == NULL) {
+ croak("Failed to allocate memory for argument list");
+ }
+
+ for (i = 0; i <= arg_count; i++) {
+ val = *av_fetch(av, i, 0);
+
+ if (PJS_ConvertPerlToJSType(PJS_GetJSContext(pcx), NULL, JS_GetGlobalObject(PJS_GetJSContext(pcx)), val, &(arg_list[i])) == JS_FALSE) {
+ Safefree(arg_list);
+ croak("Can't convert argument number %d to jsval", i);
+ }
+ }
+
+ js_fun = JS_ValueToFunction(PJS_GetJSContext(pcx), func);
+ if (JS_CallFunction(PJS_GetJSContext(pcx), JS_GetGlobalObject(PJS_GetJSContext(pcx)), js_fun,
+ arg_count + 1, (jsval *) arg_list, (jsval *) rval) == JS_FALSE) {
+ PJS_report_exception(pcx);
+ return JS_FALSE;
+ }
+
+ return JS_TRUE;
+}
+
+JSBool perl_call_jsfunc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
+ jsval tmp;
+ SV *code;
+ JSFunction *jsfun = PJS_FUNC_SELF;
+ JSObject *funobj = JS_GetFunctionObject(jsfun);
+
+ if (JS_GetProperty(cx, funobj, "_perl_func", &tmp) == JS_FALSE) {
+ croak("Can't get coderef\n");
+ }
+
+ code = JSVAL_TO_PRIVATE(tmp);
+ if (perl_call_sv_with_jsvals(cx, obj, code, NULL, argc, argv, rval) < 0) {
+ return JS_FALSE;
+ }
+
+ return JS_TRUE;
+}
Added: branches/upstream/libjavascript-perl/current/PJS_Call.h
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/PJS_Call.h?rev=18266&op=file
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_Call.h (added)
+++ branches/upstream/libjavascript-perl/current/PJS_Call.h Wed Apr 2 17:26:51 2008
@@ -1,0 +1,35 @@
+/*!
+ @header PJS_Call.h
+ @abstract Types and functions related to calling methods and functions
+*/
+
+#ifndef __PJS_CALL_H__
+#define __PJS_CALL_H__
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+#include "perl.h"
+
+#include "JavaScript_Env.h"
+
+#include "PJS_Types.h"
+#include "PJS_Common.h"
+
+PJS_EXTERN SV *
+PJS_call_perl_method(const char *, ...);
+
+PJS_EXTERN I32
+perl_call_sv_with_jsvals_rsv(JSContext *, JSObject *, SV *, SV *, uintN, jsval *, SV **);
+
+PJS_EXTERN I32
+perl_call_sv_with_jsvals(JSContext *, JSObject *, SV *, SV *, uintN, jsval *, jsval *);
+
+PJS_EXTERN JSBool
+PJS_call_javascript_function(PJS_Context *, jsval, SV *, jsval *);
+
+PJS_EXTERN JSBool
+perl_call_jsfunc(JSContext *, JSObject *, uintN, jsval *, jsval *);
+
+#endif
Modified: branches/upstream/libjavascript-perl/current/PJS_Context.c
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/PJS_Context.c?rev=18266&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_Context.c (original)
+++ branches/upstream/libjavascript-perl/current/PJS_Context.c Wed Apr 2 17:26:51 2008
@@ -122,20 +122,24 @@
Free memory occupied by PJS_Context structure
*/
void PJS_DestroyContext(PJS_Context *pcx) {
+ PJS_Function *pfunc, *pfunc_next;
+ PJS_Class *pcls, *pcls_next;
+
if (pcx == NULL) {
return;
}
+ pfunc = pcx->functions;
+
/* Check if we have any bound functions */
- PJS_Function *pfunc = pcx->functions, *pfunc_next;
while (pfunc != NULL) {
pfunc_next = pfunc->_next;
PJS_DestroyFunction(pfunc);
pfunc = pfunc_next;
}
+ pcls = pcx->classes;
/* Check if we have any bound classes */
- PJS_Class *pcls = pcx->classes, *pcls_next;
while (pcls != NULL) {
pcls_next = pcls->_next;
PJS_free_class(pcls);
Modified: branches/upstream/libjavascript-perl/current/PJS_Exceptions.h
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/PJS_Exceptions.h?rev=18266&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_Exceptions.h (original)
+++ branches/upstream/libjavascript-perl/current/PJS_Exceptions.h Wed Apr 2 17:26:51 2008
@@ -13,7 +13,15 @@
#include "perl.h"
#include "JavaScript_Env.h"
-
+
+#include "PJS_Context.h"
+
+PJS_EXTERN void
+PJS_report_exception(PJS_Context *);
+
+PJS_EXTERN void
+PJS_error_handler(JSContext *, const char *, JSErrorReport *);
+
#ifdef __cplusplus
}
#endif
Modified: branches/upstream/libjavascript-perl/current/PJS_Runtime.h
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/PJS_Runtime.h?rev=18266&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_Runtime.h (original)
+++ branches/upstream/libjavascript-perl/current/PJS_Runtime.h Wed Apr 2 17:26:51 2008
@@ -74,6 +74,12 @@
PJS_EXTERN void
PJS_RemoveTrapHandler(PJS_Runtime *fromRuntime, PJS_TrapHandler *trapHandler);
+PJS_EXTERN JSTrapStatus
+PJS_trap_handler(JSContext *, JSScript *, jsbytecode *, jsval *, void *);
+
+PJS_EXTERN JSTrapStatus
+PJS_perl_trap_handler(JSContext *, JSScript *, jsbytecode *, jsval *, void *);
+
#ifdef __cplusplus
}
#endif
Modified: branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c?rev=18266&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c (original)
+++ branches/upstream/libjavascript-perl/current/PJS_TypeConversion.c Wed Apr 2 17:26:51 2008
@@ -1,5 +1,6 @@
#include "JavaScript.h"
+#include "PJS_Call.h"
#include "PJS_Context.h"
JSBool checkSeen( JSContext *cx, JSObject *seen, SV *ref, jsval *rval ) {
@@ -113,19 +114,8 @@
/* Most likely it's an hash that is returned */
if(type == SVt_PVHV) {
+ JSObject *new_obj;
HV *hv = (HV *) SvRV(ref);
-
- if ( checkSeen( cx, seen, (SV*)hv, rval ) == JS_TRUE )
- return JS_TRUE;
-
- JSObject *new_obj;
- new_obj = JS_NewObject(cx, NULL, NULL, NULL);
- if(new_obj == NULL)
- croak("Failed to create new JavaScript object");
-
- setSeen( cx, seen, (SV*)hv, OBJECT_TO_JSVAL(new_obj) );
-
- /* Assign properties, lets iterate over the hash */
I32 items;
HE *key;
char *keyname;
@@ -133,7 +123,17 @@
STRLEN keylen;
SV *keyval;
jsval elem;
-
+
+ if ( checkSeen( cx, seen, (SV*)hv, rval ) == JS_TRUE )
+ return JS_TRUE;
+
+ new_obj = JS_NewObject(cx, NULL, NULL, NULL);
+ if(new_obj == NULL)
+ croak("Failed to create new JavaScript object");
+
+ setSeen( cx, seen, (SV*)hv, OBJECT_TO_JSVAL(new_obj) );
+
+ /* Assign properties, lets iterate over the hash */
items = hv_iterinit(hv);
while((key = hv_iternext(hv)) != NULL) {
@@ -190,16 +190,15 @@
*rval = OBJECT_TO_JSVAL(new_obj);
} else if(type == SVt_PVAV) {
- /* Then it's probablly an array */
- AV *av = (AV *) SvRV(ref);
-
- if ( checkSeen( cx, seen, (SV*)av, rval ) == JS_TRUE )
- return JS_TRUE;
-
jsint av_length;
jsint cnt;
jsval *elems;
JSObject *arr_obj;
+ /* Then it's probablly an array */
+ AV *av = (AV *) SvRV(ref);
+
+ if ( checkSeen( cx, seen, (SV*)av, rval ) == JS_TRUE )
+ return JS_TRUE;
arr_obj = JS_NewArrayObject(cx, 0, NULL);
@@ -290,6 +289,10 @@
else {
if (JSVAL_IS_OBJECT(v)) {
JSObject *object = JSVAL_TO_OBJECT(v);
+ int destroy_hv;
+ SV **used;
+ char hkey[32];
+ int klen;
/* stringify object with a default value for now, such as
String. We might want to actually tie the object in the
@@ -307,8 +310,9 @@
if (OBJECT_IS_XML(cx,object)) {
/* We can't use private functions so let's call the toString method on the object */
jsval tv;
+ JSString *xmlstring;
JS_CallFunctionName(cx, object, "toXMLString", 0, NULL, &tv);
- JSString *xmlstring = JS_ValueToString(cx,tv);
+ xmlstring = JS_ValueToString(cx,tv);
sv_setpv(*sv, JS_GetStringBytes(xmlstring));
SvUTF8_on(*sv);
return JS_TRUE;
@@ -350,15 +354,13 @@
}
}
- int destroy_hv = 0;
+ destroy_hv = 0;
if (!seen) {
seen = newHV();
destroy_hv = 1;
}
- SV **used;
- char hkey[32];
- int klen = snprintf(hkey, 32, "%p", object);
+ klen = snprintf(hkey, 32, "%p", object);
if ((used = hv_fetch(seen, hkey, klen, 0)) != NULL) {
sv_setsv(*sv, *used);
return JS_TRUE;
@@ -405,10 +407,11 @@
JS_GetArrayLength(cx, object, &jsarrlen);
for(index = 0; index < jsarrlen; index++) {
- JS_GetElement(cx, object, index, &elem);
-
SV *elem_sv;
+
+ JS_GetElement(cx, object, index, &elem);
elem_sv = newSV(0);
+
JSVALToSV(cx, seen, elem, &elem_sv);
av_push(av, elem_sv);
}
@@ -436,6 +439,7 @@
if(JSVAL_IS_STRING(key)) {
jsval value;
+ SV *val_sv;
SV *js_key_sv = newSV(0);
char *js_key = JS_GetStringBytes(JSVAL_TO_STRING(key));
@@ -452,7 +456,6 @@
croak("this can't happen.");
}
- SV *val_sv;
val_sv = newSV(0);
JSVALToSV(cx, seen, value, &val_sv);
hv_store_ent(hv, js_key_sv, val_sv, 0);
Modified: branches/upstream/libjavascript-perl/current/t/29-exceptions.t
URL: http://svn.debian.org/wsvn/branches/upstream/libjavascript-perl/current/t/29-exceptions.t?rev=18266&op=diff
==============================================================================
--- branches/upstream/libjavascript-perl/current/t/29-exceptions.t (original)
+++ branches/upstream/libjavascript-perl/current/t/29-exceptions.t Wed Apr 2 17:26:51 2008
@@ -1,10 +1,18 @@
#!perl
use strict;
-use Test::More tests => 17;
-
-use Data::Dumper;
+use Test::More;
use JavaScript;
+
+BEGIN {
+ # Skip these test if we don't have JavaScript 1.7 or later
+ my $version = (JavaScript::get_engine_version())[1];
+ $version =~ s/\.\d$// if $version =~ /\d+\.\d+\.\d+$/;
+ plan skip_all => "Engine version 1.7 or later require" if $version < 1.7;
+}
+
+plan tests => 17;
+
my $runtime = new JavaScript::Runtime();
my $context = $runtime->create_context();
@@ -70,7 +78,7 @@
EOP
is($ret, undef);
-like($@, qr/at main line 67 in 1/);
+like($@, qr/at main line 75 in 1/);
$ret = $context->eval(<<EOP);
More information about the Pkg-perl-cvs-commits
mailing list