From 126677a832652a3e68cf89afe3475c174c28b6e3 Mon Sep 17 00:00:00 2001 From: Julien Fischer Date: Fri, 27 Feb 2026 16:49:38 +1100 Subject: [PATCH] Fix errors in the GLUT binding. extras/graphics/mercury_glut/glut.callback.m: Rename overlay_display_func/2 -> disable_overlay_display_func/2 for consistency with every other pair of callback predicates in this module. Add a space before a determinism declaration. Delete doubled-up tabled_for_io attributes from foreign_procs. Call the correct GLUT function to disable keyboard up callbacks. extras/graphics/mercury_glut/glut.color_map.m: Fix incorrect argument ordering in a documentation comment. extras/graphics/mercury_glut/glut.font.m: Fix formatting. extras/graphics/mercury_glut/glut.m: Fix the definition of the glut_alpha/0 function, which was returning the wrong value. extras/graphics/mercury_glut/glut.overlay.m: Fix a documentation comment. Add some tabled_for_io attributes. extras/graphics/mercury_glut/glut.window.m: Fix doubled-up-word. s/__IO/_IO etc. --- extras/graphics/mercury_glut/glut.callback.m | 14 +++++++------- extras/graphics/mercury_glut/glut.color_map.m | 4 ++-- extras/graphics/mercury_glut/glut.font.m | 4 ++-- extras/graphics/mercury_glut/glut.m | 6 +++--- extras/graphics/mercury_glut/glut.overlay.m | 6 +++--- extras/graphics/mercury_glut/glut.window.m | 9 +++++---- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/extras/graphics/mercury_glut/glut.callback.m b/extras/graphics/mercury_glut/glut.callback.m index 73e4534c0..0cca47f71 100644 --- a/extras/graphics/mercury_glut/glut.callback.m +++ b/extras/graphics/mercury_glut/glut.callback.m @@ -2,7 +2,7 @@ % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% % Copyright (C) 2004-2007 The University of Melbourne. -% Copyright (C) 2017-2018, 2020 The Mercury team. +% Copyright (C) 2017-2018, 2020, 2026 The Mercury team. % This file is distributed under the terms specified in COPYING.LIB. %-----------------------------------------------------------------------------% % @@ -27,7 +27,7 @@ % to force the window to be redrawn. % :- pred callback.display_func(pred(io, io), io, io). -:- mode callback.display_func(pred(di, uo) is det, di, uo)is det. +:- mode callback.display_func(pred(di, uo) is det, di, uo) is det. % Unregisters the display callback for the current window. % @@ -216,7 +216,7 @@ % Unregister the overlay display callback for the current window. % -:- pred callback.overlay_display_func(io::di, io::uo) is det. +:- pred callback.disable_overlay_display_func(io::di, io::uo) is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -606,7 +606,7 @@ do_visibility_callback(VisibilityFunc, Visibility, !IO) :- :- pragma foreign_proc("C", disable_visibility_func(_IO0::di, _IO::uo), - [will_not_call_mercury, tabled_for_io, promise_pure, tabled_for_io], + [will_not_call_mercury, promise_pure, tabled_for_io], " glutVisibilityFunc(NULL); "). @@ -624,7 +624,7 @@ do_visibility_callback(VisibilityFunc, Visibility, !IO) :- :- pragma foreign_proc("C", idle_func(Closure::pred(di, uo) is det, _IO0::di, _IO::uo), - [will_not_call_mercury, tabled_for_io, promise_pure, tabled_for_io], + [will_not_call_mercury, promise_pure, tabled_for_io], " mglut_idle_callback = Closure; glutIdleFunc(MGLUT_idle_callback); @@ -688,7 +688,7 @@ do_keyboard_up_callback(KeyBoardUpFunc, ScanCode, X, Y, !IO) :- disable_keyboard_up_func(_IO0::di, _IO::uo), [will_not_call_mercury, tabled_for_io, promise_pure], " - glutKeyboardFunc(NULL); + glutKeyboardUpFunc(NULL); "). %-----------------------------------------------------------------------------% @@ -720,7 +720,7 @@ do_overlay_display_callback(OverlayDisplayFunc, !IO) :- OverlayDisplayFunc(!IO). :- pragma foreign_proc("C", - overlay_display_func(_IO0::di, _IO::uo), + disable_overlay_display_func(_IO0::di, _IO::uo), [will_not_call_mercury, promise_pure], " glutOverlayDisplayFunc(NULL); diff --git a/extras/graphics/mercury_glut/glut.color_map.m b/extras/graphics/mercury_glut/glut.color_map.m index 685257cc5..48b29c98c 100644 --- a/extras/graphics/mercury_glut/glut.color_map.m +++ b/extras/graphics/mercury_glut/glut.color_map.m @@ -2,7 +2,7 @@ % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% % Copyright (C) 2004-2007, 2012 The University of Melbourne. -% Copyright (C) 2017-2018, 2020 The Mercury team. +% Copyright (C) 2017-2018, 2020, 2026 The Mercury team. % This file is distributed under the terms specified in COPYING.LIB. %-----------------------------------------------------------------------------% % @@ -28,7 +28,7 @@ ; blue ; green. - % color_map.set_color(Index, Red, Blue, Green, !IO). + % color_map.set_color(Index, Red, Green, Blue, !IO). % Set the colormap entry for the given index. % :- pred color_map.set_color(int::in, float::in, float::in, float::in, diff --git a/extras/graphics/mercury_glut/glut.font.m b/extras/graphics/mercury_glut/glut.font.m index 249f393b6..48722d9a6 100644 --- a/extras/graphics/mercury_glut/glut.font.m +++ b/extras/graphics/mercury_glut/glut.font.m @@ -2,7 +2,7 @@ % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% % Copyright (C) 2004-2007, 2012 The University of Melbourne. -% Copyright (C) 2017-2018, 2020 The Mercury team. +% Copyright (C) 2017-2018, 2020, 2026 The Mercury team. % This file is distributed under the terms specified in COPYING.LIB. %-----------------------------------------------------------------------------% % @@ -126,7 +126,7 @@ font.bitmap_length(Font, String) = Length :- bitmap_length_2(FntPtr::in, Str::in, Length::out), [will_not_call_mercury, promise_pure], " - Length = (MR_Integer) glutBitmapLength(FntPtr, Str); + Length = (MR_Integer) glutBitmapLength(FntPtr, Str); "). :- func bitmap_font_to_ptr(bitmap_font) = font_ptr. diff --git a/extras/graphics/mercury_glut/glut.m b/extras/graphics/mercury_glut/glut.m index ec5c6825a..ad48952cd 100644 --- a/extras/graphics/mercury_glut/glut.m +++ b/extras/graphics/mercury_glut/glut.m @@ -2,7 +2,7 @@ % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% % Copyright (C) 2004-2007, 2012 The University of Melbourne. -% Copyright (C) 2017-2018 The Mercury team. +% Copyright (C) 2017-2018, 2020, 2026 The Mercury team. % This file is distributed under the terms specified in COPYING.LIB. %-----------------------------------------------------------------------------% % @@ -13,7 +13,7 @@ % % If used with freeglut then some of the extensions available in freeglut will % also be available. Calling the freeglut extensions when freeglut is *not* -% available will result in a software_error1/ exception being thrown. +% available will result in a software_error/1 exception being thrown. % % You can use the predicate glut.have_freeglut/0 to test for the presence % of freeglut. @@ -294,7 +294,7 @@ display_mode_to_int(luminance) = glut_luminance. :- pragma foreign_proc("C", glut_alpha = (Value::out), [will_not_call_mercury, promise_pure, thread_safe], " - Value = (MR_Integer) GLUT_ACCUM; + Value = (MR_Integer) GLUT_ALPHA; "). :- func glut_depth = int. diff --git a/extras/graphics/mercury_glut/glut.overlay.m b/extras/graphics/mercury_glut/glut.overlay.m index 3bc349116..e30c05030 100644 --- a/extras/graphics/mercury_glut/glut.overlay.m +++ b/extras/graphics/mercury_glut/glut.overlay.m @@ -27,7 +27,7 @@ ---> normal ; overlay. - % Returns `yes' of it is possible to establish an overlay for the + % Returns `yes' if it is possible to establish an overlay for the % current window; `no' otherwise. % :- pred overlay.possible(bool::out, io::di, io::uo) is det. @@ -167,14 +167,14 @@ overlay.establish(Result, !IO) :- :- pragma foreign_proc("C", overlay.post_redisplay(_IO0::di, _IO::uo), - [will_not_call_mercury, promise_pure], + [will_not_call_mercury, tabled_for_io, promise_pure], " glutPostOverlayRedisplay(); "). :- pragma foreign_proc("C", overlay.post_redisplay(Window::in, _IO0::di, _IO::uo), - [will_not_call_mercury, promise_pure], + [will_not_call_mercury, tabled_for_io, promise_pure], " glutPostWindowOverlayRedisplay((int) Window); "). diff --git a/extras/graphics/mercury_glut/glut.window.m b/extras/graphics/mercury_glut/glut.window.m index dfa5e0f82..d5e247010 100644 --- a/extras/graphics/mercury_glut/glut.window.m +++ b/extras/graphics/mercury_glut/glut.window.m @@ -2,7 +2,7 @@ % vim: ft=mercury ts=4 sw=4 et %-----------------------------------------------------------------------------% % Copyright (C) 2004-2007, 2012 The University of Melbourne. -% Copyright (C) 2017-2018, 2020 The Mercury team. +% Copyright (C) 2017-2018, 2020, 2026 The Mercury team. % This file is distributed under the terms specified in COPYING.LIB. %-----------------------------------------------------------------------------% % @@ -38,7 +38,7 @@ % window. :- pred window.create(string::in, window::out, io::di, io::uo) is det. - % Create a subwindow. Implicitly the the current window is set + % Create a subwindow. Implicitly the current window is set % to the newly created subwindow. % XXX We need a way to handle multiple windows for this to be useful. % @@ -502,6 +502,7 @@ cursor_to_int(inherit) = glut_cursor_inherit. " V = (MR_Integer) GLUT_CURSOR_CYCLE; "). + :- func glut_cursor_wait = int. :- pragma foreign_proc("C", glut_cursor_wait = (V::out), [will_not_call_mercury, promise_pure, thread_safe], @@ -711,7 +712,7 @@ window.set_cursor(Cursor, !IO) :- ]). :- pragma foreign_proc("C", - window.get(State::in, Value::out, __IO0::di, __IO::uo), + window.get(State::in, Value::out, _IO0::di, _IO::uo), [will_not_call_mercury, tabled_for_io, promise_pure], " Value = (MR_Integer) glutGet((GLenum) State); @@ -720,7 +721,7 @@ window.set_cursor(Cursor, !IO) :- %-----------------------------------------------------------------------------% :- pragma foreign_proc("C", - window.has_overlay(Result::out, __IO0::di, __IO::uo), + window.has_overlay(Result::out, _IO0::di, _IO::uo), [will_not_call_mercury, tabled_for_io, promise_pure], " if (glutLayerGet(GLUT_HAS_OVERLAY)) {