1.1 --- a/core/CTextParsers.h Fri Jan 19 05:25:43 2007 +0000
1.2 +++ b/core/CTextParsers.h Fri Jan 19 05:33:04 2007 +0000
1.3 @@ -1,7 +1,7 @@
1.4 #ifndef _INCLUDE_SOURCEMOD_TEXTPARSERS_H_
1.5 #define _INCLUDE_SOURCEMOD_TEXTPARSERS_H_
1.6
1.7 -#include "interfaces/ITextParsers.h"
1.8 +#include <ITextParsers.h>
1.9
1.10 using namespace SourceMod;
1.11
2.1 --- a/core/interfaces/IExtensionSys.h Fri Jan 19 05:25:43 2007 +0000
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,217 +0,0 @@
2.4 -#ifndef _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
2.5 -#define _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
2.6 -
2.7 -#include <IShareSys.h>
2.8 -#include <ILibrarySys.h>
2.9 -
2.10 -namespace SourceMod
2.11 -{
2.12 - class IExtensionInterface;
2.13 - typedef void * ITERATOR;
2.14 -
2.15 - /**
2.16 - * @brief Encapsulates an IExtension.
2.17 - */
2.18 - class IExtension
2.19 - {
2.20 - public:
2.21 - /**
2.22 - * @brief Returns whether or not the extension is properly loaded.
2.23 - */
2.24 - virtual bool IsLoaded() =0;
2.25 -
2.26 - /**
2.27 - * @brief Returns the extension's API interface
2.28 - *
2.29 - * @return An IExtensionInterface pointer.
2.30 - */
2.31 - virtual IExtensionInterface *GetAPI() =0;
2.32 -
2.33 - /**
2.34 - * @brief Returns the filename of the extension, relative to the
2.35 - * extension folder.
2.36 - *
2.37 - * @return A string containing the extension file name.
2.38 - */
2.39 - virtual const char *GetFilename() =0;
2.40 -
2.41 - /**
2.42 - * @brief Returns the extension's identity token.
2.43 - *
2.44 - * @return An IdentityToken_t pointer.
2.45 - */
2.46 - virtual IdentityToken_t *GetIdentity() =0;
2.47 -
2.48 - /**
2.49 - * @brief Retrieves the extension dependency list for this extension.
2.50 - *
2.51 - * @param pOwner Optional pointer to store the first interface's owner.
2.52 - * @param pInterface Optional pointer to store the first interface.
2.53 - * @return An ITERATOR pointer for the results, or NULL if no results at all.
2.54 - */
2.55 - virtual ITERATOR *FindFirstDependency(IExtension **pOwner, SMInterface **pInterface) =0;
2.56 -
2.57 - /**
2.58 - * @brief Finds the next dependency in the dependency list.
2.59 - *
2.60 - * @param iter Pointer to iterator from FindFirstDependency.
2.61 - * @param pOwner Optional pointer to store the interface's owner.
2.62 - * @param pInterface Optional pointer to store the interface.
2.63 - * @return True if there are more results after this, false otherwise.
2.64 - */
2.65 - virtual bool FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface) =0;
2.66 -
2.67 - /**
2.68 - * @brief Frees an ITERATOR handle from FindFirstDependency.
2.69 - *
2.70 - * @param iter Pointer to iterator to free.
2.71 - */
2.72 - virtual void FreeDependencyIterator(ITERATOR *iter) =0;
2.73 -
2.74 - /**
2.75 - * @brief Queries the extension to see its run state.
2.76 - *
2.77 - * @param error Error buffer (may be NULL).
2.78 - * @param maxlength Maximum length of buffer.
2.79 - * @return True if extension is okay, false if not okay.
2.80 - */
2.81 - virtual bool IsRunning(char *error, size_t maxlength) =0;
2.82 - };
2.83 -
2.84 - #define SMINTERFACE_EXTENSIONAPI_VERSION 1
2.85 -
2.86 - /**
2.87 - * @brief The interface an extension must expose.
2.88 - */
2.89 - class IExtensionInterface
2.90 - {
2.91 - public:
2.92 - virtual unsigned int GetExtensionVersion()
2.93 - {
2.94 - return SMINTERFACE_EXTENSIONAPI_VERSION;
2.95 - }
2.96 - public:
2.97 - /**
2.98 - * @brief Called when the extension is loaded.
2.99 - *
2.100 - * @param me Pointer back to extension.
2.101 - * @param sys Pointer to interface sharing system of SourceMod.
2.102 - * @param error Error buffer to print back to, if any.
2.103 - * @param err_max Maximum size of error buffer.
2.104 - * @param late If this extension was loaded "late" (i.e. manually).
2.105 - * @return True if load should continue, false otherwise.
2.106 - */
2.107 - virtual bool OnExtensionLoad(IExtension *me,
2.108 - IShareSys *sys,
2.109 - char *error,
2.110 - size_t err_max,
2.111 - bool late) =0;
2.112 -
2.113 - /**
2.114 - * @brief Called when the extension is about to be unloaded.
2.115 - */
2.116 - virtual void OnExtensionUnload() =0;
2.117 -
2.118 - /**
2.119 - * @brief Called when all extensions are loaded (loading cycle is done).
2.120 - * If loaded late, this will be called right after OnExtensionLoad().
2.121 - */
2.122 - virtual void OnExtensionsAllLoaded() =0;
2.123 -
2.124 - /**
2.125 - * @brief Called when your pause state is about to change.
2.126 - *
2.127 - * @param pause True if pausing, false if unpausing.
2.128 - */
2.129 - virtual void OnExtensionPauseChange(bool pause) =0;
2.130 -
2.131 - /**
2.132 - * @brief Asks the extension whether it's safe to remove an external interface it's using.
2.133 - * If it's not safe, return false, and the extension will be unloaded afterwards.
2.134 - * NOTE: It is important to also hook NotifyInterfaceDrop() in order to clean up resources.
2.135 - *
2.136 - * @param pInterface Pointer to interface being dropped.
2.137 - * @return True to continue, false to unload this extension afterwards.
2.138 - */
2.139 - virtual bool QueryInterfaceDrop(SMInterface *pInterface)
2.140 - {
2.141 - return true;
2.142 - }
2.143 -
2.144 - /**
2.145 - * @brief Notifies the extension that an external interface it uses is being removed.
2.146 - *
2.147 - * @param pInterface Pointer to interface being dropped.
2.148 - */
2.149 - virtual void NotifyInterfaceDrop(SMInterface *pInterface)
2.150 - {
2.151 - }
2.152 -
2.153 - /**
2.154 - * @brief Return false to tell Core that your extension should be considered unsable.
2.155 - *
2.156 - * @param error Error buffer.
2.157 - * @param maxlength Size of error buffer.
2.158 - * @return True on success, false otherwise.
2.159 - */
2.160 - virtual bool QueryRunning(char *error, size_t maxlength)
2.161 - {
2.162 - return true;
2.163 - }
2.164 - public:
2.165 - virtual bool IsMetamodExtension() =0;
2.166 - virtual const char *GetExtensionName() =0;
2.167 - virtual const char *GetExtensionURL() =0;
2.168 - virtual const char *GetExtensionTag() =0;
2.169 - virtual const char *GetExtensionAuthor() =0;
2.170 - virtual const char *GetExtensionVerString() =0;
2.171 - virtual const char *GetExtensionDescription() =0;
2.172 - virtual const char *GetExtensionDateString() =0;
2.173 - };
2.174 -
2.175 - #define SMINTERFACE_EXTENSIONMANAGER_NAME "IExtensionManager"
2.176 - #define SMINTERFACE_EXTENSIONMANAGER_VERSION 1
2.177 -
2.178 - enum ExtensionLifetime
2.179 - {
2.180 - ExtLifetime_Forever, //Extension will never be unloaded automatically
2.181 - ExtLifetime_Map, //Extension will be unloaded at the end of the map
2.182 - };
2.183 -
2.184 - class IExtensionManager : public SMInterface
2.185 - {
2.186 - public:
2.187 - virtual const char *GetInterfaceName()
2.188 - {
2.189 - return SMINTERFACE_EXTENSIONMANAGER_NAME;
2.190 - }
2.191 - virtual unsigned int GetInterfaceVersion()
2.192 - {
2.193 - return SMINTERFACE_EXTENSIONMANAGER_VERSION;
2.194 - }
2.195 - public:
2.196 - /**
2.197 - * @brief Loads a extension into the extension system.
2.198 - *
2.199 - * @param path Path to extension file, relative to the extensions folder.
2.200 - * @param lifetime Lifetime of the extension.
2.201 - * @param error Error buffer.
2.202 - * @param err_max Maximum error buffer length.
2.203 - * @return New IExtension on success, NULL on failure.
2.204 - */
2.205 - virtual IExtension *LoadExtension(const char *path,
2.206 - ExtensionLifetime lifetime,
2.207 - char *error,
2.208 - size_t err_max) =0;
2.209 -
2.210 - /**
2.211 - * @brief Attempts to unload a module.
2.212 - *
2.213 - * @param pExt IExtension pointer.
2.214 - * @return True if successful, false otherwise.
2.215 - */
2.216 - virtual bool UnloadExtension(IExtension *pExt) =0;
2.217 - };
2.218 -};
2.219 -
2.220 -#endif //_INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
3.1 --- a/core/interfaces/IForwardSys.h Fri Jan 19 05:25:43 2007 +0000
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,350 +0,0 @@
3.4 -#ifndef _INCLUDE_SOURCEMOD_FORWARDINTERFACE_H_
3.5 -#define _INCLUDE_SOURCEMOD_FORWARDINTERFACE_H_
3.6 -
3.7 -#include <IForwardSys.h>
3.8 -#include <IPluginSys.h>
3.9 -#include <IPluginFunction.h>
3.10 -
3.11 -#define SMINTERFACE_FORWARDMANAGER_NAME "IForwardManager"
3.12 -#define SMINTERFACE_FORWARDMANAGER_VERSION 1
3.13 -
3.14 -/**
3.15 - * There is some very important documentation at the bottom of this file.
3.16 - * Readers interested in knowing more about the forward system, scrolling down is a must!
3.17 - */
3.18 -
3.19 -namespace SourceMod
3.20 -{
3.21 - enum ResultType
3.22 - {
3.23 - Pl_Continue = 0, /* No result */
3.24 - Pl_Handled = 1, /* Result was handled, stop at the end */
3.25 - Pl_Stop = 2, /* Result was handled, stop now */
3.26 - };
3.27 -
3.28 - enum ExecType
3.29 - {
3.30 - ET_Ignore = 0, /* Ignore all return values, return 0 */
3.31 - ET_Single = 1, /* Only return the last exec, ignore all others */
3.32 - ET_Event = 2, /* Acts as an event with the ResultTypes above, no mid-Stops allowed, returns highest */
3.33 - ET_Hook = 3, /* Acts as a hook with the ResultTypes above, mid-Stops allowed, returns highest */
3.34 - ET_Custom = 4, /* Ignored or handled by an IForwardFilter */
3.35 - };
3.36 -
3.37 - class IForward;
3.38 -
3.39 - class IForwardFilter
3.40 - {
3.41 - public:
3.42 - /**
3.43 - * @brief Called when an error occurs executing a plugin.
3.44 - *
3.45 - * @param fwd IForward pointer.
3.46 - * @param func IPluginFunction pointer to the failed function.
3.47 - * @param err Error code.
3.48 - * @return True to handle, false to pass to global error reporter.
3.49 - */
3.50 - virtual bool OnErrorReport(IForward *fwd,
3.51 - IPluginFunction *func,
3.52 - int err)
3.53 - {
3.54 - return false;
3.55 - }
3.56 -
3.57 - /**
3.58 - * @brief Called after each function return during execution.
3.59 - * NOTE: Only used for ET_Custom.
3.60 - *
3.61 - * @param fwd IForward pointer.
3.62 - * @param func IPluginFunction pointer to the executed function.
3.63 - * @param retval Pointer to current return value (can be modified).
3.64 - * @return ResultType denoting the next action to take.
3.65 - */
3.66 - virtual ResultType OnFunctionReturn(IForward *fwd,
3.67 - IPluginFunction *func,
3.68 - cell_t *retval)
3.69 - {
3.70 - return Pl_Continue;
3.71 - }
3.72 -
3.73 - /**
3.74 - * @brief Called when execution begins.
3.75 - */
3.76 - virtual void OnExecuteBegin()
3.77 - {
3.78 - };
3.79 -
3.80 - /**
3.81 - * @brief Called when execution ends.
3.82 - *
3.83 - * @param final_ret Final return value (modifiable).
3.84 - * @param success Number of successful execs.
3.85 - * @param failed Number of failed execs.
3.86 - */
3.87 - virtual void OnExecuteEnd(cell_t *final_ret, unsigned int success, unsigned int failed)
3.88 - {
3.89 - }
3.90 - };
3.91 -
3.92 - /**
3.93 - * @brief Abstracts multiple function calling.
3.94 - *
3.95 - * NOTE: Parameters should be pushed in forward order, unlike
3.96 - * the virtual machine/IPluginContext order.
3.97 - * NOTE: Some functions are repeated in here because their
3.98 - * documentation differs from their IPluginFunction equivalents.
3.99 - * Missing are the Push functions, whose only doc change is that
3.100 - * they throw SP_ERROR_PARAM on type mismatches.
3.101 - */
3.102 - class IForward : public ICallable
3.103 - {
3.104 - public:
3.105 - virtual ~IForward()
3.106 - {
3.107 - }
3.108 - public:
3.109 - /**
3.110 - * @brief Returns the name of the forward.
3.111 - *
3.112 - * @return Forward name.
3.113 - */
3.114 - virtual const char *GetForwardName() =0;
3.115 -
3.116 - /**
3.117 - * @brief Returns the number of functions in this forward.
3.118 - *
3.119 - * @return Number of functions in forward.
3.120 - */
3.121 - virtual unsigned int GetFunctionCount() =0;
3.122 -
3.123 - /**
3.124 - * @brief Returns the method of multi-calling this forward has.
3.125 - *
3.126 - * @return ExecType of the forward.
3.127 - */
3.128 - virtual ExecType GetExecType() =0;
3.129 -
3.130 - /**
3.131 - * @brief Executes the forward.
3.132 - *
3.133 - * @param result Pointer to store result in.
3.134 - * @param filter Optional pointer to an IForwardFilter.
3.135 - * @return Error code, if any.
3.136 - */
3.137 - virtual int Execute(cell_t *result, IForwardFilter *filter=NULL) =0;
3.138 -
3.139 - /**
3.140 - * @brief Pushes an array of cells onto the current call. Different rules than ICallable.
3.141 - * NOTE: On Execute, the pointer passed will be modified according to the copyback rule.
3.142 - *
3.143 - * @param inarray Array to copy. Cannot be NULL, unlike ICallable's version.
3.144 - * @param cells Number of cells to allocate and optionally read from the input array.
3.145 - * @param phys_addr Unused. If a value is passed, it will be filled with NULL.
3.146 - * @param flags Whether or not changes should be copied back to the input array.
3.147 - * @return Error code, if any.
3.148 - */
3.149 - virtual int PushArray(cell_t *inarray,
3.150 - unsigned int cells,
3.151 - cell_t **phys_addr,
3.152 - int flags=0) =0;
3.153 - };
3.154 -
3.155 -
3.156 - class IChangeableForward : public IForward
3.157 - {
3.158 - public:
3.159 - /**
3.160 - * @brief Removes a function from the call list.
3.161 - * NOTE: Only removes one instance.
3.162 - *
3.163 - * @param func Function to remove.
3.164 - * @return Whether or not the function was removed.
3.165 - */
3.166 - virtual bool RemoveFunction(IPluginFunction *func) =0;
3.167 -
3.168 - /**
3.169 - * @brief Removes all instances of a plugin from the call list.
3.170 - *
3.171 - * @param plugin Plugin to remove instances of.
3.172 - * @return Number of functions removed therein.
3.173 - */
3.174 - virtual unsigned int RemoveFunctionsOfPlugin(IPlugin *plugin) =0;
3.175 -
3.176 - /**
3.177 - * @brief Adds a function to the call list.
3.178 - * NOTE: Cannot be used during an incompleted call.
3.179 - * NOTE: If used during a call, function is temporarily queued until calls are over.
3.180 - * NOTE: Adding mulitple copies of the same function is illegal.
3.181 - *
3.182 - * @param func Function to add.
3.183 - * @return True on success, otherwise false.
3.184 - */
3.185 - virtual bool AddFunction(IPluginFunction *func) =0;
3.186 -
3.187 - /**
3.188 - * @brief Adds a function to the call list.
3.189 - * NOTE: Cannot be used during an incompleted call.
3.190 - * NOTE: If used during a call, function is temporarily queued until calls are over.
3.191 - *
3.192 - * @param ctx Context to use as a look-up.
3.193 - * @param funcid Function id to add.
3.194 - * @return True on success, otherwise false.
3.195 - */
3.196 - virtual bool AddFunction(sp_context_t *ctx, funcid_t index) =0;
3.197 - };
3.198 -
3.199 - #define SP_PARAMTYPE_ANY 0
3.200 - #define SP_PARAMFLAG_BYREF (1<<0)
3.201 - #define SP_PARAMTYPE_CELL (1<<1)
3.202 - #define SP_PARAMTYPE_FLOAT (2<<1)
3.203 - #define SP_PARAMTYPE_STRING (3<<1)|SP_PARAMFLAG_BYREF
3.204 - #define SP_PARAMTYPE_ARRAY (4<<1)|SP_PARAMFLAG_BYREF
3.205 - #define SP_PARAMTYPE_VARARG (5<<1)
3.206 -
3.207 - enum ParamType
3.208 - {
3.209 - Param_Any = SP_PARAMTYPE_ANY,
3.210 - Param_Cell = SP_PARAMTYPE_CELL,
3.211 - Param_Float = SP_PARAMTYPE_FLOAT,
3.212 - Param_String = SP_PARAMTYPE_STRING,
3.213 - Param_Array = SP_PARAMTYPE_ARRAY,
3.214 - Param_VarArgs = SP_PARAMTYPE_VARARG,
3.215 - Param_CellByRef = SP_PARAMTYPE_CELL|SP_PARAMFLAG_BYREF,
3.216 - Param_FloatByRef = SP_PARAMTYPE_FLOAT|SP_PARAMFLAG_BYREF,
3.217 - };
3.218 -
3.219 - class IForwardManager : public SMInterface
3.220 - {
3.221 - public:
3.222 - virtual const char *GetInterfaceName()
3.223 - {
3.224 - return SMINTERFACE_FORWARDMANAGER_NAME;
3.225 - }
3.226 - virtual unsigned int GetInterfaceVersion()
3.227 - {
3.228 - return SMINTERFACE_FORWARDMANAGER_VERSION;
3.229 - }
3.230 - public:
3.231 - /**
3.232 - * @brief Creates a managed forward. This forward exists globally.
3.233 - * The name used to create the forward is used as its public function in all target plugins.
3.234 - * As new non-private plugins become loaded or unloaded, they will be automatically added
3.235 - * or removed. This is ideal for global, static forwards that are never changed.
3.236 - *
3.237 - * @param name Name of public function to use in forward.
3.238 - * @param et Execution type to be used.
3.239 - * @param num_params Number of parameter this function will have.
3.240 - * NOTE: For varargs, this should include the vararg parameter.
3.241 - * @param types Array of type information about each parameter. If NULL, types
3.242 - * are read off the vararg stream.
3.243 - * @param ... If types is NULL, num_params ParamTypes should be pushed.
3.244 - * @return A new IForward on success, NULL if type combination is impossible.
3.245 - */
3.246 - virtual IForward *CreateForward(const char *name,
3.247 - ExecType et,
3.248 - unsigned int num_params,
3.249 - ParamType *types,
3.250 - ...) =0;
3.251 -
3.252 - /**
3.253 - * @brief Creates an unmanaged forward. This forward exists privately.
3.254 - * Unlike managed forwards, no functions are ever added by the Manager.
3.255 - * However, functions will be removed automatically if their parent plugin is unloaded.
3.256 - *
3.257 - * @param name Name of forward (unused except for lookup, can be NULL for anonymous).
3.258 - * @param et Execution type to be used.
3.259 - * @param num_params Number of parameter this function will have.
3.260 - * NOTE: For varargs, this should include the vararg parameter.
3.261 - * @param types Array of type information about each parameter. If NULL, types
3.262 - * are read off the vararg stream.
3.263 - * @param ... If types is NULL, num_params ParamTypes should be pushed.
3.264 - * @return A new IChangeableForward on success, NULL if type combination is impossible.
3.265 - */
3.266 - virtual IChangeableForward *CreateForwardEx(const char *name,
3.267 - ExecType et,
3.268 - int num_params,
3.269 - ParamType *types,
3.270 - ...) =0;
3.271 -
3.272 - /**
3.273 - * @brief Finds a forward by name. Does not return anonymous forwards (named NULL or "").
3.274 - *
3.275 - * @param name Name of forward.
3.276 - * @param ifchng Optionally store either NULL or an IChangeableForward pointer
3.277 - * depending on type of forward.
3.278 - * @return IForward pointer, or NULL if none found matching the name.
3.279 - */
3.280 - virtual IForward *FindForward(const char *name, IChangeableForward **ifchng) =0;
3.281 -
3.282 - /**
3.283 - * @brief Frees and destroys a forward object.
3.284 - *
3.285 - * @param forward An IForward created by CreateForward() or CreateForwardEx().
3.286 - */
3.287 - virtual void ReleaseForward(IForward *forward) =0;
3.288 - };
3.289 -};
3.290 -
3.291 -/**
3.292 - * In the AMX Mod X model of forwarding, each forward contained a list of pairs, each pair containing
3.293 - * a function ID and an AMX structure. The forward structure itself did very little but hold parameter types.
3.294 - * An execution call worked like this:
3.295 - * - executeForward() took in a function id and a list of parameters
3.296 - * - for each contained plugin:
3.297 - * - the list of parameters was preprocessed and pushed
3.298 - * - the call was made
3.299 - * - the list was freed and copybacks were made
3.300 - * - return
3.301 - *
3.302 - * The advantages to this is that the system is very easy to implement, and it's fast. The disadvantage is
3.303 - * varargs tend to be very unforgiving and inflexible, and thus weird problems arose with casting. You also
3.304 - * lose flexibility, type checking, and the ability to reasonably use variable arguments lists in the VM.
3.305 - *
3.306 - * SourceMod replaces this forward system with a far more advanced, but a bit bulkier one. The idea is that
3.307 - * each plugin has a table of functions, and each function is an ICallable object. As well as being an ICallable,
3.308 - * each function is an IPluginFunction. An ICallable simply describes the process of adding parameters to a
3.309 - * function call. An IPluginFunction describes the process of actually calling a function and performing allocation,
3.310 - * copybacks, and deallocations.
3.311 - *
3.312 - * A very powerful forward system emerges: a Forward is just a collection of IPluginFunctions. Thus, the same
3.313 - * API can be easily wrapped around a simple list, and it will look transparent to the user.
3.314 - * Advantages:
3.315 - * 1) "SP Forwards" from AMX Mod X are simply IPluginFunctions without a collection.
3.316 - * 2) Forwards are function based, rather than plugin based, and are thus far more flexible at runtime..
3.317 - * 3) [2] Individual functions can be paused and more than one function from the same plugin can be hooked.
3.318 - * 4) [2] One hook type that used to map to many SP Forwards can now be centralized as one Forward.
3.319 - * This helps alleviate messes like Fakemeta.
3.320 - * 5) Parameter pushing is type-checked and allows for variable arguments.
3.321 - *
3.322 - * Note that while #2,3,4 could be added to AMX Mod X, the real binding property is #1, which makes the system
3.323 - * object oriented, rather than AMX Mod X, which hides the objects behind static functions. It is entirely a design
3.324 - * issue, rather than a usability one. The interesting part is when it gets to implementation, which has to cache
3.325 - * parameter pushing until execution. Without this, multiple function calls can be started across one plugin, which
3.326 - * will result in heap corruption given SourcePawn's implementation.
3.327 - *
3.328 - * Observe the new calling process:
3.329 - * - Each parameter is pushed into a local cache using the ICallable interface.
3.330 - * - For each function in the collection:
3.331 - * - Each parameter is decoded and -pushed into the function.
3.332 - * - The call is made.
3.333 - * - Return
3.334 - *
3.335 - * Astute readers will note the (minor) problems:
3.336 - * 1) More memory is used. Specifically, rather than N params of memory, you now have N params * M plugins.
3.337 - * This is because, again, parameters are cached both per-function and per-forward.
3.338 - * 2) There are slightly more calls going around: one extra call for each parameter, since each push is manual.
3.339 - *
3.340 - * HISTORICAL NOTES:
3.341 - * There used to be a # about copy backs.
3.342 - * Note that originally, the Forward implementation was a thin wrapper around IForwards. It did not cache pushes,
3.343 - * and instead immediately fired them to each internal plugin. This was to allow users to know that pointers would
3.344 - * be immediately resolved. Unfortunately, this became extremely burdensome on the API and exposed many problems,
3.345 - * the major (and breaking) one was that two separate Function objects cannot be in a calling process on the same
3.346 - * plugin at once. (:TODO: perhaps prevent that in the IPlugin object?) This is because heap functions lose their order
3.347 - * and become impossible to re-arrange without some global heap tracking mechanis. It also made iterative copy backs
3.348 - * for arrays/references overwhelmingly complex, since each plugin had to have its memory back-patched for each copy.
3.349 - * Therefore, this was scrapped for cached parameters (current implementation), which is the implementation AMX Mod X
3.350 - * uses. It is both faster and works better.
3.351 - */
3.352 -
3.353 -#endif //_INCLUDE_SOURCEMOD_FORWARDINTERFACE_H_
4.1 --- a/core/interfaces/IHandleSys.h Fri Jan 19 05:25:43 2007 +0000
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,252 +0,0 @@
4.4 -#ifndef _INCLUDE_SOURCEMOD_HANDLESYSTEM_INTERFACE_H_
4.5 -#define _INCLUDE_SOURCEMOD_HANDLESYSTEM_INTERFACE_H_
4.6 -
4.7 -#include <IShareSys.h>
4.8 -#include <sp_vm_types.h>
4.9 -
4.10 -#define SMINTERFACE_HANDLESYSTEM_NAME "IHandleSys"
4.11 -#define SMINTERFACE_HANDLESYSTEM_VERSION 1
4.12 -
4.13 -#define DEFAULT_IDENTITY NULL
4.14 -
4.15 -namespace SourceMod
4.16 -{
4.17 - /**
4.18 - * Both of these types have invalid values of '0' for error checking.
4.19 - */
4.20 - typedef unsigned int HandleType_t;
4.21 - typedef unsigned int Handle_t;
4.22 -
4.23 - class SourcePawn::IPluginContext;
4.24 -
4.25 - /**
4.26 - * About type checking:
4.27 - * Types can be inherited - a Parent type ("Supertype") can have child types.
4.28 - * When accessing handles, type checking is done. This table shows how this is resolved:
4.29 - *
4.30 - * HANDLE CHECK -> RESULT
4.31 - * ------ ----- ------
4.32 - * Parent Parent Success
4.33 - * Parent Child Fail
4.34 - * Child Parent Success
4.35 - * Child Child Success
4.36 - */
4.37 -
4.38 - enum HandleError
4.39 - {
4.40 - HandleError_None = 0, /* No error */
4.41 - HandleError_Changed, /* The handle has been freed and reassigned */
4.42 - HandleError_Type, /* The handle has a different type registered */
4.43 - HandleError_Freed, /* The handle has been freed */
4.44 - HandleError_Index, /* generic internal indexing error */
4.45 - HandleError_Access, /* No access permitted to free this handle */
4.46 - HandleError_Limit, /* The limited number of handles has been reached */
4.47 - HandleError_Identity, /* The identity token was not usable */
4.48 - HandleError_Owner, /* Owners do not match for this operation */
4.49 - HandleError_Version, /* Unrecognized security structure version */
4.50 - HandleError_Parameter, /* An invalid parameter was passed */
4.51 - HandleError_NoInherit, /* This type cannot be inherited */
4.52 - };
4.53 -
4.54 - /**
4.55 - * Access rights specific to a type
4.56 - */
4.57 - enum HTypeAccessRight
4.58 - {
4.59 - HTypeAccess_Create = 0, /* Handles of this type can be created (DEFAULT=false) */
4.60 - HTypeAccess_Inherit, /* Sub-types can inherit this type (DEFAULT=false) */
4.61 - /* -------------- */
4.62 - HTypeAccess_TOTAL, /* Total number of type access rights */
4.63 - };
4.64 -
4.65 - /**
4.66 - * Access rights specific to a Handle. These rights are exclusive.
4.67 - * For example, you do not need "read" access to delete or clone.
4.68 - */
4.69 - enum HandleAccessRight
4.70 - {
4.71 - HandleAccess_Read, /* Can be read (DEFAULT=ident only) */
4.72 - HandleAccess_Delete, /* Can be deleted (DEFAULT=owner only) */
4.73 - HandleAccess_Clone, /* Can be cloned (DEFAULT=any) */
4.74 - /* ------------- */
4.75 - HandleAccess_TOTAL, /* Total number of access rights */
4.76 - };
4.77 -
4.78 - #define HANDLE_RESTRICT_IDENTITY (1<<0) /* Access is restricted to the identity */
4.79 - #define HANDLE_RESTRICT_OWNER (1<<1) /* Access is restricted to the owner */
4.80 -
4.81 - /**
4.82 - * This is used to define per-type access rights.
4.83 - */
4.84 - struct TypeAccess
4.85 - {
4.86 - TypeAccess()
4.87 - {
4.88 - hsVersion = SMINTERFACE_HANDLESYSTEM_VERSION;
4.89 - }
4.90 - unsigned int hsVersion;
4.91 - IdentityToken_t *ident;
4.92 - bool access[HTypeAccess_TOTAL];
4.93 - };
4.94 -
4.95 - /**
4.96 - * This is used to define per-Handle access rights.
4.97 - */
4.98 - struct HandleAccess
4.99 - {
4.100 - HandleAccess()
4.101 - {
4.102 - hsVersion = SMINTERFACE_HANDLESYSTEM_VERSION;
4.103 - }
4.104 - unsigned int hsVersion;
4.105 - unsigned int access[HandleAccess_TOTAL];
4.106 - };
4.107 -
4.108 - /**
4.109 - * This pair of tokens is used for identification.
4.110 - */
4.111 - struct HandleSecurity
4.112 - {
4.113 - IdentityToken_t *pOwner; /* Owner of the Handle */
4.114 - IdentityToken_t *pIdentity; /* Owner of the Type */
4.115 - };
4.116 -
4.117 - class IHandleTypeDispatch
4.118 - {
4.119 - public:
4.120 - virtual unsigned int GetDispatchVersion()
4.121 - {
4.122 - return SMINTERFACE_HANDLESYSTEM_VERSION;
4.123 - }
4.124 - public:
4.125 - /**
4.126 - * @brief Called when destroying a handle. Must be implemented.
4.127 - */
4.128 - virtual void OnHandleDestroy(HandleType_t type, void *object) =0;
4.129 - };
4.130 -
4.131 - class IHandleSys : public SMInterface
4.132 - {
4.133 - public:
4.134 - virtual unsigned int GetInterfaceVersion()
4.135 - {
4.136 - return SMINTERFACE_HANDLESYSTEM_VERSION;
4.137 - }
4.138 - virtual const char *GetInterfaceName()
4.139 - {
4.140 - return SMINTERFACE_HANDLESYSTEM_NAME;
4.141 - }
4.142 - public:
4.143 - /**
4.144 - * @brief Creates a new Handle type.
4.145 - * NOTE: Currently, a child type may not have its own children.
4.146 - * NOTE: Handle names must be unique if not private.
4.147 - *
4.148 - * @param name Name of handle type (NULL or "" to be anonymous)
4.149 - * @param dispatch Pointer to a valid IHandleTypeDispatch object.
4.150 - * @param parent Parent handle to inherit from, 0 for none.
4.151 - * @param typeAccess Pointer to a TypeAccess object, NULL to use default
4.152 - * or inherited permissions. Pointer can be temporary.
4.153 - * @param hndlAccess Pointer to a HandleAccess object to define default
4.154 - * default permissions on each Handle. NULL to use default
4.155 - * permissions.
4.156 - * @param ident Security token for any permissions. If typeAccess is NULL, this
4.157 - * becomes the owning identity.
4.158 - * @param err Optional pointer to store an error code.
4.159 - * @return A new HandleType_t unique ID, or 0 on failure.
4.160 - */
4.161 - virtual HandleType_t CreateType(const char *name,
4.162 - IHandleTypeDispatch *dispatch,
4.163 - HandleType_t parent,
4.164 - const TypeAccess *typeAccess,
4.165 - const HandleAccess *hndlAccess,
4.166 - IdentityToken_t *ident,
4.167 - HandleError *err) =0;
4.168 -
4.169 - /**
4.170 - * @brief Removes a handle type.
4.171 - * NOTE: This removes all child types.
4.172 - *
4.173 - * @param type Type chain to remove.
4.174 - * @param ident Identity token. Removal fails if the token does not match.
4.175 - * @return True on success, false on failure.
4.176 - */
4.177 - virtual bool RemoveType(HandleType_t type, IdentityToken_t *ident) =0;
4.178 -
4.179 - /**
4.180 - * @brief Finds a handle type by name.
4.181 - *
4.182 - * @param name Name of handle type to find (anonymous not allowed).
4.183 - * @param type Address to store found handle in (if not found, undefined).
4.184 - * @return True if found, false otherwise.
4.185 - */
4.186 - virtual bool FindHandleType(const char *name, HandleType_t *type) =0;
4.187 -
4.188 - /**
4.189 - * @brief Creates a new handle.
4.190 - *
4.191 - * @param type Type to use on the handle.
4.192 - * @param object Object to bind to the handle.
4.193 - * @param owner Owner of the new Handle (may be NULL).
4.194 - * @param ident Identity for type access if needed (may be NULL).
4.195 - * @param err Optional pointer to store an error code.
4.196 - * @return A new Handle_t, or 0 on failure.
4.197 - */
4.198 - virtual Handle_t CreateHandle(HandleType_t type,
4.199 - void *object,
4.200 - IdentityToken_t *owner,
4.201 - IdentityToken_t *ident,
4.202 - HandleError *err) =0;
4.203 -
4.204 - /**
4.205 - * @brief Frees the memory associated with a handle and calls any destructors.
4.206 - * NOTE: This function will decrement the internal reference counter. It will
4.207 - * only perform any further action if the counter hits 0.
4.208 - *
4.209 - * @param type Handle_t identifier to destroy.
4.210 - * @param pSecurity Security information struct (may be NULL).
4.211 - * @return A HandleError error code.
4.212 - */
4.213 - virtual HandleError FreeHandle(Handle_t handle, const HandleSecurity *pSecurity) =0;
4.214 -
4.215 - /**
4.216 - * @brief Clones a handle by adding to its internal reference count. Its data,
4.217 - * type, and security permissions remain the same.
4.218 - *
4.219 - * @param handle Handle to duplicate. Any non-free handle target is valid.
4.220 - * @param newhandle Stores the duplicated handle in the pointer (must not be NULL).
4.221 - * @param newOwner New owner of cloned handle.
4.222 - * @param pSecurity Security information struct (may be NULL).
4.223 - * @return A HandleError error code.
4.224 - */
4.225 - virtual HandleError CloneHandle(Handle_t handle,
4.226 - Handle_t *newhandle,
4.227 - IdentityToken_t *newOwner,
4.228 - const HandleSecurity *pSecurity) =0;
4.229 -
4.230 - /**
4.231 - * @brief Retrieves the contents of a handle.
4.232 - *
4.233 - * @param handle Handle_t from which to retrieve contents.
4.234 - * @param type Expected type to read as. 0 ignores typing rules.
4.235 - * @param pSecurity Security information struct (may be NULL).
4.236 - * @param object Optional address to store object in.
4.237 - * @return HandleError error code.
4.238 - */
4.239 - virtual HandleError ReadHandle(Handle_t handle,
4.240 - HandleType_t type,
4.241 - const HandleSecurity *pSecurity,
4.242 - void **object) =0;
4.243 -
4.244 - /**
4.245 - * @brief Sets access permissions on one or more structures.
4.246 - *
4.247 - * @param pTypeAccess Optional TypeAccess buffer to initialize with the default values.
4.248 - * @param pHandleAccess Optional HandleAccess buffer to initialize with the default values.
4.249 - * @return True on success, false if version is unsupported.
4.250 - */
4.251 - virtual bool InitAccessDefaults(TypeAccess *pTypeAccess, HandleAccess *pHandleAccess) =0;
4.252 - };
4.253 -};
4.254 -
4.255 -#endif //_INCLUDE_SOURCEMOD_HANDLESYSTEM_INTERFACE_H_
5.1 --- a/core/interfaces/ILibrarySys.h Fri Jan 19 05:25:43 2007 +0000
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,155 +0,0 @@
5.4 -#ifndef _INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
5.5 -#define _INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
5.6 -
5.7 -#include <IShareSys.h>
5.8 -
5.9 -namespace SourceMod
5.10 -{
5.11 - #define SMINTERFACE_LIBRARYSYS_NAME "ILibrarySys"
5.12 - #define SMINTERFACE_LIBRARYSYS_VERSION 1
5.13 -
5.14 - class ILibrary
5.15 - {
5.16 - public:
5.17 - virtual ~ILibrary()
5.18 - {
5.19 - /* Calling delete will call CloseLibrary! */
5.20 - };
5.21 - public:
5.22 - /**
5.23 - * @brief Closes dynamic library and invalidates pointer.
5.24 - */
5.25 - virtual void CloseLibrary() =0;
5.26 -
5.27 - /**
5.28 - * @brief Retrieves a symbol pointer from the dynamic library.
5.29 - *
5.30 - * @param symname Symbol name.
5.31 - * @return Symbol pointer, NULL if not found.
5.32 - */
5.33 - virtual void *GetSymbolAddress(const char *symname) =0;
5.34 - };
5.35 -
5.36 - /**
5.37 - * @brief Directory browsing abstraction.
5.38 - */
5.39 - class IDirectory
5.40 - {
5.41 - public:
5.42 - virtual ~IDirectory()
5.43 - {
5.44 - }
5.45 - public:
5.46 - /**
5.47 - * @brief Returns true if there are more files to read, false otherwise.
5.48 - */
5.49 - virtual bool MoreFiles() =0;
5.50 -
5.51 - /**
5.52 - * @brief Advances to the next entry in the stream.
5.53 - */
5.54 - virtual void NextEntry() =0;
5.55 -
5.56 - /**
5.57 - * @brief Returns the name of the current entry.
5.58 - */
5.59 - virtual const char *GetEntryName() =0;
5.60 -
5.61 - /**
5.62 - * @brief Returns whether the current entry is a directory.
5.63 - */
5.64 - virtual bool IsEntryDirectory() =0;
5.65 -
5.66 - /**
5.67 - * @brief Returns whether the current entry is a file.
5.68 - */
5.69 - virtual bool IsEntryFile() =0;
5.70 -
5.71 - /**
5.72 - * @brief Returns true if the current entry is valid
5.73 - * (Used similarly to MoreFiles).
5.74 - */
5.75 - virtual bool IsEntryValid() =0;
5.76 - };
5.77 -
5.78 - /**
5.79 - * @brief Contains various operating system specific code.
5.80 - */
5.81 - class ILibrarySys : public SMInterface
5.82 - {
5.83 - public:
5.84 - virtual const char *GetInterfaceName()
5.85 - {
5.86 - return SMINTERFACE_LIBRARYSYS_NAME;
5.87 - }
5.88 - virtual unsigned int GetInterfaceVersion()
5.89 - {
5.90 - return SMINTERFACE_LIBRARYSYS_VERSION;
5.91 - }
5.92 - public:
5.93 - /**
5.94 - * @brief Opens a dynamic library file.
5.95 - *
5.96 - * @param path Path to library file (.dll/.so).
5.97 - * @param error Buffer for any error message (may be NULL).
5.98 - * @param err_max Maximum length of error buffer.
5.99 - * @return Pointer to an ILibrary, NULL if failed.
5.100 - */
5.101 - virtual ILibrary *OpenLibrary(const char *path, char *error, size_t err_max) =0;
5.102 -
5.103 - /**
5.104 - * @brief Opens a directory for reading.
5.105 - *
5.106 - * @param path Path to directory.
5.107 - * @return Pointer to an IDirectory, NULL if failed.
5.108 - */
5.109 - virtual IDirectory *OpenDirectory(const char *path) =0;
5.110 -
5.111 - /**
5.112 - * @brief Closes a directory and frees its handle.
5.113 - *
5.114 - * @param dir Pointer to IDirectory.
5.115 - */
5.116 - virtual void CloseDirectory(IDirectory *dir) =0;
5.117 -
5.118 - /**
5.119 - * @brief Returns true if a path exists.
5.120 - */
5.121 - virtual bool PathExists(const char *path) =0;
5.122 -
5.123 - /**
5.124 - * @brief Returns true if the path is a normal file.
5.125 - */
5.126 - virtual bool IsPathFile(const char *path) =0;
5.127 -
5.128 - /**
5.129 - * @brief Returns true if the path is a normal directory.
5.130 - */
5.131 - virtual bool IsPathDirectory(const char *path) =0;
5.132 -
5.133 - /**
5.134 - * @brief Gets a platform-specific error message.
5.135 - * This should only be called when an ILibrary function fails.
5.136 - * Win32 equivalent: GetLastError() + FormatMessage()
5.137 - * POSIX equivalent: errno + strerror()
5.138 - *
5.139 - * @param error Error message buffer.
5.140 - * @param err_max Maximum length of error buffer.
5.141 - */
5.142 - virtual void GetPlatformError(char *error, size_t err_max) =0;
5.143 -
5.144 - /**
5.145 - * @brief Formats a string similar to snprintf(), except
5.146 - * corrects all non-platform compatible path separators to be
5.147 - * the correct platform character.
5.148 - *
5.149 - * @param buffer Output buffer pointer.
5.150 - * @param maxlength Output buffer size.
5.151 - * @param pathfmt Format string of path.
5.152 - * @param ... Format string arguments.
5.153 - */
5.154 - virtual size_t PathFormat(char *buffer, size_t maxlength, const char *pathfmt, ...) =0;
5.155 - };
5.156 -};
5.157 -
5.158 -#endif //_INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
6.1 --- a/core/interfaces/IPluginFunction.h Fri Jan 19 05:25:43 2007 +0000
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,153 +0,0 @@
6.4 -#ifndef _INCLUDE_SOURCEMOD_PLUGINFUNCTION_INTERFACE_H_
6.5 -#define _INCLUDE_SOURCEMOD_PLUGINFUNCTION_INTERFACE_H_
6.6 -
6.7 -#include <IPluginSys.h>
6.8 -
6.9 -namespace SourceMod
6.10 -{
6.11 - #define SM_PARAM_COPYBACK (1<<0) /* Copy an array/reference back after call */
6.12 -
6.13 - #define SM_PARAM_STRING_UTF8 (1<<0) /* String should be UTF-8 handled */
6.14 - #define SM_PARAM_STRING_COPY (1<<1) /* String should be copied into the plugin */
6.15 -
6.16 - /**
6.17 - * @brief Represents what a function needs to implement in order to be callable.
6.18 - */
6.19 - class ICallable
6.20 - {
6.21 - public:
6.22 - /**
6.23 - * @brief Pushes a cell onto the current call.
6.24 - *
6.25 - * @param cell Parameter value to push.
6.26 - * @return Error code, if any.
6.27 - */
6.28 - virtual int PushCell(cell_t cell) =0;
6.29 -
6.30 - /**
6.31 - * @brief Pushes a cell by reference onto the current call.
6.32 - * NOTE: On Execute, the pointer passed will be modified if copyback is enabled.
6.33 - * NOTE: By reference parameters are cached and thus are not read until execution.
6.34 - * This means you cannot push a pointer, change it, and push it again and expect
6.35 - * two different values to come out.
6.36 - *
6.37 - * @param cell Address containing parameter value to push.
6.38 - * @param flags Copy-back flags.
6.39 - * @return Error code, if any.
6.40 - */
6.41 - virtual int PushCellByRef(cell_t *cell, int flags) =0;
6.42 -
6.43 - /**
6.44 - * @brief Pushes a float onto the current call.
6.45 - *
6.46 - * @param float Parameter value to push.
6.47 - * @return Error code, if any.
6.48 - */
6.49 - virtual int PushFloat(float number) =0;
6.50 -
6.51 - /**
6.52 - * @brief Pushes a float onto the current call by reference.
6.53 - * NOTE: On Execute, the pointer passed will be modified if copyback is enabled.
6.54 - * NOTE: By reference parameters are cached and thus are not read until execution.
6.55 - * This means you cannot push a pointer, change it, and push it again and expect
6.56 - * two different values to come out.
6.57 - *
6.58 - * @param float Parameter value to push.
6.59 - & @param flags Copy-back flags.
6.60 - * @return Error code, if any.
6.61 - */
6.62 - virtual int PushFloatByRef(float *number, int flags) =0;
6.63 -
6.64 - /**
6.65 - * @brief Pushes an array of cells onto the current call.
6.66 - * NOTE: On Execute, the pointer passed will be modified if non-NULL and copy-back
6.67 - * is enabled.
6.68 - * NOTE: By reference parameters are cached and thus are not read until execution.
6.69 - * This means you cannot push a pointer, change it, and push it again and expect
6.70 - * two different values to come out.
6.71 - *
6.72 - * @param inarray Array to copy, NULL if no initial array should be copied.
6.73 - * @param cells Number of cells to allocate and optionally read from the input array.
6.74 - * @param phys_addr Optional return address for physical array, if one was made.
6.75 - * @param flags Whether or not changes should be copied back to the input array.
6.76 - * @return Error code, if any.
6.77 - */
6.78 - virtual int PushArray(cell_t *inarray,
6.79 - unsigned int cells,
6.80 - cell_t **phys_addr,
6.81 - int flags=0) =0;
6.82 -
6.83 - /**
6.84 - * @brief Pushes a string onto the current call.
6.85 - *
6.86 - * @param string String to push.
6.87 - * @return Error code, if any.
6.88 - */
6.89 - virtual int PushString(const char *string) =0;
6.90 -
6.91 - /**
6.92 - * @brief Pushes a string or string buffer.
6.93 - * NOTE: On Execute, the pointer passed will be modified if copy-back is enabled.
6.94 - *
6.95 - * @param buffer Pointer to string buffer.
6.96 - * @param length Length of buffer.
6.97 - * @param sz_flags String flags.
6.98 - * @param cp_flags Copy-back flags.
6.99 - * @return Error code, if any.
6.100 - */
6.101 - virtual int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags) =0;
6.102 -
6.103 - /**
6.104 - * @brief Cancels a function call that is being pushed but not yet executed.
6.105 - * This can be used be reset for CallFunction() use.
6.106 - */
6.107 - virtual void Cancel() =0;
6.108 - };
6.109 -
6.110 - /**
6.111 - * @brief Encapsulates a function call in a plugin.
6.112 - * NOTE: Function calls must be atomic to one execution context.
6.113 - * NOTE: This object should not be deleted. It lives for the lifetime of the plugin.
6.114 - */
6.115 - class IPluginFunction : public ICallable
6.116 - {
6.117 - public:
6.118 - /**
6.119 - * @brief Executes the forward, resets the pushed parameter list, and performs any copybacks.
6.120 - *
6.121 - * @param result Pointer to store return value in.
6.122 - * @return Error code, if any.
6.123 - */
6.124 - virtual int Execute(cell_t *result) =0;
6.125 -
6.126 - /**
6.127 - * @brief Executes the function with the given parameter array.
6.128 - * Parameters are read in forward order (i.e. index 0 is parameter #1)
6.129 - * NOTE: You will get an error if you attempt to use CallFunction() with
6.130 - * previously pushed parameters.
6.131 - *
6.132 - * @param param Array of cell parameters.
6.133 - * @param num_params Number of parameters to push.
6.134 - * @param result Pointer to store result of function on return.
6.135 - * @return SourcePawn error code (if any).
6.136 - */
6.137 - virtual int CallFunction(const cell_t *params, unsigned int num_params, cell_t *result) =0;
6.138 -
6.139 - /**
6.140 - * @brief Returns which plugin this function belongs to.
6.141 - *
6.142 - * @return IPlugin pointer to parent plugin.
6.143 - */
6.144 - virtual IPlugin *GetParentPlugin() =0;
6.145 -
6.146 - /**
6.147 - * @brief Returns the physical address of a by-reference parameter.
6.148 - *
6.149 - * @param Parameter index to read (beginning at 0).
6.150 - * @return Address, or NULL if invalid parameter specified.
6.151 - */
6.152 - virtual cell_t *GetAddressOfPushedParam(unsigned int param) =0;
6.153 - };
6.154 -};
6.155 -
6.156 -#endif //_INCLUDE_SOURCEMOD_PLUGINFUNCTION_INTERFACE_H_
7.1 --- a/core/interfaces/IPluginSys.h Fri Jan 19 05:25:43 2007 +0000
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,302 +0,0 @@
7.4 -#ifndef _INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
7.5 -#define _INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
7.6 -
7.7 -#include <IShareSys.h>
7.8 -#include <sp_vm_api.h>
7.9 -
7.10 -#define SMINTERFACE_PLUGINSYSTEM_NAME "IPluginManager"
7.11 -#define SMINTERFACE_PLUGINSYSTEM_VERSION 1
7.12 -
7.13 -#define SM_CONTEXTVAR_USER 3
7.14 -
7.15 -namespace SourceMod
7.16 -{
7.17 - class IPlugin;
7.18 -
7.19 - /**
7.20 - * @brief Encapsulates plugin public information.
7.21 - */
7.22 - typedef struct sm_plugininfo_s
7.23 - {
7.24 - const char *name;
7.25 - const char *author;
7.26 - const char *description;
7.27 - const char *version;
7.28 - const char *url;
7.29 - } sm_plugininfo_t;
7.30 -
7.31 -
7.32 - /**
7.33 - * @brief Describes the usability status of a plugin.
7.34 - * Note: The status "Loaded" and "Created" are only reachable
7.35 - * during map load.
7.36 - */
7.37 - enum PluginStatus
7.38 - {
7.39 - Plugin_Running=0, /* Plugin is running */
7.40 - /* All states below are unexecutable */
7.41 - Plugin_Paused, /* Plugin is loaded but paused */
7.42 - Plugin_Error, /* Plugin is loaded but errored/locked */
7.43 - /* All states below do not have all natives */
7.44 - Plugin_Loaded, /* Plugin has passed loading and can be finalized */
7.45 - Plugin_Failed, /* Plugin has a fatal failure */
7.46 - Plugin_Created, /* Plugin is created but not initialized */
7.47 - Plugin_Uncompiled, /* Plugin is not yet compiled by the JIT */
7.48 - Plugin_BadLoad, /* Plugin failed to load */
7.49 - };
7.50 -
7.51 -
7.52 - /**
7.53 - * @brief Describes the object lifetime of a plugin.
7.54 - */
7.55 - enum PluginType
7.56 - {
7.57 - PluginType_Private, /* Plugin is privately managed and receives no forwards */
7.58 - PluginType_MapUpdated, /* Plugin will never be unloaded unless for updates on mapchange */
7.59 - PluginType_MapOnly, /* Plugin will be removed at mapchange */
7.60 - PluginType_Global, /* Plugin will never be unloaded or updated */
7.61 - };
7.62 -
7.63 - class IPluginFunction;
7.64 -
7.65 - /**
7.66 - * @brief Encapsulates a run-time plugin as maintained by SourceMod.
7.67 - */
7.68 - class IPlugin
7.69 - {
7.70 - public:
7.71 - virtual ~IPlugin()
7.72 - {
7.73 - }
7.74 -
7.75 - /**
7.76 - * @brief Returns the lifetime of a plugin.
7.77 - */
7.78 - virtual PluginType GetType() const =0;
7.79 -
7.80 - /**
7.81 - * @brief Returns the current API context being used in the plugin.
7.82 - *
7.83 - * @return Pointer to an IPluginContext, or NULL if not loaded.
7.84 - */
7.85 - virtual SourcePawn::IPluginContext *GetBaseContext() const =0;
7.86 -
7.87 - /**
7.88 - * @brief Returns the context structure being used in the plugin.
7.89 - *
7.90 - * @return Pointer to an sp_context_t, or NULL if not loaded.
7.91 - */
7.92 - virtual sp_context_t *GetContext() const =0;
7.93 -
7.94 - /**
7.95 - * @brief Returns the plugin file structure.
7.96 - *
7.97 - * @return Pointer to an sp_plugin_t, or NULL if not loaded.
7.98 - */
7.99 - virtual const sp_plugin_t *GetPluginStructure() const =0;
7.100 -
7.101 - /**
7.102 - * @brief Returns information about the plugin by reference.
7.103 - *
7.104 - * @return Pointer to a sm_plugininfo_t object, NULL if plugin is not loaded.
7.105 - */
7.106 - virtual const sm_plugininfo_t *GetPublicInfo() const =0;
7.107 -
7.108 - /**
7.109 - * @brief Returns the plugin filename (relative to plugins dir).
7.110 - */
7.111 - virtual const char *GetFilename() const =0;
7.112 -
7.113 - /**
7.114 - * @brief Returns true if a plugin is in debug mode, false otherwise.
7.115 - */
7.116 - virtual bool IsDebugging() const =0;
7.117 -
7.118 - /**
7.119 - * @brief Returns the plugin status.
7.120 - */
7.121 - virtual PluginStatus GetStatus() const =0;
7.122 -
7.123 - /**
7.124 - * @brief Sets whether the plugin is paused or not.
7.125 - *
7.126 - * @return True on successful state change, false otherwise.
7.127 - */
7.128 - virtual bool SetPauseState(bool paused) =0;
7.129 -
7.130 - /**
7.131 - * @brief Returns the unique serial number of a plugin.
7.132 - */
7.133 - virtual unsigned int GetSerial() const =0;
7.134 -
7.135 - /**
7.136 - * @brief Returns a function by name.
7.137 - *
7.138 - * @param public_name Name of the function.
7.139 - * @return A new IPluginFunction pointer, NULL if not found.
7.140 - */
7.141 - virtual IPluginFunction *GetFunctionByName(const char *public_name) =0;
7.142 -
7.143 - /**
7.144 - * @brief Returns a function by its id.
7.145 - *
7.146 - * @param func_id Function ID.
7.147 - * @return A new IPluginFunction pointer, NULL if not found.
7.148 - */
7.149 - virtual IPluginFunction *GetFunctionById(funcid_t func_id) =0;
7.150 -
7.151 - /**
7.152 - * @brief Returns a plugin's identity token.
7.153 - */
7.154 - virtual IdentityToken_t *GetIdentity() const =0;
7.155 - };
7.156 -
7.157 -
7.158 - /**
7.159 - * @brief Iterates over a list of plugins.
7.160 - */
7.161 - class IPluginIterator
7.162 - {
7.163 - public:
7.164 - virtual ~IPluginIterator()
7.165 - {
7.166 - };
7.167 - public:
7.168 - /**
7.169 - * @brief Returns true if there are more plugins in the iterator.
7.170 - */
7.171 - virtual bool MorePlugins() =0;
7.172 -
7.173 - /**
7.174 - * @brief Returns the plugin at the current iterator position.
7.175 - */
7.176 - virtual IPlugin *GetPlugin() =0;
7.177 -
7.178 - /**
7.179 - * @brief Advances to the next plugin in the iterator.
7.180 - */
7.181 - virtual void NextPlugin() =0;
7.182 -
7.183 - /**
7.184 - * @brief Destroys the iterator object.
7.185 - * Note: You may use 'delete' in lieu of this function.
7.186 - */
7.187 - virtual void Release() =0;
7.188 - };
7.189 -
7.190 - /**
7.191 - * @brief Listens for plugin-oriented events.
7.192 - */
7.193 - class IPluginsListener
7.194 - {
7.195 - public:
7.196 - /**
7.197 - * @brief Called when a plugin is created/mapped into memory.
7.198 - */
7.199 - virtual void OnPluginCreated(IPlugin *plugin)
7.200 - {
7.201 - }
7.202 -
7.203 - /**
7.204 - * @brief Called when a plugin is fully loaded successfully.
7.205 - */
7.206 - virtual void OnPluginLoaded(IPlugin *plugin)
7.207 - {
7.208 - }
7.209 -
7.210 - /**
7.211 - * @brief Called when a plugin is unloaded (only if fully loaded).
7.212 - */
7.213 - virtual void OnPluginUnloaded(IPlugin *plugin)
7.214 - {
7.215 - }
7.216 -
7.217 - /**
7.218 - * @brief Called when a plugin is destroyed.
7.219 - * NOTE: Always called if Created, even if load failed.
7.220 - */
7.221 - virtual void OnPluginDestroyed(IPlugin *plugin)
7.222 - {
7.223 - }
7.224 - };
7.225 -
7.226 -
7.227 - /**
7.228 - * @brief Manages the runtime loading and unloading of plugins.
7.229 - */
7.230 - class IPluginManager : public SMInterface
7.231 - {
7.232 - public:
7.233 - virtual const char *GetInterfaceName()
7.234 - {
7.235 - return SMINTERFACE_PLUGINSYSTEM_NAME;
7.236 - }
7.237 -
7.238 - virtual unsigned int GetInterfaceVersion()
7.239 - {
7.240 - return SMINTERFACE_PLUGINSYSTEM_VERSION;
7.241 - }
7.242 - public:
7.243 - /**
7.244 - * @brief Attempts to load a plugin.
7.245 - *
7.246 - * @param path Path and filename of plugin, relative to plugins folder.
7.247 - * @param debug Whether or not to default the plugin into debug mode.
7.248 - * @param type Lifetime of the plugin.
7.249 - * @param error Buffer to hold any error message.
7.250 - * @param err_max Maximum length of error message buffer.
7.251 - * @return A new plugin pointer on success, false otherwise.
7.252 - */
7.253 - virtual IPlugin *LoadPlugin(const char *path,
7.254 - bool debug,
7.255 - PluginType type,
7.256 - char error[],
7.257 - size_t err_max) =0;
7.258 -
7.259 - /**
7.260 - * @brief Attempts to unload a plugin.
7.261 - *
7.262 - * @param plugin Pointer to the plugin handle.
7.263 - * @return True on success, false otherwise.
7.264 - */
7.265 - virtual bool UnloadPlugin(IPlugin *plugin) =0;
7.266 -
7.267 - /**
7.268 - * @brief Finds a plugin by its context.
7.269 - * Note: This function should be considered O(1).
7.270 - *
7.271 - * @param ctx Pointer to an sp_context_t.
7.272 - * @return Pointer to a matching IPlugin, or NULL if none found.
7.273 - */
7.274 - virtual IPlugin *FindPluginByContext(const sp_context_t *ctx) =0;
7.275 -
7.276 - /**
7.277 - * @brief Returns the number of plugins (both failed and loaded).
7.278 - *
7.279 - * @return The number of internally cached plugins.
7.280 - */
7.281 - virtual unsigned int GetPluginCount() =0;
7.282 -
7.283 - /**
7.284 - * @brief Returns a pointer that can be used to iterate through plugins.
7.285 - * Note: This pointer must be freed using EITHER delete OR IPluginIterator::Release().
7.286 - */
7.287 - virtual IPluginIterator *GetPluginIterator() =0;
7.288 -
7.289 - /**
7.290 - * @brief Adds a plugin manager listener.
7.291 - *
7.292 - * @param listener Pointer to a listener.
7.293 - */
7.294 - virtual void AddPluginsListener(IPluginsListener *listener) =0;
7.295 -
7.296 - /**
7.297 - * @brief Removes a plugin listener.
7.298 - *
7.299 - * @param listener Pointer to a listener.
7.300 - */
7.301 - virtual void RemovePluginsListener(IPluginsListener *listener) =0;
7.302 - };
7.303 -};
7.304 -
7.305 -#endif //_INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
8.1 --- a/core/interfaces/IRootConsoleMenu.h Fri Jan 19 05:25:43 2007 +0000
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,90 +0,0 @@
8.4 -#ifndef _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
8.5 -#define _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
8.6 -
8.7 -/**
8.8 - * @brief Note: This interface is not exposed.
8.9 - * The reason should be obvious: we do not want users touching the "root" console menu.
8.10 - * If we exposed this, every little plugin would be dropping down a silly set of user commands,
8.11 - * whereas this menu is explicitly provided for stuff that only Core itself is capable of managing.
8.12 - */
8.13 -
8.14 -namespace SourceMod
8.15 -{
8.16 - /**
8.17 - * @brief Handles a root console menu action.
8.18 - */
8.19 - class IRootConsoleCommand
8.20 - {
8.21 - public:
8.22 - virtual void OnRootConsoleCommand(const char *command, unsigned int argcount) =0;
8.23 - };
8.24 -
8.25 - /**
8.26 - * @brief Manages the root console menu - the "sm" command for servers.
8.27 - */
8.28 - class IRootConsole
8.29 - {
8.30 - public:
8.31 - /**
8.32 - * @brief Adds a root console command handler. The command must be unique.
8.33 - *
8.34 - * @param cmd String containing the console command.
8.35 - * @param text Description text.
8.36 - * @param pHandler An IRootConsoleCommand pointer to handle the command.
8.37 - * @return True on success, false on too many commands or duplicate command.
8.38 - */
8.39 - virtual bool AddRootConsoleCommand(const char *cmd, const char *text, IRootConsoleCommand *pHandler) =0;
8.40 -
8.41 - /**
8.42 - * @brief Removes a root console command handler.
8.43 - *
8.44 - * @param cmd String containing the console command.
8.45 - * @param pHandler An IRootConsoleCommand pointer for verification.
8.46 - * @return True on success, false otherwise.
8.47 - */
8.48 - virtual bool RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler) =0;
8.49 -
8.50 - /**
8.51 - * @brief Prints text back to the console.
8.52 - *
8.53 - * @param fmt Format of string.
8.54 - * @param ... Format arguments.
8.55 - */
8.56 - virtual void ConsolePrint(const char *fmt, ...) =0;
8.57 -
8.58 - /**
8.59 - * @brief Returns the string of an argument.
8.60 - *
8.61 - * @param argno The index of the argument.
8.62 - * @return A string containing the argument, or nothing if invalid.
8.63 - */
8.64 - virtual const char *GetArgument(unsigned int argno) =0;
8.65 -
8.66 - /**
8.67 - * @brief Returns the number of arguments.
8.68 - *
8.69 - * @return Number of arguments.
8.70 - */
8.71 - virtual unsigned int GetArgumentCount() =0;
8.72 -
8.73 - /**
8.74 - * @brief Returns the entire argument string.
8.75 - *
8.76 - * @return String containing all arguments.
8.77 - */
8.78 - virtual const char *GetArguments() =0;
8.79 -
8.80 - /**
8.81 - * @brief Draws a generic command/description pair.
8.82 - * NOTE: The pair is currently four spaces indented and 16-N spaces of separation,
8.83 - * N being the length of the command name. This is subject to change in case we
8.84 - * account for Valve's font choices.
8.85 - *
8.86 - * @param option String containing the command option.
8.87 - * @param description String containing the command description.
8.88 - */
8.89 - virtual void DrawGenericOption(const char *cmd, const char *text) =0;
8.90 - };
8.91 -};
8.92 -
8.93 -#endif //_INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
9.1 --- a/core/interfaces/IShareSys.h Fri Jan 19 05:25:43 2007 +0000
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,149 +0,0 @@
9.4 -#ifndef _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
9.5 -#define _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
9.6 -
9.7 -#include <sp_vm_types.h>
9.8 -
9.9 -#define NO_IDENTITY 0
9.10 -
9.11 -namespace SourceMod
9.12 -{
9.13 - class IExtension;
9.14 - struct IdentityToken_t;
9.15 - typedef unsigned int HandleType_t;
9.16 - typedef HandleType_t IdentityType_t;
9.17 - /**
9.18 - * @brief Defines the base functionality required by a shared interface.
9.19 - */
9.20 - class SMInterface
9.21 - {
9.22 - public:
9.23 - /**
9.24 - * @brief Must return an integer defining the interface's version.
9.25 - */
9.26 - virtual unsigned int GetInterfaceVersion() =0;
9.27 -
9.28 - /**
9.29 - * @brief Must return a string defining the interface's unique name.
9.30 - */
9.31 - virtual const char *GetInterfaceName() =0;
9.32 -
9.33 - /**
9.34 - * @brief Must return whether the requested version number is backwards comaptible.
9.35 - * Note: This can be overridden for breaking changes or custom versioning.
9.36 - *
9.37 - * @param version Version number to compare against.
9.38 - * @return True if compatible, false otherwise.
9.39 - */
9.40 - virtual bool IsVersionCompatible(unsigned int version)
9.41 - {
9.42 - if (version > GetInterfaceVersion())
9.43 - {
9.44 - return false;
9.45 - }
9.46 -
9.47 - return true;
9.48 - }
9.49 - };
9.50 -
9.51 - /**
9.52 - * @brief Tracks dependencies and fires dependency listeners.
9.53 - */
9.54 - class IShareSys
9.55 - {
9.56 - public:
9.57 - /**
9.58 - * @brief Adds an interface to the global interface system.
9.59 - *
9.60 - * @param myself Object adding this interface, in order to track dependencies.
9.61 - * @param iface Interface pointer (must be unique).
9.62 - * @return True on success, false otherwise.
9.63 - */
9.64 - virtual bool AddInterface(IExtension *myself, SMInterface *iface) =0;
9.65 -
9.66 - /**
9.67 - * @brief Requests an interface from the global interface system.
9.68 - * If found, the interface's internal reference count will be increased.
9.69 - *
9.70 - * @param iface_name Interface name.
9.71 - * @param iface_vers Interface version to attempt to match.
9.72 - * @param myself Object requesting this interface, in order to track dependencies.
9.73 - * @param pIface Pointer to store the return value in.
9.74 - */
9.75 - virtual bool RequestInterface(const char *iface_name,
9.76 - unsigned int iface_vers,
9.77 - IExtension *myself,
9.78 - SMInterface **pIface) =0;
9.79 -
9.80 - /**
9.81 - * @brief Adds a list of natives to the global native pool, to be bound on plugin load.
9.82 - * NOTE: Adding natives currently does not bind them to any loaded plugins.
9.83 - * You must manually bind late natives.
9.84 - *
9.85 - * @param token Identity token of parent object.
9.86 - * @param natives Array of natives to add. The last entry must have NULL members.
9.87 - */
9.88 - virtual void AddNatives(IExtension *myself, const sp_nativeinfo_t *natives) =0;
9.89 -
9.90 - /**
9.91 - * @brief Creates a new identity type.
9.92 - * NOTE: Module authors should never need to use this. Due to the current implementation,
9.93 - * there is a hardcoded limit of 15 types. Core uses up a few, so think carefully!
9.94 - *
9.95 - * @param name String containing type name. Must not be empty or NULL.
9.96 - * @return A new HandleType_t identifier, or 0 on failure.
9.97 - */
9.98 - virtual IdentityType_t CreateIdentType(const char *name) =0;
9.99 -
9.100 - /**
9.101 - * @brief Finds an identity type by name.
9.102 - * DEFAULT IDENTITY TYPES:
9.103 - * "PLUGIN" - An IPlugin object.
9.104 - * "MODULE" - An IModule object.
9.105 - * "CORE" - An SMGlobalClass or other singleton.
9.106 - *
9.107 - * @param name String containing type name to search for.
9.108 - * @return A HandleType_t identifier if found, 0 otherwise.
9.109 - */
9.110 - virtual IdentityType_t FindIdentType(const char *name) =0;
9.111 -
9.112 - /**
9.113 - * @brief Creates a new identity token. This token is guaranteed to be unique
9.114 - * amongst all other open identities.
9.115 - *
9.116 - * @param type Identity type.
9.117 - * @return A new IdentityToken_t identifier.
9.118 - */
9.119 - virtual IdentityToken_t *CreateIdentity(IdentityType_t type) =0;
9.120 -
9.121 - /**
9.122 - * @brief Destroys an identity type. Note that this will delete any identities
9.123 - * that are under this type.
9.124 - *
9.125 - * @param type Identity type.
9.126 - */
9.127 - virtual void DestroyIdentType(IdentityType_t type) =0;
9.128 -
9.129 - /**
9.130 - * @brief Destroys an identity token. Any handles being owned by this token, or
9.131 - * any handles being
9.132 - *
9.133 - * @param identity Identity to remove.
9.134 - */
9.135 - virtual void DestroyIdentity(IdentityToken_t *identity) =0;
9.136 -
9.137 -
9.138 - /**
9.139 - * @brief Requires an extension. This tells SourceMod that without this extension,
9.140 - * your extension should not be loaded. The name should not include the ".dll" or
9.141 - * the ".so" part of the file name.
9.142 - *
9.143 - * @param myself IExtension pointer to yourself.
9.144 - * @param filename File of extension to require.
9.145 - * @param require Whether or not this extension is a required dependency.
9.146 - * @param autoload Whether or not to autoload this extension.
9.147 - */
9.148 - virtual void AddDependency(IExtension *myself, const char *filename, bool require, bool autoload) =0;
9.149 - };
9.150 -};
9.151 -
9.152 -#endif //_INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
10.1 --- a/core/interfaces/ISourceMod.h Fri Jan 19 05:25:43 2007 +0000
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,74 +0,0 @@
10.4 -#ifndef _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
10.5 -#define _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
10.6 -
10.7 -#include <IShareSys.h>
10.8 -
10.9 -#define SMINTERFACE_SOURCEMOD_NAME "ISourceMod"
10.10 -#define SMINTERFACE_SOURCEMOD_VERSION 1
10.11 -
10.12 -namespace SourceMod
10.13 -{
10.14 - enum PathType
10.15 - {
10.16 - Path_None = 0,
10.17 - Path_Game,
10.18 - Path_SM,
10.19 - };
10.20 -
10.21 - class ISourceMod : public SMInterface
10.22 - {
10.23 - public:
10.24 - virtual const char *GetInterfaceName()
10.25 - {
10.26 - return SMINTERFACE_SOURCEMOD_NAME;
10.27 - }
10.28 - virtual unsigned int GetInterfaceVersion()
10.29 - {
10.30 - return SMINTERFACE_SOURCEMOD_VERSION;
10.31 - }
10.32 - public:
10.33 - /**
10.34 - * @brief Returns the full path to the mod directory.
10.35 - *
10.36 - * @return A string containing the full mod path.
10.37 - */
10.38 - virtual const char *GetModPath() =0;
10.39 -
10.40 - /**
10.41 - * @brief Returns the full path to the SourceMod directory.
10.42 - *
10.43 - * @return A string containing the full SourceMod path.
10.44 - */
10.45 - virtual const char *GetSourceModPath() =0;
10.46 -
10.47 - /**
10.48 - * @brief Builds a platform path for a specific target base path.
10.49 - *
10.50 - * @param type Type of path to use as a base.
10.51 - * @param buffer Buffer to write to.
10.52 - * @param maxlength Size of buffer.
10.53 - * @param format Format string.
10.54 - * @param ... Format arguments.
10.55 - * @return Number of bytes written.
10.56 - */
10.57 - virtual size_t BuildPath(PathType type, char *buffer, size_t maxlength, char *format, ...) =0;
10.58 -
10.59 - /**
10.60 - * @brief Logs a message to the SourceMod logs.
10.61 - *
10.62 - * @param format Message format.
10.63 - * @param ... Message format parameters.
10.64 - */
10.65 - virtual void LogMessage(IExtension *pExt, const char *format, ...) =0;
10.66 -
10.67 - /**
10.68 - * @brief Logs a message to the SourceMod error logs.
10.69 - *
10.70 - * @param format Message format.
10.71 - * @param ... Message format parameters.
10.72 - */
10.73 - virtual void LogError(IExtension *pExt, const char *format, ...) =0;
10.74 - };
10.75 -};
10.76 -
10.77 -#endif //_INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
11.1 --- a/core/interfaces/ITextParsers.h Fri Jan 19 05:25:43 2007 +0000
11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
11.3 @@ -1,316 +0,0 @@
11.4 -#ifndef _INCLUDE_SOURCEMOD_TEXTPARSERS_INTERFACE_H_
11.5 -#define _INCLUDE_SOURCEMOD_TEXTPARSERS_INTERFACE_H_
11.6 -
11.7 -#include <IShareSys.h>
11.8 -
11.9 -namespace SourceMod
11.10 -{
11.11 - /**
11.12 - * The INI file format is defined as:
11.13 - * WHITESPACE: 0x20, \n, \t, \r
11.14 - * IDENTIFIER: A-Z a-z 0-9 _ - , + . $ ? /
11.15 - * STRING: Any set of symbols
11.16 - *
11.17 - * Basic syntax is comprised of SECTIONs.
11.18 - * A SECTION is defined as:
11.19 - * [SECTIONNAME]
11.20 - * OPTION
11.21 - * OPTION
11.22 - * OPTION...
11.23 - *
11.24 - * SECTIONNAME is an IDENTIFIER.
11.25 - * OPTION can be repeated any number of times, once per line.
11.26 - * OPTION is defined as one of:
11.27 - * KEY = "VALUE"
11.28 - * KEY = VALUE
11.29 - * KEY
11.30 - * Where KEY is an IDENTIFIER and VALUE is a STRING.
11.31 - *
11.32 - * WHITESPACE should always be omitted.
11.33 - * COMMENTS should be stripped, and are defined as text occuring in:
11.34 - * ;<TEXT>
11.35 - *
11.36 - * Example file below. Note that
11.37 - * The second line is technically invalid. The event handler
11.38 - * must decide whether this should be allowed.
11.39 - * --FILE BELOW--
11.40 - * [gaben]
11.41 - * hi = clams
11.42 - * bye = "NO CLAMS"
11.43 - *
11.44 - * [valve]
11.45 - * cannot
11.46 - * maintain
11.47 - * products
11.48 - */
11.49 - class ITextListener_INI
11.50 - {
11.51 - public:
11.52 - /**
11.53 - * @brief Called when a new section is encountered in an INI file.
11.54 - *
11.55 - * @param section Name of section in between the [ and ] characters.
11.56 - * @param invalid_tokens True if invalid tokens were detected in the name.
11.57 - * @param close_bracket True if a closing bracket was detected, false otherwise.
11.58 - * @param extra_tokens True if extra tokens were detected on the line.
11.59 - * @param curtok Contains current token in the line where the section name starts.
11.60 - * You can add to this offset when failing to point to a token.
11.61 - * @return True to keep parsing, false otherwise.
11.62 - */
11.63 - virtual bool ReadINI_NewSection(const char *section,
11.64 - bool invalid_tokens,
11.65 - bool close_bracket,
11.66 - bool extra_tokens,
11.67 - unsigned int *curtok)
11.68 - {
11.69 - return true;
11.70 - }
11.71 -
11.72 - /**
11.73 - * @brief Called when encountering a key/value pair in an INI file.
11.74 - *
11.75 - * @param key Name of key.
11.76 - * @param value String containing value (with quotes stripped, if any).
11.77 - * @param invalid_tokens Whether or not the key contained invalid tokens.
11.78 - * @param equal_token There was an '=' sign present (in case the value is missing).
11.79 - * @param quotes Whether value was enclosed in quotes.
11.80 - * @param curtoken Contains the token index of the start of the value string.
11.81 - * This can be changed when returning false.
11.82 - * @return True to keep parsing, false otherwise.
11.83 - */
11.84 - virtual bool ReadINI_KeyValue(const char *key,
11.85 - const char *value,
11.86 - bool invalid_tokens,
11.87 - bool equal_token,
11.88 - bool quotes,
11.89 - unsigned int *curtok)
11.90 - {
11.91 - return true;
11.92 - }
11.93 -
11.94 - /**
11.95 - * @brief Called after a line has been preprocessed, if it has text.
11.96 - *
11.97 - * @param line Contents of line.
11.98 - * @param curtok Pointer to optionally store failed position in string.
11.99 - * @return True to keep parsing, false otherwise.
11.100 - */
11.101 - virtual bool ReadINI_RawLine(const char *line, unsigned int *cutok)
11.102 - {
11.103 - return true;
11.104 - }
11.105 - };
11.106 -
11.107 - /**
11.108 - * :TODO: write this in CFG (context free grammar) format so it makes sense
11.109 - *
11.110 - * The SMC file format is defined as:
11.111 - * WHITESPACE: 0x20, \n, \t, \r
11.112 - * IDENTIFIER: Any ASCII character EXCLUDING ", {, }, ;, //, /*, or WHITESPACE.
11.113 - * STRING: Any set of symbols enclosed in quotes.
11.114 - * Note: if a STRING does not have quotes, it is parsed as an IDENTIFIER.
11.115 - *
11.116 - * Basic syntax is comprised of SECTIONBLOCKs.
11.117 - * A SECTIONBLOCK defined as:
11.118 - *
11.119 - * SECTIONNAME
11.120 - * {
11.121 - * OPTION
11.122 - * }
11.123 - *
11.124 - * OPTION can be repeated any number of times inside a SECTIONBLOCK.
11.125 - * A new line will terminate an OPTION, but there can be more than one OPTION per line.
11.126 - * OPTION is defined any of:
11.127 - * "KEY" "VALUE"
11.128 - * SECTIONBLOCK
11.129 - *
11.130 - * SECTIONNAME, KEY, VALUE, and SINGLEKEY are strings
11.131 - * SECTIONNAME cannot have trailing characters if quoted, but the quotes can be optionally removed.
11.132 - * If SECTIONNAME is not enclosed in quotes, the entire sectionname string is used (minus surrounding whitespace).
11.133 - * If KEY is not enclosed in quotes, the key is terminated at first whitespace.
11.134 - * If VALUE is not properly enclosed in quotes, the entire value string is used (minus surrounding whitespace).
11.135 - * The VALUE may have inner quotes, but the key string may not.
11.136 - *
11.137 - * For an example, see configs/permissions.cfg
11.138 - *
11.139 - * WHITESPACE should be ignored.
11.140 - * Comments are text occuring inside the following tokens, and should be stripped
11.141 - * unless they are inside literal strings:
11.142 - * ;<TEXT>
11.143 - * //<TEXT>
11.144 - * /*<TEXT> */
11.145 -
11.146 - enum SMCParseResult
11.147 - {
11.148 - SMCParse_Continue, //continue parsing
11.149 - SMCParse_Halt, //stop parsing here
11.150 - SMCParse_HaltFail //stop parsing and return failure
11.151 - };
11.152 -
11.153 - enum SMCParseError
11.154 - {
11.155 - SMCParse_Okay = 0, //no error
11.156 - SMCParse_StreamOpen, //stream failed to open
11.157 - SMCParse_StreamError, //the stream died... somehow
11.158 - SMCParse_Custom, //a custom handler threw an error
11.159 - SMCParse_InvalidSection1, //a section was declared without quotes, and had extra tokens
11.160 - SMCParse_InvalidSection2, //a section was declared without any header
11.161 - SMCParse_InvalidSection3, //a section ending was declared with too many unknown tokens
11.162 - SMCParse_InvalidSection4, //a section ending has no matching beginning
11.163 - SMCParse_InvalidSection5, //a section beginning has no matching ending
11.164 - SMCParse_InvalidTokens, //there were too many unidentifiable strings on one line
11.165 - SMCParse_TokenOverflow, //the token buffer overflowed
11.166 - SMCParse_InvalidProperty1, //a property was declared outside of any section
11.167 - };
11.168 -
11.169 - class ITextListener_SMC
11.170 - {
11.171 - public:
11.172 - /**
11.173 - * @brief Called when starting parsing.
11.174 - */
11.175 - virtual void ReadSMC_ParseStart()
11.176 - {
11.177 - };
11.178 -
11.179 - /**
11.180 - * @brief Called when ending parsing.
11.181 - *
11.182 - * @param halted True if abnormally halted, false otherwise.
11.183 - * @param failed True if parsing failed, false otherwise.
11.184 - */
11.185 - virtual void ReadSMC_ParseEnd(bool halted, bool failed)
11.186 - {
11.187 - }
11.188 -
11.189 - /**
11.190 - * @brief Called when a warning occurs.
11.191 - * @param error By-reference variable containing the error message of the warning.
11.192 - * @param tokens Pointer to the token stream causing the error.
11.193 - * @return SMCParseResult directive.
11.194 - */
11.195 - virtual SMCParseResult ReadSMC_OnWarning(SMCParseError &error, const char *tokens)
11.196 - {
11.197 - return SMCParse_HaltFail;
11.198 - }
11.199 -
11.200 - /**
11.201 - * @brief Called when entering a new section
11.202 - *
11.203 - * @param name Name of section, with the colon omitted.
11.204 - * @param opt_quotes Whether or not the option string was enclosed in quotes.
11.205 - * @return SMCParseResult directive.
11.206 - */
11.207 - virtual SMCParseResult ReadSMC_NewSection(const char *name, bool opt_quotes)
11.208 - {
11.209 - return SMCParse_Continue;
11.210 - }
11.211 -
11.212 - /**
11.213 - * @brief Called when encountering a key/value pair in a section.
11.214 - *
11.215 - * @param key Key string.
11.216 - * @param value Value string. If no quotes were specified, this will be NULL,
11.217 - and key will contain the entire string.
11.218 - * @param key_quotes Whether or not the key was in quotation marks.
11.219 - * @param value_quotes Whether or not the value was in quotation marks.
11.220 - * @return SMCParseResult directive.
11.221 - */
11.222 - virtual SMCParseResult ReadSMC_KeyValue(const char *key,
11.223 - const char *value,
11.224 - bool key_quotes,
11.225 - bool value_quotes)
11.226 - {
11.227 - return SMCParse_Continue;
11.228 - }
11.229 -
11.230 - /**
11.231 - * @brief Called when leaving the current section.
11.232 - *
11.233 - * @return SMCParseResult directive.
11.234 - */
11.235 - virtual SMCParseResult ReadSMC_LeavingSection()
11.236 - {
11.237 - return SMCParse_Continue;
11.238 - }
11.239 -
11.240 - /**
11.241 - * @brief Called after an input line has been preprocessed.
11.242 - *
11.243 - * @param line String containing line input.
11.244 - * @param curline Number of line in file.
11.245 - * @return SMCParseResult directive.
11.246 - */
11.247 - virtual SMCParseResult ReadSMC_RawLine(const char *line, unsigned int curline)
11.248 - {
11.249 - return SMCParse_Continue;
11.250 - }
11.251 - };
11.252 -
11.253 - #define SMINTERFACE_TEXTPARSERS_NAME "ITextParsers"
11.254 - #define SMINTERFACE_TEXTPARSERS_VERSION 1
11.255 -
11.256 - class ITextParsers : public SMInterface
11.257 - {
11.258 - public:
11.259 - virtual const char *GetInterfaceName()
11.260 - {
11.261 - return SMINTERFACE_TEXTPARSERS_NAME;
11.262 - }
11.263 - virtual unsigned int GetInterfaceVersion()
11.264 - {
11.265 - return SMINTERFACE_TEXTPARSERS_VERSION;
11.266 - }
11.267 - public:
11.268 - /**
11.269 - * @brief Parses an INI-format file.
11.270 - *
11.271 - * @param file Path to file.
11.272 - * @param ini_listener Event handler for reading file.
11.273 - * @param line If non-NULL, will contain last line parsed (0 if file could not be opened).
11.274 - * @param col If non-NULL, will contain last column parsed (undefined if file could not be opened).
11.275 - * @return True if parsing succeded, false if file couldn't be opened or there was a syntax error.
11.276 - */
11.277 - virtual bool ParseFile_INI(const char *file,
11.278 - ITextListener_INI *ini_listener,
11.279 - unsigned int *line,
11.280 - unsigned int *col) =0;
11.281 -
11.282 - /**
11.283 - * @brief Parses an SMC-format text file.
11.284 - * Note that the parser makes every effort to obey broken syntax.
11.285 - * For example, if an open brace is missing, but the section name has a colon,
11.286 - * it will let you know. It is up to the event handlers to decide whether to be strict or not.
11.287 - *
11.288 - * @param file Path to file.
11.289 - * @param smc_listener Event handler for reading file.
11.290 - * @param line If non-NULL, will contain last line parsed (0 if file could not be opened).
11.291 - * @param col If non-NULL, will contain last column parsed (undefined if file could not be opened).
11.292 - * @return An SMCParseError result code.
11.293 - */
11.294 - virtual SMCParseError ParseFile_SMC(const char *file,
11.295 - ITextListener_SMC *smc_listener,
11.296 - unsigned int *line,
11.297 - unsigned int *col) =0;
11.298 -
11.299 - /**
11.300 - * @brief Converts an SMCParseError to a stirng.
11.301 - *
11.302 - * @param err SMCParseError.
11.303 - * @return String error message, or NULL if none.
11.304 - */
11.305 - virtual const char *GetSMCErrorString(SMCParseError err) =0;
11.306 -
11.307 - public:
11.308 - /**
11.309 - * @brief Returns the number of bytes that a multi-byte character contains in a UTF-8 stream.
11.310 - * If the current character is not multi-byte, the function returns 1.
11.311 - *
11.312 - * @param stream Pointer to multi-byte ANSI character string.
11.313 - * @return Number of bytes in current character.
11.314 - */
11.315 - virtual unsigned int GetUTF8CharBytes(const char *stream) =0;
11.316 - };
11.317 -};
11.318 -
11.319 -#endif //_INCLUDE_SOURCEMOD_TEXTPARSERS_INTERFACE_H_
12.1 --- a/core/sm_globals.h Fri Jan 19 05:25:43 2007 +0000
12.2 +++ b/core/sm_globals.h Fri Jan 19 05:33:04 2007 +0000
12.3 @@ -8,7 +8,7 @@
12.4 #include <sp_vm_types.h>
12.5 #include <sp_vm_api.h>
12.6 #include "sm_platform.h"
12.7 -#include "interfaces/IShareSys.h"
12.8 +#include <IShareSys.h>
12.9
12.10 using namespace SourcePawn;
12.11 using namespace SourceMod;
13.1 --- a/core/sm_srvcmds.cpp Fri Jan 19 05:25:43 2007 +0000
13.2 +++ b/core/sm_srvcmds.cpp Fri Jan 19 05:33:04 2007 +0000
13.3 @@ -50,7 +50,7 @@
13.4 size_t len = vsnprintf(buffer, sizeof(buffer), fmt, ap);
13.5 va_end(ap);
13.6
13.7 - if (len >= sizeof(buffer))
13.8 + if (len >= sizeof(buffer) - 1)
13.9 {
13.10 buffer[510] = '\n';
13.11 buffer[511] = '\0';
14.1 --- a/core/systems/ExtensionSys.cpp Fri Jan 19 05:25:43 2007 +0000
14.2 +++ b/core/systems/ExtensionSys.cpp Fri Jan 19 05:33:04 2007 +0000
14.3 @@ -564,6 +564,12 @@
14.4 }
14.5 }
14.6
14.7 +void CExtensionManager::AddDependency(IExtension *pSource, const char *file, bool required, bool autoload)
14.8 +{
14.9 + /* :TODO: implement */
14.10 + return;
14.11 +}
14.12 +
14.13 void CExtensionManager::OnRootConsoleCommand(const char *cmd, unsigned int argcount)
14.14 {
14.15 if (argcount >= 3)
15.1 --- a/core/systems/ExtensionSys.h Fri Jan 19 05:25:43 2007 +0000
15.2 +++ b/core/systems/ExtensionSys.h Fri Jan 19 05:33:04 2007 +0000
15.3 @@ -80,6 +80,7 @@
15.4 void AddNatives(IExtension *pOwner, const sp_nativeinfo_t *natives);
15.5 void BindAllNativesToPlugin(IPlugin *pPlugin);
15.6 void MarkAllLoaded();
15.7 + void AddDependency(IExtension *pSource, const char *file, bool required, bool autoload);
15.8 private:
15.9 CExtension *FindByOrder(unsigned int num);
15.10 private:
16.1 --- a/core/systems/ShareSys.cpp Fri Jan 19 05:25:43 2007 +0000
16.2 +++ b/core/systems/ShareSys.cpp Fri Jan 19 05:33:04 2007 +0000
16.3 @@ -194,3 +194,9 @@
16.4 }
16.5 }
16.6 }
16.7 +
16.8 +void ShareSystem::AddDependency(IExtension *myself, const char *filename, bool require, bool autoload)
16.9 +{
16.10 + g_Extensions.AddDependency(myself, filename, require, autoload);
16.11 +}
16.12 +
17.1 --- a/core/systems/ShareSys.h Fri Jan 19 05:25:43 2007 +0000
17.2 +++ b/core/systems/ShareSys.h Fri Jan 19 05:33:04 2007 +0000
17.3 @@ -42,6 +42,7 @@
17.4 IdentityToken_t *CreateIdentity(IdentityType_t type);
17.5 void DestroyIdentType(IdentityType_t type);
17.6 void DestroyIdentity(IdentityToken_t *identity);
17.7 + void AddDependency(IExtension *myself, const char *filename, bool require, bool autoload);
17.8 public: //SMGlobalClass
17.9 /* Pre-empt in case anything tries to register idents early */
17.10 void OnSourceModStartup(bool late);
18.1 --- a/extensions/sdk/extension.cpp Fri Jan 19 05:25:43 2007 +0000
18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
18.3 @@ -1,5 +0,0 @@
18.4 -#include "extension.h"
18.5 -
18.6 -Sample g_Sample;
18.7 -
18.8 -SMEXT_LINK(&g_Sample);
19.1 --- a/extensions/sdk/extension.h Fri Jan 19 05:25:43 2007 +0000
19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
19.3 @@ -1,59 +0,0 @@
19.4 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
19.5 -#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
19.6 -
19.7 -#include "smsdk_ext.h"
19.8 -
19.9 -/**
19.10 - * @brief Sample implementation of the SDK Extension.
19.11 - * Note: Uncomment one of the pre-defined virtual functions in order to use it.
19.12 - */
19.13 -class Sample : public SDKExtension
19.14 -{
19.15 -public:
19.16 - /**
19.17 - * @brief This is called after the initial loading sequence has been processed.
19.18 - *
19.19 - * @param error Error message buffer.
19.20 - * @param err_max Size of error message buffer.
19.21 - * @param late Whether or not the module was loaded after map load.
19.22 - * @return True to succeed loading, false to fail.
19.23 - */
19.24 - //virtual bool SDK_OnLoad(char *error, size_t err_max, bool late);
19.25 -
19.26 - /**
19.27 - * @brief This is called right before the extension is unloaded.
19.28 - */
19.29 - //virtual void SDK_OnUnload();
19.30 -
19.31 - /**
19.32 - * @brief This is called once all known extensions have been loaded.
19.33 - * Note: It is is a good idea to add natives here, if any are provided.
19.34 - */
19.35 - //virtual void SDK_OnAllLoaded();
19.36 -
19.37 - /**
19.38 - * @brief Called when the pause state is changed.
19.39 - */
19.40 - //virtual void SDK_OnPauseChange(bool paused);
19.41 -
19.42 - /**
19.43 - * @brief this is called when Core wants to know if your extension is working.
19.44 - *
19.45 - * @param error Error message buffer.
19.46 - * @param err_max Size of error message buffer.
19.47 - * @return True if working, false otherwise.
19.48 - */
19.49 - //virtual void QueryRunning(char *error, size_t maxlength);
19.50 -public:
19.51 -#if defined SMEXT_CONF_METAMOD
19.52 - /**
19.53 - * Read smext_base.h for documentation on these.
19.54 - */
19.55 -
19.56 - //virtual bool SDK_OnMetamodLoad(char *error, size_t err_max, bool late);
19.57 - //virtual bool SDK_OnMetamodUnload(char *error, size_t err_max);
19.58 - //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max);
19.59 -#endif
19.60 -};
19.61 -
19.62 -#endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
20.1 --- a/extensions/sdk/sdk.sln Fri Jan 19 05:25:43 2007 +0000
20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
20.3 @@ -1,26 +0,0 @@
20.4 -
20.5 -Microsoft Visual Studio Solution File, Format Version 9.00
20.6 -# Visual Studio 2005
20.7 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdk", "sdk.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
20.8 -EndProject
20.9 -Global
20.10 - GlobalSection(SolutionConfigurationPlatforms) = preSolution
20.11 - Debug - Metamod|Win32 = Debug - Metamod|Win32
20.12 - Debug|Win32 = Debug|Win32
20.13 - Release - Metamod|Win32 = Release - Metamod|Win32
20.14 - Release|Win32 = Release|Win32
20.15 - EndGlobalSection
20.16 - GlobalSection(ProjectConfigurationPlatforms) = postSolution
20.17 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Metamod|Win32.ActiveCfg = Debug - Metamod|Win32
20.18 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Metamod|Win32.Build.0 = Debug - Metamod|Win32
20.19 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32
20.20 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32
20.21 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Metamod|Win32.ActiveCfg = Release - Metamod|Win32
20.22 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Metamod|Win32.Build.0 = Release - Metamod|Win32
20.23 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32
20.24 - {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32
20.25 - EndGlobalSection
20.26 - GlobalSection(SolutionProperties) = preSolution
20.27 - HideSolutionNode = FALSE
20.28 - EndGlobalSection
20.29 -EndGlobal
21.1 --- a/extensions/sdk/sdk.vcproj Fri Jan 19 05:25:43 2007 +0000
21.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
21.3 @@ -1,368 +0,0 @@
21.4 -<?xml version="1.0" encoding="Windows-1252"?>
21.5 -<VisualStudioProject
21.6 - ProjectType="Visual C++"
21.7 - Version="8.00"
21.8 - Name="sdk"
21.9 - ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
21.10 - RootNamespace="sdk"
21.11 - Keyword="Win32Proj"
21.12 - >
21.13 - <Platforms>
21.14 - <Platform
21.15 - Name="Win32"
21.16 - />
21.17 - </Platforms>
21.18 - <ToolFiles>
21.19 - </ToolFiles>
21.20 - <Configurations>
21.21 - <Configuration
21.22 - Name="Debug|Win32"
21.23 - OutputDirectory="$(SolutionDir)$(ConfigurationName)"
21.24 - IntermediateDirectory="$(ConfigurationName)"
21.25 - ConfigurationType="2"
21.26 - CharacterSet="2"
21.27 - >
21.28 - <Tool
21.29 - Name="VCPreBuildEventTool"
21.30 - />
21.31 - <Tool
21.32 - Name="VCCustomBuildTool"
21.33 - />
21.34 - <Tool
21.35 - Name="VCXMLDataGeneratorTool"
21.36 - />
21.37 - <Tool
21.38 - Name="VCWebServiceProxyGeneratorTool"
21.39 - />
21.40 - <Tool
21.41 - Name="VCMIDLTool"
21.42 - />
21.43 - <Tool
21.44 - Name="VCCLCompilerTool"
21.45 - Optimization="0"
21.46 - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
21.47 - MinimalRebuild="true"
21.48 - BasicRuntimeChecks="3"
21.49 - RuntimeLibrary="1"
21.50 - UsePrecompiledHeader="0"
21.51 - WarningLevel="3"
21.52 - Detect64BitPortabilityProblems="true"
21.53 - DebugInformationFormat="4"
21.54 - />
21.55 - <Tool
21.56 - Name="VCManagedResourceCompilerTool"
21.57 - />
21.58 - <Tool
21.59 - Name="VCResourceCompilerTool"
21.60 - />
21.61 - <Tool
21.62 - Name="VCPreLinkEventTool"
21.63 - />
21.64 - <Tool
21.65 - Name="VCLinkerTool"
21.66 - OutputFile="$(OutDir)\sample.ext.dll"
21.67 - LinkIncremental="2"
21.68 - GenerateDebugInformation="true"
21.69 - SubSystem="2"
21.70 - TargetMachine="1"
21.71 - />
21.72 - <Tool
21.73 - Name="VCALinkTool"
21.74 - />
21.75 - <Tool
21.76 - Name="VCManifestTool"
21.77 - />
21.78 - <Tool
21.79 - Name="VCXDCMakeTool"
21.80 - />
21.81 - <Tool
21.82 - Name="VCBscMakeTool"
21.83 - />
21.84 - <Tool
21.85 - Name="VCFxCopTool"
21.86 - />
21.87 - <Tool
21.88 - Name="VCAppVerifierTool"
21.89 - />
21.90 - <Tool
21.91 - Name="VCWebDeploymentTool"
21.92 - />
21.93 - <Tool
21.94 - Name="VCPostBuildEventTool"
21.95 - />
21.96 - </Configuration>
21.97 - <Configuration
21.98 - Name="Release|Win32"
21.99 - OutputDirectory="$(SolutionDir)$(ConfigurationName)"
21.100 - IntermediateDirectory="$(ConfigurationName)"
21.101 - ConfigurationType="2"
21.102 - CharacterSet="1"
21.103 - WholeProgramOptimization="1"
21.104 - >
21.105 - <Tool
21.106 - Name="VCPreBuildEventTool"
21.107 - />
21.108 - <Tool
21.109 - Name="VCCustomBuildTool"
21.110 - />
21.111 - <Tool
21.112 - Name="VCXMLDataGeneratorTool"
21.113 - />
21.114 - <Tool
21.115 - Name="VCWebServiceProxyGeneratorTool"
21.116 - />
21.117 - <Tool
21.118 - Name="VCMIDLTool"
21.119 - />
21.120 - <Tool
21.121 - Name="VCCLCompilerTool"
21.122 - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
21.123 - RuntimeLibrary="0"
21.124 - UsePrecompiledHeader="0"
21.125 - WarningLevel="3"
21.126 - Detect64BitPortabilityProblems="true"
21.127 - DebugInformationFormat="3"
21.128 - />
21.129 - <Tool
21.130 - Name="VCManagedResourceCompilerTool"
21.131 - />
21.132 - <Tool
21.133 - Name="VCResourceCompilerTool"
21.134 - />
21.135 - <Tool
21.136 - Name="VCPreLinkEventTool"
21.137 - />
21.138 - <Tool
21.139 - Name="VCLinkerTool"
21.140 - OutputFile="$(OutDir)\sample.ext.dll"
21.141 - LinkIncremental="1"
21.142 - GenerateDebugInformation="true"
21.143 - SubSystem="2"
21.144 - OptimizeReferences="2"
21.145 - EnableCOMDATFolding="2"
21.146 - TargetMachine="1"
21.147 - />
21.148 - <Tool
21.149 - Name="VCALinkTool"
21.150 - />
21.151 - <Tool
21.152 - Name="VCManifestTool"
21.153 - />
21.154 - <Tool
21.155 - Name="VCXDCMakeTool"
21.156 - />
21.157 - <Tool
21.158 - Name="VCBscMakeTool"
21.159 - />
21.160 - <Tool
21.161 - Name="VCFxCopTool"
21.162 - />
21.163 - <Tool
21.164 - Name="VCAppVerifierTool"
21.165 - />
21.166 - <Tool
21.167 - Name="VCWebDeploymentTool"
21.168 - />
21.169 - <Tool
21.170 - Name="VCPostBuildEventTool"
21.171 - />
21.172 - </Configuration>
21.173 - <Configuration
21.174 - Name="Debug - Metamod|Win32"
21.175 - OutputDirectory="$(SolutionDir)$(ConfigurationName)"
21.176 - IntermediateDirectory="$(ConfigurationName)"
21.177 - ConfigurationType="2"
21.178 - CharacterSet="2"
21.179 - >
21.180 - <Tool
21.181 - Name="VCPreBuildEventTool"
21.182 - />
21.183 - <Tool
21.184 - Name="VCCustomBuildTool"
21.185 - />
21.186 - <Tool
21.187 - Name="VCXMLDataGeneratorTool"
21.188 - />
21.189 - <Tool
21.190 - Name="VCWebServiceProxyGeneratorTool"
21.191 - />
21.192 - <Tool
21.193 - Name="VCMIDLTool"
21.194 - />
21.195 - <Tool
21.196 - Name="VCCLCompilerTool"
21.197 - Optimization="0"
21.198 - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SMEXT_CONF_METAMOD"
21.199 - MinimalRebuild="true"
21.200 - BasicRuntimeChecks="3"
21.201 - RuntimeLibrary="1"
21.202 - UsePrecompiledHeader="0"
21.203 - WarningLevel="3"
21.204 - Detect64BitPortabilityProblems="true"
21.205 - DebugInformationFormat="4"
21.206 - />
21.207 - <Tool
21.208 - Name="VCManagedResourceCompilerTool"
21.209 - />
21.210 - <Tool
21.211 - Name="VCResourceCompilerTool"
21.212 - />
21.213 - <Tool
21.214 - Name="VCPreLinkEventTool"
21.215 - />
21.216 - <Tool
21.217 - Name="VCLinkerTool"
21.218 - AdditionalDependencies="tier0.lib"
21.219 - OutputFile="$(OutDir)\sample.ext.dll"
21.220 - LinkIncremental="2"
21.221 - GenerateDebugInformation="true"
21.222 - SubSystem="2"
21.223 - TargetMachine="1"
21.224 - />
21.225 - <Tool
21.226 - Name="VCALinkTool"
21.227 - />
21.228 - <Tool
21.229 - Name="VCManifestTool"
21.230 - />
21.231 - <Tool
21.232 - Name="VCXDCMakeTool"
21.233 - />
21.234 - <Tool
21.235 - Name="VCBscMakeTool"
21.236 - />
21.237 - <Tool
21.238 - Name="VCFxCopTool"
21.239 - />
21.240 - <Tool
21.241 - Name="VCAppVerifierTool"
21.242 - />
21.243 - <Tool
21.244 - Name="VCWebDeploymentTool"
21.245 - />
21.246 - <Tool
21.247 - Name="VCPostBuildEventTool"
21.248 - />
21.249 - </Configuration>
21.250 - <Configuration
21.251 - Name="Release - Metamod|Win32"
21.252 - OutputDirectory="$(SolutionDir)$(ConfigurationName)"
21.253 - IntermediateDirectory="$(ConfigurationName)"
21.254 - ConfigurationType="2"
21.255 - CharacterSet="1"
21.256 - WholeProgramOptimization="1"
21.257 - >
21.258 - <Tool
21.259 - Name="VCPreBuildEventTool"
21.260 - />
21.261 - <Tool
21.262 - Name="VCCustomBuildTool"
21.263 - />
21.264 - <Tool
21.265 - Name="VCXMLDataGeneratorTool"
21.266 - />
21.267 - <Tool
21.268 - Name="VCWebServiceProxyGeneratorTool"
21.269 - />
21.270 - <Tool
21.271 - Name="VCMIDLTool"
21.272 - />
21.273 - <Tool
21.274 - Name="VCCLCompilerTool"
21.275 - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SMEXT_CONF_METAMOD"
21.276 - RuntimeLibrary="0"
21.277 - UsePrecompiledHeader="0"
21.278 - WarningLevel="3"
21.279 - Detect64BitPortabilityProblems="true"
21.280 - DebugInformationFormat="3"
21.281 - />
21.282 - <Tool
21.283 - Name="VCManagedResourceCompilerTool"
21.284 - />
21.285 - <Tool
21.286 - Name="VCResourceCompilerTool"
21.287 - />
21.288 - <Tool
21.289 - Name="VCPreLinkEventTool"
21.290 - />
21.291 - <Tool
21.292 - Name="VCLinkerTool"
21.293 - OutputFile="$(OutDir)\sample.ext.dll"
21.294 - LinkIncremental="1"
21.295 - GenerateDebugInformation="true"
21.296 - SubSystem="2"
21.297 - OptimizeReferences="2"
21.298 - EnableCOMDATFolding="2"
21.299 - TargetMachine="1"
21.300 - />
21.301 - <Tool
21.302 - Name="VCALinkTool"
21.303 - />
21.304 - <Tool
21.305 - Name="VCManifestTool"
21.306 - />
21.307 - <Tool
21.308 - Name="VCXDCMakeTool"
21.309 - />
21.310 - <Tool
21.311 - Name="VCBscMakeTool"
21.312 - />
21.313 - <Tool
21.314 - Name="VCFxCopTool"
21.315 - />
21.316 - <Tool
21.317 - Name="VCAppVerifierTool"
21.318 - />
21.319 - <Tool
21.320 - Name="VCWebDeploymentTool"
21.321 - />
21.322 - <Tool
21.323 - Name="VCPostBuildEventTool"
21.324 - />
21.325 - </Configuration>
21.326 - </Configurations>
21.327 - <References>
21.328 - </References>
21.329 - <Files>
21.330 - <Filter
21.331 - Name="Source Files"
21.332 - Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
21.333 - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
21.334 - >
21.335 - <File
21.336 - RelativePath=".\extension.cpp"
21.337 - >
21.338 - </File>
21.339 - <File
21.340 - RelativePath=".\smsdk_ext.cpp"
21.341 - >
21.342 - </File>
21.343 - </Filter>
21.344 - <Filter
21.345 - Name="Header Files"
21.346 - Filter="h;hpp;hxx;hm;inl;inc;xsd"
21.347 - UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
21.348 - >
21.349 - <File
21.350 - RelativePath=".\extension.h"
21.351 - >
21.352 - </File>
21.353 - <File
21.354 - RelativePath=".\smsdk_config.h"
21.355 - >
21.356 - </File>
21.357 - <File
21.358 - RelativePath=".\smsdk_ext.h"
21.359 - >
21.360 - </File>
21.361 - </Filter>
21.362 - <Filter
21.363 - Name="Resource Files"
21.364 - Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
21.365 - UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
21.366 - >
21.367 - </Filter>
21.368 - </Files>
21.369 - <Globals>
21.370 - </Globals>
21.371 -</VisualStudioProject>
22.1 --- a/extensions/sdk/smsdk_config.h Fri Jan 19 05:25:43 2007 +0000
22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
22.3 @@ -1,27 +0,0 @@
22.4 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
22.5 -#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
22.6 -
22.7 -/* Basic information exposed publically */
22.8 -#define SMEXT_CONF_NAME "Sample Extension"
22.9 -#define SMEXT_CONF_DESCRIPTION "Sample extension to help developers"
22.10 -#define SMEXT_CONF_VERSION "0.0.0.0"
22.11 -#define SMEXT_CONF_AUTHOR "AlliedModders"
22.12 -#define SMEXT_CONF_URL "http://www.sourcemod.net/"
22.13 -#define SMEXT_CONF_LOGTAG "SAMPLE"
22.14 -#define SMEXT_CONF_LICENSE "GPL"
22.15 -#define SMEXT_CONF_DATESTRING __DATE__
22.16 -
22.17 -/**
22.18 - * @brief Exposes plugin's main interface.
22.19 - */
22.20 -#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
22.21 -
22.22 -/**
22.23 - * @brief Sets whether or not this plugin required Metamod.
22.24 - * NOTE: Uncomment to enable, comment to disable.
22.25 - * NOTE: This is enabled automatically if a Metamod build is chosen in
22.26 - * the Visual Studio project.
22.27 - */
22.28 -//#define SMEXT_CONF_METAMOD
22.29 -
22.30 -#endif //_INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
23.1 --- a/extensions/sdk/smsdk_ext.cpp Fri Jan 19 05:25:43 2007 +0000
23.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
23.3 @@ -1,279 +0,0 @@
23.4 -#include <stdio.h>
23.5 -#include "smsdk_ext.h"
23.6 -
23.7 -IShareSys *g_pShareSys = NULL;
23.8 -IExtension *myself = NULL;
23.9 -IHandleSys *g_pHandleSys = NULL;
23.10 -ISourceMod *g_pSM = NULL;
23.11 -
23.12 -PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
23.13 -{
23.14 - return g_pExtensionIface;
23.15 -}
23.16 -
23.17 -SDKExtension::SDKExtension()
23.18 -{
23.19 -#if defined SMEXT_CONF_METAMOD
23.20 - m_SourceMMLoaded = false;
23.21 - m_WeAreUnloaded = false;
23.22 - m_WeGotPauseChange = false;
23.23 -#endif
23.24 -}
23.25 -
23.26 -bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late)
23.27 -{
23.28 - g_pShareSys = sys;
23.29 - myself = me;
23.30 -
23.31 -#if defined SMEXT_CONF_METAMOD
23.32 - m_WeAreUnloaded = true;
23.33 -
23.34 - if (!m_SourceMMLoaded)
23.35 - {
23.36 - if (error)
23.37 - {
23.38 - snprintf(error, err_max, "Metamod attach failed");
23.39 - }
23.40 - return false;
23.41 - }
23.42 -#endif
23.43 -
23.44 - SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
23.45 - SM_GET_IFACE(SOURCEMOD, g_pSM);
23.46 -
23.47 - if (SDK_OnLoad(error, err_max, late))
23.48 - {
23.49 -#if defined SMEXT_CONF_METAMOD
23.50 - m_WeAreUnloaded = true;
23.51 -#endif
23.52 - return true;
23.53 - }
23.54 -
23.55 - return false;
23.56 -}
23.57 -
23.58 -bool SDKExtension::IsMetamodExtension()
23.59 -{
23.60 -#if defined SMEXT_CONF_METAMOD
23.61 - return true;
23.62 -#else
23.63 - return false;
23.64 -#endif
23.65 -}
23.66 -
23.67 -void SDKExtension::OnExtensionPauseChange(bool state)
23.68 -{
23.69 -#if defined SMEXT_CONF_METAMOD
23.70 - m_WeGotPauseChange = true;
23.71 -#endif
23.72 - SDK_OnPauseChange(state);
23.73 -}
23.74 -
23.75 -void SDKExtension::OnExtensionsAllLoaded()
23.76 -{
23.77 - SDK_OnAllLoaded();
23.78 -}
23.79 -
23.80 -void SDKExtension::OnExtensionUnload()
23.81 -{
23.82 -#if defined SMEXT_CONF_METAMOD
23.83 - m_WeAreUnloaded = true;
23.84 -#endif
23.85 - SDK_OnUnload();
23.86 -}
23.87 -
23.88 -const char *SDKExtension::GetExtensionAuthor()
23.89 -{
23.90 - return SMEXT_CONF_AUTHOR;
23.91 -}
23.92 -
23.93 -const char *SDKExtension::GetExtensionDateString()
23.94 -{
23.95 - return SMEXT_CONF_DATESTRING;
23.96 -}
23.97 -
23.98 -const char *SDKExtension::GetExtensionDescription()
23.99 -{
23.100 - return SMEXT_CONF_DESCRIPTION;
23.101 -}
23.102 -
23.103 -const char *SDKExtension::GetExtensionVerString()
23.104 -{
23.105 - return SMEXT_CONF_VERSION;
23.106 -}
23.107 -
23.108 -const char *SDKExtension::GetExtensionName()
23.109 -{
23.110 - return SMEXT_CONF_NAME;
23.111 -}
23.112 -
23.113 -const char *SDKExtension::GetExtensionTag()
23.114 -{
23.115 - return SMEXT_CONF_LOGTAG;
23.116 -}
23.117 -
23.118 -const char *SDKExtension::GetExtensionURL()
23.119 -{
23.120 - return SMEXT_CONF_URL;
23.121 -}
23.122 -
23.123 -bool SDKExtension::SDK_OnLoad(char *error, size_t err_max, bool late)
23.124 -{
23.125 - return true;
23.126 -}
23.127 -
23.128 -void SDKExtension::SDK_OnUnload()
23.129 -{
23.130 -}
23.131 -
23.132 -void SDKExtension::SDK_OnPauseChange(bool paused)
23.133 -{
23.134 -}
23.135 -
23.136 -void SDKExtension::SDK_OnAllLoaded()
23.137 -{
23.138 -}
23.139 -
23.140 -#if defined SMEXT_CONF_METAMOD
23.141 -
23.142 -PluginId g_PLID = 0;
23.143 -ISmmPlugin *g_PLAPI = NULL;
23.144 -SourceHook::ISourceHook *g_SHPtr = NULL;
23.145 -ISmmAPI *g_SMAPI = NULL;
23.146 -
23.147 -IVEngineServer *engine = NULL;
23.148 -IServerGameDLL *gamedll = NULL;
23.149 -
23.150 -SMM_API void *PL_EXPOSURE(const char *name, int *code)
23.151 -{
23.152 - if (name && !strcmp(name, PLAPI_NAME))
23.153 - {
23.154 - if (code)
23.155 - {
23.156 - *code = IFACE_OK;
23.157 - }
23.158 - return static_cast<void *>(g_pExtensionIface);
23.159 - }
23.160 -
23.161 - if (code)
23.162 - {
23.163 - *code = IFACE_FAILED;
23.164 - }
23.165 -
23.166 - return NULL;
23.167 -}
23.168 -
23.169 -bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
23.170 -{
23.171 - PLUGIN_SAVEVARS();
23.172 -
23.173 - GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
23.174 - GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
23.175 -
23.176 - m_SourceMMLoaded = true;
23.177 -
23.178 - return SDK_OnMetamodLoad(error, maxlen, late);
23.179 -}
23.180 -
23.181 -bool SDKExtension::Unload(char *error, size_t maxlen)
23.182 -{
23.183 - if (!m_WeAreUnloaded)
23.184 - {
23.185 - if (error)
23.186 - {
23.187 - snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
23.188 - }
23.189 - return false;
23.190 - }
23.191 -
23.192 - return SDK_OnMetamodUnload(error, maxlen);
23.193 -}
23.194 -
23.195 -bool SDKExtension::Pause(char *error, size_t maxlen)
23.196 -{
23.197 - if (!m_WeGotPauseChange)
23.198 - {
23.199 - if (error)
23.200 - {
23.201 - snprintf(error, maxlen, "This extension must be paused by SourceMod.");
23.202 - }
23.203 - return false;
23.204 - }
23.205 -
23.206 - m_WeGotPauseChange = false;
23.207 -
23.208 - return SDK_OnMetamodPauseChange(true, error, maxlen);
23.209 -}
23.210 -
23.211 -bool SDKExtension::Unpause(char *error, size_t maxlen)
23.212 -{
23.213 - if (!m_WeGotPauseChange)
23.214 - {
23.215 - if (error)
23.216 - {
23.217 - snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
23.218 - }
23.219 - return false;
23.220 - }
23.221 -
23.222 - m_WeGotPauseChange = false;
23.223 -
23.224 - return SDK_OnMetamodPauseChange(false, error, maxlen);
23.225 -}
23.226 -
23.227 -const char *SDKExtension::GetAuthor()
23.228 -{
23.229 - return GetExtensionAuthor();
23.230 -}
23.231 -
23.232 -const char *SDKExtension::GetDate()
23.233 -{
23.234 - return GetExtensionDateString();
23.235 -}
23.236 -
23.237 -const char *SDKExtension::GetDescription()
23.238 -{
23.239 - return GetExtensionDescription();
23.240 -}
23.241 -
23.242 -const char *SDKExtension::GetLicense()
23.243 -{
23.244 - return SMEXT_CONF_LICENSE;
23.245 -}
23.246 -
23.247 -const char *SDKExtension::GetLogTag()
23.248 -{
23.249 - return GetExtensionTag();
23.250 -}
23.251 -
23.252 -const char *SDKExtension::GetName()
23.253 -{
23.254 - return GetExtensionName();
23.255 -}
23.256 -
23.257 -const char *SDKExtension::GetURL()
23.258 -{
23.259 - return GetExtensionURL();
23.260 -}
23.261 -
23.262 -const char *SDKExtension::GetVersion()
23.263 -{
23.264 - return GetExtensionVerString();
23.265 -}
23.266 -
23.267 -bool SDKExtension::SDK_OnMetamodLoad(char *error, size_t err_max, bool late)
23.268 -{
23.269 - return true;
23.270 -}
23.271 -
23.272 -bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t err_max)
23.273 -{
23.274 - return true;
23.275 -}
23.276 -
23.277 -bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max)
23.278 -{
23.279 - return true;
23.280 -}
23.281 -
23.282 -#endif
24.1 --- a/extensions/sdk/smsdk_ext.h Fri Jan 19 05:25:43 2007 +0000
24.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
24.3 @@ -1,142 +0,0 @@
24.4 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
24.5 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
24.6 -
24.7 -#include "smsdk_config.h"
24.8 -#include <IExtensionSys.h>
24.9 -#include <IHandleSys.h>
24.10 -#include <sp_vm_api.h>
24.11 -#include <sm_platform.h>
24.12 -#include <ISourceMod.h>
24.13 -
24.14 -#if defined SMEXT_CONF_METAMOD
24.15 -#include <ISmmPlugin.h>
24.16 -#include <eiface.h>
24.17 -#endif
24.18 -
24.19 -using namespace SourceMod;
24.20 -using namespace SourcePawn;
24.21 -
24.22 -class SDKExtension :
24.23 -#if defined SMEXT_CONF_METAMOD
24.24 - public ISmmPlugin,
24.25 -#endif
24.26 - public IExtensionInterface
24.27 -{
24.28 -public:
24.29 - SDKExtension();
24.30 -public:
24.31 - /**
24.32 - * @brief This is called after the initial loading sequence has been processed.
24.33 - *
24.34 - * @param error Error message buffer.
24.35 - * @param err_max Size of error message buffer.
24.36 - * @param late Whether or not the module was loaded after map load.
24.37 - * @return True to succeed loading, false to fail.
24.38 - */
24.39 - virtual bool SDK_OnLoad(char *error, size_t err_max, bool late);
24.40 -
24.41 - /**
24.42 - * @brief This is called right before the extension is unloaded.
24.43 - */
24.44 - virtual void SDK_OnUnload();
24.45 -
24.46 - /**
24.47 - * @brief This is called once all known extensions have been loaded.
24.48 - */
24.49 - virtual void SDK_OnAllLoaded();
24.50 -
24.51 - /**
24.52 - * @brief Called when the pause state is changed.
24.53 - */
24.54 - virtual void SDK_OnPauseChange(bool paused);
24.55 -
24.56 -#if defined SMEXT_CONF_METAMOD
24.57 - /**
24.58 - * @brief Called when Metamod is attached, before the extension version is called.
24.59 - *
24.60 - * @param error Error buffer.
24.61 - * @param err_max Maximum size of error buffer.
24.62 - * @param late Whether or not Metamod considers this a late load.
24.63 - * @return True to succeed, false to fail.
24.64 - */
24.65 - virtual bool SDK_OnMetamodLoad(char *error, size_t err_max, bool late);
24.66 -
24.67 - /**
24.68 - * @brief Called when Metamod is detaching, after the extension version is called.
24.69 - * NOTE: By default this is blocked unless sent from SourceMod.
24.70 - *
24.71 - * @param error Error buffer.
24.72 - * @param err_max Maximum size of error buffer.
24.73 - * @return True to succeed, false to fail.
24.74 - */
24.75 - virtual bool SDK_OnMetamodUnload(char *error, size_t err_max);
24.76 -
24.77 - /**
24.78 - * @brief Called when Metamod's pause state is changing.
24.79 - * NOTE: By default this is blocked unless sent from SourceMod.
24.80 - *
24.81 - * @param paused Pause state being set.
24.82 - * @param error Error buffer.
24.83 - * @param err_max Maximum size of error buffer.
24.84 - * @return True to succeed, false to fail.
24.85 - */
24.86 - virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max);
24.87 -#endif
24.88 -
24.89 -public: //IExtensionInterface
24.90 - virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late);
24.91 - virtual void OnExtensionUnload();
24.92 - virtual void OnExtensionsAllLoaded();
24.93 - virtual bool IsMetamodExtension();
24.94 - virtual void OnExtensionPauseChange(bool state);
24.95 - virtual const char *GetExtensionName();
24.96 - virtual const char *GetExtensionURL();
24.97 - virtual const char *GetExtensionTag();
24.98 - virtual const char *GetExtensionAuthor();
24.99 - virtual const char *GetExtensionVerString();
24.100 - virtual const char *GetExtensionDescription();
24.101 - virtual const char *GetExtensionDateString();
24.102 -#if defined SMEXT_CONF_METAMOD
24.103 -public: //ISmmPlugin
24.104 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
24.105 - virtual const char *GetAuthor();
24.106 - virtual const char *GetName();
24.107 - virtual const char *GetDescription();
24.108 - virtual const char *GetURL();
24.109 - virtual const char *GetLicense();
24.110 - virtual const char *GetVersion();
24.111 - virtual const char *GetDate();
24.112 - virtual const char *GetLogTag();
24.113 - virtual bool Unload(char *error, size_t maxlen);
24.114 - virtual bool Pause(char *error, size_t maxlen);
24.115 - virtual bool Unpause(char *error, size_t maxlen);
24.116 -private:
24.117 - bool m_SourceMMLoaded;
24.118 - bool m_WeAreUnloaded;
24.119 - bool m_WeGotPauseChange;
24.120 -#endif
24.121 -};
24.122 -
24.123 -extern SDKExtension *g_pExtensionIface;
24.124 -
24.125 -extern IShareSys *g_pShareSys;
24.126 -extern IExtension *myself;
24.127 -extern IHandleSys *g_pHandleSys;
24.128 -extern ISourceMod *g_pSM;
24.129 -
24.130 -#if defined SMEXT_CONF_METAMOD
24.131 -PLUGIN_GLOBALVARS();
24.132 -extern IVEngineServer *engine;
24.133 -extern IServerGameDLL *gamedll;
24.134 -#endif
24.135 -
24.136 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
24.137 -#define SM_GET_IFACE(prefix,addr) \
24.138 - if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) { \
24.139 - if (error) { \
24.140 - snprintf(error, err_max, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
24.141 - } \
24.142 - return false; \
24.143 - }
24.144 -
24.145 -#endif //_INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
25.2 +++ b/public/IExtensionSys.h Fri Jan 19 05:33:04 2007 +0000
25.3 @@ -0,0 +1,217 @@
25.4 +#ifndef _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
25.5 +#define _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
25.6 +
25.7 +#include <IShareSys.h>
25.8 +#include <ILibrarySys.h>
25.9 +
25.10 +namespace SourceMod
25.11 +{
25.12 + class IExtensionInterface;
25.13 + typedef void * ITERATOR;
25.14 +
25.15 + /**
25.16 + * @brief Encapsulates an IExtension.
25.17 + */
25.18 + class IExtension
25.19 + {
25.20 + public:
25.21 + /**
25.22 + * @brief Returns whether or not the extension is properly loaded.
25.23 + */
25.24 + virtual bool IsLoaded() =0;
25.25 +
25.26 + /**
25.27 + * @brief Returns the extension's API interface
25.28 + *
25.29 + * @return An IExtensionInterface pointer.
25.30 + */
25.31 + virtual IExtensionInterface *GetAPI() =0;
25.32 +
25.33 + /**
25.34 + * @brief Returns the filename of the extension, relative to the
25.35 + * extension folder.
25.36 + *
25.37 + * @return A string containing the extension file name.
25.38 + */
25.39 + virtual const char *GetFilename() =0;
25.40 +
25.41 + /**
25.42 + * @brief Returns the extension's identity token.
25.43 + *
25.44 + * @return An IdentityToken_t pointer.
25.45 + */
25.46 + virtual IdentityToken_t *GetIdentity() =0;
25.47 +
25.48 + /**
25.49 + * @brief Retrieves the extension dependency list for this extension.
25.50 + *
25.51 + * @param pOwner Optional pointer to store the first interface's owner.
25.52 + * @param pInterface Optional pointer to store the first interface.
25.53 + * @return An ITERATOR pointer for the results, or NULL if no results at all.
25.54 + */
25.55 + virtual ITERATOR *FindFirstDependency(IExtension **pOwner, SMInterface **pInterface) =0;
25.56 +
25.57 + /**
25.58 + * @brief Finds the next dependency in the dependency list.
25.59 + *
25.60 + * @param iter Pointer to iterator from FindFirstDependency.
25.61 + * @param pOwner Optional pointer to store the interface's owner.
25.62 + * @param pInterface Optional pointer to store the interface.
25.63 + * @return True if there are more results after this, false otherwise.
25.64 + */
25.65 + virtual bool FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface) =0;
25.66 +
25.67 + /**
25.68 + * @brief Frees an ITERATOR handle from FindFirstDependency.
25.69 + *
25.70 + * @param iter Pointer to iterator to free.
25.71 + */
25.72 + virtual void FreeDependencyIterator(ITERATOR *iter) =0;
25.73 +
25.74 + /**
25.75 + * @brief Queries the extension to see its run state.
25.76 + *
25.77 + * @param error Error buffer (may be NULL).
25.78 + * @param maxlength Maximum length of buffer.
25.79 + * @return True if extension is okay, false if not okay.
25.80 + */
25.81 + virtual bool IsRunning(char *error, size_t maxlength) =0;
25.82 + };
25.83 +
25.84 + #define SMINTERFACE_EXTENSIONAPI_VERSION 1
25.85 +
25.86 + /**
25.87 + * @brief The interface an extension must expose.
25.88 + */
25.89 + class IExtensionInterface
25.90 + {
25.91 + public:
25.92 + virtual unsigned int GetExtensionVersion()
25.93 + {
25.94 + return SMINTERFACE_EXTENSIONAPI_VERSION;
25.95 + }
25.96 + public:
25.97 + /**
25.98 + * @brief Called when the extension is loaded.
25.99 + *
25.100 + * @param me Pointer back to extension.
25.101 + * @param sys Pointer to interface sharing system of SourceMod.
25.102 + * @param error Error buffer to print back to, if any.
25.103 + * @param err_max Maximum size of error buffer.
25.104 + * @param late If this extension was loaded "late" (i.e. manually).
25.105 + * @return True if load should continue, false otherwise.
25.106 + */
25.107 + virtual bool OnExtensionLoad(IExtension *me,
25.108 + IShareSys *sys,
25.109 + char *error,
25.110 + size_t err_max,
25.111 + bool late) =0;
25.112 +
25.113 + /**
25.114 + * @brief Called when the extension is about to be unloaded.
25.115 + */
25.116 + virtual void OnExtensionUnload() =0;
25.117 +
25.118 + /**
25.119 + * @brief Called when all extensions are loaded (loading cycle is done).
25.120 + * If loaded late, this will be called right after OnExtensionLoad().
25.121 + */
25.122 + virtual void OnExtensionsAllLoaded() =0;
25.123 +
25.124 + /**
25.125 + * @brief Called when your pause state is about to change.
25.126 + *
25.127 + * @param pause True if pausing, false if unpausing.
25.128 + */
25.129 + virtual void OnExtensionPauseChange(bool pause) =0;
25.130 +
25.131 + /**
25.132 + * @brief Asks the extension whether it's safe to remove an external interface it's using.
25.133 + * If it's not safe, return false, and the extension will be unloaded afterwards.
25.134 + * NOTE: It is important to also hook NotifyInterfaceDrop() in order to clean up resources.
25.135 + *
25.136 + * @param pInterface Pointer to interface being dropped.
25.137 + * @return True to continue, false to unload this extension afterwards.
25.138 + */
25.139 + virtual bool QueryInterfaceDrop(SMInterface *pInterface)
25.140 + {
25.141 + return true;
25.142 + }
25.143 +
25.144 + /**
25.145 + * @brief Notifies the extension that an external interface it uses is being removed.
25.146 + *
25.147 + * @param pInterface Pointer to interface being dropped.
25.148 + */
25.149 + virtual void NotifyInterfaceDrop(SMInterface *pInterface)
25.150 + {
25.151 + }
25.152 +
25.153 + /**
25.154 + * @brief Return false to tell Core that your extension should be considered unsable.
25.155 + *
25.156 + * @param error Error buffer.
25.157 + * @param maxlength Size of error buffer.
25.158 + * @return True on success, false otherwise.
25.159 + */
25.160 + virtual bool QueryRunning(char *error, size_t maxlength)
25.161 + {
25.162 + return true;
25.163 + }
25.164 + public:
25.165 + virtual bool IsMetamodExtension() =0;
25.166 + virtual const char *GetExtensionName() =0;
25.167 + virtual const char *GetExtensionURL() =0;
25.168 + virtual const char *GetExtensionTag() =0;
25.169 + virtual const char *GetExtensionAuthor() =0;
25.170 + virtual const char *GetExtensionVerString() =0;
25.171 + virtual const char *GetExtensionDescription() =0;
25.172 + virtual const char *GetExtensionDateString() =0;
25.173 + };
25.174 +
25.175 + #define SMINTERFACE_EXTENSIONMANAGER_NAME "IExtensionManager"
25.176 + #define SMINTERFACE_EXTENSIONMANAGER_VERSION 1
25.177 +
25.178 + enum ExtensionLifetime
25.179 + {
25.180 + ExtLifetime_Forever, //Extension will never be unloaded automatically
25.181 + ExtLifetime_Map, //Extension will be unloaded at the end of the map
25.182 + };
25.183 +
25.184 + class IExtensionManager : public SMInterface
25.185 + {
25.186 + public:
25.187 + virtual const char *GetInterfaceName()
25.188 + {
25.189 + return SMINTERFACE_EXTENSIONMANAGER_NAME;
25.190 + }
25.191 + virtual unsigned int GetInterfaceVersion()
25.192 + {
25.193 + return SMINTERFACE_EXTENSIONMANAGER_VERSION;
25.194 + }
25.195 + public:
25.196 + /**
25.197 + * @brief Loads a extension into the extension system.
25.198 + *
25.199 + * @param path Path to extension file, relative to the extensions folder.
25.200 + * @param lifetime Lifetime of the extension.
25.201 + * @param error Error buffer.
25.202 + * @param err_max Maximum error buffer length.
25.203 + * @return New IExtension on success, NULL on failure.
25.204 + */
25.205 + virtual IExtension *LoadExtension(const char *path,
25.206 + ExtensionLifetime lifetime,
25.207 + char *error,
25.208 + size_t err_max) =0;
25.209 +
25.210 + /**
25.211 + * @brief Attempts to unload a module.
25.212 + *
25.213 + * @param pExt IExtension pointer.
25.214 + * @return True if successful, false otherwise.
25.215 + */
25.216 + virtual bool UnloadExtension(IExtension *pExt) =0;
25.217 + };
25.218 +};
25.219 +
25.220 +#endif //_INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/public/IForwardSys.h Fri Jan 19 05:33:04 2007 +0000
26.3 @@ -0,0 +1,350 @@
26.4 +#ifndef _INCLUDE_SOURCEMOD_FORWARDINTERFACE_H_
26.5 +#define _INCLUDE_SOURCEMOD_FORWARDINTERFACE_H_
26.6 +
26.7 +#include <IForwardSys.h>
26.8 +#include <IPluginSys.h>
26.9 +#include <IPluginFunction.h>
26.10 +
26.11 +#define SMINTERFACE_FORWARDMANAGER_NAME "IForwardManager"
26.12 +#define SMINTERFACE_FORWARDMANAGER_VERSION 1
26.13 +
26.14 +/**
26.15 + * There is some very important documentation at the bottom of this file.
26.16 + * Readers interested in knowing more about the forward system, scrolling down is a must!
26.17 + */
26.18 +
26.19 +namespace SourceMod
26.20 +{
26.21 + enum ResultType
26.22 + {
26.23 + Pl_Continue = 0, /* No result */
26.24 + Pl_Handled = 1, /* Result was handled, stop at the end */
26.25 + Pl_Stop = 2, /* Result was handled, stop now */
26.26 + };
26.27 +
26.28 + enum ExecType
26.29 + {
26.30 + ET_Ignore = 0, /* Ignore all return values, return 0 */
26.31 + ET_Single = 1, /* Only return the last exec, ignore all others */
26.32 + ET_Event = 2, /* Acts as an event with the ResultTypes above, no mid-Stops allowed, returns highest */
26.33 + ET_Hook = 3, /* Acts as a hook with the ResultTypes above, mid-Stops allowed, returns highest */
26.34 + ET_Custom = 4, /* Ignored or handled by an IForwardFilter */
26.35 + };
26.36 +
26.37 + class IForward;
26.38 +
26.39 + class IForwardFilter
26.40 + {
26.41 + public:
26.42 + /**
26.43 + * @brief Called when an error occurs executing a plugin.
26.44 + *
26.45 + * @param fwd IForward pointer.
26.46 + * @param func IPluginFunction pointer to the failed function.
26.47 + * @param err Error code.
26.48 + * @return True to handle, false to pass to global error reporter.
26.49 + */
26.50 + virtual bool OnErrorReport(IForward *fwd,
26.51 + IPluginFunction *func,
26.52 + int err)
26.53 + {
26.54 + return false;
26.55 + }
26.56 +
26.57 + /**
26.58 + * @brief Called after each function return during execution.
26.59 + * NOTE: Only used for ET_Custom.
26.60 + *
26.61 + * @param fwd IForward pointer.
26.62 + * @param func IPluginFunction pointer to the executed function.
26.63 + * @param retval Pointer to current return value (can be modified).
26.64 + * @return ResultType denoting the next action to take.
26.65 + */
26.66 + virtual ResultType OnFunctionReturn(IForward *fwd,
26.67 + IPluginFunction *func,
26.68 + cell_t *retval)
26.69 + {
26.70 + return Pl_Continue;
26.71 + }
26.72 +
26.73 + /**
26.74 + * @brief Called when execution begins.
26.75 + */
26.76 + virtual void OnExecuteBegin()
26.77 + {
26.78 + };
26.79 +
26.80 + /**
26.81 + * @brief Called when execution ends.
26.82 + *
26.83 + * @param final_ret Final return value (modifiable).
26.84 + * @param success Number of successful execs.
26.85 + * @param failed Number of failed execs.
26.86 + */
26.87 + virtual void OnExecuteEnd(cell_t *final_ret, unsigned int success, unsigned int failed)
26.88 + {
26.89 + }
26.90 + };
26.91 +
26.92 + /**
26.93 + * @brief Abstracts multiple function calling.
26.94 + *
26.95 + * NOTE: Parameters should be pushed in forward order, unlike
26.96 + * the virtual machine/IPluginContext order.
26.97 + * NOTE: Some functions are repeated in here because their
26.98 + * documentation differs from their IPluginFunction equivalents.
26.99 + * Missing are the Push functions, whose only doc change is that
26.100 + * they throw SP_ERROR_PARAM on type mismatches.
26.101 + */
26.102 + class IForward : public ICallable
26.103 + {
26.104 + public:
26.105 + virtual ~IForward()
26.106 + {
26.107 + }
26.108 + public:
26.109 + /**
26.110 + * @brief Returns the name of the forward.
26.111 + *
26.112 + * @return Forward name.
26.113 + */
26.114 + virtual const char *GetForwardName() =0;
26.115 +
26.116 + /**
26.117 + * @brief Returns the number of functions in this forward.
26.118 + *
26.119 + * @return Number of functions in forward.
26.120 + */
26.121 + virtual unsigned int GetFunctionCount() =0;
26.122 +
26.123 + /**
26.124 + * @brief Returns the method of multi-calling this forward has.
26.125 + *
26.126 + * @return ExecType of the forward.
26.127 + */
26.128 + virtual ExecType GetExecType() =0;
26.129 +
26.130 + /**
26.131 + * @brief Executes the forward.
26.132 + *
26.133 + * @param result Pointer to store result in.
26.134 + * @param filter Optional pointer to an IForwardFilter.
26.135 + * @return Error code, if any.
26.136 + */
26.137 + virtual int Execute(cell_t *result, IForwardFilter *filter=NULL) =0;
26.138 +
26.139 + /**
26.140 + * @brief Pushes an array of cells onto the current call. Different rules than ICallable.
26.141 + * NOTE: On Execute, the pointer passed will be modified according to the copyback rule.
26.142 + *
26.143 + * @param inarray Array to copy. Cannot be NULL, unlike ICallable's version.
26.144 + * @param cells Number of cells to allocate and optionally read from the input array.
26.145 + * @param phys_addr Unused. If a value is passed, it will be filled with NULL.
26.146 + * @param flags Whether or not changes should be copied back to the input array.
26.147 + * @return Error code, if any.
26.148 + */
26.149 + virtual int PushArray(cell_t *inarray,
26.150 + unsigned int cells,
26.151 + cell_t **phys_addr,
26.152 + int flags=0) =0;
26.153 + };
26.154 +
26.155 +
26.156 + class IChangeableForward : public IForward
26.157 + {
26.158 + public:
26.159 + /**
26.160 + * @brief Removes a function from the call list.
26.161 + * NOTE: Only removes one instance.
26.162 + *
26.163 + * @param func Function to remove.
26.164 + * @return Whether or not the function was removed.
26.165 + */
26.166 + virtual bool RemoveFunction(IPluginFunction *func) =0;
26.167 +
26.168 + /**
26.169 + * @brief Removes all instances of a plugin from the call list.
26.170 + *
26.171 + * @param plugin Plugin to remove instances of.
26.172 + * @return Number of functions removed therein.
26.173 + */
26.174 + virtual unsigned int RemoveFunctionsOfPlugin(IPlugin *plugin) =0;
26.175 +
26.176 + /**
26.177 + * @brief Adds a function to the call list.
26.178 + * NOTE: Cannot be used during an incompleted call.
26.179 + * NOTE: If used during a call, function is temporarily queued until calls are over.
26.180 + * NOTE: Adding mulitple copies of the same function is illegal.
26.181 + *
26.182 + * @param func Function to add.
26.183 + * @return True on success, otherwise false.
26.184 + */
26.185 + virtual bool AddFunction(IPluginFunction *func) =0;
26.186 +
26.187 + /**
26.188 + * @brief Adds a function to the call list.
26.189 + * NOTE: Cannot be used during an incompleted call.
26.190 + * NOTE: If used during a call, function is temporarily queued until calls are over.
26.191 + *
26.192 + * @param ctx Context to use as a look-up.
26.193 + * @param funcid Function id to add.
26.194 + * @return True on success, otherwise false.
26.195 + */
26.196 + virtual bool AddFunction(sp_context_t *ctx, funcid_t index) =0;
26.197 + };
26.198 +
26.199 + #define SP_PARAMTYPE_ANY 0
26.200 + #define SP_PARAMFLAG_BYREF (1<<0)
26.201 + #define SP_PARAMTYPE_CELL (1<<1)
26.202 + #define SP_PARAMTYPE_FLOAT (2<<1)
26.203 + #define SP_PARAMTYPE_STRING (3<<1)|SP_PARAMFLAG_BYREF
26.204 + #define SP_PARAMTYPE_ARRAY (4<<1)|SP_PARAMFLAG_BYREF
26.205 + #define SP_PARAMTYPE_VARARG (5<<1)
26.206 +
26.207 + enum ParamType
26.208 + {
26.209 + Param_Any = SP_PARAMTYPE_ANY,
26.210 + Param_Cell = SP_PARAMTYPE_CELL,
26.211 + Param_Float = SP_PARAMTYPE_FLOAT,
26.212 + Param_String = SP_PARAMTYPE_STRING,
26.213 + Param_Array = SP_PARAMTYPE_ARRAY,
26.214 + Param_VarArgs = SP_PARAMTYPE_VARARG,
26.215 + Param_CellByRef = SP_PARAMTYPE_CELL|SP_PARAMFLAG_BYREF,
26.216 + Param_FloatByRef = SP_PARAMTYPE_FLOAT|SP_PARAMFLAG_BYREF,
26.217 + };
26.218 +
26.219 + class IForwardManager : public SMInterface
26.220 + {
26.221 + public:
26.222 + virtual const char *GetInterfaceName()
26.223 + {
26.224 + return SMINTERFACE_FORWARDMANAGER_NAME;
26.225 + }
26.226 + virtual unsigned int GetInterfaceVersion()
26.227 + {
26.228 + return SMINTERFACE_FORWARDMANAGER_VERSION;
26.229 + }
26.230 + public:
26.231 + /**
26.232 + * @brief Creates a managed forward. This forward exists globally.
26.233 + * The name used to create the forward is used as its public function in all target plugins.
26.234 + * As new non-private plugins become loaded or unloaded, they will be automatically added
26.235 + * or removed. This is ideal for global, static forwards that are never changed.
26.236 + *
26.237 + * @param name Name of public function to use in forward.
26.238 + * @param et Execution type to be used.
26.239 + * @param num_params Number of parameter this function will have.
26.240 + * NOTE: For varargs, this should include the vararg parameter.
26.241 + * @param types Array of type information about each parameter. If NULL, types
26.242 + * are read off the vararg stream.
26.243 + * @param ... If types is NULL, num_params ParamTypes should be pushed.
26.244 + * @return A new IForward on success, NULL if type combination is impossible.
26.245 + */
26.246 + virtual IForward *CreateForward(const char *name,
26.247 + ExecType et,
26.248 + unsigned int num_params,
26.249 + ParamType *types,
26.250 + ...) =0;
26.251 +
26.252 + /**
26.253 + * @brief Creates an unmanaged forward. This forward exists privately.
26.254 + * Unlike managed forwards, no functions are ever added by the Manager.
26.255 + * However, functions will be removed automatically if their parent plugin is unloaded.
26.256 + *
26.257 + * @param name Name of forward (unused except for lookup, can be NULL for anonymous).
26.258 + * @param et Execution type to be used.
26.259 + * @param num_params Number of parameter this function will have.
26.260 + * NOTE: For varargs, this should include the vararg parameter.
26.261 + * @param types Array of type information about each parameter. If NULL, types
26.262 + * are read off the vararg stream.
26.263 + * @param ... If types is NULL, num_params ParamTypes should be pushed.
26.264 + * @return A new IChangeableForward on success, NULL if type combination is impossible.
26.265 + */
26.266 + virtual IChangeableForward *CreateForwardEx(const char *name,
26.267 + ExecType et,
26.268 + int num_params,
26.269 + ParamType *types,
26.270 + ...) =0;
26.271 +
26.272 + /**
26.273 + * @brief Finds a forward by name. Does not return anonymous forwards (named NULL or "").
26.274 + *
26.275 + * @param name Name of forward.
26.276 + * @param ifchng Optionally store either NULL or an IChangeableForward pointer
26.277 + * depending on type of forward.
26.278 + * @return IForward pointer, or NULL if none found matching the name.
26.279 + */
26.280 + virtual IForward *FindForward(const char *name, IChangeableForward **ifchng) =0;
26.281 +
26.282 + /**
26.283 + * @brief Frees and destroys a forward object.
26.284 + *
26.285 + * @param forward An IForward created by CreateForward() or CreateForwardEx().
26.286 + */
26.287 + virtual void ReleaseForward(IForward *forward) =0;
26.288 + };
26.289 +};
26.290 +
26.291 +/**
26.292 + * In the AMX Mod X model of forwarding, each forward contained a list of pairs, each pair containing
26.293 + * a function ID and an AMX structure. The forward structure itself did very little but hold parameter types.
26.294 + * An execution call worked like this:
26.295 + * - executeForward() took in a function id and a list of parameters
26.296 + * - for each contained plugin:
26.297 + * - the list of parameters was preprocessed and pushed
26.298 + * - the call was made
26.299 + * - the list was freed and copybacks were made
26.300 + * - return
26.301 + *
26.302 + * The advantages to this is that the system is very easy to implement, and it's fast. The disadvantage is
26.303 + * varargs tend to be very unforgiving and inflexible, and thus weird problems arose with casting. You also
26.304 + * lose flexibility, type checking, and the ability to reasonably use variable arguments lists in the VM.
26.305 + *
26.306 + * SourceMod replaces this forward system with a far more advanced, but a bit bulkier one. The idea is that
26.307 + * each plugin has a table of functions, and each function is an ICallable object. As well as being an ICallable,
26.308 + * each function is an IPluginFunction. An ICallable simply describes the process of adding parameters to a
26.309 + * function call. An IPluginFunction describes the process of actually calling a function and performing allocation,
26.310 + * copybacks, and deallocations.
26.311 + *
26.312 + * A very powerful forward system emerges: a Forward is just a collection of IPluginFunctions. Thus, the same
26.313 + * API can be easily wrapped around a simple list, and it will look transparent to the user.
26.314 + * Advantages:
26.315 + * 1) "SP Forwards" from AMX Mod X are simply IPluginFunctions without a collection.
26.316 + * 2) Forwards are function based, rather than plugin based, and are thus far more flexible at runtime..
26.317 + * 3) [2] Individual functions can be paused and more than one function from the same plugin can be hooked.
26.318 + * 4) [2] One hook type that used to map to many SP Forwards can now be centralized as one Forward.
26.319 + * This helps alleviate messes like Fakemeta.
26.320 + * 5) Parameter pushing is type-checked and allows for variable arguments.
26.321 + *
26.322 + * Note that while #2,3,4 could be added to AMX Mod X, the real binding property is #1, which makes the system
26.323 + * object oriented, rather than AMX Mod X, which hides the objects behind static functions. It is entirely a design
26.324 + * issue, rather than a usability one. The interesting part is when it gets to implementation, which has to cache
26.325 + * parameter pushing until execution. Without this, multiple function calls can be started across one plugin, which
26.326 + * will result in heap corruption given SourcePawn's implementation.
26.327 + *
26.328 + * Observe the new calling process:
26.329 + * - Each parameter is pushed into a local cache using the ICallable interface.
26.330 + * - For each function in the collection:
26.331 + * - Each parameter is decoded and -pushed into the function.
26.332 + * - The call is made.
26.333 + * - Return
26.334 + *
26.335 + * Astute readers will note the (minor) problems:
26.336 + * 1) More memory is used. Specifically, rather than N params of memory, you now have N params * M plugins.
26.337 + * This is because, again, parameters are cached both per-function and per-forward.
26.338 + * 2) There are slightly more calls going around: one extra call for each parameter, since each push is manual.
26.339 + *
26.340 + * HISTORICAL NOTES:
26.341 + * There used to be a # about copy backs.
26.342 + * Note that originally, the Forward implementation was a thin wrapper around IForwards. It did not cache pushes,
26.343 + * and instead immediately fired them to each internal plugin. This was to allow users to know that pointers would
26.344 + * be immediately resolved. Unfortunately, this became extremely burdensome on the API and exposed many problems,
26.345 + * the major (and breaking) one was that two separate Function objects cannot be in a calling process on the same
26.346 + * plugin at once. (:TODO: perhaps prevent that in the IPlugin object?) This is because heap functions lose their order
26.347 + * and become impossible to re-arrange without some global heap tracking mechanis. It also made iterative copy backs
26.348 + * for arrays/references overwhelmingly complex, since each plugin had to have its memory back-patched for each copy.
26.349 + * Therefore, this was scrapped for cached parameters (current implementation), which is the implementation AMX Mod X
26.350 + * uses. It is both faster and works better.
26.351 + */
26.352 +
26.353 +#endif //_INCLUDE_SOURCEMOD_FORWARDINTERFACE_H_
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
27.2 +++ b/public/IHandleSys.h Fri Jan 19 05:33:04 2007 +0000
27.3 @@ -0,0 +1,252 @@
27.4 +#ifndef _INCLUDE_SOURCEMOD_HANDLESYSTEM_INTERFACE_H_
27.5 +#define _INCLUDE_SOURCEMOD_HANDLESYSTEM_INTERFACE_H_
27.6 +
27.7 +#include <IShareSys.h>
27.8 +#include <sp_vm_types.h>
27.9 +
27.10 +#define SMINTERFACE_HANDLESYSTEM_NAME "IHandleSys"
27.11 +#define SMINTERFACE_HANDLESYSTEM_VERSION 1
27.12 +
27.13 +#define DEFAULT_IDENTITY NULL
27.14 +
27.15 +namespace SourceMod
27.16 +{
27.17 + /**
27.18 + * Both of these types have invalid values of '0' for error checking.
27.19 + */
27.20 + typedef unsigned int HandleType_t;
27.21 + typedef unsigned int Handle_t;
27.22 +
27.23 + class SourcePawn::IPluginContext;
27.24 +
27.25 + /**
27.26 + * About type checking:
27.27 + * Types can be inherited - a Parent type ("Supertype") can have child types.
27.28 + * When accessing handles, type checking is done. This table shows how this is resolved:
27.29 + *
27.30 + * HANDLE CHECK -> RESULT
27.31 + * ------ ----- ------
27.32 + * Parent Parent Success
27.33 + * Parent Child Fail
27.34 + * Child Parent Success
27.35 + * Child Child Success
27.36 + */
27.37 +
27.38 + enum HandleError
27.39 + {
27.40 + HandleError_None = 0, /* No error */
27.41 + HandleError_Changed, /* The handle has been freed and reassigned */
27.42 + HandleError_Type, /* The handle has a different type registered */
27.43 + HandleError_Freed, /* The handle has been freed */
27.44 + HandleError_Index, /* generic internal indexing error */
27.45 + HandleError_Access, /* No access permitted to free this handle */
27.46 + HandleError_Limit, /* The limited number of handles has been reached */
27.47 + HandleError_Identity, /* The identity token was not usable */
27.48 + HandleError_Owner, /* Owners do not match for this operation */
27.49 + HandleError_Version, /* Unrecognized security structure version */
27.50 + HandleError_Parameter, /* An invalid parameter was passed */
27.51 + HandleError_NoInherit, /* This type cannot be inherited */
27.52 + };
27.53 +
27.54 + /**
27.55 + * Access rights specific to a type
27.56 + */
27.57 + enum HTypeAccessRight
27.58 + {
27.59 + HTypeAccess_Create = 0, /* Handles of this type can be created (DEFAULT=false) */
27.60 + HTypeAccess_Inherit, /* Sub-types can inherit this type (DEFAULT=false) */
27.61 + /* -------------- */
27.62 + HTypeAccess_TOTAL, /* Total number of type access rights */
27.63 + };
27.64 +
27.65 + /**
27.66 + * Access rights specific to a Handle. These rights are exclusive.
27.67 + * For example, you do not need "read" access to delete or clone.
27.68 + */
27.69 + enum HandleAccessRight
27.70 + {
27.71 + HandleAccess_Read, /* Can be read (DEFAULT=ident only) */
27.72 + HandleAccess_Delete, /* Can be deleted (DEFAULT=owner only) */
27.73 + HandleAccess_Clone, /* Can be cloned (DEFAULT=any) */
27.74 + /* ------------- */
27.75 + HandleAccess_TOTAL, /* Total number of access rights */
27.76 + };
27.77 +
27.78 + #define HANDLE_RESTRICT_IDENTITY (1<<0) /* Access is restricted to the identity */
27.79 + #define HANDLE_RESTRICT_OWNER (1<<1) /* Access is restricted to the owner */
27.80 +
27.81 + /**
27.82 + * This is used to define per-type access rights.
27.83 + */
27.84 + struct TypeAccess
27.85 + {
27.86 + TypeAccess()
27.87 + {
27.88 + hsVersion = SMINTERFACE_HANDLESYSTEM_VERSION;
27.89 + }
27.90 + unsigned int hsVersion;
27.91 + IdentityToken_t *ident;
27.92 + bool access[HTypeAccess_TOTAL];
27.93 + };
27.94 +
27.95 + /**
27.96 + * This is used to define per-Handle access rights.
27.97 + */
27.98 + struct HandleAccess
27.99 + {
27.100 + HandleAccess()
27.101 + {
27.102 + hsVersion = SMINTERFACE_HANDLESYSTEM_VERSION;
27.103 + }
27.104 + unsigned int hsVersion;
27.105 + unsigned int access[HandleAccess_TOTAL];
27.106 + };
27.107 +
27.108 + /**
27.109 + * This pair of tokens is used for identification.
27.110 + */
27.111 + struct HandleSecurity
27.112 + {
27.113 + IdentityToken_t *pOwner; /* Owner of the Handle */
27.114 + IdentityToken_t *pIdentity; /* Owner of the Type */
27.115 + };
27.116 +
27.117 + class IHandleTypeDispatch
27.118 + {
27.119 + public:
27.120 + virtual unsigned int GetDispatchVersion()
27.121 + {
27.122 + return SMINTERFACE_HANDLESYSTEM_VERSION;
27.123 + }
27.124 + public:
27.125 + /**
27.126 + * @brief Called when destroying a handle. Must be implemented.
27.127 + */
27.128 + virtual void OnHandleDestroy(HandleType_t type, void *object) =0;
27.129 + };
27.130 +
27.131 + class IHandleSys : public SMInterface
27.132 + {
27.133 + public:
27.134 + virtual unsigned int GetInterfaceVersion()
27.135 + {
27.136 + return SMINTERFACE_HANDLESYSTEM_VERSION;
27.137 + }
27.138 + virtual const char *GetInterfaceName()
27.139 + {
27.140 + return SMINTERFACE_HANDLESYSTEM_NAME;
27.141 + }
27.142 + public:
27.143 + /**
27.144 + * @brief Creates a new Handle type.
27.145 + * NOTE: Currently, a child type may not have its own children.
27.146 + * NOTE: Handle names must be unique if not private.
27.147 + *
27.148 + * @param name Name of handle type (NULL or "" to be anonymous)
27.149 + * @param dispatch Pointer to a valid IHandleTypeDispatch object.
27.150 + * @param parent Parent handle to inherit from, 0 for none.
27.151 + * @param typeAccess Pointer to a TypeAccess object, NULL to use default
27.152 + * or inherited permissions. Pointer can be temporary.
27.153 + * @param hndlAccess Pointer to a HandleAccess object to define default
27.154 + * default permissions on each Handle. NULL to use default
27.155 + * permissions.
27.156 + * @param ident Security token for any permissions. If typeAccess is NULL, this
27.157 + * becomes the owning identity.
27.158 + * @param err Optional pointer to store an error code.
27.159 + * @return A new HandleType_t unique ID, or 0 on failure.
27.160 + */
27.161 + virtual HandleType_t CreateType(const char *name,
27.162 + IHandleTypeDispatch *dispatch,
27.163 + HandleType_t parent,
27.164 + const TypeAccess *typeAccess,
27.165 + const HandleAccess *hndlAccess,
27.166 + IdentityToken_t *ident,
27.167 + HandleError *err) =0;
27.168 +
27.169 + /**
27.170 + * @brief Removes a handle type.
27.171 + * NOTE: This removes all child types.
27.172 + *
27.173 + * @param type Type chain to remove.
27.174 + * @param ident Identity token. Removal fails if the token does not match.
27.175 + * @return True on success, false on failure.
27.176 + */
27.177 + virtual bool RemoveType(HandleType_t type, IdentityToken_t *ident) =0;
27.178 +
27.179 + /**
27.180 + * @brief Finds a handle type by name.
27.181 + *
27.182 + * @param name Name of handle type to find (anonymous not allowed).
27.183 + * @param type Address to store found handle in (if not found, undefined).
27.184 + * @return True if found, false otherwise.
27.185 + */
27.186 + virtual bool FindHandleType(const char *name, HandleType_t *type) =0;
27.187 +
27.188 + /**
27.189 + * @brief Creates a new handle.
27.190 + *
27.191 + * @param type Type to use on the handle.
27.192 + * @param object Object to bind to the handle.
27.193 + * @param owner Owner of the new Handle (may be NULL).
27.194 + * @param ident Identity for type access if needed (may be NULL).
27.195 + * @param err Optional pointer to store an error code.
27.196 + * @return A new Handle_t, or 0 on failure.
27.197 + */
27.198 + virtual Handle_t CreateHandle(HandleType_t type,
27.199 + void *object,
27.200 + IdentityToken_t *owner,
27.201 + IdentityToken_t *ident,
27.202 + HandleError *err) =0;
27.203 +
27.204 + /**
27.205 + * @brief Frees the memory associated with a handle and calls any destructors.
27.206 + * NOTE: This function will decrement the internal reference counter. It will
27.207 + * only perform any further action if the counter hits 0.
27.208 + *
27.209 + * @param type Handle_t identifier to destroy.
27.210 + * @param pSecurity Security information struct (may be NULL).
27.211 + * @return A HandleError error code.
27.212 + */
27.213 + virtual HandleError FreeHandle(Handle_t handle, const HandleSecurity *pSecurity) =0;
27.214 +
27.215 + /**
27.216 + * @brief Clones a handle by adding to its internal reference count. Its data,
27.217 + * type, and security permissions remain the same.
27.218 + *
27.219 + * @param handle Handle to duplicate. Any non-free handle target is valid.
27.220 + * @param newhandle Stores the duplicated handle in the pointer (must not be NULL).
27.221 + * @param newOwner New owner of cloned handle.
27.222 + * @param pSecurity Security information struct (may be NULL).
27.223 + * @return A HandleError error code.
27.224 + */
27.225 + virtual HandleError CloneHandle(Handle_t handle,
27.226 + Handle_t *newhandle,
27.227 + IdentityToken_t *newOwner,
27.228 + const HandleSecurity *pSecurity) =0;
27.229 +
27.230 + /**
27.231 + * @brief Retrieves the contents of a handle.
27.232 + *
27.233 + * @param handle Handle_t from which to retrieve contents.
27.234 + * @param type Expected type to read as. 0 ignores typing rules.
27.235 + * @param pSecurity Security information struct (may be NULL).
27.236 + * @param object Optional address to store object in.
27.237 + * @return HandleError error code.
27.238 + */
27.239 + virtual HandleError ReadHandle(Handle_t handle,
27.240 + HandleType_t type,
27.241 + const HandleSecurity *pSecurity,
27.242 + void **object) =0;
27.243 +
27.244 + /**
27.245 + * @brief Sets access permissions on one or more structures.
27.246 + *
27.247 + * @param pTypeAccess Optional TypeAccess buffer to initialize with the default values.
27.248 + * @param pHandleAccess Optional HandleAccess buffer to initialize with the default values.
27.249 + * @return True on success, false if version is unsupported.
27.250 + */
27.251 + virtual bool InitAccessDefaults(TypeAccess *pTypeAccess, HandleAccess *pHandleAccess) =0;
27.252 + };
27.253 +};
27.254 +
27.255 +#endif //_INCLUDE_SOURCEMOD_HANDLESYSTEM_INTERFACE_H_
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
28.2 +++ b/public/ILibrarySys.h Fri Jan 19 05:33:04 2007 +0000
28.3 @@ -0,0 +1,155 @@
28.4 +#ifndef _INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
28.5 +#define _INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
28.6 +
28.7 +#include <IShareSys.h>
28.8 +
28.9 +namespace SourceMod
28.10 +{
28.11 + #define SMINTERFACE_LIBRARYSYS_NAME "ILibrarySys"
28.12 + #define SMINTERFACE_LIBRARYSYS_VERSION 1
28.13 +
28.14 + class ILibrary
28.15 + {
28.16 + public:
28.17 + virtual ~ILibrary()
28.18 + {
28.19 + /* Calling delete will call CloseLibrary! */
28.20 + };
28.21 + public:
28.22 + /**
28.23 + * @brief Closes dynamic library and invalidates pointer.
28.24 + */
28.25 + virtual void CloseLibrary() =0;
28.26 +
28.27 + /**
28.28 + * @brief Retrieves a symbol pointer from the dynamic library.
28.29 + *
28.30 + * @param symname Symbol name.
28.31 + * @return Symbol pointer, NULL if not found.
28.32 + */
28.33 + virtual void *GetSymbolAddress(const char *symname) =0;
28.34 + };
28.35 +
28.36 + /**
28.37 + * @brief Directory browsing abstraction.
28.38 + */
28.39 + class IDirectory
28.40 + {
28.41 + public:
28.42 + virtual ~IDirectory()
28.43 + {
28.44 + }
28.45 + public:
28.46 + /**
28.47 + * @brief Returns true if there are more files to read, false otherwise.
28.48 + */
28.49 + virtual bool MoreFiles() =0;
28.50 +
28.51 + /**
28.52 + * @brief Advances to the next entry in the stream.
28.53 + */
28.54 + virtual void NextEntry() =0;
28.55 +
28.56 + /**
28.57 + * @brief Returns the name of the current entry.
28.58 + */
28.59 + virtual const char *GetEntryName() =0;
28.60 +
28.61 + /**
28.62 + * @brief Returns whether the current entry is a directory.
28.63 + */
28.64 + virtual bool IsEntryDirectory() =0;
28.65 +
28.66 + /**
28.67 + * @brief Returns whether the current entry is a file.
28.68 + */
28.69 + virtual bool IsEntryFile() =0;
28.70 +
28.71 + /**
28.72 + * @brief Returns true if the current entry is valid
28.73 + * (Used similarly to MoreFiles).
28.74 + */
28.75 + virtual bool IsEntryValid() =0;
28.76 + };
28.77 +
28.78 + /**
28.79 + * @brief Contains various operating system specific code.
28.80 + */
28.81 + class ILibrarySys : public SMInterface
28.82 + {
28.83 + public:
28.84 + virtual const char *GetInterfaceName()
28.85 + {
28.86 + return SMINTERFACE_LIBRARYSYS_NAME;
28.87 + }
28.88 + virtual unsigned int GetInterfaceVersion()
28.89 + {
28.90 + return SMINTERFACE_LIBRARYSYS_VERSION;
28.91 + }
28.92 + public:
28.93 + /**
28.94 + * @brief Opens a dynamic library file.
28.95 + *
28.96 + * @param path Path to library file (.dll/.so).
28.97 + * @param error Buffer for any error message (may be NULL).
28.98 + * @param err_max Maximum length of error buffer.
28.99 + * @return Pointer to an ILibrary, NULL if failed.
28.100 + */
28.101 + virtual ILibrary *OpenLibrary(const char *path, char *error, size_t err_max) =0;
28.102 +
28.103 + /**
28.104 + * @brief Opens a directory for reading.
28.105 + *
28.106 + * @param path Path to directory.
28.107 + * @return Pointer to an IDirectory, NULL if failed.
28.108 + */
28.109 + virtual IDirectory *OpenDirectory(const char *path) =0;
28.110 +
28.111 + /**
28.112 + * @brief Closes a directory and frees its handle.
28.113 + *
28.114 + * @param dir Pointer to IDirectory.
28.115 + */
28.116 + virtual void CloseDirectory(IDirectory *dir) =0;
28.117 +
28.118 + /**
28.119 + * @brief Returns true if a path exists.
28.120 + */
28.121 + virtual bool PathExists(const char *path) =0;
28.122 +
28.123 + /**
28.124 + * @brief Returns true if the path is a normal file.
28.125 + */
28.126 + virtual bool IsPathFile(const char *path) =0;
28.127 +
28.128 + /**
28.129 + * @brief Returns true if the path is a normal directory.
28.130 + */
28.131 + virtual bool IsPathDirectory(const char *path) =0;
28.132 +
28.133 + /**
28.134 + * @brief Gets a platform-specific error message.
28.135 + * This should only be called when an ILibrary function fails.
28.136 + * Win32 equivalent: GetLastError() + FormatMessage()
28.137 + * POSIX equivalent: errno + strerror()
28.138 + *
28.139 + * @param error Error message buffer.
28.140 + * @param err_max Maximum length of error buffer.
28.141 + */
28.142 + virtual void GetPlatformError(char *error, size_t err_max) =0;
28.143 +
28.144 + /**
28.145 + * @brief Formats a string similar to snprintf(), except
28.146 + * corrects all non-platform compatible path separators to be
28.147 + * the correct platform character.
28.148 + *
28.149 + * @param buffer Output buffer pointer.
28.150 + * @param maxlength Output buffer size.
28.151 + * @param pathfmt Format string of path.
28.152 + * @param ... Format string arguments.
28.153 + */
28.154 + virtual size_t PathFormat(char *buffer, size_t maxlength, const char *pathfmt, ...) =0;
28.155 + };
28.156 +};
28.157 +
28.158 +#endif //_INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
29.2 +++ b/public/IPluginFunction.h Fri Jan 19 05:33:04 2007 +0000
29.3 @@ -0,0 +1,153 @@
29.4 +#ifndef _INCLUDE_SOURCEMOD_PLUGINFUNCTION_INTERFACE_H_
29.5 +#define _INCLUDE_SOURCEMOD_PLUGINFUNCTION_INTERFACE_H_
29.6 +
29.7 +#include <IPluginSys.h>
29.8 +
29.9 +namespace SourceMod
29.10 +{
29.11 + #define SM_PARAM_COPYBACK (1<<0) /* Copy an array/reference back after call */
29.12 +
29.13 + #define SM_PARAM_STRING_UTF8 (1<<0) /* String should be UTF-8 handled */
29.14 + #define SM_PARAM_STRING_COPY (1<<1) /* String should be copied into the plugin */
29.15 +
29.16 + /**
29.17 + * @brief Represents what a function needs to implement in order to be callable.
29.18 + */
29.19 + class ICallable
29.20 + {
29.21 + public:
29.22 + /**
29.23 + * @brief Pushes a cell onto the current call.
29.24 + *
29.25 + * @param cell Parameter value to push.
29.26 + * @return Error code, if any.
29.27 + */
29.28 + virtual int PushCell(cell_t cell) =0;
29.29 +
29.30 + /**
29.31 + * @brief Pushes a cell by reference onto the current call.
29.32 + * NOTE: On Execute, the pointer passed will be modified if copyback is enabled.
29.33 + * NOTE: By reference parameters are cached and thus are not read until execution.
29.34 + * This means you cannot push a pointer, change it, and push it again and expect
29.35 + * two different values to come out.
29.36 + *
29.37 + * @param cell Address containing parameter value to push.
29.38 + * @param flags Copy-back flags.
29.39 + * @return Error code, if any.
29.40 + */
29.41 + virtual int PushCellByRef(cell_t *cell, int flags) =0;
29.42 +
29.43 + /**
29.44 + * @brief Pushes a float onto the current call.
29.45 + *
29.46 + * @param float Parameter value to push.
29.47 + * @return Error code, if any.
29.48 + */
29.49 + virtual int PushFloat(float number) =0;
29.50 +
29.51 + /**
29.52 + * @brief Pushes a float onto the current call by reference.
29.53 + * NOTE: On Execute, the pointer passed will be modified if copyback is enabled.
29.54 + * NOTE: By reference parameters are cached and thus are not read until execution.
29.55 + * This means you cannot push a pointer, change it, and push it again and expect
29.56 + * two different values to come out.
29.57 + *
29.58 + * @param float Parameter value to push.
29.59 + & @param flags Copy-back flags.
29.60 + * @return Error code, if any.
29.61 + */
29.62 + virtual int PushFloatByRef(float *number, int flags) =0;
29.63 +
29.64 + /**
29.65 + * @brief Pushes an array of cells onto the current call.
29.66 + * NOTE: On Execute, the pointer passed will be modified if non-NULL and copy-back
29.67 + * is enabled.
29.68 + * NOTE: By reference parameters are cached and thus are not read until execution.
29.69 + * This means you cannot push a pointer, change it, and push it again and expect
29.70 + * two different values to come out.
29.71 + *
29.72 + * @param inarray Array to copy, NULL if no initial array should be copied.
29.73 + * @param cells Number of cells to allocate and optionally read from the input array.
29.74 + * @param phys_addr Optional return address for physical array, if one was made.
29.75 + * @param flags Whether or not changes should be copied back to the input array.
29.76 + * @return Error code, if any.
29.77 + */
29.78 + virtual int PushArray(cell_t *inarray,
29.79 + unsigned int cells,
29.80 + cell_t **phys_addr,
29.81 + int flags=0) =0;
29.82 +
29.83 + /**
29.84 + * @brief Pushes a string onto the current call.
29.85 + *
29.86 + * @param string String to push.
29.87 + * @return Error code, if any.
29.88 + */
29.89 + virtual int PushString(const char *string) =0;
29.90 +
29.91 + /**
29.92 + * @brief Pushes a string or string buffer.
29.93 + * NOTE: On Execute, the pointer passed will be modified if copy-back is enabled.
29.94 + *
29.95 + * @param buffer Pointer to string buffer.
29.96 + * @param length Length of buffer.
29.97 + * @param sz_flags String flags.
29.98 + * @param cp_flags Copy-back flags.
29.99 + * @return Error code, if any.
29.100 + */
29.101 + virtual int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags) =0;
29.102 +
29.103 + /**
29.104 + * @brief Cancels a function call that is being pushed but not yet executed.
29.105 + * This can be used be reset for CallFunction() use.
29.106 + */
29.107 + virtual void Cancel() =0;
29.108 + };
29.109 +
29.110 + /**
29.111 + * @brief Encapsulates a function call in a plugin.
29.112 + * NOTE: Function calls must be atomic to one execution context.
29.113 + * NOTE: This object should not be deleted. It lives for the lifetime of the plugin.
29.114 + */
29.115 + class IPluginFunction : public ICallable
29.116 + {
29.117 + public:
29.118 + /**
29.119 + * @brief Executes the forward, resets the pushed parameter list, and performs any copybacks.
29.120 + *
29.121 + * @param result Pointer to store return value in.
29.122 + * @return Error code, if any.
29.123 + */
29.124 + virtual int Execute(cell_t *result) =0;
29.125 +
29.126 + /**
29.127 + * @brief Executes the function with the given parameter array.
29.128 + * Parameters are read in forward order (i.e. index 0 is parameter #1)
29.129 + * NOTE: You will get an error if you attempt to use CallFunction() with
29.130 + * previously pushed parameters.
29.131 + *
29.132 + * @param param Array of cell parameters.
29.133 + * @param num_params Number of parameters to push.
29.134 + * @param result Pointer to store result of function on return.
29.135 + * @return SourcePawn error code (if any).
29.136 + */
29.137 + virtual int CallFunction(const cell_t *params, unsigned int num_params, cell_t *result) =0;
29.138 +
29.139 + /**
29.140 + * @brief Returns which plugin this function belongs to.
29.141 + *
29.142 + * @return IPlugin pointer to parent plugin.
29.143 + */
29.144 + virtual IPlugin *GetParentPlugin() =0;
29.145 +
29.146 + /**
29.147 + * @brief Returns the physical address of a by-reference parameter.
29.148 + *
29.149 + * @param Parameter index to read (beginning at 0).
29.150 + * @return Address, or NULL if invalid parameter specified.
29.151 + */
29.152 + virtual cell_t *GetAddressOfPushedParam(unsigned int param) =0;
29.153 + };
29.154 +};
29.155 +
29.156 +#endif //_INCLUDE_SOURCEMOD_PLUGINFUNCTION_INTERFACE_H_
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2 +++ b/public/IPluginSys.h Fri Jan 19 05:33:04 2007 +0000
30.3 @@ -0,0 +1,302 @@
30.4 +#ifndef _INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
30.5 +#define _INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
30.6 +
30.7 +#include <IShareSys.h>
30.8 +#include <sp_vm_api.h>
30.9 +
30.10 +#define SMINTERFACE_PLUGINSYSTEM_NAME "IPluginManager"
30.11 +#define SMINTERFACE_PLUGINSYSTEM_VERSION 1
30.12 +
30.13 +#define SM_CONTEXTVAR_USER 3
30.14 +
30.15 +namespace SourceMod
30.16 +{
30.17 + class IPlugin;
30.18 +
30.19 + /**
30.20 + * @brief Encapsulates plugin public information.
30.21 + */
30.22 + typedef struct sm_plugininfo_s
30.23 + {
30.24 + const char *name;
30.25 + const char *author;
30.26 + const char *description;
30.27 + const char *version;
30.28 + const char *url;
30.29 + } sm_plugininfo_t;
30.30 +
30.31 +
30.32 + /**
30.33 + * @brief Describes the usability status of a plugin.
30.34 + * Note: The status "Loaded" and "Created" are only reachable
30.35 + * during map load.
30.36 + */
30.37 + enum PluginStatus
30.38 + {
30.39 + Plugin_Running=0, /* Plugin is running */
30.40 + /* All states below are unexecutable */
30.41 + Plugin_Paused, /* Plugin is loaded but paused */
30.42 + Plugin_Error, /* Plugin is loaded but errored/locked */
30.43 + /* All states below do not have all natives */
30.44 + Plugin_Loaded, /* Plugin has passed loading and can be finalized */
30.45 + Plugin_Failed, /* Plugin has a fatal failure */
30.46 + Plugin_Created, /* Plugin is created but not initialized */
30.47 + Plugin_Uncompiled, /* Plugin is not yet compiled by the JIT */
30.48 + Plugin_BadLoad, /* Plugin failed to load */
30.49 + };
30.50 +
30.51 +
30.52 + /**
30.53 + * @brief Describes the object lifetime of a plugin.
30.54 + */
30.55 + enum PluginType
30.56 + {
30.57 + PluginType_Private, /* Plugin is privately managed and receives no forwards */
30.58 + PluginType_MapUpdated, /* Plugin will never be unloaded unless for updates on mapchange */
30.59 + PluginType_MapOnly, /* Plugin will be removed at mapchange */
30.60 + PluginType_Global, /* Plugin will never be unloaded or updated */
30.61 + };
30.62 +
30.63 + class IPluginFunction;
30.64 +
30.65 + /**
30.66 + * @brief Encapsulates a run-time plugin as maintained by SourceMod.
30.67 + */
30.68 + class IPlugin
30.69 + {
30.70 + public:
30.71 + virtual ~IPlugin()
30.72 + {
30.73 + }
30.74 +
30.75 + /**
30.76 + * @brief Returns the lifetime of a plugin.
30.77 + */
30.78 + virtual PluginType GetType() const =0;
30.79 +
30.80 + /**
30.81 + * @brief Returns the current API context being used in the plugin.
30.82 + *
30.83 + * @return Pointer to an IPluginContext, or NULL if not loaded.
30.84 + */
30.85 + virtual SourcePawn::IPluginContext *GetBaseContext() const =0;
30.86 +
30.87 + /**
30.88 + * @brief Returns the context structure being used in the plugin.
30.89 + *
30.90 + * @return Pointer to an sp_context_t, or NULL if not loaded.
30.91 + */
30.92 + virtual sp_context_t *GetContext() const =0;
30.93 +
30.94 + /**
30.95 + * @brief Returns the plugin file structure.
30.96 + *
30.97 + * @return Pointer to an sp_plugin_t, or NULL if not loaded.
30.98 + */
30.99 + virtual const sp_plugin_t *GetPluginStructure() const =0;
30.100 +
30.101 + /**
30.102 + * @brief Returns information about the plugin by reference.
30.103 + *
30.104 + * @return Pointer to a sm_plugininfo_t object, NULL if plugin is not loaded.
30.105 + */
30.106 + virtual const sm_plugininfo_t *GetPublicInfo() const =0;
30.107 +
30.108 + /**
30.109 + * @brief Returns the plugin filename (relative to plugins dir).
30.110 + */
30.111 + virtual const char *GetFilename() const =0;
30.112 +
30.113 + /**
30.114 + * @brief Returns true if a plugin is in debug mode, false otherwise.
30.115 + */
30.116 + virtual bool IsDebugging() const =0;
30.117 +
30.118 + /**
30.119 + * @brief Returns the plugin status.
30.120 + */
30.121 + virtual PluginStatus GetStatus() const =0;
30.122 +
30.123 + /**
30.124 + * @brief Sets whether the plugin is paused or not.
30.125 + *
30.126 + * @return True on successful state change, false otherwise.
30.127 + */
30.128 + virtual bool SetPauseState(bool paused) =0;
30.129 +
30.130 + /**
30.131 + * @brief Returns the unique serial number of a plugin.
30.132 + */
30.133 + virtual unsigned int GetSerial() const =0;
30.134 +
30.135 + /**
30.136 + * @brief Returns a function by name.
30.137 + *
30.138 + * @param public_name Name of the function.
30.139 + * @return A new IPluginFunction pointer, NULL if not found.
30.140 + */
30.141 + virtual IPluginFunction *GetFunctionByName(const char *public_name) =0;
30.142 +
30.143 + /**
30.144 + * @brief Returns a function by its id.
30.145 + *
30.146 + * @param func_id Function ID.
30.147 + * @return A new IPluginFunction pointer, NULL if not found.
30.148 + */
30.149 + virtual IPluginFunction *GetFunctionById(funcid_t func_id) =0;
30.150 +
30.151 + /**
30.152 + * @brief Returns a plugin's identity token.
30.153 + */
30.154 + virtual IdentityToken_t *GetIdentity() const =0;
30.155 + };
30.156 +
30.157 +
30.158 + /**
30.159 + * @brief Iterates over a list of plugins.
30.160 + */
30.161 + class IPluginIterator
30.162 + {
30.163 + public:
30.164 + virtual ~IPluginIterator()
30.165 + {
30.166 + };
30.167 + public:
30.168 + /**
30.169 + * @brief Returns true if there are more plugins in the iterator.
30.170 + */
30.171 + virtual bool MorePlugins() =0;
30.172 +
30.173 + /**
30.174 + * @brief Returns the plugin at the current iterator position.
30.175 + */
30.176 + virtual IPlugin *GetPlugin() =0;
30.177 +
30.178 + /**
30.179 + * @brief Advances to the next plugin in the iterator.
30.180 + */
30.181 + virtual void NextPlugin() =0;
30.182 +
30.183 + /**
30.184 + * @brief Destroys the iterator object.
30.185 + * Note: You may use 'delete' in lieu of this function.
30.186 + */
30.187 + virtual void Release() =0;
30.188 + };
30.189 +
30.190 + /**
30.191 + * @brief Listens for plugin-oriented events.
30.192 + */
30.193 + class IPluginsListener
30.194 + {
30.195 + public:
30.196 + /**
30.197 + * @brief Called when a plugin is created/mapped into memory.
30.198 + */
30.199 + virtual void OnPluginCreated(IPlugin *plugin)
30.200 + {
30.201 + }
30.202 +
30.203 + /**
30.204 + * @brief Called when a plugin is fully loaded successfully.
30.205 + */
30.206 + virtual void OnPluginLoaded(IPlugin *plugin)
30.207 + {
30.208 + }
30.209 +
30.210 + /**
30.211 + * @brief Called when a plugin is unloaded (only if fully loaded).
30.212 + */
30.213 + virtual void OnPluginUnloaded(IPlugin *plugin)
30.214 + {
30.215 + }
30.216 +
30.217 + /**
30.218 + * @brief Called when a plugin is destroyed.
30.219 + * NOTE: Always called if Created, even if load failed.
30.220 + */
30.221 + virtual void OnPluginDestroyed(IPlugin *plugin)
30.222 + {
30.223 + }
30.224 + };
30.225 +
30.226 +
30.227 + /**
30.228 + * @brief Manages the runtime loading and unloading of plugins.
30.229 + */
30.230 + class IPluginManager : public SMInterface
30.231 + {
30.232 + public:
30.233 + virtual const char *GetInterfaceName()
30.234 + {
30.235 + return SMINTERFACE_PLUGINSYSTEM_NAME;
30.236 + }
30.237 +
30.238 + virtual unsigned int GetInterfaceVersion()
30.239 + {
30.240 + return SMINTERFACE_PLUGINSYSTEM_VERSION;
30.241 + }
30.242 + public:
30.243 + /**
30.244 + * @brief Attempts to load a plugin.
30.245 + *
30.246 + * @param path Path and filename of plugin, relative to plugins folder.
30.247 + * @param debug Whether or not to default the plugin into debug mode.
30.248 + * @param type Lifetime of the plugin.
30.249 + * @param error Buffer to hold any error message.
30.250 + * @param err_max Maximum length of error message buffer.
30.251 + * @return A new plugin pointer on success, false otherwise.
30.252 + */
30.253 + virtual IPlugin *LoadPlugin(const char *path,
30.254 + bool debug,
30.255 + PluginType type,
30.256 + char error[],
30.257 + size_t err_max) =0;
30.258 +
30.259 + /**
30.260 + * @brief Attempts to unload a plugin.
30.261 + *
30.262 + * @param plugin Pointer to the plugin handle.
30.263 + * @return True on success, false otherwise.
30.264 + */
30.265 + virtual bool UnloadPlugin(IPlugin *plugin) =0;
30.266 +
30.267 + /**
30.268 + * @brief Finds a plugin by its context.
30.269 + * Note: This function should be considered O(1).
30.270 + *
30.271 + * @param ctx Pointer to an sp_context_t.
30.272 + * @return Pointer to a matching IPlugin, or NULL if none found.
30.273 + */
30.274 + virtual IPlugin *FindPluginByContext(const sp_context_t *ctx) =0;
30.275 +
30.276 + /**
30.277 + * @brief Returns the number of plugins (both failed and loaded).
30.278 + *
30.279 + * @return The number of internally cached plugins.
30.280 + */
30.281 + virtual unsigned int GetPluginCount() =0;
30.282 +
30.283 + /**
30.284 + * @brief Returns a pointer that can be used to iterate through plugins.
30.285 + * Note: This pointer must be freed using EITHER delete OR IPluginIterator::Release().
30.286 + */
30.287 + virtual IPluginIterator *GetPluginIterator() =0;
30.288 +
30.289 + /**
30.290 + * @brief Adds a plugin manager listener.
30.291 + *
30.292 + * @param listener Pointer to a listener.
30.293 + */
30.294 + virtual void AddPluginsListener(IPluginsListener *listener) =0;
30.295 +
30.296 + /**
30.297 + * @brief Removes a plugin listener.
30.298 + *
30.299 + * @param listener Pointer to a listener.
30.300 + */
30.301 + virtual void RemovePluginsListener(IPluginsListener *listener) =0;
30.302 + };
30.303 +};
30.304 +
30.305 +#endif //_INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
31.2 +++ b/public/IRootConsoleMenu.h Fri Jan 19 05:33:04 2007 +0000
31.3 @@ -0,0 +1,90 @@
31.4 +#ifndef _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
31.5 +#define _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
31.6 +
31.7 +/**
31.8 + * @brief Note: This interface is not exposed.
31.9 + * The reason should be obvious: we do not want users touching the "root" console menu.
31.10 + * If we exposed this, every little plugin would be dropping down a silly set of user commands,
31.11 + * whereas this menu is explicitly provided for stuff that only Core itself is capable of managing.
31.12 + */
31.13 +
31.14 +namespace SourceMod
31.15 +{
31.16 + /**
31.17 + * @brief Handles a root console menu action.
31.18 + */
31.19 + class IRootConsoleCommand
31.20 + {
31.21 + public:
31.22 + virtual void OnRootConsoleCommand(const char *command, unsigned int argcount) =0;
31.23 + };
31.24 +
31.25 + /**
31.26 + * @brief Manages the root console menu - the "sm" command for servers.
31.27 + */
31.28 + class IRootConsole
31.29 + {
31.30 + public:
31.31 + /**
31.32 + * @brief Adds a root console command handler. The command must be unique.
31.33 + *
31.34 + * @param cmd String containing the console command.
31.35 + * @param text Description text.
31.36 + * @param pHandler An IRootConsoleCommand pointer to handle the command.
31.37 + * @return True on success, false on too many commands or duplicate command.
31.38 + */
31.39 + virtual bool AddRootConsoleCommand(const char *cmd, const char *text, IRootConsoleCommand *pHandler) =0;
31.40 +
31.41 + /**
31.42 + * @brief Removes a root console command handler.
31.43 + *
31.44 + * @param cmd String containing the console command.
31.45 + * @param pHandler An IRootConsoleCommand pointer for verification.
31.46 + * @return True on success, false otherwise.
31.47 + */
31.48 + virtual bool RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler) =0;
31.49 +
31.50 + /**
31.51 + * @brief Prints text back to the console.
31.52 + *
31.53 + * @param fmt Format of string.
31.54 + * @param ... Format arguments.
31.55 + */
31.56 + virtual void ConsolePrint(const char *fmt, ...) =0;
31.57 +
31.58 + /**
31.59 + * @brief Returns the string of an argument.
31.60 + *
31.61 + * @param argno The index of the argument.
31.62 + * @return A string containing the argument, or nothing if invalid.
31.63 + */
31.64 + virtual const char *GetArgument(unsigned int argno) =0;
31.65 +
31.66 + /**
31.67 + * @brief Returns the number of arguments.
31.68 + *
31.69 + * @return Number of arguments.
31.70 + */
31.71 + virtual unsigned int GetArgumentCount() =0;
31.72 +
31.73 + /**
31.74 + * @brief Returns the entire argument string.
31.75 + *
31.76 + * @return String containing all arguments.
31.77 + */
31.78 + virtual const char *GetArguments() =0;
31.79 +
31.80 + /**
31.81 + * @brief Draws a generic command/description pair.
31.82 + * NOTE: The pair is currently four spaces indented and 16-N spaces of separation,
31.83 + * N being the length of the command name. This is subject to change in case we
31.84 + * account for Valve's font choices.
31.85 + *
31.86 + * @param option String containing the command option.
31.87 + * @param description String containing the command description.
31.88 + */
31.89 + virtual void DrawGenericOption(const char *cmd, const char *text) =0;
31.90 + };
31.91 +};
31.92 +
31.93 +#endif //_INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
32.2 +++ b/public/IShareSys.h Fri Jan 19 05:33:04 2007 +0000
32.3 @@ -0,0 +1,149 @@
32.4 +#ifndef _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
32.5 +#define _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
32.6 +
32.7 +#include <sp_vm_types.h>
32.8 +
32.9 +#define NO_IDENTITY 0
32.10 +
32.11 +namespace SourceMod
32.12 +{
32.13 + class IExtension;
32.14 + struct IdentityToken_t;
32.15 + typedef unsigned int HandleType_t;
32.16 + typedef HandleType_t IdentityType_t;
32.17 + /**
32.18 + * @brief Defines the base functionality required by a shared interface.
32.19 + */
32.20 + class SMInterface
32.21 + {
32.22 + public:
32.23 + /**
32.24 + * @brief Must return an integer defining the interface's version.
32.25 + */
32.26 + virtual unsigned int GetInterfaceVersion() =0;
32.27 +
32.28 + /**
32.29 + * @brief Must return a string defining the interface's unique name.
32.30 + */
32.31 + virtual const char *GetInterfaceName() =0;
32.32 +
32.33 + /**
32.34 + * @brief Must return whether the requested version number is backwards comaptible.
32.35 + * Note: This can be overridden for breaking changes or custom versioning.
32.36 + *
32.37 + * @param version Version number to compare against.
32.38 + * @return True if compatible, false otherwise.
32.39 + */
32.40 + virtual bool IsVersionCompatible(unsigned int version)
32.41 + {
32.42 + if (version > GetInterfaceVersion())
32.43 + {
32.44 + return false;
32.45 + }
32.46 +
32.47 + return true;
32.48 + }
32.49 + };
32.50 +
32.51 + /**
32.52 + * @brief Tracks dependencies and fires dependency listeners.
32.53 + */
32.54 + class IShareSys
32.55 + {
32.56 + public:
32.57 + /**
32.58 + * @brief Adds an interface to the global interface system.
32.59 + *
32.60 + * @param myself Object adding this interface, in order to track dependencies.
32.61 + * @param iface Interface pointer (must be unique).
32.62 + * @return True on success, false otherwise.
32.63 + */
32.64 + virtual bool AddInterface(IExtension *myself, SMInterface *iface) =0;
32.65 +
32.66 + /**
32.67 + * @brief Requests an interface from the global interface system.
32.68 + * If found, the interface's internal reference count will be increased.
32.69 + *
32.70 + * @param iface_name Interface name.
32.71 + * @param iface_vers Interface version to attempt to match.
32.72 + * @param myself Object requesting this interface, in order to track dependencies.
32.73 + * @param pIface Pointer to store the return value in.
32.74 + */
32.75 + virtual bool RequestInterface(const char *iface_name,
32.76 + unsigned int iface_vers,
32.77 + IExtension *myself,
32.78 + SMInterface **pIface) =0;
32.79 +
32.80 + /**
32.81 + * @brief Adds a list of natives to the global native pool, to be bound on plugin load.
32.82 + * NOTE: Adding natives currently does not bind them to any loaded plugins.
32.83 + * You must manually bind late natives.
32.84 + *
32.85 + * @param token Identity token of parent object.
32.86 + * @param natives Array of natives to add. The last entry must have NULL members.
32.87 + */
32.88 + virtual void AddNatives(IExtension *myself, const sp_nativeinfo_t *natives) =0;
32.89 +
32.90 + /**
32.91 + * @brief Creates a new identity type.
32.92 + * NOTE: Module authors should never need to use this. Due to the current implementation,
32.93 + * there is a hardcoded limit of 15 types. Core uses up a few, so think carefully!
32.94 + *
32.95 + * @param name String containing type name. Must not be empty or NULL.
32.96 + * @return A new HandleType_t identifier, or 0 on failure.
32.97 + */
32.98 + virtual IdentityType_t CreateIdentType(const char *name) =0;
32.99 +
32.100 + /**
32.101 + * @brief Finds an identity type by name.
32.102 + * DEFAULT IDENTITY TYPES:
32.103 + * "PLUGIN" - An IPlugin object.
32.104 + * "MODULE" - An IModule object.
32.105 + * "CORE" - An SMGlobalClass or other singleton.
32.106 + *
32.107 + * @param name String containing type name to search for.
32.108 + * @return A HandleType_t identifier if found, 0 otherwise.
32.109 + */
32.110 + virtual IdentityType_t FindIdentType(const char *name) =0;
32.111 +
32.112 + /**
32.113 + * @brief Creates a new identity token. This token is guaranteed to be unique
32.114 + * amongst all other open identities.
32.115 + *
32.116 + * @param type Identity type.
32.117 + * @return A new IdentityToken_t identifier.
32.118 + */
32.119 + virtual IdentityToken_t *CreateIdentity(IdentityType_t type) =0;
32.120 +
32.121 + /**
32.122 + * @brief Destroys an identity type. Note that this will delete any identities
32.123 + * that are under this type.
32.124 + *
32.125 + * @param type Identity type.
32.126 + */
32.127 + virtual void DestroyIdentType(IdentityType_t type) =0;
32.128 +
32.129 + /**
32.130 + * @brief Destroys an identity token. Any handles being owned by this token, or
32.131 + * any handles being
32.132 + *
32.133 + * @param identity Identity to remove.
32.134 + */
32.135 + virtual void DestroyIdentity(IdentityToken_t *identity) =0;
32.136 +
32.137 +
32.138 + /**
32.139 + * @brief Requires an extension. This tells SourceMod that without this extension,
32.140 + * your extension should not be loaded. The name should not include the ".dll" or
32.141 + * the ".so" part of the file name.
32.142 + *
32.143 + * @param myself IExtension pointer to yourself.
32.144 + * @param filename File of extension to require.
32.145 + * @param require Whether or not this extension is a required dependency.
32.146 + * @param autoload Whether or not to autoload this extension.
32.147 + */
32.148 + virtual void AddDependency(IExtension *myself, const char *filename, bool require, bool autoload) =0;
32.149 + };
32.150 +};
32.151 +
32.152 +#endif //_INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
33.2 +++ b/public/ISourceMod.h Fri Jan 19 05:33:04 2007 +0000
33.3 @@ -0,0 +1,74 @@
33.4 +#ifndef _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
33.5 +#define _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
33.6 +
33.7 +#include <IShareSys.h>
33.8 +
33.9 +#define SMINTERFACE_SOURCEMOD_NAME "ISourceMod"
33.10 +#define SMINTERFACE_SOURCEMOD_VERSION 1
33.11 +
33.12 +namespace SourceMod
33.13 +{
33.14 + enum PathType
33.15 + {
33.16 + Path_None = 0,
33.17 + Path_Game,
33.18 + Path_SM,
33.19 + };
33.20 +
33.21 + class ISourceMod : public SMInterface
33.22 + {
33.23 + public:
33.24 + virtual const char *GetInterfaceName()
33.25 + {
33.26 + return SMINTERFACE_SOURCEMOD_NAME;
33.27 + }
33.28 + virtual unsigned int GetInterfaceVersion()
33.29 + {
33.30 + return SMINTERFACE_SOURCEMOD_VERSION;
33.31 + }
33.32 + public:
33.33 + /**
33.34 + * @brief Returns the full path to the mod directory.
33.35 + *
33.36 + * @return A string containing the full mod path.
33.37 + */
33.38 + virtual const char *GetModPath() =0;
33.39 +
33.40 + /**
33.41 + * @brief Returns the full path to the SourceMod directory.
33.42 + *
33.43 + * @return A string containing the full SourceMod path.
33.44 + */
33.45 + virtual const char *GetSourceModPath() =0;
33.46 +
33.47 + /**
33.48 + * @brief Builds a platform path for a specific target base path.
33.49 + *
33.50 + * @param type Type of path to use as a base.
33.51 + * @param buffer Buffer to write to.
33.52 + * @param maxlength Size of buffer.
33.53 + * @param format Format string.
33.54 + * @param ... Format arguments.
33.55 + * @return Number of bytes written.
33.56 + */
33.57 + virtual size_t BuildPath(PathType type, char *buffer, size_t maxlength, char *format, ...) =0;
33.58 +
33.59 + /**
33.60 + * @brief Logs a message to the SourceMod logs.
33.61 + *
33.62 + * @param format Message format.
33.63 + * @param ... Message format parameters.
33.64 + */
33.65 + virtual void LogMessage(IExtension *pExt, const char *format, ...) =0;
33.66 +
33.67 + /**
33.68 + * @brief Logs a message to the SourceMod error logs.
33.69 + *
33.70 + * @param format Message format.
33.71 + * @param ... Message format parameters.
33.72 + */
33.73 + virtual void LogError(IExtension *pExt, const char *format, ...) =0;
33.74 + };
33.75 +};
33.76 +
33.77 +#endif //_INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
34.2 +++ b/public/ITextParsers.h Fri Jan 19 05:33:04 2007 +0000
34.3 @@ -0,0 +1,316 @@
34.4 +#ifndef _INCLUDE_SOURCEMOD_TEXTPARSERS_INTERFACE_H_
34.5 +#define _INCLUDE_SOURCEMOD_TEXTPARSERS_INTERFACE_H_
34.6 +
34.7 +#include <IShareSys.h>
34.8 +
34.9 +namespace SourceMod
34.10 +{
34.11 + /**
34.12 + * The INI file format is defined as:
34.13 + * WHITESPACE: 0x20, \n, \t, \r
34.14 + * IDENTIFIER: A-Z a-z 0-9 _ - , + . $ ? /
34.15 + * STRING: Any set of symbols
34.16 + *
34.17 + * Basic syntax is comprised of SECTIONs.
34.18 + * A SECTION is defined as:
34.19 + * [SECTIONNAME]
34.20 + * OPTION
34.21 + * OPTION
34.22 + * OPTION...
34.23 + *
34.24 + * SECTIONNAME is an IDENTIFIER.
34.25 + * OPTION can be repeated any number of times, once per line.
34.26 + * OPTION is defined as one of:
34.27 + * KEY = "VALUE"
34.28 + * KEY = VALUE
34.29 + * KEY
34.30 + * Where KEY is an IDENTIFIER and VALUE is a STRING.
34.31 + *
34.32 + * WHITESPACE should always be omitted.
34.33 + * COMMENTS should be stripped, and are defined as text occuring in:
34.34 + * ;<TEXT>
34.35 + *
34.36 + * Example file below. Note that
34.37 + * The second line is technically invalid. The event handler
34.38 + * must decide whether this should be allowed.
34.39 + * --FILE BELOW--
34.40 + * [gaben]
34.41 + * hi = clams
34.42 + * bye = "NO CLAMS"
34.43 + *
34.44 + * [valve]
34.45 + * cannot
34.46 + * maintain
34.47 + * products
34.48 + */
34.49 + class ITextListener_INI
34.50 + {
34.51 + public:
34.52 + /**
34.53 + * @brief Called when a new section is encountered in an INI file.
34.54 + *
34.55 + * @param section Name of section in between the [ and ] characters.
34.56 + * @param invalid_tokens True if invalid tokens were detected in the name.
34.57 + * @param close_bracket True if a closing bracket was detected, false otherwise.
34.58 + * @param extra_tokens True if extra tokens were detected on the line.
34.59 + * @param curtok Contains current token in the line where the section name starts.
34.60 + * You can add to this offset when failing to point to a token.
34.61 + * @return True to keep parsing, false otherwise.
34.62 + */
34.63 + virtual bool ReadINI_NewSection(const char *section,
34.64 + bool invalid_tokens,
34.65 + bool close_bracket,
34.66 + bool extra_tokens,
34.67 + unsigned int *curtok)
34.68 + {
34.69 + return true;
34.70 + }
34.71 +
34.72 + /**
34.73 + * @brief Called when encountering a key/value pair in an INI file.
34.74 + *
34.75 + * @param key Name of key.
34.76 + * @param value String containing value (with quotes stripped, if any).
34.77 + * @param invalid_tokens Whether or not the key contained invalid tokens.
34.78 + * @param equal_token There was an '=' sign present (in case the value is missing).
34.79 + * @param quotes Whether value was enclosed in quotes.
34.80 + * @param curtoken Contains the token index of the start of the value string.
34.81 + * This can be changed when returning false.
34.82 + * @return True to keep parsing, false otherwise.
34.83 + */
34.84 + virtual bool ReadINI_KeyValue(const char *key,
34.85 + const char *value,
34.86 + bool invalid_tokens,
34.87 + bool equal_token,
34.88 + bool quotes,
34.89 + unsigned int *curtok)
34.90 + {
34.91 + return true;
34.92 + }
34.93 +
34.94 + /**
34.95 + * @brief Called after a line has been preprocessed, if it has text.
34.96 + *
34.97 + * @param line Contents of line.
34.98 + * @param curtok Pointer to optionally store failed position in string.
34.99 + * @return True to keep parsing, false otherwise.
34.100 + */
34.101 + virtual bool ReadINI_RawLine(const char *line, unsigned int *cutok)
34.102 + {
34.103 + return true;
34.104 + }
34.105 + };
34.106 +
34.107 + /**
34.108 + * :TODO: write this in CFG (context free grammar) format so it makes sense
34.109 + *
34.110 + * The SMC file format is defined as:
34.111 + * WHITESPACE: 0x20, \n, \t, \r
34.112 + * IDENTIFIER: Any ASCII character EXCLUDING ", {, }, ;, //, /*, or WHITESPACE.
34.113 + * STRING: Any set of symbols enclosed in quotes.
34.114 + * Note: if a STRING does not have quotes, it is parsed as an IDENTIFIER.
34.115 + *
34.116 + * Basic syntax is comprised of SECTIONBLOCKs.
34.117 + * A SECTIONBLOCK defined as:
34.118 + *
34.119 + * SECTIONNAME
34.120 + * {
34.121 + * OPTION
34.122 + * }
34.123 + *
34.124 + * OPTION can be repeated any number of times inside a SECTIONBLOCK.
34.125 + * A new line will terminate an OPTION, but there can be more than one OPTION per line.
34.126 + * OPTION is defined any of:
34.127 + * "KEY" "VALUE"
34.128 + * SECTIONBLOCK
34.129 + *
34.130 + * SECTIONNAME, KEY, VALUE, and SINGLEKEY are strings
34.131 + * SECTIONNAME cannot have trailing characters if quoted, but the quotes can be optionally removed.
34.132 + * If SECTIONNAME is not enclosed in quotes, the entire sectionname string is used (minus surrounding whitespace).
34.133 + * If KEY is not enclosed in quotes, the key is terminated at first whitespace.
34.134 + * If VALUE is not properly enclosed in quotes, the entire value string is used (minus surrounding whitespace).
34.135 + * The VALUE may have inner quotes, but the key string may not.
34.136 + *
34.137 + * For an example, see configs/permissions.cfg
34.138 + *
34.139 + * WHITESPACE should be ignored.
34.140 + * Comments are text occuring inside the following tokens, and should be stripped
34.141 + * unless they are inside literal strings:
34.142 + * ;<TEXT>
34.143 + * //<TEXT>
34.144 + * /*<TEXT> */
34.145 +
34.146 + enum SMCParseResult
34.147 + {
34.148 + SMCParse_Continue, //continue parsing
34.149 + SMCParse_Halt, //stop parsing here
34.150 + SMCParse_HaltFail //stop parsing and return failure
34.151 + };
34.152 +
34.153 + enum SMCParseError
34.154 + {
34.155 + SMCParse_Okay = 0, //no error
34.156 + SMCParse_StreamOpen, //stream failed to open
34.157 + SMCParse_StreamError, //the stream died... somehow
34.158 + SMCParse_Custom, //a custom handler threw an error
34.159 + SMCParse_InvalidSection1, //a section was declared without quotes, and had extra tokens
34.160 + SMCParse_InvalidSection2, //a section was declared without any header
34.161 + SMCParse_InvalidSection3, //a section ending was declared with too many unknown tokens
34.162 + SMCParse_InvalidSection4, //a section ending has no matching beginning
34.163 + SMCParse_InvalidSection5, //a section beginning has no matching ending
34.164 + SMCParse_InvalidTokens, //there were too many unidentifiable strings on one line
34.165 + SMCParse_TokenOverflow, //the token buffer overflowed
34.166 + SMCParse_InvalidProperty1, //a property was declared outside of any section
34.167 + };
34.168 +
34.169 + class ITextListener_SMC
34.170 + {
34.171 + public:
34.172 + /**
34.173 + * @brief Called when starting parsing.
34.174 + */
34.175 + virtual void ReadSMC_ParseStart()
34.176 + {
34.177 + };
34.178 +
34.179 + /**
34.180 + * @brief Called when ending parsing.
34.181 + *
34.182 + * @param halted True if abnormally halted, false otherwise.
34.183 + * @param failed True if parsing failed, false otherwise.
34.184 + */
34.185 + virtual void ReadSMC_ParseEnd(bool halted, bool failed)
34.186 + {
34.187 + }
34.188 +
34.189 + /**
34.190 + * @brief Called when a warning occurs.
34.191 + * @param error By-reference variable containing the error message of the warning.
34.192 + * @param tokens Pointer to the token stream causing the error.
34.193 + * @return SMCParseResult directive.
34.194 + */
34.195 + virtual SMCParseResult ReadSMC_OnWarning(SMCParseError &error, const char *tokens)
34.196 + {
34.197 + return SMCParse_HaltFail;
34.198 + }
34.199 +
34.200 + /**
34.201 + * @brief Called when entering a new section
34.202 + *
34.203 + * @param name Name of section, with the colon omitted.
34.204 + * @param opt_quotes Whether or not the option string was enclosed in quotes.
34.205 + * @return SMCParseResult directive.
34.206 + */
34.207 + virtual SMCParseResult ReadSMC_NewSection(const char *name, bool opt_quotes)
34.208 + {
34.209 + return SMCParse_Continue;
34.210 + }
34.211 +
34.212 + /**
34.213 + * @brief Called when encountering a key/value pair in a section.
34.214 + *
34.215 + * @param key Key string.
34.216 + * @param value Value string. If no quotes were specified, this will be NULL,
34.217 + and key will contain the entire string.
34.218 + * @param key_quotes Whether or not the key was in quotation marks.
34.219 + * @param value_quotes Whether or not the value was in quotation marks.
34.220 + * @return SMCParseResult directive.
34.221 + */
34.222 + virtual SMCParseResult ReadSMC_KeyValue(const char *key,
34.223 + const char *value,
34.224 + bool key_quotes,
34.225 + bool value_quotes)
34.226 + {
34.227 + return SMCParse_Continue;
34.228 + }
34.229 +
34.230 + /**
34.231 + * @brief Called when leaving the current section.
34.232 + *
34.233 + * @return SMCParseResult directive.
34.234 + */
34.235 + virtual SMCParseResult ReadSMC_LeavingSection()
34.236 + {
34.237 + return SMCParse_Continue;
34.238 + }
34.239 +
34.240 + /**
34.241 + * @brief Called after an input line has been preprocessed.
34.242 + *
34.243 + * @param line String containing line input.
34.244 + * @param curline Number of line in file.
34.245 + * @return SMCParseResult directive.
34.246 + */
34.247 + virtual SMCParseResult ReadSMC_RawLine(const char *line, unsigned int curline)
34.248 + {
34.249 + return SMCParse_Continue;
34.250 + }
34.251 + };
34.252 +
34.253 + #define SMINTERFACE_TEXTPARSERS_NAME "ITextParsers"
34.254 + #define SMINTERFACE_TEXTPARSERS_VERSION 1
34.255 +
34.256 + class ITextParsers : public SMInterface
34.257 + {
34.258 + public:
34.259 + virtual const char *GetInterfaceName()
34.260 + {
34.261 + return SMINTERFACE_TEXTPARSERS_NAME;
34.262 + }
34.263 + virtual unsigned int GetInterfaceVersion()
34.264 + {
34.265 + return SMINTERFACE_TEXTPARSERS_VERSION;
34.266 + }
34.267 + public:
34.268 + /**
34.269 + * @brief Parses an INI-format file.
34.270 + *
34.271 + * @param file Path to file.
34.272 + * @param ini_listener Event handler for reading file.
34.273 + * @param line If non-NULL, will contain last line parsed (0 if file could not be opened).
34.274 + * @param col If non-NULL, will contain last column parsed (undefined if file could not be opened).
34.275 + * @return True if parsing succeded, false if file couldn't be opened or there was a syntax error.
34.276 + */
34.277 + virtual bool ParseFile_INI(const char *file,
34.278 + ITextListener_INI *ini_listener,
34.279 + unsigned int *line,
34.280 + unsigned int *col) =0;
34.281 +
34.282 + /**
34.283 + * @brief Parses an SMC-format text file.
34.284 + * Note that the parser makes every effort to obey broken syntax.
34.285 + * For example, if an open brace is missing, but the section name has a colon,
34.286 + * it will let you know. It is up to the event handlers to decide whether to be strict or not.
34.287 + *
34.288 + * @param file Path to file.
34.289 + * @param smc_listener Event handler for reading file.
34.290 + * @param line If non-NULL, will contain last line parsed (0 if file could not be opened).
34.291 + * @param col If non-NULL, will contain last column parsed (undefined if file could not be opened).
34.292 + * @return An SMCParseError result code.
34.293 + */
34.294 + virtual SMCParseError ParseFile_SMC(const char *file,
34.295 + ITextListener_SMC *smc_listener,
34.296 + unsigned int *line,
34.297 + unsigned int *col) =0;
34.298 +
34.299 + /**
34.300 + * @brief Converts an SMCParseError to a stirng.
34.301 + *
34.302 + * @param err SMCParseError.
34.303 + * @return String error message, or NULL if none.
34.304 + */
34.305 + virtual const char *GetSMCErrorString(SMCParseError err) =0;
34.306 +
34.307 + public:
34.308 + /**
34.309 + * @brief Returns the number of bytes that a multi-byte character contains in a UTF-8 stream.
34.310 + * If the current character is not multi-byte, the function returns 1.
34.311 + *
34.312 + * @param stream Pointer to multi-byte ANSI character string.
34.313 + * @return Number of bytes in current character.
34.314 + */
34.315 + virtual unsigned int GetUTF8CharBytes(const char *stream) =0;
34.316 + };
34.317 +};
34.318 +
34.319 +#endif //_INCLUDE_SOURCEMOD_TEXTPARSERS_INTERFACE_H_
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
35.2 +++ b/public/sample_ext/extension.cpp Fri Jan 19 05:33:04 2007 +0000
35.3 @@ -0,0 +1,5 @@
35.4 +#include "extension.h"
35.5 +
35.6 +Sample g_Sample;
35.7 +
35.8 +SMEXT_LINK(&g_Sample);
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
36.2 +++ b/public/sample_ext/extension.h Fri Jan 19 05:33:04 2007 +0000
36.3 @@ -0,0 +1,59 @@
36.4 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
36.5 +#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
36.6 +
36.7 +#include "smsdk_ext.h"
36.8 +
36.9 +/**
36.10 + * @brief Sample implementation of the SDK Extension.
36.11 + * Note: Uncomment one of the pre-defined virtual functions in order to use it.
36.12 + */
36.13 +class Sample : public SDKExtension
36.14 +{
36.15 +public:
36.16 + /**
36.17 + * @brief This is called after the initial loading sequence has been processed.
36.18 + *
36.19 + * @param error Error message buffer.
36.20 + * @param err_max Size of error message buffer.
36.21 + * @param late Whether or not the module was loaded after map load.
36.22 + * @return True to succeed loading, false to fail.
36.23 + */
36.24 + //virtual bool SDK_OnLoad(char *error, size_t err_max, bool late);
36.25 +
36.26 + /**
36.27 + * @brief This is called right before the extension is unloaded.
36.28 + */
36.29 + //virtual void SDK_OnUnload();
36.30 +
36.31 + /**
36.32 + * @brief This is called once all known extensions have been loaded.
36.33 + * Note: It is is a good idea to add natives here, if any are provided.
36.34 + */
36.35 + //virtual void SDK_OnAllLoaded();
36.36 +
36.37 + /**
36.38 + * @brief Called when the pause state is changed.
36.39 + */
36.40 + //virtual void SDK_OnPauseChange(bool paused);
36.41 +
36.42 + /**
36.43 + * @brief this is called when Core wants to know if your extension is working.
36.44 + *
36.45 + * @param error Error message buffer.
36.46 + * @param err_max Size of error message buffer.
36.47 + * @return True if working, false otherwise.
36.48 + */
36.49 + //virtual void QueryRunning(char *error, size_t maxlength);
36.50 +public:
36.51 +#if defined SMEXT_CONF_METAMOD
36.52 + /**
36.53 + * Read smext_base.h for documentation on these.
36.54 + */
36.55 +
36.56 + //virtual bool SDK_OnMetamodLoad(char *error, size_t err_max, bool late);
36.57 + //virtual bool SDK_OnMetamodUnload(char *error, size_t err_max);
36.58 + //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max);
36.59 +#endif
36.60 +};
36.61 +
36.62 +#endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
37.2 +++ b/public/sample_ext/sdk.sln Fri Jan 19 05:33:04 2007 +0000
37.3 @@ -0,0 +1,26 @@
37.4 +
37.5 +Microsoft Visual Studio Solution File, Format Version 9.00
37.6 +# Visual Studio 2005
37.7 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdk", "sdk.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
37.8 +EndProject
37.9 +Global
37.10 + GlobalSection(SolutionConfigurationPlatforms) = preSolution
37.11 + Debug - Metamod|Win32 = Debug - Metamod|Win32
37.12 + Debug|Win32 = Debug|Win32
37.13 + Release - Metamod|Win32 = Release - Metamod|Win32
37.14 + Release|Win32 = Release|Win32
37.15 + EndGlobalSection
37.16 + GlobalSection(ProjectConfigurationPlatforms) = postSolution
37.17 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Metamod|Win32.ActiveCfg = Debug - Metamod|Win32
37.18 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Metamod|Win32.Build.0 = Debug - Metamod|Win32
37.19 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32
37.20 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32
37.21 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Metamod|Win32.ActiveCfg = Release - Metamod|Win32
37.22 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Metamod|Win32.Build.0 = Release - Metamod|Win32
37.23 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32
37.24 + {B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32
37.25 + EndGlobalSection
37.26 + GlobalSection(SolutionProperties) = preSolution
37.27 + HideSolutionNode = FALSE
37.28 + EndGlobalSection
37.29 +EndGlobal
38.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
38.2 +++ b/public/sample_ext/sdk.vcproj Fri Jan 19 05:33:04 2007 +0000
38.3 @@ -0,0 +1,368 @@
38.4 +<?xml version="1.0" encoding="Windows-1252"?>
38.5 +<VisualStudioProject
38.6 + ProjectType="Visual C++"
38.7 + Version="8.00"
38.8 + Name="sdk"
38.9 + ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
38.10 + RootNamespace="sdk"
38.11 + Keyword="Win32Proj"
38.12 + >
38.13 + <Platforms>
38.14 + <Platform
38.15 + Name="Win32"
38.16 + />
38.17 + </Platforms>
38.18 + <ToolFiles>
38.19 + </ToolFiles>
38.20 + <Configurations>
38.21 + <Configuration
38.22 + Name="Debug|Win32"
38.23 + OutputDirectory="$(SolutionDir)$(ConfigurationName)"
38.24 + IntermediateDirectory="$(ConfigurationName)"
38.25 + ConfigurationType="2"
38.26 + CharacterSet="2"
38.27 + >
38.28 + <Tool
38.29 + Name="VCPreBuildEventTool"
38.30 + />
38.31 + <Tool
38.32 + Name="VCCustomBuildTool"
38.33 + />
38.34 + <Tool
38.35 + Name="VCXMLDataGeneratorTool"
38.36 + />
38.37 + <Tool
38.38 + Name="VCWebServiceProxyGeneratorTool"
38.39 + />
38.40 + <Tool
38.41 + Name="VCMIDLTool"
38.42 + />
38.43 + <Tool
38.44 + Name="VCCLCompilerTool"
38.45 + Optimization="0"
38.46 + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
38.47 + MinimalRebuild="true"
38.48 + BasicRuntimeChecks="3"
38.49 + RuntimeLibrary="1"
38.50 + UsePrecompiledHeader="0"
38.51 + WarningLevel="3"
38.52 + Detect64BitPortabilityProblems="true"
38.53 + DebugInformationFormat="4"
38.54 + />
38.55 + <Tool
38.56 + Name="VCManagedResourceCompilerTool"
38.57 + />
38.58 + <Tool
38.59 + Name="VCResourceCompilerTool"
38.60 + />
38.61 + <Tool
38.62 + Name="VCPreLinkEventTool"
38.63 + />
38.64 + <Tool
38.65 + Name="VCLinkerTool"
38.66 + OutputFile="$(OutDir)\sample.ext.dll"
38.67 + LinkIncremental="2"
38.68 + GenerateDebugInformation="true"
38.69 + SubSystem="2"
38.70 + TargetMachine="1"
38.71 + />
38.72 + <Tool
38.73 + Name="VCALinkTool"
38.74 + />
38.75 + <Tool
38.76 + Name="VCManifestTool"
38.77 + />
38.78 + <Tool
38.79 + Name="VCXDCMakeTool"
38.80 + />
38.81 + <Tool
38.82 + Name="VCBscMakeTool"
38.83 + />
38.84 + <Tool
38.85 + Name="VCFxCopTool"
38.86 + />
38.87 + <Tool
38.88 + Name="VCAppVerifierTool"
38.89 + />
38.90 + <Tool
38.91 + Name="VCWebDeploymentTool"
38.92 + />
38.93 + <Tool
38.94 + Name="VCPostBuildEventTool"
38.95 + />
38.96 + </Configuration>
38.97 + <Configuration
38.98 + Name="Release|Win32"
38.99 + OutputDirectory="$(SolutionDir)$(ConfigurationName)"
38.100 + IntermediateDirectory="$(ConfigurationName)"
38.101 + ConfigurationType="2"
38.102 + CharacterSet="1"
38.103 + WholeProgramOptimization="1"
38.104 + >
38.105 + <Tool
38.106 + Name="VCPreBuildEventTool"
38.107 + />
38.108 + <Tool
38.109 + Name="VCCustomBuildTool"
38.110 + />
38.111 + <Tool
38.112 + Name="VCXMLDataGeneratorTool"
38.113 + />
38.114 + <Tool
38.115 + Name="VCWebServiceProxyGeneratorTool"
38.116 + />
38.117 + <Tool
38.118 + Name="VCMIDLTool"
38.119 + />
38.120 + <Tool
38.121 + Name="VCCLCompilerTool"
38.122 + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
38.123 + RuntimeLibrary="0"
38.124 + UsePrecompiledHeader="0"
38.125 + WarningLevel="3"
38.126 + Detect64BitPortabilityProblems="true"
38.127 + DebugInformationFormat="3"
38.128 + />
38.129 + <Tool
38.130 + Name="VCManagedResourceCompilerTool"
38.131 + />
38.132 + <Tool
38.133 + Name="VCResourceCompilerTool"
38.134 + />
38.135 + <Tool
38.136 + Name="VCPreLinkEventTool"
38.137 + />
38.138 + <Tool
38.139 + Name="VCLinkerTool"
38.140 + OutputFile="$(OutDir)\sample.ext.dll"
38.141 + LinkIncremental="1"
38.142 + GenerateDebugInformation="true"
38.143 + SubSystem="2"
38.144 + OptimizeReferences="2"
38.145 + EnableCOMDATFolding="2"
38.146 + TargetMachine="1"
38.147 + />
38.148 + <Tool
38.149 + Name="VCALinkTool"
38.150 + />
38.151 + <Tool
38.152 + Name="VCManifestTool"
38.153 + />
38.154 + <Tool
38.155 + Name="VCXDCMakeTool"
38.156 + />
38.157 + <Tool
38.158 + Name="VCBscMakeTool"
38.159 + />
38.160 + <Tool
38.161 + Name="VCFxCopTool"
38.162 + />
38.163 + <Tool
38.164 + Name="VCAppVerifierTool"
38.165 + />
38.166 + <Tool
38.167 + Name="VCWebDeploymentTool"
38.168 + />
38.169 + <Tool
38.170 + Name="VCPostBuildEventTool"
38.171 + />
38.172 + </Configuration>
38.173 + <Configuration
38.174 + Name="Debug - Metamod|Win32"
38.175 + OutputDirectory="$(SolutionDir)$(ConfigurationName)"
38.176 + IntermediateDirectory="$(ConfigurationName)"
38.177 + ConfigurationType="2"
38.178 + CharacterSet="2"
38.179 + >
38.180 + <Tool
38.181 + Name="VCPreBuildEventTool"
38.182 + />
38.183 + <Tool
38.184 + Name="VCCustomBuildTool"
38.185 + />
38.186 + <Tool
38.187 + Name="VCXMLDataGeneratorTool"
38.188 + />
38.189 + <Tool
38.190 + Name="VCWebServiceProxyGeneratorTool"
38.191 + />
38.192 + <Tool
38.193 + Name="VCMIDLTool"
38.194 + />
38.195 + <Tool
38.196 + Name="VCCLCompilerTool"
38.197 + Optimization="0"
38.198 + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SMEXT_CONF_METAMOD"
38.199 + MinimalRebuild="true"
38.200 + BasicRuntimeChecks="3"
38.201 + RuntimeLibrary="1"
38.202 + UsePrecompiledHeader="0"
38.203 + WarningLevel="3"
38.204 + Detect64BitPortabilityProblems="true"
38.205 + DebugInformationFormat="4"
38.206 + />
38.207 + <Tool
38.208 + Name="VCManagedResourceCompilerTool"
38.209 + />
38.210 + <Tool
38.211 + Name="VCResourceCompilerTool"
38.212 + />
38.213 + <Tool
38.214 + Name="VCPreLinkEventTool"
38.215 + />
38.216 + <Tool
38.217 + Name="VCLinkerTool"
38.218 + AdditionalDependencies="tier0.lib"
38.219 + OutputFile="$(OutDir)\sample.ext.dll"
38.220 + LinkIncremental="2"
38.221 + GenerateDebugInformation="true"
38.222 + SubSystem="2"
38.223 + TargetMachine="1"
38.224 + />
38.225 + <Tool
38.226 + Name="VCALinkTool"
38.227 + />
38.228 + <Tool
38.229 + Name="VCManifestTool"
38.230 + />
38.231 + <Tool
38.232 + Name="VCXDCMakeTool"
38.233 + />
38.234 + <Tool
38.235 + Name="VCBscMakeTool"
38.236 + />
38.237 + <Tool
38.238 + Name="VCFxCopTool"
38.239 + />
38.240 + <Tool
38.241 + Name="VCAppVerifierTool"
38.242 + />
38.243 + <Tool
38.244 + Name="VCWebDeploymentTool"
38.245 + />
38.246 + <Tool
38.247 + Name="VCPostBuildEventTool"
38.248 + />
38.249 + </Configuration>
38.250 + <Configuration
38.251 + Name="Release - Metamod|Win32"
38.252 + OutputDirectory="$(SolutionDir)$(ConfigurationName)"
38.253 + IntermediateDirectory="$(ConfigurationName)"
38.254 + ConfigurationType="2"
38.255 + CharacterSet="1"
38.256 + WholeProgramOptimization="1"
38.257 + >
38.258 + <Tool
38.259 + Name="VCPreBuildEventTool"
38.260 + />
38.261 + <Tool
38.262 + Name="VCCustomBuildTool"
38.263 + />
38.264 + <Tool
38.265 + Name="VCXMLDataGeneratorTool"
38.266 + />
38.267 + <Tool
38.268 + Name="VCWebServiceProxyGeneratorTool"
38.269 + />
38.270 + <Tool
38.271 + Name="VCMIDLTool"
38.272 + />
38.273 + <Tool
38.274 + Name="VCCLCompilerTool"
38.275 + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SMEXT_CONF_METAMOD"
38.276 + RuntimeLibrary="0"
38.277 + UsePrecompiledHeader="0"
38.278 + WarningLevel="3"
38.279 + Detect64BitPortabilityProblems="true"
38.280 + DebugInformationFormat="3"
38.281 + />
38.282 + <Tool
38.283 + Name="VCManagedResourceCompilerTool"
38.284 + />
38.285 + <Tool
38.286 + Name="VCResourceCompilerTool"
38.287 + />
38.288 + <Tool
38.289 + Name="VCPreLinkEventTool"
38.290 + />
38.291 + <Tool
38.292 + Name="VCLinkerTool"
38.293 + OutputFile="$(OutDir)\sample.ext.dll"
38.294 + LinkIncremental="1"
38.295 + GenerateDebugInformation="true"
38.296 + SubSystem="2"
38.297 + OptimizeReferences="2"
38.298 + EnableCOMDATFolding="2"
38.299 + TargetMachine="1"
38.300 + />
38.301 + <Tool
38.302 + Name="VCALinkTool"
38.303 + />
38.304 + <Tool
38.305 + Name="VCManifestTool"
38.306 + />
38.307 + <Tool
38.308 + Name="VCXDCMakeTool"
38.309 + />
38.310 + <Tool
38.311 + Name="VCBscMakeTool"
38.312 + />
38.313 + <Tool
38.314 + Name="VCFxCopTool"
38.315 + />
38.316 + <Tool
38.317 + Name="VCAppVerifierTool"
38.318 + />
38.319 + <Tool
38.320 + Name="VCWebDeploymentTool"
38.321 + />
38.322 + <Tool
38.323 + Name="VCPostBuildEventTool"
38.324 + />
38.325 + </Configuration>
38.326 + </Configurations>
38.327 + <References>
38.328 + </References>
38.329 + <Files>
38.330 + <Filter
38.331 + Name="Source Files"
38.332 + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
38.333 + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
38.334 + >
38.335 + <File
38.336 + RelativePath=".\extension.cpp"
38.337 + >
38.338 + </File>
38.339 + <File
38.340 + RelativePath=".\smsdk_ext.cpp"
38.341 + >
38.342 + </File>
38.343 + </Filter>
38.344 + <Filter
38.345 + Name="Header Files"
38.346 + Filter="h;hpp;hxx;hm;inl;inc;xsd"
38.347 + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
38.348 + >
38.349 + <File
38.350 + RelativePath=".\extension.h"
38.351 + >
38.352 + </File>
38.353 + <File
38.354 + RelativePath=".\smsdk_config.h"
38.355 + >
38.356 + </File>
38.357 + <File
38.358 + RelativePath=".\smsdk_ext.h"
38.359 + >
38.360 + </File>
38.361 + </Filter>
38.362 + <Filter
38.363 + Name="Resource Files"
38.364 + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
38.365 + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
38.366 + >
38.367 + </Filter>
38.368 + </Files>
38.369 + <Globals>
38.370 + </Globals>
38.371 +</VisualStudioProject>
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
39.2 +++ b/public/sample_ext/smsdk_config.h Fri Jan 19 05:33:04 2007 +0000
39.3 @@ -0,0 +1,27 @@
39.4 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
39.5 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
39.6 +
39.7 +/* Basic information exposed publically */
39.8 +#define SMEXT_CONF_NAME "Sample Extension"
39.9 +#define SMEXT_CONF_DESCRIPTION "Sample extension to help developers"
39.10 +#define SMEXT_CONF_VERSION "0.0.0.0"
39.11 +#define SMEXT_CONF_AUTHOR "AlliedModders"
39.12 +#define SMEXT_CONF_URL "http://www.sourcemod.net/"
39.13 +#define SMEXT_CONF_LOGTAG "SAMPLE"
39.14 +#define SMEXT_CONF_LICENSE "GPL"
39.15 +#define SMEXT_CONF_DATESTRING __DATE__
39.16 +
39.17 +/**
39.18 + * @brief Exposes plugin's main interface.
39.19 + */
39.20 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
39.21 +
39.22 +/**
39.23 + * @brief Sets whether or not this plugin required Metamod.
39.24 + * NOTE: Uncomment to enable, comment to disable.
39.25 + * NOTE: This is enabled automatically if a Metamod build is chosen in
39.26 + * the Visual Studio project.
39.27 + */
39.28 +//#define SMEXT_CONF_METAMOD
39.29 +
39.30 +#endif //_INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
40.2 +++ b/public/sample_ext/smsdk_ext.cpp Fri Jan 19 05:33:04 2007 +0000
40.3 @@ -0,0 +1,279 @@
40.4 +#include <stdio.h>
40.5 +#include "smsdk_ext.h"
40.6 +
40.7 +IShareSys *g_pShareSys = NULL;
40.8 +IExtension *myself = NULL;
40.9 +IHandleSys *g_pHandleSys = NULL;
40.10 +ISourceMod *g_pSM = NULL;
40.11 +
40.12 +PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
40.13 +{
40.14 + return g_pExtensionIface;
40.15 +}
40.16 +
40.17 +SDKExtension::SDKExtension()
40.18 +{
40.19 +#if defined SMEXT_CONF_METAMOD
40.20 + m_SourceMMLoaded = false;
40.21 + m_WeAreUnloaded = false;
40.22 + m_WeGotPauseChange = false;
40.23 +#endif
40.24 +}
40.25 +
40.26 +bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late)
40.27 +{
40.28 + g_pShareSys = sys;
40.29 + myself = me;
40.30 +
40.31 +#if defined SMEXT_CONF_METAMOD
40.32 + m_WeAreUnloaded = true;
40.33 +
40.34 + if (!m_SourceMMLoaded)
40.35 + {
40.36 + if (error)
40.37 + {
40.38 + snprintf(error, err_max, "Metamod attach failed");
40.39 + }
40.40 + return false;
40.41 + }
40.42 +#endif
40.43 +
40.44 + SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
40.45 + SM_GET_IFACE(SOURCEMOD, g_pSM);
40.46 +
40.47 + if (SDK_OnLoad(error, err_max, late))
40.48 + {
40.49 +#if defined SMEXT_CONF_METAMOD
40.50 + m_WeAreUnloaded = true;
40.51 +#endif
40.52 + return true;
40.53 + }
40.54 +
40.55 + return false;
40.56 +}
40.57 +
40.58 +bool SDKExtension::IsMetamodExtension()
40.59 +{
40.60 +#if defined SMEXT_CONF_METAMOD
40.61 + return true;
40.62 +#else
40.63 + return false;
40.64 +#endif
40.65 +}
40.66 +
40.67 +void SDKExtension::OnExtensionPauseChange(bool state)
40.68 +{
40.69 +#if defined SMEXT_CONF_METAMOD
40.70 + m_WeGotPauseChange = true;
40.71 +#endif
40.72 + SDK_OnPauseChange(state);
40.73 +}
40.74 +
40.75 +void SDKExtension::OnExtensionsAllLoaded()
40.76 +{
40.77 + SDK_OnAllLoaded();
40.78 +}
40.79 +
40.80 +void SDKExtension::OnExtensionUnload()
40.81 +{
40.82 +#if defined SMEXT_CONF_METAMOD
40.83 + m_WeAreUnloaded = true;
40.84 +#endif
40.85 + SDK_OnUnload();
40.86 +}
40.87 +
40.88 +const char *SDKExtension::GetExtensionAuthor()
40.89 +{
40.90 + return SMEXT_CONF_AUTHOR;
40.91 +}
40.92 +
40.93 +const char *SDKExtension::GetExtensionDateString()
40.94 +{
40.95 + return SMEXT_CONF_DATESTRING;
40.96 +}
40.97 +
40.98 +const char *SDKExtension::GetExtensionDescription()
40.99 +{
40.100 + return SMEXT_CONF_DESCRIPTION;
40.101 +}
40.102 +
40.103 +const char *SDKExtension::GetExtensionVerString()
40.104 +{
40.105 + return SMEXT_CONF_VERSION;
40.106 +}
40.107 +
40.108 +const char *SDKExtension::GetExtensionName()
40.109 +{
40.110 + return SMEXT_CONF_NAME;
40.111 +}
40.112 +
40.113 +const char *SDKExtension::GetExtensionTag()
40.114 +{
40.115 + return SMEXT_CONF_LOGTAG;
40.116 +}
40.117 +
40.118 +const char *SDKExtension::GetExtensionURL()
40.119 +{
40.120 + return SMEXT_CONF_URL;
40.121 +}
40.122 +
40.123 +bool SDKExtension::SDK_OnLoad(char *error, size_t err_max, bool late)
40.124 +{
40.125 + return true;
40.126 +}
40.127 +
40.128 +void SDKExtension::SDK_OnUnload()
40.129 +{
40.130 +}
40.131 +
40.132 +void SDKExtension::SDK_OnPauseChange(bool paused)
40.133 +{
40.134 +}
40.135 +
40.136 +void SDKExtension::SDK_OnAllLoaded()
40.137 +{
40.138 +}
40.139 +
40.140 +#if defined SMEXT_CONF_METAMOD
40.141 +
40.142 +PluginId g_PLID = 0;
40.143 +ISmmPlugin *g_PLAPI = NULL;
40.144 +SourceHook::ISourceHook *g_SHPtr = NULL;
40.145 +ISmmAPI *g_SMAPI = NULL;
40.146 +
40.147 +IVEngineServer *engine = NULL;
40.148 +IServerGameDLL *gamedll = NULL;
40.149 +
40.150 +SMM_API void *PL_EXPOSURE(const char *name, int *code)
40.151 +{
40.152 + if (name && !strcmp(name, PLAPI_NAME))
40.153 + {
40.154 + if (code)
40.155 + {
40.156 + *code = IFACE_OK;
40.157 + }
40.158 + return static_cast<void *>(g_pExtensionIface);
40.159 + }
40.160 +
40.161 + if (code)
40.162 + {
40.163 + *code = IFACE_FAILED;
40.164 + }
40.165 +
40.166 + return NULL;
40.167 +}
40.168 +
40.169 +bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
40.170 +{
40.171 + PLUGIN_SAVEVARS();
40.172 +
40.173 + GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
40.174 + GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
40.175 +
40.176 + m_SourceMMLoaded = true;
40.177 +
40.178 + return SDK_OnMetamodLoad(error, maxlen, late);
40.179 +}
40.180 +
40.181 +bool SDKExtension::Unload(char *error, size_t maxlen)
40.182 +{
40.183 + if (!m_WeAreUnloaded)
40.184 + {
40.185 + if (error)
40.186 + {
40.187 + snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
40.188 + }
40.189 + return false;
40.190 + }
40.191 +
40.192 + return SDK_OnMetamodUnload(error, maxlen);
40.193 +}
40.194 +
40.195 +bool SDKExtension::Pause(char *error, size_t maxlen)
40.196 +{
40.197 + if (!m_WeGotPauseChange)
40.198 + {
40.199 + if (error)
40.200 + {
40.201 + snprintf(error, maxlen, "This extension must be paused by SourceMod.");
40.202 + }
40.203 + return false;
40.204 + }
40.205 +
40.206 + m_WeGotPauseChange = false;
40.207 +
40.208 + return SDK_OnMetamodPauseChange(true, error, maxlen);
40.209 +}
40.210 +
40.211 +bool SDKExtension::Unpause(char *error, size_t maxlen)
40.212 +{
40.213 + if (!m_WeGotPauseChange)
40.214 + {
40.215 + if (error)
40.216 + {
40.217 + snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
40.218 + }
40.219 + return false;
40.220 + }
40.221 +
40.222 + m_WeGotPauseChange = false;
40.223 +
40.224 + return SDK_OnMetamodPauseChange(false, error, maxlen);
40.225 +}
40.226 +
40.227 +const char *SDKExtension::GetAuthor()
40.228 +{
40.229 + return GetExtensionAuthor();
40.230 +}
40.231 +
40.232 +const char *SDKExtension::GetDate()
40.233 +{
40.234 + return GetExtensionDateString();
40.235 +}
40.236 +
40.237 +const char *SDKExtension::GetDescription()
40.238 +{
40.239 + return GetExtensionDescription();
40.240 +}
40.241 +
40.242 +const char *SDKExtension::GetLicense()
40.243 +{
40.244 + return SMEXT_CONF_LICENSE;
40.245 +}
40.246 +
40.247 +const char *SDKExtension::GetLogTag()
40.248 +{
40.249 + return GetExtensionTag();
40.250 +}
40.251 +
40.252 +const char *SDKExtension::GetName()
40.253 +{
40.254 + return GetExtensionName();
40.255 +}
40.256 +
40.257 +const char *SDKExtension::GetURL()
40.258 +{
40.259 + return GetExtensionURL();
40.260 +}
40.261 +
40.262 +const char *SDKExtension::GetVersion()
40.263 +{
40.264 + return GetExtensionVerString();
40.265 +}
40.266 +
40.267 +bool SDKExtension::SDK_OnMetamodLoad(char *error, size_t err_max, bool late)
40.268 +{
40.269 + return true;
40.270 +}
40.271 +
40.272 +bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t err_max)
40.273 +{
40.274 + return true;
40.275 +}
40.276 +
40.277 +bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max)
40.278 +{
40.279 + return true;
40.280 +}
40.281 +
40.282 +#endif
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
41.2 +++ b/public/sample_ext/smsdk_ext.h Fri Jan 19 05:33:04 2007 +0000
41.3 @@ -0,0 +1,142 @@
41.4 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
41.5 +#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
41.6 +
41.7 +#include "smsdk_config.h"
41.8 +#include <IExtensionSys.h>
41.9 +#include <IHandleSys.h>
41.10 +#include <sp_vm_api.h>
41.11 +#include <sm_platform.h>
41.12 +#include <ISourceMod.h>
41.13 +
41.14 +#if defined SMEXT_CONF_METAMOD
41.15 +#include <ISmmPlugin.h>
41.16 +#include <eiface.h>
41.17 +#endif
41.18 +
41.19 +using namespace SourceMod;
41.20 +using namespace SourcePawn;
41.21 +
41.22 +class SDKExtension :
41.23 +#if defined SMEXT_CONF_METAMOD
41.24 + public ISmmPlugin,
41.25 +#endif
41.26 + public IExtensionInterface
41.27 +{
41.28 +public:
41.29 + SDKExtension();
41.30 +public:
41.31 + /**
41.32 + * @brief This is called after the initial loading sequence has been processed.
41.33 + *
41.34 + * @param error Error message buffer.
41.35 + * @param err_max Size of error message buffer.
41.36 + * @param late Whether or not the module was loaded after map load.
41.37 + * @return True to succeed loading, false to fail.
41.38 + */
41.39 + virtual bool SDK_OnLoad(char *error, size_t err_max, bool late);
41.40 +
41.41 + /**
41.42 + * @brief This is called right before the extension is unloaded.
41.43 + */
41.44 + virtual void SDK_OnUnload();
41.45 +
41.46 + /**
41.47 + * @brief This is called once all known extensions have been loaded.
41.48 + */
41.49 + virtual void SDK_OnAllLoaded();
41.50 +
41.51 + /**
41.52 + * @brief Called when the pause state is changed.
41.53 + */
41.54 + virtual void SDK_OnPauseChange(bool paused);
41.55 +
41.56 +#if defined SMEXT_CONF_METAMOD
41.57 + /**
41.58 + * @brief Called when Metamod is attached, before the extension version is called.
41.59 + *
41.60 + * @param error Error buffer.
41.61 + * @param err_max Maximum size of error buffer.
41.62 + * @param late Whether or not Metamod considers this a late load.
41.63 + * @return True to succeed, false to fail.
41.64 + */
41.65 + virtual bool SDK_OnMetamodLoad(char *error, size_t err_max, bool late);
41.66 +
41.67 + /**
41.68 + * @brief Called when Metamod is detaching, after the extension version is called.
41.69 + * NOTE: By default this is blocked unless sent from SourceMod.
41.70 + *
41.71 + * @param error Error buffer.
41.72 + * @param err_max Maximum size of error buffer.
41.73 + * @return True to succeed, false to fail.
41.74 + */
41.75 + virtual bool SDK_OnMetamodUnload(char *error, size_t err_max);
41.76 +
41.77 + /**
41.78 + * @brief Called when Metamod's pause state is changing.
41.79 + * NOTE: By default this is blocked unless sent from SourceMod.
41.80 + *
41.81 + * @param paused Pause state being set.
41.82 + * @param error Error buffer.
41.83 + * @param err_max Maximum size of error buffer.
41.84 + * @return True to succeed, false to fail.
41.85 + */
41.86 + virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max);
41.87 +#endif
41.88 +
41.89 +public: //IExtensionInterface
41.90 + virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t err_max, bool late);
41.91 + virtual void OnExtensionUnload();
41.92 + virtual void OnExtensionsAllLoaded();
41.93 + virtual bool IsMetamodExtension();
41.94 + virtual void OnExtensionPauseChange(bool state);
41.95 + virtual const char *GetExtensionName();
41.96 + virtual const char *GetExtensionURL();
41.97 + virtual const char *GetExtensionTag();
41.98 + virtual const char *GetExtensionAuthor();
41.99 + virtual const char *GetExtensionVerString();
41.100 + virtual const char *GetExtensionDescription();
41.101 + virtual const char *GetExtensionDateString();
41.102 +#if defined SMEXT_CONF_METAMOD
41.103 +public: //ISmmPlugin
41.104 + virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
41.105 + virtual const char *GetAuthor();
41.106 + virtual const char *GetName();
41.107 + virtual const char *GetDescription();
41.108 + virtual const char *GetURL();
41.109 + virtual const char *GetLicense();
41.110 + virtual const char *GetVersion();
41.111 + virtual const char *GetDate();
41.112 + virtual const char *GetLogTag();
41.113 + virtual bool Unload(char *error, size_t maxlen);
41.114 + virtual bool Pause(char *error, size_t maxlen);
41.115 + virtual bool Unpause(char *error, size_t maxlen);
41.116 +private:
41.117 + bool m_SourceMMLoaded;
41.118 + bool m_WeAreUnloaded;
41.119 + bool m_WeGotPauseChange;
41.120 +#endif
41.121 +};
41.122 +
41.123 +extern SDKExtension *g_pExtensionIface;
41.124 +
41.125 +extern IShareSys *g_pShareSys;
41.126 +extern IExtension *myself;
41.127 +extern IHandleSys *g_pHandleSys;
41.128 +extern ISourceMod *g_pSM;
41.129 +
41.130 +#if defined SMEXT_CONF_METAMOD
41.131 +PLUGIN_GLOBALVARS();
41.132 +extern IVEngineServer *engine;
41.133 +extern IServerGameDLL *gamedll;
41.134 +#endif
41.135 +
41.136 +#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
41.137 +#define SM_GET_IFACE(prefix,addr) \
41.138 + if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) { \
41.139 + if (error) { \
41.140 + snprintf(error, err_max, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
41.141 + } \
41.142 + return false; \
41.143 + }
41.144 +
41.145 +#endif //_INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
42.2 +++ b/public/sm_platform.h Fri Jan 19 05:33:04 2007 +0000
42.3 @@ -0,0 +1,39 @@
42.4 +#ifndef _INCLUDE_SOURCEMOD_PLATFORM_H_
42.5 +#define _INCLUDE_SOURCEMOD_PLATFORM_H_
42.6 +
42.7 +/**
42.8 + * @file Contains platform-specific macros for abstraction.
42.9 + */
42.10 +
42.11 +#if defined WIN32 || defined WIN64
42.12 +#define PLATFORM_WINDOWS
42.13 +#if !defined WIN32_LEAN_AND_MEAN
42.14 +#define WIN32_LEAN_AND_MEAN
42.15 +#endif
42.16 +#if !defined snprintf
42.17 +#define snprintf _snprintf
42.18 +#endif
42.19 +#if !defined stat
42.20 +#define stat _stat
42.21 +#endif
42.22 +#define strcasecmp strcmpi
42.23 +#include <windows.h>
42.24 +#include <direct.h>
42.25 +#define PLATFORM_LIB_EXT "dll"
42.26 +#define PLATFORM_MAX_PATH MAX_PATH
42.27 +#define PLATFORM_SEP_CHAR '\\'
42.28 +#define PLATFORM_SEP_ALTCHAR '/'
42.29 +#define PLATFORM_EXTERN_C extern "C" __declspec(dllexport)
42.30 +#else if defined __linux__
42.31 +#define PLATFORM_LINUX
42.32 +#define PLATFORM_POSIX
42.33 +#include <dirent.h>
42.34 +#include <errno.h>
42.35 +#define PLATFORM_MAX_PATH PATH_MAX
42.36 +#define PLATFORM_LIB_EXT "so"
42.37 +#define PLATFORM_SEP_CHAR '/'
42.38 +#define PLATFORM_SEP_ALTCHAR '\\'
42.39 +#define PLATFORM_EXTERN_C extern "C" __attribute__((visibility("default")))
42.40 +#endif
42.41 +
42.42 +#endif //_INCLUDE_SOURCEMOD_PLATFORM_H_
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
43.2 +++ b/public/sourcepawn/sp_file_headers.h Fri Jan 19 05:33:04 2007 +0000
43.3 @@ -0,0 +1,163 @@
43.4 +#ifndef _INCLUDE_SPFILE_HEADERS_H
43.5 +#define _INCLUDE_SPFILE_HEADERS_H
43.6 +
43.7 +#include <stddef.h>
43.8 +#if defined __GNUC__ || defined HAVE_STDINT_
43.9 +#include <stdint.h>
43.10 +#else
43.11 + #if !defined HAVE_STDINT_H
43.12 + typedef unsigned __int64 uint64_t;
43.13 + typedef __int64 int64_t;
43.14 + typedef unsigned __int32 uint32_t;
43.15 + typedef __int32 int32_t;
43.16 + typedef unsigned __int16 uint16_t;
43.17 + typedef __int16 int16_t;
43.18 + typedef unsigned __int8 uint8_t;
43.19 + typedef __int8 int8_t;
43.20 + #define HAVE_STDINT_H
43.21 + #endif
43.22 +#endif
43.23 +
43.24 +#define SPFILE_MAGIC 0x53504646 /* Source Pawn File Format (SPFF) */
43.25 +//#define SPFILE_VERSION 0x0100
43.26 +#define SPFILE_VERSION 0x0101 /* Uncompressed bytecode */
43.27 +
43.28 +//:TODO: better compiler/nix support
43.29 +#if defined __linux__
43.30 + #pragma pack(1) /* structures must be packed (byte-aligned) */
43.31 +#else
43.32 + #pragma pack(push)
43.33 + #pragma pack(1) /* structures must be packed (byte-aligned) */
43.34 +#endif
43.35 +
43.36 +#define SPFILE_COMPRESSION_NONE 0
43.37 +#define SPFILE_COMPRESSION_GZ 1
43.38 +
43.39 +typedef struct sp_file_section_s
43.40 +{
43.41 + uint32_t nameoffs; /* rel offset into global string table */
43.42 + uint32_t dataoffs;
43.43 + uint32_t size;
43.44 +} sp_file_section_t;
43.45 +
43.46 +/**
43.47 + * If compression is 0, then
43.48 + * disksize may be 0 to mean that
43.49 + * only the imagesize is needed.
43.50 + */
43.51 +typedef struct sp_file_hdr_s
43.52 +{
43.53 + uint32_t magic; /* magic number */
43.54 + uint16_t version; /* version code */
43.55 + uint8_t compression;/* compression algorithm */
43.56 + uint32_t disksize; /* size on disk */
43.57 + uint32_t imagesize; /* size in memory */
43.58 + uint8_t sections; /* number of sections */
43.59 + uint32_t stringtab; /* offset to string table */
43.60 + uint32_t dataoffs; /* offset to file proper (any compression starts here) */
43.61 +} sp_file_hdr_t;
43.62 +
43.63 +#define SP_FLAG_DEBUG (1<<0)
43.64 +
43.65 +/* section is ".code" */
43.66 +typedef struct sp_file_code_s
43.67 +{
43.68 + uint32_t codesize; /* codesize in bytes */
43.69 + uint8_t cellsize; /* cellsize in bytes */
43.70 + uint8_t codeversion; /* version of opcodes supported */
43.71 + uint16_t flags; /* flags */
43.72 + uint32_t main; /* address to "main" if any */
43.73 + uint32_t code; /* rel offset to code */
43.74 +} sp_file_code_t;
43.75 +
43.76 +/* section is .data */
43.77 +typedef struct sp_file_data_s
43.78 +{
43.79 + uint32_t datasize; /* size of data section in memory */
43.80 + uint32_t memsize; /* total mem required (includes data) */
43.81 + uint32_t data; /* file offset to data (helper) */
43.82 +} sp_file_data_t;
43.83 +
43.84 +/* section is .publics */
43.85 +typedef struct sp_file_publics_s
43.86 +{
43.87 + uint32_t address; /* address rel to code section */
43.88 + uint32_t name; /* index into nametable */
43.89 +} sp_file_publics_t;
43.90 +
43.91 +/* section is .natives */
43.92 +typedef struct sp_file_natives_s
43.93 +{
43.94 + uint32_t name; /* name of native at index */
43.95 +} sp_file_natives_t;
43.96 +
43.97 +/* section is .libraries */
43.98 +typedef struct sp_file_libraries_s
43.99 +{
43.100 + uint32_t name; /* index into nametable */
43.101 +} sp_file_libraries_t;
43.102 +
43.103 +/* section is .pubvars */
43.104 +typedef struct sp_file_pubvars_s
43.105 +{
43.106 + uint32_t address; /* address rel to dat section */
43.107 + uint32_t name; /* index into nametable */
43.108 +} sp_file_pubvars_t;
43.109 +
43.110 +#if defined __linux__
43.111 + #pragma pack() /* reset default packing */
43.112 +#else
43.113 + #pragma pack(pop) /* reset previous packing */
43.114 +#endif
43.115 +
43.116 +typedef struct sp_fdbg_info_s
43.117 +{
43.118 + uint32_t num_files; /* number of files */
43.119 + uint32_t num_lines; /* number of lines */
43.120 + uint32_t num_syms; /* number of symbols */
43.121 + uint32_t num_arrays; /* number of symbols which are arrays */
43.122 +} sp_fdbg_info_t;
43.123 +
43.124 +/**
43.125 + * Debug information structures
43.126 + */
43.127 +typedef struct sp_fdbg_file_s
43.128 +{
43.129 + uint32_t addr; /* address into code */
43.130 + uint32_t name; /* offset into debug nametable */
43.131 +} sp_fdbg_file_t;
43.132 +
43.133 +typedef struct sp_fdbg_line_s
43.134 +{
43.135 + uint32_t addr; /* address into code */
43.136 + uint32_t line; /* line number */
43.137 +} sp_fdbg_line_t;
43.138 +
43.139 +#define SP_SYM_VARIABLE 1 /* cell that has an address and that can be fetched directly (lvalue) */
43.140 +#define SP_SYM_REFERENCE 2 /* VARIABLE, but must be dereferenced */
43.141 +#define SP_SYM_ARRAY 3
43.142 +#define SP_SYM_REFARRAY 4 /* an array passed by reference (i.e. a pointer) */
43.143 +#define SP_SYM_FUNCTION 9
43.144 +
43.145 +typedef struct sp_fdbg_symbol_s
43.146 +{
43.147 + int32_t addr; /* address rel to DAT or stack frame */
43.148 + int16_t tagid; /* tag id */
43.149 + uint32_t codestart; /* start scope validity in code */
43.150 + uint32_t codeend; /* end scope validity in code */
43.151 + uint8_t ident; /* variable type */
43.152 + uint8_t vclass; /* scope class (local vs global) */
43.153 + uint16_t dimcount; /* dimension count (for arrays) */
43.154 + uint32_t name; /* offset into debug nametable */
43.155 +} sp_fdbg_symbol_t;
43.156 +
43.157 +typedef struct sp_fdbg_arraydim_s
43.158 +{
43.159 + int16_t tagid; /* tag id */
43.160 + uint32_t size; /* size of dimension */
43.161 +} sp_fdbg_arraydim_t;
43.162 +
43.163 +/* section is .names */
43.164 +typedef char * sp_file_nametab_t;
43.165 +
43.166 +#endif //_INCLUDE_SPFILE_HEADERS_H
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
44.2 +++ b/public/sourcepawn/sp_typeutil.h Fri Jan 19 05:33:04 2007 +0000
44.3 @@ -0,0 +1,15 @@
44.4 +#ifndef _INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_
44.5 +#define _INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_
44.6 +
44.7 +#include "sp_vm_types.h"
44.8 +
44.9 +inline cell_t sp_ftoc(float val)
44.10 +{
44.11 + return *(cell_t *)&val;
44.12 +}
44.13 +inline float sp_ctof(cell_t val)
44.14 +{
44.15 + return *(float *)&val;
44.16 +}
44.17 +
44.18 +#endif //_INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_
44.19 \ No newline at end of file
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
45.2 +++ b/public/sourcepawn/sp_vm_api.h Fri Jan 19 05:33:04 2007 +0000
45.3 @@ -0,0 +1,631 @@
45.4 +#ifndef _INCLUDE_SOURCEPAWN_VM_API_H_
45.5 +#define _INCLUDE_SOURCEPAWN_VM_API_H_
45.6 +
45.7 +#include <stdio.h>
45.8 +#include "sp_vm_types.h"
45.9 +
45.10 +#define SOURCEPAWN_VM_API_VERSION 1
45.11 +
45.12 +#if defined SOURCEMOD_BUILD
45.13 +namespace SourceMod
45.14 +{
45.15 + struct IdentityToken_t;
45.16 +};
45.17 +#endif
45.18 +
45.19 +namespace SourcePawn
45.20 +{
45.21 + class IVirtualMachine;
45.22 +
45.23 + /**
45.24 + * @brief Interface to managing a debug context at runtime.
45.25 + */
45.26 + class IPluginDebugInfo
45.27 + {
45.28 + public:
45.29 + /**
45.30 + * @brief Given a code pointer, finds the file it is associated with.
45.31 + *
45.32 + * @param addr Code address offset.
45.33 + * @param filename Pointer to store filename pointer in.
45.34 + */
45.35 + virtual int LookupFile(ucell_t addr, const char **filename) =0;
45.36 +
45.37 + /**
45.38 + * @brief Given a code pointer, finds the function it is associated with.
45.39 + *
45.40 + * @param addr Code address offset.
45.41 + * @param name Pointer to store function name pointer in.
45.42 + */
45.43 + virtual int LookupFunction(ucell_t addr, const char **name) =0;
45.44 +
45.45 + /**
45.46 + * @brief Given a code pointer, finds the line it is associated with.
45.47 + *
45.48 + * @param addr Code address offset.
45.49 + * @param line Pointer to store line number in.
45.50 + */
45.51 + virtual int LookupLine(ucell_t addr, uint32_t *line) =0;
45.52 + };
45.53 +
45.54 + /**
45.55 + * @brief Interface to managing a context at runtime.
45.56 + */
45.57 + class IPluginContext
45.58 + {
45.59 + public:
45.60 + virtual ~IPluginContext() { };
45.61 + public:
45.62 + /**
45.63 + * @brief Returns the parent IVirtualMachine.
45.64 + *
45.65 + * @return Parent virtual machine pointer.
45.66 + */
45.67 + virtual IVirtualMachine *GetVirtualMachine() =0;
45.68 +
45.69 + /**
45.70 + * @brief Returns the child sp_context_t structure.
45.71 + *
45.72 + * @return Child sp_context_t structure.
45.73 + */
45.74 + virtual sp_context_t *GetContext() =0;
45.75 +
45.76 + /**
45.77 + * @brief Returns true if the plugin is in debug mode.
45.78 + *
45.79 + * @return True if in debug mode, false otherwise.
45.80 + */
45.81 + virtual bool IsDebugging() =0;
45.82 +
45.83 + /**
45.84 + * @brief Installs a debug break and returns the old one, if any.
45.85 + * This will fail if the plugin is not debugging.
45.86 + *
45.87 + * @param newpfn New function pointer.
45.88 + * @param oldpfn Pointer to retrieve old function pointer.
45.89 + */
45.90 + virtual int SetDebugBreak(SPVM_DEBUGBREAK newpfn, SPVM_DEBUGBREAK *oldpfn) =0;
45.91 +
45.92 + /**
45.93 + * @brief Returns debug info.
45.94 + *
45.95 + * @return IPluginDebugInfo, or NULL if no debug info found.
45.96 + */
45.97 + virtual IPluginDebugInfo *GetDebugInfo() =0;
45.98 +
45.99 + /**
45.100 + * @brief Allocs memory on the secondary stack of a plugin.
45.101 + * Note that although called a heap, it is in fact a stack.
45.102 + *
45.103 + * @param cells Number of cells to allocate.
45.104 + * @param local_addr Will be filled with data offset to heap.
45.105 + * @param phys_addr Physical address to heap memory.
45.106 + */
45.107 + virtual int HeapAlloc(unsigned int cells, cell_t *local_addr, cell_t **phys_addr) =0;
45.108 +
45.109 + /**
45.110 + * @brief Pops a heap address off the heap stack. Use this to free memory allocated with
45.111 + * SP_HeapAlloc().
45.112 + * Note that in SourcePawn, the heap is in fact a bottom-up stack. Deallocations
45.113 + * with this native should be performed in precisely the REVERSE order.
45.114 + *
45.115 + * @param local_addr Local address to free.
45.116 + */
45.117 + virtual int HeapPop(cell_t local_addr) =0;
45.118 +
45.119 + /**
45.120 + * @brief Releases a heap address using a different method than SP_HeapPop().
45.121 + * This allows you to release in any order. However, if you allocate N
45.122 + * objects, release only some of them, then begin allocating again,
45.123 + * you cannot go back and starting freeing the originals.
45.124 + * In other words, for each chain of allocations, if you start deallocating,
45.125 + * then allocating more in a chain, you must only deallocate from the current
45.126 + * allocation chain. This is basically HeapPop() except on a larger scale.
45.127 + *
45.128 + * @param local_addr Local address to free.
45.129 + */
45.130 + virtual int HeapRelease(cell_t local_addr) =0;
45.131 +
45.132 + /**
45.133 + * @brief Finds a native by name.
45.134 + *
45.135 + * @param name Name of native.
45.136 + * @param index Optionally filled with native index number.
45.137 + */
45.138 + virtual int FindNativeByName(const char *name, uint32_t *index) =0;
45.139 +
45.140 + /**
45.141 + * @brief Gets native info by index.
45.142 + *
45.143 + * @param index Index number of native.
45.144 + * @param native Optionally filled with pointer to native structure.
45.145 + */
45.146 + virtual int GetNativeByIndex(uint32_t index, sp_native_t **native) =0;
45.147 +
45.148 + /**
45.149 + * @brief Gets the number of natives.
45.150 + *
45.151 + * @return Filled with the number of natives.
45.152 + */
45.153 + virtual uint32_t GetNativesNum() =0;
45.154 +
45.155 + /**
45.156 + * @brief Finds a public function by name.
45.157 + *
45.158 + * @param name Name of public
45.159 + * @param index Optionally filled with public index number.
45.160 + */
45.161 + virtual int FindPublicByName(const char *name, uint32_t *index) =0;
45.162 +
45.163 + /**
45.164 + * @brief Gets public function info by index.
45.165 + *
45.166 + * @param index Public function index number.
45.167 + * @param publicptr Optionally filled with pointer to public structure.
45.168 + */
45.169 + virtual int GetPublicByIndex(uint32_t index, sp_public_t **publicptr) =0;
45.170 +
45.171 + /**
45.172 + * @brief Gets the number of public functions.
45.173 + *
45.174 + * @return Filled with the number of public functions.
45.175 + */
45.176 + virtual uint32_t GetPublicsNum() =0;
45.177 +
45.178 + /**
45.179 + * @brief Gets public variable info by index.
45.180 + *
45.181 + * @param index Public variable index number.
45.182 + * @param pubvar Optionally filled with pointer to pubvar structure.
45.183 + */
45.184 + virtual int GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar) =0;
45.185 +
45.186 + /**
45.187 + * @brief Finds a public variable by name.
45.188 + *
45.189 + * @param name Name of pubvar
45.190 + * @param index Optionally filled with pubvar index number.
45.191 + */
45.192 + virtual int FindPubvarByName(const char *name, uint32_t *index) =0;
45.193 +
45.194 + /**
45.195 + * @brief Gets the addresses of a public variable.
45.196 + *
45.197 + * @param index Index of public variable.
45.198 + * @param local_addr Address to store local address in.
45.199 + * @param phys_addr Address to store physically relocated in.
45.200 + */
45.201 + virtual int GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr) =0;
45.202 +
45.203 + /**
45.204 + * @brief Returns the number of public variables.
45.205 + *
45.206 + * @return Number of public variables.
45.207 + */
45.208 + virtual uint32_t GetPubVarsNum() =0;
45.209 +
45.210 + /**
45.211 + * @brief Round-about method of converting a plugin reference to a physical address
45.212 + *
45.213 + * @param local_addr Local address in plugin.
45.214 + * @param phys_addr Optionally filled with relocated physical address.
45.215 + */
45.216 + virtual int LocalToPhysAddr(cell_t local_addr, cell_t **phys_addr) =0;
45.217 +
45.218 + /**
45.219 + * @brief Converts a local address to a physical string.
45.220 + *
45.221 + * @param local_addr Local address in plugin.
45.222 + * @param addr Destination output pointer.
45.223 + */
45.224 + virtual int LocalToString(cell_t local_addr, char **addr) =0;
45.225 +
45.226 + /**
45.227 + * @brief Converts a physical string to a local address.
45.228 + *
45.229 + * @param local_addr Local address in plugin.
45.230 + * @param bytes Number of chars to write, including NULL terminator.
45.231 + * @param source Source string to copy.
45.232 + */
45.233 + virtual int StringToLocal(cell_t local_addr, size_t bytes, const char *source) =0;
45.234 +
45.235 + /**
45.236 + * @brief Converts a physical UTF-8 string to a local address.
45.237 + * This function is the same as the ANSI version, except it will copy the maximum number of characters possible
45.238 + * without accidentally chopping a multi-byte character.
45.239 + *
45.240 + * @param local_addr Local address in plugin.
45.241 + * @param maxbytes Number of bytes to write, including NULL terminator.
45.242 + * @param source Source string to copy.
45.243 + * @param wrtnbytes Optionally set to the number of actual bytes written.
45.244 + */
45.245 + virtual int StringToLocalUTF8(cell_t local_addr,
45.246 + size_t maxbytes,
45.247 + const char *source,
45.248 + size_t *wrtnbytes) =0;
45.249 +
45.250 + /**
45.251 + * @brief Pushes a cell onto the stack. Increases the parameter count by one.
45.252 + *
45.253 + * @param value Cell value.
45.254 + */
45.255 + virtual int PushCell(cell_t value) =0;
45.256 +
45.257 + /**
45.258 + * @brief Pushes an array of cells onto the stack. Increases the parameter count by one.
45.259 + * If the function returns an error it will fail entirely, releasing anything allocated in the process.
45.260 + * Note that this does not release the heap, so you should release it after
45.261 + * calling Execute().
45.262 + *
45.263 + * @param local_addr Filled with local address to release.
45.264 + * @param phys_addr Optionally filled with physical address of new array.
45.265 + * @param array Cell array to copy.
45.266 + * @param numcells Number of cells in the array to copy.
45.267 + */
45.268 + virtual int PushCellArray(cell_t *local_addr, cell_t **phys_addr, cell_t array[], unsigned int numcells) =0;
45.269 +
45.270 + /**
45.271 + * @brief Pushes a string onto the stack (by reference) and increases the parameter count by one.
45.272 + * Note that this does not release the heap, so you should release it after
45.273 + * calling Execute().
45.274 + *
45.275 + * @param local_addr Filled with local address to release.
45.276 + * @param phys_addr Optionally filled with physical address of new array.
45.277 + * @param string Source string to push.
45.278 + */
45.279 + virtual int PushString(cell_t *local_addr, char **phys_addr, const char *string) =0;
45.280 +
45.281 + /**
45.282 + * @brief Individually pushes each cell of an array of cells onto the stack. Increases the
45.283 + * parameter count by the number of cells pushed.
45.284 + * If the function returns an error it will fail entirely, releasing anything allocated in the process.
45.285 + *
45.286 + * @param array Array of cells to read from.
45.287 + * @param numcells Number of cells to read.
45.288 + */
45.289 + virtual int PushCellsFromArray(cell_t array[], unsigned int numcells) =0;
45.290 +
45.291 + /**
45.292 + * @brief Binds a list of native names and their function pointers to a context.
45.293 + * If num is 0, the list is read until an entry with a NULL name is reached.
45.294 + * If overwrite is non-zero, already registered natives will be overwritten.
45.295 + *
45.296 + * @param natives Array of natives.
45.297 + * @param num Number of natives in array.
45.298 + * @param overwrite Toggles overwrite.
45.299 + */
45.300 + virtual int BindNatives(const sp_nativeinfo_t *natives, unsigned int num, int overwrite) =0;
45.301 +
45.302 + /**
45.303 + * @brief Binds a single native. Overwrites any existing bind.
45.304 + * If the context does not contain the native that will be binded the function will return
45.305 + * with a SP_ERROR_NOT_FOUND error.
45.306 + *
45.307 + * @param native Pointer to native.
45.308 + */
45.309 + virtual int BindNative(const sp_nativeinfo_t *native) =0;
45.310 +
45.311 + /**
45.312 + * @brief Binds a single native to any non-registered native.
45.313 + *
45.314 + * @param native Native to bind.
45.315 + */
45.316 + virtual int BindNativeToAny(SPVM_NATIVE_FUNC native) =0;
45.317 +
45.318 + /**
45.319 + * @brief Executes a function ID located in this context.
45.320 + *
45.321 + * @param funcid Function id to execute.
45.322 + * @param result Pointer to store the return value (required).
45.323 + * @return Error code (if any) from the VM.
45.324 + */
45.325 + virtual int Execute(uint32_t funcid, cell_t *result) =0;
45.326 +
45.327 +
45.328 + /**
45.329 + * @brief Throws a error and halts any current execution.
45.330 + *
45.331 + * @param error The error number to set.
45.332 + * @param msg Custom error message format. NULL to use default.
45.333 + * @param ... Message format arguments, if any.
45.334 + */
45.335 + virtual void ThrowNativeErrorEx(int error, const char *msg, ...) =0;
45.336 +
45.337 + /**
45.338 + * @brief Throws a generic native error and halts any current execution.
45.339 + *
45.340 + * @param msg Custom error message format. NULL to set no message.
45.341 + * @param ... Message format arguments, if any.
45.342 + * @return 0 for convenience.
45.343 + */
45.344 + virtual cell_t ThrowNativeError(const char *msg, ...) =0;
45.345 +
45.346 +#if defined SOURCEMOD_BUILD
45.347 + /**
45.348 + * @brief Returns the identity token for this context.
45.349 + * Note: This is a helper function for native calls and the Handle System.
45.350 + *
45.351 + * @return Identity token.
45.352 + */
45.353 + virtual SourceMod::IdentityToken_t *GetIdentity() =0;
45.354 +#endif
45.355 + };
45.356 +
45.357 +
45.358 + /**
45.359 + * @brief Information about a position in a call stack.
45.360 + */
45.361 + struct CallStackInfo
45.362 + {
45.363 + const char *filename; /* NULL if not found */
45.364 + unsigned int line; /* 0 if not found */
45.365 + const char *function; /* NULL if not found */
45.366 + };
45.367 +
45.368 + /**
45.369 + * @brief Retrieves error information from a debug hook.
45.370 + */
45.371 + class IContextTrace
45.372 + {
45.373 + public:
45.374 + /**
45.375 + * @brief Returns the integer error code.
45.376 + *
45.377 + * @return Integer error code.
45.378 + */
45.379 + virtual int GetErrorCode() =0;
45.380 +
45.381 + /**
45.382 + * @brief Returns a string describing the error.
45.383 + *
45.384 + * @return Error string.
45.385 + */
45.386 + virtual const char *GetErrorString() =0;
45.387 +
45.388 + /**
45.389 + * @brief Returns whether debug info is available.
45.390 + *
45.391 + * @return True if debug info is available, false otherwise.
45.392 + */
45.393 + virtual bool DebugInfoAvailable() =0;
45.394 +
45.395 + /**
45.396 + * @brief Returns a custom error message.
45.397 + *
45.398 + * @return A pointer to a custom error message, or NULL otherwise.
45.399 + */
45.400 + virtual const char *GetCustomErrorString() =0;
45.401 +
45.402 + /**
45.403 + * @brief Returns trace info for a specific point in the backtrace, if any.
45.404 + * The next subsequent call to GetTraceInfo() will return the next item in the call stack.
45.405 + * Calls are retrieved in descending order (i.e. the first item is at the top of the stack/call sequence).
45.406 + *
45.407 + * @param trace An ErrorTraceInfo buffer to store information (NULL to ignore).
45.408 + * @return True if successful, false if there are no more traces.
45.409 + */
45.410 + virtual bool GetTraceInfo(CallStackInfo *trace) =0;
45.411 +
45.412 + /**
45.413 + * @brief Resets the trace to its original position (the call on the top of the stack).
45.414 + */
45.415 + virtual void ResetTrace() =0;
45.416 +
45.417 + /**
45.418 + * @brief Retrieves the name of the last native called.
45.419 + * Returns NULL if there was no native that caused the error.
45.420 + *
45.421 + * @param index Optional pointer to store index.
45.422 + * @return Native name, or NULL if none.
45.423 + */
45.424 + virtual const char *GetLastNative(uint32_t *index) =0;
45.425 + };
45.426 +
45.427 +
45.428 + /**
45.429 + * @brief Provides callbacks for debug information.
45.430 + */
45.431 + class IDebugListener
45.432 + {
45.433 + public:
45.434 + virtual void OnContextExecuteError(IPluginContext *ctx, IContextTrace *error) =0;
45.435 + };
45.436 +
45.437 +
45.438 + /**
45.439 + * @brief Contains helper functions used by VMs and the host app
45.440 + */
45.441 + class ISourcePawnEngine
45.442 + {
45.443 + public:
45.444 + /**
45.445 + * @brief Loads a named file from a file pointer.
45.446 + * Note: Using this means the memory will be allocated by the VM.
45.447 + *
45.448 + * @param fp File pointer. May be at any offset. Not closed on return.
45.449 + * @param err Optional error code pointer.
45.450 + * @return A new plugin structure.
45.451 + */
45.452 + virtual sp_plugin_t *LoadFromFilePointer(FILE *fp, int *err) =0;
45.453 +
45.454 + /**
45.455 + * @brief Loads a file from a base memory address.
45.456 + *
45.457 + * @param base Base address of the plugin's memory region.
45.458 + * @param plugin If NULL, a new plugin pointer is returned.
45.459 + * Otherwise, the passed pointer is used.
45.460 + * @param err Optional error code pointer.
45.461 + * @return The resulting plugin pointer.
45.462 + */
45.463 + virtual sp_plugin_t *LoadFromMemory(void *base, sp_plugin_t *plugin, int *err) =0;
45.464 +
45.465 + /**
45.466 + * Frees all of the memory associated with a plugin file.
45.467 + * If allocated using SP_LoadFromMemory, the base and plugin pointer
45.468 + * itself are not freed (so this may end up doing nothing).
45.469 + */
45.470 + virtual int FreeFromMemory(sp_plugin_t *plugin) =0;
45.471 +
45.472 + /**
45.473 + * @brief Allocates large blocks of temporary memory.
45.474 + *
45.475 + * @param size Size of memory to allocate.
45.476 + * @return Pointer to memory, NULL if allocation failed.
45.477 + */
45.478 + virtual void *BaseAlloc(size_t size) =0;
45.479 +
45.480 + /**
45.481 + * @brief Frees memory allocated with BaseAlloc.
45.482 + *
45.483 + * @param memory Memory address to free.
45.484 + */
45.485 + virtual void BaseFree(void *memory) =0;
45.486 +
45.487 + /**
45.488 + * @brief Allocates executable memory.
45.489 + *
45.490 + * @param size Size of memory to allocate.
45.491 + * @return Pointer to memory, NULL if allocation failed.
45.492 + */
45.493 + virtual void *ExecAlloc(size_t size) =0;
45.494 +
45.495 + /**
45.496 + * @brief Frees executable memory.
45.497 + *
45.498 + * @param address Address to free.
45.499 + */
45.500 + virtual void ExecFree(void *address) =0;
45.501 +
45.502 + /**
45.503 + * @brief Sets the debug listener. This should only be called once.
45.504 + * If called successively (using manual chaining), only the last function should
45.505 + * attempt to call back into the same plugin. Otherwise, globally cached states
45.506 + * can be accidentally overwritten.
45.507 + *
45.508 + * @param listener Pointer to an IDebugListener.
45.509 + * @return Old IDebugListener, or NULL if none.
45.510 + */
45.511 + virtual IDebugListener *SetDebugListener(IDebugListener *listener) =0;
45.512 +
45.513 + /**
45.514 + * @brief Returns the number of plugins on the call stack.
45.515 + *
45.516 + * @return Number of contexts in the call stack.
45.517 + */
45.518 + virtual unsigned int GetContextCallCount() =0;
45.519 + };
45.520 +
45.521 +
45.522 + /**
45.523 + * @brief Dummy class for encapsulating private compilation data.
45.524 + */
45.525 + class ICompilation
45.526 + {
45.527 + public:
45.528 + virtual ~ICompilation() { };
45.529 + };
45.530 +
45.531 +
45.532 + /**
45.533 + * @brief Outlines the interface a Virtual Machine (JIT) must expose
45.534 + */
45.535 + class IVirtualMachine
45.536 + {
45.537 + public:
45.538 + /**
45.539 + * @brief Returns the current API version.
45.540 + */
45.541 + virtual unsigned int GetAPIVersion() =0;
45.542 +
45.543 + /**
45.544 + * @brief Returns the string name of a VM implementation.
45.545 + */
45.546 + virtual const char *GetVMName() =0;
45.547 +
45.548 + /**
45.549 + * @brief Begins a new compilation
45.550 + *
45.551 + * @param plugin Pointer to a plugin structure.
45.552 + * @return New compilation pointer.
45.553 + */
45.554 + virtual ICompilation *StartCompilation(sp_plugin_t *plugin) =0;
45.555 +
45.556 + /**
45.557 + * @brief Sets a compilation option.
45.558 + *
45.559 + * @param co Pointer to a compilation.
45.560 + * @param key Option key name.
45.561 + * @param val Option value string.
45.562 + * @return True if option could be set, false otherwise.
45.563 + */
45.564 + virtual bool SetCompilationOption(ICompilation *co, const char *key, const char *val) =0;
45.565 +
45.566 + /**
45.567 + * @brief Finalizes a compilation into a new sp_context_t.
45.568 + * Note: This will free the ICompilation pointer.
45.569 + *
45.570 + * @param co Compilation pointer.
45.571 + * @param err Filled with error code on exit.
45.572 + * @return New plugin context.
45.573 + */
45.574 + virtual sp_context_t *CompileToContext(ICompilation *co, int *err) =0;
45.575 +
45.576 + /**
45.577 + * @brief Aborts a compilation and frees the ICompilation pointer.
45.578 + *
45.579 + * @param co Compilation pointer.
45.580 + */
45.581 + virtual void AbortCompilation(ICompilation *co) =0;
45.582 +
45.583 + /**
45.584 + * @brief Frees any internal variable usage on a context.
45.585 + *
45.586 + * @param ctx Context structure pointer.
45.587 + */
45.588 + virtual void FreeContext(sp_context_t *ctx) =0;
45.589 +
45.590 + /**
45.591 + * @brief Calls the "execute" function on a context.
45.592 + *
45.593 + * @param ctx Executes a function in a context.
45.594 + * @param code_addr Index into the code section.
45.595 + * @param result Pointer to store result into.
45.596 + * @return Error code (if any).
45.597 + */
45.598 + virtual int ContextExecute(sp_context_t *ctx, uint32_t code_addr, cell_t *result) =0;
45.599 +
45.600 + /**
45.601 + * @brief Given a context and a code address, returns the index of the function.
45.602 + *
45.603 + * @param ctx Context to search.
45.604 + * @param code_addr Index into the code section.
45.605 + * @param result Pointer to store result into.
45.606 + * @return True if code index is valid, false otherwise.
45.607 + */
45.608 + virtual bool FunctionLookup(const sp_context_t *ctx, uint32_t code_addr, unsigned int *result) =0;
45.609 +
45.610 + /**
45.611 + * @brief Returns the number of functions defined in the context.
45.612 + *
45.613 + * @param ctx Context to search.
45.614 + * @return Number of functions.
45.615 + */
45.616 + virtual unsigned int FunctionCount(const sp_context_t *ctx) =0;
45.617 +
45.618 + /**
45.619 + * @brief Returns a version string.
45.620 + *
45.621 + * @return Versioning string.
45.622 + */
45.623 + virtual const char *GetVersionString() =0;
45.624 +
45.625 + /**
45.626 + * @brief Returns a string describing optimizations.
45.627 + *
45.628 + * @return String describing CPU specific optimizations.
45.629 + */
45.630 + virtual const char *GetCPUOptimizations() =0;
45.631 + };
45.632 +};
45.633 +
45.634 +#endif //_INCLUDE_SOURCEPAWN_VM_API_H_
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
46.2 +++ b/public/sourcepawn/sp_vm_base.h Fri Jan 19 05:33:04 2007 +0000
46.3 @@ -0,0 +1,16 @@
46.4 +#ifndef _INCLUDE_SOURCEPAWN_VM_BASE_H_
46.5 +#define _INCLUDE_SOURCEPAWN_VM_BASE_H_
46.6 +
46.7 +#include <sp_vm_api.h>
46.8 +
46.9 +/* :TODO: rename this to sp_vm_linkage.h */
46.10 +
46.11 +#if defined WIN32
46.12 +#define EXPORT_LINK extern "C" __declspec(dllexport)
46.13 +#else if defined __GNUC__
46.14 +#define EXPORT_LINK extern "C" __attribute__((visibility("default")))
46.15 +#endif
46.16 +
46.17 +typedef SourcePawn::IVirtualMachine *(*SP_GETVM_FUNC)(SourcePawn::ISourcePawnEngine *);
46.18 +
46.19 +#endif //_INCLUDE_SOURCEPAWN_VM_BASE_H_
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
47.2 +++ b/public/sourcepawn/sp_vm_types.h Fri Jan 19 05:33:04 2007 +0000
47.3 @@ -0,0 +1,251 @@
47.4 +#ifndef _INCLUDE_SOURCEPAWN_VM_TYPES_H
47.5 +#define _INCLUDE_SOURCEPAWN_VM_TYPES_H
47.6 +
47.7 +#include "sp_file_headers.h"
47.8 +
47.9 +typedef uint32_t ucell_t;
47.10 +typedef int32_t cell_t;
47.11 +typedef uint32_t funcid_t;
47.12 +
47.13 +#include "sp_typeutil.h"
47.14 +
47.15 +#define SP_MAX_EXEC_PARAMS 32 /* Maximum number of parameters in a function */
47.16 +
47.17 +/**
47.18 + * Error codes
47.19 + * NOTE: Be sure to update the error string table when changing these
47.20 + */
47.21 +#define SP_ERROR_NONE 0
47.22 +#define SP_ERROR_FILE_FORMAT 1 /* File format unrecognized */
47.23 +#define SP_ERROR_DECOMPRESSOR 2 /* A decompressor was not found */
47.24 +#define SP_ERROR_HEAPLOW 3 /* Not enough space left on the heap */
47.25 +#define SP_ERROR_PARAM 4 /* Invalid parameter or parameter type */
47.26 +#define SP_ERROR_INVALID_ADDRESS 5 /* A memory address was not valid */
47.27 +#define SP_ERROR_NOT_FOUND 6 /* The object in question was not found */
47.28 +#define SP_ERROR_INDEX 7 /* Invalid index parameter */
47.29 +#define SP_ERROR_STACKLOW 8 /* Nnot enough space left on the stack */
47.30 +#define SP_ERROR_NOTDEBUGGING 9 /* Debug mode was not on or debug section not found */
47.31 +#define SP_ERROR_INVALID_INSTRUCTION 10 /* Invalid instruction was encountered */
47.32 +#define SP_ERROR_MEMACCESS 11 /* Invalid memory access */
47.33 +#define SP_ERROR_STACKMIN 12 /* Stack went beyond its minimum value */
47.34 +#define SP_ERROR_HEAPMIN 13 /* Heap went beyond its minimum value */
47.35 +#define SP_ERROR_DIVIDE_BY_ZERO 14 /* Division by zero */
47.36 +#define SP_ERROR_ARRAY_BOUNDS 15 /* Array index is out of bounds */
47.37 +#define SP_ERROR_INSTRUCTION_PARAM 16 /* Instruction had an invalid parameter */
47.38 +#define SP_ERROR_STACKLEAK 17 /* A native leaked an item on the stack */
47.39 +#define SP_ERROR_HEAPLEAK 18 /* A native leaked an item on the heap */
47.40 +#define SP_ERROR_ARRAY_TOO_BIG 19 /* A dynamic array is too big */
47.41 +#define SP_ERROR_TRACKER_BOUNDS 20 /* Tracker stack is out of bounds */
47.42 +#define SP_ERROR_INVALID_NATIVE 21 /* Native was pending or invalid */
47.43 +#define SP_ERROR_PARAMS_MAX 22 /* Maximum number of parameters reached */
47.44 +#define SP_ERROR_NATIVE 23 /* Error originates from a native */
47.45 +
47.46 +/**********************************************
47.47 + *** The following structures are reference structures.
47.48 + *** They are not essential to the API, but are used
47.49 + *** to hold the back end database format of the plugin
47.50 + *** binary.
47.51 + **********************************************/
47.52 +
47.53 +/**
47.54 + * Information about the core plugin tables.
47.55 + * These may or may not be present!
47.56 + */
47.57 +typedef struct sp_plugin_infotab_s
47.58 +{
47.59 + const char *stringbase; /* base of string table */
47.60 + uint32_t publics_num; /* number of publics */
47.61 + sp_file_publics_t *publics; /* public table */
47.62 + uint32_t natives_num; /* number of natives */
47.63 + sp_file_natives_t *natives; /* native table */
47.64 + uint32_t pubvars_num; /* number of pubvars */
47.65 + sp_file_pubvars_t *pubvars; /* pubvars table */
47.66 + uint32_t libraries_num; /* number of libraries */
47.67 + sp_file_libraries_t *lib; /* library table */
47.68 +} sp_plugin_infotab_t;
47.69 +
47.70 +/**
47.71 + * Information about the plugin's debug tables.
47.72 + * These are all present if one is present.
47.73 + */
47.74 +typedef struct sp_plugin_debug_s
47.75 +{
47.76 + const char *stringbase; /* base of string table */
47.77 + uint32_t files_num; /* number of files */
47.78 + sp_fdbg_file_t *files; /* files table */
47.79 + uint32_t lines_num; /* number of lines */
47.80 + sp_fdbg_line_t *lines; /* lines table */
47.81 + uint32_t syms_num; /* number of symbols */
47.82 + sp_fdbg_symbol_t *symbols; /* symbol table */
47.83 +} sp_plugin_debug_t;
47.84 +
47.85 +#define SP_FA_SELF_EXTERNAL (1<<0)
47.86 +#define SP_FA_BASE_EXTERNAL (1<<1)
47.87 +
47.88 +/**
47.89 + * The rebased, in-memory format of a plugin.
47.90 + * This differs from the on-disk structure to ensure
47.91 + * that the format is properly read.
47.92 + */
47.93 +typedef struct sp_plugin_s
47.94 +{
47.95 + uint8_t *base; /* base of memory */
47.96 + uint8_t *pcode; /* p-code */
47.97 + uint32_t pcode_size; /* size of p-code */
47.98 + uint8_t *data; /* data size */
47.99 + uint32_t data_size; /* size of data */
47.100 + uint32_t memory; /* required memory */
47.101 + uint16_t flags; /* code flags */
47.102 + uint32_t allocflags; /* allocation flags */
47.103 + sp_plugin_infotab_t info; /* base info table */
47.104 + sp_plugin_debug_t debug; /* debug info table */
47.105 +} sp_plugin_t;
47.106 +
47.107 +/** Forward declarations */
47.108 +
47.109 +namespace SourcePawn
47.110 +{
47.111 + class IPluginContext;
47.112 + class IVirtualMachine;
47.113 +};
47.114 +
47.115 +struct sp_context_s;
47.116 +
47.117 +typedef cell_t (*SPVM_NATIVE_FUNC)(SourcePawn::IPluginContext *, const cell_t *);
47.118 +
47.119 +/**********************************************
47.120 + *** The following structures are bound to the VM/JIT.
47.121 + *** Changing them will result in necessary recompilation.
47.122 + **********************************************/
47.123 +
47.124 +/**
47.125 + * Offsets and names to a public function.
47.126 + * By default, these point back to the string table
47.127 + * in the sp_plugin_infotab_t structure.
47.128 + */
47.129 +typedef struct sp_public_s
47.130 +{
47.131 + funcid_t funcid; /* encoded function id */
47.132 + uint32_t code_offs; /* code offset */
47.133 + const char *name; /* name */
47.134 +} sp_public_t;
47.135 +
47.136 +/**
47.137 + * Offsets and names to public variables.
47.138 + * The offset is relocated and the name by default
47.139 + * points back to the sp_plugin_infotab_t structure.
47.140 + */
47.141 +typedef struct sp_pubvar_s
47.142 +{
47.143 + cell_t *offs; /* pointer to data */
47.144 + const char *name; /* name */
47.145 +} sp_pubvar_t;
47.146 +
47.147 +#define SP_NATIVE_UNBOUND (0) /* Native is undefined */
47.148 +#define SP_NATIVE_BOUND (1) /* Native is bound */
47.149 +
47.150 +/**
47.151 + * Native lookup table, by default names
47.152 + * point back to the sp_plugin_infotab_t structure.
47.153 + * A native is NULL if unit
47.154 + */
47.155 +typedef struct sp_native_s
47.156 +{
47.157 + SPVM_NATIVE_FUNC pfn; /* function pointer */
47.158 + const char * name; /* name of function */
47.159 + uint32_t status; /* status flags */
47.160 +} sp_native_t;
47.161 +
47.162 +/**
47.163 + * Used for setting natives from modules/host apps.
47.164 + */
47.165 +typedef struct sp_nativeinfo_s
47.166 +{
47.167 + const char *name;
47.168 + SPVM_NATIVE_FUNC func;
47.169 +} sp_nativeinfo_t;
47.170 +
47.171 +/**
47.172 + * Debug file table
47.173 + */
47.174 +typedef struct sp_debug_file_s
47.175 +{
47.176 + uint32_t addr; /* address into code */
47.177 + const char * name; /* name of file */
47.178 +} sp_debug_file_t;
47.179 +
47.180 +/**
47.181 + * Note that line is missing. It is not necessary since
47.182 + * this can be retrieved from the base plugin info.
47.183 + */
47.184 +typedef struct sp_debug_line_s
47.185 +{
47.186 + uint32_t addr; /* address into code */
47.187 + uint32_t line; /* line no. */
47.188 +} sp_debug_line_t;
47.189 +
47.190 +typedef sp_fdbg_arraydim_t sp_debug_arraydim_t;
47.191 +
47.192 +/**
47.193 + * The majority of this struct is already located in the parent
47.194 + * block. Thus, only the relocated portions are required.
47.195 + */
47.196 +typedef struct sp_debug_symbol_s
47.197 +{
47.198 + uint32_t codestart; /* relocated code address */
47.199 + uint32_t codeend; /* relocated code end address */
47.200 + const char * name; /* relocated name */
47.201 + sp_debug_arraydim_t *dims; /* relocated dimension struct, if any */
47.202 + sp_fdbg_symbol_t *sym; /* pointer to original symbol */
47.203 +} sp_debug_symbol_t;
47.204 +
47.205 +/**
47.206 + * Breaks into a debugger
47.207 + * Params:
47.208 + * [0] - plugin context
47.209 + * [1] - frm
47.210 + * [2] - cip
47.211 + */
47.212 +typedef int (*SPVM_DEBUGBREAK)(struct sp_context_s *, uint32_t, uint32_t);
47.213 +
47.214 +#define SPFLAG_PLUGIN_DEBUG (1<<0) /* plugin is in debug mode */
47.215 +
47.216 +/**
47.217 + * This is the heart of the VM. It contains all of the runtime
47.218 + * information about a plugin context.
47.219 + * Note that user[0..3] can be used for any user based pointers.
47.220 + * vm[0..3] should not be touched, as it is reserved for the VM.
47.221 + */
47.222 +typedef struct sp_context_s
47.223 +{
47.224 + /* general/parent information */
47.225 + void *codebase; /* base of generated code and memory */
47.226 + sp_plugin_t *plugin; /* pointer back to parent information */
47.227 + SourcePawn::IPluginContext *context; /* pointer to IPluginContext */
47.228 + SourcePawn::IVirtualMachine *vmbase; /* pointer to IVirtualMachine */
47.229 + void *user[4]; /* user specific pointers */
47.230 + void *vm[4]; /* VM specific pointers */
47.231 + uint32_t flags; /* compilation flags */
47.232 + SPVM_DEBUGBREAK dbreak; /* debug break function */
47.233 + /* context runtime information */
47.234 + uint8_t *memory; /* data chunk */
47.235 + ucell_t mem_size; /* total memory size; */
47.236 + cell_t data_size; /* data chunk size, always starts at 0 */
47.237 + cell_t heap_base; /* where the heap starts */
47.238 + /* execution specific data */
47.239 + cell_t hp; /* heap pointer */
47.240 + cell_t sp; /* stack pointer */
47.241 + cell_t frm; /* frame pointer */
47.242 + uint32_t pushcount; /* push count */
47.243 + int32_t n_err; /* error code set by a native */
47.244 + uint32_t n_idx; /* current native index being executed */
47.245 + /* context rebased database */
47.246 + sp_public_t *publics; /* public functions table */
47.247 + sp_pubvar_t *pubvars; /* public variables table */
47.248 + sp_native_t *natives; /* natives table */
47.249 + sp_debug_file_t *files; /* files */
47.250 + sp_debug_line_t *lines; /* lines */
47.251 + sp_debug_symbol_t *symbols; /* symbols */
47.252 +} sp_context_t;
47.253 +
47.254 +#endif //_INCLUDE_SOURCEPAWN_VM_TYPES_H