Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit c2fa711

Browse files
committed
libscript: Add Extend() and Push() methods to MCAutoScriptObjectRefArrayBase
1 parent 04d0966 commit c2fa711

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

libscript/include/libscript/script-auto.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ class MCAutoScriptObjectRefArrayBase
111111
return MCMemoryResizeArray (p_new_count, m_values, m_count);
112112
}
113113

114+
bool Extend(uindex_t p_new_count)
115+
{
116+
MCAssert(p_new_count >= m_count);
117+
return Resize(p_new_count);
118+
}
119+
120+
bool Push(T p_value)
121+
{
122+
if (!(nil == m_values ? New(1) : Extend(m_count + 1)))
123+
return false;
124+
m_values[m_count - 1] = REF(p_value);
125+
return true;
126+
}
127+
114128
T & operator [] (const int p_index)
115129
{
116130
MCAssert (nil != m_values);

0 commit comments

Comments
 (0)