Add block parameter to various ArrayList functions (#1656)
* Add block parameter to FindString * Add block parameter for GetString & GetArray * Fix buffer overflow issues * Fix wrong return * Add size parameter to SetArrayString
This commit is contained in:
@@ -129,9 +129,11 @@ methodmap ArrayList < Handle {
|
||||
// @param index Index in the array.
|
||||
// @param buffer Buffer to copy to.
|
||||
// @param maxlength Maximum size of the buffer.
|
||||
// @param block Optionally specify which block to read from
|
||||
// (useful if the blocksize > 0).
|
||||
// @return Number of characters copied.
|
||||
// @error Invalid index.
|
||||
public native int GetString(int index, char[] buffer, int maxlength);
|
||||
public native int GetString(int index, char[] buffer, int maxlength, int block=0);
|
||||
|
||||
// Retrieves an array of cells from an array.
|
||||
//
|
||||
@@ -139,9 +141,11 @@ methodmap ArrayList < Handle {
|
||||
// @param buffer Buffer to store the array in.
|
||||
// @param size If not set, assumes the buffer size is equal to the
|
||||
// blocksize. Otherwise, the size passed is used.
|
||||
// @param block Optionally specify which block to read from
|
||||
// (useful if the blocksize > 0).
|
||||
// @return Number of cells copied.
|
||||
// @error Invalid index.
|
||||
public native int GetArray(int index, any[] buffer, int size=-1);
|
||||
public native int GetArray(int index, any[] buffer, int size=-1, int block=0);
|
||||
|
||||
// Sets a cell value in an array.
|
||||
//
|
||||
@@ -157,9 +161,13 @@ methodmap ArrayList < Handle {
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @param value String value to set.
|
||||
// @param size If not set, assumes the buffer size is equal to the
|
||||
// blocksize. Otherwise, the size passed is used.
|
||||
// @param block Optionally specify which block to write to
|
||||
// (useful if the blocksize > 0).
|
||||
// @return Number of characters copied.
|
||||
// @error Invalid index.
|
||||
public native int SetString(int index, const char[] value);
|
||||
public native int SetString(int index, const char[] value, int size=-1, int block=0);
|
||||
|
||||
// Sets an array of cells in an array.
|
||||
//
|
||||
@@ -167,9 +175,11 @@ methodmap ArrayList < Handle {
|
||||
// @param values Array to copy.
|
||||
// @param size If not set, assumes the buffer size is equal to the
|
||||
// blocksize. Otherwise, the size passed is used.
|
||||
// @param block Optionally specify which block to write to
|
||||
// (useful if the blocksize > 0).
|
||||
// @return Number of cells copied.
|
||||
// @error Invalid index.
|
||||
public native int SetArray(int index, const any[] values, int size=-1);
|
||||
public native int SetArray(int index, const any[] values, int size=-1, int block=0);
|
||||
|
||||
// Shifts an array up. All array contents after and including the given
|
||||
// index are shifted up by one, and the given index is then "free."
|
||||
@@ -198,8 +208,9 @@ methodmap ArrayList < Handle {
|
||||
// the string cannot be located, -1 will be returned.
|
||||
//
|
||||
// @param item String to search for
|
||||
// @param block Optionally which block to search in
|
||||
// @return Array index, or -1 on failure
|
||||
public native int FindString(const char[] item);
|
||||
public native int FindString(const char[] item, int block=0);
|
||||
|
||||
// Returns the index for the first occurrence of the provided value. If the
|
||||
// value cannot be located, -1 will be returned.
|
||||
@@ -349,10 +360,12 @@ native any GetArrayCell(Handle array, int index, int block=0, bool asChar=false)
|
||||
* @param index Index in the array.
|
||||
* @param buffer Buffer to copy to.
|
||||
* @param maxlength Maximum size of the buffer.
|
||||
* @param block Optionally specify which block to read from
|
||||
* (useful if the blocksize > 0).
|
||||
* @return Number of characters copied.
|
||||
* @error Invalid Handle or invalid index.
|
||||
*/
|
||||
native int GetArrayString(Handle array, int index, char[] buffer, int maxlength);
|
||||
native int GetArrayString(Handle array, int index, char[] buffer, int maxlength, int block=0);
|
||||
|
||||
/**
|
||||
* Retrieves an array of cells from an array.
|
||||
@@ -362,10 +375,12 @@ native int GetArrayString(Handle array, int index, char[] buffer, int maxlength)
|
||||
* @param buffer Buffer to store the array in.
|
||||
* @param size If not set, assumes the buffer size is equal to the
|
||||
* blocksize. Otherwise, the size passed is used.
|
||||
* @param block Optionally specify which block to read from
|
||||
* (useful if the blocksize > 0).
|
||||
* @return Number of cells copied.
|
||||
* @error Invalid Handle or invalid index.
|
||||
*/
|
||||
native int GetArrayArray(Handle array, int index, any[] buffer, int size=-1);
|
||||
native int GetArrayArray(Handle array, int index, any[] buffer, int size=-1, int block=0);
|
||||
|
||||
/**
|
||||
* Sets a cell value in an array.
|
||||
@@ -386,10 +401,14 @@ native void SetArrayCell(Handle array, int index, any value, int block=0, bool a
|
||||
* @param array Array Handle.
|
||||
* @param index Index in the array.
|
||||
* @param value String value to set.
|
||||
* @param size If not set, assumes the buffer size is equal to the
|
||||
* blocksize. Otherwise, the size passed is used.
|
||||
* @param block Optionally specify which block to write to
|
||||
* (useful if the blocksize > 0).
|
||||
* @return Number of characters copied.
|
||||
* @error Invalid Handle or invalid index.
|
||||
*/
|
||||
native int SetArrayString(Handle array, int index, const char[] value);
|
||||
native int SetArrayString(Handle array, int index, const char[] value, int size=-1, int block=0);
|
||||
|
||||
/**
|
||||
* Sets an array of cells in an array.
|
||||
@@ -399,10 +418,12 @@ native int SetArrayString(Handle array, int index, const char[] value);
|
||||
* @param values Array to copy.
|
||||
* @param size If not set, assumes the buffer size is equal to the
|
||||
* blocksize. Otherwise, the size passed is used.
|
||||
* @param block Optionally specify which block to write to
|
||||
* (useful if the blocksize > 0).
|
||||
* @return Number of cells copied.
|
||||
* @error Invalid Handle or invalid index.
|
||||
*/
|
||||
native int SetArrayArray(Handle array, int index, const any[] values, int size=-1);
|
||||
native int SetArrayArray(Handle array, int index, const any[] values, int size=-1, int block=0);
|
||||
|
||||
/**
|
||||
* Shifts an array up. All array contents after and including the given
|
||||
@@ -442,10 +463,11 @@ native void SwapArrayItems(Handle array, int index1, int index2);
|
||||
*
|
||||
* @param array Array Handle.
|
||||
* @param item String to search for
|
||||
* @param block Optionally which block to search in
|
||||
* @return Array index, or -1 on failure
|
||||
* @error Invalid Handle
|
||||
*/
|
||||
native int FindStringInArray(Handle array, const char[] item);
|
||||
native int FindStringInArray(Handle array, const char[] item, int block=0);
|
||||
|
||||
/**
|
||||
* Returns the index for the first occurrence of the provided value. If the value
|
||||
|
||||
Reference in New Issue
Block a user