Skip to content

Commit

Permalink
Get rid of GLFWbool
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Jun 8, 2019
1 parent 6bcab56 commit fe62700
Show file tree
Hide file tree
Showing 42 changed files with 275 additions and 276 deletions.
6 changes: 3 additions & 3 deletions glfw/cocoa_init.m
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static void createKeyTables(void)

// Retrieve Unicode data for the current keyboard layout
//
static GLFWbool updateUnicodeDataNS(void)
static bool updateUnicodeDataNS(void)
{
if (_glfw.ns.inputSource)
{
Expand Down Expand Up @@ -232,7 +232,7 @@ static GLFWbool updateUnicodeDataNS(void)

// Load HIToolbox.framework and the TIS symbols we need from it
//
static GLFWbool initializeTIS(void)
static bool initializeTIS(void)
{
// This works only because Cocoa has already loaded it properly
_glfw.ns.tis.bundle =
Expand Down Expand Up @@ -558,7 +558,7 @@ void _glfwPlatformRemoveTimer(unsigned long long timer_id) {
}
}

void _glfwPlatformUpdateTimer(unsigned long long timer_id, double interval, GLFWbool enabled) {
void _glfwPlatformUpdateTimer(unsigned long long timer_id, double interval, bool enabled) {
for (size_t i = 0; i < num_timers; i++) {
if (timers[i].id == timer_id) {
Timer *t = timers + i;
Expand Down
8 changes: 4 additions & 4 deletions glfw/cocoa_monitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@

// Check whether the display mode should be included in enumeration
//
static GLFWbool modeIsGood(CGDisplayModeRef mode)
static bool modeIsGood(CGDisplayModeRef mode)
{
uint32_t flags = CGDisplayModeGetIOFlags(mode);

Expand Down Expand Up @@ -215,7 +215,7 @@ static void endFadeReservation(CGDisplayFadeReservationToken token)

// Finds and caches the NSScreen corresponding to the specified monitor
//
GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
bool refreshMonitorScreen(_GLFWmonitor* monitor)
{
if (monitor->ns.screen)
return GLFW_TRUE;
Expand Down Expand Up @@ -265,7 +265,7 @@ static CVReturn displayLinkCallback(
{
CGDirectDisplayID displayID = (CGDirectDisplayID)userInfo;
[_glfw.ns.displayLinks.lock lock];
GLFWbool notify = GLFW_FALSE;
bool notify = GLFW_FALSE;
for (size_t i = 0; i < _glfw.ns.displayLinks.count; i++) {
if (_glfw.ns.displayLinks.entries[i].displayID == displayID) {
if (_glfw.ns.displayLinks.entries[i].renderFrameRequested) {
Expand Down Expand Up @@ -542,7 +542,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
CVDisplayLinkRelease(link);
}

GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
{
uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));
Expand Down
12 changes: 6 additions & 6 deletions glfw/cocoa_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ typedef struct _GLFWwindowNS
id view;
id layer;

GLFWbool maximized;
GLFWbool retina;
bool maximized;
bool retina;

// Cached window properties to filter out duplicate events
int width, height;
Expand All @@ -136,16 +136,16 @@ typedef struct _GLFWwindowNS
// Dead key state
UInt32 deadKeyState;
// Whether a render frame has been requested for this window
GLFWbool renderFrameRequested;
bool renderFrameRequested;
GLFWcocoarenderframefun renderFrameCallback;
} _GLFWwindowNS;

typedef struct _GLFWDisplayLinkNS
{
CVDisplayLinkRef displayLink;
CGDirectDisplayID displayID;
GLFWbool displayLinkStarted;
GLFWbool renderFrameRequested;
bool displayLinkStarted;
bool renderFrameRequested;
} _GLFWDisplayLinkNS;

// Cocoa-specific global data
Expand All @@ -154,7 +154,7 @@ typedef struct _GLFWlibraryNS
{
CGEventSourceRef eventSource;
id delegate;
GLFWbool cursorHidden;
bool cursorHidden;
TISInputSourceRef inputSource;
IOHIDManagerRef hidManager;
id unicodeData;
Expand Down
18 changes: 9 additions & 9 deletions glfw/cocoa_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ CGDirectDisplayID displayIDForWindow(_GLFWwindow *w) {

// Returns whether the cursor is in the content area of the specified window
//
static GLFWbool cursorInContentArea(_GLFWwindow* window)
static bool cursorInContentArea(_GLFWwindow* window)
{
const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
return [window->ns.view mouse:pos inRect:[window->ns.view frame]];
Expand Down Expand Up @@ -263,7 +263,7 @@ static int translateFlags(NSUInteger flags)

// Translates a macOS keycode to a GLFW keycode
//
static int translateKey(unsigned int key, GLFWbool apply_keymap)
static int translateKey(unsigned int key, bool apply_keymap)
{
if (apply_keymap) {
// Look for the effective key name after applying any keyboard layouts/mappings
Expand Down Expand Up @@ -860,7 +860,7 @@ - (void)updateTrackingAreas
CFRelease(string);
}

static inline GLFWbool
static inline bool
is_ascii_control_char(char x) {
return x == 0 || (1 <= x && x <= 31) || x == 127;
}
Expand All @@ -871,7 +871,7 @@ - (void)keyDown:(NSEvent *)event
const NSUInteger flags = [event modifierFlags];
const int mods = translateFlags(flags);
const int key = translateKey(scancode, GLFW_TRUE);
const GLFWbool process_text = !window->ns.textInputFilterCallback || window->ns.textInputFilterCallback(key, mods, scancode, flags) != 1;
const bool process_text = !window->ns.textInputFilterCallback || window->ns.textInputFilterCallback(key, mods, scancode, flags) != 1;
const bool previous_has_marked_text = [self hasMarkedText];
[self unmarkText];
_glfw.ns.text[0] = 0;
Expand Down Expand Up @@ -1285,7 +1285,7 @@ static void createMenuBar(void)

// Initialize the Cocoa Application Kit
//
static GLFWbool initializeAppKit(void)
static bool initializeAppKit(void)
{
if (_glfw.ns.delegate)
return GLFW_TRUE;
Expand Down Expand Up @@ -1329,7 +1329,7 @@ static GLFWbool initializeAppKit(void)

// Create the Cocoa window
//
static GLFWbool createNativeWindow(_GLFWwindow* window,
static bool createNativeWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWfbconfig* fbconfig)
{
Expand Down Expand Up @@ -1800,18 +1800,18 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
return ![window->ns.object isOpaque] && ![window->ns.view isOpaque];
}

void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, bool enabled)
{
[window->ns.object setStyleMask:getStyleMask(window)];
}

void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, bool enabled)
{
[window->ns.object setStyleMask:getStyleMask(window)];
[window->ns.object makeFirstResponder:window->ns.view];
}

void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, bool enabled)
{
if (enabled)
[window->ns.object setLevel:NSFloatingWindowLevel];
Expand Down
6 changes: 3 additions & 3 deletions glfw/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
// exists and whether all relevant options have supported and non-conflicting
// values
//
GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
bool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
{
if (ctxconfig->share)
{
Expand Down Expand Up @@ -341,7 +341,7 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,

// Retrieves the attributes of the current context
//
GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
bool _glfwRefreshContextAttribs(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig)
{
int i;
Expand Down Expand Up @@ -577,7 +577,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,

// Searches an extension string for the specified extension
//
GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions)
bool _glfwStringInExtensionString(const char* string, const char* extensions)
{
const char* start = extensions;

Expand Down
24 changes: 12 additions & 12 deletions glfw/dbus_glfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ report_error(DBusError *err, const char *fmt, ...) {
static _GLFWDBUSData *dbus_data = NULL;
static DBusConnection *session_bus = NULL;

GLFWbool
bool
glfw_dbus_init(_GLFWDBUSData *dbus, EventLoopData *eld) {
dbus->eld = eld;
dbus_data = dbus;
Expand Down Expand Up @@ -136,7 +136,7 @@ toggle_dbus_timeout(DBusTimeout *timeout, void *data) {


DBusConnection*
glfw_dbus_connect_to(const char *path, const char* err_msg, const char *name, GLFWbool register_on_bus) {
glfw_dbus_connect_to(const char *path, const char* err_msg, const char *name, bool register_on_bus) {
DBusError err;
dbus_error_init(&err);
DBusConnection *ans = dbus_connection_open_private(path, &err);
Expand Down Expand Up @@ -195,14 +195,14 @@ glfw_dbus_close_connection(DBusConnection *conn) {
dbus_connection_unref(conn);
}

GLFWbool
bool
glfw_dbus_get_args(DBusMessage *msg, const char *failmsg, ...) {
DBusError err;
dbus_error_init(&err);
va_list ap;
va_start(ap, failmsg);
int firstarg = va_arg(ap, int);
GLFWbool ret = dbus_message_get_args_valist(msg, &err, firstarg, ap) ? GLFW_TRUE : GLFW_FALSE;
bool ret = dbus_message_get_args_valist(msg, &err, firstarg, ap) ? GLFW_TRUE : GLFW_FALSE;
va_end(ap);
if (!ret) report_error(&err, failmsg);
return ret;
Expand Down Expand Up @@ -233,9 +233,9 @@ method_reply_received(DBusPendingCall *pending, void *user_data) {
}
}

GLFWbool
bool
call_method_with_msg(DBusConnection *conn, DBusMessage *msg, int timeout, dbus_pending_callback callback, void *user_data) {
GLFWbool retval = GLFW_FALSE;
bool retval = GLFW_FALSE;
#define REPORT(errs) _glfwInputError(GLFW_PLATFORM_ERROR, "Failed to call DBUS method: node=%s path=%s interface=%s method=%s, with error: %s", dbus_message_get_destination(msg), dbus_message_get_path(msg), dbus_message_get_interface(msg), dbus_message_get_member(msg), errs)
if (callback) {
DBusPendingCall *pending = NULL;
Expand All @@ -260,12 +260,12 @@ call_method_with_msg(DBusConnection *conn, DBusMessage *msg, int timeout, dbus_p
#undef REPORT
}

static GLFWbool
static bool
call_method(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, int timeout, dbus_pending_callback callback, void *user_data, va_list ap) {
if (!conn) return GLFW_FALSE;
DBusMessage *msg = dbus_message_new_method_call(node, path, interface, method);
if (!msg) return GLFW_FALSE;
GLFWbool retval = GLFW_FALSE;
bool retval = GLFW_FALSE;

int firstarg = va_arg(ap, int);
if ((firstarg == DBUS_TYPE_INVALID) || dbus_message_append_args_valist(msg, firstarg, ap)) {
Expand All @@ -278,19 +278,19 @@ call_method(DBusConnection *conn, const char *node, const char *path, const char
return retval;
}

GLFWbool
bool
glfw_dbus_call_method_with_reply(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, int timeout, dbus_pending_callback callback, void* user_data, ...) {
GLFWbool retval;
bool retval;
va_list ap;
va_start(ap, user_data);
retval = call_method(conn, node, path, interface, method, timeout, callback, user_data, ap);
va_end(ap);
return retval;
}

GLFWbool
bool
glfw_dbus_call_method_no_reply(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...) {
GLFWbool retval;
bool retval;
va_list ap;
va_start(ap, method);
retval = call_method(conn, node, path, interface, method, DBUS_TIMEOUT_USE_DEFAULT, NULL, NULL, ap);
Expand Down
12 changes: 6 additions & 6 deletions glfw/dbus_glfw.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ typedef struct {
} _GLFWDBUSData;


GLFWbool glfw_dbus_init(_GLFWDBUSData *dbus, EventLoopData *eld);
bool glfw_dbus_init(_GLFWDBUSData *dbus, EventLoopData *eld);
void glfw_dbus_terminate(_GLFWDBUSData *dbus);
DBusConnection* glfw_dbus_connect_to(const char *path, const char* err_msg, const char* name, GLFWbool register_on_bus);
DBusConnection* glfw_dbus_connect_to(const char *path, const char* err_msg, const char* name, bool register_on_bus);
void glfw_dbus_close_connection(DBusConnection *conn);
GLFWbool
bool
call_method_with_msg(DBusConnection *conn, DBusMessage *msg, int timeout, dbus_pending_callback callback, void *user_data);
GLFWbool
bool
glfw_dbus_call_method_no_reply(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
GLFWbool
bool
glfw_dbus_call_method_with_reply(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, int timeout_ms, dbus_pending_callback callback, void *user_data, ...);
void glfw_dbus_dispatch(DBusConnection *);
void glfw_dbus_session_bus_dispatch(void);
GLFWbool glfw_dbus_get_args(DBusMessage *msg, const char *failmsg, ...);
bool glfw_dbus_get_args(DBusMessage *msg, const char *failmsg, ...);
int glfw_dbus_match_signal(DBusMessage *msg, const char *interface, ...);
DBusConnection* glfw_dbus_session_bus(void);
8 changes: 4 additions & 4 deletions glfw/egl_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static int getEGLConfigAttrib(EGLConfig config, int attrib)

// Return the EGLConfig most closely matching the specified hints
//
static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
static bool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* desired,
EGLConfig* result)
{
Expand Down Expand Up @@ -297,7 +297,7 @@ static void destroyContextEGL(_GLFWwindow* window)

// Initialize EGL
//
GLFWbool _glfwInitEGL(void)
bool _glfwInitEGL(void)
{
int i;
const char* sonames[] =
Expand Down Expand Up @@ -453,7 +453,7 @@ void _glfwTerminateEGL(void)

// Create the OpenGL or OpenGL ES context
//
GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
bool _glfwCreateContextEGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
Expand Down Expand Up @@ -714,7 +714,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
// Returns the Visual and depth of the chosen EGLConfig
//
#if defined(_GLFW_X11)
GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
bool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig,
Visual** visual, int* depth)
Expand Down
18 changes: 9 additions & 9 deletions glfw/egl_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ typedef struct _GLFWlibraryEGL
{
EGLDisplay display;
EGLint major, minor;
GLFWbool prefix;
bool prefix;

GLFWbool KHR_create_context;
GLFWbool KHR_create_context_no_error;
GLFWbool KHR_gl_colorspace;
GLFWbool KHR_get_all_proc_addresses;
GLFWbool KHR_context_flush_control;
bool KHR_create_context;
bool KHR_create_context_no_error;
bool KHR_gl_colorspace;
bool KHR_get_all_proc_addresses;
bool KHR_context_flush_control;

void* handle;

Expand All @@ -203,13 +203,13 @@ typedef struct _GLFWlibraryEGL
} _GLFWlibraryEGL;


GLFWbool _glfwInitEGL(void);
bool _glfwInitEGL(void);
void _glfwTerminateEGL(void);
GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
bool _glfwCreateContextEGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig);
#if defined(_GLFW_X11)
GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
bool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig,
Visual** visual, int* depth);
Expand Down
Loading

0 comments on commit fe62700

Please sign in to comment.