summaryrefslogtreecommitdiff
path: root/lib/sbin/CreateFunctionBindings.pl
diff options
context:
space:
mode:
authortradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac>2002-03-27 15:34:19 +0000
committertradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac>2002-03-27 15:34:19 +0000
commit489ed36e225fbadf3618d9e338d158750347fa9f (patch)
tree606b59cd9a8da7b83da483f23d54a9fb8a21e53e /lib/sbin/CreateFunctionBindings.pl
parent358c188550d74a47d1fb817de7d9add766720f04 (diff)
Reworked treatment of CCTK_DECLARE macros. Now the C file preprocessor
will put everything up to the closing bracket for a routine into a new block. Also, the USE_CCTK macro is now appended directly to the CCTK_DECLARE macro. There is no need anymore to use CCTK_NO_AUTOUSE_MACRO. Also changed the way how parameters and arguments are used within the USE_CCTK macros: now it's done by "(void) (parameter = 0);" which is better than assigning the address of it to some dummy pointer. This fixes problems where one had to parse for a possible return statement at the end of the routine. This fix closes PR Cactus/949. Also did some perl code optimization and added grdoc headers for files generated by the CST. git-svn-id: http://svn.cactuscode.org/flesh/trunk@2676 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/CreateFunctionBindings.pl')
-rw-r--r--lib/sbin/CreateFunctionBindings.pl1261
1 files changed, 478 insertions, 783 deletions
diff --git a/lib/sbin/CreateFunctionBindings.pl b/lib/sbin/CreateFunctionBindings.pl
index 24f3b825..53923c43 100644
--- a/lib/sbin/CreateFunctionBindings.pl
+++ b/lib/sbin/CreateFunctionBindings.pl
@@ -3,10 +3,10 @@
# @file CreateFunctionBindings.pl
# @date Sat Feb 10 2001
# @author Gabrielle Allen
-# @desc
-#
+# @desc
+#
# @enddesc
-# @version $Id$
+# @version $Id$
#@@*/
@@ -14,15 +14,9 @@
# @routine CreateFunctionBindings
# @date Sat Feb 10 2001
# @author Gabrielle Allen
-# @desc
+# @desc
# Creates bindings for thorn provided functions
-# @enddesc
-# @calls
-# @calledby
-# @history
-#
-# @endhistory
-#
+# @enddesc
#@@*/
sub CreateFunctionBindings
@@ -30,11 +24,14 @@ sub CreateFunctionBindings
my($bindings_dir, $rhinterface_db) = @_;
my($dataout);
my($function_db);
+ my($registerfiles);
-# Create Function Database
+ $registerfiles = 'IsOverloaded.c OverloadThorns.c FortranThornFunctions.c DummyThornFunctions.c RegisterThornFunctions.c';
+
+ # Create Function Database
$function_db = &FunctionDatabase($rhinterface_db);
-# Create directories
+ # Create directories
if(! -d $bindings_dir)
{
mkdir("$bindings_dir", 0755) || die "Unable to create $bindings_dir";
@@ -43,86 +40,65 @@ sub CreateFunctionBindings
chdir $bindings_dir;
- if(! -d "Functions")
+ if(! -d 'Functions')
{
- mkdir("Functions", 0755) || die "Unable to create Functions directory";
+ mkdir('Functions', 0755) || die 'Unable to create Functions directory';
}
- if(! -d "include")
+ if(! -d 'include')
{
- mkdir("include", 0755) || die "Unable to create include directory";
+ mkdir('include', 0755) || die 'Unable to create include directory';
}
-# Create ThornOverloadables.h
- chdir "include";
+ # Create ThornOverloadables.h
$dataout = &ThornOverloadables($function_db);
- &WriteFile("ThornOverloadables.h",\$dataout);
- chdir $bindings_dir;
+ &WriteFile('include/ThornOverloadables.h',\$dataout);
-# Create DummyThornFunctions.c
- chdir "Functions";
+ # Create DummyThornFunctions.c
$dataout = &DummyThornFunctions($function_db);
- &WriteFile("DummyThornFunctions.c",\$dataout);
- chdir $bindings_dir;
+ &WriteFile('Functions/DummyThornFunctions.c',\$dataout);
-# Create OverloadThorns.c
- chdir "Functions";
+ # Create OverloadThorns.c
$dataout = &OverloadThorns();
- &WriteFile("OverloadThorns.c",\$dataout);
- chdir $bindings_dir;
+ &WriteFile('Functions/OverloadThorns.c',\$dataout);
-# Create FortranThornFunctions.c
- chdir "Functions";
+ # Create FortranThornFunctions.c
$dataout = &FortranThornFunctions($function_db);
- &WriteFile("FortranThornFunctions.c",\$dataout);
- chdir $bindings_dir;
+ &WriteFile('Functions/FortranThornFunctions.c',\$dataout);
-# Create Thorn Include Prototypes
- chdir "include";
- foreach $thorn (split(" ",$rhinterface_db->{"THORNS"}))
+ # Create Thorn Include Prototypes
+ foreach $thorn (split(' ',$rhinterface_db->{'THORNS'}))
{
- $filename = $thorn."_Prototypes.h";
$dataout = &ThornIncludes($thorn,$function_db,$rhinterface_db);
- &WriteFile($filename,\$dataout);
+ &WriteFile("include/${thorn}_Prototypes.h",\$dataout);
}
- chdir $bindings_dir;
-# Create Master Include Prototypes
- chdir "include";
- $filename = "cctk_FunctionAliases.h";
+ # Create Master Include Prototypes
$dataout = &ThornMasterIncludes($rhinterface_db);
- &WriteFile($filename,\$dataout);
- chdir $bindings_dir;
+ &WriteFile('include/cctk_FunctionAliases.h',\$dataout);
-# Create THORN_Register.c
- chdir "Functions";
- $registerfiles = "";
- foreach $thorn (split(" ",$rhinterface_db->{"THORNS"}))
+ # Create THORN_Register.c
+ foreach $thorn (split(' ',$rhinterface_db->{'THORNS'}))
{
- $filename = $thorn."_Register.c";
+ $filename = "${thorn}_Register.c";
$dataout = &RegisterThornFunctions($thorn,$function_db,$rhinterface_db);
- &WriteFile($filename,\$dataout);
+ &WriteFile("Functions/$filename",\$dataout);
$registerfiles .= " $filename";
}
- chdir $bindings_dir;
-# Create Master registration file RegisterThornFunctions.c
- chdir "Functions";
+ # Create Master registration file RegisterThornFunctions.c
$dataout = &RegisterAllFunctions($rhinterface_db);
- &WriteFile("RegisterThornFunctions.c",\$dataout);
- chdir $bindings_dir;
+ &WriteFile('Functions/RegisterThornFunctions.c',\$dataout);
-# Create IsOverloaded functions
- chdir "Functions";
+ # Create IsOverloaded functions
$dataout = &IsOverloadedBindings($function_db);
- &WriteFile("IsOverloaded.c",\$dataout);
- chdir $bindings_dir;
+ &WriteFile('Functions/IsOverloaded.c',\$dataout);
+
+ # Create make.code.defn
+ $dataout = "SRCS = $registerfiles";
+ &WriteFile("Functions/make.code.defn",\$dataout);
-# Create make.code.defn
- chdir "Functions";
- $dataout = "\nSRCS = IsOverloaded.c OverloadThorns.c FortranThornFunctions.c DummyThornFunctions.c RegisterThornFunctions.c $registerfiles\n\n";
- &WriteFile("make.code.defn",\$dataout);
chdir $start_dir;
return;
@@ -133,116 +109,78 @@ sub CreateFunctionBindings
# @routine IsOverloadedBindings
# @date Tue Feb 20 2001
# @author Gabrielle Allen
-# @desc
+# @desc
# Code for returning number of times a function has been overloaded.
-# This should be done in a better way, and include flesh overloaded
+# This should be done in a better way, and include flesh overloaded
# functions
-# @enddesc
-# @calls
-# @calledby
-# @history
-#
-# @endhistory
-#
+# @enddesc
#@@*/
sub IsOverloadedBindings
{
my($function_db) = @_;
- my($dataout,$line,@data);
+ my(@data) = ();
# Header Data
- $line = "/*\@\@\n";
- push(@data, $line);
- $line = " \@header IsOverloaded.c\n";
- push(@data, $line);
- $line = " \@desc\n";
- push(@data, $line);
- $line = " Query how many times a function is overloaded\n";
- push(@data, $line);
- $line = " \@enddesc \n";
- push(@data, $line);
- $line = " \@\@*/\n\n";
- push(@data, $line);
-
- $line = "\#include <stdlib.h>\n\n";
- push(@data, $line);
- $line = "\#include \"cctk_Flesh.h\"\n\n";
- push(@data, $line);
- $line = "\#include \"cctk_FortranString.h\"\n\n";
- push(@data, $line);
-
- foreach $function (split(" ",$function_db->{"FUNCTIONS"}))
+ push(@data, '/*@@');
+ push(@data, ' @file IsOverloaded.c');
+ push(@data, ' @author Automatically generated by CreateFunctionBindings.pl');
+ push(@data, ' @desc');
+ push(@data, ' Query how many times a function is overloaded');
+ push(@data, ' @enddesc');
+ push(@data, ' @@*/');
+ push(@data, '');
+ push(@data, '');
+
+ push(@data, '#include <stdlib.h>');
+ push(@data, '');
+ push(@data, '#include "cctk_Flesh.h"');
+ push(@data, '#include "cctk_FortranString.h"');
+ push(@data, '');
+
+ foreach $function (split(' ',$function_db->{'FUNCTIONS'}))
{
if ($function !~ m:^\s*$:)
{
- $line = "int CCTKBindings_Overload$function(void *);\n";
- push(@data, $line);
+ push(@data, "int CCTKBindings_Overload$function(void *);");
}
}
- $line = "int CCTK_IsOverloaded(const char *function);\n";
- push(@data, $line);
-
- $line = "int CCTK_IsOverloaded(const char *function)\n";
- push(@data, $line);
- $line = "{\n";
- push(@data, $line);
- $line = " int retval=0;\n\n";
- push(@data, $line);
- $line = " const char *cctk_dummy_string; /* avoid warnings */\n\n";
- push(@data, $line);
- $line = " cctk_dummy_string=function; /* avoid warnings */\n\n";
- push(@data, $line);
-
- foreach $function (split(" ",$function_db->{"FUNCTIONS"}))
+ push(@data, 'int CCTK_IsOverloaded(const char *function);');
+ push(@data, 'int CCTK_IsOverloaded(const char *function)');
+ push(@data, '{');
+ push(@data, ' int retval = 0;');
+ push(@data, '');
+ push(@data, ' (void) (function + 0); /* avoid warnings */');
+ push(@data, '');
+
+ foreach $function (split(' ',$function_db->{'FUNCTIONS'}))
{
if ($function !~ m:^\s*$:)
{
- $line = " if (strcmp(function,\"$function\")==0)\n";
- push(@data, $line);
- $line = " {\n";
- push(@data, $line);
- $line = " retval = CCTKBindings_Overload$function(NULL);\n";
- push(@data, $line);
- $line = " }\n\n";
- push(@data, $line);
+ push(@data, " if (strcmp(function, \"$function\") == 0)");
+ push(@data, ' {');
+ push(@data, " retval = CCTKBindings_Overload$function(NULL);");
+ push(@data, ' }');
+ push(@data, '');
}
}
- $line = " return retval;\n";
- push(@data, $line);
- $line = "}\n\n\n";
- push(@data, $line);
+ push(@data, ' return retval;');
+ push(@data, '}');
+ push(@data, '');
# Put fortran binding here for the moment
- $line = "void CCTK_FCALL CCTK_FNAME(CCTK_IsOverloaded)\n";
- push(@data, $line);
- $line = " (int *ret, ONE_FORTSTRING_ARG);\n";
- push(@data, $line);
- $line = "void CCTK_FCALL CCTK_FNAME(CCTK_IsOverloaded)\n";
- push(@data, $line);
- $line = " (int *ret, ONE_FORTSTRING_ARG)\n";
- push(@data, $line);
- $line = "{\n";
- push(@data, $line);
- $line = " ONE_FORTSTRING_CREATE(name);\n";
- push(@data, $line);
- $line = " *ret = CCTK_IsOverloaded(name);\n";
- push(@data, $line);
- $line = " free(name);\n";
- push(@data, $line);
- $line = "}\n";
- push(@data, $line);
-
-
- $dataout = "";
- foreach $line (@data)
- {
- $dataout .= $line;
- }
-
- return $dataout;
+ push(@data, 'void CCTK_FCALL CCTK_FNAME(CCTK_IsOverloaded) (int *ret, ONE_FORTSTRING_ARG);');
+ push(@data, 'void CCTK_FCALL CCTK_FNAME(CCTK_IsOverloaded) (int *ret, ONE_FORTSTRING_ARG)');
+ push(@data, '{');
+ push(@data, ' ONE_FORTSTRING_CREATE(name);');
+ push(@data, ' *ret = CCTK_IsOverloaded(name);');
+ push(@data, ' free(name);');
+ push(@data, '}');
+ push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline
+
+ return join ("\n", @data);
}
@@ -250,366 +188,252 @@ sub IsOverloadedBindings
# @routine ThornOverloadables
# @date Sat Feb 10
# @author Gabrielle Allen
-# @desc
+# @desc
# Create include file for thorn function overloads
-# @enddesc
-# @calls
-# @calledby
-# @history
-#
-# @endhistory
-#
+# @enddesc
#@@*/
sub ThornOverloadables
{
my($function_db) = @_;
- my($dataout,$line,@data);
+ my(@data) = ();
# Header Data
- $line = "/*\@\@\n";
- push(@data, $line);
- $line = " \@header ThornOverloadables.h\n";
- push(@data, $line);
- $line = " \@desc\n";
- push(@data, $line);
- $line = " The overloadable functions from thorns\n";
- push(@data, $line);
- $line = " See OverloadMacros.h to see how to use these.\n";
- push(@data, $line);
- $line = " \@enddesc \n";
- push(@data, $line);
- $line = " \@\@*/\n\n";
- push(@data, $line);
- $line = "\#ifdef OVERLOADABLE_CALL\n";
- push(@data, $line);
- $line = "\#undef OVERLOADABLE_CALL\n";
- push(@data, $line);
- $line = "\#endif\n\n";
- push(@data, $line);
- $line = "\#ifdef OVERLOABLE_PREFIX\n";
- push(@data, $line);
- $line = "\#undef OVERLOADABLE_PREFIX\n";
- push(@data, $line);
- $line = "\#endif\n\n";
- push(@data, $line);
- $line = "\#ifdef OVERLOABLE_DUMMY_PREFIX\n";
- push(@data, $line);
- $line = "\#undef OVERLOADABLE_DUMMY_PREFIX\n";
- push(@data, $line);
- $line = "\#endif\n\n";
- push(@data, $line);
- $line = "\#define OVERLOADABLE_CALL CCTKBindings_\n";
- push(@data, $line);
- $line = "\#define OVERLOADABLE_PREFIX\n";
- push(@data, $line);
- $line = "\#define OVERLOADABLE_DUMMY_PREFIX CCTKBindings_Dummy\n\n";
- push(@data, $line);
- $line = "#ifdef ARGUMENTS\n";
- push(@data, $line);
- $line = "#undef ARGUMENTS\n";
- push(@data, $line);
- $line = "#endif\n\n";
- push(@data, $line);
- $line = "#ifdef RETURN_TYPE\n";
- push(@data, $line);
- $line = "#undef RETURN_TYPE\n";
- push(@data, $line);
- $line = "#endif\n\n";
- push(@data, $line);
-
- foreach $function (split(" ",$function_db->{"FUNCTIONS"}))
+ push(@data, '/*@@');
+ push(@data, ' @header ThornOverloadables.h');
+ push(@data, ' @author Automatically generated by CreateFunctionBindings.pl');
+ push(@data, ' @desc');
+ push(@data, ' The overloadable functions from thorns');
+ push(@data, ' See OverloadMacros.h to see how to use these.');
+ push(@data, ' @enddesc');
+ push(@data, ' @@*/');
+ push(@data, '');
+ push(@data, '');
+
+ push(@data, '#ifdef OVERLOADABLE_CALL');
+ push(@data, '#undef OVERLOADABLE_CALL');
+ push(@data, '#endif');
+ push(@data, '');
+ push(@data, '#ifdef OVERLOABLE_PREFIX');
+ push(@data, '#undef OVERLOADABLE_PREFIX');
+ push(@data, '#endif');
+ push(@data, '');
+ push(@data, '#ifdef OVERLOABLE_DUMMY_PREFIX');
+ push(@data, '#undef OVERLOADABLE_DUMMY_PREFIX');
+ push(@data, '#endif');
+ push(@data, '');
+ push(@data, '#define OVERLOADABLE_CALL CCTKBindings_');
+ push(@data, '#define OVERLOADABLE_PREFIX');
+ push(@data, '#define OVERLOADABLE_DUMMY_PREFIX CCTKBindings_Dummy');
+ push(@data, '');
+ push(@data, '#ifdef ARGUMENTS');
+ push(@data, '#undef ARGUMENTS');
+ push(@data, '#endif');
+ push(@data, '');
+ push(@data, '#ifdef RETURN_TYPE');
+ push(@data, '#undef RETURN_TYPE');
+ push(@data, '#endif');
+ push(@data, '');
+
+ foreach $function (split(' ',$function_db->{'FUNCTIONS'}))
{
if ($function !~ m:^\s*$:)
{
- $line = "\#define ARGUMENTS $function_db->{\"$function CARGS\"}\n";
- push(@data, $line);
- $line = "\#define RETURN_TYPE $function_db->{\"$function RET\"}\n\n";
- push(@data,$line);
- $line = "OVERLOADABLE($function)\n\n";
- push(@data,$line);
- $line = "\#undef ARGUMENTS\n";
- push(@data,$line);
- $line = "\#undef RETURN_TYPE\n\n";
- push(@data,$line);
+ push(@data, "#define ARGUMENTS $function_db->{\"$function CARGS\"}");
+ push(@data, "#define RETURN_TYPE $function_db->{\"$function RET\"}");
+ push(@data, '');
+ push(@data, "OVERLOADABLE($function)");
+ push(@data, '');
+ push(@data, '#undef ARGUMENTS');
+ push(@data, '#undef RETURN_TYPE');
+ push(@data, '');
}
}
-
- $line = "#ifdef ARGUMENTS\n";
- push(@data, $line);
- $line = "#undef ARGUMENTS\n";
- push(@data, $line);
- $line = "#endif\n\n";
- push(@data, $line);
- $line = "#ifdef RETURN_TYPE\n";
- push(@data, $line);
- $line = "#undef RETURN_TYPE\n";
- push(@data, $line);
- $line = "#endif\n\n";
- push(@data, $line);
- $line = "\#undef OVERLOADABLE_CALL\n";
- push(@data,$line);
- $line = "\#undef OVERLOADABLE_PREFIX\n";
- push(@data,$line);
- $line = "\#undef OVERLOADABLE_DUMMY_PREFIX\n";
- push(@data,$line);
-
- $dataout = "";
- foreach $line (@data)
- {
- $dataout .= $line;
- }
- return $dataout;
-}
+ push(@data, '#undef OVERLOADABLE_CALL');
+ push(@data, '#undef OVERLOADABLE_PREFIX');
+ push(@data, '#undef OVERLOADABLE_DUMMY_PREFIX');
+ push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline
+ return join ("\n", @data);
+}
#/*@@
# @routine ThornMasterIncludes
# @date Thu Feb 15 2001
# @author Gabrielle Allen
-# @desc
+# @desc
# Master file of function prototypes for each thorn
-# @enddesc
-# @calls
-# @calledby
-# @history
-#
-# @endhistory
-#
+# @enddesc
#@@*/
sub ThornMasterIncludes
{
my($rhinterface_db) = @_;
- my($line,@data,$dataout,$thorn);
+ my(@data);
# Header Data
- $line = "/*\@\@\n";
- push(@data, $line);
- $line = " \@header cctk_FunctionAliases.h\n";
- push(@data, $line);
- $line = " \@desc\n";
- push(@data, $line);
- $line = " Prototypes for overloaded functions used by all thorn\n";
- push(@data, $line);
- $line = " \@enddesc \n";
- push(@data, $line);
- $line = " \@\@*/\n\n";
- push(@data, $line);
- $line = "\#ifndef _CCTK_FUNCTIONALIASES_H_\n";
- push(@data, $line);
- $line = "\#define _CCTK_FUNCTIONALIASES_H_\n\n";
- push(@data, $line);
-
- $line = "\#ifdef CCODE\n";
- push(@data, $line);
- $line = "int CCTK_IsOverloaded(const char *function);\n\n";
- push(@data, $line);
- $line = "\#endif\n\n";
- push(@data, $line);
-
- foreach $thorn (split(" ",$rhinterface_db->{"THORNS"}))
+ push(@data, '/*@@');
+ push(@data, ' @header cctk_FunctionAliases.h');
+ push(@data, ' @author Automatically generated by CreateFunctionBindings.pl');
+ push(@data, ' @desc');
+ push(@data, ' Prototypes for overloaded functions used by all thorns');
+ push(@data, ' @enddesc');
+ push(@data, ' @@*/');
+ push(@data, '');
+ push(@data, '');
+
+ push(@data, '#ifndef _CCTK_FUNCTIONALIASES_H_');
+ push(@data, '#define _CCTK_FUNCTIONALIASES_H_ 1');
+ push(@data, '');
+
+ push(@data, '#ifdef CCODE');
+ push(@data, 'int CCTK_IsOverloaded(const char *function);');
+ push(@data, '');
+ push(@data, '#endif');
+ push(@data, '');
+
+ foreach $thorn (split(' ',$rhinterface_db->{'THORNS'}))
{
- $line = "\#ifdef THORN_IS_$thorn\n";
- push(@data, $line);
- $line = "\#include \"$thorn"."_Prototypes.h\"\n";
- push(@data, $line);
- $line = "\#endif\n\n";
- push(@data, $line);
+ push(@data, "#ifdef THORN_IS_$thorn");
+ push(@data, "#include \"${thorn}_Prototypes.h\"");
+ push(@data, '#endif');
+ push(@data, '');
}
- $line = "\#endif\n\n";
- push(@data, $line);
+ push(@data, '#endif /* _CCTK_FUNCTIONALIASES_H_ */');
+ push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline
- $dataout = "";
- foreach $line (@data)
- {
- $dataout .= $line;
- }
-
- return $dataout;
+ return join ("\n", @data);
}
-
#/*@@
# @routine OverloadThorns
# @date Tue Feb 20 2001
# @author Gabrielle Allen
-# @desc
+# @desc
# Main file for overloading thorns. Note that the text doesn't change
# but the contents does depending on the thorn set used. For this reason
# it is in the bindings and not in the Flesh.
-# @enddesc
-# @calls
-# @calledby
-# @history
-#
-# @endhistory
-#
+# @enddesc
#@@*/
sub OverloadThorns
{
- my($line,@data,$dataout);
+ my(@data) = ();
# Header Data
- $line = "/*\@\@\n";
- push(@data, $line);
- $line = "\@file OverloadThornFunctions.c\n";
- push(@data, $line);
- $line = "\@desc \n";
- push(@data, $line);
- $line = "Contains routines to overload thorn functions\n";
- push(@data, $line);
- $line = "Uses the overload macros to make sure of consistency and\n";
- push(@data, $line);
- $line = "to save typing !\n";
- push(@data, $line);
- $line = "\@enddesc\n";
- push(@data, $line);
- $line = "\@\@*/\n\n";
- push(@data, $line);
-
- $line = "\#include <stdio.h>\n";
- push(@data, $line);
- $line = "\#include <stdlib.h>\n";
- push(@data, $line);
- $line = "\#include <string.h>\n\n";
- push(@data, $line);
-
- $line = "\#include \"cctk_Flesh.h\"\n";
- push(@data, $line);
- $line = "\#include \"cctk_WarnLevel.h\"\n";
- push(@data, $line);
- $line = "\#include \"OverloadMacros.h\"\n\n";
- push(@data, $line);
-
- $line = "/* Define the prototypes for the dummy functions. */\n";
- push(@data, $line);
- $line = "\#define OVERLOADABLE(name) OVERLOADABLE_DUMMYPROTOTYPE(name)\n\n";
- push(@data, $line);
-
- $line = "\#include \"ThornOverloadables.h\"\n\n";
- push(@data, $line);
-
- $line = "\#undef OVERLOADABLE\n\n";
- push(@data, $line);
-
- $line = "\#define OVERLOADABLE(name) OVERLOADABLE_FUNCTION(name)\n\n";
- push(@data, $line);
-
- $line = "\#include \"ThornOverloadables.h\"\n\n";
- push(@data, $line);
-
- $line = "\#undef OVERLOADABLE\n\n";
- push(@data, $line);
-
- $line = "\#undef OVERLOADABLE_CALL\n";
- push(@data, $line);
- $line = "\#undef OVERLOADABLE_PREFIX\n";
- push(@data, $line);
- $line = "\#undef OVERLOADABLE_DUMMY_PREFIX\n\n";
- push(@data, $line);
-
- $line = "/* Initialising Stuff */\n\n";
- push(@data, $line);
-
- $line = "void CCTKBindings_SetupThornFunctions(void);\n";
- push(@data, $line);
- $line = "void CCTKBindings_SetupThornFunctions(void)\n";
- push(@data, $line);
- $line = "{\n";
- push(@data, $line);
- $line = "\#undef OVERLOADABLE\n";
- push(@data, $line);
- $line = "\#define OVERLOADABLE(name) OVERLOADABLE_INITIALISE(name)\n";
- push(@data, $line);
- $line = "\#include \"ThornOverloadables.h\"\n";
- push(@data, $line);
- $line = "#undef OVERLOADABLE\n";
- push(@data, $line);
- $line = "}\n\n";
- push(@data, $line);
-
- $dataout = "";
- foreach $line (@data)
- {
- $dataout .= $line;
- }
-
- return $dataout;
+ push(@data, '/*@@');
+ push(@data, ' @file OverloadThornFunctions.c');
+ push(@data, ' @author Automatically generated by CreateFunctionBindings.pl');
+ push(@data, ' @desc');
+ push(@data, ' Contains routines to overload thorn functions');
+ push(@data, ' Uses the overload macros to make sure of consistency ');
+ push(@data, ' and to save typing !');
+ push(@data, ' @enddesc');
+ push(@data, ' @@*/');
+ push(@data, '');
+ push(@data, '');
+
+ push(@data, '#include <stdio.h>');
+ push(@data, '#include <stdlib.h>');
+ push(@data, '#include <string.h>');
+ push(@data, '');
+
+ push(@data, '#include "cctk_Flesh.h"');
+ push(@data, '#include "cctk_WarnLevel.h"');
+ push(@data, '#include "OverloadMacros.h"');
+ push(@data, '');
+
+ push(@data, '/* Define the prototypes for the dummy functions. */');
+ push(@data, '#define OVERLOADABLE(name) OVERLOADABLE_DUMMYPROTOTYPE(name)');
+ push(@data, '');
+
+ push(@data, '#include "ThornOverloadables.h"');
+ push(@data, '');
+
+ push(@data, '#undef OVERLOADABLE');
+ push(@data, '');
+
+ push(@data, '#define OVERLOADABLE(name) OVERLOADABLE_FUNCTION(name)');
+ push(@data, '');
+
+ push(@data, '#include "ThornOverloadables.h"');
+ push(@data, '');
+
+ push(@data, '#undef OVERLOADABLE');
+ push(@data, '');
+
+ push(@data, '#undef OVERLOADABLE_CALL');
+ push(@data, '#undef OVERLOADABLE_PREFIX');
+ push(@data, '#undef OVERLOADABLE_DUMMY_PREFIX');
+ push(@data, '');
+
+ push(@data, '/* Initialising Stuff */');
+ push(@data, '');
+
+ push(@data, 'void CCTKBindings_SetupThornFunctions(void);');
+ push(@data, 'void CCTKBindings_SetupThornFunctions(void)');
+ push(@data, '{');
+ push(@data, '#undef OVERLOADABLE');
+ push(@data, '#define OVERLOADABLE(name) OVERLOADABLE_INITIALISE(name)');
+ push(@data, '#include "ThornOverloadables.h"');
+ push(@data, '#undef OVERLOADABLE');
+ push(@data, '}');
+ push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline
+
+ return join ("\n", @data);
}
-
#/*@@
# @routine ThornIncludes.h
# @date Thu Feb 15 2001
# @author Gabrielle Allen
-# @desc
+# @desc
# Create function prototypes for each thorn
-# @enddesc
-# @calls
-# @calledby
-# @history
-#
-# @endhistory
-#
+# @enddesc
#@@*/
sub ThornIncludes
{
-
my($thorn,$function_db,$rhinterface_db) = @_;
- my($line,@data,$dataout,$function);
+ my(@data) = ();
# Header Data
- $line = "/*\@\@\n";
- push(@data, $line);
- $line = " \@header $thorn"."_Prototypes.h\n";
- push(@data, $line);
- $line = " \@desc\n";
- push(@data, $line);
- $line = " Prototypes for overloaded functions used by this thorn\n";
- push(@data, $line);
- $line = " \@enddesc \n";
- push(@data, $line);
- $line = " \@\@*/\n\n";
- push(@data, $line);
- $line = "\#ifndef _\U$thorn\E_PROTOTYPES_H_\n";
- push(@data, $line);
- $line = "\#define _\U$thorn\E_PROTOTYPES_H_\n\n";
- push(@data, $line);
-
-
- $line = "\#ifdef CCODE\n";
- push(@data, $line);
-
- foreach $function (split(" ",($rhinterface_db->{"\U$thorn USES FUNCTION\E"})))
+ push(@data, '/*@@');
+ push(@data, " \@header ${thorn}_Prototypes.h");
+ push(@data, ' @author Automatically generated by CreateFunctionBindings.pl');
+ push(@data, ' @desc');
+ push(@data, ' Prototypes for overloaded functions used by this thorn');
+ push(@data, ' @enddesc');
+ push(@data, ' @@*/');
+ push(@data, '');
+ push(@data, '');
+
+ push(@data, "#ifndef _\U$thorn\E_PROTOTYPES_H_");
+ push(@data, "#define _\U$thorn\E_PROTOTYPES_H_ 1");
+ push(@data, '');
+
+ push(@data, '#ifdef CCODE');
+
+ foreach $function (split(' ',($rhinterface_db->{"\U$thorn USES FUNCTION\E"})))
{
if ($function !~ m:^\s*$:)
{
- $line = "extern $function_db->{\"$function RET\"} (*$function)($function_db->{\"$function CARGS\"});\n";
- push(@data, $line);
+ push(@data, "extern $function_db->{\"$function RET\"} (*$function)($function_db->{\"$function CARGS\"});");
}
}
- $line = "\#endif /*CCODE*/\n\n";
- push(@data, $line);
+ push(@data, '#endif /* CCODE */');
+ push(@data, '');
- $line = "\#endif\n\n";
- push(@data, $line);
+ push(@data, '#endif');
+ push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline
- $dataout = "";
- foreach $line (@data)
- {
- $dataout .= $line;
- }
-
- return $dataout;
+ return join ("\n", @data);
}
@@ -617,180 +441,119 @@ sub ThornIncludes
# @routine RegisterAllFunctions
# @date Sun Feb 11 2001
# @author Gabrielle Allen
-# @desc
+# @desc
# Create file to call all thorn function registration
-# @enddesc
-# @calls
-# @calledby
-# @history
-#
-# @endhistory
-#
+# @enddesc
#@@*/
sub RegisterAllFunctions
{
my($rhinterface_db) = @_;
- my($dataout,$line,@data);
-
- $line = "/*\@\@\n";
- push(@data, $line);
- $line = " \@header RegisterAllFunctions.c\n";
- push(@data, $line);
- $line = " \@desc\n";
- push(@data, $line);
- $line = " Register aliased functions from active thorns\n";
- push(@data, $line);
- $line = " \@enddesc \n";
- push(@data, $line);
- $line = " \@returntype int\n";
- push(@data, $line);
- $line = " \@returndesc \n";
- push(@data, $line);
- $line = " Minus number of failed overloads\n";
- push(@data, $line);
- $line = " \@endreturndesc\n";
- push(@data, $line);
- $line = " \@\@*/\n\n";
- push(@data, $line);
- $line = "\#include \"cctk_Flesh.h\"\n";
- push(@data, $line);
- $line = "\#include \"cctk_ActiveThorns.h\"\n\n";
- push(@data, $line);
-
- foreach $thorn (split(" ",$rhinterface_db->{"THORNS"}))
- {
- $line = "int CCTKBindings_".$thorn."Aliases(void);\n";
- push(@data, $line);
- }
- $line = "int CCTKBindings_RegisterThornFunctions(void);\n\n";
- push(@data, $line);
- $line = "int CCTKBindings_RegisterThornFunctions(void)\n";
- push(@data, $line);
- $line = "{\n";
- push(@data, $line);
- $line = " int retval = 0;\n";
- push(@data, $line);
-
- foreach $thorn (split(" ",$rhinterface_db->{"THORNS"}))
+ my(@data) = ();
+
+ push(@data, '/*@@');
+ push(@data, ' @file RegisterAllFunctions.c');
+ push(@data, ' @author Automatically generated by CreateFunctionBindings.pl');
+ push(@data, ' @desc');
+ push(@data, ' Register aliased functions from active thorns');
+ push(@data, ' @enddesc');
+ push(@data, ' @@*/');
+ push(@data, '');
+ push(@data, '');
+
+ push(@data, '#include "cctk_Flesh.h"');
+ push(@data, '#include "cctk_ActiveThorns.h"');
+ push(@data, '');
+
+ foreach $thorn (split(' ',$rhinterface_db->{'THORNS'}))
{
- $line = " if (CCTK_IsThornActive(\"$thorn\"))\n";
- push(@data, $line);
- $line = " {\n";
- push(@data, $line);
- $line = " retval =+ CCTKBindings_".$thorn."Aliases();\n";
- push(@data, $line);
- $line = " }\n";
- push(@data, $line);
+ push(@data, "int CCTKBindings_${thorn}Aliases(void);");
}
- $line = " return retval;\n";
- push(@data, $line);
- $line = "}\n";
- push(@data, $line);
- $dataout = "";
- foreach $line (@data)
+ push(@data, 'int CCTKBindings_RegisterThornFunctions(void);');
+ push(@data, 'int CCTKBindings_RegisterThornFunctions(void)');
+ push(@data, '{');
+ push(@data, ' int retval = 0;');
+
+ foreach $thorn (split(' ',$rhinterface_db->{'THORNS'}))
{
- $dataout .= $line;
+ push(@data, " if (CCTK_IsThornActive(\"$thorn\"))");
+ push(@data, ' {');
+ push(@data, " retval += CCTKBindings_${thorn}Aliases();");
+ push(@data, ' }');
}
+ push(@data, ' return retval;');
+ push(@data, '}');
+ push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline
- return $dataout;
-
+ return join ("\n", @data);
}
+
#/*@@
# @routine DummyThornFunctions
# @date Sat Feb 10
# @author Gabrielle Allen
-# @desc
+# @desc
# Check contents for ThornOverloadables_h
-# @enddesc
-# @calls
-# @calledby
-# @history
-#
-# @endhistory
-#
+# @enddesc
#@@*/
sub DummyThornFunctions
{
my($function_db) = @_;
- my($dataout,$line,@data);
+ my(@data) = ();
# Header Data
- $line = "/*\@\@\n";
- push(@data, $line);
- $line = " \@header DummyThornFunctions.h\n";
- push(@data, $line);
- $line = " \@desc\n";
- push(@data, $line);
- $line = " Dummy functions for overloaded thorn functions\n";
- push(@data, $line);
- $line = " \@enddesc \n";
- push(@data, $line);
- $line = " \@\@*/\n\n";
- push(@data, $line);
- $line = "\#include <stdlib.h>\n\n";
- push(@data, $line);
- $line = "\#include \"cctk_Flesh.h\"\n";
- push(@data, $line);
- $line = "\#include \"cctk_WarnLevel.h\"\n\n";
- push(@data, $line);
-
- foreach $function (split(" ",$function_db->{"FUNCTIONS"}))
+ push(@data, '/*@@');
+ push(@data, ' @header DummyThornFunctions.h');
+ push(@data, ' @author Automatically generated by CreateFunctionBindings.pl');
+ push(@data, ' @desc');
+ push(@data, ' Dummy functions for overloaded thorn functions');
+ push(@data, ' @enddesc');
+ push(@data, ' @@*/');
+ push(@data, '');
+ push(@data, '');
+
+ push(@data, '#include <stdlib.h>');
+ push(@data, '');
+ push(@data, '#include "cctk_Flesh.h"');
+ push(@data, '#include "cctk_WarnLevel.h"');
+ push(@data, '');
+
+ foreach $function (split(' ',$function_db->{'FUNCTIONS'}))
{
if ($function !~ m:^\s*$:)
- {
- $ret = $function_db->{"$function RET"};
-
- $line = "$ret CCTKBindings_Dummy$function($function_db->{\"$function CARGS\"});\n";
- push(@data, $line);
- $line = "$ret CCTKBindings_Dummy$function($function_db->{\"$function CARGS\"})\n";
- push(@data, $line);
- $line = "{\n";
- push(@data, $line);
-
- # Make sure we use all arguments to avoid warnings
- $line = " const void *cctk_dummy_pointer;\n";
- push(@data, $line);
- $line = " cctk_dummy_pointer = cctk_dummy_pointer;\n";
- push(@data, $line);
- foreach $arg (split(",",$function_db->{"$function CARGS"}))
- {
- $arg =~ m:(.*\s+\**)([^\s*\*]+)\s*:;
-# $type=$1;
- $name=$2;
- $line = " cctk_dummy_pointer = \&$name;\n";
- push(@data, $line);
- }
- $line = " CCTK_Warn(1,__LINE__,__FILE__,\"Bindings\",\n";
- push(@data, $line);
- $line = " \"CCTKBindings_Dummy$function: Calling thorn function $function which has not been overloaded\");\n";
- push(@data, $line);
- if ($ret =~ m:INT:i)
- {
- $line = "return -1;";
- push(@data, $line);
- }
- elsif ($ret =~ m:REAL:i)
- {
- $line = "return 0;";
- push(@data, $line);
- }
- $line = "}\n\n";
- push(@data, $line);
- }
- }
+ {
+ $ret = $function_db->{"$function RET"};
- $dataout = "";
- foreach $line (@data)
- {
- $dataout .= $line;
+ push(@data, "$ret CCTKBindings_Dummy$function($function_db->{\"$function CARGS\"});");
+ push(@data, "$ret CCTKBindings_Dummy$function($function_db->{\"$function CARGS\"})");
+ push(@data, '{');
+
+ # Make sure we use all arguments to avoid warnings
+ foreach $arg (split(',',$function_db->{"$function CARGS"}))
+ {
+ $arg =~ m:.*\s+\**([^\s*\*]+)\s*:;
+ push(@data, " (void) ($1 + 0)");
+ }
+ push(@data, ' CCTK_Warn(1, __LINE__, __FILE__, "Bindings",');
+ push(@data, " \"CCTKBindings_Dummy$function: Calling thorn function $function which has not been overloaded\");");
+ if ($ret =~ m:INT:i)
+ {
+ push(@data, ' return -1;');
+ }
+ elsif ($ret =~ m:REAL:i)
+ {
+ push(@data, ' return 0;');
+ }
+ push(@data, '}');
+ push(@data, '');
+ }
}
+ push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline
- return $dataout;
-
+ return join ("\n", @data);
}
@@ -798,39 +561,31 @@ sub DummyThornFunctions
# @routine RegisterThornFunctions
# @date Sun Feb 11 2001
# @author Gabrielle Allen
-# @desc
+# @desc
# Create contents for files to register aliased functions
-# @enddesc
-# @calls
-# @calledby
-# @history
-#
-# @endhistory
-#
+# @enddesc
#@@*/
sub RegisterThornFunctions
{
my($thorn,$function_db,$rhinterface_db) = @_;
- my($dataout,$line,@data,$function);
+ my(@data) = ();
# Header Data
- $line = "/*\@\@\n";
- push(@data, $line);
- $line = " \@header $thorn"."_Register.h\n";
- push(@data, $line);
- $line = " \@desc\n";
- push(@data, $line);
- $line = " Register aliased functions for $thorn\n";
- push(@data, $line);
- $line = " \@enddesc \n";
- push(@data, $line);
- $line = " \@\@*/\n\n";
- push(@data, $line);
- $line = "\#include \"cctk_Flesh.h\"\n";
- push(@data, $line);
-
- foreach $function (split(" ",$rhinterface_db->{"\U$thorn PROVIDES FUNCTION\E"}))
+ push(@data, '/*@@');
+ push(@data, " \@header ${thorn}_Register.h");
+ push(@data, ' @author Automatically generated by CreateFunctionBindings.pl');
+ push(@data, ' @desc');
+ push(@data, " Register aliased functions for $thorn");
+ push(@data, ' @enddesc');
+ push(@data, ' @@*/');
+ push(@data, '');
+ push(@data, '');
+
+ push(@data, '#include "cctk_Flesh.h"');
+ push(@data, '');
+
+ foreach $function (split(' ',$rhinterface_db->{"\U$thorn PROVIDES FUNCTION\E"}))
{
if ($function !~ m:^\s*$:)
{
@@ -838,53 +593,34 @@ sub RegisterThornFunctions
$ret = $function_db->{"$function RET"};
$args = $function_db->{"$function CARGS"};
- $line = "$ret $provided_with($args);\n";
- push(@data, $line);
- $line = "int CCTKBindings_Overload$function($ret (* $function)($args));\n";
- push(@data, $line);
+ push(@data, "$ret $provided_with($args);");
+ push(@data, "int CCTKBindings_Overload$function($ret (* $function)($args));");
}
}
- $line = "\n";
- push(@data, $line);
- $line = "int CCTKBindings_".$thorn."Aliases(void);\n";
- push(@data, $line);
- $line = "\n";
- push(@data, $line);
- $line = "int CCTKBindings_".$thorn."Aliases(void)\n";
- push(@data, $line);
- $line = "{\n";
- push(@data, $line);
- $line = " int retval=0; /* returns minus number of failed overloads */\n";
- push(@data, $line);
- $line = " int ierr=0;\n\n";
- push(@data, $line);
- $line = " retval = ierr; /* use ierr to prevent warnings */\n\n";
- push(@data, $line);
-
-
- foreach $function (split(" ",$rhinterface_db->{"\U$thorn PROVIDES FUNCTION\E"}))
+ push(@data, '');
+ push(@data, "int CCTKBindings_${thorn}Aliases(void);");
+ push(@data, "int CCTKBindings_${thorn}Aliases(void)");
+ push(@data, '{');
+ push(@data, ' int retval = 0; /* returns minus number of failed overloads */');
+ push(@data, ' int ierr = 0;');
+ push(@data, '');
+ push(@data, ' retval = ierr; /* use ierr to prevent warnings */');
+ push(@data, '');
+
+ foreach $function (split(' ',$rhinterface_db->{"\U$thorn PROVIDES FUNCTION\E"}))
{
if ($function !~ m:^\s*$:)
{
- $line = " ierr = CCTKBindings_Overload$function($rhinterface_db->{\"\U$thorn PROVIDES FUNCTION\E $function WITH\"});\n";
- push(@data, $line);
- $line = " retval = (ierr == 0) ? retval-- : retval;\n";
- push(@data, $line);
+ push(@data, " ierr = CCTKBindings_Overload$function($rhinterface_db->{\"\U$thorn PROVIDES FUNCTION\E $function WITH\"});");
+ push(@data, ' retval = (ierr == 0) ? retval-- : retval;');
}
}
-
- $line = " return retval;\n";
- push(@data, $line);
- $line = "}\n";
- push(@data, $line);
-
- $dataout = "";
- foreach $line (@data)
- {
- $dataout .= $line;
- }
- return ($dataout);
+ push(@data, ' return retval;');
+ push(@data, '}');
+ push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline
+
+ return join ("\n", @data);
}
@@ -892,184 +628,148 @@ sub RegisterThornFunctions
# @routine FortranThornFunctions
# @date Sat Feb 10 2001
# @author Gabrielle Allen
-# @desc
+# @desc
# Create fortran wrappers for thorn functions
-# @enddesc
-# @calls
-# @calledby
-# @history
-#
-# @endhistory
-#
+# @enddesc
#@@*/
sub FortranThornFunctions
{
my($function_db) = @_;
- my($dataout,$line,@data,$function);
+ my(@data) = ();
# Header Data
- $line = "/*\@\@\n";
- push(@data, $line);
- $line = " \@header FortranThornFunctions.h\n";
- push(@data, $line);
- $line = " \@desc\n";
- push(@data, $line);
- $line = " Fortran wrappers for overloaded thorn functions\n";
- push(@data, $line);
- $line = " \@enddesc \n";
- push(@data, $line);
- $line = " \@\@*/\n\n";
- push(@data, $line);
- $line = "\#include <stdlib.h>\n\n";
- push(@data, $line);
- $line = "\#include \"cctk_Flesh.h\"\n";
- push(@data, $line);
- $line = "\#include \"cctk_WarnLevel.h\"\n\n";
- push(@data, $line);
- $line = "\#include \"cctk_FortranString.h\"\n\n";
- push(@data, $line);
+ push(@data, '/*@@');
+ push(@data, ' @header FortranThornFunctions.h');
+ push(@data, ' @author Automatically generated by CreateFunctionBindings.pl');
+ push(@data, ' @desc');
+ push(@data, ' Fortran wrappers for overloaded thorn functions');
+ push(@data, ' @enddesc');
+ push(@data, ' @@*/');
+ push(@data, '');
+ push(@data, '');
+
+ push(@data, '#include <stdlib.h>');
+ push(@data, '');
+ push(@data, '#include "cctk_Flesh.h"');
+ push(@data, '#include "cctk_WarnLevel.h"');
+ push(@data, '#include "cctk_FortranString.h"');
+ push(@data, '');
# Do aliased function prototypes
- foreach $function (split(" ",$function_db->{"FUNCTIONS"}))
+ foreach $function (split(' ',$function_db->{'FUNCTIONS'}))
{
if ($function !~ m:^\s*$:)
{
- $line = "extern $function_db->{\"$function RET\"} (*$function)($function_db->{\"$function CARGS\"});\n";
- push(@data, $line);
+ push(@data, "extern $function_db->{\"$function RET\"} (*$function)($function_db->{\"$function CARGS\"});");
}
}
- $line = "\n\n";
- push(@data, $line);
+ push(@data, '');
+ push(@data, '');
-
- foreach $function (split(" ",$function_db->{"FUNCTIONS"}))
+ foreach $function (split(' ',$function_db->{'FUNCTIONS'}))
{
if ($function !~ m:^\s*$:)
{
- $line = "$function_db->{\"$function RET\"} CCTK_FCALL CCTK_FNAME($function)\n";
- $line .= "($function_db->{\"$function WARGS\"}";
+ push(@data, "$function_db->{\"$function RET\"} CCTK_FCALL CCTK_FNAME($function)");
+ $line = "($function_db->{\"$function WARGS\"}";
if ($function_db->{"$function STRINGS"} == 1)
{
- $line .= ", ONE_FORTSTRING_ARG";
+ $line .= ', ONE_FORTSTRING_ARG';
}
elsif ($function_db->{"$function STRINGS"} == 2)
{
- $line .= ", TWO_FORTSTRINGS_ARGS";
+ $line .= ', TWO_FORTSTRINGS_ARGS';
}
elsif ($function_db->{"$function STRINGS"} == 3)
{
- $line .= ", THREE_FORTSTRINGS_ARGS";
+ $line .= ', THREE_FORTSTRINGS_ARGS';
}
-
- $line .= ")";
+ $line .= ')';
# prototype
- push(@data, "$line;\n");
+ push(@data, "$line;");
# call
- push(@data, "$line\n");
- $line = "{\n";
push(@data, $line);
+ push(@data, '{');
- if ($function_db->{"$function TYPE"} =~ "FUNC")
+ if ($function_db->{"$function TYPE"} =~ 'FUNC')
{
- $line = " $function_db->{\"$function RET\"} cctki_retval;\n";
- push(@data, $line);
+ push(@data, " $function_db->{\"$function RET\"} cctki_retval;");
}
if ($function_db->{"$function STRINGS"} == 1)
{
- $line = "ONE_FORTSTRING_CREATE(cctki_string1)\n";
- push(@data, $line);
+ push(@data, 'ONE_FORTSTRING_CREATE(cctki_string1)');
}
elsif ($function_db->{"$function STRINGS"} == 2)
{
- $line = "TWO_FORTSTRINGS_CREATE(cctki_string1,cctki_string2)\n";
- push(@data, $line);
+ push(@data, 'TWO_FORTSTRINGS_CREATE(cctki_string1, cctki_string2)');
}
elsif ($function_db->{"$function STRINGS"} == 3)
{
- $line = "THREE_FORTSTRINGS_CREATE(cctki_string1,cctki_string2,cctki_string3)\n";
- push(@data, $line);
+ push(@data, 'THREE_FORTSTRINGS_CREATE(cctki_string1, cctki_string2, cctki_string3)');
}
- if ($function_db->{"$function TYPE"} =~ "FUNC")
+ if ($function_db->{"$function TYPE"} =~ 'FUNC')
{
- $line = " cctki_retval = \n";
- push(@data, $line);
+ push(@data, ' cctki_retval = ');
}
- $line = " $function($function_db->{\"$function WCALL\"}";
- push(@data, $line);
+ push(@data, " $function($function_db->{\"$function WCALL\"}");
if ($function_db->{"$function STRINGS"} == 1)
{
- $line = ", cctki_string1";
- push(@data, $line);
+ push(@data, ', cctki_string1');
}
elsif ($function_db->{"$function STRINGS"} == 2)
{
- $line = ", cctki_string1, cctki_string2";
- push(@data, $line);
+ push(@data, ', cctki_string1, cctki_string2');
}
elsif ($function_db->{"$function STRINGS"} == 3)
{
- $line = ", cctki_string1, cctki_string2, cctki_string3";
- push(@data, $line);
+ push(@data, ', cctki_string1, cctki_string2, cctki_string3');
}
- $line = ");\n";
- push(@data, $line);
+ push(@data, ');');
if ($function_db->{"$function STRINGS"} == 1)
{
- $line = " free(cctki_string1);\n";
- push(@data, $line);
+ push(@data, ' free(cctki_string1);');
}
elsif ($function_db->{"$function STRINGS"} == 2)
{
- $line = " free(cctki_string1);\n free(cctki_string2);\n";
- push(@data, $line);
+ push(@data, ' free(cctki_string1);');
+ push(@data, ' free(cctki_string2);');
}
elsif ($function_db->{"$function STRINGS"} == 3)
{
- $line = " free(cctki_string1);\n free(cctki_string2);\n free(cctki_string3);\n";
- push(@data, $line);
+ push(@data, ' free(cctki_string1);');
+ push(@data, ' free(cctki_string2);');
+ push(@data, ' free(cctki_string3);');
}
- if ($function_db->{"$function TYPE"} =~ "FUNC")
+ if ($function_db->{"$function TYPE"} =~ 'FUNC')
{
- $line = " return cctki_retval; \n";
- push(@data, $line);
+ push(@data, ' return cctki_retval;');
}
- $line = "}\n";
- push(@data, $line);
+ push(@data, '}');
}
}
+ push(@data, "\n"); # workaround for perl 5.004_04 to add a trailing newline
- $dataout = "";
- foreach $line (@data)
- {
- $dataout .= $line;
- }
-
- return $dataout;
+ return join ("\n", @data);
}
+
#/*@@
# @routine FunctionDatabase
# @date Wed Dec 06 11.37
# @author Gabrielle Allen
-# @desc
+# @desc
# Check consistency for Thorn Functions and create database
-# @enddesc
-# @calls
-# @calledby
-# @history
-#
-# @endhistory
-#
+# @enddesc
#@@*/
sub FunctionDatabase
@@ -1077,73 +777,73 @@ sub FunctionDatabase
my($rhinterface_db) = @_;
my($thorn,$inret,$inargs,$message,$function);
- $function_db->{"FUNCTIONS"}= " ";
- $function_db->{"PROVIDED FUNCTIONS"}= " ";
+ $function_db->{'FUNCTIONS'}= ' ';
+ $function_db->{'PROVIDED FUNCTIONS'}= ' ';
# Add used functions to database
- foreach $thorn (split(" ",$rhinterface_db->{"THORNS"}))
+ foreach $thorn (split(' ',$rhinterface_db->{'THORNS'}))
{
- foreach $function (split(" ",($rhinterface_db->{"\U$thorn USES FUNCTION\E"})))
+ foreach $function (split(' ',($rhinterface_db->{"\U$thorn USES FUNCTION\E"})))
{
$inargs = $rhinterface_db->{"\U$thorn FUNCTION\E $function ARGS"};
$inret = $rhinterface_db->{"\U$thorn FUNCTION\E $function RET"};
($nstrings,$types,$c,$fortran,$wrappercall,$wrapperargs,$cargs) = &ParseArguments($inret,$inargs);
- if ($function_db->{"FUNCTIONS"} =~ / $function / && $function !~ /^\s*$/)
+ if ($function_db->{'FUNCTIONS'} =~ / $function / && $function !~ /^\s*$/)
{
if ($types ne $function_db->{"$function TYPES"})
{
$message = "Argument types for aliased $function do not match";
- &CST_error(0,$message,"",__LINE__,__FILE__);
+ &CST_error(0,$message,'',__LINE__,__FILE__);
}
if ($inret ne $function_db->{"$function RET"})
{
$message = "Return types for aliased $function do not match";
- &CST_error(0,$message,"",__LINE__,__FILE__);
+ &CST_error(0,$message,'',__LINE__,__FILE__);
}
}
else
{
if ($inret =~ m:^\s*void\s*$:)
{
- $function_db->{"$function CARGS"} = "SUB";
+ $function_db->{"$function CARGS"} = 'SUB';
}
else
{
- $function_db->{"$function CARGS"} = "FUNC";
+ $function_db->{"$function CARGS"} = 'FUNC';
}
if ($c)
{
if ($fortran)
{
- $function_db->{"$function LANG"} = "FC";
+ $function_db->{"$function LANG"} = 'FC';
}
else
{
- $function_db->{"$function LANG"} = "C";
+ $function_db->{"$function LANG"} = 'C';
$message = "Fortran wrapper not created for alias $function";
- &CST_error(1,$message,"",__LINE__,__FILE__);
+ &CST_error(1,$message,'',__LINE__,__FILE__);
}
}
else
{
- $function_db->{"$function LANG"} = "";
+ $function_db->{"$function LANG"} = '';
$message = "Can't create alias for $function";
- &CST_error(0,$message,"",__LINE__,__FILE__);
- }
+ &CST_error(0,$message,'',__LINE__,__FILE__);
+ }
- if ($rhinterface_db->{"\U$thorn FUNCTION\E $function RET"} eq "void")
+ if ($rhinterface_db->{"\U$thorn FUNCTION\E $function RET"} eq 'void')
{
- $function_db->{"$function TYPE"} = "SUB";
+ $function_db->{"$function TYPE"} = 'SUB';
}
else
{
- $function_db->{"$function TYPE"} = "FUNC";
+ $function_db->{"$function TYPE"} = 'FUNC';
}
- $function_db->{"FUNCTIONS"} .= "$function ";
+ $function_db->{'FUNCTIONS'} .= "$function ";
$function_db->{"$function STRINGS"} = $nstrings;
$function_db->{"$function CARGS"} = $cargs;
$function_db->{"$function TYPES"} = $types;
@@ -1155,58 +855,53 @@ sub FunctionDatabase
}
# Check consistency of providing functions
- foreach $thorn (split(" ",$rhinterface_db->{"THORNS"}))
+ foreach $thorn (split(' ',$rhinterface_db->{'THORNS'}))
{
- foreach $function (split(" ",($rhinterface_db->{"\U$thorn PROVIDES FUNCTION\E"})))
+ foreach $function (split(' ',($rhinterface_db->{"\U$thorn PROVIDES FUNCTION\E"})))
{
$inargs = $rhinterface_db->{"\U$thorn FUNCTION\E $function ARGS"};
$inret = $rhinterface_db->{"\U$thorn FUNCTION\E $function RET"};
($nstrings,$types,$c,$fortran,$wrappercall,$wrapperargs,$cargs) = &ParseArguments($inret,$inargs);
- if ($function_db->{"FUNCTIONS"} =~ / $function / && $function !~ /^\s*$/)
+ if ($function_db->{'FUNCTIONS'} =~ / $function / && $function !~ /^\s*$/)
{
if ($types ne $function_db->{"$function TYPES"})
{
$message = "Argument types for aliased $function do not match";
- &CST_error(0,$message,"",__LINE__,__FILE__);
+ &CST_error(0,$message,'',__LINE__,__FILE__);
}
if ($inret ne $function_db->{"$function RET"})
{
$message = "Return types for aliased $function do not match";
- &CST_error(0,$message,"",__LINE__,__FILE__);
+ &CST_error(0,$message,'',__LINE__,__FILE__);
}
}
- $function_db->{"PROVIDED FUNCTIONS"} .= "$function ";
+ $function_db->{'PROVIDED FUNCTIONS'} .= "$function ";
}
}
# Check to see if any functions are potentially used and not provided
- foreach $function (split(" ",($function_db->{"FUNCTIONS"})))
+ foreach $function (split(' ',($function_db->{'FUNCTIONS'})))
{
- if ($function_db->{"PROVIDED FUNCTIONS"} !~ / $function /)
+ if ($function_db->{'PROVIDED FUNCTIONS'} !~ / $function /)
{
$message = "Aliased function $function is not provided by any thorn";
- &CST_error(1,$message,"",__LINE__,__FILE__);
+ &CST_error(1,$message,'',__LINE__,__FILE__);
}
}
return $function_db;
}
+
#/*@@
# @routine ParseArguments
# @date Sun Feb 11 2001
# @author Gabrielle Allen
-# @desc
+# @desc
# Parse the argument list and create versions for C and Fortran
-# @enddesc
-# @calls
-# @calledby
-# @history
-#
-# @endhistory
-#
+# @enddesc
#@@*/
sub ParseArguments
@@ -1218,11 +913,11 @@ sub ParseArguments
# print "=================\n";
# print "All args: $args\n";
- $fwrapperargs = "";
- $fwrappercallargs = "";
- $ccallargs = "";
- $types = "";
- $number_args = split(",",$args);
+ $fwrapperargs = '';
+ $fwrappercallargs = '';
+ $ccallargs = '';
+ $types = '';
+ $number_args = split(',',$args);
# Need to count strings for fortran wrappers
$number_strings = 0;
@@ -1232,7 +927,7 @@ sub ParseArguments
# Will be set to zero if can't add the aliased C function
$c = 1;
- foreach $arg (split(",",$args))
+ foreach $arg (split(',',$args))
{
# print " Arg is $arg\n";
@@ -1252,7 +947,7 @@ sub ParseArguments
# print " Type is $type\n";
# treat string differently
-
+
if ($type =~ m/CCTK_STRING/)
{
$number_strings++;
@@ -1283,7 +978,7 @@ sub ParseArguments
$fortran = 0;
$c = 0;
$message = "Error parsing aliased function argument $arg";
- &CST_error(1,$message,"",__LINE__,__FILE__);
+ &CST_error(1,$message,'',__LINE__,__FILE__);
}
}