From 54304e71740f558d3d8258a96bc2f1a7e9634cc9 Mon Sep 17 00:00:00 2001 From: schnetter Date: Thu, 25 Aug 2005 14:18:10 +0000 Subject: Add Cactus variable type CCTK_POINTER_TO_CONST Complete the implementation of the Cactus variable type CCTK_POINTER_TO_CONST. Define a constant CCTK_VARIABLE_POINTER_TO_CONST. Handle this variable when asking for its name and its size. Allow values of this type in tables. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4113 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/util/Table.c | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 126 insertions(+), 12 deletions(-) (limited to 'src/util') diff --git a/src/util/Table.c b/src/util/Table.c index d9b9df78..3dfc1648 100644 --- a/src/util/Table.c +++ b/src/util/Table.c @@ -131,7 +131,7 @@ CCTK_FILEVERSION(util_Table_c); * iterators. In both cases we use the same data structure: * * int N_objects; // actual number of tables/iterators - * int N_elements; // actual size of growable array + * int N_elements; // actual size of growable array * void *array; // pointer to malloc-allocated growable array * // indexed by handle/ihandle * @@ -1986,7 +1986,7 @@ void CCTK_FCALL CCTK_FNAME(Util_TableGetGenericArray) @var value @vtype one of - CCTK_POINTER, CCTK_FPOINTER, + CCTK_POINTER, CCTK_POINTER_TO_CONST, CCTK_FPOINTER, CCTK_CHAR, CCTK_BYTE, CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8, @@ -2044,6 +2044,32 @@ void CCTK_FCALL CCTK_FNAME(Util_TableSetPointer) /**************************************/ +int Util_TableSetPointerToConst(int handle, + CCTK_POINTER_TO_CONST value, + const char *key) +{ + return Util_TableSetPointerToConstArray(handle, 1, &value, key); +} + +#ifdef UTIL_TABLE_FORTRAN_WRAPPERS +void CCTK_FCALL CCTK_FNAME(Util_TableSetPointerToConst) + (int *retval, const int *handle, + const CCTK_POINTER_TO_CONST *value, + ONE_FORTSTRING_ARG); +void CCTK_FCALL CCTK_FNAME(Util_TableSetPointerTOConst) + (int *retval, + const int *handle, + const CCTK_POINTER_TO_CONST *value, + ONE_FORTSTRING_ARG) +{ + ONE_FORTSTRING_CREATE(key) + *retval = Util_TableSetPointerToConst(*handle, *value, key); + free(key); +} +#endif /* UTIL_TABLE_FORTRAN_WRAPPERS */ + +/**************************************/ + int Util_TableSetFPointer(int handle, CCTK_FPOINTER value, const char *key) { return Util_TableSetFPointerArray(handle, 1, &value, key); @@ -2453,7 +2479,7 @@ void CCTK_FCALL CCTK_FNAME(Util_TableSetComplex32) @var array @vtype const T[], where T is one of - CCTK_POINTER, CCTK_FPOINTER, + CCTK_POINTER, CCTK_POINTER_TO_CONST, CCTK_FPOINTER, CCTK_CHAR, CCTK_BYTE, CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8, @@ -2503,12 +2529,12 @@ int Util_TableSetPointerArray(int handle, #ifdef UTIL_TABLE_FORTRAN_WRAPPERS void CCTK_FCALL CCTK_FNAME(Util_TableSetPointerArray) (int *retval, const int *handle, - const int *N_elements, - const CCTK_POINTER array[], ONE_FORTSTRING_ARG); + const int *N_elements, const CCTK_POINTER array[], + ONE_FORTSTRING_ARG); void CCTK_FCALL CCTK_FNAME(Util_TableSetPointerArray) (int *retval, const int *handle, - const int *N_elements, - const CCTK_POINTER array[], ONE_FORTSTRING_ARG) + const int *N_elements, const CCTK_POINTER array[], + ONE_FORTSTRING_ARG) { ONE_FORTSTRING_CREATE(key) *retval = Util_TableSetPointerArray(*handle, *N_elements, array, key); @@ -2518,6 +2544,37 @@ void CCTK_FCALL CCTK_FNAME(Util_TableSetPointerArray) /**************************************/ +int Util_TableSetPointerToConstArray(int handle, + int N_elements, + const CCTK_POINTER_TO_CONST array[], + const char *key) +{ + return internal_set(handle, + CCTK_VARIABLE_POINTER_TO_CONST, + N_elements, (const void *) array, + key); +} + +#ifdef UTIL_TABLE_FORTRAN_WRAPPERS +void CCTK_FCALL CCTK_FNAME(Util_TableSetPointerToConstArray) + (int *retval, const int *handle, + const int *N_elements, + const CCTK_POINTER_TO_CONST array[], + ONE_FORTSTRING_ARG); +void CCTK_FCALL CCTK_FNAME(Util_TableSetPointerToConstArray) + (int *retval, const int *handle, + const int *N_elements, + const CCTK_POINTER_TO_CONST array[], + ONE_FORTSTRING_ARG) +{ + ONE_FORTSTRING_CREATE(key) + *retval = Util_TableSetPointerToConstArray(*handle, *N_elements, array, key); + free(key); +} +#endif /* UTIL_TABLE_FORTRAN_WRAPPERS */ + +/**************************************/ + int Util_TableSetFPointerArray(int handle, int N_elements, const CCTK_FPOINTER array[], const char *key) @@ -3036,7 +3093,7 @@ void CCTK_FCALL CCTK_FNAME(Util_TableSetComplex32Array) @var value @vtype T *, where T is one of - CCTK_POINTER, CCTK_FPOINTER, + CCTK_POINTER, CCTK_POINTER_TO_CONST, CCTK_FPOINTER, CCTK_CHAR, CCTK_BYTE, CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8, @@ -3112,6 +3169,32 @@ void CCTK_FCALL CCTK_FNAME (Util_TableGetPointer) /**************************************/ +int Util_TableGetPointerToConst(int handle, + CCTK_POINTER_TO_CONST *value, + const char *key) +{ + const int status = Util_TableGetPointerToConstArray(handle, 1, value, key); + return (status == 0) + ? UTIL_ERROR_TABLE_VALUE_IS_EMPTY + : status; +} + +#ifdef UTIL_TABLE_FORTRAN_WRAPPERS +void CCTK_FCALL CCTK_FNAME (Util_TableGetPointerToConst) + (int *retval, const int *handle, + CCTK_POINTER_TO_CONST *value, ONE_FORTSTRING_ARG); +void CCTK_FCALL CCTK_FNAME (Util_TableGetPointerToConst) + (int *retval, const int *handle, + CCTK_POINTER_TO_CONST *value, ONE_FORTSTRING_ARG) +{ + ONE_FORTSTRING_CREATE (key) + *retval = Util_TableGetPointerToConst (*handle, value, key); + free (key); +} +#endif /* UTIL_TABLE_FORTRAN_WRAPPERS */ + +/**************************************/ + int Util_TableGetFPointer(int handle, CCTK_FPOINTER *value, const char *key) { const int status = Util_TableGetFPointerArray(handle, 1, value, key); @@ -3571,7 +3654,7 @@ void CCTK_FCALL CCTK_FNAME (Util_TableGetComplex32) @var array @vtype T[], where T is one of - CCTK_POINTER, CCTK_FPOINTER, + CCTK_POINTER, CCTK_POINTER_TO_CONST, CCTK_FPOINTER, CCTK_CHAR, CCTK_BYTE, CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8, @@ -3655,6 +3738,37 @@ void CCTK_FCALL CCTK_FNAME (Util_TableGetPointerArray) /**************************************/ +int Util_TableGetPointerToConstArray(int handle, + int N_elements, + CCTK_POINTER_TO_CONST array[], + const char *key) +{ + return internal_get(handle, + CCTK_VARIABLE_POINTER_TO_CONST, + N_elements, (void *) array, + key); +} + +#ifdef UTIL_TABLE_FORTRAN_WRAPPERS +void CCTK_FCALL CCTK_FNAME (Util_TableGetPointerToConstArray) + (int *retval, const int *handle, + const int *N_elements, + CCTK_POINTER_TO_CONST array[], + ONE_FORTSTRING_ARG); +void CCTK_FCALL CCTK_FNAME (Util_TableGetPointerToConstArray) + (int *retval, const int *handle, + const int *N_elements, + CCTK_POINTER_TO_CONST array[], + ONE_FORTSTRING_ARG) +{ + ONE_FORTSTRING_CREATE (key) + *retval = Util_TableGetPointerToConstArray(*handle, *N_elements, array, key); + free (key); +} +#endif /* UTIL_TABLE_FORTRAN_WRAPPERS */ + +/**************************************/ + int Util_TableGetFPointerArray(int handle, int N_elements, CCTK_FPOINTER array[], const char *key) @@ -4798,7 +4912,7 @@ int Util_TableItSetToKey(int ihandle, const char *key) @var array @vtype const T[], where T is one of - CCTK_POINTER, CCTK_FPOINTER, + CCTK_POINTER, CCTK_POINTER_TO_CONST, CCTK_FPOINTER, CCTK_CHAR, CCTK_BYTE, CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8, @@ -4917,7 +5031,7 @@ static @var value_buffer @vtype T[], where T is one of - CCTK_POINTER, CCTK_FPOINTER, + CCTK_POINTER, CCTK_POINTER_TO_CONST, CCTK_FPOINTER, CCTK_CHAR, CCTK_BYTE, CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8, @@ -5145,7 +5259,7 @@ static @var array @vtype const T[], where T is one of - CCTK_POINTER, CCTK_FPOINTER, + CCTK_POINTER, CCTK_POINTER_TO_CONST, CCTK_FPOINTER, CCTK_CHAR, CCTK_BYTE, CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8, -- cgit v1.2.3