API changes in libmozjs

أحمد المحمودي <[email protected]> Sat, 9 Apr 2011 23:35:13 +0200
Newsgroups gmane.comp.web.links
Message-ID <[email protected]>
--===============0400989610==
Content-Type: multipart/signed; micalg=pgp-sha256;
	protocol="application/pgp-signature"; boundary="VrqPEDrXMn8OVzN4"
Content-Disposition: inline


--VrqPEDrXMn8OVzN4
Content-Type: multipart/mixed; boundary="AqsLC8rIMeq19msA"
Content-Disposition: inline


--AqsLC8rIMeq19msA
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello,

  There have been API changes in libmozjs, which make the build fail if=20
  I enable ECMAScript support.

  Attached is a patch that fixes the build failure. Anyways, elinks=20
  immediately seg faults after invocation. So I had to disable=20
  ECMAScript support.

--=20
 =E2=80=8E=D8=A3=D8=AD=D9=85=D8=AF =D8=A7=D9=84=D9=85=D8=AD=D9=85=D9=88=D8=
=AF=D9=8A (Ahmed El-Mahmoudy)
  Digital design engineer
 GPG KeyID: 0xEDDDA1B7
 GPG Fingerprint: 8206 A196 2084 7E6D 0DF8  B176 BC19 6A94 EDDD A1B7

--AqsLC8rIMeq19msA
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment; filename="mozjs.diff"
Content-Transfer-Encoding: quoted-printable

Description: Adapt for mozjs API changes
Author: =D8=A3=D8=AD=D9=85=D8=AF =D8=A7=D9=84=D9=85=D8=AD=D9=85=D9=88=D8=AF=
=D9=8A (Ahmed El-Mahmoudy) <[email protected]>
--- a/src/scripting/smjs/bookmarks.c
+++ b/src/scripting/smjs/bookmarks.c
@@ -113,22 +113,22 @@
 	unsigned char *str;
=20
 	/* jsstring_to_utf8() might GC; protect the string to come.  */
-	if (!JS_AddNamedRoot(ctx, &jsstr, "jsval_to_bookmark_string"))
+	if (!JS_AddNamedStringRoot(ctx, &jsstr, "jsval_to_bookmark_string"))
 		return JS_FALSE;
=20
 	jsstr =3D JS_ValueToString(ctx, val);
 	if (jsstr =3D=3D NULL) {
-		JS_RemoveRoot(ctx, &jsstr);
+		JS_RemoveStringRoot(ctx, &jsstr);
 		return JS_FALSE;
 	}
=20
 	str =3D jsstring_to_utf8(ctx, jsstr, NULL);
 	if (str =3D=3D NULL) {
-		JS_RemoveRoot(ctx, &jsstr);
+		JS_RemoveStringRoot(ctx, &jsstr);
 		return JS_FALSE;
 	}
=20
-	JS_RemoveRoot(ctx, &jsstr);
+	JS_RemoveStringRoot(ctx, &jsstr);
 	mem_free_set(result, str);
 	return JS_TRUE;
 }
--- a/src/scripting/smjs/load_uri.c
+++ b/src/scripting/smjs/load_uri.c
@@ -56,7 +56,7 @@
 end:
 	if (download->cached)
 		object_unlock(download->cached);
-	JS_RemoveRoot(smjs_ctx, &hop->callback);
+	JS_RemoveValueRoot(smjs_ctx, &hop->callback);
 	mem_free(download->data);
 	mem_free(download);
=20
@@ -76,7 +76,7 @@
 	if (argc < 2) return JS_FALSE;
=20
 	jsstr =3D JS_ValueToString(smjs_ctx, argv[0]);
-	uri_string =3D JS_GetStringBytes(jsstr);
+	uri_string =3D JS_EncodeString(smjs_ctx, jsstr);
=20
 	uri =3D get_uri(uri_string, 0);
 	if (!uri) return JS_FALSE;
@@ -96,7 +96,7 @@
=20
 	hop->callback =3D argv[1];
 	hop->ses =3D smjs_ses;
-	if (!JS_AddNamedRoot(smjs_ctx, &hop->callback,
+	if (!JS_AddNamedValueRoot(smjs_ctx, &hop->callback,
 			     "smjs_load_uri_hop.callback")) {
 		mem_free(hop);
 		mem_free(download);
--- a/src/scripting/smjs/action_object.c
+++ b/src/scripting/smjs/action_object.c
@@ -131,7 +131,7 @@
=20
 	*vp =3D JSVAL_NULL;
=20
-	action_str =3D JS_GetStringBytes(JS_ValueToString(ctx, id));
+	action_str =3D JS_EncodeString(ctx, JS_ValueToString(ctx, id));
 	if (!action_str) return JS_TRUE;
=20
 	action_fn =3D smjs_get_action_fn_object(action_str);
--- a/src/scripting/smjs/globhist.c
+++ b/src/scripting/smjs/globhist.c
@@ -139,7 +139,7 @@
 	switch (JSVAL_TO_INT(id)) {
 	case GLOBHIST_TITLE: {
 		JSString *jsstr =3D JS_ValueToString(smjs_ctx, *vp);
-		unsigned char *str =3D JS_GetStringBytes(jsstr);
+		unsigned char *str =3D JS_EncodeString(smjs_ctx, jsstr);
=20
 		mem_free_set(&history_item->title, stracpy(str));
=20
@@ -147,7 +147,7 @@
 	}
 	case GLOBHIST_URL: {
 		JSString *jsstr =3D JS_ValueToString(smjs_ctx, *vp);
-		unsigned char *str =3D JS_GetStringBytes(jsstr);
+		unsigned char *str =3D JS_EncodeString(smjs_ctx, jsstr);
=20
 		mem_free_set(&history_item->url, stracpy(str));
=20
@@ -207,7 +207,7 @@
 	unsigned char *uri_string;
 	struct global_history_item *history_item;
=20
-	uri_string =3D JS_GetStringBytes(JS_ValueToString(ctx, id));
+	uri_string =3D JS_EncodeString(ctx, JS_ValueToString(ctx, id));
 	if (!uri_string) goto ret_null;
=20
 	history_item =3D get_global_history_item(uri_string);
--- a/src/scripting/smjs/keybinding.c
+++ b/src/scripting/smjs/keybinding.c
@@ -32,7 +32,7 @@
 	data =3D JS_GetInstancePrivate(ctx, obj,
 				     (JSClass *) &keymap_class, NULL);
=20
-	keystroke_str =3D JS_GetStringBytes(JS_ValueToString(ctx, id));
+	keystroke_str =3D JS_EncodeString(ctx, JS_ValueToString(ctx, id));
 	if (!keystroke_str) goto ret_null;
=20
 	action_str =3D get_action_name_from_keystroke((enum keymap_id) *data,
@@ -90,13 +90,13 @@
 	keymap_str =3D get_keymap_name((enum keymap_id) *data);
 	if (!keymap_str) return JS_FALSE;
=20
-	keystroke_str =3D JS_GetStringBytes(JS_ValueToString(ctx, id));
+	keystroke_str =3D JS_EncodeString(ctx, JS_ValueToString(ctx, id));
 	if (!keystroke_str) return JS_FALSE;
=20
 	if (JSVAL_IS_STRING(*vp)) {
 		unsigned char *action_str;
=20
-		action_str =3D JS_GetStringBytes(JS_ValueToString(ctx, *vp));
+		action_str =3D JS_EncodeString(ctx, JS_ValueToString(ctx, *vp));
 		if (!action_str) return JS_FALSE;
=20
 		if (bind_do(keymap_str, keystroke_str, action_str, 0))
--- a/src/scripting/smjs/cache_object.c
+++ b/src/scripting/smjs/cache_object.c
@@ -150,7 +150,7 @@
 	else switch (JSVAL_TO_INT(id)) {
 	case CACHE_ENTRY_CONTENT: {
 		JSString *jsstr =3D JS_ValueToString(smjs_ctx, *vp);
-		unsigned char *str =3D JS_GetStringBytes(jsstr);
+		unsigned char *str =3D JS_EncodeString(smjs_ctx, jsstr);
 		size_t len =3D JS_GetStringLength(jsstr);
=20
 		add_fragment(cached, 0, str, len);
@@ -161,7 +161,7 @@
 	}
 	case CACHE_ENTRY_TYPE: {
 		JSString *jsstr =3D JS_ValueToString(smjs_ctx, *vp);
-		unsigned char *str =3D JS_GetStringBytes(jsstr);
+		unsigned char *str =3D JS_EncodeString(smjs_ctx, jsstr);
=20
 		mem_free_set(&cached->content_type, stracpy(str));
=20
@@ -170,7 +170,7 @@
 	}
 	case CACHE_ENTRY_HEAD: {
 		JSString *jsstr =3D JS_ValueToString(smjs_ctx, *vp);
-		unsigned char *str =3D JS_GetStringBytes(jsstr);
+		unsigned char *str =3D JS_EncodeString(smjs_ctx, jsstr);
=20
 		mem_free_set(&cached->head, stracpy(str));
=20
--- a/src/scripting/smjs/core.c
+++ b/src/scripting/smjs/core.c
@@ -98,7 +98,7 @@
                      jsval *argv, jsval *rval)
 {
 	JSString *jsstr =3D JS_ValueToString(smjs_ctx, *argv);
-	unsigned char *path =3D JS_GetStringBytes(jsstr);
+	unsigned char *path =3D JS_EncodeString(smjs_ctx, jsstr);
=20
 	if (smjs_do_file(path))
 		return JS_TRUE;
@@ -308,7 +308,7 @@
 	struct string utf8;
=20
 	utf16_len =3D JS_GetStringLength(jsstr);
-	utf16 =3D JS_GetStringChars(jsstr); /* stays owned by jsstr */
+	utf16 =3D JS_GetStringCharsZ(ctx, jsstr); /* stays owned by jsstr */
 	if (utf16 =3D=3D NULL) {
 		/* JS_GetStringChars doesn't have a JSContext *
 		 * parameter so it can't report the error
--- a/src/scripting/smjs/elinks_object.c
+++ b/src/scripting/smjs/elinks_object.c
@@ -61,7 +61,7 @@
 	jsstr =3D JS_ValueToString(smjs_ctx, *vp);
 	if (!jsstr) return JS_FALSE;
=20
-	url =3D JS_GetStringBytes(jsstr);
+	url =3D JS_EncodeString(smjs_ctx, jsstr);
 	if (!url) return JS_FALSE;
=20
 	goto_url(smjs_ses, url);
--- a/src/scripting/smjs/hooks.c
+++ b/src/scripting/smjs/hooks.c
@@ -41,7 +41,7 @@
 				ret =3D EVENT_HOOK_STATUS_LAST;
 		} else {
 			JSString *jsstr =3D JS_ValueToString(smjs_ctx, rval);
-			unsigned char *str =3D JS_GetStringBytes(jsstr);
+			unsigned char *str =3D JS_EncodeString(smjs_ctx, jsstr);
=20
 			mem_free_set(url, stracpy(str));
 		}
--- a/src/ecmascript/spidermonkey-shared.h
+++ b/src/ecmascript/spidermonkey-shared.h
@@ -68,7 +68,7 @@
 		return "";
 	}
=20
-	return empty_string_or_(JS_GetStringBytes(JS_ValueToString(ctx, val)));
+	return empty_string_or_(JS_EncodeString(ctx, JS_ValueToString(ctx, val)));
 }
=20
 #endif
--- a/src/ecmascript/spidermonkey/form.c
+++ b/src/ecmascript/spidermonkey/form.c
@@ -942,7 +942,7 @@
 static JSBool
 form_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
 {
-	/* DBG("doc %p %s\n", parent_doc, JS_GetStringBytes(JS_ValueToString(ctx,=
 OBJECT_TO_JSVAL(parent_doc)))); */
+	/* DBG("doc %p %s\n", parent_doc, JS_EncodeString(ctx, JS_ValueToString(c=
tx, OBJECT_TO_JSVAL(parent_doc)))); */
 	JSObject *parent_doc;	/* instance of @document_class */
 	JSObject *parent_win;	/* instance of @window_class */
 	struct view_state *vs;
@@ -1525,7 +1525,7 @@
 	if (JS_ConvertValue(ctx, *vp, JSTYPE_STRING, vp) =3D=3D JS_FALSE)
 		return UCS_NO_CHAR;
 	len =3D JS_GetStringLength(JSVAL_TO_STRING(*vp));
-	chr =3D JS_GetStringChars(JSVAL_TO_STRING(*vp));
+	chr =3D JS_GetStringCharsZ(ctx, JSVAL_TO_STRING(*vp));
=20
 	/* This implementation ignores extra characters in the string.  */
 	if (len < 1)

--AqsLC8rIMeq19msA--

--VrqPEDrXMn8OVzN4
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBCAAGBQJNoNERAAoJELwZapTt3aG3gmsH/jBS7sPoPOiEGiQwOXnbaMOM
0QgY+BhMaKbu8tIU1afQzNpBXI0+YtiNSG87xqLzj3CxbxK0qSkcYi+GiCXijvUD
UtK/YweG7gNwskRRINnnXHOaZb5Uzflap+H+ETzcI8rLL69P2DaSk0k/Zxpf+PZh
NPj7v5Fq98rMyIpgWSa1MQQvK7+nRplnar4SWMMqQMMdih9+XUbymYJclVYKCWd1
+k/Beh8SXWoDR4nfqMI5fvhQwoHzR+HHzmA7GC4mr0qfnE5r/Wl3A3i6tOhln+3g
7c05h8hgdHjlSJ7J9pdhBsHk33QcYhpp5QTGQrR6+SskSin2pSaMS4d6K+XPgPQ=
=TtyO
-----END PGP SIGNATURE-----

--VrqPEDrXMn8OVzN4--

--===============0400989610==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev

--===============0400989610==--