summaryrefslogtreecommitdiff
path: root/src/util/Table.c
diff options
context:
space:
mode:
authorschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2005-01-29 18:27:28 +0000
committerschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2005-01-29 18:27:28 +0000
commitf334c541a830cae5833275613fab51f630bcd825 (patch)
tree3e2998fbbf05784a41e98bde40f8a6c54f6e0217 /src/util/Table.c
parent4f4a6c4f93991d738607db809336e536f415aab1 (diff)
Make CCTK_BYTE and CCTK_CHAR be distinct types. CCTK_BYTE is for grid
variables, and CCTK_CHAR (like CCTK_STRING) only for other purposes, e.g. tables. * Introduce unique integer constants for them * Add missing conversion functions from and to strings * Add table functions for CCTK_BYTE. git-svn-id: http://svn.cactuscode.org/flesh/trunk@3972 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/util/Table.c')
-rw-r--r--src/util/Table.c118
1 files changed, 118 insertions, 0 deletions
diff --git a/src/util/Table.c b/src/util/Table.c
index 4dad0ee1..087e2ca8 100644
--- a/src/util/Table.c
+++ b/src/util/Table.c
@@ -2033,6 +2033,7 @@ void CCTK_FCALL CCTK_FNAME(Util_TableGetGenericArray)
@vtype one of
CCTK_POINTER, CCTK_FPOINTER,
CCTK_CHAR,
+ CCTK_BYTE,
CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8,
CCTK_REAL, CCTK_REAL4, CCTK_REAL8, CCTK_REAL16,
CCTK_COMPLEX, CCTK_COMPLEX8, CCTK_COMPLEX16, CCTK_COMPLEX32
@@ -2153,6 +2154,27 @@ int Util_TableSetChar(int handle, CCTK_CHAR value, const char *key)
* integers
*/
+int Util_TableSetByte(int handle, CCTK_BYTE value, const char *key)
+{
+ return Util_TableSetByteArray(handle, 1, &value, key);
+}
+
+#ifdef UTIL_TABLE_FORTRAN_WRAPPERS
+void CCTK_FCALL CCTK_FNAME(Util_TableSetByte)
+ (int *retval, const int *handle,
+ const CCTK_BYTE *value, ONE_FORTSTRING_ARG);
+void CCTK_FCALL CCTK_FNAME(Util_TableSetByte)
+ (int *retval, const int *handle,
+ const CCTK_BYTE *value, ONE_FORTSTRING_ARG)
+{
+ ONE_FORTSTRING_CREATE(key)
+ *retval = Util_TableSetByte(*handle, *value, key);
+ free(key);
+}
+#endif /* UTIL_TABLE_FORTRAN_WRAPPERS */
+
+/**************************************/
+
int Util_TableSetInt(int handle, CCTK_INT value, const char *key)
{
return Util_TableSetIntArray(handle, 1, &value, key);
@@ -2478,6 +2500,7 @@ void CCTK_FCALL CCTK_FNAME(Util_TableSetComplex32)
@vtype const T[], where T is one of
CCTK_POINTER, CCTK_FPOINTER,
CCTK_CHAR,
+ CCTK_BYTE,
CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8,
CCTK_REAL, CCTK_REAL4, CCTK_REAL8, CCTK_REAL16,
CCTK_COMPLEX, CCTK_COMPLEX8, CCTK_COMPLEX16, CCTK_COMPLEX32
@@ -2635,6 +2658,33 @@ void CCTK_FCALL CCTK_FNAME(Util_TableSetCharArray)
* arrays of integers
*/
+int Util_TableSetByteArray(int handle,
+ int N_elements, const CCTK_BYTE array[],
+ const char *key)
+{
+ return internal_set(handle,
+ CCTK_VARIABLE_BYTE, N_elements, (const void *) array,
+ key);
+}
+
+#ifdef UTIL_TABLE_FORTRAN_WRAPPERS
+void CCTK_FCALL CCTK_FNAME(Util_TableSetByteArray)
+ (int *retval, const int *handle,
+ const int *N_elements,
+ const CCTK_BYTE array[], ONE_FORTSTRING_ARG);
+void CCTK_FCALL CCTK_FNAME(Util_TableSetByteArray)
+ (int *retval, const int *handle,
+ const int *N_elements,
+ const CCTK_BYTE array[], ONE_FORTSTRING_ARG)
+{
+ ONE_FORTSTRING_CREATE(key)
+ *retval = Util_TableSetByteArray(*handle, *N_elements, array, key);
+ free(key);
+}
+#endif /* UTIL_TABLE_FORTRAN_WRAPPERS */
+
+/**************************************/
+
int Util_TableSetIntArray(int handle,
int N_elements, const CCTK_INT array[],
const char *key)
@@ -3033,6 +3083,7 @@ void CCTK_FCALL CCTK_FNAME(Util_TableSetComplex32Array)
@vtype T *, where T is one of
CCTK_POINTER, CCTK_FPOINTER,
CCTK_CHAR,
+ CCTK_BYTE,
CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8,
CCTK_REAL, CCTK_REAL4, CCTK_REAL8, CCTK_REAL16,
CCTK_COMPLEX, CCTK_COMPLEX8, CCTK_COMPLEX16, CCTK_COMPLEX32
@@ -3180,6 +3231,30 @@ int Util_TableGetChar(int handle, CCTK_CHAR *value, const char *key)
* integers
*/
+int Util_TableGetByte(int handle, CCTK_BYTE *value, const char *key)
+{
+ const int status = Util_TableGetByteArray(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_TableGetByte)
+ (int *retval, const int *handle,
+ CCTK_BYTE *value, ONE_FORTSTRING_ARG);
+void CCTK_FCALL CCTK_FNAME (Util_TableGetByte)
+ (int *retval, const int *handle,
+ CCTK_BYTE *value, ONE_FORTSTRING_ARG)
+{
+ ONE_FORTSTRING_CREATE (key)
+ *retval = Util_TableGetByte (*handle, value, key);
+ free (key);
+}
+#endif /* UTIL_TABLE_FORTRAN_WRAPPERS */
+
+/**************************************/
+
int Util_TableGetInt(int handle, CCTK_INT *value, const char *key)
{
const int status = Util_TableGetIntArray(handle, 1, value, key);
@@ -3543,6 +3618,7 @@ void CCTK_FCALL CCTK_FNAME (Util_TableGetComplex32)
@vtype T[], where T is one of
CCTK_POINTER, CCTK_FPOINTER,
CCTK_CHAR,
+ CCTK_BYTE,
CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8,
CCTK_REAL, CCTK_REAL4, CCTK_REAL8, CCTK_REAL16,
CCTK_COMPLEX, CCTK_COMPLEX8, CCTK_COMPLEX16, CCTK_COMPLEX32
@@ -3717,6 +3793,33 @@ void CCTK_FCALL CCTK_FNAME (Util_TableGetCharArray)
* arrays of integers
*/
+int Util_TableGetByteArray(int handle,
+ int N_elements, CCTK_BYTE array[],
+ const char *key)
+{
+ return internal_get(handle,
+ CCTK_VARIABLE_BYTE, N_elements, (void *) array,
+ key);
+}
+
+#ifdef UTIL_TABLE_FORTRAN_WRAPPERS
+void CCTK_FCALL CCTK_FNAME (Util_TableGetByteArray)
+ (int *retval, const int *handle,
+ const int *N_elements, CCTK_BYTE array[],
+ ONE_FORTSTRING_ARG);
+void CCTK_FCALL CCTK_FNAME (Util_TableGetByteArray)
+ (int *retval, const int *handle,
+ const int *N_elements, CCTK_BYTE array[],
+ ONE_FORTSTRING_ARG)
+{
+ ONE_FORTSTRING_CREATE (key)
+ *retval = Util_TableGetByteArray (*handle, *N_elements, array, key);
+ free (key);
+}
+#endif /* UTIL_TABLE_FORTRAN_WRAPPERS */
+
+/**************************************/
+
int Util_TableGetIntArray(int handle,
int N_elements, CCTK_INT array[],
const char *key)
@@ -4742,6 +4845,7 @@ int Util_TableItSetToKey(int ihandle, const char *key)
@vtype const T[], where T is one of
CCTK_POINTER, CCTK_FPOINTER,
CCTK_CHAR,
+ CCTK_BYTE,
CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8,
CCTK_REAL, CCTK_REAL4, CCTK_REAL8, CCTK_REAL16,
CCTK_COMPLEX, CCTK_COMPLEX8, CCTK_COMPLEX16, CCTK_COMPLEX32
@@ -4857,6 +4961,7 @@ static
@vtype T[], where T is one of
CCTK_POINTER, CCTK_FPOINTER,
CCTK_CHAR,
+ CCTK_BYTE,
CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8,
CCTK_REAL, CCTK_REAL4, CCTK_REAL8, CCTK_REAL16,
CCTK_COMPLEX, CCTK_COMPLEX8, CCTK_COMPLEX16, CCTK_COMPLEX32
@@ -5082,6 +5187,7 @@ static
@vtype const T[], where T is one of
CCTK_POINTER, CCTK_FPOINTER,
CCTK_CHAR,
+ CCTK_BYTE,
CCTK_INT, CCTK_INT1, CCTK_INT2, CCTK_INT4, CCTK_INT8,
CCTK_REAL, CCTK_REAL4, CCTK_REAL8, CCTK_REAL16,
CCTK_COMPLEX, CCTK_COMPLEX8, CCTK_COMPLEX16, CCTK_COMPLEX32
@@ -5376,6 +5482,16 @@ static
int i;
switch (tep->type_code)
{
+ case CCTK_VARIABLE_BYTE:
+ printf("\t[byte]");
+ {
+ const CCTK_BYTE *const value_ptr_byte = (const CCTK_BYTE *) tep->value;
+ for (i = 0 ; i < tep->N_elements ; ++i)
+ {
+ printf("\t%d", (int) value_ptr_byte[i]);
+ }
+ }
+ break;
case CCTK_VARIABLE_INT:
printf("\t[int]");
{
@@ -5967,6 +6083,8 @@ static
/* integers */
CHECK_SET_GET_INT_ARRAY(handle, CCTK_CHAR, 0,
Util_TableSetCharArray, Util_TableGetCharArray);
+ CHECK_SET_GET_BYTE_ARRAY(handle, CCTK_BYTE, 1,
+ Util_TableSetByteArray, Util_TableGetByteArray);
CHECK_SET_GET_INT_ARRAY(handle, CCTK_INT, 1,
Util_TableSetIntArray, Util_TableGetIntArray);
#ifdef CCTK_INT1