gambas-source-code/main/gbx/gbx_c_array.h

116 lines
3.4 KiB
C
Raw Normal View History

/***************************************************************************
gbx_c_array.h
(c) 2000-2017 Benoît Minisini <g4mba5@gmail.com>
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
the Free Software Foundation; either version 2, or (at your option)
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
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
***************************************************************************/
#ifndef __GBX_C_ARRAY_H
#define __GBX_C_ARRAY_H
#ifndef GBX_INFO
#include "gambas.h"
#include "gbx_variant.h"
#include "gbx_object.h"
#include "gbx_type.h"
#include "gbx_class.h"
// Do not forget to modify GB_ARRAY_BASE in gambas.h
typedef
struct {
OBJECT object;
int size;
int count;
TYPE type;
void *data;
int *dim;
void *ref;
}
CARRAY;
#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[];
extern GB_DESC NATIVE_PointerArray[];
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[];
extern GB_DESC NATIVE_TemplateArrayOfStruct[];
#else
#define THIS ((CARRAY *)_object)
#endif
void CARRAY_split(CARRAY *_object, const char *str, int lstr, const char *sep, const char *esc, bool no_void, bool keep_esc);
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
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);
#define CARRAY_invert(_array) CARRAY_reverse(_array, NULL)
void *CARRAY_get_data_multi(CARRAY *_object, GB_INTEGER *arg, int nparam);
void *CARRAY_out_of_bounds();
CLASS *CARRAY_get_array_class(CLASS *class, CTYPE ctype);
int *CARRAY_get_array_bounds(CARRAY *_object);
void CARRAY_resize(CARRAY *_object, int size);
CARRAY *CARRAY_create_static(CLASS *class, void *ref, CLASS_ARRAY *desc, void *data);
int CARRAY_get_static_count(CLASS_ARRAY *desc);
size_t CARRAY_get_static_size(CLASS *class, CLASS_ARRAY *desc);
void CARRAY_release_static(CLASS *class, CLASS_ARRAY *desc, void *data);
#define CARRAY_get_data(_array, _index) \
({ \
int __index = (_index); \
CARRAY *__array = (CARRAY *)(_array); \
void *__data; \
if ((__index < 0) || (__index >= __array->count)) \
__data = CARRAY_out_of_bounds(); \
else \
__data = (void *)((char *)(__array->data) + __index * __array->size); \
__data; \
})
#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); \
})
#endif // #ifndef __GBX_CLASS_INFO_C
#define ARRAY_TEMPLATE_NDESC 24
#define ARRAY_OF_STRUCT_TEMPLATE_NDESC 15
#endif