diff -ur a/Makefile.PL b/Makefile.PL --- a/Makefile.PL 2010-05-29 02:43:06.000000000 -0400 +++ b/Makefile.PL 2012-10-10 16:14:34.000000000 -0400 @@ -28,6 +28,8 @@ libjs.a js32.dll libmozjs.so + libmozjs185.so + libmozjs187.so ); my %possible_install_paths = ( diff -ur a/SpiderMonkey.pm b/SpiderMonkey.pm --- a/SpiderMonkey.pm 2010-05-29 02:49:31.000000000 -0400 +++ b/SpiderMonkey.pm 2012-10-10 16:13:43.000000000 -0400 @@ -161,9 +161,8 @@ $self->{global_class} = JavaScript::SpiderMonkey::JS_GlobalClass(); $self->{global_object} = - JavaScript::SpiderMonkey::JS_NewObject( - $self->{context}, $self->{global_class}, - $self->{global_class}, $self->{global_class}); + JavaScript::SpiderMonkey::JS_NewCompartmentAndGlobalObject( + $self->{context}, $self->{global_class}); JavaScript::SpiderMonkey::JS_InitStandardClasses($self->{context}, $self->{global_object}); diff -ur a/SpiderMonkey.xs b/SpiderMonkey.xs --- a/SpiderMonkey.xs 2010-05-29 02:49:31.000000000 -0400 +++ b/SpiderMonkey.xs 2012-10-10 16:13:41.000000000 -0400 @@ -20,10 +20,13 @@ #define snprintf _snprintf #endif +#ifndef JSCLASS_GLOBAL_FLAGS +#define JSCLASS_GLOBAL_FLAGS 0 +#endif /* JSRuntime needs this global class */ static JSClass global_class = { - "Global", 0, + "Global", JSCLASS_GLOBAL_FLAGS, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub }; @@ -67,10 +70,18 @@ * I hope all reasonable machines can hold an address in * an int. */ - XPUSHs(sv_2mortal(newSViv((int)obj))); + XPUSHs(sv_2mortal(newSViv(PTR2IV(obj)))); +#if JS_VERSION < 185 XPUSHs(sv_2mortal(newSVpv(JS_GetStringBytes(JSVAL_TO_STRING(id)), 0))); +#else + XPUSHs(sv_2mortal(newSVpv(JS_EncodeString(cx, JSVAL_TO_STRING(id)), 0))); +#endif XPUSHs(sv_2mortal(newSVpv(what, 0))); +#if JS_VERSION < 185 XPUSHs(sv_2mortal(newSVpv(JS_GetStringBytes(JSVAL_TO_STRING(*vp)), 0))); +#else + XPUSHs(sv_2mortal(newSVpv(JS_EncodeString(cx, JSVAL_TO_STRING(*vp)), 0))); +#endif PUTBACK; call_pv("JavaScript::SpiderMonkey::getsetter_dispatcher", G_DISCARD); FREETMPS; @@ -83,10 +94,21 @@ JSBool getter_dispatcher( JSContext *cx, JSObject *obj, +#if JS_VERSION < 185 jsval id, +#else + jsid iid, +#endif jsval *vp /* --------------------------------------------------------------------- */ ) { +#if JS_VERSION >= 185 + jsval id; + if (!JS_IdToValue(cx,iid,&id)) { + fprintf(stderr, "getter_dispatcher: JS_IdToValue failed.\n"); + return JS_FALSE; + } +#endif return getsetter_dispatcher(cx, obj, id, vp, "getter"); } @@ -94,10 +116,22 @@ JSBool setter_dispatcher( JSContext *cx, JSObject *obj, +#if JS_VERSION < 185 jsval id, +#else + jsid iid, + JSBool strict, +#endif jsval *vp /* --------------------------------------------------------------------- */ ) { +#if JS_VERSION >= 185 + jsval id; + if (!JS_IdToValue(cx,iid,&id)) { + fprintf(stderr, "setter_dispatcher: JS_IdToValue failed.\n"); + return JS_FALSE; + } +#endif return getsetter_dispatcher(cx, obj, id, vp, "setter"); } @@ -128,10 +162,19 @@ /* --------------------------------------------------------------------- */ static JSBool +#if JS_VERSION < 185 FunctionDispatcher(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { +#else +FunctionDispatcher(JSContext *cx, uintN argc, jsval *vp) { +#endif /* --------------------------------------------------------------------- */ dSP; +#if JS_VERSION >= 185 + JSObject *obj = JS_THIS_OBJECT(cx,vp); + jsval *argv = JS_ARGV(cx,vp); + jsval rval; +#endif SV *sv; char *n_jstr; int n_jnum; @@ -149,12 +192,20 @@ ENTER ; SAVETMPS ; PUSHMARK(SP); - XPUSHs(sv_2mortal(newSViv((int)obj))); + XPUSHs(sv_2mortal(newSViv(PTR2IV(obj)))); XPUSHs(sv_2mortal(newSVpv( - JS_GetFunctionName(fun), 0))); +#if JS_VERSION < 185 + JS_GetStringBytes(JS_GetFunctionId(fun)), 0))); +#else + JS_EncodeString(cx, JS_GetFunctionId(fun)), 0))); +#endif for(i=0; ibranch_count = 0; pcx->branch_max = max_branch_operations; +#if JS_VERSION < 181 JS_SetBranchCallback(cx, BranchHandler); +#else + JS_SetOperationCallback(cx, BranchHandler); +#endif } OUTPUT: --- a/t/error.t 2012-10-10 16:18:21.000000000 -0400 +++ b/t/error.t 2012-10-10 16:20:45.000000000 -0400 @@ -9,8 +9,8 @@ $js1->init (); ok (!$js1->eval ($jscode1)); ok ($@ !~ "\n"); -ok ($@ =~ "SyntaxError"); +ok ($@ =~ "SyntaxError" || $@ =~ "ReferenceError: invalid assignment left-hand side"); #print "$@\n"; my $jscode2 =<