From e7236e4a5ff6e7d28792d6ab8bee43c2024a9a53 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 27 Jul 2019 13:36:51 +0200 Subject: Fix unused parameter warnings and prevent rot --- pugl/cairo_gl.h | 3 +++ pugl/pugl_internal.h | 5 +---- pugl/pugl_internal_types.h | 11 ++++++++++- pugl/pugl_osx.m | 44 +++++++++++++++++++++++++++++++------------- pugl/pugl_win.c | 3 +-- pugl/pugl_x11_cairo.c | 4 ++-- pugl/pugl_x11_gl.c | 10 ++++------ 7 files changed, 52 insertions(+), 28 deletions(-) (limited to 'pugl') diff --git a/pugl/cairo_gl.h b/pugl/cairo_gl.h index 7024ae6..467a435 100644 --- a/pugl/cairo_gl.h +++ b/pugl/cairo_gl.h @@ -55,6 +55,9 @@ pugl_cairo_gl_free(PuglCairoGL* ctx) static void pugl_cairo_gl_configure(PuglCairoGL* ctx, int width, int height) { + (void)ctx; + (void)width; + (void)height; glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_RECTANGLE_ARB); diff --git a/pugl/pugl_internal.h b/pugl/pugl_internal.h index 6042e6a..57b026f 100644 --- a/pugl/pugl_internal.h +++ b/pugl/pugl_internal.h @@ -46,11 +46,8 @@ puglDefaultHints(void) } PuglView* -puglInit(int* pargc, char** argv) +puglInit(int* PUGL_UNUSED(pargc), char** PUGL_UNUSED(argv)) { - (void)pargc; - (void)argv; - PuglView* view = (PuglView*)calloc(1, sizeof(PuglView)); if (!view) { return NULL; diff --git a/pugl/pugl_internal_types.h b/pugl/pugl_internal_types.h index c065902..6a1ea80 100644 --- a/pugl/pugl_internal_types.h +++ b/pugl/pugl_internal_types.h @@ -21,10 +21,19 @@ #ifndef PUGL_INTERNAL_TYPES_H #define PUGL_INTERNAL_TYPES_H +#include "pugl/pugl.h" + #include #include -#include "pugl/pugl.h" +// Unused parameter macro to suppresses warnings and make it impossible to use +#if defined(__cplusplus) || defined(_MSC_VER) +# define PUGL_UNUSED(name) +#elif defined(__GNUC__) +# define PUGL_UNUSED(name) name##_unused __attribute__((__unused__)) +#else +# define PUGL_UNUSED(name) +#endif /** Platform-specific internals. */ typedef struct PuglInternalsImpl PuglInternals; diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m index 2164597..3112a23 100644 --- a/pugl/pugl_osx.m +++ b/pugl/pugl_osx.m @@ -72,6 +72,8 @@ struct PuglInternalsImpl { backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag { + (void)flag; + NSWindow* result = [super initWithContentRect:contentRect styleMask:aStyle backing:bufferingType @@ -217,7 +219,7 @@ struct PuglInternalsImpl { } static uint32_t -getModifiers(PuglView* view, NSEvent* ev) +getModifiers(const NSEvent* const ev) { const NSEventModifierFlags modifierFlags = [ev modifierFlags]; @@ -228,7 +230,7 @@ getModifiers(PuglView* view, NSEvent* ev) } static PuglKey -keySymToSpecial(PuglView* view, NSEvent* ev) +keySymToSpecial(const NSEvent* const ev) { NSString* chars = [ev charactersIgnoringModifiers]; if ([chars length] == 1) { @@ -303,7 +305,7 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) wloc.y, rloc.x, [[NSScreen mainScreen] frame].size.height - rloc.y, - getModifiers(view->puglview, event), + getModifiers(event), PUGL_CROSSING_NORMAL }; puglDispatchEvent(view->puglview, (const PuglEvent*)&ev); @@ -331,7 +333,7 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) wloc.y, rloc.x, [[NSScreen mainScreen] frame].size.height - rloc.y, - getModifiers(puglview, event), + getModifiers(event), 0, 1 }; @@ -365,7 +367,7 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) wloc.y, rloc.x, [[NSScreen mainScreen] frame].size.height - rloc.y, - getModifiers(puglview, event), + getModifiers(event), (uint32_t)[event buttonNumber] + 1 }; puglDispatchEvent(puglview, (const PuglEvent*)&ev); @@ -383,7 +385,7 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) wloc.y, rloc.x, [[NSScreen mainScreen] frame].size.height - rloc.y, - getModifiers(puglview, event), + getModifiers(event), (uint32_t)[event buttonNumber] + 1 }; puglDispatchEvent(puglview, (const PuglEvent*)&ev); @@ -421,7 +423,7 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) wloc.y, rloc.x, [[NSScreen mainScreen] frame].size.height - rloc.y, - getModifiers(puglview, event), + getModifiers(event), [event deltaX], [event deltaY] }; @@ -436,7 +438,7 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) const NSPoint wloc = [self eventLocation:event]; const NSPoint rloc = [NSEvent mouseLocation]; - const PuglKey spec = keySymToSpecial(puglview, event); + const PuglKey spec = keySymToSpecial(event); const NSString* chars = [event charactersIgnoringModifiers]; const char* str = [[chars lowercaseString] UTF8String]; const uint32_t code = ( @@ -450,7 +452,7 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) wloc.y, rloc.x, [[NSScreen mainScreen] frame].size.height - rloc.y, - getModifiers(puglview, event), + getModifiers(event), [event keyCode], (code != 0xFFFD) ? code : 0 }; @@ -466,7 +468,7 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) { const NSPoint wloc = [self eventLocation:event]; const NSPoint rloc = [NSEvent mouseLocation]; - const PuglKey spec = keySymToSpecial(puglview, event); + const PuglKey spec = keySymToSpecial(event); const NSString* chars = [event charactersIgnoringModifiers]; const char* str = [[chars lowercaseString] UTF8String]; const uint32_t code = @@ -480,7 +482,7 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) wloc.y, rloc.x, [[NSScreen mainScreen] frame].size.height - rloc.y, - getModifiers(puglview, event), + getModifiers(event), [event keyCode], (code != 0xFFFD) ? code : 0 }; @@ -508,6 +510,8 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) selectedRange:(NSRange)selected replacementRange:(NSRange)replacement { + (void)selected; + (void)replacement; [markedText release]; markedText = ( [string isKindOfClass:[NSAttributedString class]] @@ -529,17 +533,23 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) attributedSubstringForProposedRange:(NSRange)range actualRange:(NSRangePointer)actual { + (void)range; + (void)actual; return nil; } - (NSUInteger) characterIndexForPoint:(NSPoint)point { + (void)point; return 0; } - (NSRect) firstRectForCharacterRange:(NSRange)range actualRange:(NSRangePointer)actual { + (void)range; + (void)actual; + const NSRect frame = [(id)puglview bounds]; return NSMakeRect(frame.origin.x, frame.origin.y, 0.0, 0.0); } @@ -547,6 +557,8 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) - (void) insertText:(id)string replacementRange:(NSRange)replacement { + (void)replacement; + NSEvent* const event = [NSApp currentEvent]; NSString* const characters = ([string isKindOfClass:[NSAttributedString class]] @@ -575,7 +587,7 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) wloc.y, rloc.x, [[NSScreen mainScreen] frame].size.height - rloc.y, - getModifiers(puglview, event), + getModifiers(event), [event keyCode], code, { 0, 0, 0, 0, 0, 0, 0, 0 } }; @@ -587,7 +599,7 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) - (void) flagsChanged:(NSEvent*)event { - const uint32_t mods = getModifiers(puglview, event); + const uint32_t mods = getModifiers(event); PuglEventType type = PUGL_NOTHING; PuglKey special = 0; @@ -685,6 +697,8 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) - (BOOL) windowShouldClose:(id)sender { + (void)sender; + PuglEvent ev = { 0 }; ev.type = PUGL_CLOSE; puglDispatchEvent(window->puglview, &ev); @@ -693,6 +707,8 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) - (void) windowDidBecomeKey:(NSNotification*)notification { + (void)notification; + PuglOpenGLView* glview = window->puglview->impl->glview; if (window->puglview->impl->glview->urgentTimer) { [glview->urgentTimer invalidate]; @@ -707,6 +723,8 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) - (void) windowDidResignKey:(NSNotification*)notification { + (void)notification; + PuglEvent ev = { 0 }; ev.type = PUGL_FOCUS_OUT; ev.focus.grab = false; diff --git a/pugl/pugl_win.c b/pugl/pugl_win.c index b691295..e47916c 100644 --- a/pugl/pugl_win.c +++ b/pugl/pugl_win.c @@ -856,9 +856,8 @@ puglRequestAttention(PuglView* view) } PuglStatus -puglWaitForEvent(PuglView* view) +puglWaitForEvent(PuglView* PUGL_UNUSED(view)) { - (void)view; WaitMessage(); return PUGL_SUCCESS; } diff --git a/pugl/pugl_x11_cairo.c b/pugl/pugl_x11_cairo.c index c62621e..53304d8 100644 --- a/pugl/pugl_x11_cairo.c +++ b/pugl/pugl_x11_cairo.c @@ -89,13 +89,13 @@ puglX11CairoDestroy(PuglView* view) } static int -puglX11CairoEnter(PuglView* view) +puglX11CairoEnter(PuglView* PUGL_UNUSED(view)) { return 0; } static int -puglX11CairoLeave(PuglView* view, bool flush) +puglX11CairoLeave(PuglView* PUGL_UNUSED(view), bool PUGL_UNUSED(flush)) { return 0; } diff --git a/pugl/pugl_x11_gl.c b/pugl/pugl_x11_gl.c index 0102f4c..06b4b2e 100644 --- a/pugl/pugl_x11_gl.c +++ b/pugl/pugl_x11_gl.c @@ -174,18 +174,16 @@ puglX11GlLeave(PuglView* view, bool flush) } static int -puglX11GlResize(PuglView* view, int width, int height) +puglX11GlResize(PuglView* PUGL_UNUSED(view), + int PUGL_UNUSED(width), + int PUGL_UNUSED(height)) { - (void)view; - (void)width; - (void)height; return 0; } static void* -puglX11GlGetHandle(PuglView* view) +puglX11GlGetHandle(PuglView* PUGL_UNUSED(view)) { - (void)view; return NULL; } -- cgit v1.2.1