Burninate IDataPack (#864)
This doesn't break any extensions NOT using IDataPack, and we do not know of any that are. * The extension storage utility of this interface has been broken for the last 9 months, with ISourceMod::CreateDataPack being disabled. * The plugin interop utility of this interface (its stated purpose) has been broken for the last 11+ years, with ISourceMod::GetDataPackHandleType being disabled. I imagine it only survived the first cleanup 11 years ago because CSS:DM was using it internally, which it has now been migrated away from. Compiled all the included extensions without changes (API compat), and loaded extensions build pre-change without issue (ABI compat).
This commit is contained in:
		
							parent
							
								
									144fb907f1
								
							
						
					
					
						commit
						ba8b42ef1b
					
				| @ -35,7 +35,7 @@ namespace SourceMod { | ||||
| 
 | ||||
| // Add 1 to the RHS of this expression to bump the intercom file
 | ||||
| // This is to prevent mismatching core/logic binaries
 | ||||
| static const uint32_t SM_LOGIC_MAGIC = 0x0F47C0DE - 56; | ||||
| static const uint32_t SM_LOGIC_MAGIC = 0x0F47C0DE - 57; | ||||
| 
 | ||||
| } // namespace SourceMod
 | ||||
| 
 | ||||
|  | ||||
| @ -50,7 +50,6 @@ class IProviderCallbacks; | ||||
| class IExtensionSys; | ||||
| class ITextParsers; | ||||
| class ILogger; | ||||
| class IDataPack; | ||||
| class ICellArray; | ||||
| 
 | ||||
| struct sm_logic_t | ||||
| @ -70,8 +69,6 @@ struct sm_logic_t | ||||
| 	void			(*GenerateError)(IPluginContext *, cell_t, int, const char *, ...); | ||||
| 	void			(*AddNatives)(sp_nativeinfo_t *natives); | ||||
| 	void            (*RegisterProfiler)(IProfilingTool *tool); | ||||
| 	IDataPack *     (*CreateDataPack)(); | ||||
| 	void            (*FreeDataPack)(IDataPack *pack); | ||||
| 	ICellArray *    (*CreateCellArray)(size_t blocksize); | ||||
| 	void            (*FreeCellArray)(ICellArray *arr); | ||||
| 	void *			(*FromPseudoAddress)(uint32_t pseudoAddr); | ||||
|  | ||||
| @ -46,7 +46,7 @@ CDataPack::~CDataPack() | ||||
| 
 | ||||
| static ke::Vector<ke::AutoPtr<CDataPack>> sDataPackCache; | ||||
| 
 | ||||
| IDataPack *CDataPack::New() | ||||
| CDataPack *CDataPack::New() | ||||
| { | ||||
|   if (sDataPackCache.empty()) | ||||
|     return new CDataPack(); | ||||
| @ -58,7 +58,7 @@ IDataPack *CDataPack::New() | ||||
| } | ||||
| 
 | ||||
| void | ||||
| CDataPack::Free(IDataPack *pack) | ||||
| CDataPack::Free(CDataPack *pack) | ||||
| { | ||||
|   sDataPackCache.append(static_cast<CDataPack *>(pack)); | ||||
| } | ||||
| @ -187,11 +187,6 @@ const char *CDataPack::ReadString(size_t *len) const | ||||
| 	return val.chars(); | ||||
| } | ||||
| 
 | ||||
| void *CDataPack::GetMemory() const | ||||
| { | ||||
| 	return nullptr; | ||||
| } | ||||
| 
 | ||||
| void *CDataPack::ReadMemory(size_t *size) const | ||||
| { | ||||
| 	void *ptr = nullptr; | ||||
|  | ||||
| @ -32,7 +32,7 @@ | ||||
| #ifndef _INCLUDE_SOURCEMOD_CDATAPACK_H_ | ||||
| #define _INCLUDE_SOURCEMOD_CDATAPACK_H_ | ||||
| 
 | ||||
| #include <IDataPack.h> | ||||
| #include <ISourceMod.h> | ||||
| #include <amtl/am-vector.h> | ||||
| #include <amtl/am-string.h> | ||||
| 
 | ||||
| @ -46,39 +46,137 @@ enum CDataPackType { | ||||
| 	Function | ||||
| }; | ||||
| 
 | ||||
| class CDataPack : public IDataPack | ||||
| class CDataPack | ||||
| { | ||||
| public: | ||||
| 	CDataPack(); | ||||
| 	~CDataPack(); | ||||
| 
 | ||||
|     static IDataPack *New(); | ||||
|     static void Free(IDataPack *pack); | ||||
| public: //IDataReader
 | ||||
|     static CDataPack *New(); | ||||
|     static void Free(CDataPack *pack); | ||||
| 
 | ||||
| public: // Originally IDataReader
 | ||||
| 	/**
 | ||||
| 	 * @brief Resets the position in the data stream to the beginning. | ||||
| 	 */ | ||||
| 	void Reset() const; | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Retrieves the current stream position. | ||||
| 	 * | ||||
| 	 * @return			Index into the stream. | ||||
| 	 */ | ||||
| 	size_t GetPosition() const; | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Sets the current stream position. | ||||
| 	 * | ||||
| 	 * @param pos		Index to set the stream at. | ||||
| 	 * @return			True if succeeded, false if out of bounds. | ||||
| 	 */ | ||||
| 	bool SetPosition(size_t pos) const; | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Reads one cell from the data stream. | ||||
| 	 * | ||||
| 	 * @return			A cell read from the current position. | ||||
| 	 */ | ||||
| 	cell_t ReadCell() const; | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Reads one float from the data stream. | ||||
| 	 * | ||||
| 	 * @return			A float read from the current position. | ||||
| 	 */ | ||||
| 	float ReadFloat() const; | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Returns whether or not a specified number of bytes from the current stream | ||||
| 	 *  position to the end can be read. | ||||
| 	 * | ||||
| 	 * @param bytes		Number of bytes to simulate reading. | ||||
| 	 * @return			True if can be read, false otherwise. | ||||
| 	 */ | ||||
| 	bool IsReadable(size_t bytes = 0) const; | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Reads a string from the data stream. | ||||
| 	 * | ||||
| 	 * @param len		Optional pointer to store the string length. | ||||
| 	 * @return			Pointer to the string, or NULL if out of bounds. | ||||
| 	 */ | ||||
| 	const char *ReadString(size_t *len) const; | ||||
| 	void *GetMemory() const; | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Reads the current position as a generic data type. | ||||
| 	 * | ||||
| 	 * @param size		Optional pointer to store the size of the data type. | ||||
| 	 * @return			Pointer to the data, or NULL if out of bounds. | ||||
| 	 */ | ||||
| 	void *ReadMemory(size_t *size) const; | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Reads a function pointer from the data stream. | ||||
| 	 * | ||||
| 	 * @return			A function pointer read from the current position. | ||||
| 	 */ | ||||
| 	cell_t ReadFunction() const; | ||||
| public: //IDataPack
 | ||||
| 
 | ||||
| public: // Originally IDataPack
 | ||||
| 	/**
 | ||||
| 	 * @brief Resets the used size of the stream back to zero. | ||||
| 	 */ | ||||
| 	void ResetSize(); | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Packs one cell into the data stream. | ||||
| 	 * | ||||
| 	 * @param cell		Cell value to write. | ||||
| 	 */ | ||||
| 	void PackCell(cell_t cell); | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Packs one float into the data stream. | ||||
| 	 * | ||||
| 	 * @param val		Float value to write. | ||||
| 	 */ | ||||
| 	void PackFloat(float val); | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Packs one string into the data stream. | ||||
| 	 * The length is recorded as well for buffer overrun protection. | ||||
| 	 * | ||||
| 	 * @param string	String to write. | ||||
| 	 */ | ||||
| 	void PackString(const char *string); | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Creates a generic block of memory in the stream. | ||||
| 	 * | ||||
| 	 * Note that the pointer it returns can be invalidated on further | ||||
| 	 * writing, since the stream size may grow.  You may need to double back | ||||
| 	 * and fetch the pointer again. | ||||
| 	 * | ||||
| 	 * @param size		Size of the memory to create in the stream. | ||||
| 	 * @param addr		Optional pointer to store the relocated memory address. | ||||
| 	 * @return			Current position of the stream beforehand. | ||||
| 	 */ | ||||
| 	size_t CreateMemory(size_t size, void **addr); | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Packs one function pointer into the data stream. | ||||
| 	 * | ||||
| 	 * @param function	The function pointer to write. | ||||
| 	 */ | ||||
| 	void PackFunction(cell_t function); | ||||
| 
 | ||||
| public: | ||||
| 	void Initialize(); | ||||
| 	inline size_t GetCapacity() const { return this->elements.length(); }; | ||||
| 	inline CDataPackType GetCurrentType(void) const { return this->elements[this->position].type; }; | ||||
| 	bool RemoveItem(size_t pos = -1); | ||||
| private: | ||||
| 
 | ||||
| private: | ||||
| 	typedef union { | ||||
| 		cell_t cval; | ||||
| 		float fval; | ||||
|  | ||||
| @ -55,7 +55,6 @@ | ||||
| #include "sprintf.h" | ||||
| #include "LibrarySys.h" | ||||
| #include "RootConsoleMenu.h" | ||||
| #include "CDataPack.h" | ||||
| #include "CellArray.h" | ||||
| #include <bridge/include/BridgeAPI.h> | ||||
| #include <bridge/include/IProviderCallbacks.h> | ||||
| @ -167,8 +166,6 @@ static sm_logic_t logic = | ||||
| 	GenerateError, | ||||
| 	AddNatives, | ||||
| 	RegisterProfiler, | ||||
| 	CDataPack::New, | ||||
| 	CDataPack::Free, | ||||
| 	CellArray::New, | ||||
| 	CellArray::Free, | ||||
| 	FromPseudoAddress, | ||||
|  | ||||
| @ -73,7 +73,7 @@ public: | ||||
| 
 | ||||
| static cell_t smn_CreateDataPack(IPluginContext *pContext, const cell_t *params) | ||||
| { | ||||
| 	CDataPack *pDataPack = static_cast<CDataPack *>(CDataPack::New()); | ||||
| 	CDataPack *pDataPack = CDataPack::New(); | ||||
| 
 | ||||
| 	if (!pDataPack) | ||||
| 	{ | ||||
|  | ||||
| @ -617,14 +617,14 @@ unsigned int SourceModBase::GetGlobalTarget() const | ||||
| 	return m_target; | ||||
| } | ||||
| 
 | ||||
| IDataPack *SourceModBase::CreateDataPack() | ||||
| void *SourceModBase::CreateDataPack() | ||||
| { | ||||
| 	return nullptr; | ||||
| } | ||||
| 
 | ||||
| void SourceModBase::FreeDataPack(IDataPack *pack) | ||||
| void SourceModBase::FreeDataPack(void *pack) | ||||
| { | ||||
| 	logicore.FreeDataPack(pack); | ||||
| 	return; | ||||
| } | ||||
| 
 | ||||
| Handle_t SourceModBase::GetDataPackHandleType(bool readonly) | ||||
|  | ||||
| @ -113,8 +113,8 @@ public: // ISourceMod | ||||
| 	void LogMessage(IExtension *pExt, const char *format, ...); | ||||
| 	void LogError(IExtension *pExt, const char *format, ...); | ||||
| 	size_t FormatString(char *buffer, size_t maxlength, IPluginContext *pContext, const cell_t *params, unsigned int param); | ||||
| 	IDataPack *CreateDataPack(); | ||||
| 	void FreeDataPack(IDataPack *pack); | ||||
| 	void *CreateDataPack(); | ||||
| 	void FreeDataPack(void *pack); | ||||
| 	HandleType_t GetDataPackHandleType(bool readonly=false); | ||||
| 	KeyValues *ReadKeyValuesHandle(Handle_t hndl, HandleError *err=NULL, bool root=false); | ||||
| 	const char *GetGameFolderName() const; | ||||
|  | ||||
| @ -1,181 +0,0 @@ | ||||
| /**
 | ||||
|  * vim: set ts=4 : | ||||
|  * ============================================================================= | ||||
|  * SourceMod | ||||
|  * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved. | ||||
|  * ============================================================================= | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it under | ||||
|  * the terms of the GNU General Public License, version 3.0, as published by the | ||||
|  * Free Software Foundation. | ||||
|  *  | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||||
|  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more | ||||
|  * details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License along with | ||||
|  * this program.  If not, see <http://www.gnu.org/licenses/>.
 | ||||
|  * | ||||
|  * As a special exception, AlliedModders LLC gives you permission to link the | ||||
|  * code of this program (as well as its derivative works) to "Half-Life 2," the | ||||
|  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software | ||||
|  * by the Valve Corporation.  You must obey the GNU General Public License in | ||||
|  * all respects for all other code used.  Additionally, AlliedModders LLC grants | ||||
|  * this exception to all derivative works.  AlliedModders LLC defines further | ||||
|  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), | ||||
|  * or <http://www.sourcemod.net/license.php>.
 | ||||
|  * | ||||
|  * Version: $Id$ | ||||
|  */ | ||||
| 
 | ||||
| #ifndef _INCLUDE_SOURCEMOD_INTERFACE_DATAPACK_H_ | ||||
| #define _INCLUDE_SOURCEMOD_INTERFACE_DATAPACK_H_ | ||||
| 
 | ||||
| #include <sp_vm_api.h> | ||||
| 
 | ||||
| /**
 | ||||
|  * @file IDataPack.h | ||||
|  * @brief Contains functions for packing data abstractly to/from plugins.  The wrappers | ||||
|  * for creating these are contained in ISourceMod.h | ||||
|  * @deprecated Deprecated. Does nothing. | ||||
|  */ | ||||
| 
 | ||||
| namespace SourceMod | ||||
| { | ||||
| 	/**
 | ||||
| 	 * @brief Specifies a data pack that can only be read. | ||||
| 	 */ | ||||
| 	class IDataReader | ||||
| 	{ | ||||
| 	public: | ||||
| 		/**
 | ||||
| 		 * @brief Resets the position in the data stream to the beginning. | ||||
| 		 */ | ||||
| 		virtual void Reset() const =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Retrieves the current stream position. | ||||
| 		 * | ||||
| 		 * @return			Index into the stream. | ||||
| 		 */ | ||||
| 		virtual size_t GetPosition() const =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Sets the current stream position. | ||||
| 		 * | ||||
| 		 * @param pos		Index to set the stream at. | ||||
| 		 * @return			True if succeeded, false if out of bounds. | ||||
| 		 */ | ||||
| 		virtual bool SetPosition(size_t pos) const =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Reads one cell from the data stream. | ||||
| 		 * | ||||
| 		 * @return			A cell read from the current position. | ||||
| 		 */ | ||||
| 		virtual cell_t ReadCell() const =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Reads one float from the data stream. | ||||
| 		 * | ||||
| 		 * @return			A float read from the current position. | ||||
| 		 */ | ||||
| 		virtual float ReadFloat() const =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Returns whether or not a specified number of bytes from the current stream | ||||
| 		 *  position to the end can be read. | ||||
| 		 *  | ||||
| 		 * @param bytes		Number of bytes to simulate reading. | ||||
| 		 * @return			True if can be read, false otherwise. | ||||
| 		 */ | ||||
| 		virtual bool IsReadable(size_t bytes) const =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Reads a string from the data stream. | ||||
| 		 * | ||||
| 		 * @param len		Optional pointer to store the string length. | ||||
| 		 * @return			Pointer to the string, or NULL if out of bounds. | ||||
| 		 */ | ||||
| 		virtual const char *ReadString(size_t *len) const =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Reads the current position as a generic address. | ||||
| 		 * | ||||
| 		 * @return			Pointer to the memory. | ||||
| 		 */ | ||||
| 		virtual void *GetMemory() const =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		* @brief Reads the current position as a generic data type. | ||||
| 		* | ||||
| 		* @param size		Optional pointer to store the size of the data type. | ||||
| 		* @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; | ||||
| 	}; | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * @brief Specifies a data pack that can only be written. | ||||
| 	 */ | ||||
| 	class IDataPack : public IDataReader | ||||
| 	{ | ||||
| 	public: | ||||
| 		/**
 | ||||
| 		* @brief Resets the used size of the stream back to zero. | ||||
| 		*/ | ||||
| 		virtual void ResetSize() =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Packs one cell into the data stream. | ||||
| 		 * | ||||
| 		 * @param cell		Cell value to write. | ||||
| 		 */ | ||||
| 		virtual void PackCell(cell_t cell) =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Packs one float into the data stream. | ||||
| 		 * | ||||
| 		 * @param val		Float value to write. | ||||
| 		 */ | ||||
| 		virtual void PackFloat(float val) =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Packs one string into the data stream. | ||||
| 		 * The length is recorded as well for buffer overrun protection. | ||||
| 		 * | ||||
| 		 * @param string	String to write. | ||||
| 		 */ | ||||
| 		virtual void PackString(const char *string) =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Creates a generic block of memory in the stream. | ||||
| 		 * | ||||
| 		 * Note that the pointer it returns can be invalidated on further | ||||
| 		 * writing, since the stream size may grow.  You may need to double back | ||||
| 		 * and fetch the pointer again. | ||||
| 		 * | ||||
| 		 * @param size		Size of the memory to create in the stream. | ||||
| 		 * @param addr		Optional pointer to store the relocated memory address. | ||||
| 		 * @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; | ||||
| 	}; | ||||
| } | ||||
| 
 | ||||
| #endif //_INCLUDE_SOURCEMOD_INTERFACE_DATAPACK_H_
 | ||||
| @ -39,7 +39,6 @@ | ||||
| 
 | ||||
| #include <IHandleSys.h> | ||||
| #include <sp_vm_api.h> | ||||
| #include <IDataPack.h> | ||||
| #include <time.h> | ||||
| 
 | ||||
| #define SMINTERFACE_SOURCEMOD_NAME		"ISourceMod" | ||||
| @ -163,18 +162,18 @@ namespace SourceMod | ||||
| 									unsigned int param) =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Creates a data pack object. | ||||
| 		 * @brief Not implemented, do not use. | ||||
| 		 * | ||||
| 		 * @return			A new IDataPack object. | ||||
| 		 * @return nullptr | ||||
| 		 */ | ||||
| 		virtual IDataPack *CreateDataPack() =0; | ||||
| 		virtual void *CreateDataPack() =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Releases a data pack's resources so it can be re-used. | ||||
| 		 * @brief Not implemented, do not use. | ||||
| 		 * | ||||
| 		 * @param pack		An IDataPack object to release. | ||||
| 		 * @param pack	Ignored | ||||
| 		 */ | ||||
| 		virtual void FreeDataPack(IDataPack *pack) =0; | ||||
| 		virtual void FreeDataPack(void *pack) =0; | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * @brief Not implemented, do not use. | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user