summaryrefslogtreecommitdiff
path: root/src/include/OverloadMacros.h
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-07-23 12:59:26 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-07-23 12:59:26 +0000
commit17d4b583e0f8cffc5a8c5fe7f112a8406a2b27aa (patch)
tree484320ce026a6d3e20d923aedb413dc8488d6be1 /src/include/OverloadMacros.h
parentaef5b060e4bda34e2d8723bcc072e969d82d3a25 (diff)
Mainly changes to get redirection of stdout to work.
Now the defaults for overloaded functions are setup before anything else, and the the Overloading functions count the number of times they are called and don't allow the thing to be overloaded more than twice - once for the default, and once for people actually wanting to overload it. Redirection now works - output is put into files like CCTK_Proc<x> where x is the process number. Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@773 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/include/OverloadMacros.h')
-rw-r--r--src/include/OverloadMacros.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/include/OverloadMacros.h b/src/include/OverloadMacros.h
index dd09bd2c..72c22583 100644
--- a/src/include/OverloadMacros.h
+++ b/src/include/OverloadMacros.h
@@ -24,16 +24,20 @@
/* This macro defines a global variable with the name of the function
* and a function which allows people to set its value.
+ *
+ * The function can only be called twice - to set the default, and to overload it.
*/
#define OVERLOADABLE_FUNCTION(name) \
RETURN_TYPE (*CCTK_##name)(ARGUMENTS) = NULL; \
int CCTK_Overload##name(RETURN_TYPE (*func)(ARGUMENTS)) \
{ \
int return_code; \
- if(! CCTK_##name) \
+ static int overloaded = 0; \
+ if(overloaded < 2) \
{ \
CCTK_##name = func; \
- return_code = 1; \
+ overloaded++; \
+ return_code = overloaded; \
} \
else \
{ \