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
This commit is contained in:
Hajime Hoshi 2019-12-03 00:53:01 +09:00
parent 42056c2d61
commit 7991ba4cfa
4 changed files with 6 additions and 11 deletions

View File

@ -16,14 +16,13 @@
#include <stdint.h>
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);

View File

@ -38,8 +38,8 @@ void MetalLayer_SetDevice(void *metalLayer, void *device) {
((CAMetalLayer *)metalLayer).device = (id<MTLDevice>)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) {

View File

@ -14,11 +14,7 @@
// +build darwin
#include <stdint.h>
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);

View File

@ -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;
}