Added global class initialization automation
Finalized basics of plugin loading Began redoing how dependencies will be tracked Renamed some bad names Finished some stuff in ForwardSys --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40216
This commit is contained in:
@@ -8,16 +8,12 @@ namespace SourceMod
|
||||
{
|
||||
class IModuleInterface;
|
||||
|
||||
class IModule : public IUnloadableParent
|
||||
class IModule
|
||||
{
|
||||
public:
|
||||
virtual UnloadableParentType GetParentType()
|
||||
{
|
||||
return ParentType_Module;
|
||||
}
|
||||
public:
|
||||
virtual IModuleInterface *GetModuleInfo() =0;
|
||||
virtual const char *GetFilename() =0;
|
||||
virtual IdentityToken_t GetIdentityToken() =0;
|
||||
};
|
||||
|
||||
class IModuleInterface
|
||||
@@ -27,13 +23,19 @@ namespace SourceMod
|
||||
* @brief Called when the module is loaded.
|
||||
*
|
||||
* @param me Pointer back to module.
|
||||
* @param token Identity token handle.
|
||||
* @param sys Pointer to interface sharing system of SourceMod.
|
||||
* @param error Error buffer to print back to, if any.
|
||||
* @param err_max Maximum size of error buffer.
|
||||
* @param late If this module was loaded "late" (i.e. manually).
|
||||
* @return True if load should continue, false otherwise.
|
||||
*/
|
||||
virtual bool OnModuleLoad(IModule *me, IShareSys *sys, char *error, size_t err_max, bool late) =0;
|
||||
virtual bool OnModuleLoad(IModule *me,
|
||||
IdentityToken_t token,
|
||||
IShareSys *sys,
|
||||
char *error,
|
||||
size_t err_max,
|
||||
bool late) =0;
|
||||
|
||||
/**
|
||||
* @brief Called when the module is unloaded.
|
||||
@@ -51,7 +53,6 @@ namespace SourceMod
|
||||
* @param pause True if pausing, false if unpausing.
|
||||
*/
|
||||
virtual void OnPauseChange(bool pause) =0;
|
||||
|
||||
public:
|
||||
virtual const char *GetModuleName() =0;
|
||||
virtual const char *GetModuleVersion() =0;
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
#define SM_FUNCFLAG_COPYBACK (1<<0) /* Copy an array/reference back after call */
|
||||
#define SM_PARAM_COPYBACK (1<<0) /* Copy an array/reference back after call */
|
||||
|
||||
#define SP_STRING_UTF8 (1<<0) /* String should be UTF-8 handled */
|
||||
#define SP_STRING_COPY (1<<1) /* String should be copied into the plugin */
|
||||
#define SM_PARAM_STRING_UTF8 (1<<0) /* String should be UTF-8 handled */
|
||||
#define SM_PARAM_STRING_COPY (1<<1) /* String should be copied into the plugin */
|
||||
|
||||
/**
|
||||
* @brief Represents what a function needs to implement in order to be callable.
|
||||
|
||||
@@ -25,15 +25,19 @@ namespace SourceMod
|
||||
const char *url;
|
||||
} sm_plugininfo_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Describes the usability status of a plugin.
|
||||
*/
|
||||
enum PluginStatus
|
||||
{
|
||||
Plugin_Running=0, /* Plugin is running */
|
||||
Plugin_Loaded, /* Plugin is loaded but not initialized */
|
||||
Plugin_Paused, /* Plugin is paused */
|
||||
/* All states below are unexecutable */
|
||||
Plugin_Paused, /* Plugin is loaded but paused */
|
||||
/* All states below do not have all natives */
|
||||
Plugin_Loaded, /* Plugin has passed loading and can be finalized */
|
||||
Plugin_Error, /* Plugin has a blocking error */
|
||||
Plugin_Created, /* Plugin is created but not initialized */
|
||||
Plugin_Uncompiled, /* Plugin is not yet compiled by the JIT */
|
||||
Plugin_BadLoad, /* Plugin failed to load */
|
||||
};
|
||||
|
||||
+13
-67
@@ -1,8 +1,11 @@
|
||||
#ifndef _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
|
||||
#define _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
|
||||
|
||||
#include <sp_vm_types.h>
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
typedef unsigned int IdentityToken_t;
|
||||
/**
|
||||
* @brief Defines the base functionality required by a shared interface.
|
||||
*/
|
||||
@@ -37,48 +40,6 @@ namespace SourceMod
|
||||
}
|
||||
};
|
||||
|
||||
enum UnloadableParentType
|
||||
{
|
||||
ParentType_Module,
|
||||
ParentType_Plugin
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Denotes a top-level unloadable object.
|
||||
*/
|
||||
class IUnloadableParent
|
||||
{
|
||||
public:
|
||||
virtual UnloadableParentType GetParentType() =0;
|
||||
|
||||
virtual void *GetParentToken() =0;
|
||||
|
||||
/**
|
||||
* @brief Called when an interface this object has requested is removed.
|
||||
*
|
||||
* @param pIface Interface being removed.
|
||||
*/
|
||||
virtual void OnInterfaceUnlink(SMInterface *pIface) =0;
|
||||
protected:
|
||||
void *m_parent_token;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Listens for unlinked objects.
|
||||
*/
|
||||
class IUnlinkListener
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Called when a parent object is unloaded.
|
||||
*
|
||||
* @param parent The parent object which is dying.
|
||||
*/
|
||||
virtual void OnParentUnlink(IUnloadableParent *parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Tracks dependencies and fires dependency listeners.
|
||||
*/
|
||||
@@ -89,9 +50,9 @@ namespace SourceMod
|
||||
* @brief Adds an interface to the global interface system
|
||||
*
|
||||
* @param iface Interface pointer (must be unique).
|
||||
* @param parent Parent unloadable token given to the module/interface.
|
||||
* @param token Parent token of the module/interface.
|
||||
*/
|
||||
virtual bool AddInterface(SMInterface *iface, IUnloadableParent *parent) =0;
|
||||
virtual bool AddInterface(SMInterface *iface, IdentityToken_t token) =0;
|
||||
|
||||
/**
|
||||
* @brief Requests an interface from the global interface system.
|
||||
@@ -99,36 +60,21 @@ namespace SourceMod
|
||||
*
|
||||
* @param iface_name Interface name.
|
||||
* @param iface_vers Interface version to attempt to match.
|
||||
* @param me Object requesting this interface, in order to track dependencies.
|
||||
* @param token Object requesting this interface, in order to track dependencies.
|
||||
* @param pIface Pointer to store the return value in.
|
||||
*/
|
||||
virtual bool RequestInterface(const char *iface_name,
|
||||
unsigned int iface_vers,
|
||||
IUnloadableParent *me,
|
||||
unsigned int iface_vers,
|
||||
IdentityToken_t token,
|
||||
void **pIface) =0;
|
||||
|
||||
/**
|
||||
* @brief Unloads an interface.
|
||||
*
|
||||
* @param iface Interface pointer.
|
||||
* @param parent Security token, trivial measure to prevent accidental unloads.
|
||||
* This token must match the one used with AddInterface().
|
||||
* @brief Adds a list of natives to the global native pool.
|
||||
*
|
||||
* @param token Identity token of parent object.
|
||||
* @param natives Array of natives to add, NULL terminated.
|
||||
*/
|
||||
virtual void RemoveInterface(SMInterface *iface, IUnloadableParent *parent) =0;
|
||||
|
||||
/**
|
||||
* @brief Adds an unlink listener.
|
||||
*
|
||||
* @param pListener Listener pointer.
|
||||
*/
|
||||
virtual void AddUnlinkListener(IUnlinkListener *pListener) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes an unlink listener.
|
||||
*
|
||||
* @param pListener Listener pointer.
|
||||
*/
|
||||
virtual void RemoveUnlinkListener(IUnlinkListener *pListener) =0;
|
||||
virtual void AddNatives(IdentityToken_t token, const sp_nativeinfo_t *natives[]) =0;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user