[gjs/restore-msvc-build: 1/3] [gjs|modules]/*.cpp: Forward declare specializations where needed




commit 5bb84516689d562f6065f1859148371df2a6b0bc
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Aug 25 14:31:40 2020 +0800

    [gjs|modules]/*.cpp: Forward declare specializations where needed
    
    This will help us avoid failing the static_assert in js/GCPolicyApi.h where
    pointer types are not allowed, when building with Visual Studio, which is
    caused by the compiler not picking up the needed types when js/GCPolicyAPI.h
    is included in some way or the other.

 gjs/atoms.cpp             | 8 ++++++++
 gjs/context-private.h     | 1 -
 gjs/deprecation.cpp       | 8 ++++++++
 gjs/jsapi-util-string.cpp | 8 ++++++++
 gjs/stack.cpp             | 8 ++++++++
 modules/cairo.cpp         | 8 ++++++++
 modules/print.cpp         | 8 ++++++++
 7 files changed, 48 insertions(+), 1 deletion(-)
---
diff --git a/gjs/atoms.cpp b/gjs/atoms.cpp
index e6d2be69..b3ec1dd3 100644
--- a/gjs/atoms.cpp
+++ b/gjs/atoms.cpp
@@ -35,6 +35,14 @@
 
 #include "gjs/atoms.h"
 
+// Avoid static_assert in MSVC builds
+namespace JS {
+template <typename T> struct GCPolicy;
+
+template <>
+struct GCPolicy<void*> : public IgnoreGCPolicy<void*> {};
+}
+
 bool GjsAtom::init(JSContext* cx, const char* str) {
     JSString* s = JS_AtomizeAndPinString(cx, str);
     if (!s)
diff --git a/gjs/context-private.h b/gjs/context-private.h
index f8524e84..e01bced5 100644
--- a/gjs/context-private.h
+++ b/gjs/context-private.h
@@ -256,5 +256,4 @@ class GjsContextPrivate : public JS::JobQueue {
     void free_profiler(void);
     void dispose(void);
 };
-
 #endif  // GJS_CONTEXT_PRIVATE_H_
diff --git a/gjs/deprecation.cpp b/gjs/deprecation.cpp
index 4798d6d3..4aadfe1b 100644
--- a/gjs/deprecation.cpp
+++ b/gjs/deprecation.cpp
@@ -42,6 +42,14 @@
 #include "gjs/deprecation.h"
 #include "gjs/macros.h"
 
+// Avoid static_assert in MSVC builds
+namespace JS {
+template <typename T> struct GCPolicy;
+
+template <>
+struct GCPolicy<void*> : public IgnoreGCPolicy<void*> {};
+}
+
 const char* messages[] = {
     // None:
     "(invalid message)",
diff --git a/gjs/jsapi-util-string.cpp b/gjs/jsapi-util-string.cpp
index 9e97ead8..6ef23ad9 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -50,6 +50,14 @@
 #include "gjs/jsapi-util.h"
 #include "gjs/macros.h"
 
+// Avoid static_assert in MSVC builds
+namespace JS {
+template <typename T> struct GCPolicy;
+
+template <>
+struct GCPolicy<void*> : public IgnoreGCPolicy<void*> {};
+}
+
 class JSLinearString;
 
 char* gjs_hyphen_to_underscore(const char* str) {
diff --git a/gjs/stack.cpp b/gjs/stack.cpp
index c3137411..1eda2fdf 100644
--- a/gjs/stack.cpp
+++ b/gjs/stack.cpp
@@ -52,6 +52,14 @@
 
 #include "gjs/context.h"
 
+// Avoid static_assert in MSVC builds
+namespace JS {
+template <typename T> struct GCPolicy;
+
+template <>
+struct GCPolicy<void*> : public IgnoreGCPolicy<void*> {};
+}
+
 void
 gjs_context_print_stack_stderr(GjsContext *context)
 {
diff --git a/modules/cairo.cpp b/modules/cairo.cpp
index b4a7fb96..1a7c10e4 100644
--- a/modules/cairo.cpp
+++ b/modules/cairo.cpp
@@ -32,6 +32,14 @@
 #include "gjs/jsapi-util.h"
 #include "modules/cairo-private.h"
 
+// Avoid static_assert in MSVC builds
+namespace JS {
+template <typename T> struct GCPolicy;
+
+template <>
+struct GCPolicy<void*> : public IgnoreGCPolicy<void*> {};
+}
+
 #ifdef CAIRO_HAS_XLIB_SURFACE
 #    include <cairo-xlib.h>
 
diff --git a/modules/print.cpp b/modules/print.cpp
index bccbcfed..f3076ce0 100644
--- a/modules/print.cpp
+++ b/modules/print.cpp
@@ -22,6 +22,14 @@
 #include "gjs/jsapi-util.h"
 #include "modules/print.h"
 
+// Avoid static_assert in MSVC builds
+namespace JS {
+template <typename T> struct GCPolicy;
+
+template <>
+struct GCPolicy<void*> : public IgnoreGCPolicy<void*> {};
+}
+
 GJS_JSAPI_RETURN_CONVENTION
 static bool gjs_log(JSContext* cx, unsigned argc, JS::Value* vp) {
     JS::CallArgs argv = JS::CallArgsFromVp(argc, vp);


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