initial import of plugin loading code
authorDavid Anderson <dvander@alliedmods.net>
Fri Nov 10 07:49:38 2006 +0000 (2006-11-10)
changeset 172d8a8186eccbf
parent 171 067b18e15149
child 173 662fc7f7144b
initial import of plugin loading code
little fixes to API
temporarily commented dependency iface until final
core/interfaces/IPluginSys.h
core/msvc8/sourcemod_mm.vcproj
core/vm/sp_vm_engine.cpp
plugins/include/sourcemod.inc
plugins/test.sma
sourcepawn/include/sp_vm_api.h
     1.1 --- a/core/interfaces/IPluginSys.h	Fri Nov 10 06:07:41 2006 +0000
     1.2 +++ b/core/interfaces/IPluginSys.h	Fri Nov 10 07:49:38 2006 +0000
     1.3 @@ -2,7 +2,7 @@
     1.4  #define _INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
     1.5  
     1.6  #include <IShareSys.h>
     1.7 -#include <sp_vm_context.h>
     1.8 +#include <sp_vm_api.h>
     1.9  
    1.10  #define SMINTERFACE_PLUGINMANAGER_NAME		"IPluginManager"
    1.11  #define SMINTERFACE_PLUGINMANAGER_VERSION	1
    1.12 @@ -27,6 +27,7 @@
    1.13  	enum PluginStatus
    1.14  	{
    1.15  		Plugin_Running=0,		/* Plugin is running */
    1.16 +		Plugin_Loaded,			/* Plugin is loaded but not initialized */
    1.17  		Plugin_Paused,			/* Plugin is paused */
    1.18  		Plugin_Stopped,			/* Plugin is paused for map changes, too */
    1.19  		Plugin_Error,			/* Plugin has a blocking error */
    1.20 @@ -46,59 +47,66 @@
    1.21  	/**
    1.22  	 * @brief Encapsulates a run-time plugin as maintained by SourceMod.
    1.23  	 */
    1.24 -	class IPlugin : public IUnloadableParent
    1.25 +	class IPlugin /*: public IUnloadableParent*/
    1.26  	{
    1.27  	public:
    1.28 -		UnloadableParentType GetParentType()
    1.29 +		/*UnloadableParentType GetParentType()
    1.30  		{
    1.31  			return ParentType_Module;
    1.32 -		}
    1.33 +		}*/
    1.34  	public:
    1.35  		/**
    1.36  		 * @brief Returns the lifetime of a plugin.
    1.37  		 */
    1.38 -		virtual PluginLifetime GetLifetime() =0;
    1.39 +		virtual PluginLifetime GetLifetime() const =0;
    1.40  
    1.41  		/**
    1.42  		 * @brief Returns the current API context being used in the plugin.
    1.43  		 *
    1.44  		 * @return	Pointer to an IPluginContext, or NULL if not loaded.
    1.45  		 */
    1.46 -		virtual SourcePawn::IPluginContext *GetBaseContext() =0;
    1.47 +		virtual SourcePawn::IPluginContext *GetBaseContext() const =0;
    1.48  
    1.49  		/**
    1.50  		 * @brief Returns the context structure being used in the plugin.
    1.51  		 *
    1.52 -		 * @brief	Pointer to an sp_context_t, or NULL if not loaded.
    1.53 +		 * @return	Pointer to an sp_context_t, or NULL if not loaded.
    1.54  		 */
    1.55 -		virtual sp_context_t *GetContext() =0;
    1.56 +		virtual sp_context_t *GetContext() const =0;
    1.57  
    1.58  		/**
    1.59 -		 * @brief Returns information about the plugin.
    1.60 +		 * @brief Returns the plugin file structure.
    1.61  		 *
    1.62 -		 * @brief	Pointer to an sm_plugininfo_t, or NULL if not loaded.
    1.63 +		 * @return	Pointer to an sp_plugin_t, or NULL if not loaded.
    1.64  		 */
    1.65 -		virtual sm_plugininfo_t *GetPublicInfo() =0;
    1.66 +		virtual const sp_plugin_t *GetPluginStructure() const =0;
    1.67 +
    1.68 +		/**
    1.69 +		 * @brief Returns information about the plugin by reference.
    1.70 +		 *
    1.71 +		 * @return			Pointer to a sm_plugininfo_t object, NULL if plugin is not loaded.
    1.72 +		 */
    1.73 +		virtual const sm_plugininfo_t *GetPublicInfo() const =0;
    1.74  
    1.75  		/**
    1.76  		 * @brief Returns the plugin filename (relative to plugins dir).
    1.77  		 */
    1.78 -		virtual const char *GetFilename() =0;
    1.79 +		virtual const char *GetFilename() const =0;
    1.80  
    1.81  		/**
    1.82  		 * @brief Returns true if a plugin is in debug mode, false otherwise.
    1.83  		 */
    1.84 -		virtual bool IsDebugging() =0;
    1.85 +		virtual bool IsDebugging() const =0;
    1.86  
    1.87  		/**
    1.88  		 * @brief Returns the plugin status.
    1.89  		 */
    1.90 -		virtual PluginStatus GetStatus() =0;
    1.91 +		virtual PluginStatus GetStatus() const =0;
    1.92  		
    1.93  		/**
    1.94  		 * @brief Sets whether the plugin is paused or not.
    1.95  		 *
    1.96 -		 * @return			True on successful pause, false otherwise.
    1.97 +		 * @return			True on successful state change, false otherwise.
    1.98  		 */
    1.99  		virtual bool SetPauseState(bool paused) =0;
   1.100  
   1.101 @@ -110,12 +118,12 @@
   1.102  		/**
   1.103  		 * @brief Returns whether the plugin is locked from being updated on mapchange.
   1.104  		 */
   1.105 -		virtual bool GetLockForUpdates() =0;
   1.106 +		virtual bool GetLockForUpdates() const =0;
   1.107  
   1.108  		/**
   1.109  		 * @brief Returns the unique serial number of a plugin.
   1.110  		 */
   1.111 -		virtual unsigned int GetSerial() =0;
   1.112 +		virtual unsigned int GetSerial() const =0;
   1.113  	};
   1.114  
   1.115  
   1.116 @@ -125,7 +133,7 @@
   1.117  	class IPluginIterator
   1.118  	{
   1.119  	public:
   1.120 -		virtual void ~IPluginIterator()
   1.121 +		virtual ~IPluginIterator()
   1.122  		{
   1.123  		};
   1.124  	public:
     2.1 --- a/core/msvc8/sourcemod_mm.vcproj	Fri Nov 10 06:07:41 2006 +0000
     2.2 +++ b/core/msvc8/sourcemod_mm.vcproj	Fri Nov 10 07:49:38 2006 +0000
     2.3 @@ -255,6 +255,10 @@
     2.4  					RelativePath="..\systems\LibrarySys.h"
     2.5  					>
     2.6  				</File>
     2.7 +				<File
     2.8 +					RelativePath="..\systems\PluginSys.h"
     2.9 +					>
    2.10 +				</File>
    2.11  			</Filter>
    2.12  			<Filter
    2.13  				Name="Source Files"
    2.14 @@ -263,6 +267,10 @@
    2.15  					RelativePath="..\systems\LibrarySys.cpp"
    2.16  					>
    2.17  				</File>
    2.18 +				<File
    2.19 +					RelativePath="..\systems\PluginSys.cpp"
    2.20 +					>
    2.21 +				</File>
    2.22  			</Filter>
    2.23  		</Filter>
    2.24  		<Filter
     3.1 --- a/core/vm/sp_vm_engine.cpp	Fri Nov 10 06:07:41 2006 +0000
     3.2 +++ b/core/vm/sp_vm_engine.cpp	Fri Nov 10 07:49:38 2006 +0000
     3.3 @@ -56,11 +56,6 @@
     3.4  
     3.5  void SourcePawnEngine::FreeBaseContext(IPluginContext *ctx)
     3.6  {
     3.7 -	sp_context_t *_ctx = ctx->GetContext();
     3.8 -	IVirtualMachine *vm = ctx->GetVirtualMachine();
     3.9 -	
    3.10 -	vm->FreeContext(_ctx);
    3.11 -
    3.12  	delete ctx;
    3.13  }
    3.14  
     4.1 --- a/plugins/include/sourcemod.inc	Fri Nov 10 06:07:41 2006 +0000
     4.2 +++ b/plugins/include/sourcemod.inc	Fri Nov 10 07:49:38 2006 +0000
     4.3 @@ -52,7 +52,7 @@
     4.4   *
     4.5   * @noreturn
     4.6   */
     4.7 -forward OnPluginRequirements();
     4.8 +forward OnCreatePlugin();
     4.9  
    4.10  /**
    4.11   * Called when the plugin is about to be unloaded.
     5.1 --- a/plugins/test.sma	Fri Nov 10 06:07:41 2006 +0000
     5.2 +++ b/plugins/test.sma	Fri Nov 10 07:49:38 2006 +0000
     5.3 @@ -6,7 +6,7 @@
     5.4  	author = "BAILOPAN",
     5.5  	description = "Tests Stuff",
     5.6  	version = "1.0.0.0",
     5.7 -	url = "http://www.sourceomd.net/"
     5.8 +	url = "http://www.sourcemod.net/"
     5.9  }
    5.10  
    5.11  public OnPluginInit()
     6.1 --- a/sourcepawn/include/sp_vm_api.h	Fri Nov 10 06:07:41 2006 +0000
     6.2 +++ b/sourcepawn/include/sp_vm_api.h	Fri Nov 10 07:49:38 2006 +0000
     6.3 @@ -343,7 +343,7 @@
     6.4  		virtual IPluginContext *CreateBaseContext(sp_context_t *ctx) =0;
     6.5  
     6.6  		/** 
     6.7 -		 * Frees a context.
     6.8 +		 * Frees a base context.  Does not free the sp_context_t it holds.
     6.9  		 *
    6.10  		 * @param ctx		Context pointer to free.
    6.11  		 */