1.1 --- a/core/interfaces/IPluginFunction.h Sun Nov 12 02:27:27 2006 +0000
1.2 +++ b/core/interfaces/IPluginFunction.h Sun Nov 12 09:51:39 2006 +0000
1.3 @@ -5,10 +5,7 @@
1.4
1.5 namespace SourceMod
1.6 {
1.7 - #define SMFUNC_COPYBACK_NONE (0) /* Never copy an array back */
1.8 - #define SMFUNC_COPYBACK_ONCE (1<<0) /* Copy an array back after call */
1.9 - #define SMFUNC_COPYBACK_ALWAYS (1<<1) /* Copy an array back after subsequent calls (forwards) */
1.10 - #define SMFUNC_ARRAY_NOINIT (1<<2) /* The array is not copied at first, but copyback is performed */
1.11 + #define SM_FUNCFLAG_COPYBACK (1<<0) /* Copy an array/reference back after call */
1.12
1.13 /**
1.14 * @brief Represents what a function needs to implement in order to be callable.
1.15 @@ -27,6 +24,9 @@
1.16 /**
1.17 * @brief Pushes a cell by reference onto the current call.
1.18 * NOTE: On Execute, the pointer passed will be modified if copyback is enabled.
1.19 + * NOTE: By reference parameters are cached and thus are not read until execution.
1.20 + * This means you cannot push a pointer, change it, and push it again and expect
1.21 + * two different values to come out.
1.22 *
1.23 * @param cell Address containing parameter value to push.
1.24 * @param flags Copy-back flags.
1.25 @@ -45,6 +45,9 @@
1.26 /**
1.27 * @brief Pushes a float onto the current call by reference.
1.28 * NOTE: On Execute, the pointer passed will be modified if copyback is enabled.
1.29 + * NOTE: By reference parameters are cached and thus are not read until execution.
1.30 + * This means you cannot push a pointer, change it, and push it again and expect
1.31 + * two different values to come out.
1.32 *
1.33 * @param float Parameter value to push.
1.34 & @param flags Copy-back flags.
1.35 @@ -53,20 +56,12 @@
1.36 virtual int PushFloatByRef(float *number, int flags) =0;
1.37
1.38 /**
1.39 - * @brief Pushes an array of cells onto the current call, each cell individually.
1.40 - * NOTE: This is essentially a crippled version of PushArray().
1.41 - *
1.42 - * @param array Array of cells.
1.43 - * @param numcells Number of cells in array.
1.44 - * @param each Whether or not to push as an array or individual cells.
1.45 - * @return Error code, if any.
1.46 - */
1.47 - virtual int PushCells(cell_t array[], unsigned int numcells, bool each) =0;
1.48 -
1.49 - /**
1.50 * @brief Pushes an array of cells onto the current call.
1.51 * NOTE: On Execute, the pointer passed will be modified if non-NULL and copy-back
1.52 * is enabled.
1.53 + * NOTE: By reference parameters are cached and thus are not read until execution.
1.54 + * This means you cannot push a pointer, change it, and push it again and expect
1.55 + * two different values to come out.
1.56 *
1.57 * @param array Array to copy, NULL if no initial array should be copied.
1.58 * @param cells Number of cells to allocate and optionally read from the input array.
1.59 @@ -77,7 +72,7 @@
1.60 virtual int PushArray(cell_t *inarray,
1.61 unsigned int cells,
1.62 cell_t **phys_addr,
1.63 - int flags=SMFUNC_COPYBACK_NONE) =0;
1.64 + int flags=0) =0;
1.65
1.66 /**
1.67 * @brief Pushes a string onto the current call.
1.68 @@ -95,7 +90,7 @@
1.69 * @param flags Copy-back flags.
1.70 * @return Error code, if any.
1.71 */
1.72 - virtual int PushStringByRef(char *string, int flags) =0;
1.73 + virtual int PushStringEx(char *string, int flags) =0;
1.74
1.75 /**
1.76 * @brief Cancels a function call that is being pushed but not yet executed.
1.77 @@ -104,30 +99,6 @@
1.78 virtual void Cancel() =0;
1.79 };
1.80
1.81 -
1.82 - /**
1.83 - * @brief Used for copy-back notification
1.84 - */
1.85 - class IFunctionCopybackReader
1.86 - {
1.87 - public:
1.88 - /**
1.89 - * @brief Called before an array is copied back.
1.90 - *
1.91 - * @param param Parameter index.
1.92 - * @param cells Number of cells in the array.
1.93 - * @param source_addr Source address in the plugin that will be copied.
1.94 - * @param orig_addr Destination addres in plugin that will be overwritten.
1.95 - * @param flags Copy flags.
1.96 - * @return True to copy back, false otherwise.
1.97 - */
1.98 - virtual bool OnCopybackArray(unsigned int param,
1.99 - unsigned int cells,
1.100 - cell_t *source_addr,
1.101 - cell_t *orig_addr,
1.102 - int flags) =0;
1.103 - };
1.104 -
1.105 /**
1.106 * @brief Encapsulates a function call in a plugin.
1.107 * NOTE: Function calls must be atomic to one execution context.
1.108 @@ -143,7 +114,7 @@
1.109 * @param reader Copy-back listener. NULL to specify
1.110 * @return Error code, if any.
1.111 */
1.112 - virtual int Execute(cell_t *result, IFunctionCopybackReader *reader) =0;
1.113 + virtual int Execute(cell_t *result) =0;
1.114
1.115 /**
1.116 * @brief Executes the function with the given parameter array.
1.117 @@ -172,28 +143,6 @@
1.118 * @return Address, or NULL if invalid parameter specified.
1.119 */
1.120 virtual cell_t *GetAddressOfPushedParam(unsigned int param) =0;
1.121 -
1.122 -#if 0
1.123 - /**
1.124 - * @brief Clones the function object. This can be used to maintain a private copy.
1.125 - * The copy retains no push states and must be freeed with ReleaseCopy().
1.126 - */
1.127 - virtual IPluginFunction *Copy() =0;
1.128 -
1.129 - /**
1.130 - * @brief If this object is a clone, this function must be called to destroy it.
1.131 - */
1.132 - virtual void ReleaseCopy() =0;
1.133 -
1.134 - /**
1.135 - * @brief Returns original function pointer, if any.
1.136 - * Note: IsCopyOf() will return the original non-copy, even if used
1.137 - * from a copy.
1.138 - *
1.139 - * @return The original object that this was sourced from.
1.140 - */
1.141 - virtual IPluginFunction *IsCopyOf() =0;
1.142 -#endif
1.143 };
1.144 };
1.145