[gjs/wip/ptomato/mozjs31prep] jsapi-util: Remove gjs_move_exception()
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs31prep] jsapi-util: Remove gjs_move_exception()
- Date: Thu, 27 Oct 2016 00:10:15 +0000 (UTC)
commit 033effc7f8d3b5b262e133c9decf934ff06a2a82
Author: Philip Chimento <philip endlessm com>
Date: Wed Oct 26 16:48:04 2016 -0700
jsapi-util: Remove gjs_move_exception()
This was only used in one place in function.cpp, where the source context
and destination context were the same, making the gjs_move_exception()
effectively a no-op.
It seems this was left over from when imports were done in a different
context.
https://bugzilla.gnome.org/show_bug.cgi?id=742249
gi/function.cpp | 4 +--
gjs/jsapi-util.cpp | 77 ----------------------------------------------------
gjs/jsapi-util.h | 3 +-
3 files changed, 2 insertions(+), 82 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 3bd2030..dde7ba3 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -1726,10 +1726,8 @@ gjs_define_function(JSContext *context,
JS_BeginRequest(context);
function = function_new(context, gtype, info);
- if (function == NULL) {
- gjs_move_exception(context, context);
+ if (function == NULL)
goto out;
- }
if (info_type == GI_INFO_TYPE_FUNCTION) {
name = (gchar *) g_base_info_get_name((GIBaseInfo*) info);
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 38a7920..da5bf0a 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -636,83 +636,6 @@ gjs_log_exception(JSContext *context)
return retval;
}
-static void
-try_to_chain_stack_trace(JSContext *src_context,
- JSContext *dst_context,
- JS::Value src_exc)
-{
- /* append current stack of dst_context to stack trace for src_exc.
- * we bail if anything goes wrong, just using the src_exc unmodified
- * in that case. */
- JS::Value chained, src_stack, dst_stack, new_stack;
- JSString *new_stack_str;
-
- JS_BeginRequest(src_context);
- JS_BeginRequest(dst_context);
-
- if (!src_exc.isObject())
- goto out; // src_exc doesn't have a stack trace
-
- /* create a new exception in dst_context to get a stack trace */
- gjs_throw_literal(dst_context, "Chained exception");
- if (!(JS_GetPendingException(dst_context, &chained) && chained.isObject()))
- goto out; // gjs_throw_literal didn't work?!
- JS_ClearPendingException(dst_context);
-
- /* get stack trace for src_exc and chained */
- if (!(JS_GetProperty(dst_context, &chained.toObject(),
- "stack", &dst_stack) &&
- dst_stack.isString()))
- goto out; // couldn't get chained stack
- if (!(JS_GetProperty(src_context, &src_exc.toObject(),
- "stack", &src_stack) &&
- src_stack.isString()))
- goto out; // couldn't get source stack
-
- /* add chained exception's stack trace to src_exc */
- new_stack_str = JS_ConcatStrings(dst_context, src_stack.toString(),
- dst_stack.toString());
- if (new_stack_str==NULL)
- goto out; // couldn't concatenate src and dst stacks?!
- new_stack = JS::StringValue(new_stack_str);
- JS_SetProperty(dst_context, &src_exc.toObject(), "stack", &new_stack);
-
- out:
- JS_EndRequest(dst_context);
- JS_EndRequest(src_context);
-}
-
-bool
-gjs_move_exception(JSContext *src_context,
- JSContext *dest_context)
-{
- bool success;
-
- JS_BeginRequest(src_context);
- JS_BeginRequest(dest_context);
-
- /* NOTE: src and dest could be the same. */
- JS::Value exc;
- if (JS_GetPendingException(src_context, &exc)) {
- if (src_context != dest_context) {
- /* try to add the current stack of dest_context to the
- * stack trace of exc */
- try_to_chain_stack_trace(src_context, dest_context, exc);
- /* move the exception to dest_context */
- JS_SetPendingException(dest_context, exc);
- JS_ClearPendingException(src_context);
- }
- success = true;
- } else {
- success = false;
- }
-
- JS_EndRequest(dest_context);
- JS_EndRequest(src_context);
-
- return success;
-}
-
bool
gjs_call_function_value(JSContext *context,
JSObject *obj,
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index ea9e074..ef14f17 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -369,8 +369,7 @@ void gjs_throw_g_error (JSContext *context,
GError *error);
bool gjs_log_exception (JSContext *context);
-bool gjs_move_exception (JSContext *src_context,
- JSContext *dest_context);
+
bool gjs_log_exception_full (JSContext *context,
JS::Value exc,
JSString *message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]