Skip to content

Commit

Permalink
Allow any returns in native callbacks (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
Headline committed Jul 26, 2018
1 parent 7d8dfb0 commit 11abe77
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
4 changes: 2 additions & 2 deletions plugins/adminmenu.sp
Expand Up @@ -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<int>(hAdminMenu);
return hAdminMenu;
}

public int __AddTargetsToMenu(Handle plugin, int numParams)
Expand Down
34 changes: 24 additions & 10 deletions plugins/include/functions.inc
Expand Up @@ -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
Expand Down

0 comments on commit 11abe77

Please sign in to comment.