Add WritePackFunction and ReadPackFunction natives
Adds type safety to CDataPack. Cells can't be read as Float anymore. Now you're able to store a function pointer in a datapack and be sure the pointer can't be read as a cell and a cell can't be read as a function pointer.
This commit is contained in:
@@ -72,6 +72,16 @@ native WritePackFloat(Handle:pack, Float:val);
|
||||
*/
|
||||
native WritePackString(Handle:pack, const String:str[]);
|
||||
|
||||
/**
|
||||
* Packs a function pointer into a data pack.
|
||||
*
|
||||
* @param pack Handle to the data pack.
|
||||
* @param fktptr Function pointer to add.
|
||||
* @noreturn
|
||||
* @error Invalid handle.
|
||||
*/
|
||||
native WritePackFunction(Handle:pack, Function:fktptr);
|
||||
|
||||
/**
|
||||
* Reads a cell from a data pack.
|
||||
*
|
||||
@@ -101,6 +111,15 @@ native Float:ReadPackFloat(Handle:pack);
|
||||
*/
|
||||
native ReadPackString(Handle:pack, String:buffer[], maxlen);
|
||||
|
||||
/**
|
||||
* Reads a function pointer from a data pack.
|
||||
*
|
||||
* @param pack Handle to the data pack.
|
||||
* @return Function pointer.
|
||||
* @error Invalid handle, or bounds error.
|
||||
*/
|
||||
native Function ReadPackFunction(Handle:pack);
|
||||
|
||||
/**
|
||||
* Resets the position in a data pack.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user