version 1.65, 2015/06/11 21:20:41
|
version 1.106, 2025/04/15 10:17:57
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.22 |
RPL/2 (R) version 4.1.36 |
Copyright (C) 1989-2015 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 29
|
Line 29
|
================================================================================ |
================================================================================ |
*/ |
*/ |
|
|
# define RPLARGS |
// Si TYPE_DECLARATION est défini, toutes les structures internes du RPL/2 |
# define struct_processus void |
// sont exposés pour travailler sur des nouveaux types de données. |
|
# ifndef TYPE_DECLARATION |
|
# define RPLARGS |
|
# define struct_processus void |
|
# endif |
|
|
# include "rpl.h" |
# include "rpl.h" |
|
|
/* |
/* |
Line 40
|
Line 45
|
*/ |
*/ |
|
|
#define __RPL__ struct_rpl_arguments *rpl_arguments; \ |
#define __RPL__ struct_rpl_arguments *rpl_arguments; \ |
rpl_arguments = &__static_rpl_arguments; |
rpl_arguments = &__static_rpl_arguments; \ |
|
|
#define __CATCH_SYSTEM_ERROR__ \ |
#define __CATCH_SYSTEM_ERROR__ \ |
do { if (((*rpl_arguments).erreur != 0) && \ |
do { if (((*rpl_arguments).erreur != 0) && \ |
((*rpl_arguments).type_erreur == 'S')) \ |
((*rpl_arguments).type_erreur == 'S')) \ |
return 0; } while(0) |
return 0; } while(0) |
#define leave do { return(0); } while(0) |
#define leave do { return(0); } while(0) |
#define allocation(a) librpl_allocation((*rpl_arguments).s_etat_processus, a) |
#define _allocation(a) librpl_allocation((*rpl_arguments).s_etat_processus, a) |
#define copie_objet(a, b) librpl_copie_objet( \ |
#define _copie_objet(a, b) librpl_copie_objet( \ |
(*rpl_arguments).s_etat_processus, a, b) |
(*rpl_arguments).s_etat_processus, a, b) |
#define liberation(a) librpl_liberation((*rpl_arguments).s_etat_processus, a) |
#define _liberation(a) librpl_liberation((*rpl_arguments).s_etat_processus, a) |
|
|
#ifdef __RPLC_MAIN |
#ifdef __RPLC_MAIN |
struct_rpl_arguments __static_rpl_arguments; |
struct_rpl_arguments __static_rpl_arguments; |
|
void *__static_library_descriptor; |
# define global |
# define global |
# define initialize(a, b) a = b |
# define initialize(a, b) a = b |
# define declarePersistantObject(rpl_object) declareObject(rpl_object) |
# define declarePersistantObject(rpl_object) declareObject(rpl_object) |
#else |
#else |
extern struct_rpl_arguments __static_rpl_arguments; |
extern struct_rpl_arguments __static_rpl_arguments; |
|
extern void *__static_library_descriptor; |
# define global extern |
# define global extern |
# define initialize(a, b) a; |
# define initialize(a, b) a; |
# define declarePersistantObject(rpl_object) extern struct_objet *rpl_object |
# define declarePersistantObject(rpl_object) extern struct_objet *rpl_object |
Line 68
|
Line 75
|
|
|
/* |
/* |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
|
Gestion des objets |
|
-------------------------------------------------------------------------------- |
|
*/ |
|
|
|
// new, dup, drop, disp, parse |
|
// __type_new(struct_rpl_arguments *rpl_arguments) |
|
#define declareTypeExtension(fct) \ |
|
int __type_##fct(struct_processus *s_etat_processus, void **arg) { \ |
|
char *rptr, *ptr, *iptr; \ |
|
rptr = (char *) ((*s_etat_processus).definitions_chainees + \ |
|
(*s_etat_processus).position_courante); \ |
|
ptr = rptr; \ |
|
iptr = (char *) (*s_etat_processus).instruction_courante; \ |
|
if ((ptr != rptr) && (iptr)) goto __parse_error; |
|
#define parseError { goto __parse_error; } while(0) |
|
#define typeError { return(0); } while(0) |
|
#define typeSystemError { (*s_etat_processus).erreur_systeme = \ |
|
d_es_execution_bibliotheque; return(0); } while(0) |
|
#define typeSuccess { return(1); } while(0) |
|
#define typeFound(a) { return(a); } while(0) |
|
#define endTypeExtension __parse_error: return(0); } |
|
#define sizeOfParse (rptr - ptr) |
|
#define searchType(...) { recherche_type(s_etat_processus); \ |
|
if (((*s_etat_processus).erreur_execution != d_ex) || \ |
|
((*s_etat_processus).erreur_systeme != d_es)) \ |
|
{ __VA_ARGS__; return(0); } } while(0) |
|
#define structObject struct_objet |
|
#define initializeObject(a, b) do { \ |
|
(*a).descripteur_bibliotheque = (*b).descripteur_bibliotheque; \ |
|
(*a).extension_type = (*b).extension_type; } while(0) |
|
#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 elseIfIsExternal(a, b) } else if (((*a).type == EXT) && \ |
|
((*a).extension_type == b)) |
|
#define subType(a) ((*a).extension_type) |
|
#define integerFormat(a) formateur_nombre(s_etat_processus, a, 'I') |
|
#define procStatus(a) (*a).s_etat_processus |
|
|
|
/* |
|
-------------------------------------------------------------------------------- |
Types |
Types |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
*/ |
*/ |
Line 102
|
Line 150
|
({ __CATCH_SYSTEM_ERROR__; typeof(daisyChain) __daisyChain = daisyChain; \ |
({ __CATCH_SYSTEM_ERROR__; typeof(daisyChain) __daisyChain = daisyChain; \ |
if (__daisyChain == NULL) executionError("End of daisy chain"); \ |
if (__daisyChain == NULL) executionError("End of daisy chain"); \ |
(__daisyChain == NULL) ? NULL : (*__daisyChain).suivant; }) |
(__daisyChain == NULL) ? NULL : (*__daisyChain).suivant; }) |
|
|
|
#define next suivant |
|
#define data donnee |
|
#define daisyChain struct_liste_chainee |
|
|
#define null NULL |
#define null NULL |
#define nullify(ptr) __CATCH_SYSTEM_ERROR__; do { ptr = NULL; } while(0) |
#define nullify(ptr) __CATCH_SYSTEM_ERROR__; do { ptr = NULL; } while(0) |
Line 135
|
Line 187
|
#define declareUnion typedef union { |
#define declareUnion typedef union { |
#define as(name) } name; |
#define as(name) } name; |
|
|
#define target(a) (*a) |
#define target(a) (*(a)) |
#define address(a) (&a) |
#define address(a) (&(a)) |
|
|
#define subroutine(name) int name() |
#define subroutine(name) int name() |
#define beginGroup { __CATCH_SYSTEM_ERROR__; |
#define beginGroup { __CATCH_SYSTEM_ERROR__; |
Line 176
|
Line 228
|
unsigned char __taille_bloc; \ |
unsigned char __taille_bloc; \ |
unsigned char __type; \ |
unsigned char __type; \ |
t_8_bits __masque; \ |
t_8_bits __masque; \ |
|
void *s_etat_processus = (*rpl_arguments).s_etat_processus; \ |
|
DISABLE_SET_BUT_NOT_USED_WARNING(s_etat_processus); \ |
{ \ |
{ \ |
(*rpl_arguments).instruction_valide = 'Y'; \ |
(*rpl_arguments).instruction_valide = 'Y'; \ |
(*rpl_arguments).erreur = 0; \ |
(*rpl_arguments).erreur = 0; \ |
Line 224
|
Line 278
|
do { \ |
do { \ |
if (rpl_object == NULL) \ |
if (rpl_object == NULL) \ |
systemError("Nullified object"); \ |
systemError("Nullified object"); \ |
liberation(rpl_object); \ |
_liberation(rpl_object); \ |
rpl_object = NULL; \ |
rpl_object = NULL; \ |
} while(0) |
} while(0) |
|
|
Line 236
|
Line 290
|
|
|
#define dupObject(rpl_object) \ |
#define dupObject(rpl_object) \ |
__CATCH_SYSTEM_ERROR__; \ |
__CATCH_SYSTEM_ERROR__; \ |
do { if (copie_objet(rpl_object, 'P') != rpl_object) \ |
do { if (_copie_objet(rpl_object, 'P') != rpl_object) \ |
systemError("Memory allocation error"); } while(0) |
systemError("Memory allocation error"); } while(0) |
|
|
/* |
/* |
Line 245
|
Line 299
|
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
*/ |
*/ |
|
|
#define CONCAT(a, b) __CONCAT(a, b) |
#define CONCAT(a, b) __RPL_CONCAT(a, b) |
#define __CONCAT(a, b) a##b |
#define __RPL_CONCAT(a, b) a##b |
#define FIRST(...) FIRST_HELPER(__VA_ARGS__, throwaway) |
#define FIRST(...) FIRST_HELPER(__VA_ARGS__, throwaway) |
#define FIRST_HELPER(first, ...) first |
#define FIRST_HELPER(first, ...) first |
#define REST(...) REST_HELPER(NUM(__VA_ARGS__), __VA_ARGS__) |
#define REST(...) REST_HELPER(NUM(__VA_ARGS__), __VA_ARGS__) |
Line 302
|
Line 356
|
|
|
#define libraryName(name) char __library_name[] = #name; |
#define libraryName(name) char __library_name[] = #name; |
|
|
#define __onLoading int __runOnLoading(struct_rpl_arguments *rpl_arguments) |
#define __onLoading int __runOnLoading(struct_rpl_arguments *rpl_arguments, \ |
#define __onClosing int __runOnClosing(struct_rpl_arguments *rpl_arguments) |
void *descriptor) |
|
#define __onClosing int __runOnClosing(struct_rpl_arguments *rpl_arguments, \ |
|
void *descriptor) |
#define declareSubroutine(when) __##when { \ |
#define declareSubroutine(when) __##when { \ |
char __function_name[] = #when; \ |
char __function_name[] = #when; \ |
__static_rpl_arguments = (*rpl_arguments); \ |
__static_rpl_arguments = (*rpl_arguments); \ |
|
__static_library_descriptor = descriptor; \ |
HEADER \ |
HEADER \ |
declareHelpString(""); \ |
declareHelpString(""); \ |
numberOfArguments(0); \ |
numberOfArguments(0); \ |
Line 319
|
Line 376
|
do { syslog(LOG_NOTICE, __VA_ARGS__); } while(0) |
do { syslog(LOG_NOTICE, __VA_ARGS__); } while(0) |
|
|
#define exportExternalFunctions(...) \ |
#define exportExternalFunctions(...) \ |
char **__external_symbols(struct_rpl_arguments *rpl_arguments, \ |
char **___external_symbols(struct_rpl_arguments *rpl_arguments, \ |
integer8 *nb_symbols, \ |
integer8 *nb_symbols, \ |
const char *version) { \ |
const char *version) { \ |
char arguments[] = #__VA_ARGS__; \ |
char arguments[] = #__VA_ARGS__; \ |
Line 535
|
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__, "unknown") != NULL) \ |
else if (strstr(#__VA_ARGS__, "complex") != NULL) { \ |
__type = 1; \ |
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).descripteur_bibliotheque == \ |
|
__static_library_descriptor) __type = 1; } }\ |
|
else if (strstr(#__VA_ARGS__, "unknown") != NULL) { \ |
|
__type = 1; } \ |
if (__type == 0) \ |
if (__type == 0) \ |
{ \ |
{ \ |
executionError("Type not allowed"); \ |
executionError("Type not allowed"); \ |
Line 554
|
Line 621
|
} \ |
} \ |
} } while(0) |
} } while(0) |
|
|
|
#define objectSubtype(a) (*a).extension_type |
|
|
/* |
/* |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Gestion des objets |
Gestion des objets |
Line 648
|
Line 717
|
if ((*rpl_object).nombre_occurrences > 1) \ |
if ((*rpl_object).nombre_occurrences > 1) \ |
{ \ |
{ \ |
struct_objet *__tmp_rpl_object; \ |
struct_objet *__tmp_rpl_object; \ |
if ((__tmp_rpl_object = copie_objet(rpl_object, 'O')) == NULL) \ |
if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
liberation(rpl_object); \ |
_liberation(rpl_object); \ |
rpl_object = __tmp_rpl_object; \ |
rpl_object = __tmp_rpl_object; \ |
} \ |
} \ |
(*((integer8 *) (*rpl_object).objet)) = (integer8) value; \ |
(*((integer8 *) (*rpl_object).objet)) = (integer8) value; \ |
Line 671
|
Line 740
|
#define createIntegerObject(rpl_object) do { \ |
#define createIntegerObject(rpl_object) do { \ |
if (rpl_object != NULL) \ |
if (rpl_object != NULL) \ |
systemError("Reallocated object"); \ |
systemError("Reallocated object"); \ |
if ((rpl_object = allocation(INT)) == NULL) \ |
if ((rpl_object = _allocation(INT)) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
setInteger(rpl_object, 0); } while(0) |
setInteger(rpl_object, 0); } while(0) |
|
|
Line 683
|
Line 752
|
if ((*rpl_object).nombre_occurrences > 1) \ |
if ((*rpl_object).nombre_occurrences > 1) \ |
{ \ |
{ \ |
struct_objet *__tmp_rpl_object; \ |
struct_objet *__tmp_rpl_object; \ |
if ((__tmp_rpl_object = copie_objet(rpl_object, 'O')) == NULL) \ |
if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
liberation(rpl_object); \ |
_liberation(rpl_object); \ |
rpl_object = __tmp_rpl_object; \ |
rpl_object = __tmp_rpl_object; \ |
} \ |
} \ |
(*((real8 *) (*rpl_object).objet)) = (real8) value; \ |
(*((real8 *) (*rpl_object).objet)) = (real8) value; \ |
Line 706
|
Line 775
|
#define createRealObject(rpl_object) do { \ |
#define createRealObject(rpl_object) do { \ |
if (rpl_object != NULL) \ |
if (rpl_object != NULL) \ |
systemError("Reallocated object"); \ |
systemError("Reallocated object"); \ |
if ((rpl_object = allocation(REL)) == NULL) \ |
if ((rpl_object = _allocation(REL)) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
setReal(rpl_object, 0); } while(0) |
setReal(rpl_object, 0); } while(0) |
|
|
Line 720
|
Line 789
|
if ((*rpl_object).nombre_occurrences > 1) \ |
if ((*rpl_object).nombre_occurrences > 1) \ |
{ \ |
{ \ |
struct_objet *__tmp_rpl_object; \ |
struct_objet *__tmp_rpl_object; \ |
if ((__tmp_rpl_object = copie_objet(rpl_object, 'O')) == NULL) \ |
if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
liberation(rpl_object); \ |
_liberation(rpl_object); \ |
rpl_object = __tmp_rpl_object; \ |
rpl_object = __tmp_rpl_object; \ |
} \ |
} \ |
setRealPartOfComplex(rpl_object, __rp); \ |
setRealPartOfComplex(rpl_object, __rp); \ |
Line 734
|
Line 803
|
if ((*rpl_object).nombre_occurrences > 1) \ |
if ((*rpl_object).nombre_occurrences > 1) \ |
{ \ |
{ \ |
struct_objet *__tmp_rpl_object; \ |
struct_objet *__tmp_rpl_object; \ |
if ((__tmp_rpl_object = copie_objet(rpl_object, 'O')) == NULL) \ |
if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
liberation(rpl_object); \ |
_liberation(rpl_object); \ |
rpl_object = __tmp_rpl_object; \ |
rpl_object = __tmp_rpl_object; \ |
} \ |
} \ |
ifIsComplex(rpl_object) (*((complex16 *) (*rpl_object).objet)) \ |
ifIsComplex(rpl_object) (*((complex16 *) (*rpl_object).objet)) \ |
Line 747
|
Line 816
|
if ((*rpl_object).nombre_occurrences > 1) \ |
if ((*rpl_object).nombre_occurrences > 1) \ |
{ \ |
{ \ |
struct_objet *__tmp_rpl_object; \ |
struct_objet *__tmp_rpl_object; \ |
if ((__tmp_rpl_object = copie_objet(rpl_object, 'O')) == NULL) \ |
if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
liberation(rpl_object); \ |
_liberation(rpl_object); \ |
rpl_object = __tmp_rpl_object; \ |
rpl_object = __tmp_rpl_object; \ |
} \ |
} \ |
(*((complex16 *) (*rpl_object).objet)).partie_imaginaire = value; \ |
(*((complex16 *) (*rpl_object).objet)).partie_imaginaire = value; \ |
Line 776
|
Line 845
|
#define createComplexObject(rpl_object) do { \ |
#define createComplexObject(rpl_object) do { \ |
if (rpl_object != NULL) \ |
if (rpl_object != NULL) \ |
systemError("Reallocated object"); \ |
systemError("Reallocated object"); \ |
if ((rpl_object = allocation(CPL)) == NULL) \ |
if ((rpl_object = _allocation(CPL)) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
setComplex(rpl_object, 0, 0); } while(0) |
setComplex(rpl_object, 0, 0); } while(0) |
|
|
Line 788
|
Line 857
|
s_etat_processus = (*rpl_arguments).s_etat_processus; \ |
s_etat_processus = (*rpl_arguments).s_etat_processus; \ |
if (rpl_object != NULL) \ |
if (rpl_object != NULL) \ |
systemError("Reallocated object"); \ |
systemError("Reallocated object"); \ |
if ((rpl_object = allocation(cat)) == NULL) \ |
if ((rpl_object = _allocation(cat)) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
(*((structure *) (*rpl_object).objet)).taille = size; \ |
(*((structure *) (*rpl_object).objet)).taille = size; \ |
if (((*((structure *) (*rpl_object).objet)).tableau = \ |
if (((*((structure *) (*rpl_object).objet)).tableau = \ |
Line 815
|
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 824
|
Line 900
|
if ((*rpl_object).nombre_occurrences > 1) \ |
if ((*rpl_object).nombre_occurrences > 1) \ |
{ \ |
{ \ |
struct_objet *__tmp_rpl_object; \ |
struct_objet *__tmp_rpl_object; \ |
if ((__tmp_rpl_object = copie_objet(rpl_object, 'O')) == NULL) \ |
if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
liberation(rpl_object); \ |
_liberation(rpl_object); \ |
rpl_object = __tmp_rpl_object; \ |
rpl_object = __tmp_rpl_object; \ |
} \ |
} \ |
__position--; \ |
__position--; \ |
Line 872
|
Line 948
|
if ((*rpl_object).nombre_occurrences > 1) \ |
if ((*rpl_object).nombre_occurrences > 1) \ |
{ \ |
{ \ |
struct_objet *__tmp_rpl_object; \ |
struct_objet *__tmp_rpl_object; \ |
if ((__tmp_rpl_object = copie_objet(rpl_object, 'O')) == NULL) \ |
if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
liberation(rpl_object); \ |
_liberation(rpl_object); \ |
rpl_object = __tmp_rpl_object; \ |
rpl_object = __tmp_rpl_object; \ |
} \ |
} \ |
__position--; \ |
__position--; \ |
Line 920
|
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 928
|
Line 1052
|
if ((*rpl_object).nombre_occurrences > 1) \ |
if ((*rpl_object).nombre_occurrences > 1) \ |
{ \ |
{ \ |
struct_objet *__tmp_rpl_object; \ |
struct_objet *__tmp_rpl_object; \ |
if ((__tmp_rpl_object = copie_objet(rpl_object, 'O')) == NULL) \ |
if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
liberation(rpl_object); \ |
_liberation(rpl_object); \ |
rpl_object = __tmp_rpl_object; \ |
rpl_object = __tmp_rpl_object; \ |
} \ |
} \ |
(*((integer8 *) (*rpl_object).objet)) = (integer8) value; \ |
(*((integer8 *) (*rpl_object).objet)) = (integer8) value; \ |
Line 952
|
Line 1076
|
#define createBinaryIntegerObject(rpl_object) do { \ |
#define createBinaryIntegerObject(rpl_object) do { \ |
if (rpl_object != NULL) \ |
if (rpl_object != NULL) \ |
systemError("Reallocated object"); \ |
systemError("Reallocated object"); \ |
if ((rpl_object = allocation(BIN)) == NULL) \ |
if ((rpl_object = _allocation(BIN)) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
setBinaryInteger(rpl_object, 0); } while(0) |
setBinaryInteger(rpl_object, 0); } while(0) |
|
|
Line 972
|
Line 1096
|
if ((*rpl_object).nombre_occurrences > 1) \ |
if ((*rpl_object).nombre_occurrences > 1) \ |
{ \ |
{ \ |
struct_objet *__tmp_rpl_object; \ |
struct_objet *__tmp_rpl_object; \ |
if ((__tmp_rpl_object = copie_objet(rpl_object, 'O')) == NULL) \ |
if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
liberation(rpl_object); \ |
_liberation(rpl_object); \ |
rpl_object = __tmp_rpl_object; \ |
rpl_object = __tmp_rpl_object; \ |
} \ |
} \ |
free((*((struct_nom *) (*rpl_object).objet)).nom); \ |
free((*((struct_nom *) (*rpl_object).objet)).nom); \ |
Line 996
|
Line 1120
|
s_etat_processus = (*rpl_arguments).s_etat_processus; \ |
s_etat_processus = (*rpl_arguments).s_etat_processus; \ |
if (rpl_object != NULL) \ |
if (rpl_object != NULL) \ |
systemError("Reallocated object"); \ |
systemError("Reallocated object"); \ |
if ((rpl_object = allocation(NOM)) == NULL) \ |
if ((rpl_object = _allocation(NOM)) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
(*((struct_nom *) (*rpl_object).objet)).symbole = d_faux; \ |
(*((struct_nom *) (*rpl_object).objet)).symbole = d_faux; \ |
if (((*((struct_nom *) (*rpl_object).objet)).nom = malloc( \ |
if (((*((struct_nom *) (*rpl_object).objet)).nom = malloc( \ |
Line 1010
|
Line 1134
|
((*rpl_object).type == CHN) |
((*rpl_object).type == CHN) |
|
|
#define ifIsString(rpl_object) if (isString(rpl_object)) |
#define ifIsString(rpl_object) if (isString(rpl_object)) |
#define elseIfIsString(rpl_object) else if (isString(rpl_object)) |
#define elseIfIsString(rpl_object) } else if (isString(rpl_object)) |
|
|
#define setString(rpl_object, string) do { \ |
#define setString(rpl_object, string) do { \ |
struct_processus *s_etat_processus; \ |
struct_processus *s_etat_processus; \ |
Line 1022
|
Line 1146
|
if ((*rpl_object).nombre_occurrences > 1) \ |
if ((*rpl_object).nombre_occurrences > 1) \ |
{ \ |
{ \ |
struct_objet *__tmp_rpl_object; \ |
struct_objet *__tmp_rpl_object; \ |
if ((__tmp_rpl_object = copie_objet(rpl_object, 'O')) == NULL) \ |
if ((__tmp_rpl_object = _copie_objet(rpl_object, 'O')) \ |
|
== NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
liberation(rpl_object); \ |
_liberation(rpl_object); \ |
rpl_object = __tmp_rpl_object; \ |
rpl_object = __tmp_rpl_object; \ |
} \ |
} \ |
free((unsigned char *) (*rpl_object).objet); \ |
free((unsigned char *) (*rpl_object).objet); \ |
Line 1041
|
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; \ |
if (rpl_object != NULL) \ |
if (rpl_object != NULL) \ |
systemError("Reallocated object"); \ |
systemError("Reallocated object"); \ |
if ((rpl_object = allocation(CHN)) == NULL) \ |
if ((rpl_object = _allocation(CHN)) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
if (((*rpl_object).objet = malloc(sizeof(unsigned char))) == NULL) \ |
if (((*rpl_object).objet = malloc(sizeof(unsigned char))) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
Line 1063
|
Line 1204
|
#define createListObject(rpl_object) do { \ |
#define createListObject(rpl_object) do { \ |
if (rpl_object != NULL) \ |
if (rpl_object != NULL) \ |
systemError("Reallocated object"); \ |
systemError("Reallocated object"); \ |
if ((rpl_object = allocation(LST)) == NULL) \ |
if ((rpl_object = _allocation(LST)) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
(*rpl_object).objet = NULL; } while(0) |
(*rpl_object).objet = NULL; } while(0) |
|
|
Line 1073
|
Line 1214
|
ifIsList(list) \ |
ifIsList(list) \ |
{ \ |
{ \ |
struct_objet *__tmp_rpl_object; \ |
struct_objet *__tmp_rpl_object; \ |
if ((__tmp_rpl_object = copie_objet(list, 'N')) == NULL) \ |
if ((__tmp_rpl_object = _copie_objet(list, 'N')) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
liberation(list); \ |
_liberation(list); \ |
list = __tmp_rpl_object; \ |
list = __tmp_rpl_object; \ |
if ((*list).objet == NULL) \ |
if ((*list).objet == NULL) \ |
{ \ |
{ \ |
Line 1108
|
Line 1249
|
ifIsList(list) \ |
ifIsList(list) \ |
{ \ |
{ \ |
struct_objet *__tmp_rpl_object; \ |
struct_objet *__tmp_rpl_object; \ |
if ((__tmp_rpl_object = copie_objet(list, 'N')) == NULL) \ |
if ((__tmp_rpl_object = _copie_objet(list, 'N')) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
liberation(list); \ |
_liberation(list); \ |
list = __tmp_rpl_object; \ |
list = __tmp_rpl_object; \ |
if ((*list).objet == NULL) \ |
if ((*list).objet == NULL) \ |
{ \ |
{ \ |
Line 1162
|
Line 1303
|
__current = (*__current).suivant; \ |
__current = (*__current).suivant; \ |
} \ |
} \ |
} \ |
} \ |
liberation((*__current).donnee); \ |
_liberation((*__current).donnee); \ |
free(__current); \ |
free(__current); \ |
} \ |
} \ |
} \ |
} \ |
Line 1189
|
Line 1330
|
} \ |
} \ |
} } while(0) |
} } while(0) |
|
|
|
// NON |
|
#define createObject(rpl_object) do { \ |
|
if (rpl_object != NULL) \ |
|
systemError("Reallocated object"); \ |
|
if ((rpl_object = _allocation(NON)) == NULL) \ |
|
systemError("Memory allocation error"); \ |
|
(*rpl_object).objet = NULL; \ |
|
} while(0) |
|
|
|
// EXT |
|
#define createExternalObject(rpl_object, subtype) do { \ |
|
if (rpl_object != NULL) \ |
|
systemError("Reallocated object"); \ |
|
if ((rpl_object = _allocation(EXT)) == NULL) \ |
|
systemError("Memory allocation error"); \ |
|
(*rpl_object).objet = NULL; \ |
|
(*rpl_object).extension_type = subtype; \ |
|
(*rpl_object).descripteur_bibliotheque = __static_library_descriptor; \ |
|
} while(0) |
|
|
/* |
/* |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Allocation mémoire |
Allocation mémoire |
Line 1201
|
Line 1362
|
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; \ |
if ((ptr = malloc(a)) == NULL) \ |
if ((ptr = malloc(a)) == NULL) \ |
systemError("Memory allocation error"); ptr; }) |
{ systemError("Memory allocation error"); \ |
|
__CATCH_SYSTEM_ERROR__; } ptr; }) \ |
|
|
|
#define reallocate(a, s) ({ void *ptr; \ |
|
struct_processus *s_etat_processus; \ |
|
s_etat_processus = (*rpl_arguments).s_etat_processus; \ |
|
if ((ptr = realloc(a, s)) == NULL) \ |
|
{ systemError("Memory allocation error"); \ |
|
__CATCH_SYSTEM_ERROR__; } ptr; }) \ |
|
|
#define deallocate(a) do { \ |
#define deallocate(a) do { \ |
struct_processus *s_etat_processus; \ |
struct_processus *s_etat_processus; \ |