[gjs: 6/7] jsapi-util: Remove jsapi-private



commit e23b19ef5ceffc2eaa34821a83c982342d5a08fa
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue Sep 19 00:03:28 2017 -0700

    jsapi-util: Remove jsapi-private
    
    Ever since removing the gjs-module API, there has not really been a
    distinction between "public" and "private" jsapi-util functions. Just
    remove the private files and incorporate everything declared or defined
    there into the other jsapi-util files.

 gi/function.cpp             |  1 -
 gi/repo.cpp                 |  1 -
 gjs-srcs.mk                 |  2 --
 gjs/context.cpp             |  1 -
 gjs/jsapi-dynamic-class.cpp |  1 -
 gjs/jsapi-private.cpp       | 72 ---------------------------------------------
 gjs/jsapi-private.h         | 43 ---------------------------
 gjs/jsapi-util-error.cpp    | 41 ++++++++++++++++++++++++++
 gjs/jsapi-util.cpp          |  1 -
 gjs/jsapi-util.h            |  2 ++
 gjs/module.cpp              |  1 -
 modules/console.cpp         |  1 -
 12 files changed, 43 insertions(+), 124 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index b54cc8d..31ccb0d 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -35,7 +35,6 @@
 #include "param.h"
 #include "gjs/context-private.h"
 #include "gjs/jsapi-class.h"
-#include "gjs/jsapi-private.h"
 #include "gjs/jsapi-wrapper.h"
 #include "gjs/mem.h"
 
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 1b037da..7de6f6c 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -38,7 +38,6 @@
 #include "gerror.h"
 #include "gjs/jsapi-class.h"
 #include "gjs/jsapi-wrapper.h"
-#include "gjs/jsapi-private.h"
 #include "gjs/mem.h"
 
 #include <util/misc.h>
diff --git a/gjs-srcs.mk b/gjs-srcs.mk
index 38cf6d6..36f29a7 100644
--- a/gjs-srcs.mk
+++ b/gjs-srcs.mk
@@ -62,8 +62,6 @@ gjs_srcs =                            \
        gjs/importer.h                  \
        gjs/jsapi-class.h               \
        gjs/jsapi-dynamic-class.cpp     \
-       gjs/jsapi-private.cpp           \
-       gjs/jsapi-private.h             \
        gjs/jsapi-util.cpp              \
        gjs/jsapi-util.h                \
        gjs/jsapi-util-args.h           \
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 0aaa686..4a679f6 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -32,7 +32,6 @@
 #include "engine.h"
 #include "global.h"
 #include "importer.h"
-#include "jsapi-private.h"
 #include "jsapi-util.h"
 #include "jsapi-wrapper.h"
 #include "native.h"
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index f070dee..aca46e5 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -31,7 +31,6 @@
 #include "jsapi-class.h"
 #include "jsapi-util.h"
 #include "jsapi-wrapper.h"
-#include "jsapi-private.h"
 
 #include <string.h>
 #include <math.h>
diff --git a/gjs/jsapi-util-error.cpp b/gjs/jsapi-util-error.cpp
index 9ee8e71..7393a68 100644
--- a/gjs/jsapi-util-error.cpp
+++ b/gjs/jsapi-util-error.cpp
@@ -26,6 +26,7 @@
 #include "jsapi-util.h"
 #include "jsapi-wrapper.h"
 #include "gi/gerror.h"
+#include "util/misc.h"
 
 #include <util/log.h>
 
@@ -232,3 +233,43 @@ gjs_format_stack_trace(JSContext       *cx,
 
     return g_filename_from_utf8(stack_utf8, -1, nullptr, nullptr, nullptr);
 }
+
+void
+gjs_warning_reporter(JSContext     *context,
+                     JSErrorReport *report)
+{
+    const char *warning;
+    GLogLevelFlags level;
+
+    g_assert(report);
+
+    if (gjs_environment_variable_is_set("GJS_ABORT_ON_OOM") &&
+        report->flags == JSREPORT_ERROR &&
+        report->errorNumber == 137) {
+        /* 137, JSMSG_OUT_OF_MEMORY */
+        g_error("GJS ran out of memory at %s: %i.",
+                report->filename,
+                report->lineno);
+    }
+
+    if ((report->flags & JSREPORT_WARNING) != 0) {
+        warning = "WARNING";
+        level = G_LOG_LEVEL_MESSAGE;
+
+        /* suppress bogus warnings. See mozilla/js/src/js.msg */
+        if (report->errorNumber == 162) {
+            /* 162, JSMSG_UNDEFINED_PROP: warns every time a lazy property
+             * is resolved, since the property starts out
+             * undefined. When this is a real bug it should usually
+             * fail somewhere else anyhow.
+             */
+            return;
+        }
+    } else {
+        warning = "REPORTED";
+        level = G_LOG_LEVEL_WARNING;
+    }
+
+    g_log(G_LOG_DOMAIN, level, "JS %s: [%s %d]: %s", warning, report->filename,
+          report->lineno, report->message().c_str());
+}
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 0dfe12f..94ceb82 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -33,7 +33,6 @@
 #include "jsapi-util.h"
 #include "jsapi-wrapper.h"
 #include "context-private.h"
-#include "jsapi-private.h"
 #include <gi/boxed.h>
 
 #include <string.h>
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 41ee04a..7555879 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -253,6 +253,8 @@ const char* gjs_get_type_name                (JS::Value        value);
 /* Functions intended for more "internal" use */
 
 void gjs_maybe_gc (JSContext *context);
+void gjs_schedule_gc_if_needed(JSContext *cx);
+void gjs_gc_if_needed(JSContext *cx);
 
 bool gjs_eval_with_scope(JSContext             *context,
                          JS::HandleObject       object,
diff --git a/gjs/module.cpp b/gjs/module.cpp
index b476848..d0d4a01 100644
--- a/gjs/module.cpp
+++ b/gjs/module.cpp
@@ -23,7 +23,6 @@
 
 #include <gio/gio.h>
 
-#include "jsapi-private.h"
 #include "jsapi-util.h"
 #include "jsapi-wrapper.h"
 #include "module.h"
diff --git a/modules/console.cpp b/modules/console.cpp
index eb1fb6b..5d7da29 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -55,7 +55,6 @@
 #include "console.h"
 #include "gjs/context.h"
 #include "gjs/context-private.h"
-#include "gjs/jsapi-private.h"
 #include "gjs/jsapi-wrapper.h"
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]