Add ArrayStack.Clear native (#1676)

This commit is contained in:
Corey D 2022-01-22 22:26:21 +11:00 committed by Your Name
parent 542b7673d6
commit fb0144900f
2 changed files with 20 additions and 0 deletions

View File

@ -83,6 +83,22 @@ static cell_t CreateStack(IPluginContext *pContext, const cell_t *params)
return hndl;
}
static cell_t ClearStack(IPluginContext *pContext, const cell_t *params)
{
CellArray *array;
HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
}
array->clear();
return 1;
}
static cell_t CloneStack(IPluginContext *pContext, const cell_t *params)
{
CellArray *oldArray;
@ -425,6 +441,7 @@ REGISTER_NATIVES(cellStackNatives)
// Transitional syntax support.
{"ArrayStack.ArrayStack", CreateStack},
{"ArrayStack.Clear", ClearStack},
{"ArrayStack.Clone", CloneStack},
{"ArrayStack.Pop", ArrayStack_Pop},
{"ArrayStack.PopString", ArrayStack_PopString},

View File

@ -54,6 +54,9 @@ methodmap ArrayStack < Handle
// new Array[X][32]
public native ArrayStack(int blocksize=1);
// Clears a stack of all entries.
public native void Clear();
// Clones an stack, returning a new handle with the same size and data.
// This should NOT be confused with CloneHandle. This is a completely new
// handle with the same data but no relation to the original. It should