Add ArrayStack.Clear native (#1676)
This commit is contained in:
parent
542b7673d6
commit
fb0144900f
@ -83,6 +83,22 @@ static cell_t CreateStack(IPluginContext *pContext, const cell_t *params)
|
|||||||
return hndl;
|
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)
|
static cell_t CloneStack(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
CellArray *oldArray;
|
CellArray *oldArray;
|
||||||
@ -425,6 +441,7 @@ REGISTER_NATIVES(cellStackNatives)
|
|||||||
|
|
||||||
// Transitional syntax support.
|
// Transitional syntax support.
|
||||||
{"ArrayStack.ArrayStack", CreateStack},
|
{"ArrayStack.ArrayStack", CreateStack},
|
||||||
|
{"ArrayStack.Clear", ClearStack},
|
||||||
{"ArrayStack.Clone", CloneStack},
|
{"ArrayStack.Clone", CloneStack},
|
||||||
{"ArrayStack.Pop", ArrayStack_Pop},
|
{"ArrayStack.Pop", ArrayStack_Pop},
|
||||||
{"ArrayStack.PopString", ArrayStack_PopString},
|
{"ArrayStack.PopString", ArrayStack_PopString},
|
||||||
|
@ -54,6 +54,9 @@ methodmap ArrayStack < Handle
|
|||||||
// new Array[X][32]
|
// new Array[X][32]
|
||||||
public native ArrayStack(int blocksize=1);
|
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.
|
// 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
|
// 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
|
// handle with the same data but no relation to the original. It should
|
||||||
|
Loading…
Reference in New Issue
Block a user