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:
Peace-Maker
2014-08-04 02:05:25 +02:00
parent 836cde4e21
commit bfcfbbe107
5 changed files with 176 additions and 12 deletions
+19
View File
@@ -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.
*