version 1.47, 2013/03/29 10:30:32
|
version 1.56, 2014/01/26 18:21:35
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.13 |
RPL/2 (R) version 4.1.17 |
Copyright (C) 1989-2013 Dr. BERTRAND Joël |
Copyright (C) 1989-2014 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 39
|
Line 39
|
================================================================================ |
================================================================================ |
*/ |
*/ |
|
|
|
#define __RPL__ struct_rpl_arguments *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')) \ |
Line 49
|
Line 52
|
(*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 |
|
struct_rpl_arguments __static_rpl_arguments; |
|
# define global |
|
# define initialize(a, b) a = b |
|
# define declarePersistantObject(object) declareObject(object) |
|
#else |
|
extern struct_rpl_arguments __static_rpl_arguments; |
|
# define global extern |
|
# define initialize(a, b) a; |
|
# define declarePersistantObject(object) extern struct_objet *object; |
|
#endif |
|
|
|
#define empty int |
|
|
/* |
/* |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Types |
Types |
Line 228
|
Line 245
|
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
*/ |
*/ |
|
|
#define declareInternalFunction(type, name, ...) \ |
#define CONCAT(a, b) __CONCAT(a, b) |
type __internal_##name(struct_rpl_arguments *rpl_arguments, __VA_ARGS__) { \ |
#define __CONCAT(a, b) a##b |
|
#define FIRST(...) FIRST_HELPER(__VA_ARGS__, throwaway) |
#define endInternalFunction leave; } |
#define FIRST_HELPER(first, ...) first |
|
#define REST(...) REST_HELPER(NUM(__VA_ARGS__), __VA_ARGS__) |
#define useInternalFunction(type, name, ...) \ |
#define REST_HELPER(qty, ...) REST_HELPER2(qty, __VA_ARGS__) |
type __internal_##name(struct_rpl_arguments *rpl_arguments, __VA_ARGS__) |
#define REST_HELPER2(qty, ...) REST_HELPER_##qty(__VA_ARGS__) |
|
#define REST_HELPER_ONE(first) |
|
#define REST_HELPER_TWOORMORE(first, ...) , __VA_ARGS__ |
|
#define NUM(...) \ |
|
SELECT_10TH(__VA_ARGS__, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE,\ |
|
TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, ONE, throwaway) |
|
#define SELECT_10TH(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, ...) a10 |
|
|
|
#define declareInternalFunction(type, ...) \ |
|
type CONCAT(__internal_, FIRST(__VA_ARGS__)) \ |
|
(struct_rpl_arguments *rpl_arguments REST(__VA_ARGS__)) { \ |
|
type __internal_return; __internal_return = 0; int __type; \ |
|
DISABLE_SET_BUT_NOT_USED_WARNING(__type); |
|
|
|
#define endInternalFunction return(__internal_return); } |
|
|
|
#define useInternalFunction(type, ...) \ |
|
type CONCAT(__internal_, FIRST(__VA_ARGS__)) \ |
|
(struct_rpl_arguments *rpl_arguments REST(__VA_ARGS__)) |
|
|
#define callInternalFunction(name, ...) \ |
#define callInternalFunction(...) \ |
__internal_##name(rpl_arguments, __VA_ARGS__) |
CONCAT(__internal_, FIRST(__VA_ARGS__))(rpl_arguments REST(__VA_ARGS__)) |
|
|
/* |
/* |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Line 246
|
Line 281
|
*/ |
*/ |
|
|
#define declareCFunction(type, name, ...) \ |
#define declareCFunction(type, name, ...) \ |
type name(__VA_ARGS__) { __RPL__ |
type name(__VA_ARGS__) { __RPL__ type __c_return; |
#define endCFunction leave; } |
#define endCFunction return(__c_return); } |
|
|
|
#define useCFunction(type, name, ...) type name(__VA_ARGS__) |
|
|
/* |
/* |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Line 960
|
Line 997
|
#define setString(object, string) do { \ |
#define setString(object, string) do { \ |
ifIsString(object) \ |
ifIsString(object) \ |
{ \ |
{ \ |
if ((*object).nombre_occurrences > 1) \ |
if (string == NULL) executionError("Nullified string"); else \ |
{ \ |
{ \ |
struct_objet *__tmp_object; \ |
if ((*object).nombre_occurrences > 1) \ |
if ((__tmp_object = copie_objet(object, 'O')) == NULL) \ |
{ \ |
|
struct_objet *__tmp_object; \ |
|
if ((__tmp_object = copie_objet(object, 'O')) == NULL) \ |
|
systemError("Memory allocation error"); \ |
|
liberation(object); \ |
|
object = __tmp_object; \ |
|
} \ |
|
free((unsigned char *) (*object).objet); \ |
|
if (((*object).objet = malloc((strlen(string) + 1) * \ |
|
sizeof(unsigned char))) == NULL) \ |
systemError("Memory allocation error"); \ |
systemError("Memory allocation error"); \ |
liberation(object); \ |
strcpy((char *) (*object).objet, string); \ |
object = __tmp_object; \ |
|
} \ |
} \ |
free((unsigned char *) (*object).objet); \ |
|
if (((*object).objet = malloc((strlen(string) + 1) * \ |
|
sizeof(unsigned char))) == NULL) \ |
|
systemError("Memory allocation error"); \ |
|
strcpy((char *) (*object).objet, string); \ |
|
} \ |
} \ |
else executionError("Type mistmatch error"); } while(0) |
else executionError("Type mistmatch error"); } while(0) |
|
|
Line 1071
|
Line 1111
|
#define removeObjectFromList(list, object) do { \ |
#define removeObjectFromList(list, object) do { \ |
ifIsList(list) \ |
ifIsList(list) \ |
{ \ |
{ \ |
if ((*object).objet == NULL) \ |
if ((*list).objet != NULL) \ |
{ \ |
{ \ |
struct_objet *__tmp_object; \ |
struct_liste_chainee *__current; \ |
if ((__tmp_object = copie_objet(list, 'N')) == NULL) \ |
struct_liste_chainee *__previous; \ |
systemError("Memory allocation error"); \ |
__current = (*list).objet; \ |
liberation(object); \ |
__previous = NULL; \ |
object = __tmp_object; \ |
if ((*__current).donnee == object) \ |
\ |
{ \ |
\ |
(*list).objet = (*__current).suivant; \ |
\ |
} \ |
\ |
else \ |
} \ |
{ \ |
|
while(__current != NULL) \ |
|
{ \ |
|
if ((*__current).donnee == object) \ |
|
{ \ |
|
(*__previous).suivant = (*__current).suivant; \ |
|
break; \ |
|
} \ |
|
__previous = __current; \ |
|
__current = (*__current).suivant; \ |
|
} \ |
|
} \ |
|
liberation((*__current).donnee); \ |
|
free(__current); \ |
|
} \ |
} \ |
} \ |
else executionError("Type mistmatch error"); } while(0) |
else executionError("Type mistmatch error"); } while(0) |
|
|
Line 1148
|
Line 1202
|
|
|
#endif |
#endif |
|
|
static struct_rpl_arguments __static_rpl_arguments; |
|
#define __RPL__ struct_rpl_arguments *rpl_arguments; \ |
|
rpl_arguments = &__static_rpl_arguments; |
|
|
|
// vim: ts=4 |
// vim: ts=4 |