[gjs/iwyu: 34/34] js: Fix header includes according to IWYU
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/iwyu: 34/34] js: Fix header includes according to IWYU
- Date: Thu, 21 May 2020 05:45:58 +0000 (UTC)
commit 31a296880c18b13050be6203c593edf5947d5f62
Author: Philip Chimento <philip chimento gmail com>
Date: Fri May 15 23:30:00 2020 -0700
js: Fix header includes according to IWYU
This updates all the includes according to what IWYU suggests. In a few
cases we move a typedef down in order to avoid IWYU wanting a forward
declaration, or use a JS::Heap<T>{braced initializer} in order to avoid
an implicit std::move.
gi/foreign.h | 2 ++
gi/function.cpp | 2 ++
gi/fundamental.cpp | 2 ++
gi/gerror.cpp | 1 +
gi/gjs_gi_trace.h | 2 +-
gi/gtype.cpp | 2 ++
gi/interface.h | 1 +
gi/object.cpp | 4 +++-
gi/object.h | 10 ++++++----
gi/private.cpp | 1 +
gi/union.h | 1 +
gi/wrapperutils.h | 3 ++-
gjs/atoms.cpp | 6 ++++--
gjs/context-private.h | 16 +++++++++++++++-
gjs/context.cpp | 2 --
gjs/global.cpp | 2 ++
gjs/global.h | 1 +
gjs/jsapi-dynamic-class.cpp | 1 -
gjs/jsapi-util.cpp | 1 +
gjs/jsapi-util.h | 1 +
gjs/native.h | 1 +
gjs/profiler.cpp | 5 -----
libgjs-private/gjs-gdbus-wrapper.h | 4 ++--
libgjs-private/gjs-util.c | 3 +--
modules/cairo-path.cpp | 1 -
modules/cairo.cpp | 1 -
modules/console.cpp | 1 +
test/gjs-test-coverage.cpp | 1 -
test/gjs-test-rooting.cpp | 3 +--
test/gjs-test-utils.h | 3 +--
30 files changed, 55 insertions(+), 29 deletions(-)
---
diff --git a/gi/foreign.h b/gi/foreign.h
index 14054310..40cf1a41 100644
--- a/gi/foreign.h
+++ b/gi/foreign.h
@@ -28,7 +28,9 @@
#include <girepository.h>
+#include <js/RootingAPI.h>
#include <js/TypeDecls.h>
+#include <js/Value.h>
#include "gi/arg.h"
#include "gjs/macros.h"
diff --git a/gi/function.cpp b/gi/function.cpp
index f857426c..d84bb5c8 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -28,6 +28,7 @@
#include <string.h> // for strcmp, memset, size_t
#include <new>
+#include <string>
#include <ffi.h>
#include <girepository.h>
@@ -42,6 +43,7 @@
#include <js/PropertySpec.h>
#include <js/Realm.h> // for GetRealmFunctionPrototype
#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
#include <js/Value.h>
#include <js/Warnings.h>
#include <jsapi.h> // for HandleValueArray, JS_GetElement
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index b13a0b7b..42b53e78 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -24,6 +24,8 @@
#include <config.h>
+#include <utility> // for (implicit) move
+
#include <girepository.h>
#include <glib.h>
diff --git a/gi/gerror.cpp b/gi/gerror.cpp
index 66341b7d..38e1e577 100644
--- a/gi/gerror.cpp
+++ b/gi/gerror.cpp
@@ -33,6 +33,7 @@
#include <js/PropertyDescriptor.h> // for JSPROP_ENUMERATE
#include <js/RootingAPI.h>
#include <js/SavedFrameAPI.h>
+#include <js/TypeDecls.h>
#include <js/Utility.h> // for UniqueChars
#include <js/Value.h>
#include <jsapi.h> // for JS_DefinePropertyById, JS_GetProp...
diff --git a/gi/gjs_gi_trace.h b/gi/gjs_gi_trace.h
index 77e6c6fe..9e686548 100644
--- a/gi/gjs_gi_trace.h
+++ b/gi/gjs_gi_trace.h
@@ -26,7 +26,7 @@
#ifndef GI_GJS_GI_TRACE_H_
#define GI_GJS_GI_TRACE_H_
-#include <config.h> // IWYU pragma: keep
+#include <config.h>
#ifdef HAVE_DTRACE
diff --git a/gi/gtype.cpp b/gi/gtype.cpp
index dd68d924..70cbe245 100644
--- a/gi/gtype.cpp
+++ b/gi/gtype.cpp
@@ -24,6 +24,8 @@
#include <config.h>
+#include <utility> // for (implicit) move
+
#include <glib-object.h>
#include <glib.h>
diff --git a/gi/interface.h b/gi/interface.h
index a5993666..3440e110 100644
--- a/gi/interface.h
+++ b/gi/interface.h
@@ -33,6 +33,7 @@
#include <js/CallArgs.h>
#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
#include <js/TypeDecls.h>
#include "gi/wrapperutils.h"
diff --git a/gi/object.cpp b/gi/object.cpp
index 6c861846..7df8f8f2 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -24,13 +24,15 @@
#include <config.h>
+#include <stdint.h>
#include <string.h> // for memset, strcmp
-#include <algorithm> // for move, find
+#include <algorithm> // for find
#include <functional> // for mem_fn
#include <string>
#include <tuple> // for tie
#include <type_traits> // for remove_reference<>::type
+#include <utility> // for move
#include <vector>
#include <ffi.h>
diff --git a/gi/object.h b/gi/object.h
index e48c1bea..d99bb666 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -37,8 +37,14 @@
#include <glib.h>
#include <js/GCHashTable.h> // for GCHashMap
+#include <js/Id.h>
#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
#include <js/TypeDecls.h>
+#include <jsfriendapi.h> // for JSID_IS_ATOM, JSID_TO_ATOM
+#include <mozilla/HashFunctions.h> // for HashGeneric, HashNumber
+#include <mozilla/HashTable.h> // for DefaultHasher
+#include <mozilla/Likely.h> // for MOZ_LIKELY
#include "gi/wrapperutils.h"
#include "gjs/jsapi-util-root.h"
@@ -53,10 +59,6 @@ class CallArgs;
namespace js {
class SystemAllocPolicy;
}
-namespace mozilla {
-template <class Key>
-struct DefaultHasher;
-}
class ObjectInstance;
class ObjectPrototype;
diff --git a/gi/private.cpp b/gi/private.cpp
index 81760e18..9159776d 100644
--- a/gi/private.cpp
+++ b/gi/private.cpp
@@ -32,6 +32,7 @@
#include <js/CallArgs.h>
#include <js/Id.h> // for JSID_TO_SYMBOL
#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
#include <js/TypeDecls.h>
#include <js/Utility.h> // for UniqueChars
#include <jsapi.h> // for JS_GetArrayLength, JS_GetElement
diff --git a/gi/union.h b/gi/union.h
index 3d2249f2..e72dd8ef 100644
--- a/gi/union.h
+++ b/gi/union.h
@@ -38,6 +38,7 @@
namespace JS {
class CallArgs;
}
+struct JSClass;
struct JSClassOps;
class UnionPrototype;
class UnionInstance;
diff --git a/gi/wrapperutils.h b/gi/wrapperutils.h
index e8f1f430..8ec8b6ba 100644
--- a/gi/wrapperutils.h
+++ b/gi/wrapperutils.h
@@ -37,6 +37,7 @@
#include <glib.h>
#include <js/CallArgs.h>
+#include <js/Id.h>
#include <js/MemoryFunctions.h>
#include <js/RootingAPI.h>
#include <js/TypeDecls.h>
@@ -46,7 +47,7 @@
#include "gjs/atoms.h"
#include "gjs/context-private.h"
-#include "gjs/jsapi-class.h"
+#include "gjs/jsapi-class.h" // IWYU pragma: keep
#include "gjs/jsapi-util.h"
#include "gjs/macros.h"
#include "util/log.h"
diff --git a/gjs/atoms.cpp b/gjs/atoms.cpp
index b63a1343..5329ddc2 100644
--- a/gjs/atoms.cpp
+++ b/gjs/atoms.cpp
@@ -26,6 +26,8 @@
#include <config.h>
+#include <js/Id.h>
+#include <js/RootingAPI.h>
#include <js/Symbol.h>
#include <js/TracingAPI.h>
#include <js/TypeDecls.h>
@@ -37,7 +39,7 @@ bool GjsAtom::init(JSContext* cx, const char* str) {
JSString* s = JS_AtomizeAndPinString(cx, str);
if (!s)
return false;
- m_jsid = INTERNED_STRING_TO_JSID(cx, s);
+ m_jsid = JS::Heap<jsid>{INTERNED_STRING_TO_JSID(cx, s)};
return true;
}
@@ -48,7 +50,7 @@ bool GjsSymbolAtom::init(JSContext* cx, const char* str) {
JS::Symbol* symbol = JS::NewSymbol(cx, descr);
if (!symbol)
return false;
- m_jsid = SYMBOL_TO_JSID(symbol);
+ m_jsid = JS::Heap<jsid>{SYMBOL_TO_JSID(symbol)};
return true;
}
diff --git a/gjs/context-private.h b/gjs/context-private.h
index f9c8bd30..1b1e5562 100644
--- a/gjs/context-private.h
+++ b/gjs/context-private.h
@@ -35,19 +35,27 @@
#include <glib-object.h>
#include <glib.h>
+#include <js/AllocPolicy.h>
#include <js/GCHashTable.h>
#include <js/GCVector.h>
#include <js/Promise.h>
+#include <js/RootingAPI.h>
#include <js/TypeDecls.h>
#include <jsapi.h> // for JS_GetContextPrivate
#include <jsfriendapi.h> // for ScriptEnvironmentPreparer
+#include <mozilla/UniquePtr.h>
-#include "gjs/atoms.h"
#include "gjs/context.h"
#include "gjs/jsapi-util.h"
#include "gjs/macros.h"
#include "gjs/profiler.h"
+namespace mozilla {
+template <class Key>
+struct DefaultHasher;
+}
+class GjsAtoms;
+
using JobQueueStorage =
JS::GCVector<JS::Heap<JSObject*>, 0, js::SystemAllocPolicy>;
using ObjectInitList =
@@ -65,6 +73,12 @@ using GTypeNotUint64 =
// The GC sweep method should ignore FundamentalTable and GTypeTable's key types
namespace JS {
+// Forward declarations
+template <typename T>
+class WeakCache;
+template <typename T>
+struct GCPolicy;
+
template <>
struct GCPolicy<void*> : public IgnoreGCPolicy<void*> {};
// We need GCPolicy<GType> for GTypeTable. SpiderMonkey already defines
diff --git a/gjs/context.cpp b/gjs/context.cpp
index b5d1a0a4..4b7fe238 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -24,10 +24,8 @@
#include <config.h>
#include <signal.h> // for sigaction, SIGUSR1, sa_handler
-#include <stdint.h>
#include <stdio.h> // for FILE, fclose, size_t
#include <string.h> // for memset
-#include <sys/types.h> // IWYU pragma: keep
#ifdef HAVE_UNISTD_H
# include <unistd.h> // for getpid
diff --git a/gjs/global.cpp b/gjs/global.cpp
index d4d12411..517737b8 100644
--- a/gjs/global.cpp
+++ b/gjs/global.cpp
@@ -37,7 +37,9 @@
#include <js/Conversions.h>
#include <js/PropertyDescriptor.h> // for JSPROP_PERMANENT, JSPROP_RE...
#include <js/PropertySpec.h>
+#include <js/Realm.h> // for GetObjectRealmOrNull, SetRealmPrivate
#include <js/RealmOptions.h>
+#include <js/RootingAPI.h>
#include <js/SourceText.h>
#include <js/TypeDecls.h>
#include <js/Utility.h> // for UniqueChars
diff --git a/gjs/global.h b/gjs/global.h
index 341f1572..b4b29e03 100644
--- a/gjs/global.h
+++ b/gjs/global.h
@@ -27,6 +27,7 @@
#include <config.h>
#include <js/TypeDecls.h>
+#include <js/Value.h>
#include "gjs/macros.h"
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index 87a9fbb6..3cacb0e3 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -42,7 +42,6 @@
#include "gjs/atoms.h"
#include "gjs/context-private.h"
-#include "gjs/jsapi-class.h" // IWYU pragma: keep
#include "gjs/jsapi-util.h"
#include "gjs/macros.h"
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index f6cbd475..531b1d49 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -40,6 +40,7 @@
#include <js/CharacterEncoding.h>
#include <js/Class.h>
#include <js/Conversions.h>
+#include <js/ErrorReport.h>
#include <js/GCAPI.h> // for JS_MaybeGC, NonIncrementalGC, GCRe...
#include <js/GCVector.h> // for RootedVector
#include <js/RootingAPI.h>
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 47866a8f..62ecf23c 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -38,6 +38,7 @@
#include <glib.h>
#include <js/GCPolicyAPI.h> // for IgnoreGCPolicy
+#include <js/Id.h>
#include <js/TypeDecls.h>
#include <js/Utility.h> // for UniqueChars
#include <jspubtd.h> // for JSProtoKey
diff --git a/gjs/native.h b/gjs/native.h
index cfc0974b..b52efeb3 100644
--- a/gjs/native.h
+++ b/gjs/native.h
@@ -26,6 +26,7 @@
#include <config.h>
+#include <js/RootingAPI.h>
#include <js/TypeDecls.h>
#include "gjs/macros.h"
diff --git a/gjs/profiler.cpp b/gjs/profiler.cpp
index a0e645be..066ac337 100644
--- a/gjs/profiler.cpp
+++ b/gjs/profiler.cpp
@@ -41,9 +41,6 @@
# include <sys/types.h> // for timer_t
# include <syscall.h> // for __NR_gettid
# include <time.h> // for itimerspec, timer_delete, ...
-# ifdef HAVE_SYS_SYSCALL_H
-# include <sys/syscall.h> // IWYU pragma: keep
-# endif
# ifdef HAVE_UNISTD_H
# include <unistd.h> // for getpid, syscall
# endif
@@ -54,12 +51,10 @@
#endif
#include <js/ProfilingStack.h> // for EnableContextProfilingStack, ...
-#include <js/TypeDecls.h>
#include "gjs/context.h"
#include "gjs/jsapi-util.h"
#include "gjs/macros.h"
-#include "gjs/profiler-private.h" // IWYU pragma: keep
#include "gjs/profiler.h"
#define FLUSH_DELAY_SECONDS 3
diff --git a/libgjs-private/gjs-gdbus-wrapper.h b/libgjs-private/gjs-gdbus-wrapper.h
index 8d704c48..e5c218e2 100644
--- a/libgjs-private/gjs-gdbus-wrapper.h
+++ b/libgjs-private/gjs-gdbus-wrapper.h
@@ -31,8 +31,6 @@
G_BEGIN_DECLS
-typedef struct _GjsDBusImplementation GjsDBusImplementation;
-typedef struct _GjsDBusImplementationClass GjsDBusImplementationClass;
typedef struct _GjsDBusImplementationPrivate GjsDBusImplementationPrivate;
#define GJS_TYPE_DBUS_IMPLEMENTATION (gjs_dbus_implementation_get_type ())
@@ -47,10 +45,12 @@ struct _GjsDBusImplementation {
GjsDBusImplementationPrivate *priv;
};
+typedef struct _GjsDBusImplementation GjsDBusImplementation;
struct _GjsDBusImplementationClass {
GDBusInterfaceSkeletonClass parent_class;
};
+typedef struct _GjsDBusImplementationClass GjsDBusImplementationClass;
GJS_EXPORT
GType gjs_dbus_implementation_get_type (void);
diff --git a/libgjs-private/gjs-util.c b/libgjs-private/gjs-util.c
index 20a732d5..d4f74705 100644
--- a/libgjs-private/gjs-util.c
+++ b/libgjs-private/gjs-util.c
@@ -20,12 +20,11 @@
* IN THE SOFTWARE.
*/
-#include <config.h> /* IWYU pragma: keep */
+#include <config.h>
#include <locale.h> /* for setlocale */
#include <stddef.h> /* for size_t */
#include <string.h> /* for strcmp */
-#include <sys/types.h> /* IWYU pragma: keep */
#include <gio/gio.h>
#include <glib-object.h>
diff --git a/modules/cairo-path.cpp b/modules/cairo-path.cpp
index 5329d219..5bb5582a 100644
--- a/modules/cairo-path.cpp
+++ b/modules/cairo-path.cpp
@@ -34,7 +34,6 @@
#include "gjs/jsapi-class.h"
#include "gjs/jsapi-util.h"
#include "gjs/macros.h"
-#include "modules/cairo-private.h" // IWYU pragma: keep
typedef struct {
cairo_path_t *path;
diff --git a/modules/cairo.cpp b/modules/cairo.cpp
index 06593d2d..b4a7fb96 100644
--- a/modules/cairo.cpp
+++ b/modules/cairo.cpp
@@ -30,7 +30,6 @@
#include <jsapi.h> // for JS_NewPlainObject
#include "gjs/jsapi-util.h"
-#include "modules/cairo-module.h" // IWYU pragma: keep
#include "modules/cairo-private.h"
#ifdef CAIRO_HAS_XLIB_SURFACE
diff --git a/modules/console.cpp b/modules/console.cpp
index aad5ddea..7f8b9477 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -57,6 +57,7 @@
#include <js/ErrorReport.h>
#include <js/RootingAPI.h>
#include <js/SourceText.h>
+#include <js/TypeDecls.h>
#include <js/Utility.h> // for UniqueChars
#include <js/Warnings.h>
#include <jsapi.h> // for JS_IsExceptionPending, Exce...
diff --git a/test/gjs-test-coverage.cpp b/test/gjs-test-coverage.cpp
index e0c5b8d8..6496f1c2 100644
--- a/test/gjs-test-coverage.cpp
+++ b/test/gjs-test-coverage.cpp
@@ -35,7 +35,6 @@
#include "gjs/context.h"
#include "gjs/coverage.h"
#include "gjs/jsapi-util.h"
-#include "test/gjs-test-utils.h" // IWYU pragma: keep
typedef struct _GjsCoverageFixture {
GjsContext *context;
diff --git a/test/gjs-test-rooting.cpp b/test/gjs-test-rooting.cpp
index 3856efa5..3dfa4cd4 100644
--- a/test/gjs-test-rooting.cpp
+++ b/test/gjs-test-rooting.cpp
@@ -17,8 +17,7 @@ static GCond gc_finished;
static volatile int gc_counter;
#define PARENT(fx) ((GjsUnitTestFixture *)fx)
-typedef struct _GjsRootingFixture GjsRootingFixture;
-struct _GjsRootingFixture {
+struct GjsRootingFixture {
GjsUnitTestFixture parent;
bool finalized;
diff --git a/test/gjs-test-utils.h b/test/gjs-test-utils.h
index b0e38e53..356e0a81 100644
--- a/test/gjs-test-utils.h
+++ b/test/gjs-test-utils.h
@@ -32,8 +32,7 @@
#include <js/TypeDecls.h>
-typedef struct _GjsUnitTestFixture GjsUnitTestFixture;
-struct _GjsUnitTestFixture {
+struct GjsUnitTestFixture {
GjsContext *gjs_context;
JSContext *cx;
JS::Realm* realm;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]