[mw-devel] MW3 r1260 - branches/wheezy/src

kais58 at sucs.org kais58 at sucs.org
Fri Sep 7 13:58:47 BST 2012


Author: kais58
Date: 2012-09-07 13:58:47 +0100 (Fri, 07 Sep 2012)
New Revision: 1260

Modified:
   branches/wheezy/src/js.c
Log:
Update to wheezy libmozjs


Modified: branches/wheezy/src/js.c
===================================================================
--- branches/wheezy/src/js.c	2012-09-07 12:53:35 UTC (rev 1259)
+++ branches/wheezy/src/js.c	2012-09-07 12:58:47 UTC (rev 1260)
@@ -59,35 +59,35 @@
 
 JSClass globclass = {
 	"milliways", 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,
 	JSCLASS_NO_OPTIONAL_MEMBERS
 };
 
 JSClass js_dbresultclass = {
 	"dbresult", 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,
 	JSCLASS_NO_OPTIONAL_MEMBERS
 };
 
 JSClass js_whoclass = {
 	"who", 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,
 	JSCLASS_NO_OPTIONAL_MEMBERS
 };
 
 JSClass js_userrecordclass = {
 	"userrecord", 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,
 	JSCLASS_NO_OPTIONAL_MEMBERS
 };
 
 JSClass js_termsizeclass = {
 	"termsize", 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,
 	JSCLASS_NO_OPTIONAL_MEMBERS
 };
@@ -140,7 +140,7 @@
 /* Function for printing to standard out from javascript (helpful for
  * debugging and demonstrates how to call C from js) - also useful for event functions
  */
-static JSBool js_print(JSContext *cx, JSObject __attribute__((unused)) *obj, uintN argc, jsval *argv, jsval __attribute__((unused)) *rval) 
+static JSBool js_print(JSContext *cx, uintN argc, jsval *vp) 
 {
 	uintN i;
 	char *msg;
@@ -149,17 +149,17 @@
 	}
 	
 	for (i = 0; i<argc; i++) {
-		if (JSVAL_IS_STRING(argv[i]) || JSVAL_IS_NUMBER(argv[i])) {
-			msg = JS_GetStringBytes(JS_ValueToString(cx, argv[i]));
+		if (JSVAL_IS_STRING(JS_ARGV(cx,vp)[i]) || JSVAL_IS_NUMBER(JS_ARGV(cx,vp)[i])) {
+			msg = JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[i]));
 			display_message(msg, 0, 1);
 			
 		} else 
-		if (JSVAL_IS_NULL(argv[i])) {
+		if (JSVAL_IS_NULL(JS_ARGV(cx,vp)[i])) {
 			display_message("jsval is NULL",0,1);
 		} else
-		if (JSVAL_IS_OBJECT(argv[i])) {
-			printf("jsval at %p\n", (void *)argv[i]);
-			if (JS_IsArrayObject(cx, JSVAL_TO_OBJECT(argv[i]))) {
+		if (JSVAL_IS_OBJECT(JS_ARGV(cx,vp)[i])) {
+			printf("jsval at %p\n", (void *) &JS_ARGV(cx,vp)[i]);
+			if (JS_IsArrayObject(cx, JSVAL_TO_OBJECT(JS_ARGV(cx,vp)[i]))) {
 				display_message("jsval is an (Array)",0,1);
 			}
 		}
@@ -168,7 +168,7 @@
 }
 
 /* execute a talker command */
-static JSBool js_mwexec(JSContext *cx, JSObject __attribute__((unused)) *obj, uintN argc, jsval *argv, jsval __attribute__((unused)) *rval) 
+static JSBool js_mwexec(JSContext *cx, uintN argc, jsval *vp) 
 {
 	char msg[MAXTEXTLENGTH];
 	if (argc < 1) {
@@ -176,11 +176,11 @@
 		return JS_FALSE;
 	}
 	
-	if (JSVAL_IS_STRING(argv[0])) {
+	if (JSVAL_IS_STRING(JS_ARGV(cx,vp)[0])) {
 		
 		// DoCommand seems to like a buffer of MAXTEXTLENGTH that is can alter so best
 		//  to copy the non-editable result from JS_GetStringBytes
-		strncpy(msg, JS_GetStringBytes(JS_ValueToString(cx, argv[0])), MAXTEXTLENGTH-100);
+		strncpy(msg, JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[0])), MAXTEXTLENGTH-100);
 		msg[MAXTEXTLENGTH-100] = '\0' ;
 		DoCommand(msg, chattable);
 		return JS_TRUE;
@@ -191,7 +191,7 @@
 
 
 /* say to the talker */
-static JSBool js_say(JSContext *cx, JSObject __attribute__((unused)) *obj, uintN argc, jsval *argv, jsval __attribute__((unused)) *rval) 
+static JSBool js_say(JSContext *cx, uintN argc, jsval *vp) 
 {
 	char msg[MAXTEXTLENGTH];
 	//int conversion_result;
@@ -207,11 +207,11 @@
 		return JS_FALSE;
 	}
 	
-	if (JSVAL_IS_STRING(argv[0]) || JSVAL_IS_NUMBER(argv[0])) {
+	if (JSVAL_IS_STRING(JS_ARGV(cx,vp)[0]) || JSVAL_IS_NUMBER(JS_ARGV(cx,vp)[0])) {
 	
 		// chat_say seems to like a buffer of MAXTEXTLENGTH that is can alter so best
 		//  to copy the non-editable result from JS_GetStringBytes
-		strncpy(msg, JS_GetStringBytes(JS_ValueToString(cx, argv[0])), MAXTEXTLENGTH-100);
+		strncpy(msg, JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[0])), MAXTEXTLENGTH-100);
 		msg[MAXTEXTLENGTH-100] = '\0' ;
 		chat_say(msg);
 		return JS_TRUE;
@@ -223,7 +223,7 @@
 }
 
 /* send an rpc/rpb */
-static JSBool js_rpc(JSContext *cx, JSObject __attribute__((unused)) *obj, uintN argc, jsval *argv, jsval __attribute__((unused)) *rval) 
+static JSBool js_rpc(JSContext *cx, uintN argc, jsval *vp) 
 {
 	char msg[MAXTEXTLENGTH]="";
 	char rpc_type[MAXTEXTLENGTH]="";
@@ -234,21 +234,21 @@
 		JS_ReportError(cx, "Error: javascript rpc() expects 3 arguments");
 		return JS_FALSE;
 	}
-	if(JSVAL_IS_INT(argv[0])) {
-		if(JSVAL_TO_INT(argv[0]) == K_BROADCAST) {
+	if(JSVAL_IS_INT(JS_ARGV(cx,vp)[0])) {
+		if(JSVAL_TO_INT(JS_ARGV(cx,vp)[0]) == K_BROADCAST) {
 			broadcast=1;
 		}
 	}
 	
-	if (JSVAL_IS_STRING(argv[0])) {
-		strncpy(username, JS_GetStringBytes(JS_ValueToString(cx, argv[0])), NAMESIZE);
+	if (JSVAL_IS_STRING(JS_ARGV(cx,vp)[0])) {
+		strncpy(username, JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[0])), NAMESIZE);
 		username[NAMESIZE] = '\0' ;
 	}
 	
-	strncpy(rpc_type, JS_GetStringBytes(JS_ValueToString(cx, argv[1])), MAXTEXTLENGTH);
+	strncpy(rpc_type, JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[1])), MAXTEXTLENGTH);
 	rpc_type[MAXTEXTLENGTH-1] = '\0' ;
 
-	strncpy(msg, JS_GetStringBytes(JS_ValueToString(cx, argv[2])), MAXTEXTLENGTH);
+	strncpy(msg, JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[2])), MAXTEXTLENGTH);
 	msg[MAXTEXTLENGTH-1] = '\0' ;
 	// something is empty
 	if( (broadcast==0 && username[0]=='\0') || rpc_type[0]=='\0') {
@@ -262,7 +262,7 @@
 }
 
 /* send an ipc/ipb */
-static JSBool js_ipc(JSContext *cx, JSObject __attribute__((unused)) *obj, uintN argc, jsval *argv, jsval __attribute__((unused)) *rval) 
+static JSBool js_ipc(JSContext *cx, uintN argc, jsval *vp) 
 {
 	char msg[MAXTEXTLENGTH]="";
 	char username[NAMESIZE+1]="";
@@ -271,18 +271,18 @@
 		JS_ReportError(cx, "Error: javascript ipc() expects 2 arguments");
 		return JS_FALSE;
 	}
-	if(JSVAL_IS_INT(argv[0])) {
-		if(JSVAL_TO_INT(argv[0]) == K_BROADCAST) {
+	if(JSVAL_IS_INT(JS_ARGV(cx,vp)[0])) {
+		if(JSVAL_TO_INT(JS_ARGV(cx,vp)[0]) == K_BROADCAST) {
 			broadcast=1;
 		}
 	}
-	if (JSVAL_IS_STRING(argv[0])) {
-		strncpy(username, JS_GetStringBytes(JS_ValueToString(cx, argv[0])), NAMESIZE);
+	if (JSVAL_IS_STRING(JS_ARGV(cx,vp)[0])) {
+		strncpy(username, JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[0])), NAMESIZE);
 		username[NAMESIZE] = '\0' ;
 	}
 	
 
-	strncpy(msg, JS_GetStringBytes(JS_ValueToString(cx, argv[1])), MAXTEXTLENGTH);
+	strncpy(msg, JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[1])), MAXTEXTLENGTH);
 	msg[MAXTEXTLENGTH-1] = '\0' ;
 
 	// not broadcast and no username
@@ -297,21 +297,21 @@
 }
 
 /* ask a user for extra input */
-static JSBool js_input(JSContext *cx, JSObject __attribute__((unused)) *obj, uintN argc, jsval *argv, jsval *rval) 
+static JSBool js_input(JSContext *cx, uintN argc, jsval *vp) 
 {
 	JSString *the_jsstring, *jsstr;
 	size_t ucs2_length, prompt_length, line_length;
-	jschar *ucs2_string;
+	const jschar *ucs2_string;
 	int conv_error;
 	
 	char *prompt=NULL, *line;
 	
 	if(argc > 0) {
-		if(JSVAL_IS_STRING(argv[0])) {
+		if(JSVAL_IS_STRING(JS_ARGV(cx,vp)[0])) {
 			// convert prompt to local - this bit of ugliness is still needed in case people aren't using utf8
-			the_jsstring = JS_ValueToString(cx, argv[0]);
+			the_jsstring = JS_ValueToString(cx, JS_ARGV(cx,vp)[0]);
 			ucs2_length=JS_GetStringLength(the_jsstring);
-			ucs2_string=JS_GetStringChars(the_jsstring);
+			ucs2_string=JS_GetStringCharsZ(jscx, the_jsstring);
 			prompt_length=sizeof(char)*((ucs2_length*3)+1); // bit ugly
 			prompt=malloc(prompt_length); 
 			if(prompt!=NULL) {
@@ -354,25 +354,25 @@
 			jsstr = JS_NewStringCopyZ(cx, "(garbled string)");
 		}
 	
-		free(ucs2_string);
+		free((jschar*)ucs2_string);
 	} else {
 		jsstr = JS_NewStringCopyZ(cx, "(garbled string)");		
 	}
-	*rval=STRING_TO_JSVAL(jsstr);
+	JS_SET_RVAL(cx,vp,STRING_TO_JSVAL(jsstr));
 	
 	return JS_TRUE;
 }
 
 
 /* beep */
-static JSBool js_beep(JSContext *cx, JSObject __attribute__((unused)) *obj, uintN argc, jsval *argv, jsval __attribute__((unused)) *rval) 
+static JSBool js_beep(JSContext *cx, uintN argc, jsval *vp) 
 {
 	int i, beeps=0;
 	if(argc < 1) {
 		beeps=1;
 	}
-	else if(JSVAL_IS_INT(argv[0])) {
-		beeps=JSVAL_TO_INT(argv[0]);
+	else if(JSVAL_IS_INT(JS_ARGV(cx,vp)[0])) {
+		beeps=JSVAL_TO_INT(JS_ARGV(cx,vp)[0]);
 		if(beeps < 1 || beeps > 5) {
 			beeps=0;
 			js_warning(cx, "beep() will only do between 1 and 5 beeps");
@@ -389,7 +389,7 @@
 }
 
 /* bind something to a javascript function */
-static JSBool js_bind(JSContext *cx, JSObject __attribute__((unused)) *obj, uintN argc, jsval *argv, jsval __attribute__((unused)) *rval) 
+static JSBool js_bind(JSContext *cx, uintN argc, jsval *vp) 
 {
 	char *bind=NULL;
 	char *function_name=NULL;
@@ -405,22 +405,22 @@
 		return JS_FALSE;
 	}
 		
-	if (JSVAL_IS_STRING(argv[0])) {
-		bind = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+	if (JSVAL_IS_STRING(JS_ARGV(cx,vp)[0])) {
+		bind = JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[0]));
 		bind_type=K_BIND;
-	} else if (JSVAL_IS_INT(argv[0])) {
-		bind_type=JSVAL_TO_INT(argv[0]);
+	} else if (JSVAL_IS_INT(JS_ARGV(cx,vp)[0])) {
+		bind_type=JSVAL_TO_INT(JS_ARGV(cx,vp)[0]);
 		if(bind_type == K_BIND || bind_type == K_BIND_ALIAS || bind_type == K_BIND_RPC) {
 			i++;
-			bind = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+			bind = JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[1]));
 
 		}
 	} else {
 		JS_ReportError(cx, "Error in javascript: bind expects first argument to be a string or a recognised bind id");
 		return JS_FALSE;
 	}
-	if (argc>= i-1 && JSVAL_IS_STRING(argv[i])) {
-		function_name = JS_GetStringBytes(JS_ValueToString(cx, argv[i]));
+	if (argc>= i-1 && JSVAL_IS_STRING(JS_ARGV(cx,vp)[i])) {
+		function_name = JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[i]));
 
 	} else {
 		JS_ReportError(cx, "Error in javascript: bind expects final argument to be a string.");
@@ -516,7 +516,7 @@
 }
 
 /* bind something to a javascript function */
-static JSBool js_unbind(JSContext *cx, JSObject __attribute__((unused)) *obj, uintN argc, jsval *argv, jsval __attribute__((unused)) *rval) 
+static JSBool js_unbind(JSContext *cx, uintN argc, jsval *vp) 
 {
 	char *bind=NULL;
 	char *function_name=NULL;
@@ -530,13 +530,13 @@
 		return JS_FALSE;
 	}
 		
-	if (JSVAL_IS_STRING(argv[0])) {
-		bind = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+	if (JSVAL_IS_STRING(JS_ARGV(cx,vp)[0])) {
+		bind = JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[0]));
 		bind_type=K_BIND;
-	} else if (JSVAL_IS_INT(argv[0])) {
-		bind_type=JSVAL_TO_INT(argv[0]);
-		if(JSVAL_IS_STRING(argv[1])) {
-			bind = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+	} else if (JSVAL_IS_INT(JS_ARGV(cx,vp)[0])) {
+		bind_type=JSVAL_TO_INT(JS_ARGV(cx,vp)[0]);
+		if(JSVAL_IS_STRING(JS_ARGV(cx,vp)[1])) {
+			bind = JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[1]));
 			function_name = bind;
 		} else {
 			JS_ReportError(cx, "Error in javascript: bind expects final argument to be a string.");
@@ -636,7 +636,7 @@
 }
 
 // return the users terminal dimensions
-static JSBool js_termsize(JSContext *cx, JSObject __attribute__((unused)) *obj, uintN argc, jsval *argv, jsval *rval) 
+static JSBool js_termsize(JSContext *cx, uintN argc, jsval *vp) 
 {
 	JSObject *result_object;
 	jsval jv;
@@ -658,12 +658,12 @@
 	JS_DefineProperty(cx, result_object, "height", INT_TO_JSVAL(height), NULL, NULL, 0);
 	
 	
-	*rval=jv;
+	JS_SET_RVAL(cx, vp, jv);
 	return JS_TRUE;
 }
 
 // Provides a javascript function to query the wholist
-static JSBool js_wholist(JSContext *cx, JSObject __attribute__((unused)) *obj, uintN argc, jsval *argv, jsval *rval) {
+static JSBool js_wholist(JSContext *cx, uintN argc, jsval *vp) {
 	struct person u;
 	struct who w;
 	int ufile, wfile;
@@ -678,7 +678,7 @@
 		return JS_FALSE;
 	}
 	res = JS_NewArrayObject(cx, 0, NULL);
-	JS_AddRoot(cx, res);
+	JS_AddObjectRoot(cx, &res);
 
 	while (read(wfile,&w,sizeof(w))) {
 		JSObject *user_record;
@@ -731,8 +731,8 @@
 	close(wfile);
 	close(ufile);
 
-	JS_RemoveRoot(cx, res);
-	*rval = OBJECT_TO_JSVAL(res);
+	JS_RemoveObjectRoot(cx, &res);
+	JS_SET_RVAL( cx, vp, OBJECT_TO_JSVAL(res));
 	return JS_TRUE;
 }
 
@@ -749,7 +749,7 @@
 
 /* Function to make a url GET request and return the resulting page
  */
-static JSBool js_urlget(JSContext *cx, JSObject __attribute__((unused)) *obj, uintN argc, jsval *argv, jsval __attribute__((unused)) *rval) 
+static JSBool js_urlget(JSContext *cx, uintN argc, jsval *vp) 
 {
 	char *url;
 	JSString *jsstr;
@@ -762,12 +762,12 @@
 		return JS_FALSE;
 	}
 	
-	if (JSVAL_IS_STRING(argv[0])) {
+	if (JSVAL_IS_STRING(JS_ARGV(cx,vp)[0])) {
 		CURL *cl;
 		char cerr[CURL_ERROR_SIZE];
 		struct block_t *answer = block_new(1024);
 
-		url = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+		url = JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[0]));
 		cl = curl_easy_init();
 		curl_easy_setopt(cl, CURLOPT_WRITEFUNCTION, urldata);
 		curl_easy_setopt(cl, CURLOPT_WRITEDATA, answer);
@@ -788,7 +788,7 @@
 		curl_easy_cleanup(cl);
 
 		jsstr = JS_NewStringCopyZ(cx, answer->p_buffer);
-		*rval = STRING_TO_JSVAL(jsstr);
+		JS_SET_RVAL(cx,vp,STRING_TO_JSVAL(jsstr));
 
 		free(answer);
 		return JS_TRUE;
@@ -812,7 +812,7 @@
 	if (data == NULL || ncols < 1) return NULL;
 
 	jsdata = JS_NewArrayObject(cx, 0, NULL);
-	JS_AddRoot(cx, jsdata);
+	JS_AddObjectRoot(cx, &jsdata);
 
 	for (i = 0; i < ncols; i++) {
 //		printf("dbdata_to_jsarray: data @ %p -", (void *)data->field[i]);
@@ -827,7 +827,7 @@
 		JS_SetElement(cx, jsdata, i, &jv);
 
 	}
-	JS_RemoveRoot(cx, jsdata);
+	JS_RemoveObjectRoot(cx, &jsdata);
 
 	return jsdata;
 }
@@ -844,7 +844,7 @@
 	if (data == NULL) return NULL;
 
 	jsarray = JS_NewArrayObject(cx, 0, NULL);
-	JS_AddRoot(cx, jsarray);
+	JS_AddObjectRoot(cx, &jsarray);
 
 /*	printf("Making Array(%d)\n", data->cols); */
 	i = 0;
@@ -858,7 +858,7 @@
 		node = node->next;
 		i++;
 	}
-	JS_RemoveRoot(cx, jsarray);
+	JS_RemoveObjectRoot(cx, &jsarray);
 
 	return jsarray;
 }
@@ -873,7 +873,7 @@
 	if (data == NULL) return NULL;
 
 	jsarray = JS_NewArrayObject(cx, 0, NULL);
-	JS_AddRoot(cx, jsarray);
+	JS_AddObjectRoot(cx, &jsarray);
 	
 	for(i=0;i<data->cols;i++) {
 		jsstr = JS_NewStringCopyZ(cx, data->colNames[i]);
@@ -882,7 +882,7 @@
 		
 	}
 	
-	JS_RemoveRoot(cx, jsarray);
+	JS_RemoveObjectRoot(cx, &jsarray);
 
 	return jsarray;
 }
@@ -928,7 +928,7 @@
 // Provides a javascript function to query an sqlite3 database
 // This probably wants updating to not return JS_FALSE as that halts js execution
 // far better to return an error code in rsval which the javascript can handle
-static JSBool js_doquery(JSContext *cx, JSObject __attribute__((unused)) *obj, uintN argc, jsval *argv, jsval *rval) {
+static JSBool js_doquery(JSContext *cx, uintN argc, jsval *vp) {
 	struct js_db_result *dbres;
 	char *dbname;
 	char *query;
@@ -952,13 +952,13 @@
 		return JS_FALSE;
 	}
 
-	if (!(JSVAL_IS_STRING(argv[0]) && JSVAL_IS_STRING(argv[1]))) {
+	if (!(JSVAL_IS_STRING(JS_ARGV(cx,vp)[0]) && JSVAL_IS_STRING(JS_ARGV(cx,vp)[1]))) {
 		JS_ReportError(cx, "Error: db_query strings");
 		return JS_FALSE;
 	}
 
-	dbname = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
-	query = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+	dbname = JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[0]));
+	query = JS_EncodeString(jscx, JS_ValueToString(cx, JS_ARGV(cx,vp)[1]));
 	
 	if (dbname[0] == '/'
 	||  strncmp(dbname, "../", 3)==0
@@ -982,14 +982,16 @@
 	
 	js_db_free(dbres);
 	
-	*rval = resobject_jsval;
+	JS_SET_RVAL(cx, vp, resobject_jsval);
 	return retval;
 }
 
-static JSBool js_store_get(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
+static JSBool js_store_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
 {
+	jsval idval;
+	JS_IdToValue(cx, id, &idval);
 	if (JSVAL_IS_STRING(idval)) {
-		char *key = JS_GetStringBytes(JS_ValueToString(cx, idval));
+		char *key = JS_EncodeString(jscx, JS_ValueToString(cx, idval));
 		char *val = userdb_get(USERDB_PUBLIC, user->name, key);
 		if (val == NULL) {
 			*vp = JSVAL_VOID;
@@ -1002,11 +1004,13 @@
 	return JS_TRUE;
 }
 
-static JSBool js_store_set(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
+static JSBool js_store_set(JSContext *cx, JSObject *obj, jsid id,JSBool strict, jsval *vp)
 {
+	jsval idval;
+	JS_IdToValue(cx, id, &idval);
 	if (JSVAL_IS_STRING(idval) && JSVAL_IS_STRING(*vp)) {
-		char *key = JS_GetStringBytes(JS_ValueToString(cx, idval));
-		char *val = JS_GetStringBytes(JS_ValueToString(cx, *vp));
+		char *key = JS_EncodeString(jscx, JS_ValueToString(cx, idval));
+		char *val = JS_EncodeString(jscx, JS_ValueToString(cx, *vp));
 		userdb_set(USERDB_PUBLIC, user->name, key, val);
 	}
 	return JS_TRUE;
@@ -1166,8 +1170,8 @@
 	}
 	js_clear_timeout();
 	// now the script has been run we can destroy it (the context retains the functions/objects it created)
-	
-	JS_DestroyScript(jscx, script);
+	// Per Mozilla, this no longer does anything and has been removed from library
+	//JS_DestroyScript(jscx, script);
 	return 0;
 }
 
@@ -1255,7 +1259,7 @@
 	JS_SetErrorReporter(jscx, js_error_handler);
 
 	/* create the root object */
-	jsroot = JS_NewObject(jscx, &globclass, NULL, NULL);
+	jsroot = JS_NewGlobalObject(jscx, &globclass);
 
 	/* initiate builtin classes */
 	JS_InitStandardClasses(jscx, jsroot);




More information about the mw-devel mailing list