From 7991ba4cfaee81f8ed1cfe78505596c980c6cf80 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 3 Dec 2019 00:53:01 +0900 Subject: [PATCH] graphicsdriver/metal: Bug fix: Failed to compile for iOS The definition of BOOL is different between macOS and iOS. C's bool is used on iOS, but C's bool is hard to use from Go (e.g., an integer cannot be converted to C's bool). Use unsigned char instead. Fixes #1006 --- internal/graphicsdriver/metal/ca/ca.h | 3 +-- internal/graphicsdriver/metal/ca/ca.m | 4 ++-- internal/graphicsdriver/metal/ns/ns.h | 6 +----- internal/graphicsdriver/metal/ns/ns.m | 4 ++-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/internal/graphicsdriver/metal/ca/ca.h b/internal/graphicsdriver/metal/ca/ca.h index d470eed34..a4e1e35d5 100644 --- a/internal/graphicsdriver/metal/ca/ca.h +++ b/internal/graphicsdriver/metal/ca/ca.h @@ -16,14 +16,13 @@ #include -typedef signed char BOOL; typedef unsigned long uint_t; void *MakeMetalLayer(); uint16_t MetalLayer_PixelFormat(void *metalLayer); void MetalLayer_SetDevice(void *metalLayer, void *device); -void MetalLayer_SetOpaque(void *metalLayer, BOOL opaque); +void MetalLayer_SetOpaque(void *metalLayer, unsigned char opaque); const char *MetalLayer_SetPixelFormat(void *metalLayer, uint16_t pixelFormat); const char *MetalLayer_SetMaximumDrawableCount(void *metalLayer, uint_t maximumDrawableCount); diff --git a/internal/graphicsdriver/metal/ca/ca.m b/internal/graphicsdriver/metal/ca/ca.m index 3ce535d58..2ae631835 100644 --- a/internal/graphicsdriver/metal/ca/ca.m +++ b/internal/graphicsdriver/metal/ca/ca.m @@ -38,8 +38,8 @@ void MetalLayer_SetDevice(void *metalLayer, void *device) { ((CAMetalLayer *)metalLayer).device = (id)device; } -void MetalLayer_SetOpaque(void *metalLayer, BOOL opaque) { - ((CAMetalLayer *)metalLayer).opaque = opaque; +void MetalLayer_SetOpaque(void *metalLayer, unsigned char opaque) { + ((CAMetalLayer *)metalLayer).opaque = (BOOL)opaque; } const char *MetalLayer_SetPixelFormat(void *metalLayer, uint16_t pixelFormat) { diff --git a/internal/graphicsdriver/metal/ns/ns.h b/internal/graphicsdriver/metal/ns/ns.h index 7962023e6..ca9c4c078 100644 --- a/internal/graphicsdriver/metal/ns/ns.h +++ b/internal/graphicsdriver/metal/ns/ns.h @@ -14,11 +14,7 @@ // +build darwin -#include - -typedef signed char BOOL; - void *Window_ContentView(void *window); void View_SetLayer(void *view, void *layer); -void View_SetWantsLayer(void *view, BOOL wantsLayer); +void View_SetWantsLayer(void *view, unsigned char wantsLayer); diff --git a/internal/graphicsdriver/metal/ns/ns.m b/internal/graphicsdriver/metal/ns/ns.m index c4a820bcf..55fb09e38 100644 --- a/internal/graphicsdriver/metal/ns/ns.m +++ b/internal/graphicsdriver/metal/ns/ns.m @@ -25,6 +25,6 @@ void View_SetLayer(void *view, void *layer) { ((NSView *)view).layer = (CALayer *)layer; } -void View_SetWantsLayer(void *view, BOOL wantsLayer) { - ((NSView *)view).wantsLayer = wantsLayer; +void View_SetWantsLayer(void *view, unsigned char wantsLayer) { + ((NSView *)view).wantsLayer = (BOOL)wantsLayer; }