[gjs/wip/ptomato/mozjs31: 7/17] js: Remove deprecated JS_ValueToString()
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs31: 7/17] js: Remove deprecated JS_ValueToString()
- Date: Thu, 3 Nov 2016 02:57:41 +0000 (UTC)
commit a0cba7ecd08380ced43a1e51a1891e712f620f5f
Author: Philip Chimento <philip endlessm com>
Date: Tue Oct 18 13:52:52 2016 -0700
js: Remove deprecated JS_ValueToString()
In mozjs31 this is replaced with JS::ToString().
gi/arg.cpp | 4 ++--
gjs/context.cpp | 26 ++++++++++++--------------
gjs/coverage.cpp | 9 ++++-----
gjs/jsapi-util.cpp | 5 ++---
modules/console.cpp | 6 +++---
5 files changed, 23 insertions(+), 27 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index ef320a3..130916b 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -416,7 +416,7 @@ value_to_ghashtable_key(JSContext *cx,
char *cstr; \
JS::RootedValue str_val(cx, value); \
if (!str_val.isString()) { \
- JS::RootedString str(cx, JS_ValueToString(cx, str_val)); \
+ JS::RootedString str(cx, JS::ToString(cx, str_val)); \
str_val.setString(str); \
} \
if (!gjs_string_to_##lctype(cx, str_val, &cstr)) \
@@ -2574,7 +2574,7 @@ gjs_object_from_g_hash (JSContext *context,
true))
goto out;
- keystr = JS_ValueToString(context, keyjs);
+ keystr = JS::ToString(context, keyjs);
if (!keystr)
goto out;
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 9f050ef..7c730b7 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -110,7 +110,6 @@ gjs_log(JSContext *context,
JS::CallArgs argv = JS::CallArgsFromVp (argc, vp);
char *s;
JSExceptionState *exc_state;
- JSString *jstr;
if (argc != 1) {
gjs_throw(context, "Must pass a single argument to log()");
@@ -119,12 +118,12 @@ gjs_log(JSContext *context,
JS_BeginRequest(context);
- /* JS_ValueToString might throw, in which we will only
- *log that the value could be converted to string */
+ /* JS::ToString might throw, in which case we will only log that the value
+ * could not be converted to string */
exc_state = JS_SaveExceptionState(context);
- jstr = JS_ValueToString(context, argv[0]);
+ JS::RootedString jstr(context, JS::ToString(context, argv[0]));
if (jstr != NULL)
- argv[0] = JS::StringValue(jstr); // GC root
+ argv[0].setString(jstr); // GC root
JS_RestoreExceptionState(context, exc_state);
if (jstr == NULL) {
@@ -164,12 +163,12 @@ gjs_log_error(JSContext *context,
JS::RootedString jstr(context);
if (argc == 2) {
- /* JS_ValueToString might throw, in which we will only
- *log that the value could be converted to string */
+ /* JS::ToString might throw, in which case we will only log that the
+ * value could be converted to string */
exc_state = JS_SaveExceptionState(context);
- jstr = JS_ValueToString(context, argv[1]);
+ jstr = JS::ToString(context, argv[1]);
if (jstr != NULL)
- argv[1] = JS::StringValue(jstr); // GC root
+ argv[1].setString(jstr); // GC root
JS_RestoreExceptionState(context, exc_state);
}
@@ -195,15 +194,14 @@ gjs_print_parse_args(JSContext *context,
str = g_string_new("");
for (n = 0; n < argv.length(); ++n) {
JSExceptionState *exc_state;
- JSString *jstr;
- /* JS_ValueToString might throw, in which we will only
- * log that the value could be converted to string */
+ /* JS::ToString might throw, in which case we will only log that the
+ * value could not be converted to string */
exc_state = JS_SaveExceptionState(context);
- jstr = JS_ValueToString(context, argv[n]);
+ JS::RootedString jstr(context, JS::ToString(context, argv[n]));
if (jstr != NULL)
- argv[n] = JS::StringValue(jstr); // GC root
+ argv[n].setString(jstr); // GC root
JS_RestoreExceptionState(context, exc_state);
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 57501d4..b4d8ec2 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1314,7 +1314,6 @@ coverage_log(JSContext *context,
JS::CallArgs argv = JS::CallArgsFromVp (argc, vp);
char *s;
JSExceptionState *exc_state;
- JSString *jstr;
if (argc != 1) {
gjs_throw(context, "Must pass a single argument to log()");
@@ -1329,12 +1328,12 @@ coverage_log(JSContext *context,
return true;
}
- /* JS_ValueToString might throw, in which we will only
- *log that the value could be converted to string */
+ /* JS::ToString might throw, in which case we will only log that the value
+ * could not be converted to string */
exc_state = JS_SaveExceptionState(context);
- jstr = JS_ValueToString(context, argv[0]);
+ JS::RootedString jstr(context, JS::ToString(context, argv[0]));
if (jstr != NULL)
- argv[0] = JS::StringValue(jstr); // GC root
+ argv[0].setString(jstr); // GC root
JS_RestoreExceptionState(context, exc_state);
if (jstr == NULL) {
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index c0a5794..0e48eb1 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -437,7 +437,6 @@ char*
gjs_value_debug_string(JSContext *context,
JS::HandleValue value)
{
- JSString *str;
char *bytes;
char *debugstr;
@@ -448,7 +447,7 @@ gjs_value_debug_string(JSContext *context,
JS_BeginRequest(context);
- str = JS_ValueToString(context, value);
+ JS::RootedString str(context, JS::ToString(context, value));
if (str == NULL) {
if (value.isObject()) {
@@ -497,7 +496,7 @@ utf8_exception_from_non_gerror_value(JSContext *cx,
JS::HandleValue exc)
{
char *utf8_exception = NULL;
- JSString *exc_str = JS_ValueToString(cx, exc);
+ JS::RootedString exc_str(cx, JS::ToString(cx, exc));
if (exc_str != NULL)
gjs_string_to_utf8(cx, JS::StringValue(exc_str), &utf8_exception);
return utf8_exception;
diff --git a/modules/console.cpp b/modules/console.cpp
index 6c563a8..33619c0 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -161,7 +161,7 @@ gjs_console_interact(JSContext *context,
GJS_GET_THIS(context, argc, vp, argv, object);
bool eof = false;
JS::RootedValue result(context);
- JSString *str;
+ JS::RootedString str(context);
GString *buffer = NULL;
char *temp_buf = NULL;
int lineno;
@@ -200,12 +200,12 @@ gjs_console_interact(JSContext *context,
gjs_schedule_gc_if_needed(context);
if (JS_GetPendingException(context, result.address())) {
- str = JS_ValueToString(context, result);
+ str = JS::ToString(context, result);
JS_ClearPendingException(context);
} else if (result.isUndefined()) {
goto next;
} else {
- str = JS_ValueToString(context, result);
+ str = JS::ToString(context, result);
}
if (str) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]