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




commit 892a17b6b4a732641c7b02af003d5e669749fc15
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             | 6 ++++++
 gjs/context-private.h     | 1 -
 gjs/deprecation.cpp       | 6 ++++++
 gjs/jsapi-util-string.cpp | 6 ++++++
 gjs/stack.cpp             | 6 ++++++
 modules/cairo.cpp         | 6 ++++++
 modules/print.cpp         | 6 ++++++
 7 files changed, 36 insertions(+), 1 deletion(-)
---
diff --git a/gjs/atoms.cpp b/gjs/atoms.cpp
index e6d2be69..0c947ab7 100644
--- a/gjs/atoms.cpp
+++ b/gjs/atoms.cpp
@@ -35,6 +35,12 @@
 
 #include "gjs/atoms.h"
 
+// Avoid static_assert in MSVC builds
+namespace JS {
+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..285618db 100644
--- a/gjs/deprecation.cpp
+++ b/gjs/deprecation.cpp
@@ -42,6 +42,12 @@
 #include "gjs/deprecation.h"
 #include "gjs/macros.h"
 
+// Avoid static_assert in MSVC builds
+namespace JS {
+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..09fea81c 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -50,6 +50,12 @@
 #include "gjs/jsapi-util.h"
 #include "gjs/macros.h"
 
+// Avoid static_assert in MSVC builds
+namespace JS {
+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..f485c919 100644
--- a/gjs/stack.cpp
+++ b/gjs/stack.cpp
@@ -52,6 +52,12 @@
 
 #include "gjs/context.h"
 
+// Avoid static_assert in MSVC builds
+namespace JS {
+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..4af95d77 100644
--- a/modules/cairo.cpp
+++ b/modules/cairo.cpp
@@ -32,6 +32,12 @@
 #include "gjs/jsapi-util.h"
 #include "modules/cairo-private.h"
 
+// Avoid static_assert in MSVC builds
+namespace JS {
+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..45436e0d 100644
--- a/modules/print.cpp
+++ b/modules/print.cpp
@@ -22,6 +22,12 @@
 #include "gjs/jsapi-util.h"
 #include "modules/print.h"
 
+// Avoid static_assert in MSVC builds
+namespace JS {
+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]