From 11abe77eed2adfaf4d28a7ddf57fde9e133c442a Mon Sep 17 00:00:00 2001 From: Michael Flaherty Date: Wed, 25 Jul 2018 21:46:44 -0700 Subject: [PATCH] Allow any returns in native callbacks (#857) --- plugins/adminmenu.sp | 4 ++-- plugins/include/functions.inc | 34 ++++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/plugins/adminmenu.sp b/plugins/adminmenu.sp index ec95d069a..776a7ff4f 100644 --- a/plugins/adminmenu.sp +++ b/plugins/adminmenu.sp @@ -162,9 +162,9 @@ public void DefaultCategoryHandler(TopMenu topmenu, } } -public int __GetAdminTopMenu(Handle plugin, int numParams) +public any __GetAdminTopMenu(Handle plugin, int numParams) { - return view_as(hAdminMenu); + return hAdminMenu; } public int __AddTargetsToMenu(Handle plugin, int numParams) diff --git a/plugins/include/functions.inc b/plugins/include/functions.inc index b9bd2f9c7..060ec0691 100644 --- a/plugins/include/functions.inc +++ b/plugins/include/functions.inc @@ -357,16 +357,30 @@ native int Call_Finish(any &result=0); */ native void Call_Cancel(); -/** - * 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. - * @return Value for the native call to return. - */ -typedef NativeCall = function int (Handle plugin, int numParams); +typeset NativeCall +{ + /** + * 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. + * @return Value for the native call to return. + */ + function int (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. + * @return Value for the native call to return. + */ + function any (Handle plugin, int numParams); +} /** * Creates a dynamic native. This should only be called in AskPluginLoad(), or