Skip to content

Commit

Permalink
Plugin API: added IAGSEngine.GetDynamicArrayLength()
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Dec 20, 2024
1 parent fb2e404 commit 0507a7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Engine/plugin/agsplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,16 @@ void *IAGSEngine::CreateDynamicArray(size_t elem_count, size_t elem_size, bool i
return obj_ref.Obj;
}

size_t IAGSEngine::GetDynamicArrayLength(const void *arr)
{
return arr ? CCDynamicArray::GetHeader(arr).ElemCount : 0u;
}

size_t IAGSEngine::GetDynamicArraySize(const void *arr)
{
return arr ? CCDynamicArray::GetHeader(arr).TotalSize : 0u;
}

// *********** General plugin implementation **********

void pl_stop_plugins() {
Expand Down
7 changes: 6 additions & 1 deletion Engine/plugin/agsplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,12 @@ class IAGSEngine {
// You may return this pointer from the registered plugin's function just like any other
// managed object pointer.
AGSIFUNC(void*) CreateDynamicArray(size_t elem_count, size_t elem_size, bool is_managed_type);

// Retrieves dynamic array's length (number of elements).
// You should pass a dynamic array object either received from the engine in your registered
// script function, or created by you with CreateDynamicArray().
AGSIFUNC(size_t) GetDynamicArrayLength(const void *arr);
// Retrieves dynamic array's size (total capacity in bytes).
AGSIFUNC(size_t) GetDynamicArraySize(const void *arr);
};


Expand Down

0 comments on commit 0507a7b

Please sign in to comment.