summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2005-08-25 14:18:10 +0000
committerschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2005-08-25 14:18:10 +0000
commit54304e71740f558d3d8258a96bc2f1a7e9634cc9 (patch)
tree13e928c5210cb77435cc2e28d857e4d3c1c69834 /src
parent96615e830e211991fb1fac2704fc9d97fbc26738 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/include/cctk_Constants.h39
-rw-r--r--src/include/util_Table.h16
-rw-r--r--src/main/Groups.c8
-rw-r--r--src/util/Table.c138
4 files changed, 170 insertions, 31 deletions
diff --git a/src/include/cctk_Constants.h b/src/include/cctk_Constants.h
index a07dec1e..89f561ad 100644
--- a/src/include/cctk_Constants.h
+++ b/src/include/cctk_Constants.h
@@ -11,25 +11,26 @@
#ifndef _CCTK_CONSTANTS_H_
#define _CCTK_CONSTANTS_H_
-#define CCTK_VARIABLE_VOID 100
-#define CCTK_VARIABLE_BYTE 101
-#define CCTK_VARIABLE_INT 102
-#define CCTK_VARIABLE_INT1 103
-#define CCTK_VARIABLE_INT2 104
-#define CCTK_VARIABLE_INT4 105
-#define CCTK_VARIABLE_INT8 106
-#define CCTK_VARIABLE_REAL 107
-#define CCTK_VARIABLE_REAL4 108
-#define CCTK_VARIABLE_REAL8 109
-#define CCTK_VARIABLE_REAL16 110
-#define CCTK_VARIABLE_COMPLEX 111
-#define CCTK_VARIABLE_COMPLEX8 112
-#define CCTK_VARIABLE_COMPLEX16 113
-#define CCTK_VARIABLE_COMPLEX32 114
-#define CCTK_VARIABLE_CHAR 115
-#define CCTK_VARIABLE_STRING 116
-#define CCTK_VARIABLE_POINTER 117
-#define CCTK_VARIABLE_FPOINTER 118
+#define CCTK_VARIABLE_VOID 100
+#define CCTK_VARIABLE_BYTE 101
+#define CCTK_VARIABLE_INT 102
+#define CCTK_VARIABLE_INT1 103
+#define CCTK_VARIABLE_INT2 104
+#define CCTK_VARIABLE_INT4 105
+#define CCTK_VARIABLE_INT8 106
+#define CCTK_VARIABLE_REAL 107
+#define CCTK_VARIABLE_REAL4 108
+#define CCTK_VARIABLE_REAL8 109
+#define CCTK_VARIABLE_REAL16 110
+#define CCTK_VARIABLE_COMPLEX 111
+#define CCTK_VARIABLE_COMPLEX8 112
+#define CCTK_VARIABLE_COMPLEX16 113
+#define CCTK_VARIABLE_COMPLEX32 114
+#define CCTK_VARIABLE_CHAR 115
+#define CCTK_VARIABLE_STRING 116
+#define CCTK_VARIABLE_POINTER 117
+#define CCTK_VARIABLE_POINTER_TO_CONST 118
+#define CCTK_VARIABLE_FPOINTER 119
/* DEPRECATED IN BETA 12 */
#define CCTK_VARIABLE_FN_POINTER CCTK_VARIABLE_FPOINTER
diff --git a/src/include/util_Table.h b/src/include/util_Table.h
index db1d0102..b21a44cb 100644
--- a/src/include/util_Table.h
+++ b/src/include/util_Table.h
@@ -178,6 +178,9 @@ int Util_TableGetGenericArray(int handle,
/* pointers */
int Util_TableSetPointer(int handle, CCTK_POINTER value, const char *key);
+int Util_TableSetPointerToConst(int handle,
+ CCTK_POINTER_TO_CONST value,
+ const char *key);
int Util_TableSetFPointer(int handle, CCTK_FPOINTER value, const char *key);
/*
* ... the following function (an alias for the previous one) is for
@@ -234,6 +237,10 @@ int Util_TableSetComplex32(int handle, CCTK_COMPLEX32 value, const char *key);
int Util_TableSetPointerArray(int handle,
int N_elements, const CCTK_POINTER array[],
const char *key);
+int Util_TableSetPointerToConstArray(int handle,
+ int N_elements,
+ const CCTK_POINTER_TO_CONST array[],
+ const char *key);
int Util_TableSetFPointerArray(int handle,
int N_elements, const CCTK_FPOINTER array[],
const char *key);
@@ -327,6 +334,10 @@ int Util_TableSetComplex32Array(int handle,
/* pointers */
int Util_TableGetPointer(int handle, CCTK_POINTER *value, const char *key);
+int Util_TableGetPointerToConst(int handle,
+ CCTK_POINTER_TO_CONST *value,
+ const char *key);
+
int Util_TableGetFPointer(int handle, CCTK_FPOINTER *value, const char *key);
/*
* ... the following function (an alias for the previous one) is for
@@ -383,6 +394,11 @@ int Util_TableGetComplex32(int handle, CCTK_COMPLEX32 *value, const char *key);
int Util_TableGetPointerArray(int handle,
int N_elements, CCTK_POINTER array[],
const char *key);
+int Util_TableGetPointerToConstArray(int handle,
+ int N_elements,
+ CCTK_POINTER_TO_CONST array[],
+ const char *key);
+
int Util_TableGetFPointerArray(int handle,
int N_elements, CCTK_FPOINTER array[],
const char *key);
diff --git a/src/main/Groups.c b/src/main/Groups.c
index 3c6f8419..605215fb 100644
--- a/src/main/Groups.c
+++ b/src/main/Groups.c
@@ -931,6 +931,10 @@ const char *CCTK_VarTypeName (int vtype)
retval = "CCTK_VARIABLE_POINTER";
break;
+ case CCTK_VARIABLE_POINTER_TO_CONST:
+ retval = "CCTK_VARIABLE_POINTER_TO_CONST";
+ break;
+
case CCTK_VARIABLE_FPOINTER:
retval = "CCTK_VARIABLE_FPOINTER";
break;
@@ -1943,6 +1947,10 @@ int CCTK_VarTypeSize (int vtype)
var_size = sizeof (CCTK_POINTER);
break;
+ case CCTK_VARIABLE_POINTER_TO_CONST:
+ var_size = sizeof (CCTK_POINTER_TO_CONST);
+ break;
+
case CCTK_VARIABLE_FPOINTER:
var_size = sizeof (CCTK_FPOINTER);
break;
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,