2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
gbx_c_array.c
|
|
|
|
|
2018-02-12 02:53:46 +01:00
|
|
|
(c) 2000-2017 Benoît Minisini <g4mba5@gmail.com>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2009-08-17 12:41:51 +02:00
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
2007-12-30 17:41:49 +01:00
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#define __GBX_C_ARRAY_C
|
|
|
|
|
|
|
|
#include "gbx_info.h"
|
|
|
|
|
|
|
|
#ifndef GBX_INFO
|
|
|
|
|
2009-07-21 15:14:01 +02:00
|
|
|
#include <limits.h>
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#include "gb_common.h"
|
|
|
|
#include "gb_error.h"
|
|
|
|
#include "gb_array.h"
|
|
|
|
#include "gb_limit.h"
|
|
|
|
#include "gbx_class.h"
|
|
|
|
|
|
|
|
#include "gbx_exec.h"
|
|
|
|
#include "gbx_date.h"
|
|
|
|
#include "gbx_variant.h"
|
|
|
|
#include "gbx_compare.h"
|
|
|
|
#include "gbx_class.h"
|
|
|
|
#include "gbx_object.h"
|
|
|
|
#include "gbx_api.h"
|
|
|
|
#include "gbx_c_file.h"
|
2010-07-08 00:06:05 +02:00
|
|
|
#include "gbx_struct.h"
|
2007-12-30 17:41:49 +01:00
|
|
|
#include "gbx_c_array.h"
|
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
static bool _create_static_array;
|
|
|
|
|
|
|
|
|
|
|
|
static void THROW_static_array()
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_SARRAY);
|
|
|
|
return;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
static bool check_not_multi(CARRAY *_object)
|
|
|
|
{
|
2010-05-19 22:18:23 +02:00
|
|
|
if (UNLIKELY(THIS->ref != NULL))
|
2010-05-19 14:43:57 +02:00
|
|
|
{
|
|
|
|
THROW_static_array();
|
|
|
|
return TRUE;
|
|
|
|
}
|
2010-05-19 22:18:23 +02:00
|
|
|
else if (UNLIKELY(THIS->dim != NULL))
|
2009-03-02 12:36:42 +01:00
|
|
|
{
|
|
|
|
GB_Error("Array is multi-dimensional");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2010-08-14 22:51:42 +02:00
|
|
|
static bool check_start_length(int count, int *start, int *length)
|
|
|
|
{
|
|
|
|
if (*start < 0)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_BOUND);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*start >= count)
|
|
|
|
*length = 0;
|
|
|
|
|
|
|
|
if (*length == -1)
|
|
|
|
*length = count - *start;
|
|
|
|
|
|
|
|
if (*length < 0 || (*start + *length) > count)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_BOUND);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-05-19 14:43:57 +02:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
static int get_dim(CARRAY *_object)
|
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
int d;
|
|
|
|
|
2012-10-14 12:52:02 +02:00
|
|
|
if (THIS->dim == NULL)
|
2009-03-02 12:36:42 +01:00
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(d = 0;; d++)
|
|
|
|
{
|
|
|
|
if (THIS->dim[d] < 0)
|
|
|
|
return (d + 1);
|
|
|
|
}
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
static int get_bound(CARRAY *_object, int d)
|
|
|
|
{
|
2012-10-14 12:52:02 +02:00
|
|
|
if (THIS->dim == NULL)
|
2010-05-19 14:43:57 +02:00
|
|
|
return THIS->count;
|
2009-03-02 12:36:42 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
d = THIS->dim[d];
|
|
|
|
if (d < 0)
|
|
|
|
d = (-d);
|
|
|
|
|
|
|
|
return d;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
CLASS *CARRAY_get_array_class(CLASS *class, CTYPE ctype)
|
2010-05-19 14:43:57 +02:00
|
|
|
{
|
2010-07-08 00:06:05 +02:00
|
|
|
if (ctype.id == T_NULL)
|
2010-05-19 14:43:57 +02:00
|
|
|
{
|
2010-07-08 00:06:05 +02:00
|
|
|
if (TYPE_is_pure_object((TYPE)class))
|
|
|
|
return CLASS_get_array_class(class);
|
|
|
|
|
|
|
|
ctype.id = (unsigned char)(TYPE)class;
|
|
|
|
ctype.value = -1;
|
2010-05-19 14:43:57 +02:00
|
|
|
}
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
switch (ctype.id)
|
|
|
|
{
|
|
|
|
case T_BOOLEAN: class = CLASS_BooleanArray; break;
|
|
|
|
case T_BYTE: class = CLASS_ByteArray; break;
|
|
|
|
case T_SHORT: class = CLASS_ShortArray; break;
|
|
|
|
case T_INTEGER: class = CLASS_IntegerArray; break;
|
|
|
|
case T_LONG: class = CLASS_LongArray; break;
|
|
|
|
case T_SINGLE: class = CLASS_SingleArray; break;
|
|
|
|
case T_FLOAT: class = CLASS_FloatArray; break;
|
|
|
|
case T_STRING: class = CLASS_StringArray; break;
|
|
|
|
case T_DATE: class = CLASS_DateArray; break;
|
|
|
|
case T_POINTER: class = CLASS_PointerArray; break;
|
|
|
|
|
|
|
|
case T_OBJECT:
|
|
|
|
if (ctype.value >= 0)
|
|
|
|
class = CLASS_get_array_class(class->load->class_ref[ctype.value]);
|
|
|
|
else
|
|
|
|
class = CLASS_ObjectArray;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TC_STRUCT:
|
|
|
|
class = CLASS_get_array_of_struct_class(class->load->class_ref[ctype.value]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
class = CLASS_VariantArray;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
return class;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-19 15:32:30 +01:00
|
|
|
void *CARRAY_out_of_bound()
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2008-03-19 15:32:30 +01:00
|
|
|
GB_Error((char *)E_BOUND);
|
|
|
|
return NULL;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2008-03-19 15:32:30 +01:00
|
|
|
|
2008-01-24 11:42:42 +01:00
|
|
|
#define get_data_multi CARRAY_get_data_multi
|
2008-03-19 15:32:30 +01:00
|
|
|
#define get_data CARRAY_get_data
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-01-24 11:42:42 +01:00
|
|
|
void *CARRAY_get_data_multi(CARRAY *_object, GB_INTEGER *arg, int nparam)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
int index;
|
|
|
|
|
|
|
|
//fprintf(stderr, "get_data_multi: nparam = %d\n", nparam);
|
|
|
|
|
2010-05-19 22:18:23 +02:00
|
|
|
if (UNLIKELY(THIS->dim != NULL))
|
2009-03-02 12:36:42 +01:00
|
|
|
{
|
|
|
|
int max;
|
|
|
|
int i;
|
|
|
|
int d;
|
|
|
|
bool stop = FALSE;
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
nparam--;
|
|
|
|
|
|
|
|
for (i = 0;; i++)
|
|
|
|
{
|
|
|
|
if (i > nparam)
|
|
|
|
break;
|
|
|
|
|
|
|
|
max = THIS->dim[i];
|
|
|
|
if (max < 0)
|
|
|
|
{
|
|
|
|
max = (-max);
|
|
|
|
stop = TRUE;
|
|
|
|
}
|
|
|
|
|
2010-06-03 01:23:50 +02:00
|
|
|
VALUE_conv_integer((VALUE *)&arg[i]);
|
2009-03-02 12:36:42 +01:00
|
|
|
d = arg[i].value;
|
|
|
|
|
|
|
|
if (d < 0 || d >= max)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_BOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
index *= max;
|
|
|
|
index += d;
|
|
|
|
|
|
|
|
if (stop)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i != nparam)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_NDIM);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (nparam != 1)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_NDIM);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
index = arg->value;
|
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
if ((index < 0) || (index >= THIS->count))
|
2009-03-02 12:36:42 +01:00
|
|
|
{
|
|
|
|
GB_Error((char *)E_BOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
return (void *)((char *)(THIS->data) + index * THIS->size);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
static int get_count(int *dim)
|
|
|
|
{
|
|
|
|
int i, size;
|
|
|
|
|
|
|
|
size = 1;
|
|
|
|
|
|
|
|
for (i = 0;; i++)
|
|
|
|
{
|
|
|
|
size *= dim[i];
|
|
|
|
if (size < 0)
|
|
|
|
{
|
|
|
|
size = (-size);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
static void release_one(CARRAY *_object, int i)
|
|
|
|
{
|
2008-09-22 01:22:07 +02:00
|
|
|
if (THIS->type == T_STRING)
|
|
|
|
STRING_unref(&(((char **)(THIS->data))[i]));
|
|
|
|
else if (THIS->type == T_VARIANT)
|
|
|
|
VARIANT_free(&(((VARIANT *)(THIS->data))[i]));
|
|
|
|
else if (TYPE_is_object(THIS->type))
|
2013-03-30 14:51:10 +01:00
|
|
|
OBJECT_UNREF(((void **)(THIS->data))[i]);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2010-05-27 00:01:28 +02:00
|
|
|
static void release_static(TYPE type, void *data, int start, int end)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
int i;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-27 00:01:28 +02:00
|
|
|
if (type == T_STRING)
|
2008-09-22 01:22:07 +02:00
|
|
|
{
|
|
|
|
for (i = start; i < end; i++)
|
2010-05-27 00:01:28 +02:00
|
|
|
STRING_unref(&((char **)data)[i]);
|
2008-09-22 01:22:07 +02:00
|
|
|
}
|
2010-05-27 00:01:28 +02:00
|
|
|
else if (type == T_VARIANT)
|
2008-09-22 01:22:07 +02:00
|
|
|
{
|
|
|
|
for (i = start; i < end; i++)
|
2010-05-27 00:01:28 +02:00
|
|
|
VARIANT_free(&((VARIANT *)data)[i]);
|
2008-09-22 01:22:07 +02:00
|
|
|
}
|
2010-05-27 00:01:28 +02:00
|
|
|
else if (TYPE_is_object(type))
|
2008-09-22 01:22:07 +02:00
|
|
|
{
|
|
|
|
for (i = start; i < end; i++)
|
2013-03-30 14:51:10 +01:00
|
|
|
OBJECT_UNREF(((void **)data)[i]);
|
2008-09-22 01:22:07 +02:00
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-27 00:01:28 +02:00
|
|
|
static void release(CARRAY *_object, int start, int end)
|
|
|
|
{
|
|
|
|
if (end < 0)
|
|
|
|
end = THIS->count;
|
|
|
|
|
|
|
|
release_static(THIS->type, THIS->data, start, end);
|
|
|
|
}
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
static void borrow(CARRAY *_object, int start, int end)
|
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
int i;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
if (end < 0)
|
2010-05-19 14:43:57 +02:00
|
|
|
end = THIS->count;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-09-22 01:22:07 +02:00
|
|
|
if (THIS->type == T_STRING)
|
|
|
|
{
|
|
|
|
for (i = start; i < end; i++)
|
|
|
|
STRING_ref(((char **)(THIS->data))[i]);
|
|
|
|
}
|
|
|
|
else if (THIS->type == T_VARIANT)
|
|
|
|
{
|
|
|
|
for (i = start; i < end; i++)
|
|
|
|
VARIANT_keep(&((VARIANT *)(THIS->data))[i]);
|
|
|
|
}
|
|
|
|
else if (TYPE_is_object(THIS->type))
|
|
|
|
{
|
|
|
|
for (i = start; i < end; i++)
|
|
|
|
OBJECT_ref(((void **)(THIS->data))[i]);
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void clear(CARRAY *_object)
|
|
|
|
{
|
2010-05-19 22:18:23 +02:00
|
|
|
if (UNLIKELY(THIS->ref != NULL))
|
2010-05-19 14:43:57 +02:00
|
|
|
{
|
|
|
|
THROW_static_array();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
release(THIS, 0, -1);
|
2010-05-19 22:18:23 +02:00
|
|
|
if (UNLIKELY(THIS->dim != NULL))
|
2009-03-02 12:36:42 +01:00
|
|
|
{
|
2010-07-08 00:06:05 +02:00
|
|
|
memset(THIS->data, 0, THIS->size * THIS->count);
|
2009-03-02 12:36:42 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ARRAY_delete(&THIS->data);
|
2010-07-08 00:06:05 +02:00
|
|
|
ARRAY_create_with_size(&THIS->data, THIS->size, 8);
|
2010-05-19 14:43:57 +02:00
|
|
|
THIS->count = 0;
|
2009-03-02 12:36:42 +01:00
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *insert(CARRAY *_object, int index)
|
|
|
|
{
|
2010-05-19 14:43:57 +02:00
|
|
|
THIS->count++;
|
2009-03-02 12:36:42 +01:00
|
|
|
return ARRAY_insert(&THIS->data, index);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
size_t CARRAY_get_static_size(CLASS *class, CLASS_ARRAY *desc)
|
2010-05-27 00:01:28 +02:00
|
|
|
{
|
2010-07-08 00:06:05 +02:00
|
|
|
return (size_t)get_count(desc->dim) * CLASS_sizeof_ctype(class, desc->ctype);
|
2010-05-27 00:01:28 +02:00
|
|
|
}
|
|
|
|
|
2010-11-26 21:30:58 +01:00
|
|
|
int CARRAY_get_static_count(CLASS_ARRAY *desc)
|
|
|
|
{
|
|
|
|
return get_count(desc->dim);
|
|
|
|
}
|
|
|
|
|
2010-05-27 00:01:28 +02:00
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
CARRAY *CARRAY_create_static(CLASS *class, void *ref, CLASS_ARRAY *desc, void *data)
|
2010-05-27 00:01:28 +02:00
|
|
|
{
|
|
|
|
CARRAY *array;
|
2010-07-08 00:06:05 +02:00
|
|
|
TYPE type;
|
|
|
|
CLASS *aclass;
|
2010-05-27 00:01:28 +02:00
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
type = CLASS_ctype_to_type(class, desc->ctype);
|
2010-05-27 00:01:28 +02:00
|
|
|
_create_static_array = TRUE;
|
2010-07-08 00:06:05 +02:00
|
|
|
aclass = CARRAY_get_array_class(class, desc->ctype);
|
|
|
|
array = OBJECT_create_native(aclass, NULL);
|
2010-05-27 00:01:28 +02:00
|
|
|
_create_static_array = FALSE;
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
array->type = type;
|
2010-05-27 00:01:28 +02:00
|
|
|
array->data = data;
|
|
|
|
array->ref = ref;
|
|
|
|
array->count = get_count(desc->dim);
|
2013-03-30 14:51:10 +01:00
|
|
|
OBJECT_REF(ref);
|
2010-05-27 00:01:28 +02:00
|
|
|
array->dim = desc->dim;
|
2010-07-08 00:06:05 +02:00
|
|
|
array->size = CLASS_sizeof_ctype(class, desc->ctype);
|
2010-05-27 00:01:28 +02:00
|
|
|
|
|
|
|
return array;
|
|
|
|
}
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
void CARRAY_release_static(CLASS *class, CLASS_ARRAY *desc, void *data)
|
2010-05-27 00:01:28 +02:00
|
|
|
{
|
2010-07-08 00:06:05 +02:00
|
|
|
int count = get_count(desc->dim);
|
|
|
|
|
|
|
|
if (desc->ctype.id == TC_STRUCT)
|
|
|
|
{
|
|
|
|
CLASS *sclass = class->load->class_ref[desc->ctype.value];
|
|
|
|
int i;
|
|
|
|
int size = CLASS_sizeof_ctype(class, desc->ctype);
|
|
|
|
char *p = (char *)data;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
OBJECT_release_static(sclass, sclass->load->dyn, sclass->load->n_dyn, p);
|
|
|
|
p += size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
release_static(CLASS_ctype_to_type(class, desc->ctype), data, 0, count);
|
2010-05-27 00:01:28 +02:00
|
|
|
}
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
void CARRAY_get_value(CARRAY *_object, int index, VALUE *value)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
|
|
|
VALUE_read(value, get_data(THIS, index), THIS->type);
|
|
|
|
}
|
|
|
|
|
2011-03-16 23:16:19 +01:00
|
|
|
int *CARRAY_get_array_bounds(CARRAY *_object)
|
|
|
|
{
|
|
|
|
return THIS->dim;
|
|
|
|
}
|
|
|
|
|
2015-08-21 20:49:33 +02:00
|
|
|
static void check_size(CARRAY *_object, int size, int inc)
|
|
|
|
{
|
2015-08-22 13:04:14 +02:00
|
|
|
if (inc > 0)
|
|
|
|
size = (size + inc - 1) / inc * inc;
|
|
|
|
|
2015-08-21 20:49:33 +02:00
|
|
|
if (size > (INT_MAX / THIS->size))
|
|
|
|
THROW(E_MEMORY);
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_new, GB_INTEGER size)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
TYPE type;
|
|
|
|
CLASS *klass;
|
|
|
|
int inc;
|
|
|
|
GB_INTEGER *sizes = ARG(size);
|
|
|
|
int nsize = GB_NParam() + 1;
|
|
|
|
int i;
|
2010-05-19 14:43:57 +02:00
|
|
|
|
|
|
|
if (_create_static_array)
|
|
|
|
return;
|
2009-03-02 12:36:42 +01:00
|
|
|
|
|
|
|
klass = OBJECT_class(THIS);
|
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
type = (TYPE)klass->array_type;
|
|
|
|
if (!type)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2010-05-19 14:43:57 +02:00
|
|
|
GB_Error("Bad array type");
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
/*if (TYPE_is_object(type))
|
2010-05-30 21:37:40 +02:00
|
|
|
THIS->mode = T_OBJECT;
|
|
|
|
else
|
2010-07-08 00:06:05 +02:00
|
|
|
THIS->mode = (int)type;*/
|
2010-05-30 21:37:40 +02:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
//printf("Array_new: type = %d nsize = %d\n", type, nsize);
|
2009-03-02 12:36:42 +01:00
|
|
|
|
|
|
|
THIS->type = type;
|
2010-07-08 00:06:05 +02:00
|
|
|
THIS->size = TYPE_sizeof_memory(type);
|
2009-03-02 12:36:42 +01:00
|
|
|
|
|
|
|
if (nsize <= 1)
|
|
|
|
{
|
2013-01-06 17:13:31 +01:00
|
|
|
int size = VARGOPT(size, 0);
|
2015-08-21 20:49:33 +02:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
if (size < 0)
|
|
|
|
size = 0;
|
|
|
|
|
|
|
|
inc = (size / 8) & ~7;
|
|
|
|
if (inc < 8)
|
|
|
|
inc = 8;
|
2015-08-21 20:49:33 +02:00
|
|
|
else if (inc > 256)
|
|
|
|
inc = 256;
|
2009-03-02 12:36:42 +01:00
|
|
|
|
2015-08-21 20:49:33 +02:00
|
|
|
if (size)
|
|
|
|
check_size(THIS, size, inc);
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
ARRAY_create_with_size(&THIS->data, THIS->size, inc);
|
2009-03-02 12:36:42 +01:00
|
|
|
if (size > 0)
|
|
|
|
ARRAY_add_many_void(&THIS->data, size);
|
2013-01-06 17:13:31 +01:00
|
|
|
|
|
|
|
THIS->count = size;
|
2009-03-02 12:36:42 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (nsize > MAX_ARRAY_DIM)
|
|
|
|
{
|
|
|
|
GB_Error("Too many dimensions");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-06 17:13:31 +01:00
|
|
|
uint64_t size = 1;
|
2009-03-02 12:36:42 +01:00
|
|
|
for (i = 0; i < nsize; i++)
|
|
|
|
{
|
2010-06-03 01:23:50 +02:00
|
|
|
VALUE_conv_integer((VALUE *)&sizes[i]);
|
2009-03-02 12:36:42 +01:00
|
|
|
if (sizes[i].value < 1)
|
|
|
|
{
|
|
|
|
GB_Error("Bad dimension");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
size *= sizes[i].value;
|
2015-08-21 20:49:33 +02:00
|
|
|
check_size(THIS, size, 0);
|
2009-03-02 12:36:42 +01:00
|
|
|
}
|
|
|
|
|
2013-03-30 00:33:01 +01:00
|
|
|
ALLOC_ZERO(&THIS->dim, nsize * sizeof(int));
|
2009-03-02 12:36:42 +01:00
|
|
|
|
|
|
|
for (i = 0; i < nsize; i++)
|
|
|
|
THIS->dim[i] = sizes[i].value;
|
|
|
|
THIS->dim[nsize - 1] = (-THIS->dim[nsize - 1]);
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
ARRAY_create_with_size(&THIS->data, THIS->size, 8);
|
2009-07-21 15:14:01 +02:00
|
|
|
ARRAY_add_many_void(&THIS->data, (int)size);
|
2013-01-06 17:13:31 +01:00
|
|
|
|
|
|
|
THIS->count = size;
|
2009-03-02 12:36:42 +01:00
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_PROPERTY(Array_Type)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
GB_ReturnInteger(THIS->type);
|
|
|
|
|
2010-07-16 16:15:11 +02:00
|
|
|
END_PROPERTY
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD_VOID(Array_free)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-19 22:18:23 +02:00
|
|
|
if (UNLIKELY(THIS->ref != NULL))
|
2010-05-19 14:43:57 +02:00
|
|
|
{
|
2014-11-24 13:43:57 +01:00
|
|
|
OBJECT_UNREF(THIS->ref);
|
2010-05-19 14:43:57 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-05-27 00:01:28 +02:00
|
|
|
release(THIS, 0, -1);
|
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
ARRAY_delete(&THIS->data);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2013-03-30 00:33:01 +01:00
|
|
|
FREE(&THIS->dim);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD_VOID(Array_Clear)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
clear(THIS);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_PROPERTY(Array_Data)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_ReturnPointer(THIS->data);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_PROPERTY(Array_Count)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
GB_ReturnInt(THIS->count);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_PROPERTY(Array_Max)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
GB_ReturnInt(THIS->count - 1);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
|
|
|
static bool copy_remove(CARRAY *_object, int start, int length, bool copy, bool remove)
|
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
CARRAY *array;
|
2010-05-19 14:43:57 +02:00
|
|
|
int count = THIS->count;
|
2009-03-02 12:36:42 +01:00
|
|
|
void *data;
|
|
|
|
int i, nsize;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
if (check_not_multi(THIS) && (start != 0 || length != -1))
|
|
|
|
return TRUE;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-08-14 22:51:42 +02:00
|
|
|
if (check_start_length(count, &start, &length))
|
2009-03-02 12:36:42 +01:00
|
|
|
return TRUE;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
if (copy)
|
|
|
|
{
|
|
|
|
GB_ArrayNew((GB_ARRAY *)POINTER(&array), THIS->type, 0);
|
|
|
|
|
|
|
|
if (length > 0)
|
|
|
|
{
|
|
|
|
data = ARRAY_insert_many(&array->data, 0, length);
|
2010-05-19 14:43:57 +02:00
|
|
|
array->count += length;
|
2010-07-08 00:06:05 +02:00
|
|
|
memmove(data, get_data(THIS, start), length * THIS->size);
|
2007-12-30 17:41:49 +01:00
|
|
|
borrow(array, 0, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (THIS->dim)
|
|
|
|
{
|
|
|
|
nsize = get_dim(THIS);
|
2013-03-30 00:33:01 +01:00
|
|
|
ALLOC_ZERO(&array->dim, nsize * sizeof(int));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
for (i = 0; i < nsize; i++)
|
|
|
|
array->dim[i] = THIS->dim[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (remove)
|
|
|
|
{
|
|
|
|
release(THIS, start, start + length);
|
|
|
|
ARRAY_remove_many(&THIS->data, start, length);
|
2010-05-19 14:43:57 +02:00
|
|
|
THIS->count -= length;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (copy)
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_ReturnObject(array);
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Remove, GB_INTEGER index; GB_INTEGER length)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
copy_remove(THIS, VARG(index), VARGOPT(length, 1), FALSE, TRUE);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Copy, GB_INTEGER start; GB_INTEGER length)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
int start, length;
|
|
|
|
|
|
|
|
if (MISSING(start) && MISSING(length))
|
|
|
|
{
|
|
|
|
start = 0;
|
|
|
|
length = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
start = VARGOPT(start, 0);
|
|
|
|
length = VARGOPT(length, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
copy_remove(THIS, start, length, TRUE, FALSE);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Extract, GB_INTEGER start; GB_INTEGER length)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
copy_remove(THIS, VARG(start), VARGOPT(length, 1), TRUE, TRUE);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2014-01-28 00:46:37 +01:00
|
|
|
void CARRAY_resize(CARRAY *_object, int size)
|
|
|
|
{
|
2015-08-21 02:40:14 +02:00
|
|
|
int count;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2015-08-21 02:40:14 +02:00
|
|
|
if (size < 0)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_ARG);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
count = THIS->count;
|
|
|
|
if (size == count)
|
|
|
|
return;
|
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
if (size > count)
|
|
|
|
{
|
2015-08-21 20:49:33 +02:00
|
|
|
check_size(THIS, size, DATA_TO_ARRAY(THIS->data)->inc);
|
2009-03-02 12:36:42 +01:00
|
|
|
ARRAY_add_many_void(&THIS->data, size - count);
|
|
|
|
}
|
2015-08-21 02:40:14 +02:00
|
|
|
else
|
2009-03-02 12:36:42 +01:00
|
|
|
{
|
|
|
|
release(THIS, size, -1);
|
|
|
|
ARRAY_remove_many(&THIS->data, size, count - size);
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
THIS->count = size;
|
2014-01-28 00:46:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_METHOD(Array_Resize, GB_INTEGER size)
|
|
|
|
|
|
|
|
int size = VARG(size);
|
|
|
|
|
|
|
|
if (check_not_multi(THIS))
|
|
|
|
return;
|
|
|
|
|
|
|
|
CARRAY_resize(THIS, size);
|
2010-05-19 14:43:57 +02:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
|
|
|
static void add(CARRAY *_object, GB_VALUE *value, int index)
|
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
void *data;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
if (check_not_multi(THIS))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
data = insert(THIS, index);
|
|
|
|
/*GB_Conv(value, THIS->type);*/
|
|
|
|
GB_Store(THIS->type, value, data);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define IMPLEMENT_add(_type, _gtype) \
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_##_type##_Add, GB_##_gtype value; GB_INTEGER index) \
|
2007-12-30 17:41:49 +01:00
|
|
|
\
|
2009-03-02 12:36:42 +01:00
|
|
|
add(THIS, (GB_VALUE *)(void *)ARG(value), VARGOPT(index, -1)); \
|
|
|
|
\
|
2007-12-30 17:41:49 +01:00
|
|
|
END_METHOD \
|
|
|
|
\
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_##_type##_Push, GB_##_gtype value) \
|
2007-12-30 17:41:49 +01:00
|
|
|
\
|
2009-03-02 12:36:42 +01:00
|
|
|
add(THIS, (GB_VALUE *)(void *)ARG(value), -1); \
|
|
|
|
\
|
2007-12-30 17:41:49 +01:00
|
|
|
END_METHOD
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
IMPLEMENT_add(Integer, INTEGER)
|
|
|
|
IMPLEMENT_add(Long, LONG)
|
|
|
|
IMPLEMENT_add(Float, FLOAT)
|
|
|
|
IMPLEMENT_add(Single, SINGLE)
|
|
|
|
IMPLEMENT_add(Date, DATE)
|
|
|
|
IMPLEMENT_add(String, STRING)
|
|
|
|
IMPLEMENT_add(Object, OBJECT)
|
|
|
|
IMPLEMENT_add(Variant, VARIANT)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Add, GB_VARIANT value; GB_INTEGER index)
|
2009-04-08 12:11:16 +02:00
|
|
|
|
|
|
|
GB_VALUE *value = (GB_VALUE *)(void *)ARG(value);
|
|
|
|
GB_Conv(value, THIS->type);
|
|
|
|
add(THIS, value, VARGOPT(index, -1));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Push, GB_VARIANT value)
|
2009-04-08 12:11:16 +02:00
|
|
|
|
|
|
|
GB_VALUE *value = (GB_VALUE *)(void *)ARG(value);
|
|
|
|
GB_Conv(value, THIS->type);
|
|
|
|
add(THIS, value, -1);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#define IMPLEMENT_put(_type, _gtype) \
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_##_type##_put, GB_##_gtype value; GB_INTEGER index) \
|
2009-03-02 12:36:42 +01:00
|
|
|
\
|
|
|
|
void *data = get_data_multi(THIS, ARG(index), GB_NParam() + 1); \
|
|
|
|
if (!data) return; \
|
|
|
|
GB_Store(GB_T_##_gtype, (GB_VALUE *)(void *)ARG(value), data); \
|
|
|
|
\
|
2007-12-30 17:41:49 +01:00
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
#define IMPLEMENT_put2(_type, _gtype, _gstore) \
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_##_type##_put, GB_##_gtype value; GB_INTEGER index) \
|
2007-12-30 17:41:49 +01:00
|
|
|
\
|
2009-03-02 12:36:42 +01:00
|
|
|
void *data = get_data_multi(THIS, ARG(index), GB_NParam() + 1); \
|
|
|
|
if (!data) return; \
|
|
|
|
GB_Store(GB_T_##_gstore, (GB_VALUE *)(void *)ARG(value), data); \
|
|
|
|
\
|
2007-12-30 17:41:49 +01:00
|
|
|
END_METHOD
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_put, GB_VARIANT value; GB_INTEGER index)
|
2009-04-08 12:11:16 +02:00
|
|
|
|
|
|
|
GB_VALUE *value;
|
|
|
|
void *data;
|
|
|
|
|
|
|
|
value = (GB_VALUE *)(void *)ARG(value);
|
|
|
|
GB_Conv(value, THIS->type);
|
|
|
|
|
|
|
|
data = get_data_multi(THIS, ARG(index), GB_NParam() + 1);
|
|
|
|
if (!data) return;
|
|
|
|
|
|
|
|
GB_Store(THIS->type, value, data);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
IMPLEMENT_put(Integer, INTEGER)
|
|
|
|
IMPLEMENT_put2(Short, INTEGER, SHORT)
|
|
|
|
IMPLEMENT_put2(Byte, INTEGER, BYTE)
|
|
|
|
IMPLEMENT_put2(Boolean, INTEGER, BOOLEAN)
|
|
|
|
IMPLEMENT_put(Long, LONG)
|
|
|
|
IMPLEMENT_put(Float, FLOAT)
|
|
|
|
IMPLEMENT_put(Single, SINGLE)
|
|
|
|
IMPLEMENT_put(Date, DATE)
|
|
|
|
IMPLEMENT_put(String, STRING)
|
|
|
|
IMPLEMENT_put(Object, OBJECT)
|
|
|
|
IMPLEMENT_put(Variant, VARIANT)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Fill, GB_VALUE value; GB_INTEGER start; GB_INTEGER length)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
int count = THIS->count;
|
2009-03-02 12:36:42 +01:00
|
|
|
int start = VARGOPT(start, 0);
|
|
|
|
int length = VARGOPT(length, count);
|
|
|
|
int i;
|
|
|
|
void *data;
|
|
|
|
int size;
|
2010-08-14 22:51:42 +02:00
|
|
|
|
|
|
|
if (check_start_length(count, &start, &length))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
VALUE_conv((VALUE *)ARG(value), THIS->type);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
data = get_data(THIS, start);
|
2010-07-08 00:06:05 +02:00
|
|
|
size = THIS->size;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
GB_Store(THIS->type, (GB_VALUE *)ARG(value), data);
|
|
|
|
data += size;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Insert, GB_OBJECT array; GB_INTEGER pos)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
int pos = VARGOPT(pos, -1);
|
|
|
|
CARRAY *array = (CARRAY *)VARG(array);
|
|
|
|
void *data;
|
|
|
|
int count;
|
2008-05-11 20:07:16 +02:00
|
|
|
|
|
|
|
if (GB_CheckObject(array))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
if (check_not_multi(THIS))
|
|
|
|
{
|
|
|
|
GB_ReturnNull();
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
count = array->count;
|
2009-03-02 12:36:42 +01:00
|
|
|
|
|
|
|
if (count > 0)
|
|
|
|
{
|
|
|
|
if (pos < 0)
|
2010-05-19 14:43:57 +02:00
|
|
|
pos = THIS->count;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
data = ARRAY_insert_many(&THIS->data, pos, count);
|
2010-05-19 14:43:57 +02:00
|
|
|
THIS->count += count;
|
2007-12-30 17:41:49 +01:00
|
|
|
borrow(array, 0, -1);
|
2010-07-08 00:06:05 +02:00
|
|
|
memmove(data, array->data, count * THIS->size);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
2009-03-02 12:36:42 +01:00
|
|
|
|
|
|
|
GB_ReturnObject(THIS);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD_VOID(Array_Pop)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
int index = THIS->count - 1;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
if (check_not_multi(THIS))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
if (index < 0)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_ARG);
|
|
|
|
return;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_ReturnPtr(THIS->type, get_data(THIS, index));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
BORROW(&TEMP);
|
|
|
|
release_one(THIS, index);
|
|
|
|
ARRAY_remove(&THIS->data, index);
|
2010-05-19 14:43:57 +02:00
|
|
|
THIS->count--;
|
2009-03-02 12:36:42 +01:00
|
|
|
UNBORROW(&TEMP);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_get, GB_INTEGER index)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
void *data = get_data_multi(THIS, ARG(index), GB_NParam() + 1);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
if (data)
|
|
|
|
GB_ReturnPtr(THIS->type, data);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2011-06-25 00:33:26 +02:00
|
|
|
#if 0
|
|
|
|
BEGIN_PROPERTY(Array_Last)
|
|
|
|
|
|
|
|
void *data;
|
|
|
|
int index = THIS->count - 1;
|
|
|
|
|
|
|
|
if (check_not_multi(THIS))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (index < 0)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_ARG);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = get_data(THIS, index);
|
|
|
|
|
|
|
|
if (READ_PROPERTY)
|
|
|
|
{
|
|
|
|
GB_ReturnPtr(THIS->type, data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GB_VALUE *value;
|
|
|
|
|
|
|
|
value = (GB_VALUE *)(void *)ARG(value);
|
|
|
|
GB_Conv(value, THIS->type);
|
|
|
|
|
|
|
|
if (!data) return;
|
|
|
|
|
|
|
|
GB_Store(THIS->type, value, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
#endif
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD_VOID(Array_next)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
int *index = (int *)GB_GetEnum();
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
if (*index >= THIS->count)
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_StopEnum();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GB_ReturnPtr(THIS->type, get_data(THIS, *index));
|
|
|
|
(*index)++;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Sort, GB_INTEGER mode)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
COMPARE_FUNC compare;
|
|
|
|
int mode = VARGOPT(mode, 0);
|
|
|
|
void *data = THIS->data;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
if (THIS->count > 1)
|
2009-03-02 12:36:42 +01:00
|
|
|
{
|
2017-10-21 01:19:27 +02:00
|
|
|
compare = COMPARE_get_func(THIS->type, mode);
|
2010-07-08 00:06:05 +02:00
|
|
|
qsort(data, THIS->count, THIS->size, compare);
|
2009-03-02 12:36:42 +01:00
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_ReturnObject(THIS);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2009-08-22 14:17:31 +02:00
|
|
|
static int find(CARRAY *_object, int mode, void *value, int start)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2017-10-21 01:19:27 +02:00
|
|
|
COMPARE_FUNC compare = COMPARE_get_func(THIS->type, mode);
|
2009-03-02 12:36:42 +01:00
|
|
|
int i;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-08-22 14:17:31 +02:00
|
|
|
if (start < 0)
|
|
|
|
start = 0;
|
2010-05-19 14:43:57 +02:00
|
|
|
else if (start >= THIS->count)
|
2009-08-22 14:17:31 +02:00
|
|
|
return (-1);
|
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
for (i = start; i < THIS->count; i++)
|
2009-03-02 12:36:42 +01:00
|
|
|
{
|
2009-08-22 14:17:31 +02:00
|
|
|
if ((*compare)(get_data(THIS, i), value) == 0)
|
2009-03-02 12:36:42 +01:00
|
|
|
return i;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
2015-06-08 17:52:18 +02:00
|
|
|
#define IMPLEMENT_find_fast(_type, _gtype, _ctype) \
|
|
|
|
static int find_##_ctype(CARRAY *_object, int value, int start) \
|
|
|
|
{ \
|
|
|
|
int count = THIS->count; \
|
|
|
|
_ctype *data; \
|
|
|
|
int i; \
|
|
|
|
\
|
|
|
|
if (start < 0) \
|
|
|
|
start = 0; \
|
|
|
|
else if (start > count) \
|
|
|
|
return (-1); \
|
|
|
|
\
|
|
|
|
data = (_ctype *)THIS->data; \
|
|
|
|
\
|
|
|
|
for (i = start; i < count; i++) \
|
|
|
|
{ \
|
|
|
|
if (data[i] == value) \
|
|
|
|
return i; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
return (-1); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
BEGIN_METHOD(Array_##_type##_Find, _gtype value; GB_INTEGER start) \
|
|
|
|
\
|
|
|
|
GB_ReturnInteger(find_##_ctype(THIS, VARG(value), VARGOPT(start, 0))); \
|
|
|
|
\
|
|
|
|
END_METHOD \
|
|
|
|
BEGIN_METHOD(Array_##_type##_Exist, _gtype value) \
|
|
|
|
\
|
|
|
|
GB_ReturnBoolean(find_##_ctype(THIS, VARG(value), 0) >= 0); \
|
|
|
|
\
|
|
|
|
END_METHOD
|
2011-09-26 03:46:48 +02:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#define IMPLEMENT_find(_type, _gtype) \
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_##_type##_Find, _gtype value; GB_INTEGER start) \
|
2007-12-30 17:41:49 +01:00
|
|
|
\
|
2009-08-22 14:17:31 +02:00
|
|
|
GB_ReturnInt(find(THIS, 0, &VARG(value), VARGOPT(start, 0))); \
|
2007-12-30 17:41:49 +01:00
|
|
|
\
|
|
|
|
END_METHOD \
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_##_type##_Exist, _gtype value) \
|
2007-12-30 17:41:49 +01:00
|
|
|
\
|
2009-08-22 14:17:31 +02:00
|
|
|
GB_ReturnBoolean(find(THIS, 0, &VARG(value), 0) >= 0); \
|
2007-12-30 17:41:49 +01:00
|
|
|
\
|
|
|
|
END_METHOD
|
|
|
|
|
2015-06-08 17:52:18 +02:00
|
|
|
IMPLEMENT_find_fast(Boolean, GB_BOOLEAN, bool)
|
|
|
|
IMPLEMENT_find_fast(Byte, GB_INTEGER, uchar)
|
|
|
|
IMPLEMENT_find_fast(Short, GB_INTEGER, short)
|
|
|
|
IMPLEMENT_find_fast(Integer, GB_INTEGER, int)
|
|
|
|
IMPLEMENT_find_fast(Long, GB_LONG, int64_t)
|
|
|
|
IMPLEMENT_find_fast(Float, GB_FLOAT, double)
|
|
|
|
IMPLEMENT_find_fast(Single, GB_SINGLE, float)
|
2011-12-28 04:04:46 +01:00
|
|
|
IMPLEMENT_find(Date, GB_DATE)
|
2012-08-29 22:56:13 +02:00
|
|
|
IMPLEMENT_find(Variant, GB_VARIANT)
|
2009-02-16 22:39:07 +01:00
|
|
|
|
2011-12-27 14:39:23 +01:00
|
|
|
static int find_object(CARRAY *_object, void *value, int start, bool byref)
|
2009-02-16 22:39:07 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
int i;
|
2011-12-27 14:39:23 +01:00
|
|
|
void **data;
|
2009-02-16 22:39:07 +01:00
|
|
|
|
2009-08-22 14:17:31 +02:00
|
|
|
if (start < 0)
|
|
|
|
start = 0;
|
2010-05-19 14:43:57 +02:00
|
|
|
else if (start >= THIS->count)
|
2009-08-22 14:17:31 +02:00
|
|
|
return (-1);
|
|
|
|
|
2011-12-27 14:39:23 +01:00
|
|
|
data = get_data(THIS, 0);
|
|
|
|
|
|
|
|
if (byref)
|
2009-03-02 12:36:42 +01:00
|
|
|
{
|
2011-12-27 14:39:23 +01:00
|
|
|
for (i = 0; i < THIS->count; i++)
|
|
|
|
{
|
|
|
|
if (data[i] == value)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < THIS->count; i++)
|
|
|
|
{
|
|
|
|
//if (*((void **)get_data(THIS, i)) == value)
|
|
|
|
if (!COMPARE_object(&data[i], &value))
|
|
|
|
return i;
|
|
|
|
}
|
2009-03-02 12:36:42 +01:00
|
|
|
}
|
2009-02-16 22:39:07 +01:00
|
|
|
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Object_Find, GB_OBJECT value; GB_INTEGER start)
|
2009-02-16 22:39:07 +01:00
|
|
|
|
2011-12-27 14:39:23 +01:00
|
|
|
GB_ReturnInt(find_object(THIS, VARG(value), VARGOPT(start, 0), FALSE));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(Array_Object_FindByRef, GB_OBJECT value; GB_INTEGER start)
|
|
|
|
|
|
|
|
GB_ReturnInt(find_object(THIS, VARG(value), VARGOPT(start, 0), TRUE));
|
2009-02-16 22:39:07 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Object_Exist, GB_OBJECT value)
|
2009-02-16 22:39:07 +01:00
|
|
|
|
2011-12-27 14:39:23 +01:00
|
|
|
GB_ReturnBoolean(find_object(THIS, VARG(value), 0, FALSE) >= 0);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(Array_Object_ExistByRef, GB_OBJECT value)
|
|
|
|
|
|
|
|
GB_ReturnBoolean(find_object(THIS, VARG(value), 0, TRUE) >= 0);
|
2009-02-16 22:39:07 +01:00
|
|
|
|
|
|
|
END_METHOD
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
2015-06-08 17:52:18 +02:00
|
|
|
static int find_string(CARRAY *_object, int mode, const char *value, int len_value, int start)
|
|
|
|
{
|
|
|
|
char **data;
|
|
|
|
char *str;
|
|
|
|
int i;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
//fprintf(stderr, "find_string: %p %d: %.*s | %s\n", THIS, THIS->count, len_value, value, DEBUG_get_current_position());
|
|
|
|
|
|
|
|
if (start < 0)
|
|
|
|
start = 0;
|
|
|
|
else if (start >= THIS->count)
|
|
|
|
return (-1);
|
|
|
|
|
|
|
|
data = ((char **)THIS->data);
|
|
|
|
|
|
|
|
if (mode == GB_COMP_BINARY)
|
|
|
|
{
|
|
|
|
for (i = start; i < THIS->count; i++)
|
|
|
|
{
|
|
|
|
str = data[i];
|
|
|
|
len = STRING_length(str);
|
|
|
|
if (STRING_equal(str, len, value, len_value))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mode == GB_COMP_NOCASE)
|
|
|
|
{
|
|
|
|
for (i = start; i < THIS->count; i++)
|
|
|
|
{
|
|
|
|
str = data[i];
|
|
|
|
len = STRING_length(str);
|
|
|
|
if (STRING_equal_ignore_case(str, len, value, len_value))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-21 01:19:27 +02:00
|
|
|
COMPARE_STRING_FUNC compare = COMPARE_get_string_func(mode);
|
|
|
|
bool nocase = mode & GB_COMP_NOCASE;
|
2015-06-08 17:52:18 +02:00
|
|
|
|
|
|
|
for (i = start; i < THIS->count; i++)
|
|
|
|
{
|
2017-10-21 01:19:27 +02:00
|
|
|
if ((*compare)(data[i], STRING_length(data[i]), value, len_value, nocase, FALSE) == 0)
|
2015-06-08 17:52:18 +02:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_String_Find, GB_STRING value; GB_INTEGER mode; GB_INTEGER start)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-09-26 03:46:48 +02:00
|
|
|
GB_ReturnInteger(find_string(THIS, VARGOPT(mode, GB_COMP_BINARY), STRING(value), LENGTH(value), VARGOPT(start, 0)));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_String_Exist, GB_STRING value; GB_INTEGER mode)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-11 20:14:04 +01:00
|
|
|
//fprintf(stderr, "%s\n", DEBUG_get_current_position());
|
2011-09-26 03:46:48 +02:00
|
|
|
GB_ReturnBoolean(find_string(THIS, VARGOPT(mode, GB_COMP_BINARY), STRING(value), LENGTH(value), 0) >= 0);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_String_join, GB_STRING sep; GB_STRING esc)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
char *sep = ",";
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Software farm: Software now can be safely installed or removed. The
source checksum is checked, as well as the required components. Libraries
and dependencies on other software are not yet taken into account. A
'*.desktop' file is automatically created on installation now.
[INTERPRETER]
* NEW: Split() has a new behaviour when its escape argument has two
characters, the second one being the first splitting character. It uses
the first character to escape splitting characters. For example,
Split("a;b~;c;d",";","~;") returns ["a","b;c","d"].
* NEW: String[].Join() method handle the new Split syntax.
["a","b;c","d"].Join(";","~;") returns "a;b~;c;d". Moreover, in the
traditional escape syntax, the joined string are not escaped anymore if
they are void.
[GB.DESKTOP]
* NEW: DesktopFile.MimeTypes is a new property corresponding to the
'MimeType' entry of the '*.desktop' file.
* NEW: DesktopFile now can be used for creating or modifying '*.desktop'
files.
git-svn-id: svn://localhost/gambas/trunk@6689 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-11-30 01:30:32 +01:00
|
|
|
uint lsep = 1;
|
2009-03-02 12:36:42 +01:00
|
|
|
char *esc = "";
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Software farm: Software now can be safely installed or removed. The
source checksum is checked, as well as the required components. Libraries
and dependencies on other software are not yet taken into account. A
'*.desktop' file is automatically created on installation now.
[INTERPRETER]
* NEW: Split() has a new behaviour when its escape argument has two
characters, the second one being the first splitting character. It uses
the first character to escape splitting characters. For example,
Split("a;b~;c;d",";","~;") returns ["a","b;c","d"].
* NEW: String[].Join() method handle the new Split syntax.
["a","b;c","d"].Join(";","~;") returns "a;b~;c;d". Moreover, in the
traditional escape syntax, the joined string are not escaped anymore if
they are void.
[GB.DESKTOP]
* NEW: DesktopFile.MimeTypes is a new property corresponding to the
'MimeType' entry of the '*.desktop' file.
* NEW: DesktopFile now can be used for creating or modifying '*.desktop'
files.
git-svn-id: svn://localhost/gambas/trunk@6689 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-11-30 01:30:32 +01:00
|
|
|
uint lesc = 0;
|
2009-03-02 12:36:42 +01:00
|
|
|
char escl, NO_WARNING(escr);
|
|
|
|
int i;
|
|
|
|
char **data = (char **)THIS->data;
|
2007-12-30 17:41:49 +01:00
|
|
|
char *p, *p2;
|
2008-11-08 15:55:03 +01:00
|
|
|
int l, max;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
if (!MISSING(sep))
|
|
|
|
{
|
|
|
|
sep = STRING(sep);
|
|
|
|
lsep = LENGTH(sep);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!MISSING(esc))
|
|
|
|
{
|
|
|
|
esc = STRING(esc);
|
|
|
|
lesc = LENGTH(esc);
|
|
|
|
|
|
|
|
if (lesc == 1)
|
|
|
|
escl = escr = esc[0];
|
|
|
|
else if (lesc >= 2)
|
|
|
|
{
|
|
|
|
escl = esc[0];
|
|
|
|
escr = esc[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Software farm: Software now can be safely installed or removed. The
source checksum is checked, as well as the required components. Libraries
and dependencies on other software are not yet taken into account. A
'*.desktop' file is automatically created on installation now.
[INTERPRETER]
* NEW: Split() has a new behaviour when its escape argument has two
characters, the second one being the first splitting character. It uses
the first character to escape splitting characters. For example,
Split("a;b~;c;d",";","~;") returns ["a","b;c","d"].
* NEW: String[].Join() method handle the new Split syntax.
["a","b;c","d"].Join(";","~;") returns "a;b~;c;d". Moreover, in the
traditional escape syntax, the joined string are not escaped anymore if
they are void.
[GB.DESKTOP]
* NEW: DesktopFile.MimeTypes is a new property corresponding to the
'MimeType' entry of the '*.desktop' file.
* NEW: DesktopFile now can be used for creating or modifying '*.desktop'
files.
git-svn-id: svn://localhost/gambas/trunk@6689 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-11-30 01:30:32 +01:00
|
|
|
if (lesc == 0)
|
2008-11-08 15:55:03 +01:00
|
|
|
{
|
|
|
|
max = 0;
|
2010-05-19 14:43:57 +02:00
|
|
|
for (i = 0; i < THIS->count; i++)
|
2008-11-08 15:55:03 +01:00
|
|
|
max += STRING_length(data[i]) + lsep;
|
2010-05-19 14:43:57 +02:00
|
|
|
if (THIS->count)
|
2008-11-08 15:55:03 +01:00
|
|
|
max -= lsep;
|
|
|
|
|
2008-11-10 01:18:00 +01:00
|
|
|
STRING_start_len(max);
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Software farm: Software now can be safely installed or removed. The
source checksum is checked, as well as the required components. Libraries
and dependencies on other software are not yet taken into account. A
'*.desktop' file is automatically created on installation now.
[INTERPRETER]
* NEW: Split() has a new behaviour when its escape argument has two
characters, the second one being the first splitting character. It uses
the first character to escape splitting characters. For example,
Split("a;b~;c;d",";","~;") returns ["a","b;c","d"].
* NEW: String[].Join() method handle the new Split syntax.
["a","b;c","d"].Join(";","~;") returns "a;b~;c;d". Moreover, in the
traditional escape syntax, the joined string are not escaped anymore if
they are void.
[GB.DESKTOP]
* NEW: DesktopFile.MimeTypes is a new property corresponding to the
'MimeType' entry of the '*.desktop' file.
* NEW: DesktopFile now can be used for creating or modifying '*.desktop'
files.
git-svn-id: svn://localhost/gambas/trunk@6689 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-11-30 01:30:32 +01:00
|
|
|
|
|
|
|
for (i = 0; i < THIS->count; i++)
|
|
|
|
{
|
|
|
|
p = data[i];
|
|
|
|
l = STRING_length(data[i]);
|
|
|
|
|
|
|
|
if (i)
|
|
|
|
STRING_make(sep, lsep);
|
|
|
|
if (l)
|
|
|
|
STRING_make(p, l);
|
|
|
|
}
|
2008-11-08 15:55:03 +01:00
|
|
|
}
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Software farm: Software now can be safely installed or removed. The
source checksum is checked, as well as the required components. Libraries
and dependencies on other software are not yet taken into account. A
'*.desktop' file is automatically created on installation now.
[INTERPRETER]
* NEW: Split() has a new behaviour when its escape argument has two
characters, the second one being the first splitting character. It uses
the first character to escape splitting characters. For example,
Split("a;b~;c;d",";","~;") returns ["a","b;c","d"].
* NEW: String[].Join() method handle the new Split syntax.
["a","b;c","d"].Join(";","~;") returns "a;b~;c;d". Moreover, in the
traditional escape syntax, the joined string are not escaped anymore if
they are void.
[GB.DESKTOP]
* NEW: DesktopFile.MimeTypes is a new property corresponding to the
'MimeType' entry of the '*.desktop' file.
* NEW: DesktopFile now can be used for creating or modifying '*.desktop'
files.
git-svn-id: svn://localhost/gambas/trunk@6689 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-11-30 01:30:32 +01:00
|
|
|
else if (*sep && escr == *sep)
|
|
|
|
{
|
2008-11-10 01:18:00 +01:00
|
|
|
STRING_start();
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Software farm: Software now can be safely installed or removed. The
source checksum is checked, as well as the required components. Libraries
and dependencies on other software are not yet taken into account. A
'*.desktop' file is automatically created on installation now.
[INTERPRETER]
* NEW: Split() has a new behaviour when its escape argument has two
characters, the second one being the first splitting character. It uses
the first character to escape splitting characters. For example,
Split("a;b~;c;d",";","~;") returns ["a","b;c","d"].
* NEW: String[].Join() method handle the new Split syntax.
["a","b;c","d"].Join(";","~;") returns "a;b~;c;d". Moreover, in the
traditional escape syntax, the joined string are not escaped anymore if
they are void.
[GB.DESKTOP]
* NEW: DesktopFile.MimeTypes is a new property corresponding to the
'MimeType' entry of the '*.desktop' file.
* NEW: DesktopFile now can be used for creating or modifying '*.desktop'
files.
git-svn-id: svn://localhost/gambas/trunk@6689 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-11-30 01:30:32 +01:00
|
|
|
|
|
|
|
for (i = 0; i < THIS->count; i++)
|
|
|
|
{
|
|
|
|
p = data[i];
|
|
|
|
l = STRING_length(data[i]);
|
|
|
|
|
|
|
|
if (i)
|
|
|
|
STRING_make(sep, lsep);
|
|
|
|
|
|
|
|
if (l == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
p2 = index(p, escr);
|
|
|
|
if (p2)
|
|
|
|
{
|
|
|
|
STRING_make(p, p2 - p);
|
|
|
|
STRING_make_char(escl);
|
|
|
|
STRING_make_char(escr);
|
|
|
|
p = p2 + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
STRING_make(p, l + data[i] - p);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2009-03-02 12:36:42 +01:00
|
|
|
{
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Software farm: Software now can be safely installed or removed. The
source checksum is checked, as well as the required components. Libraries
and dependencies on other software are not yet taken into account. A
'*.desktop' file is automatically created on installation now.
[INTERPRETER]
* NEW: Split() has a new behaviour when its escape argument has two
characters, the second one being the first splitting character. It uses
the first character to escape splitting characters. For example,
Split("a;b~;c;d",";","~;") returns ["a","b;c","d"].
* NEW: String[].Join() method handle the new Split syntax.
["a","b;c","d"].Join(";","~;") returns "a;b~;c;d". Moreover, in the
traditional escape syntax, the joined string are not escaped anymore if
they are void.
[GB.DESKTOP]
* NEW: DesktopFile.MimeTypes is a new property corresponding to the
'MimeType' entry of the '*.desktop' file.
* NEW: DesktopFile now can be used for creating or modifying '*.desktop'
files.
git-svn-id: svn://localhost/gambas/trunk@6689 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-11-30 01:30:32 +01:00
|
|
|
STRING_start();
|
|
|
|
|
|
|
|
for (i = 0; i < THIS->count; i++)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Software farm: Software now can be safely installed or removed. The
source checksum is checked, as well as the required components. Libraries
and dependencies on other software are not yet taken into account. A
'*.desktop' file is automatically created on installation now.
[INTERPRETER]
* NEW: Split() has a new behaviour when its escape argument has two
characters, the second one being the first splitting character. It uses
the first character to escape splitting characters. For example,
Split("a;b~;c;d",";","~;") returns ["a","b;c","d"].
* NEW: String[].Join() method handle the new Split syntax.
["a","b;c","d"].Join(";","~;") returns "a;b~;c;d". Moreover, in the
traditional escape syntax, the joined string are not escaped anymore if
they are void.
[GB.DESKTOP]
* NEW: DesktopFile.MimeTypes is a new property corresponding to the
'MimeType' entry of the '*.desktop' file.
* NEW: DesktopFile now can be used for creating or modifying '*.desktop'
files.
git-svn-id: svn://localhost/gambas/trunk@6689 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-11-30 01:30:32 +01:00
|
|
|
p = data[i];
|
|
|
|
l = STRING_length(data[i]);
|
|
|
|
|
|
|
|
if (i)
|
|
|
|
STRING_make(sep, lsep);
|
|
|
|
|
|
|
|
if (l == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
STRING_make_char(escl);
|
|
|
|
for(;;)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Software farm: Software now can be safely installed or removed. The
source checksum is checked, as well as the required components. Libraries
and dependencies on other software are not yet taken into account. A
'*.desktop' file is automatically created on installation now.
[INTERPRETER]
* NEW: Split() has a new behaviour when its escape argument has two
characters, the second one being the first splitting character. It uses
the first character to escape splitting characters. For example,
Split("a;b~;c;d",";","~;") returns ["a","b;c","d"].
* NEW: String[].Join() method handle the new Split syntax.
["a","b;c","d"].Join(";","~;") returns "a;b~;c;d". Moreover, in the
traditional escape syntax, the joined string are not escaped anymore if
they are void.
[GB.DESKTOP]
* NEW: DesktopFile.MimeTypes is a new property corresponding to the
'MimeType' entry of the '*.desktop' file.
* NEW: DesktopFile now can be used for creating or modifying '*.desktop'
files.
git-svn-id: svn://localhost/gambas/trunk@6689 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-11-30 01:30:32 +01:00
|
|
|
p2 = index(p, escr);
|
|
|
|
if (p2)
|
|
|
|
{
|
|
|
|
STRING_make(p, p2 - p + 1);
|
|
|
|
STRING_make_char(escr);
|
|
|
|
p = p2 + 1;
|
|
|
|
}
|
|
|
|
else
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
[DEVELOPMENT ENVIRONMENT]
* NEW: Software farm: Software now can be safely installed or removed. The
source checksum is checked, as well as the required components. Libraries
and dependencies on other software are not yet taken into account. A
'*.desktop' file is automatically created on installation now.
[INTERPRETER]
* NEW: Split() has a new behaviour when its escape argument has two
characters, the second one being the first splitting character. It uses
the first character to escape splitting characters. For example,
Split("a;b~;c;d",";","~;") returns ["a","b;c","d"].
* NEW: String[].Join() method handle the new Split syntax.
["a","b;c","d"].Join(";","~;") returns "a;b~;c;d". Moreover, in the
traditional escape syntax, the joined string are not escaped anymore if
they are void.
[GB.DESKTOP]
* NEW: DesktopFile.MimeTypes is a new property corresponding to the
'MimeType' entry of the '*.desktop' file.
* NEW: DesktopFile now can be used for creating or modifying '*.desktop'
files.
git-svn-id: svn://localhost/gambas/trunk@6689 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-11-30 01:30:32 +01:00
|
|
|
STRING_make(p, l + data[i] - p);
|
|
|
|
break;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
}
|
2008-11-10 01:18:00 +01:00
|
|
|
STRING_make_char(escr);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
2009-03-02 12:36:42 +01:00
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-11-10 01:18:00 +01:00
|
|
|
GB_ReturnString(STRING_end_temp());
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_METHOD_VOID(CARRAY_reverse)
|
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
size_t size;
|
|
|
|
int count;
|
|
|
|
char *buffer[16];
|
|
|
|
char *pi, *pj;
|
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
count = THIS->count;
|
2011-11-24 22:45:21 +01:00
|
|
|
if (count > 1)
|
2009-03-02 12:36:42 +01:00
|
|
|
{
|
2011-11-24 22:45:21 +01:00
|
|
|
size = THIS->size;
|
|
|
|
pi = get_data(THIS, 0);
|
|
|
|
pj = get_data(THIS, count - 1);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
memcpy(buffer, pi, size);
|
|
|
|
memcpy(pi, pj, size);
|
|
|
|
memcpy(pj, buffer, size);
|
|
|
|
pi += size;
|
|
|
|
pj -= size;
|
|
|
|
}
|
|
|
|
while (pi < pj);
|
2009-03-02 12:36:42 +01:00
|
|
|
}
|
2011-11-24 22:45:21 +01:00
|
|
|
|
|
|
|
GB_ReturnObject(THIS);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Read, GB_OBJECT file; GB_INTEGER start; GB_INTEGER length)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
int count = THIS->count;
|
2009-03-02 12:36:42 +01:00
|
|
|
int start = VARGOPT(start, 0);
|
|
|
|
int length = VARGOPT(length, count);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-08-14 22:51:42 +02:00
|
|
|
if (check_start_length(count, &start, &length))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
STREAM_read(CSTREAM_stream(VARG(file)), get_data(THIS, start), length * THIS->size);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Write, GB_OBJECT file; GB_INTEGER start; GB_INTEGER length)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-19 14:43:57 +02:00
|
|
|
int count = THIS->count;
|
2009-03-02 12:36:42 +01:00
|
|
|
int start = VARGOPT(start, 0);
|
|
|
|
int length = VARGOPT(length, count);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-08-14 22:51:42 +02:00
|
|
|
if (check_start_length(count, &start, &length))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
STREAM_write(CSTREAM_stream(VARG(file)), get_data(THIS, start), length * THIS->size);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_PROPERTY(Array_Dim)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_ReturnInteger(get_dim(THIS));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Bounds_get, GB_INTEGER index)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
int dim = get_dim(THIS);
|
|
|
|
int index = VARG(index);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
if (index < 0 || index >= dim)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_BOUND);
|
|
|
|
return;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_ReturnInteger(get_bound(THIS, index));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Byte_ToString, GB_INTEGER start; GB_INTEGER length)
|
2010-07-08 00:06:05 +02:00
|
|
|
|
|
|
|
int start, length;
|
|
|
|
int count = THIS->count;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
start = VARGOPT(start, 0);
|
|
|
|
|
|
|
|
if (start < 0)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_BOUND);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start >= count)
|
|
|
|
{
|
2011-10-24 21:33:41 +02:00
|
|
|
GB_ReturnVoidString();
|
2010-07-08 00:06:05 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
length = VARGOPT(length, -1);
|
|
|
|
if (length < 0)
|
|
|
|
{
|
|
|
|
p = memchr((char *)THIS->data + start, 0, count - start);
|
|
|
|
if (!p)
|
|
|
|
length = count - start;
|
|
|
|
else
|
|
|
|
length = p - ((char *)THIS->data + start);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((start + length) > count)
|
|
|
|
length = count - start;
|
|
|
|
}
|
|
|
|
|
|
|
|
GB_ReturnNewString((char *)THIS->data + start, length);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
BEGIN_METHOD(Array_Byte_FromString, GB_STRING string)
|
2010-07-08 00:06:05 +02:00
|
|
|
|
2011-07-03 22:46:03 +02:00
|
|
|
CARRAY *array;
|
2010-07-08 00:06:05 +02:00
|
|
|
char *string = STRING(string);
|
|
|
|
int length = LENGTH(string);
|
|
|
|
|
2011-07-03 22:46:03 +02:00
|
|
|
GB_ArrayNew((GB_ARRAY *)POINTER(&array), T_BYTE, length);
|
2011-09-11 18:31:51 +02:00
|
|
|
memcpy(array->data, string, length);
|
2011-07-03 22:46:03 +02:00
|
|
|
GB_ReturnObject(array);
|
2010-07-08 00:06:05 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_METHOD(ArrayOfStruct_get, GB_INTEGER index)
|
|
|
|
|
|
|
|
void *data = get_data_multi(THIS, ARG(index), GB_NParam() + 1);
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
GB_ReturnObject(CSTRUCT_create_static(THIS, (CLASS *)THIS->type, data));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2011-06-25 00:33:26 +02:00
|
|
|
|
2011-01-13 19:56:52 +01:00
|
|
|
BEGIN_METHOD(ArrayOfStruct_put, GB_OBJECT value; GB_INTEGER index)
|
|
|
|
|
|
|
|
int i;
|
|
|
|
CLASS *class = (CLASS *)THIS->type;
|
|
|
|
char *addr;
|
|
|
|
void *object = VARG(value);
|
|
|
|
void *data;
|
|
|
|
VALUE temp;
|
|
|
|
CLASS_DESC *desc;
|
|
|
|
|
|
|
|
if (GB_CheckObject(object))
|
|
|
|
return;
|
|
|
|
|
|
|
|
data = get_data_multi(THIS, ARG(index), GB_NParam() + 1);
|
|
|
|
if (!data)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < class->n_desc; i++)
|
|
|
|
{
|
|
|
|
desc = class->table[i].desc;
|
|
|
|
|
|
|
|
if (((CSTRUCT *)object)->ref)
|
|
|
|
addr = (char *)((CSTATICSTRUCT *)object)->addr + desc->variable.offset;
|
|
|
|
else
|
|
|
|
addr = (char *)object + sizeof(CSTRUCT) + desc->variable.offset;
|
|
|
|
|
|
|
|
VALUE_class_read(desc->variable.class, &temp, (void *)addr, desc->variable.ctype, object);
|
|
|
|
|
|
|
|
addr = (char *)data + desc->variable.offset;
|
|
|
|
VALUE_write(&temp, (void *)addr, desc->variable.type);
|
|
|
|
}
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
|
2011-06-25 00:33:26 +02:00
|
|
|
#if 0
|
|
|
|
BEGIN_PROPERTY(ArrayOfStruct_Last)
|
|
|
|
|
|
|
|
int index = THIS->count - 1;
|
|
|
|
|
|
|
|
if (check_not_multi(THIS))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (index < 0)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_ARG);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *data = get_data(THIS, index);
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
GB_ReturnObject(CSTRUCT_create_static(THIS, (CLASS *)THIS->type, data));
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
BEGIN_METHOD_VOID(ArrayOfStruct_next)
|
|
|
|
|
|
|
|
int *index = (int *)GB_GetEnum();
|
|
|
|
|
|
|
|
if (*index >= THIS->count)
|
|
|
|
GB_StopEnum();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GB_ReturnObject(CSTRUCT_create_static(THIS, (CLASS *)THIS->type, get_data(THIS, *index)));
|
|
|
|
(*index)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2017-09-28 02:05:43 +02:00
|
|
|
static void error_convert(CARRAY *array)
|
2010-11-27 02:27:23 +01:00
|
|
|
{
|
2017-09-28 02:05:43 +02:00
|
|
|
OBJECT_UNREF(array);
|
2010-11-27 02:27:23 +01:00
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-07-09 17:37:42 +02:00
|
|
|
static bool _convert(CARRAY *src, CLASS *class, VALUE *conv)
|
2010-11-27 02:27:23 +01:00
|
|
|
{
|
|
|
|
CARRAY *array;
|
|
|
|
int i;
|
|
|
|
void *data;
|
|
|
|
VALUE temp;
|
2012-10-14 12:52:02 +02:00
|
|
|
int dim;
|
2010-11-27 02:27:23 +01:00
|
|
|
|
2012-07-09 17:37:42 +02:00
|
|
|
if (!src || !TYPE_is_pure_object((TYPE)class))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
CLASS_load(class); // Force creation of array classes
|
|
|
|
|
2017-09-28 02:05:43 +02:00
|
|
|
if (!class->is_array)
|
2012-07-08 16:35:58 +02:00
|
|
|
return TRUE;
|
2010-11-27 02:27:23 +01:00
|
|
|
|
2017-09-28 02:05:43 +02:00
|
|
|
array = OBJECT_create(class, NULL, NULL, 0);
|
2010-11-27 02:27:23 +01:00
|
|
|
|
2012-10-31 00:44:24 +01:00
|
|
|
if (src->count)
|
2009-03-02 12:36:42 +01:00
|
|
|
{
|
2012-10-31 00:44:24 +01:00
|
|
|
ARRAY_add_many_void(&array->data, src->count);
|
|
|
|
array->count = src->count;
|
|
|
|
|
2017-09-28 02:05:43 +02:00
|
|
|
ON_ERROR_1(error_convert, array)
|
2009-03-02 12:36:42 +01:00
|
|
|
{
|
2012-10-31 00:44:24 +01:00
|
|
|
for (i = 0; i < src->count; i++)
|
|
|
|
{
|
|
|
|
data = CARRAY_get_data(src, i);
|
|
|
|
VALUE_read(&temp, data, src->type);
|
|
|
|
BORROW(&temp);
|
|
|
|
data = CARRAY_get_data(array, i);
|
|
|
|
VALUE_write(&temp, data, array->type);
|
|
|
|
RELEASE(&temp);
|
|
|
|
}
|
2009-03-02 12:36:42 +01:00
|
|
|
}
|
2012-10-31 00:44:24 +01:00
|
|
|
END_ERROR
|
2009-03-02 12:36:42 +01:00
|
|
|
}
|
2010-11-27 02:27:23 +01:00
|
|
|
|
2012-10-14 12:52:02 +02:00
|
|
|
dim = get_dim(src);
|
|
|
|
if (dim > 1)
|
|
|
|
{
|
2013-03-30 00:33:01 +01:00
|
|
|
ALLOC(&array->dim, dim * sizeof(int));
|
2012-10-14 12:52:02 +02:00
|
|
|
for (i = 0; i < dim; i++)
|
|
|
|
array->dim[i] = src->dim[i];
|
|
|
|
}
|
|
|
|
|
2012-07-08 16:35:58 +02:00
|
|
|
conv->_object.object = array;
|
|
|
|
return FALSE;
|
2010-11-27 02:27:23 +01:00
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-09-09 13:03:47 +02:00
|
|
|
#else
|
|
|
|
|
|
|
|
#include "gbx_c_array.h"
|
|
|
|
|
2012-07-09 17:37:42 +02:00
|
|
|
#define _convert NULL
|
2010-11-27 02:27:23 +01:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#endif /* #ifndef GBX_INFO */
|
|
|
|
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_ArrayBounds[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE(".Array.Bounds", sizeof(CARRAY)), GB_NOT_CREATABLE(),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_get", "i", Array_Bounds_get, "(Dimension)i"),
|
[DEVELOPMENT ENVIRONMENT]
* NEW: The debug window has a button to switch between "normal view" and
"symbol view". In "normal view", array and collection contents are
displayed. If the object is not an array or a collection, then all
non-hidden symbols are displayed. In "symbol view", all objects symbols
are displayed, whatever the object type is.
[INTERPRETER]
* NEW: The debugger now can display collection-like objects. An object can
be displayed like a collection if it has a Count property, is enumerable,
has a _get special method taking a string, and has a Key property that
returns the key of the last enumerated element.
[GB.DEBUG]
* NEW: The debugger now can display collection-like objects. An object can
be displayed like a collection if it has a Count property, is enumerable,
has a _get special method taking a string, and has a Key property that
returns the key of the last enumerated element.
[GB.FORM]
* BUG: GridView.Clear resets the height of all rows to the default value.
git-svn-id: svn://localhost/gambas/trunk@4558 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-03-17 03:05:31 +01:00
|
|
|
GB_PROPERTY_READ("Count", "i", Array_Dim),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_Array[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE("Array", sizeof(CARRAY)), GB_NOT_CREATABLE(),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_free", NULL, Array_free, NULL),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_PROPERTY_READ("Type", "i", Array_Type),
|
|
|
|
GB_PROPERTY_READ("Count", "i", Array_Count),
|
|
|
|
GB_PROPERTY_READ("Max", "i", Array_Max),
|
|
|
|
GB_PROPERTY_READ("Length", "i", Array_Count),
|
|
|
|
GB_PROPERTY_READ("Dim", "i", Array_Dim),
|
|
|
|
GB_PROPERTY_READ("Data", "p", Array_Data),
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_PROPERTY_SELF("Bounds", ".Array.Bounds"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Remove", NULL, Array_Remove, "(Index)i[(Length)i]"),
|
|
|
|
GB_METHOD("Clear", NULL, Array_Clear, NULL),
|
|
|
|
GB_METHOD("Resize", NULL, Array_Resize, "(Size)i"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-29 22:47:41 +01:00
|
|
|
//GB_METHOD("Add", NULL, Array_Add, "(Value)v[(Index)i]"),
|
|
|
|
//GB_METHOD("Push", NULL, Array_Push, "(Value)v"),
|
|
|
|
//GB_METHOD("_put", NULL, Array_put, "(Value)v(Index)i."),
|
2009-04-08 12:11:16 +02:00
|
|
|
|
2011-12-29 22:47:41 +01:00
|
|
|
//GB_METHOD("Pop", "v", Array_Pop_variant, NULL), // Does not work
|
|
|
|
//GB_METHOD("_get", "v", Array_get_variant, "(Index)i."),
|
|
|
|
//GB_METHOD("_next", "v", Array_next_variant, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "v", Array_Last),
|
2009-04-08 12:11:16 +02:00
|
|
|
|
2011-12-29 22:47:41 +01:00
|
|
|
/*GB_METHOD("Copy", "Array", Array_Copy, "[(Start)i(Length)i]"),
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Extract", "Array", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "Array", Array_Extract, "(Start)i[(Length)i]"),
|
2011-12-29 22:47:41 +01:00
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)v[(Start)i(Length)i]"),*/
|
2010-11-27 02:27:23 +01:00
|
|
|
|
2012-07-09 17:37:42 +02:00
|
|
|
GB_INTERFACE("_convert", _convert),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_BooleanArray[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE("Boolean[]", sizeof(CARRAY)), GB_INHERITS("Array"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Add", NULL, Array_Integer_Add, "(Value)b[(Index)i]"),
|
|
|
|
GB_METHOD("Push", NULL, Array_Integer_Push, "(Value)b"),
|
|
|
|
GB_METHOD("_put", NULL, Array_Boolean_put, "(Value)b(Index)i."),
|
2015-06-08 17:52:18 +02:00
|
|
|
GB_METHOD("Find", "i", Array_Boolean_Find, "(Value)b[(Start)i]"),
|
|
|
|
GB_METHOD("Exist", "b", Array_Boolean_Exist, "(Value)b"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Pop", "b", Array_Pop, NULL),
|
|
|
|
GB_METHOD("_get", "b", Array_get, "(Index)i."),
|
|
|
|
GB_METHOD("_next", "b", Array_next, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "b", Array_Last),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Read", NULL, Array_Read, "(Stream)Stream;[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Write", NULL, Array_Write, "(Stream)Stream;[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Insert", "Boolean[]", Array_Insert, "(Array)Boolean[];[(Pos)i]"),
|
|
|
|
GB_METHOD("Copy", "Boolean[]", Array_Copy, "[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Extract", "Boolean[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "Boolean[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Sort", "Boolean[]", Array_Sort, "[(Mode)i]"),
|
2011-11-24 22:45:21 +01:00
|
|
|
GB_METHOD("Reverse", "Boolean[]", CARRAY_reverse, NULL),
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)b[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_ByteArray[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE("Byte[]", sizeof(CARRAY)), GB_INHERITS("Array"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Add", NULL, Array_Integer_Add, "(Value)c[(Index)i]"),
|
|
|
|
GB_METHOD("Push", NULL, Array_Integer_Push, "(Value)c"),
|
|
|
|
GB_METHOD("_put", NULL, Array_Byte_put, "(Value)c(Index)i."),
|
2015-06-08 17:52:18 +02:00
|
|
|
GB_METHOD("Find", "i", Array_Byte_Find, "(Value)c[(Start)i]"),
|
|
|
|
GB_METHOD("Exist", "b", Array_Byte_Exist, "(Value)c"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Pop", "c", Array_Pop, NULL),
|
|
|
|
GB_METHOD("_get", "c", Array_get, "(Index)i."),
|
|
|
|
GB_METHOD("_next", "c", Array_next, NULL),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Read", NULL, Array_Read, "(Stream)Stream;[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Write", NULL, Array_Write, "(Stream)Stream;[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Insert", "Byte[]", Array_Insert, "(Array)Byte[];[(Pos)i]"),
|
|
|
|
GB_METHOD("Copy", "Byte[]", Array_Copy, "[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Extract", "Byte[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "Byte[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Sort", "Byte[]", Array_Sort, "[(Mode)i]"),
|
2011-11-24 22:45:21 +01:00
|
|
|
GB_METHOD("Reverse", "Byte[]", CARRAY_reverse, NULL),
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)c[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("ToString", "s", Array_Byte_ToString, "[(Start)i(Length)i]"),
|
|
|
|
GB_STATIC_METHOD("FromString", "Byte[]", Array_Byte_FromString, "(String)s"),
|
2010-07-08 00:06:05 +02:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_ShortArray[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE("Short[]", sizeof(CARRAY)), GB_INHERITS("Array"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Add", NULL, Array_Integer_Add, "(Value)h[(Index)i]"),
|
|
|
|
GB_METHOD("Push", NULL, Array_Integer_Push, "(Value)h"),
|
|
|
|
GB_METHOD("_put", NULL, Array_Short_put, "(Value)h(Index)i."),
|
2015-06-08 17:52:18 +02:00
|
|
|
GB_METHOD("Find", "i", Array_Short_Find, "(Value)h[(Start)i]"),
|
|
|
|
GB_METHOD("Exist", "b", Array_Short_Exist, "(Value)h"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Pop", "h", Array_Pop, NULL),
|
|
|
|
GB_METHOD("_get", "h", Array_get, "(Index)i."),
|
|
|
|
GB_METHOD("_next", "h", Array_next, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "h", Array_Last),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Read", NULL, Array_Read, "(Stream)Stream;[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Write", NULL, Array_Write, "(Stream)Stream;[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Insert", "Short[]", Array_Insert, "(Array)Short[];[(Pos)i]"),
|
|
|
|
GB_METHOD("Copy", "Short[]", Array_Copy, "[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Extract", "Short[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "Short[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Sort", "Short[]", Array_Sort, "[(Mode)i]"),
|
2011-11-24 22:45:21 +01:00
|
|
|
GB_METHOD("Reverse", "Short[]", CARRAY_reverse, NULL),
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)h[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_IntegerArray[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE("Integer[]", sizeof(CARRAY)), GB_INHERITS("Array"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Add", NULL, Array_Integer_Add, "(Value)i[(Index)i]"),
|
|
|
|
GB_METHOD("Push", NULL, Array_Integer_Push, "(Value)i"),
|
|
|
|
GB_METHOD("_put", NULL, Array_Integer_put, "(Value)i(Index)i."),
|
|
|
|
GB_METHOD("Find", "i", Array_Integer_Find, "(Value)i[(Start)i]"),
|
|
|
|
GB_METHOD("Exist", "b", Array_Integer_Exist, "(Value)i"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Pop", "i", Array_Pop, NULL),
|
|
|
|
GB_METHOD("_get", "i", Array_get, "(Index)i."),
|
|
|
|
GB_METHOD("_next", "i", Array_next, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "i", Array_Last),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Read", NULL, Array_Read, "(Stream)Stream;[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Write", NULL, Array_Write, "(Stream)Stream;[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Insert", "Integer[]", Array_Insert, "(Array)Integer[];[(Pos)i]"),
|
|
|
|
GB_METHOD("Copy", "Integer[]", Array_Copy, "[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Extract", "Integer[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "Integer[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Sort", "Integer[]", Array_Sort, "[(Mode)i]"),
|
2011-11-24 22:45:21 +01:00
|
|
|
GB_METHOD("Reverse", "Integer[]", CARRAY_reverse, NULL),
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)i[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_LongArray[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE("Long[]", sizeof(CARRAY)), GB_INHERITS("Array"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Add", NULL, Array_Long_Add, "(Value)l[(Index)i]"),
|
|
|
|
GB_METHOD("Push", NULL, Array_Long_Push, "(Value)l"),
|
|
|
|
GB_METHOD("_put", NULL, Array_Long_put, "(Value)l(Index)i."),
|
|
|
|
GB_METHOD("Find", "i", Array_Long_Find, "(Value)l[(Start)i]"),
|
|
|
|
GB_METHOD("Exist", "b", Array_Long_Exist, "(Value)l"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Pop", "l", Array_Pop, NULL),
|
|
|
|
GB_METHOD("_get", "l", Array_get, "(Index)i."),
|
|
|
|
GB_METHOD("_next", "l", Array_next, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "l", Array_Last),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Read", NULL, Array_Read, "(Stream)Stream;[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Write", NULL, Array_Write, "(Stream)Stream;[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Insert", "Long[]", Array_Insert, "(Array)Long[];[(Pos)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Copy", "Long[]", Array_Copy, "[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Extract", "Long[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "Long[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Sort", "Long[]", Array_Sort, "[(Mode)i]"),
|
2011-11-24 22:45:21 +01:00
|
|
|
GB_METHOD("Reverse", "Long[]", CARRAY_reverse, NULL),
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)l[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
2008-01-23 20:56:18 +01:00
|
|
|
#ifdef OS_64BITS
|
2011-12-28 04:04:46 +01:00
|
|
|
#define Array_Pointer_Add Array_Long_Add
|
|
|
|
#define Array_Pointer_Push Array_Long_Push
|
|
|
|
#define Array_Pointer_put Array_Long_put
|
|
|
|
#define Array_Pointer_Find Array_Long_Find
|
|
|
|
#define Array_Pointer_Exist Array_Long_Exist
|
2008-01-23 20:56:18 +01:00
|
|
|
#else
|
2011-12-28 04:04:46 +01:00
|
|
|
#define Array_Pointer_Add Array_Integer_Add
|
|
|
|
#define Array_Pointer_Push Array_Integer_Push
|
|
|
|
#define Array_Pointer_put Array_Integer_put
|
|
|
|
#define Array_Pointer_Find Array_Integer_Find
|
|
|
|
#define Array_Pointer_Exist Array_Integer_Exist
|
2008-01-23 20:56:18 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
GB_DESC NATIVE_PointerArray[] =
|
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE("Pointer[]", sizeof(CARRAY)), GB_INHERITS("Array"),
|
2008-01-23 20:56:18 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
2008-01-23 20:56:18 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Add", NULL, Array_Pointer_Add, "(Value)p[(Index)i]"),
|
|
|
|
GB_METHOD("Push", NULL, Array_Pointer_Push, "(Value)p"),
|
|
|
|
GB_METHOD("_put", NULL, Array_Pointer_put, "(Value)p(Index)i."),
|
|
|
|
GB_METHOD("Find", "i", Array_Pointer_Find, "(Value)p[(Start)i]"),
|
|
|
|
GB_METHOD("Exist", "b", Array_Pointer_Exist, "(Value)p"),
|
2008-01-23 20:56:18 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Pop", "p", Array_Pop, NULL),
|
|
|
|
GB_METHOD("_get", "p", Array_get, "(Index)i."),
|
|
|
|
GB_METHOD("_next", "p", Array_next, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "p", Array_Last),
|
2008-01-23 20:56:18 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Read", NULL, Array_Read, "(Stream)Stream;[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Write", NULL, Array_Write, "(Stream)Stream;[(Start)i(Length)i]"),
|
2008-01-23 20:56:18 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Insert", "Pointer[]", Array_Insert, "(Array)Pointer[];[(Pos)i]"),
|
2008-01-23 20:56:18 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Copy", "Pointer[]", Array_Copy, "[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Extract", "Pointer[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "Pointer[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Sort", "Pointer[]", Array_Sort, "[(Mode)i]"),
|
2011-11-24 22:45:21 +01:00
|
|
|
GB_METHOD("Reverse", "Pointer[]", CARRAY_reverse, NULL),
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)p[(Start)i(Length)i]"),
|
2008-01-23 20:56:18 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2008-01-23 20:56:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_StringArray[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE("String[]", sizeof(CARRAY)), GB_INHERITS("Array"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Add", NULL, Array_String_Add, "(Value)s[(Index)i]"),
|
|
|
|
GB_METHOD("Push", NULL, Array_String_Push, "(Value)s"),
|
|
|
|
GB_METHOD("_put", NULL, Array_String_put, "(Value)s(Index)i."),
|
|
|
|
GB_METHOD("Find", "i", Array_String_Find, "(Value)s[(Mode)i(Start)i]"),
|
|
|
|
GB_METHOD("Exist", "b", Array_String_Exist, "(Value)s[(Mode)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Pop", "s", Array_Pop, NULL),
|
|
|
|
GB_METHOD("_get", "s", Array_get, "(Index)i."),
|
|
|
|
GB_METHOD("_next", "s", Array_next, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "s", Array_Last),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Insert", "String[]", Array_Insert, "(Array)String[];[(Pos)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Join", "s", Array_String_join, "[(Separator)s(Escape)s]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Copy", "String[]", Array_Copy, "[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Extract", "String[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "String[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Sort", "String[]", Array_Sort, "[(Mode)i]"),
|
2011-11-24 22:45:21 +01:00
|
|
|
GB_METHOD("Reverse", "String[]", CARRAY_reverse, NULL),
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)s[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_FloatArray[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE("Float[]", sizeof(CARRAY)), GB_INHERITS("Array"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Add", NULL, Array_Float_Add, "(Value)f[(Index)i]"),
|
|
|
|
GB_METHOD("Push", NULL, Array_Float_Push, "(Value)f"),
|
|
|
|
GB_METHOD("_put", NULL, Array_Float_put, "(Value)f(Index)i."),
|
|
|
|
GB_METHOD("Find", "i", Array_Float_Find, "(Value)f[(Start)i]"),
|
|
|
|
GB_METHOD("Exist", "b", Array_Float_Exist, "(Value)f"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Pop", "f", Array_Pop, NULL),
|
|
|
|
GB_METHOD("_get", "f", Array_get, "(Index)i."),
|
|
|
|
GB_METHOD("_next", "f", Array_next, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "f", Array_Last),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Read", NULL, Array_Read, "(Stream)Stream;[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Write", NULL, Array_Write, "(Stream)Stream;[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Insert", "Float[]", Array_Insert, "(Array)Float[];[(Pos)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Copy", "Float[]", Array_Copy, "[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Extract", "Float[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "Float[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Sort", "Float[]", Array_Sort, "[(Mode)i]"),
|
2011-11-24 22:45:21 +01:00
|
|
|
GB_METHOD("Reverse", "Float[]", CARRAY_reverse, NULL),
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)f[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_SingleArray[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE("Single[]", sizeof(CARRAY)), GB_INHERITS("Array"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Add", NULL, Array_Single_Add, "(Value)g[(Index)i]"),
|
|
|
|
GB_METHOD("Push", NULL, Array_Single_Push, "(Value)g"),
|
|
|
|
GB_METHOD("_put", NULL, Array_Single_put, "(Value)g(Index)i."),
|
|
|
|
GB_METHOD("Find", "i", Array_Single_Find, "(Value)g[(Start)i]"),
|
|
|
|
GB_METHOD("Exist", "b", Array_Single_Exist, "(Value)g"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Pop", "g", Array_Pop, NULL),
|
|
|
|
GB_METHOD("_get", "g", Array_get, "(Index)i."),
|
|
|
|
GB_METHOD("_next", "g", Array_next, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "g", Array_Last),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Read", NULL, Array_Read, "(Stream)Stream;[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Write", NULL, Array_Write, "(Stream)Stream;[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Insert", "Single[]", Array_Insert, "(Array)Single[];[(Pos)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Copy", "Single[]", Array_Copy, "[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Extract", "Single[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "Single[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Sort", "Single[]", Array_Sort, "[(Mode)i]"),
|
2011-11-24 22:45:21 +01:00
|
|
|
GB_METHOD("Reverse", "Single[]", CARRAY_reverse, NULL),
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)g[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_DateArray[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE("Date[]", sizeof(CARRAY)), GB_INHERITS("Array"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Add", NULL, Array_Date_Add, "(Value)d[(Index)i]"),
|
|
|
|
GB_METHOD("Push", NULL, Array_Date_Push, "(Value)d"),
|
|
|
|
GB_METHOD("_put", NULL, Array_Date_put, "(Value)d(Index)i."),
|
|
|
|
GB_METHOD("Find", "i", Array_Date_Find, "(Value)d[(Start)i]"),
|
|
|
|
GB_METHOD("Exist", "b", Array_Date_Exist, "(Value)d"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Pop", "d", Array_Pop, NULL),
|
|
|
|
GB_METHOD("_get", "d", Array_get, "(Index)i."),
|
|
|
|
GB_METHOD("_next", "d", Array_next, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "d", Array_Last),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Read", NULL, Array_Read, "(Stream)Stream;[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Write", NULL, Array_Write, "(Stream)Stream;[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Insert", "Date[]", Array_Insert, "(Array)Date[];[(Pos)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Copy", "Date[]", Array_Copy, "[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Extract", "Date[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "Date[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Sort", "Date[]", Array_Sort, "[(Mode)i]"),
|
2011-11-24 22:45:21 +01:00
|
|
|
GB_METHOD("Reverse", "Date[]", CARRAY_reverse, NULL),
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)d[(Start)i(Length)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_ObjectArray[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE("Object[]", sizeof(CARRAY)), GB_INHERITS("Array"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Add", NULL, Array_Object_Add, "(Value)o[(Index)i]"),
|
|
|
|
GB_METHOD("Push", NULL, Array_Object_Push, "(Value)o"),
|
|
|
|
GB_METHOD("_put", NULL, Array_Object_put, "(Value)o(Index)i."),
|
|
|
|
GB_METHOD("Find", "i", Array_Object_Find, "(Value)o[(Start)i]"),
|
2011-12-27 14:39:23 +01:00
|
|
|
GB_METHOD("FindByRef", "i", Array_Object_FindByRef, "(Value)o[(Start)i]"),
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Exist", "b", Array_Object_Exist, "(Value)o"),
|
2011-12-27 14:39:23 +01:00
|
|
|
GB_METHOD("ExistByRef", "b", Array_Object_ExistByRef, "(Value)o"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Pop", "o", Array_Pop, NULL),
|
|
|
|
GB_METHOD("_get", "o", Array_get, "(Index)i."),
|
|
|
|
GB_METHOD("_next", "o", Array_next, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "o", Array_Last),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Insert", "Object[]", Array_Insert, "(Array)Object[];[(Pos)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Copy", "Object[]", Array_Copy, "[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Extract", "Object[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "Object[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)o[(Start)i(Length)i]"),
|
2011-11-24 22:45:21 +01:00
|
|
|
GB_METHOD("Reverse", "Object[]", CARRAY_reverse, NULL),
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Sort", "Object[]", Array_Sort, "[(Mode)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
GB_DESC NATIVE_VariantArray[] =
|
|
|
|
{
|
|
|
|
GB_DECLARE("Variant[]", sizeof(CARRAY)), GB_INHERITS("Array"),
|
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
2010-07-08 00:06:05 +02:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Add", NULL, Array_Variant_Add, "(Value)v[(Index)i]"),
|
|
|
|
GB_METHOD("Push", NULL, Array_Variant_Push, "(Value)v"),
|
|
|
|
GB_METHOD("_put", NULL, Array_Variant_put, "(Value)v(Index)i."),
|
2012-08-29 22:56:13 +02:00
|
|
|
GB_METHOD("Find", "i", Array_Variant_Find, "(Value)v[(Start)i]"),
|
|
|
|
GB_METHOD("Exist", "b", Array_Variant_Exist, "(Value)v"),
|
2010-07-08 00:06:05 +02:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Pop", "v", Array_Pop, NULL),
|
|
|
|
GB_METHOD("_get", "v", Array_get, "(Index)i."),
|
|
|
|
GB_METHOD("_next", "v", Array_next, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "v", Array_Last),
|
2010-07-08 00:06:05 +02:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Insert", "Variant[]", Array_Insert, "(Array)Variant[];[(Pos)i]"),
|
2010-07-08 00:06:05 +02:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Copy", "Variant[]", Array_Copy, "[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Extract", "Variant[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "Variant[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)v[(Start)i(Length)i]"),
|
2011-11-24 22:45:21 +01:00
|
|
|
GB_METHOD("Reverse", "Variant[]", CARRAY_reverse, NULL),
|
2010-07-08 00:06:05 +02:00
|
|
|
|
|
|
|
GB_END_DECLARE
|
|
|
|
};
|
|
|
|
|
2008-08-31 02:32:21 +02:00
|
|
|
// Beware: if this declaration is modified, the ARRAY_TEMPLATE_NDESC constant must be modified accordingly.
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_TemplateArray[ARRAY_TEMPLATE_NDESC] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_DECLARE("*[]", sizeof(CARRAY)), GB_INHERITS("Array"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Add", NULL, Array_Object_Add, "(Value)*;[(Index)i]"),
|
|
|
|
GB_METHOD("Push", NULL, Array_Object_Push, "(Value)*;"),
|
|
|
|
GB_METHOD("_put", NULL, Array_Object_put, "(Value)*;(Index)i."),
|
|
|
|
GB_METHOD("Find", "i", Array_Object_Find, "(Value)*;[(Start)i]"),
|
2011-12-27 14:39:23 +01:00
|
|
|
GB_METHOD("FindByRef", "i", Array_Object_FindByRef, "(Value)*;[(Start)i]"),
|
2012-01-13 09:04:11 +01:00
|
|
|
GB_METHOD("Exist", "b", Array_Object_Exist, "(Value)*;"),
|
2011-12-27 14:39:23 +01:00
|
|
|
GB_METHOD("ExistByRef", "b", Array_Object_ExistByRef, "(Value)*;"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Pop", "*", Array_Pop, NULL),
|
|
|
|
GB_METHOD("_get", "*", Array_get, "(Index)i."),
|
|
|
|
GB_METHOD("_next", "*", Array_next, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "*", Array_Last),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Insert", "*", Array_Insert, "(Array)*[];[(Pos)i]"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_METHOD("Copy", "*[]", Array_Copy, "[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Extract", "*[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Delete", "*[]", Array_Extract, "(Start)i[(Length)i]"),
|
|
|
|
GB_METHOD("Fill", NULL, Array_Fill, "(Value)*;[(Start)i(Length)i]"),
|
|
|
|
GB_METHOD("Sort", "*[]", Array_Sort, "[(Mode)i]"),
|
2011-11-24 22:45:21 +01:00
|
|
|
GB_METHOD("Reverse", "*[]", CARRAY_reverse, NULL),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
// Beware: if this declaration is modified, the ARRAY_OF_STRUCT_TEMPLATE_NDESC constant must be modified accordingly.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
GB_DESC NATIVE_TemplateArrayOfStruct[ARRAY_OF_STRUCT_TEMPLATE_NDESC] =
|
|
|
|
{
|
|
|
|
GB_DECLARE("$*[]", sizeof(CARRAY)), GB_NOT_CREATABLE(),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
//GB_METHOD("_new", NULL, Array_new, "[(Size)i.]"),
|
|
|
|
GB_METHOD("_free", NULL, Array_free, NULL),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 04:04:46 +01:00
|
|
|
GB_PROPERTY_READ("Count", "i", Array_Count),
|
|
|
|
GB_PROPERTY_READ("Max", "i", Array_Max),
|
|
|
|
GB_PROPERTY_READ("Length", "i", Array_Count),
|
|
|
|
GB_PROPERTY_READ("Dim", "i", Array_Dim),
|
|
|
|
GB_PROPERTY_READ("Data", "p", Array_Data),
|
2010-07-08 00:06:05 +02:00
|
|
|
GB_PROPERTY_SELF("Bounds", ".Array.Bounds"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
GB_METHOD("_get", "*", ArrayOfStruct_get, "(Index)i."),
|
2011-01-13 19:56:52 +01:00
|
|
|
GB_METHOD("_put", NULL, ArrayOfStruct_put, "(Value)*;(Index)i."),
|
2010-07-08 00:06:05 +02:00
|
|
|
GB_METHOD("_next", "*", ArrayOfStruct_next, NULL),
|
2011-06-25 00:33:26 +02:00
|
|
|
//GB_PROPERTY_READ("Last", "b", ArrayOfStruct_Last),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-03-02 12:36:42 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef GBX_INFO
|
|
|
|
|
|
|
|
/* Gambas API */
|
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
void GB_ArrayNew(GB_ARRAY *array, TYPE type, int size)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
int np;
|
2010-07-08 00:06:05 +02:00
|
|
|
CTYPE ctype;
|
2009-03-02 12:36:42 +01:00
|
|
|
|
|
|
|
if (size > 0)
|
|
|
|
{
|
|
|
|
GB_Push(1, GB_T_INTEGER, size);
|
|
|
|
np = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
np = 0;
|
|
|
|
}
|
2010-05-19 14:43:57 +02:00
|
|
|
|
2010-07-08 00:06:05 +02:00
|
|
|
ctype.id = T_NULL;
|
|
|
|
*array = OBJECT_create(CARRAY_get_array_class((CLASS *)type, ctype), NULL, NULL, np);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
int GB_ArrayCount(GB_ARRAY array)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2010-05-19 14:43:57 +02:00
|
|
|
return ((CARRAY *)array)->count;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
void *GB_ArrayAdd(GB_ARRAY array)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
return insert((CARRAY *)array, -1);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
void *GB_ArrayGet(GB_ARRAY array, int index)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-03-02 12:36:42 +01:00
|
|
|
return get_data((CARRAY *)array, index);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2008-03-31 21:04:28 +02:00
|
|
|
TYPE GB_ArrayType(GB_ARRAY array)
|
|
|
|
{
|
|
|
|
return ((CARRAY *)array)->type;
|
|
|
|
}
|
|
|
|
|
2010-11-16 02:49:18 +01:00
|
|
|
void GB_ArrayRemove(GB_ARRAY array, int index)
|
|
|
|
{
|
|
|
|
copy_remove((CARRAY *)array, index, 1, FALSE, TRUE);
|
|
|
|
}
|
|
|
|
|
2012-11-24 19:52:11 +01:00
|
|
|
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#endif
|