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
+14
View File
@@ -113,6 +113,13 @@ namespace SourceMod
* @return Pointer to the data, or NULL if out of bounds.
*/
virtual void *ReadMemory(size_t *size) const =0;
/**
* @brief Reads a function pointer from the data stream.
*
* @return A function pointer read from the current position.
*/
virtual cell_t ReadFunction() const =0;
};
/**
@@ -160,6 +167,13 @@ namespace SourceMod
* @return Current position of the stream beforehand.
*/
virtual size_t CreateMemory(size_t size, void **addr) =0;
/**
* @brief Packs one function pointer into the data stream.
*
* @param function The function pointer to write.
*/
virtual void PackFunction(cell_t function) =0;
};
}