diff options
author | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-01-21 11:12:23 +0000 |
---|---|---|
committer | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-01-21 11:12:23 +0000 |
commit | 81b3057b07e225171a91d180ac3259d78749fc81 (patch) | |
tree | 41efd31cc39b1b3817cbd6f00910d184fe6eec2c /lib/sbin/create_c_stuff.pl | |
parent | 85477596402e451bbd9b484cf82b2d42636f0128 (diff) |
Changed to call the new functions in Misc.c, rather than to write loads
of similar code.
Tom
git-svn-id: http://svn.cactuscode.org/flesh/trunk@99 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/create_c_stuff.pl')
-rw-r--r-- | lib/sbin/create_c_stuff.pl | 71 |
1 files changed, 12 insertions, 59 deletions
diff --git a/lib/sbin/create_c_stuff.pl b/lib/sbin/create_c_stuff.pl index 202debf5..75c8fd4c 100644 --- a/lib/sbin/create_c_stuff.pl +++ b/lib/sbin/create_c_stuff.pl @@ -84,6 +84,7 @@ sub CreateParameterBindingFile } + push(@data, " return 0;"); push(@data, "}"); push(@data, ""); @@ -91,8 +92,6 @@ sub CreateParameterBindingFile # Setting subroutine push(@data, ("int $prefix"."Set(const char *param, const char *value)", "{")); - push(@data, (" char temp[1001];", " int p;", "")); - push(@data, (" int retval;", " retval = 1;", "")); @@ -146,20 +145,15 @@ sub set_parameter_code { if( $type eq "KEYWORD") { - $line = " if(CCTK_InList(value, $n_ranges" ; + $line = " retval = CCTK_SetKeywordInRangeList(\&($structure.$parameter), value, $n_ranges" ; } elsif($type eq "INTEGER") { - $line = " if(CCTK_IntInRangeList(atoi(value), $n_ranges" ; + $line = " retval = CCTK_SetIntInRangeList(\&($structure.$parameter),value, $n_ranges" ; } elsif($type eq "REAL") { - $line = " strncpy(temp, value, 1000);"; - push(@lines, $line); - - $line = " for (p=0;p<strlen(temp);p++) if (temp[p] == 'E' || temp[p] == 'd' || temp[p] == 'D') temp[p] = 'e';"; - push(@lines, $line); - $line = " if(CCTK_DoubleInRangeList(atof(temp), $n_ranges" ; + $line = " retval = CCTK_SetDoubleInRangeList(\&($structure.$parameter),value, $n_ranges" ; } for($range=1; $range <= $n_ranges; $range++) { @@ -170,65 +164,24 @@ sub set_parameter_code $line .= ",\"".$quoted_range."\""; } - $line .= "))"; - - push(@lines, ($line, " {")); - - if( $type eq "KEYWORD") - { - $line = " if($structure.$parameter) free($structure.$parameter);"; - push(@lines, $line); - - $line = " $structure" .".$parameter = malloc(strlen(value)\*sizeof(char));"; - push(@lines, $line); - - $line = " if($structure.$parameter)"; - push(@lines, $line); - - $line = " strcpy($structure.$parameter, value);"; - push(@lines, ($line, " retval = 0;", " }")); - - } - elsif($type eq "INTEGER") - { - $line = " $structure.$parameter = atoi(value);" ; - push(@lines, ($line, " retval = 0;", " }")); - } - elsif($type eq "REAL") - { - push(@lines, " $structure.$parameter = atof(temp); "); - - push(@lines, ($line, " retval = 0;", " }")); - - } - - push(@lines, " }"); - + $line .= ");"; } - elsif( $type eq "STRING" || $type eq "SENTENCE") + elsif( $type eq "KEYWORD") { - $line = " if($structure.$parameter) free($structure.$parameter);"; - push(@lines, $line); - - $line = " $structure" .".$parameter = malloc(strlen(value)\*sizeof(char));"; - push(@lines, $line); - - $line = " if($structure.$parameter)"; - push(@lines, $line); - - $line = " strcpy($structure.$parameter, value);"; - push(@lines, ($line, " }")); + $line = " retval = CCTK_SetKeyword(\&($structure.$parameter), value);" ; + } - elsif( $type eq "LOGICAL") + elsif( $type eq "STRING" || $type eq "SENTENCE") { - push(@lines, (" if(CCTK_InList(value, 4, \"true\", \"t\", \"yes\", \"1\"))"," {", "$structure.$parameter = 1", "}", "else if(CCTK_InList(value, 4, \"false\", \"f\", \"no\", \"0\"))"," {", "$structure.$parameter = 0", "}", "else", "{ ", "retval = 2" , "};")); + $line = " retval = CCTK_SetString(\&($structure.$parameter),value);" ; } else { print "Unknown parameter type $type\n"; } - + push(@lines, ($line, " }")); + return @lines; } |