Skip to content

Commit

Permalink
Add void function prototypes to NativeCall and MenuHandler (#2081)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
MAGNAT2645 authored Dec 18, 2023
1 parent 385eae8 commit ab6b45b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
10 changes: 10 additions & 0 deletions plugins/include/functions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
9 changes: 8 additions & 1 deletion plugins/include/menus.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down

0 comments on commit ab6b45b

Please sign in to comment.