version 1.86, 2017/07/22 11:29:50
|
version 1.106, 2025/04/15 10:17:57
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.27 |
RPL/2 (R) version 4.1.36 |
Copyright (C) 1989-2017 Dr. BERTRAND Joël |
Copyright (C) 1989-2025 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 105
|
Line 105
|
#define initializeObject(a, b) do { \ |
#define initializeObject(a, b) do { \ |
(*a).descripteur_bibliotheque = (*b).descripteur_bibliotheque; \ |
(*a).descripteur_bibliotheque = (*b).descripteur_bibliotheque; \ |
(*a).extension_type = (*b).extension_type; } while(0) |
(*a).extension_type = (*b).extension_type; } while(0) |
#define objectContainer(a) ((*a).objet) |
#define objectContainer(type, a) ((type *) ((*a).objet)) |
|
#define objectOf(a) ((*a).objet) |
#define ifIsExternal(a, b) if (((*a).type == EXT) && ((*a).extension_type == b)) |
#define ifIsExternal(a, b) if (((*a).type == EXT) && ((*a).extension_type == b)) |
#define elseIfIsExternal(a, b) } else if (((*a).type == EXT) && \ |
#define elseIfIsExternal(a, b) } else if (((*a).type == EXT) && \ |
((*a).extension_type == b)) |
((*a).extension_type == b)) |
Line 591
|
Line 592
|
else \ |
else \ |
{ \ |
{ \ |
__type = 0; \ |
__type = 0; \ |
if (strstr(#__VA_ARGS__, "integer") != NULL) \ |
if (strstr(#__VA_ARGS__, "integerVector") != NULL) { \ |
if ((*rpl_object).type == INT) __type = 1; \ |
if ((*rpl_object).type == VIN) __type = 1; } \ |
if (strstr(#__VA_ARGS__, "real") != NULL) \ |
else if (strstr(#__VA_ARGS__, "realVector") != NULL) { \ |
if ((*rpl_object).type == REL) __type = 1; \ |
if ((*rpl_object).type == VRL) __type = 1; } \ |
if (strstr(#__VA_ARGS__, "complex") != NULL) \ |
else if (strstr(#__VA_ARGS__, "complexVector") != NULL) { \ |
if ((*rpl_object).type == CPL) __type = 1; \ |
if ((*rpl_object).type == VCX) __type = 1; } \ |
if (strstr(#__VA_ARGS__, "string") != NULL) \ |
else if (strstr(#__VA_ARGS__, "integer") != NULL) { \ |
if ((*rpl_object).type == CHN) __type = 1; \ |
if ((*rpl_object).type == INT) __type = 1; } \ |
if (strstr(#__VA_ARGS__, "list") != NULL) \ |
else if (strstr(#__VA_ARGS__, "real") != NULL) { \ |
if ((*rpl_object).type == LST) __type = 1; \ |
if ((*rpl_object).type == REL) __type = 1; } \ |
if (strstr(#__VA_ARGS__, "external") != NULL) \ |
else if (strstr(#__VA_ARGS__, "complex") != NULL) { \ |
|
if ((*rpl_object).type == CPL) __type = 1; } \ |
|
else if (strstr(#__VA_ARGS__, "string") != NULL) { \ |
|
if ((*rpl_object).type == CHN) __type = 1; } \ |
|
else if (strstr(#__VA_ARGS__, "list") != NULL) { \ |
|
if ((*rpl_object).type == LST) __type = 1; } \ |
|
else if (strstr(#__VA_ARGS__, "external") != NULL) { \ |
if ((*rpl_object).type == EXT) { \ |
if ((*rpl_object).type == EXT) { \ |
if ((*rpl_object).descripteur_bibliotheque == \ |
if ((*rpl_object).descripteur_bibliotheque == \ |
__static_library_descriptor) __type = 1; }\ |
__static_library_descriptor) __type = 1; } }\ |
if (strstr(#__VA_ARGS__, "unknown") != NULL) \ |
else if (strstr(#__VA_ARGS__, "unknown") != NULL) { \ |
__type = 1; \ |
__type = 1; } \ |
if (__type == 0) \ |
if (__type == 0) \ |
{ \ |
{ \ |
executionError("Type not allowed"); \ |
executionError("Type not allowed"); \ |
Line 877
|
Line 884
|
} \ |
} \ |
} } while(0) |
} } while(0) |
|
|
|
#define vectorSize(rpl_object) \ |
|
({ integer8 __size = 0; if (((*rpl_object).type == VIN) || \ |
|
((*rpl_object).type == VRL) || \ |
|
((*rpl_object).type == VCX)) \ |
|
__size = (*((struct_vecteur *) (*rpl_object).objet)).taille; \ |
|
else executionError("Type mistmatch error"); __size; }) |
|
|
// Integer vector |
// Integer vector |
|
|
#define setIntegerIntoVector(rpl_object, value, position) do { \ |
#define setIntegerIntoVector(rpl_object, value, position) do { \ |
Line 982
|
Line 996
|
|
|
#define createComplexMatrixObject |
#define createComplexMatrixObject |
|
|
|
// Array |
|
|
|
#define isArray(rpl_object) \ |
|
((*rpl_object).type == TBL) |
|
|
|
#define ifIsArray(rpl_object) if (isArray(rpl_object)) |
|
#define elseIfIsArray(rpl_object) } else if (isArray(rpl_object)) |
|
|
|
#define createArray(rpl_object, size) do { \ |
|
int __i; \ |
|
if (rpl_object != NULL) systemError("Reallocated object"); \ |
|
if ((rpl_object = _allocation(TBL)) == NULL) \ |
|
systemError("Memory allocation error"); \ |
|
(*((struct_tableau *) (*rpl_object).objet)).nombre_elements = size; \ |
|
if (((*((struct_tableau *) (*rpl_object).objet)).elements = malloc( \ |
|
size * sizeof(struct_objet *))) == NULL) \ |
|
systemError("Memory allocation error"); \ |
|
for(__i = 0; __i < size; __i++) { \ |
|
nullify((*((struct_tableau *) (*rpl_object).objet)).elements[__i]); \ |
|
createIntegerObject((*((struct_tableau *) (*rpl_object).objet)) \ |
|
.elements[__i]); } \ |
|
} while(0) |
|
|
|
#define setObjectIntoArray(rpl_array, pos, rpl_object) do { \ |
|
typeof(pos) __position = pos; __position--; \ |
|
ifIsArray(rpl_array) { \ |
|
if ((__position < 0) || (__position >= (*((struct_tableau *) \ |
|
(*rpl_array).objet)).nombre_elements)) \ |
|
executionError("Element out of range"); \ |
|
if ((*rpl_array).nombre_occurrences > 1) \ |
|
{ \ |
|
struct_objet *__tmp_rpl_object; \ |
|
if ((__tmp_rpl_object = _copie_objet(rpl_array, 'O')) == NULL) \ |
|
systemError("Memory allocation error"); \ |
|
_liberation(rpl_array); \ |
|
rpl_array = __tmp_rpl_object; \ |
|
} \ |
|
_liberation((*((struct_tableau *) (*rpl_array).objet)) \ |
|
.elements[__position]); \ |
|
(*((struct_tableau *) (*rpl_array).objet)).elements[__position] = \ |
|
rpl_object; \ |
|
} \ |
|
else executionError("Type mistmatch error"); \ |
|
nullify(rpl_object); \ |
|
} while(0) |
|
|
|
#define getObjectFromArray() |
|
|
// Binary integer |
// Binary integer |
|
|
#define setBinaryInteger(rpl_object, value) do { \ |
#define setBinaryInteger(rpl_object, value) do { \ |
Line 1104
|
Line 1166
|
ifIsString(rpl_object) string = (char *) (*rpl_object).objet; \ |
ifIsString(rpl_object) string = (char *) (*rpl_object).objet; \ |
else executionError("Type mismatch error"); } while(0) |
else executionError("Type mismatch error"); } while(0) |
|
|
|
#define unEscString(s) ({ \ |
|
unsigned char *__a; integer8 __l; \ |
|
__a = formateur_flux((*rpl_arguments).s_etat_processus, \ |
|
(unsigned char *) s, &__l); \ |
|
if (nullified(__a)) systemError("Memory allocation error"); \ |
|
(string) __a; \ |
|
}) |
|
|
|
#define escString(rpl_object) ({ \ |
|
unsigned char *__a; integer8 __l; \ |
|
__a = analyse_flux((*rpl_arguments).s_etat_processus, \ |
|
(unsigned char *) s, strlen(s)); \ |
|
if (nullified(__a)) systemError("Memory allocation error"); \ |
|
(string) __a; \ |
|
}) |
|
|
#define createStringObject(rpl_object) do { \ |
#define createStringObject(rpl_object) do { \ |
struct_processus *s_etat_processus; \ |
struct_processus *s_etat_processus; \ |
s_etat_processus = (*rpl_arguments).s_etat_processus; \ |
s_etat_processus = (*rpl_arguments).s_etat_processus; \ |