2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
gbx_c_array.h
|
2007-12-30 17:41:49 +01:00
|
|
|
|
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
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __GBX_C_ARRAY_H
|
|
|
|
#define __GBX_C_ARRAY_H
|
|
|
|
|
2008-09-09 13:03:47 +02:00
|
|
|
#ifndef GBX_INFO
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#include "gambas.h"
|
|
|
|
|
|
|
|
#include "gbx_variant.h"
|
|
|
|
#include "gbx_object.h"
|
2008-03-19 15:32:30 +01:00
|
|
|
#include "gbx_type.h"
|
2010-05-19 14:43:57 +02:00
|
|
|
#include "gbx_class.h"
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-07-09 19:10:21 +02:00
|
|
|
// Do not forget to modify GB_ARRAY_BASE in gambas.h
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
typedef
|
2012-07-09 19:10:21 +02:00
|
|
|
struct {
|
|
|
|
OBJECT object;
|
2010-07-08 00:06:05 +02:00
|
|
|
int size;
|
2010-05-30 21:37:40 +02:00
|
|
|
int count;
|
2012-07-09 19:10:21 +02:00
|
|
|
TYPE type;
|
|
|
|
void *data;
|
|
|
|
int *dim;
|
2010-05-19 14:43:57 +02:00
|
|
|
void *ref;
|
2012-07-09 19:10:21 +02:00
|
|
|
}
|
|
|
|
CARRAY;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#ifndef __GBX_C_ARRAY_C
|
|
|
|
extern GB_DESC NATIVE_ArrayBounds[];
|
|
|
|
extern GB_DESC NATIVE_Array[];
|
|
|
|
extern GB_DESC NATIVE_BooleanArray[];
|
|
|
|
extern GB_DESC NATIVE_ByteArray[];
|
|
|
|
extern GB_DESC NATIVE_ShortArray[];
|
|
|
|
extern GB_DESC NATIVE_IntegerArray[];
|
|
|
|
extern GB_DESC NATIVE_LongArray[];
|
2008-01-23 20:56:18 +01:00
|
|
|
extern GB_DESC NATIVE_PointerArray[];
|
2007-12-30 17:41:49 +01:00
|
|
|
extern GB_DESC NATIVE_SingleArray[];
|
|
|
|
extern GB_DESC NATIVE_FloatArray[];
|
|
|
|
extern GB_DESC NATIVE_StringArray[];
|
|
|
|
extern GB_DESC NATIVE_DateArray[];
|
|
|
|
extern GB_DESC NATIVE_VariantArray[];
|
|
|
|
extern GB_DESC NATIVE_ObjectArray[];
|
|
|
|
extern GB_DESC NATIVE_TemplateArray[];
|
2010-07-08 00:06:05 +02:00
|
|
|
extern GB_DESC NATIVE_TemplateArrayOfStruct[];
|
2007-12-30 17:41:49 +01:00
|
|
|
#else
|
|
|
|
|
|
|
|
#define THIS ((CARRAY *)_object)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2009-09-10 21:30:41 +02:00
|
|
|
void CARRAY_split(CARRAY *_object, const char *str, int lstr, const char *sep, const char *esc, bool no_void, bool keep_esc);
|
2008-01-17 22:39:26 +01:00
|
|
|
void CARRAY_reverse(void *_object, void *_param);
|
|
|
|
void CARRAY_get_value(CARRAY *_object, int index, VALUE *value);
|
2007-12-30 17:41:49 +01:00
|
|
|
#define CARRAY_invert(_array) CARRAY_reverse(_array, NULL)
|
2008-01-24 11:42:42 +01:00
|
|
|
void *CARRAY_get_data_multi(CARRAY *_object, GB_INTEGER *arg, int nparam);
|
2019-09-26 14:25:37 +02:00
|
|
|
void CARRAY_static_array();
|
2018-11-09 00:06:20 +01:00
|
|
|
void *CARRAY_out_of_bounds();
|
2010-07-08 00:06:05 +02:00
|
|
|
CLASS *CARRAY_get_array_class(CLASS *class, CTYPE ctype);
|
2011-03-16 23:16:19 +01:00
|
|
|
int *CARRAY_get_array_bounds(CARRAY *_object);
|
2014-01-28 00:46:37 +01:00
|
|
|
void CARRAY_resize(CARRAY *_object, int size);
|
2010-07-08 00:06:05 +02:00
|
|
|
|
|
|
|
CARRAY *CARRAY_create_static(CLASS *class, void *ref, CLASS_ARRAY *desc, void *data);
|
2010-11-26 21:30:58 +01:00
|
|
|
int CARRAY_get_static_count(CLASS_ARRAY *desc);
|
2010-07-08 00:06:05 +02:00
|
|
|
size_t CARRAY_get_static_size(CLASS *class, CLASS_ARRAY *desc);
|
|
|
|
void CARRAY_release_static(CLASS *class, CLASS_ARRAY *desc, void *data);
|
2008-03-19 15:32:30 +01:00
|
|
|
|
2019-03-20 15:08:16 +01:00
|
|
|
#define CARRAY_get_data_unsafe(_array, _index) \
|
|
|
|
({ \
|
|
|
|
int __index = (_index); \
|
|
|
|
CARRAY *__array = (CARRAY *)(_array); \
|
|
|
|
(void *)((char *)(__array->data) + __index * __array->size); \
|
|
|
|
})
|
|
|
|
|
2008-03-19 15:32:30 +01:00
|
|
|
#define CARRAY_get_data(_array, _index) \
|
|
|
|
({ \
|
|
|
|
int __index = (_index); \
|
|
|
|
CARRAY *__array = (CARRAY *)(_array); \
|
|
|
|
void *__data; \
|
2010-05-19 14:43:57 +02:00
|
|
|
if ((__index < 0) || (__index >= __array->count)) \
|
2018-11-09 00:06:20 +01:00
|
|
|
__data = CARRAY_out_of_bounds(); \
|
2008-03-19 15:32:30 +01:00
|
|
|
else \
|
2010-07-08 00:06:05 +02:00
|
|
|
__data = (void *)((char *)(__array->data) + __index * __array->size); \
|
2008-03-19 15:32:30 +01:00
|
|
|
__data; \
|
|
|
|
})
|
|
|
|
|
2014-11-03 00:09:04 +01:00
|
|
|
#define CARRAY_get_data_throw(_array, _index) \
|
|
|
|
({ \
|
|
|
|
int __index = (_index); \
|
|
|
|
CARRAY *__array = (CARRAY *)(_array); \
|
|
|
|
if ((__index < 0) || (__index >= __array->count)) \
|
|
|
|
THROW(E_BOUND); \
|
|
|
|
(void *)((char *)(__array->data) + __index * __array->size); \
|
|
|
|
})
|
|
|
|
|
2019-09-26 14:25:37 +02:00
|
|
|
#define CARRAY_check_not_read_only(_object) \
|
|
|
|
{ \
|
|
|
|
if (((CARRAY *)_object)->ref) \
|
|
|
|
THROW(E_SARRAY); \
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-09-09 13:03:47 +02:00
|
|
|
#endif // #ifndef __GBX_CLASS_INFO_C
|
|
|
|
|
2019-03-06 03:55:48 +01:00
|
|
|
#define ARRAY_TEMPLATE_NDESC 24
|
2018-11-09 00:06:20 +01:00
|
|
|
#define ARRAY_OF_STRUCT_TEMPLATE_NDESC 15
|
2008-09-09 13:03:47 +02:00
|
|
|
|
2018-11-09 00:06:20 +01:00
|
|
|
#endif
|