Breakage alert :\

ThrowNativeErrorEx now returns 0 for convenience
PushCellByRef and PushFloatByRef no longer have a flags parameter because it was almost pointless

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40590
This commit is contained in:
Scott Ehlert 2007-03-07 18:24:09 +00:00
parent 876e3da8e3
commit dfed71eb28
7 changed files with 22 additions and 19 deletions

View File

@ -297,7 +297,7 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter)
{ {
func->PushStringEx((char *)param->byref.orig_addr, param->byref.cells, param->byref.sz_flags, param->byref.flags); func->PushStringEx((char *)param->byref.orig_addr, param->byref.cells, param->byref.sz_flags, param->byref.flags);
} else if (type == Param_Float || type == Param_Cell) { } else if (type == Param_Float || type == Param_Cell) {
func->PushCellByRef(&param->val, 0); func->PushCellByRef(&param->val);
} else { } else {
func->PushArray(param->byref.orig_addr, param->byref.cells, NULL, param->byref.flags); func->PushArray(param->byref.orig_addr, param->byref.cells, NULL, param->byref.flags);
assert(type == Param_Array || type == Param_FloatByRef || type == Param_CellByRef); assert(type == Param_Array || type == Param_FloatByRef || type == Param_CellByRef);
@ -434,7 +434,7 @@ int CForward::PushFloat(float number)
return SP_ERROR_NONE; return SP_ERROR_NONE;
} }
int CForward::PushCellByRef(cell_t *cell, int flags) int CForward::PushCellByRef(cell_t *cell)
{ {
if (m_curparam < m_numparams) if (m_curparam < m_numparams)
{ {
@ -452,13 +452,13 @@ int CForward::PushCellByRef(cell_t *cell, int flags)
m_params[m_curparam].pushedas = Param_CellByRef; m_params[m_curparam].pushedas = Param_CellByRef;
} }
_Int_PushArray(cell, 1, flags); _Int_PushArray(cell, 1, SM_PARAM_COPYBACK);
m_curparam++; m_curparam++;
return SP_ERROR_NONE; return SP_ERROR_NONE;
} }
int CForward::PushFloatByRef(float *num, int flags) int CForward::PushFloatByRef(float *num)
{ {
if (m_curparam < m_numparams) if (m_curparam < m_numparams)
{ {
@ -476,7 +476,7 @@ int CForward::PushFloatByRef(float *num, int flags)
m_params[m_curparam].pushedas = Param_FloatByRef; m_params[m_curparam].pushedas = Param_FloatByRef;
} }
_Int_PushArray((cell_t *)num, 1, flags); _Int_PushArray((cell_t *)num, 1, SM_PARAM_COPYBACK);
m_curparam++; m_curparam++;
return SP_ERROR_NONE; return SP_ERROR_NONE;

View File

@ -47,9 +47,9 @@ class CForward : public IChangeableForward
{ {
public: //ICallable public: //ICallable
virtual int PushCell(cell_t cell); virtual int PushCell(cell_t cell);
virtual int PushCellByRef(cell_t *cell, int flags); virtual int PushCellByRef(cell_t *cell);
virtual int PushFloat(float number); virtual int PushFloat(float number);
virtual int PushFloatByRef(float *number, int flags); virtual int PushFloatByRef(float *number);
virtual int PushArray(cell_t *inarray, unsigned int cells, cell_t **phys_addr, int flags); virtual int PushArray(cell_t *inarray, unsigned int cells, cell_t **phys_addr, int flags);
virtual int PushString(const char *string); virtual int PushString(const char *string);
virtual int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags); virtual int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags);

View File

@ -212,11 +212,11 @@ void BaseContext::SetErrorMessage(const char *msg, va_list ap)
vsnprintf(m_MsgCache, sizeof(m_MsgCache), msg, ap); vsnprintf(m_MsgCache, sizeof(m_MsgCache), msg, ap);
} }
void BaseContext::ThrowNativeErrorEx(int error, const char *msg, ...) cell_t BaseContext::ThrowNativeErrorEx(int error, const char *msg, ...)
{ {
if (!m_InExec) if (!m_InExec)
{ {
return; return 0;
} }
ctx->n_err = error; ctx->n_err = error;
@ -228,6 +228,8 @@ void BaseContext::ThrowNativeErrorEx(int error, const char *msg, ...)
SetErrorMessage(msg, ap); SetErrorMessage(msg, ap);
va_end(ap); va_end(ap);
} }
return 0;
} }
cell_t BaseContext::ThrowNativeError(const char *msg, ...) cell_t BaseContext::ThrowNativeError(const char *msg, ...)

View File

@ -61,7 +61,7 @@ namespace SourcePawn
virtual int BindNative(const sp_nativeinfo_t *native); virtual int BindNative(const sp_nativeinfo_t *native);
virtual int BindNativeToAny(SPVM_NATIVE_FUNC native); virtual int BindNativeToAny(SPVM_NATIVE_FUNC native);
virtual int Execute(uint32_t code_addr, cell_t *result); virtual int Execute(uint32_t code_addr, cell_t *result);
virtual void ThrowNativeErrorEx(int error, const char *msg, ...); virtual cell_t ThrowNativeErrorEx(int error, const char *msg, ...);
virtual cell_t ThrowNativeError(const char *msg, ...); virtual cell_t ThrowNativeError(const char *msg, ...);
virtual IPluginFunction *GetFunctionByName(const char *public_name); virtual IPluginFunction *GetFunctionByName(const char *public_name);
virtual IPluginFunction *GetFunctionById(funcid_t func_id); virtual IPluginFunction *GetFunctionById(funcid_t func_id);

View File

@ -79,14 +79,14 @@ int CFunction::PushCell(cell_t cell)
return SP_ERROR_NONE; return SP_ERROR_NONE;
} }
int CFunction::PushCellByRef(cell_t *cell, int flags) int CFunction::PushCellByRef(cell_t *cell)
{ {
if (m_curparam >= SP_MAX_EXEC_PARAMS) if (m_curparam >= SP_MAX_EXEC_PARAMS)
{ {
return SetError(SP_ERROR_PARAMS_MAX); return SetError(SP_ERROR_PARAMS_MAX);
} }
return PushArray(cell, 1, NULL, flags); return PushArray(cell, 1, NULL, SM_PARAM_COPYBACK);
} }
int CFunction::PushFloat(float number) int CFunction::PushFloat(float number)
@ -96,9 +96,9 @@ int CFunction::PushFloat(float number)
return PushCell(val); return PushCell(val);
} }
int CFunction::PushFloatByRef(float *number, int flags) int CFunction::PushFloatByRef(float *number)
{ {
return PushCellByRef((cell_t *)number, flags); return PushCellByRef((cell_t *)number);
} }
int CFunction::PushArray(cell_t *inarray, unsigned int cells, cell_t **phys_addr, int copyback) int CFunction::PushArray(cell_t *inarray, unsigned int cells, cell_t **phys_addr, int copyback)

View File

@ -35,9 +35,9 @@ public:
CFunction(uint32_t code_addr, IPluginContext *pContext); CFunction(uint32_t code_addr, IPluginContext *pContext);
public: public:
virtual int PushCell(cell_t cell); virtual int PushCell(cell_t cell);
virtual int PushCellByRef(cell_t *cell, int flags); virtual int PushCellByRef(cell_t *cell);
virtual int PushFloat(float number); virtual int PushFloat(float number);
virtual int PushFloatByRef(float *number, int flags); virtual int PushFloatByRef(float *number);
virtual int PushArray(cell_t *inarray, unsigned int cells, cell_t **phys_addr, int copyback); virtual int PushArray(cell_t *inarray, unsigned int cells, cell_t **phys_addr, int copyback);
virtual int PushString(const char *string); virtual int PushString(const char *string);
virtual int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags); virtual int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags);

View File

@ -70,7 +70,7 @@ namespace SourcePawn
* @param flags Copy-back flags. * @param flags Copy-back flags.
* @return Error code, if any. * @return Error code, if any.
*/ */
virtual int PushCellByRef(cell_t *cell, int flags) =0; virtual int PushCellByRef(cell_t *cell) =0;
/** /**
* @brief Pushes a float onto the current call. * @brief Pushes a float onto the current call.
@ -91,7 +91,7 @@ namespace SourcePawn
& @param flags Copy-back flags. & @param flags Copy-back flags.
* @return Error code, if any. * @return Error code, if any.
*/ */
virtual int PushFloatByRef(float *number, int flags) =0; virtual int PushFloatByRef(float *number) =0;
/** /**
* @brief Pushes an array of cells onto the current call. * @brief Pushes an array of cells onto the current call.
@ -505,8 +505,9 @@ namespace SourcePawn
* @param error The error number to set. * @param error The error number to set.
* @param msg Custom error message format. NULL to use default. * @param msg Custom error message format. NULL to use default.
* @param ... Message format arguments, if any. * @param ... Message format arguments, if any.
* @return 0 for convenience.
*/ */
virtual void ThrowNativeErrorEx(int error, const char *msg, ...) =0; virtual cell_t ThrowNativeErrorEx(int error, const char *msg, ...) =0;
/** /**
* @brief Throws a generic native error and halts any current execution. * @brief Throws a generic native error and halts any current execution.