[gjs] stack: Remove gjs_context_get_frame_info()
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] stack: Remove gjs_context_get_frame_info()
- Date: Sun, 13 Aug 2017 23:39:26 +0000 (UTC)
commit f2aa7cbeda4a5cce24604d0a22cdf1ad50b8fb26
Author: Philip Chimento <philip endlessm com>
Date: Fri Aug 11 13:15:02 2017 +0100
stack: Remove gjs_context_get_frame_info()
This is not needed anymore as we can now use the new facilities in JSAPI
for getting frame info, and use gjs_format_stack_trace() to build the
actual stack string.
https://bugzilla.gnome.org/show_bug.cgi?id=786183
gjs/jsapi-util.h | 5 -----
gjs/jsapi-wrapper.h | 1 -
gjs/stack.cpp | 47 +++++------------------------------------------
3 files changed, 5 insertions(+), 48 deletions(-)
---
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 2bc2468..b9d1959 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -254,11 +254,6 @@ const char* gjs_get_type_name (JS::Value value);
void gjs_maybe_gc (JSContext *context);
-bool gjs_context_get_frame_info(JSContext *cx,
- mozilla::Maybe<JS::MutableHandleValue> stack,
- mozilla::Maybe<JS::MutableHandleValue> fileName,
- mozilla::Maybe<JS::MutableHandleValue> lineNumber);
-
bool gjs_eval_with_scope(JSContext *context,
JS::HandleObject object,
const char *script,
diff --git a/gjs/jsapi-wrapper.h b/gjs/jsapi-wrapper.h
index bdc7245..1eb0656 100644
--- a/gjs/jsapi-wrapper.h
+++ b/gjs/jsapi-wrapper.h
@@ -38,7 +38,6 @@
#if defined(__clang__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC system_header
#endif
-#include <mozilla/Maybe.h>
#include <jsapi.h>
#include <jsfriendapi.h>
#include <js/Conversions.h>
diff --git a/gjs/stack.cpp b/gjs/stack.cpp
index 2d3a7cb..f71f852 100644
--- a/gjs/stack.cpp
+++ b/gjs/stack.cpp
@@ -47,57 +47,20 @@
#include "jsapi-util.h"
#include "jsapi-wrapper.h"
-bool
-gjs_context_get_frame_info(JSContext *context,
- mozilla::Maybe<JS::MutableHandleValue> stack,
- mozilla::Maybe<JS::MutableHandleValue> fileName,
- mozilla::Maybe<JS::MutableHandleValue> lineNumber)
-{
- JSAutoRequest ar(context);
- JS::RootedObject global(context, JS::CurrentGlobalOrNull(context)),
- constructor(context);
- JSAutoCompartment ac(context, global);
-
- JS::RootedId error_id(context, gjs_intern_string_to_id(context, "Error"));
- if (!gjs_object_require_property(context, global, "global object",
- error_id, &constructor))
- return false;
-
- JS::RootedObject err_obj(context, JS_New(context, constructor,
- JS::HandleValueArray::empty()));
-
- if (stack &&
- !gjs_object_get_property(context, err_obj, GJS_STRING_STACK,
- stack.ref()))
- return false;
-
- if (fileName &&
- !gjs_object_get_property(context, err_obj, GJS_STRING_FILENAME,
- fileName.ref()))
- return false;
-
- if (lineNumber &&
- !gjs_object_get_property(context, err_obj, GJS_STRING_LINE_NUMBER,
- lineNumber.ref()))
- return false;
-
- return true;
-}
-
void
gjs_context_print_stack_stderr(GjsContext *context)
{
JSContext *cx = (JSContext*) gjs_context_get_native_context(context);
- JS::RootedValue v_stack(cx);
+ JS::RootedObject frame(cx);
+ JS::AutoSaveExceptionState exc(cx);
GjsAutoChar stack;
g_printerr("== Stack trace for context %p ==\n", context);
- /* Stderr is locale encoding, so we use string_to_filename here */
- if (!gjs_context_get_frame_info(cx, mozilla::Some<JS::MutableHandleValue>(&v_stack),
- mozilla::Nothing(), mozilla::Nothing()) ||
- !gjs_string_to_filename(cx, v_stack, &stack)) {
+ if (!JS::CaptureCurrentStack(cx, &frame) ||
+ !(stack = gjs_format_stack_trace(cx, frame))) {
g_printerr("No stack trace available\n");
+ exc.restore();
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]