edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] Edbrowse 3.4.7
@ 2011-10-24 17:59 Jean-Philippe MENGUAL
  2011-10-24 20:27 ` Chris Brannon
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jean-Philippe MENGUAL @ 2011-10-24 17:59 UTC (permalink / raw)
  To: Edbrowse-dev


[-- Attachment #1.1: Type: text/plain, Size: 590 bytes --]

Hi,

Packaging edbrowse for Debian, I had to use some libmozjs in some
package. It seems this in thunderbird was used. More precisely, the
source knows to use only an old libmozjs, and it is contained in
thunderbird headers. But it seems deprecated and, thus, edhlowse crashes
at runtime.

Here's a patch which allows to use the latest javascript library,
installed in /usr/lib, instead of /usr/lib/icedove. Thanks to the patch,
now the package libmozjs-dev is used (it's newer and edbrowse doesn't
crash anymre).


I hope it can help.

Regards,

Jean-Philippe MENGUAL


[-- Attachment #1.2: libmozjs.patch --]
[-- Type: text/x-patch, Size: 31003 bytes --]

Index: a/src/eb.p
===================================================================
--- a/src/eb.p	(révision 19117)
+++ b/src/eb.p	(copie de travail)
@@ -237,7 +237,7 @@
 /* sourcefile=jsdom.c */
 JSString * our_JS_NewStringCopyN(JSContext * cx, const char *s, size_t n) ;
 JSString * our_JS_NewStringCopyZ(JSContext * cx, const char *s) ;
-char * transcode_get_js_bytes(JSString *s) ;
+char * transcode_get_js_bytes(JSContext * cx, JSString *s) ;
 void * createJavaContext(void) ;
 void freeJavaContext(void *jsc) ;
 void establish_innerHTML(void *jv, const char *start, const char *end, bool is_ta) ;
Index: a/src/jsloc.c
===================================================================
--- a/src/jsloc.c	(révision 19117)
+++ b/src/jsloc.c	(copie de travail)
@@ -33,10 +33,14 @@
 stringize(long v)
 {
     static char buf[24];
+    static char *dynamic;
     int n;
     jsdouble d;
     if(JSVAL_IS_STRING(v)) {
-	return JS_GetStringBytes(JSVAL_TO_STRING(v));
+	if (dynamic)
+	    JS_free(jcx, dynamic);
+	dynamic = JS_EncodeString(jcx, JSVAL_TO_STRING(v));
+	return dynamic;
     }
     if(JSVAL_IS_INT(v)) {
 	n = JSVAL_TO_INT(v);
@@ -44,7 +48,7 @@
 	return buf;
     }
     if(JSVAL_IS_DOUBLE(v)) {
-	d = *JSVAL_TO_DOUBLE(v);
+	d = JSVAL_TO_DOUBLE(v);
 	n = d;
 	if(n == d)
 	    sprintf(buf, "%d", n);
@@ -59,7 +63,7 @@
 static JSClass url_class = {
     "URL",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
@@ -87,16 +91,14 @@
 
 /* Converting to a string just pulls out the href property */
 static JSBool
-loc_toString(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+loc_toString(JSContext * cx, uintN argc, jsval * vp)
 {
-    JS_GetProperty(jcx, obj, "href", rval);
+    JS_GetProperty(jcx, JS_THIS_OBJECT(cx, vp), "href", vp);
     return JS_TRUE;
 }				/* loc_toString */
 
 static JSBool
-loc_reload(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+loc_reload(JSContext * cx, uintN argc, jsval * vp)
 {
     const char *s = cw->firstURL;
     if(s && isURL(s))
@@ -107,13 +109,12 @@
 }				/* loc_reload */
 
 static JSBool
-loc_replace(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+loc_replace(JSContext * cx, uintN argc, jsval * vp)
 {
     const char *s;
     char *ss, *t;
-    if(argc > 0 && JSVAL_IS_STRING(argv[0])) {
-	s = stringize(argv[0]);
+    if(argc > 0 && JSVAL_IS_STRING(JS_ARGV(cx, vp)[0])) {
+	s = stringize(JS_ARGV(cx, vp)[0]);
 /* I have to copy the string, just so I can run unpercent */
 	ss = cloneString(s);
 	unpercentURL(ss);
@@ -219,7 +220,7 @@
 /* define or set a local property */
 static void
 loc_def_set(const char *name, const char *s,
-   JSBool(*setter) (JSContext *, JSObject *, jsval, jsval *), jsuint attr)
+    JSBool(*setter) (JSContext *, JSObject *, jsid, JSBool strict, jsval *), jsuint attr)
 {
     JSBool found;
     jsval vv;
@@ -237,7 +238,7 @@
 /* Like the above, but using an integer, this is for port only. */
 static void
 loc_def_set_n(const char *name, int port,
-   JSBool(*setter) (JSContext *, JSObject *, jsval, jsval *), jsuint attr)
+    JSBool(*setter) (JSContext *, JSObject *, jsid, JSBool strict, jsval *), jsuint attr)
 {
     JSBool found;
     jsval vv = INT_TO_JSVAL(port);
@@ -250,7 +251,7 @@
 
 static void
 loc_def_set_part(const char *name, const char *s, int n,
-   JSBool(*setter) (JSContext *, JSObject *, jsval, jsval *), jsuint attr)
+    JSBool(*setter) (JSContext *, JSObject *, jsid, JSBool strict, jsval *), jsuint attr)
 {
     JSBool found;
     jsval vv;
@@ -266,7 +267,7 @@
 }				/* loc_def_set_part */
 
 static JSBool
-setter_loc(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_loc(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     const char *s = stringize(*vp);
     if(!s) {
@@ -288,7 +289,7 @@
 }				/* setter_loc */
 
 static JSBool
-setter_loc_href(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_loc_href(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     const char *url = 0;
     if(setter_suspend)
@@ -310,7 +311,7 @@
 }				/* setter_loc_href */
 
 static JSBool
-setter_loc_hash(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_loc_hash(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     const char *e;
     if(setter_suspend)
@@ -322,7 +323,7 @@
 }				/* setter_loc_hash */
 
 static JSBool
-setter_loc_search(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_loc_search(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     const char *e;
     if(setter_suspend)
@@ -334,7 +335,7 @@
 }				/* setter_loc_search */
 
 static JSBool
-setter_loc_prot(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_loc_prot(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     const char *e;
     if(setter_suspend)
@@ -346,7 +347,7 @@
 }				/* setter_loc_prot */
 
 static JSBool
-setter_loc_pathname(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_loc_pathname(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     const char *e;
     if(setter_suspend)
@@ -358,7 +359,7 @@
 }				/* setter_loc_pathname */
 
 static JSBool
-setter_loc_hostname(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_loc_hostname(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     const char *e;
     if(setter_suspend)
@@ -371,7 +372,7 @@
 }				/* setter_loc_hostname */
 
 static JSBool
-setter_loc_port(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_loc_port(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     int port;
     if(setter_suspend)
@@ -384,7 +385,7 @@
 }				/* setter_loc_port */
 
 static JSBool
-setter_loc_host(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_loc_host(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     const char *e, *s;
     int n;
@@ -494,22 +495,22 @@
 }				/* url_initialize */
 
 static JSBool
-url_ctor(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
+url_ctor(JSContext * cx, uintN argc, jsval * vp)
 {
     const char *url = 0;
     const char *s;
-    if(argc && JSVAL_IS_STRING(*argv)) {
-	s = stringize(argv[0]);
+    if(argc && JSVAL_IS_STRING(*JS_ARGV(cx, vp))) {
+	s = stringize(JS_ARGV(cx, vp)[0]);
 	if(strlen(s))
 	    url = s;
     }				/* string argument */
-    uo = obj;
+    uo = JS_THIS_OBJECT(cx, vp);
     url_initialize(url, false, false);
     return JS_TRUE;
 }				/* url_ctor */
 
 static JSFunctionSpec url_methods[] = {
-    {"toString", loc_toString, 0, 0, 0},
+    {"toString", loc_toString, 0, 0},
     {0}
 };
 
@@ -529,7 +530,7 @@
 *********************************************************************/
 
 static JSBool
-setter_value(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_value(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     const char *val;
     if(setter_suspend)
@@ -545,7 +546,7 @@
 }				/* setter_value */
 
 static JSBool
-setter_checked(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_checked(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     JSBool b;
     if(setter_suspend)
@@ -555,7 +556,7 @@
 }				/* setter_checked */
 
 static JSBool
-setter_selected(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_selected(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     JSBool b;
     if(setter_suspend)
@@ -565,7 +566,7 @@
 }				/* setter_selected */
 
 static JSBool
-setter_selidx(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_selidx(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     int n;
     if(setter_suspend)
@@ -575,7 +576,7 @@
 }				/* setter_selidx */
 
 static JSBool
-getter_cookie(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+getter_cookie(JSContext * cx, JSObject * obj, jsid id, jsval * vp)
 {
     int cook_l;
     char *cook = initString(&cook_l);
@@ -602,7 +603,7 @@
 }				/* getter_cookie */
 
 static JSBool
-setter_cookie(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_cookie(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     const char *host = getHostURL(cw->fileName);
     if(!host) {
@@ -616,7 +617,7 @@
 }				/* setter_cookie */
 
 static JSBool
-setter_domain(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_domain(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     const char *hostname = getHostURL(cw->fileName);
     const char *dom = 0;
@@ -639,8 +640,8 @@
 requiring no knowledge of smjs.
 *********************************************************************/
 
-static JSBool(*my_getter) (JSContext *, JSObject *, jsval, jsval *);
-static JSBool(*my_setter) (JSContext *, JSObject *, jsval, jsval *);
+static JSBool(*my_getter) (JSContext *, JSObject *, jsid, jsval *);
+static JSBool(*my_setter) (JSContext *, JSObject *, jsid, JSBool strict, jsval *);
 
 void
 establish_property_string(void *jv, const char *name, const char *value,
@@ -650,7 +651,8 @@
     if(readonly)
 	attr |= JSPROP_READONLY;
     JSObject *obj = jv;
-    my_getter = my_setter = 0;
+    my_getter = 0;
+    my_setter = 0;
     if(stringEqual(name, "value"))
 	my_setter = setter_value;
     if(stringEqual(name, "domain"))
@@ -899,7 +901,7 @@
 static JSClass option_class = {
     "Option",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 void *
Index: a/src/jsdom.c
===================================================================
--- a/src/jsdom.c	(révision 19117)
+++ b/src/jsdom.c	(copie de travail)
@@ -115,19 +115,27 @@
 }				/* our_JS_NewStringCopyZ */
 
 char *
-transcode_get_js_bytes(JSString *s)
+transcode_get_js_bytes(JSContext * cx, JSString *s)
 {
     char *converted = NULL;
     int converted_l = 0;
-    const char *origbytes = JS_GetStringBytes(s);
+    char *origbytes = JS_EncodeString(cx, s);
+    char *clone;
 
-    if(!JS_CStringsAreUTF8())
-	return cloneString(origbytes);
+    if(!JS_CStringsAreUTF8()) {
+	clone = cloneString(origbytes);
+	JS_free(cx, origbytes);
+	return clone;
+    }
 
-    if(cons_utf8)
-	return cloneString(origbytes);
+    if(cons_utf8) {
+	clone = cloneString(origbytes);
+	JS_free(cx, origbytes);
+	return clone;
+    }
 
     utf2iso(origbytes, strlen(origbytes), &converted, &converted_l);
+    JS_free(cx, origbytes);
     return converted;
 }			/* our_JS_GetTranscodedBytes */
 
@@ -156,96 +164,91 @@
 
 static JSClass window_class = {
     "Window",
-    JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JSCLASS_HAS_PRIVATE | JSCLASS_GLOBAL_FLAGS,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSBool
-window_ctor(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+window_ctor(JSContext * cx, uintN argc, jsval * vp)
 {
-    const char *newloc = 0;
+    char *newloc = 0;
     const char *winname = 0;
     JSString *str;
-    if(argc > 0 && (str = JS_ValueToString(jcx, argv[0]))) {
-	newloc = JS_GetStringBytes(str);
+    if(argc > 0 && (str = JS_ValueToString(jcx, JS_ARGV(cx, vp)[0]))) {
+	newloc = JS_EncodeString(cx, str);
     }
-    if(argc > 1 && (str = JS_ValueToString(jcx, argv[1]))) {
-	winname = transcode_get_js_bytes(str);
+    if(argc > 1 && (str = JS_ValueToString(jcx, JS_ARGV(cx, vp)[1]))) {
+	winname = transcode_get_js_bytes(cx, str);
     }
 /* third argument is attributes, like window size and location, that we don't care about. */
     javaOpensWindow(newloc, winname);
+    if (newloc)
+	JS_free(cx, newloc);
     if(!parsePage)
 	return JS_FALSE;
-    establish_property_object(obj, "opener", jwin);
+    establish_property_object(JS_THIS_OBJECT(cx, vp), "opener", jwin);
     return JS_TRUE;
 }				/* window_ctor */
 
 /* window.open() instantiates a new window object */
 static JSBool
-win_open(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
+win_open(JSContext * cx, uintN argc, jsval * vp)
 {
     JSObject *newwin = JS_ConstructObjectWithArguments(jcx,
-       &window_class, 0, jwin, argc, argv);
-    *rval = OBJECT_TO_JSVAL(newwin);
+       &window_class, 0, jwin, argc, JS_ARGV(cx, vp));
+    JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(newwin));
 }				/* win_open */
 
 /* for window.focus etc */
 static JSBool
-nullFunction(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+nullFunction(JSContext * cx, uintN argc, jsval * vp)
 {
     return JS_TRUE;
 }				/* nullFunction */
 
 static JSBool
-falseFunction(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+falseFunction(JSContext * cx, uintN argc, jsval * vp)
 {
-    *rval = JSVAL_FALSE;
+    JS_SET_RVAL(cx, vp, JSVAL_FALSE);
     return JS_TRUE;
 }				/* falseFunction */
 
 static JSBool
-trueFunction(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+trueFunction(JSContext * cx, uintN argc, jsval * vp)
 {
-    *rval = JSVAL_TRUE;
+    JS_SET_RVAL(cx, vp, JSVAL_TRUE);
     return JS_TRUE;
 }				/* trueFunction */
 
 static JSBool
-setAttribute(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+setAttribute(JSContext * cx, uintN argc, jsval * vp)
 {
-    if(argc != 2 || !JSVAL_IS_STRING(argv[0])) {
+    if(argc != 2 || !JSVAL_IS_STRING(JS_ARGV(cx, vp)[0])) {
 	JS_ReportError(jcx, "unexpected arguments to setAttribute()");
     } else {
-	const char *prop = stringize(argv[0]);
-	JS_DefineProperty(jcx, obj, prop, argv[1], NULL, NULL, PROP_FIXED);
+	const char *prop = stringize(JS_ARGV(cx, vp)[0]);
+	JS_DefineProperty(jcx, JS_THIS_OBJECT(cx, vp), prop, JS_ARGV(cx, vp)[1], NULL, NULL, PROP_FIXED);
     }
     return JS_TRUE;
 }				/* setAttribute */
 
 static JSBool
-appendChild(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+appendChild(JSContext * cx, uintN argc, jsval * vp)
 {
     JSObject *elar;		/* elements array */
     jsuint length;
     jsval v;
-    JS_GetProperty(jcx, obj, "elements", &v);
+    JS_GetProperty(jcx, JS_THIS_OBJECT(cx, vp), "elements", &v);
     elar = JSVAL_TO_OBJECT(v);
     JS_GetArrayLength(jcx, elar, &length);
     JS_DefineElement(jcx, elar, length,
-       (argc > 0 ? argv[0] : JSVAL_NULL), NULL, NULL, JSPROP_ENUMERATE);
+       (argc > 0 ? JS_ARGV(cx, vp)[0] : JSVAL_NULL), NULL, NULL, JSPROP_ENUMERATE);
     return JS_TRUE;
 }				/* appendChild */
 
 static JSBool
-win_close(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+win_close(JSContext * cx, uintN argc, jsval * vp)
 {
 /* It's too confusing to just close the window */
     i_puts(MSG_PageDone);
@@ -254,13 +257,12 @@
 }				/* win_close */
 
 static JSBool
-win_alert(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+win_alert(JSContext * cx, uintN argc, jsval * vp)
 {
     char *msg = NULL;
     JSString *str;
-    if(argc > 0 && (str = JS_ValueToString(jcx, argv[0]))) {
-	msg = transcode_get_js_bytes(str);
+    if(argc > 0 && (str = JS_ValueToString(jcx, JS_ARGV(cx, vp)[0]))) {
+	msg = transcode_get_js_bytes(cx, str);
     }
     if(msg) {
 	puts(msg);
@@ -270,8 +272,7 @@
 }				/* win_alert */
 
 static JSBool
-win_prompt(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+win_prompt(JSContext * cx, uintN argc, jsval * vp)
 {
     char *msg = EMPTYSTRING;
     char *answer = EMPTYSTRING;
@@ -280,11 +281,11 @@
     char *s;
     char c;
 
-    if(argc > 0 && (str = JS_ValueToString(jcx, argv[0]))) {
-	msg = transcode_get_js_bytes(str);
+    if(argc > 0 && (str = JS_ValueToString(jcx, JS_ARGV(cx, vp)[0]))) {
+	msg = transcode_get_js_bytes(cx, str);
     }
-    if(argc > 1 && (str = JS_ValueToString(jcx, argv[1]))) {
-	answer = transcode_get_js_bytes(str);
+    if(argc > 1 && (str = JS_ValueToString(jcx, JS_ARGV(cx, vp)[1]))) {
+	answer = transcode_get_js_bytes(cx, str);
     }
 
     printf("%s", msg);
@@ -309,13 +310,12 @@
 	nzFree(answer);		/* Don't need the default answer anymore. */
 	answer = inbuf;
     }
-    *rval = STRING_TO_JSVAL(our_JS_NewStringCopyZ(jcx, answer));
+    JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(our_JS_NewStringCopyZ(jcx, answer)));
     return JS_TRUE;
 }				/* win_prompt */
 
 static JSBool
-win_confirm(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+win_confirm(JSContext * cx, uintN argc, jsval * vp)
 {
     char *msg = EMPTYSTRING;
     JSString *str;
@@ -324,8 +324,8 @@
     char c;
     bool first = true;
 
-    if(argc > 0 && (str = JS_ValueToString(jcx, argv[0]))) {
-	msg = transcode_get_js_bytes(str);
+    if(argc > 0 && (str = JS_ValueToString(jcx, JS_ARGV(cx, vp)[0]))) {
+	msg = transcode_get_js_bytes(cx, str);
     }
 
     while(true) {
@@ -351,9 +351,9 @@
 
     c = tolower(c);
     if(c == 'y')
-	*rval = JSVAL_TRUE;
+	JS_SET_RVAL(cx, vp, JSVAL_TRUE);
     else
-	*rval = JSVAL_FALSE;
+	JS_SET_RVAL(cx, vp, JSVAL_FALSE);
     nzFree(msg);
     return JS_TRUE;
 }				/* win_confirm */
@@ -361,7 +361,7 @@
 static JSClass timer_class = {
     "Timer",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
@@ -403,7 +403,8 @@
 	if(fo) {
 /* Extract the function name, which requires several steps */
 	    JSFunction *f = JS_ValueToFunction(jcx, OBJECT_TO_JSVAL(fo));
-	    const char *s = JS_GetFunctionName(f);
+	    JSString *js = JS_GetFunctionId(f);
+	    char *s = transcode_get_js_bytes(jcx, js);
 /* Remember that unnamed functions are named anonymous. */
 	    if(!s || !*s || stringEqual(s, "anonymous"))
 		s = "javascript";
@@ -411,6 +412,7 @@
 	    if(len > sizeof (fname) - 4)
 		len = sizeof (fname) - 4;
 	    strncpy(fname, s, len);
+	    nzFree(s);
 	    fname[len] = 0;
 	    strcat(fname, "()");
 	    fstr = fname;
@@ -432,37 +434,37 @@
 }				/* setTimeout */
 
 static JSBool
-win_sto(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
+win_sto(JSContext * cx, uintN argc, jsval * vp)
 {
-    *rval = OBJECT_TO_JSVAL(setTimeout(argc, argv, false));
+    JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(setTimeout(argc, JS_ARGV(cx, vp), false)));
     return JS_TRUE;
 }				/* win_sto */
 
 static JSBool
-win_intv(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
+win_intv(JSContext * cx, uintN argc, jsval * vp)
 {
-    *rval = OBJECT_TO_JSVAL(setTimeout(argc, argv, true));
+    JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(setTimeout(argc, JS_ARGV(cx, vp), true)));
     return JS_TRUE;
 }				/* win_intv */
 
 static JSFunctionSpec window_methods[] = {
-    {"alert", win_alert, 1, 0, 0},
-    {"prompt", win_prompt, 2, 0, 0},
-    {"confirm", win_confirm, 1, 0, 0},
-    {"setTimeout", win_sto, 2, 0, 0},
-    {"setInterval", win_intv, 2, 0, 0},
-    {"open", win_open, 3, 0, 0},
-    {"close", win_close, 0, 0, 0},
-    {"focus", nullFunction, 0, 0, 0},
-    {"blur", nullFunction, 0, 0, 0},
-    {"scroll", nullFunction, 0, 0, 0},
+    {"alert", win_alert, 1, 0},
+    {"prompt", win_prompt, 2, 0},
+    {"confirm", win_confirm, 1, 0},
+    {"setTimeout", win_sto, 2, 0},
+    {"setInterval", win_intv, 2, 0},
+    {"open", win_open, 3, 0},
+    {"close", win_close, 0, 0},
+    {"focus", nullFunction, 0, 0},
+    {"blur", nullFunction, 0, 0},
+    {"scroll", nullFunction, 0, 0},
     {0}
 };
 
 static JSClass doc_class = {
     "Document",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
@@ -477,14 +479,14 @@
 }				/* dwrite2 */
 
 static void
-dwrite1(uintN argc, jsval * argv, bool newline)
+dwrite1(JSContext * cx, uintN argc, jsval * argv, bool newline)
 {
     int i;
     char *msg;
     JSString *str;
     for(i = 0; i < argc; ++i) {
 	if((str = JS_ValueToString(jcx, argv[i])) &&
-	   (msg = transcode_get_js_bytes(str))) {
+	   (msg = transcode_get_js_bytes(cx, str))) {
 	    dwrite2(msg);
 	nzFree(msg);
 	}
@@ -494,15 +496,14 @@
 }				/* dwrite1 */
 
 static JSBool
-doc_write(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+doc_write(JSContext * cx, uintN argc, jsval * vp)
 {
-    dwrite1(argc, argv, false);
+    dwrite1(cx, argc, JS_ARGV(cx, vp), false);
     return JS_TRUE;
 }				/* doc_write */
 
 static JSBool
-setter_innerHTML(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_innerHTML(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     const char *s = stringize(*vp);
     if(s && strlen(s)) {
@@ -516,108 +517,106 @@
 }				/* setter_innerHTML */
 
 static JSBool
-setter_innerText(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
+setter_innerText(JSContext * cx, JSObject * obj, jsid id, JSBool strict, jsval * vp)
 {
     jsval v = *vp;
-    const char *s;
+    char *s;
     if(!JSVAL_IS_STRING(v))
 	return JS_FALSE;
-    s = JS_GetStringBytes(JSVAL_TO_STRING(v));
+    s = JS_EncodeString(cx, JSVAL_TO_STRING(v));
     i_puts(MSG_InnerText);
 /* The string has already been updated in the object. */
+    JS_free(cx, s);
     return JS_TRUE;
 }				/* setter_innerText */
 
 static JSBool
-doc_writeln(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+doc_writeln(JSContext * cx, uintN argc, jsval * vp)
 {
-    dwrite1(argc, argv, true);
+    dwrite1(cx, argc, JS_ARGV(cx, vp), true);
     return JS_TRUE;
 }				/* doc_writeln */
 
 static JSFunctionSpec doc_methods[] = {
-    {"focus", nullFunction, 0, 0, 0},
-    {"blur", nullFunction, 0, 0, 0},
-    {"open", nullFunction, 0, 0, 0},
-    {"close", nullFunction, 0, 0, 0},
-    {"write", doc_write, 0, 0, 0},
-    {"writeln", doc_writeln, 0, 0, 0},
+    {"focus", nullFunction, 0, 0},
+    {"blur", nullFunction, 0, 0},
+    {"open", nullFunction, 0, 0},
+    {"close", nullFunction, 0, 0},
+    {"write", doc_write, 0, 0},
+    {"writeln", doc_writeln, 0, 0},
     {0}
 };
 
 static JSClass element_class = {
     "Element",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSFunctionSpec element_methods[] = {
-    {"focus", nullFunction, 0, 0, 0},
-    {"blur", nullFunction, 0, 0, 0},
+    {"focus", nullFunction, 0, 0},
+    {"blur", nullFunction, 0, 0},
     {0}
 };
 
 static JSClass form_class = {
     "Form",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSBool
-form_submit(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+form_submit(JSContext * cx, uintN argc, jsval * vp)
 {
-    javaSubmitsForm(obj, false);
+    javaSubmitsForm(JS_THIS_OBJECT(cx, vp), false);
     return JS_TRUE;
 }				/* form_submit */
 
 static JSBool
-form_reset(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
-   jsval * rval)
+form_reset(JSContext * cx, uintN argc, jsval * vp)
 {
-    javaSubmitsForm(obj, true);
+    javaSubmitsForm(JS_THIS_OBJECT(cx, vp), true);
     return JS_TRUE;
 }				/* form_reset */
 
 static JSFunctionSpec form_methods[] = {
-    {"submit", form_submit, 0, 0, 0},
-    {"reset", form_reset, 0, 0, 0},
+    {"submit", form_submit, 0, 0},
+    {"reset", form_reset, 0, 0},
     {0}
 };
 
 static JSClass body_class = {
     "Body",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSFunctionSpec body_methods[] = {
-    {"setAttribute", setAttribute, 2, 0, 0},
-    {"appendChild", appendChild, 1, 0, 0},
+    {"setAttribute", setAttribute, 2, 0},
+    {"appendChild", appendChild, 1, 0},
     {0}
 };
 
 static JSClass head_class = {
     "Head",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSFunctionSpec head_methods[] = {
-    {"setAttribute", setAttribute, 2, 0, 0},
-    {"appendChild", appendChild, 1, 0, 0},
+    {"setAttribute", setAttribute, 2, 0},
+    {"appendChild", appendChild, 1, 0},
     {0}
 };
 
 static JSClass meta_class = {
     "Meta",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
@@ -625,89 +624,89 @@
 static JSClass link_class = {
     "Link",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSFunctionSpec link_methods[] = {
-    {"setAttribute", setAttribute, 2, 0, 0},
+    {"setAttribute", setAttribute, 2, 0},
     {0}
 };
 
 static JSClass image_class = {
     "Image",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSClass frame_class = {
     "Frame",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSClass anchor_class = {
     "Anchor",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSClass table_class = {
     "Table",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSClass trow_class = {
     "Trow",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSClass cell_class = {
     "Cell",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSClass div_class = {
     "Div",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSClass span_class = {
     "Span",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSClass area_class = {
     "Area",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 static JSClass option_class = {
     "Option",
     JSCLASS_HAS_PRIVATE,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
 };
 
 struct DOMCLASS {
     JSClass *class;
     JSFunctionSpec *methods;
-      JSBool(*constructor) (JSContext *, JSObject *, uintN, jsval *, jsval *);
+      JSBool(*constructor) (JSContext *, uintN, jsval *);
     int nargs;
 };
 
@@ -809,14 +808,9 @@
     JS_SetOptions(jcx, JSOPTION_VAROBJFIX);
 
 /* Create the Window object, which is the global object in DOM. */
-    jwin = JS_NewObject(jcx, &window_class, NULL, NULL);
+    jwin = JS_NewCompartmentAndGlobalObject(jcx, &window_class, NULL);
     if(!jwin)
 	i_printfExit(MSG_JavaWindowError);
-    JS_InitClass(jcx, jwin, 0, &window_class, window_ctor, 3,
-       NULL, window_methods, NULL, NULL);
-/* Ok, but the global object was created before the class,
- * so it doesn't have its methods yet. */
-    JS_DefineFunctions(jcx, jwin, window_methods);
 
 /* Math, Date, Number, String, etc */
     if(!JS_InitStandardClasses(jcx, jwin))

[-- Attachment #2: Ceci est une partie de message numériquement signée --]
[-- Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Edbrowse-dev] Edbrowse 3.4.7
  2011-10-24 17:59 [Edbrowse-dev] Edbrowse 3.4.7 Jean-Philippe MENGUAL
@ 2011-10-24 20:27 ` Chris Brannon
  2011-10-24 20:28 ` Chris Brannon
  2011-10-24 20:29 ` Chris Brannon
  2 siblings, 0 replies; 4+ messages in thread
From: Chris Brannon @ 2011-10-24 20:27 UTC (permalink / raw)
  To: Edbrowse-dev

Jean-Philippe MENGUAL <mengualjeanphi@free.fr> writes:

> Hi,
>
> Packaging edbrowse for Debian, I had to use some libmozjs in some
> package. It seems this in thunderbird was used. More precisely, the
> source knows to use only an old libmozjs, and it is contained in
> thunderbird headers. But it seems deprecated and, thus, edhlowse crashes
> at runtime.

Hi,
First of all, thank  you very much for the patch.
edbrowse doesn't build after I apply it over here.  If you look at the
git repo, you'll find a jswork branch.  The code on that branch will
build against Spidermonkey 1.8.5.  The only reason I haven't published
it as version 3.4.8, is that I can't guarantee that it is free from
memory leaks and the like.  In fact, the stringize function definitely
leaks memory.  I see what you did with stringize, but I think that yours
leads to dangling pointers.

Which version of spidermonkey are you building against?

-- Chris

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Edbrowse-dev] Edbrowse 3.4.7
  2011-10-24 17:59 [Edbrowse-dev] Edbrowse 3.4.7 Jean-Philippe MENGUAL
  2011-10-24 20:27 ` Chris Brannon
@ 2011-10-24 20:28 ` Chris Brannon
  2011-10-24 20:29 ` Chris Brannon
  2 siblings, 0 replies; 4+ messages in thread
From: Chris Brannon @ 2011-10-24 20:28 UTC (permalink / raw)
  To: Edbrowse-dev

Jean-Philippe MENGUAL <mengualjeanphi@free.fr> writes:

> Hi,
>
> Packaging edbrowse for Debian, I had to use some libmozjs in some
> package. It seems this in thunderbird was used. More precisely, the
> source knows to use only an old libmozjs, and it is contained in
> thunderbird headers. But it seems deprecated and, thus, edhlowse crashes
> at runtime.

Hi,
First of all, thank  you very much for the patch.
edbrowse doesn't build after I apply it over here.  If you look at the
git repo, you'll find a jswork branch.  The code on that branch will
build against Spidermonkey 1.8.5.  The only reason I haven't published
it as version 3.4.8, is that I can't guarantee that it is free from
memory leaks and the like.  In fact, the stringize function definitely
leaks memory.  I see what you did with stringize, but I think that yours
leads to dangling pointers.

Which version of spidermonkey are you building against?

-- Chris

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Edbrowse-dev] Edbrowse 3.4.7
  2011-10-24 17:59 [Edbrowse-dev] Edbrowse 3.4.7 Jean-Philippe MENGUAL
  2011-10-24 20:27 ` Chris Brannon
  2011-10-24 20:28 ` Chris Brannon
@ 2011-10-24 20:29 ` Chris Brannon
  2 siblings, 0 replies; 4+ messages in thread
From: Chris Brannon @ 2011-10-24 20:29 UTC (permalink / raw)
  To: Edbrowse-dev

Jean-Philippe MENGUAL <mengualjeanphi@free.fr> writes:

> Hi,
>
> Packaging edbrowse for Debian, I had to use some libmozjs in some
> package. It seems this in thunderbird was used. More precisely, the
> source knows to use only an old libmozjs, and it is contained in
> thunderbird headers. But it seems deprecated and, thus, edhlowse crashes
> at runtime.

Hi,
First of all, thank  you very much for the patch.
edbrowse doesn't build after I apply it over here.  If you look at the
git repo, you'll find a jswork branch.  The code on that branch will
build against Spidermonkey 1.8.5.  The only reason I haven't published
it as version 3.4.8, is that I can't guarantee that it is free from
memory leaks and the like.  In fact, the stringize function definitely
leaks memory.  I see what you did with stringize, but I think that yours
leads to dangling pointers.

Which version of spidermonkey are you building against?

-- Chris

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-10-24 20:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-24 17:59 [Edbrowse-dev] Edbrowse 3.4.7 Jean-Philippe MENGUAL
2011-10-24 20:27 ` Chris Brannon
2011-10-24 20:28 ` Chris Brannon
2011-10-24 20:29 ` Chris Brannon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).