From ab6b45b81cfcaa8034d9ee90af1beb9aff6527d0 Mon Sep 17 00:00:00 2001 From: Ivan Zaitsev Date: Tue, 19 Dec 2023 04:57:58 +0500 Subject: [PATCH] Add void function prototypes to NativeCall and MenuHandler (#2081) * Add void prototype to NativeCall typeset `void` prototype can be used for simple natives which don't return any value. This is done to silence compiler warnings 209 (`function has explicit 'int' tag but does not return a value`) and 242 (`function "NativeCallback" should return an explicit value`). * Make MenuHandler into typeset and add void prototype This can be used for basic menu handlers that don't return modified item styles and don't redraw menu items. --- plugins/include/functions.inc | 10 ++++++++++ plugins/include/menus.inc | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/include/functions.inc b/plugins/include/functions.inc index f1bab1e18e..e386b1a389 100644 --- a/plugins/include/functions.inc +++ b/plugins/include/functions.inc @@ -448,6 +448,16 @@ typeset NativeCall * @return Value for the native call to return. */ function any (Handle plugin, int numParams); + + /** + * Defines a native function. + * + * It is not necessary to validate the parameter count + * + * @param plugin Handle of the calling plugin. + * @param numParams Number of parameters passed to the native. + */ + function void (Handle plugin, int numParams); } /** diff --git a/plugins/include/menus.inc b/plugins/include/menus.inc index e440e2f720..b1cd6673a0 100644 --- a/plugins/include/menus.inc +++ b/plugins/include/menus.inc @@ -148,8 +148,15 @@ enum MenuSource * @param action The action of the menu. * @param param1 First action parameter (usually the client). * @param param2 Second action parameter (usually the item). + * + * Use void-typed prototype if you don't plan to handle MenuAction_DrawItem + * and MenuAction_DisplayItem actions. */ -typedef MenuHandler = function int (Menu menu, MenuAction action, int param1, int param2); +typeset MenuHandler +{ + function int (Menu menu, MenuAction action, int param1, int param2); + function void (Menu menu, MenuAction action, int param1, int param2); +}; // Panels are used for drawing raw menus without any extra helper functions. // Handles must be closed via delete or CloseHandle().