--- rpl/src/rplexternals.h 2017/07/02 22:28:20 1.77 +++ rpl/src/rplexternals.h 2017/07/03 11:47:05 1.78 @@ -45,7 +45,7 @@ */ #define __RPL__ struct_rpl_arguments *rpl_arguments; \ - rpl_arguments = &__static_rpl_arguments; + rpl_arguments = &__static_rpl_arguments; \ #define __CATCH_SYSTEM_ERROR__ \ do { if (((*rpl_arguments).erreur != 0) && \ @@ -59,11 +59,13 @@ #ifdef __RPLC_MAIN struct_rpl_arguments __static_rpl_arguments; + void *__static_library_descriptor; # define global # define initialize(a, b) a = b # define declarePersistantObject(rpl_object) declareObject(rpl_object) #else extern struct_rpl_arguments __static_rpl_arguments; + extern void *__static_library_descriptor; # define global extern # define initialize(a, b) a; # define declarePersistantObject(rpl_object) extern struct_objet *rpl_object @@ -337,11 +339,14 @@ #define libraryName(name) char __library_name[] = #name; -#define __onLoading int __runOnLoading(struct_rpl_arguments *rpl_arguments) -#define __onClosing int __runOnClosing(struct_rpl_arguments *rpl_arguments) +#define __onLoading int __runOnLoading(struct_rpl_arguments *rpl_arguments, \ + void *descriptor) +#define __onClosing int __runOnClosing(struct_rpl_arguments *rpl_arguments, \ + void *descriptor) #define declareSubroutine(when) __##when { \ char __function_name[] = #when; \ __static_rpl_arguments = (*rpl_arguments); \ + __static_library_descriptor = descriptor; \ HEADER \ declareHelpString(""); \ numberOfArguments(0); \ @@ -580,6 +585,10 @@ if ((*rpl_object).type == CHN) __type = 1; \ if (strstr(#__VA_ARGS__, "list") != NULL) \ if ((*rpl_object).type == LST) __type = 1; \ + if (strstr(#__VA_ARGS__, "external") != NULL) \ + if ((*rpl_object).type == EXT) { \ + if ((*rpl_object).descripteur_bibliotheque == \ + __static_library_descriptor) __type = 1; }\ if (strstr(#__VA_ARGS__, "unknown") != NULL) \ __type = 1; \ if (__type == 0) \ @@ -589,6 +598,8 @@ } \ } } while(0) +#define objectSubtype(a) (*a).extension_type + /* -------------------------------------------------------------------------------- Gestion des objets @@ -1225,6 +1236,17 @@ } \ } } 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 @@ -1237,13 +1259,15 @@ struct_processus *s_etat_processus; \ s_etat_processus = (*rpl_arguments).s_etat_processus; \ 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"); ptr; }) + { systemError("Memory allocation error"); \ + __CATCH_SYSTEM_ERROR__; } ptr; }) \ #define deallocate(a) do { \ struct_processus *s_etat_processus; \