I've made a patch to address these incompatibilities. Now it compile with
1.8.5 but crash when I try to use it, so either this patch is incomplete,
or there are some bugs in 1.8.5. BTW, this patch works just fine with
1.8.2.15.
diff -uNr JavaScript-SpiderMonkey-0.21.orig/Makefile.PL JavaScript-SpiderMonkey-0.21/Makefile.PL
--- JavaScript-SpiderMonkey-0.21.orig/Makefile.PL 2012-02-16 15:37:54.235633658 +0200
+++ JavaScript-SpiderMonkey-0.21/Makefile.PL 2012-02-16 15:37:59.963633733 +0200
@@ -28,6 +28,7 @@
libjs.a
js32.dll
libmozjs.so
+ libmozjs185.so
);
my %possible_install_paths = (
diff -uNr JavaScript-SpiderMonkey-0.21.orig/SpiderMonkey.xs JavaScript-SpiderMonkey-0.21/SpiderMonkey.xs
--- JavaScript-SpiderMonkey-0.21.orig/SpiderMonkey.xs 2012-02-16 15:37:54.235633658 +0200
+++ JavaScript-SpiderMonkey-0.21/SpiderMonkey.xs 2012-02-16 15:55:06.212647179 +0200
@@ -68,9 +68,9 @@
* an int.
*/
XPUSHs(sv_2mortal(newSViv((int)obj)));
- XPUSHs(sv_2mortal(newSVpv(JS_GetStringBytes(JSVAL_TO_STRING(id)), 0)));
+ XPUSHs(sv_2mortal(newSVpv(JS_EncodeString(cx, JSVAL_TO_STRING(id)), 0)));
XPUSHs(sv_2mortal(newSVpv(what, 0)));
- XPUSHs(sv_2mortal(newSVpv(JS_GetStringBytes(JSVAL_TO_STRING(*vp)), 0)));
+ XPUSHs(sv_2mortal(newSVpv(JS_EncodeString(cx, JSVAL_TO_STRING(*vp)), 0)));
PUTBACK;
call_pv("JavaScript::SpiderMonkey::getsetter_dispatcher", G_DISCARD);
FREETMPS;
@@ -151,10 +151,10 @@
PUSHMARK(SP);
XPUSHs(sv_2mortal(newSViv((int)obj)));
XPUSHs(sv_2mortal(newSVpv(
- JS_GetFunctionName(fun), 0)));
+ JS_EncodeString(cx, JS_GetFunctionId(fun)), 0)));
for(i=0; i<argc; i++) {
XPUSHs(sv_2mortal(newSVpv(
- JS_GetStringBytes(JS_ValueToString(cx, argv[i])), 0)));
+ JS_EncodeString(cx, JS_ValueToString(cx, argv[i])), 0)));
}
PUTBACK;
count = call_pv("JavaScript::SpiderMonkey::function_dispatcher", G_SCALAR);
@@ -192,7 +192,7 @@
if(Debug)
fprintf(stderr, "DEBUG: %lx is a double(%f)\n", (long) sv,n_jdbl);
- *rval = DOUBLE_TO_JSVAL(JS_NewDouble(cx, n_jdbl));
+ JS_NewNumberValue(cx, n_jdbl, rval);
} else if(SvPOK(sv)) {
n_jstr = SvPV(sv, PL_na);
//warn("DEBUG: %s (%d)\n", n_jstr);
@@ -241,7 +241,7 @@
/* --------------------------------------------------------------------- */
static JSBool
-BranchHandler(JSContext *cx, JSScript *script) {
+BranchHandler(JSContext *cx, ...) {
/* --------------------------------------------------------------------- */
PJS_Context* pcx = (PJS_Context*) JS_GetContextPrivate(cx);
@@ -582,10 +582,10 @@
rc = JS_GetProperty(cx, obj, name, &vp);
if(rc) {
str = JS_ValueToString(cx, vp);
- if(strcmp(JS_GetStringBytes(str), "undefined") == 0) {
+ if(strcmp(JS_EncodeString(cx, str), "undefined") == 0) {
sv = &PL_sv_undef;
} else {
- sv_setpv(sv, JS_GetStringBytes(str));
+ sv_setpv(sv, JS_EncodeString(cx, str));
}
} else {
sv = &PL_sv_undef;
@@ -675,10 +675,10 @@
rc = JS_GetElement(cx, obj, idx, &vp);
if(rc) {
str = JS_ValueToString(cx, vp);
- if(strcmp(JS_GetStringBytes(str), "undefined") == 0) {
+ if(strcmp(JS_EncodeString(cx, str), "undefined") == 0) {
sv = &PL_sv_undef;
} else {
- sv_setpv(sv, JS_GetStringBytes(str));
+ sv_setpv(sv, JS_EncodeString(cx, str));
}
} else {
sv = &PL_sv_undef;